:root {
  color-scheme: light;
  --ink: #1c2741;
  --blue: #233c85;
  --blue-light: #edf1fb;
  --muted: #59657a;
  --line: #d8dee8;
  --paper: #fff;
  --right: #146044;
  --wrong: #943a30;
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: #f4f6fa;
  line-height: 1.55;
}
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
button:focus-visible, a:focus-visible {
  outline: 3px solid #3459b8;
  outline-offset: 3px;
}
h1:focus { outline: none; }
h1, h2, p { margin: 0; }

.masthead { padding-top: env(safe-area-inset-top, 0px); background: var(--paper); border-bottom: 1px solid #dde2ec; }
.mast-inner, .layout { width: min(1120px, calc(100% - 64px)); margin-inline: auto; }
.mast-inner { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand, .quiet-button { display: inline-flex; align-items: center; }
.brand { gap: 12px; font-size: 1.23rem; font-weight: 750; color: var(--blue); letter-spacing: .035em; }
.brand-sub { font-size: .95rem; font-weight: 550; color: var(--muted); letter-spacing: .02em; }
.brand-divider { border-left: 1px solid #d1d8e4; height: 17px; }
.book-icon {
  display: inline-block;
  position: relative;
  width: 34px; height: 34px;
  background: var(--blue);
  border-radius: 9px;
}
.book-icon::before {
  content: "";
  position: absolute;
  inset: 8px 9px;
  border: 1.5px solid white;
  border-left-width: 3px;
  border-radius: 2px;
}
.book-icon::after {
  content: "";
  position: absolute;
  width: 4px; height: 9px;
  top: 8px; right: 12px;
  background: #ff9d83;
  clip-path: polygon(0 0,100% 0,100% 100%,50% 76%,0 100%);
}
.quiet-button {
  min-height: 44px;
  padding: 0 15px;
  gap: 9px;
  border-radius: 10px;
  border: 1px solid var(--line);
  color: var(--blue);
  background: #fff;
  font-size: .94rem;
  font-weight: 650;
}
.grid-icon {
  width: 14px; height: 14px;
  background: conic-gradient(from 90deg at 5px 5px, transparent 75%, currentColor 0) 0 0 / 8px 8px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(208px, 288px) minmax(0, 1fr);
  gap: clamp(20px, 2.6vw, 34px);
  align-items: start;
  margin-block: clamp(24px, 4.5vh, 48px);
}
.sidebar { display: grid; gap: 20px; min-width: 0; }
.practice-column { min-width: 0; }
.cover {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  padding: 28px;
  min-height: 294px;
  border-radius: 16px;
  background: linear-gradient(143deg, #263b77 0%, #294c92 74%, #415ead 100%);
  color: #fff;
}
.cover::before {
  content: "";
  position: absolute;
  top: 0; right: 23px;
  background: #ffac90;
  height: 39px; width: 17px;
  clip-path: polygon(0 0,100% 0,100% 100%,50% 82%,0 100%);
}
.cover-year {
  font-size: .82rem; font-weight: 650; letter-spacing: .12em;
  color: #e0e8ff;
}
.cover h2 { margin-top: 12px; font-size: clamp(1.45rem, 2vw, 1.85rem); line-height: 1.44; font-weight: 700; letter-spacing: .035em; }
.cover p { margin-top: 13px; font-size: .9rem; color: #e3eaff; }
.cover-art {
  pointer-events: none;
  position: absolute; width: 156px; height: 93px; right: -10px; bottom: 0;
  z-index: -1;
}
.sheet {
  position: absolute; right: 14px; bottom: -38px; width: 108px; height: 130px;
  border: 1px solid #a5b9e4; border-radius: 6px;
  transform: rotate(-14deg);
}
.shadow-sheet { right: 43px; bottom: -47px; background: #566fa4; transform: rotate(-26deg); }
.front-sheet {
  display: flex; flex-direction: column; gap: 9px;
  padding: 32px 14px 0; background: #c9d7ef;
  box-shadow: -5px 3px 0 #243c7140;
}
.front-sheet::before { content: ""; position: absolute; top: 15px; left: 14px; height: 4px; width: 37px; border-radius: 2px; background: #5873a6; }
.front-sheet b {
  width: 62px; height: 9px;
  background: radial-gradient(ellipse at 4px 4px, transparent 2px, #5674a8 2.3px 3.4px, transparent 3.7px) 0 0 / 14px 9px repeat-x;
}
.front-sheet b:nth-child(2)::before { content: ""; display: block; margin-left: 28px; width: 8px; height: 8px; border-radius: 50%; background: #456297; }
.side-info, .question-panel { background: var(--paper); border: 1px solid #dce2ea; border-radius: 16px; box-shadow: 0 4px 20px #1f345005; }
.side-info { padding: 23px; }
.side-info h2, .dialog-head h2 { font-size: 1.08rem; }
.side-count { display: flex; align-items: baseline; gap: 9px; margin-top: 12px; }
.side-count strong { font-size: 1.65rem; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.side-count small { font-size: 1rem; font-weight: 500; color: var(--muted); }
.side-count > span { color: var(--muted); font-size: .88rem; }
.progress-track { height: 6px; border-radius: 6px; margin-top: 9px; background: #e7eaf2; overflow: hidden; }
.progress-track i { display: block; width: 0; height: 100%; background: var(--blue); border-radius: inherit; }
.type-list { display: grid; margin-top: 16px; }
.type-button { background: none; border: 0; border-top: 1px solid #e8ebf1; min-height: 46px; display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left; padding: 5px 0; }
.type-name { font-size: .95rem; font-weight: 550; }
.type-value { color: var(--muted); font-size: .875rem; font-variant-numeric: tabular-nums; }

.question-panel { padding: clamp(26px, 3.4vw, 48px); }
.card-top, .meta-line { display: flex; align-items: center; gap: 10px; }
.card-top { justify-content: space-between; }
.meta-line { flex-wrap: wrap; }
.badge {
  display: inline-flex; align-items: center; border-radius: 6px;
  background: var(--blue-light); color: var(--blue); padding: 4px 10px;
  font-size: .88rem; font-weight: 700; letter-spacing: .035em;
}
#original-number, .position { color: var(--muted); font-size: .875rem; }
.position { white-space: nowrap; font-variant-numeric: tabular-nums; }
.question-panel h1 { margin-top: 28px; color: #18263e; font-size: clamp(1.45rem, 2.1vw, 1.875rem); font-weight: 670; line-height: 1.52; overflow-wrap: anywhere; }
.instruction { margin-top: 9px; font-size: .94rem; color: var(--muted); }
.options { display: grid; gap: 10px; margin-top: 23px; }
.option {
  display: flex; align-items: center; gap: 14px;
  width: 100%; min-width: 0; min-height: 58px; padding: 12px 16px;
  border: 1px solid #d4dce8; border-radius: 10px;
  background: #fff; text-align: left; line-height: 1.5; font-size: 1.04rem;
}
.option-key {
  flex: 0 0 auto; display: grid; place-items: center;
  min-width: 29px; height: 29px; padding-inline: 3px; border-radius: 7px;
  background: #eef1f6; color: #40516a; font-size: .94rem; font-weight: 650;
}
.option-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.option-mark { flex: 0 0 auto; font-size: .84rem; font-weight: 650; }
.option-mark:empty { display: none; }
.option.is-selected { border-color: #5471b2; background: #f2f5ff; }
.option.is-selected .option-key { color: white; background: var(--blue); }
.option.is-correct { color: var(--right); border-color: #76aa96; background: #eef8f3; }
.option.is-correct .option-key { color: #fff; background: var(--right); }
.option.is-incorrect { color: var(--wrong); border-color: #cd928b; background: #fff4f2; }
.option.is-incorrect .option-key { color: #fff; background: var(--wrong); }
.option.locked { cursor: default; }
.feedback-box { padding: 13px 16px; border-radius: 8px; margin-top: 16px; font-size: .96rem; background: #f1f4f9; overflow-wrap: anywhere; }
.feedback-box.right { color: var(--right); background: #eef8f3; }
.feedback-box.wrong { color: var(--wrong); background: #fff3f0; }
.feedback-title { font-weight: 700; }
.feedback-detail { font-size: .92rem; }
.feedback-detail:not(:empty) { margin-top: 3px; }
.action-row, .result-actions { display: flex; align-items: stretch; gap: 12px; margin-top: 26px; }
.action-row { padding-top: 22px; border-top: 1px solid #e3e7ed; }
.primary, .secondary { min-height: 46px; padding: 8px 20px; font-weight: 650; font-size: .98rem; border-radius: 9px; }
.primary { border: 1px solid var(--blue); color: #fff; background: var(--blue); }
.secondary { border: 1px solid #cdd6e4; color: var(--blue); background: #fff; }
.primary:disabled { color: #4e5b72; background: #e0e5ef; border-color: #d6dce7; }
.secondary:disabled { color: #687387; background: #f7f8fb; border-color: #e0e4eb; }
.action-row .secondary { margin-right: auto; }
.source-line, .save-note { font-size: .82rem; color: var(--muted); }
.source-line { margin-top: 16px; }
.save-note { padding: 11px 5px 0; text-align: center; }
.source-line:empty, .save-note:empty { display: none; }

dialog {
  color: var(--ink); background: #fff;
  width: min(480px, calc(100% - 24px)); max-height: 88vh; max-height: 88dvh;
  border: 1px solid var(--line); border-radius: 15px; padding: 0;
  box-shadow: 0 18px 70px #17223a33;
}
dialog::backdrop { background: #13223a80; }
#restart-dialog { width: min(380px, calc(100% - 24px)); }
.restart-form { padding: 24px; }
.restart-form h2 { font-size: 1.25rem; }
.restart-form p { margin-top: 8px; color: var(--muted); }
.restart-form .result-actions { justify-content: flex-end; }
.dialog-head {
  position: sticky; z-index: 1; top: 0; display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px 8px 22px; background: #fff; border-bottom: 1px solid #e1e5ec;
}
.dialog-head h2 { font-size: 1.25rem; }
.close-button { width: 44px; height: 44px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 1.7rem; }
.dialog-body { padding: 16px 22px 22px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: .875rem; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; border: 1px solid #8b96a6; }
.legend i.legend-right { background: #b0d9c7; border-color: #41856b; }
.legend i.legend-wrong { background: #f2bfb6; border-color: #a5645b; }
.grid-section { margin-top: 18px; }
.grid-section h3 { margin: 0 0 8px; font-size: 1rem; }
.grid-cells { display: grid; gap: 7px; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid-cell {
  min-height: 44px; padding: 4px 0; border: 1px solid var(--line); border-radius: 7px;
  background: #f8f9fc; color: var(--ink); font-size: .93rem; font-weight: 600; font-variant-numeric: tabular-nums;
}
.grid-cell.right { color: var(--right); background: #e4f3ec; border-color: #9cc4b3; }
.grid-cell.wrong { color: var(--wrong); background: #ffebe7; border-color: #e1ada5; }
.grid-cell.current { outline: 2px solid var(--blue); outline-offset: 1px; }
.grid-cell:focus-visible { outline-width: 3px; outline-offset: 3px; }
.score { display: flex; align-items: baseline; gap: 10px; margin: 18px 0 20px; color: var(--blue); }
.score strong { font-size: clamp(2.55rem, 7vw, 4rem); letter-spacing: -.045em; line-height: 1.15; }
.score span { font-weight: 600; }
.result-row { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.result-actions { flex-wrap: wrap; }

@media (hover: hover) {
  .option:not(.locked):not(:disabled):hover { border-color: #8498c6; background: #f4f6fc; }
  .primary:not(:disabled):hover { background: #172e6f; }
  .secondary:not(:disabled):hover, .quiet-button:hover, .close-button:hover { background: #f1f4fa; }
  .type-button:hover, .grid-cell:hover { color: var(--blue); text-decoration: underline; text-underline-offset: 3px; }
}
@media (max-width: 760px) {
  body { padding-bottom: env(safe-area-inset-bottom); }
  .mast-inner { width: 100%; min-height: 56px; padding: 4px max(16px, env(safe-area-inset-right)) 4px max(16px, env(safe-area-inset-left)); }
  .brand { gap: 8px; font-size: 1.1rem; }
  .brand-sub { font-size: .88rem; }
  .book-icon { width: 30px; height: 30px; }
  .book-icon::before { inset: 6px 7px; }
  .book-icon::after { top: 6px; right: 10px; }
  .quiet-button { gap: 7px; min-height: 44px; padding: 0 9px; border: 0; background: transparent; }
  .layout { display: block; width: min(570px, calc(100% - 24px)); margin-block: 14px 22px; }
  .sidebar { display: none; }
  .question-panel { padding: 19px 17px; border-radius: 13px; }
  .question-panel h1 { margin-top: 19px; font-size: clamp(1.21rem, 4.8vw, 1.48rem); }
  .instruction { font-size: .9rem; margin-top: 7px; }
  .options { margin-top: 17px; gap: 9px; }
  .option { min-height: 52px; padding: 10px 12px; gap: 10px; font-size: 1rem; }
  .option-key { min-width: 27px; height: 27px; }
  .action-row { margin-top: 20px; padding-top: 15px; }
  .action-row .primary, .action-row .secondary { padding-inline: 13px; }
  .source-line { margin-top: 12px; }
  .result-actions { margin-top: 20px; }
}
@media (max-width: 360px) {
  .layout { width: calc(100% - 14px); margin-top: 8px; }
  .question-panel { padding: 16px 12px; }
  .card-top, .meta-line, .action-row { gap: 6px; }
  .action-row .primary, .action-row .secondary { padding-inline: 10px; font-size: .93rem; }
  .option { padding-inline: 9px; gap: 8px; }
  .result-actions > button { flex: 1 1 auto; }
  .dialog-body { padding-inline: 15px; }
}
@media (max-height: 500px) and (min-width: 600px) {
  .mast-inner { min-height: 50px; }
  .layout { margin-block: 12px; }
  .question-panel h1 { margin-top: 14px; }
  .options { margin-top: 14px; }
}
