@layer reset, tokens, base, layout, components, views, utilities;

@layer reset {

  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  body,
  h1,
  h2,
  h3,
  h4,
  p,
  ul,
  ol,
  dl,
  dd,
  figure,
  fieldset {
    margin: 0;
  }

  ul[class],
  ol[class] {
    padding: 0;
    list-style: none;
  }

  img,
  svg {
    display: block;
    max-width: 100%;
  }

  button,
  input,
  textarea,
  select {
    font: inherit;
    color: inherit;
  }

  [hidden] {
    display: none !important;
  }
}

@layer tokens {
  :root {
    color-scheme: light dark;
    --paper: #F2F4F3;
    --surface: #FFFFFF;
    --surface-2: #F6F8F7;
    --ink: #15232A;
    --ink-2: #4A5C63;
    --line: #DCE2E0;
    --line-strong: #7F8F94;
    --brand: #2F5A66;
    --brand-hover: #254A54;
    --brand-ink: #FFFFFF;
    --brand-soft: #E1EBEC;
    --ok: #2B7656;
    --ok-soft: #E3F1EA;
    --on-ok: #FFFFFF;
    --bad: #B3362E;
    --bad-soft: #F7E4E2;
    --on-bad: #FFFFFF;
    --flag: #955C0E;
    --flag-soft: #F6ECDC;
    --disabled-bg: #E6EAE9;
    --disabled-ink: #7C8B90;
    --focus: #2F5A66;
    --backdrop: rgb(15 23 26 / 0.45);
    --shadow-1: 0 1px 2px rgb(21 35 42 / 0.06);
    --shadow-2: 0 12px 32px rgb(21 35 42 / 0.16);
    --show-when-light: inline-flex;
    --show-when-dark: none;
    --logo-tile: transparent;
    --font-sans: "Segoe UI", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
    --font-mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
    --fs-12: 0.75rem;
    --fs-13: 0.8125rem;
    --fs-14: 0.875rem;
    --fs-16: 1rem;
    --fs-18: 1.125rem;
    --fs-20: 1.25rem;
    --fs-28: 1.75rem;
    --fs-48: 3rem;
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-6: 24px;
    --sp-8: 32px;
    --sp-12: 48px;
    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 16px;
    --r-full: 999px;
    --dur-fast: 120ms;
    --dur: 200ms;
    --ease: cubic-bezier(0.2, 0, 0, 1);
    --z-sticky: 10;
    --z-dock: 20;
    --z-toast: 40;
    --container: 1120px;
    --gutter: 16px;
    --app-bar-h: 56px;
  }

  @media (prefers-color-scheme: dark) {
    :root:not(:has(> head > meta[name="color-scheme"][content="light"])) {
      --paper: #0F171A;
      --surface: #172328;
      --surface-2: #1C2A30;
      --ink: #E3EAEA;
      --ink-2: #9DAEB2;
      --line: #2A3A40;
      --line-strong: #5E7279;
      --brand: #86B9C4;
      --brand-hover: #9CC8D1;
      --brand-ink: #0F1A1D;
      --brand-soft: #1D333A;
      --ok: #7CCBA4;
      --ok-soft: #173126;
      --on-ok: #0F1A1D;
      --bad: #F28B82;
      --bad-soft: #3A1F1D;
      --on-bad: #1A0F0E;
      --flag: #E5B266;
      --flag-soft: #33281A;
      --disabled-bg: #24343A;
      --disabled-ink: #6F8288;
      --focus: #86B9C4;
      --backdrop: rgb(0 0 0 / 0.6);
      --shadow-1: 0 1px 2px rgb(0 0 0 / 0.4);
      --shadow-2: 0 12px 32px rgb(0 0 0 / 0.5);
      --show-when-light: none;
      --show-when-dark: inline-flex;
      --logo-tile: #E3EAEA;
    }
  }

  :root:has(> head > meta[name="color-scheme"][content="dark"]) {
    color-scheme: dark;
    --paper: #0F171A;
    --surface: #172328;
    --surface-2: #1C2A30;
    --ink: #E3EAEA;
    --ink-2: #9DAEB2;
    --line: #2A3A40;
    --line-strong: #5E7279;
    --brand: #86B9C4;
    --brand-hover: #9CC8D1;
    --brand-ink: #0F1A1D;
    --brand-soft: #1D333A;
    --ok: #7CCBA4;
    --ok-soft: #173126;
    --on-ok: #0F1A1D;
    --bad: #F28B82;
    --bad-soft: #3A1F1D;
    --on-bad: #1A0F0E;
    --flag: #E5B266;
    --flag-soft: #33281A;
    --disabled-bg: #24343A;
    --disabled-ink: #6F8288;
    --focus: #86B9C4;
    --backdrop: rgb(0 0 0 / 0.6);
    --shadow-1: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-2: 0 12px 32px rgb(0 0 0 / 0.5);
    --show-when-light: none;
    --show-when-dark: inline-flex;
    --logo-tile: #E3EAEA;
  }

  :root:has(> head > meta[name="color-scheme"][content="light"]) {
    color-scheme: light;
  }

  @media (min-width: 640px) {
    :root {
      --gutter: 24px;
    }
  }

  @media (min-width: 1024px) {
    :root {
      --gutter: 32px;
    }
  }
}

@layer base {
  html {
    font-family: var(--font-sans);
    font-size: 100%;
    line-height: 1.6;
    color: var(--ink);
    background: var(--paper);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    accent-color: var(--brand);
    scrollbar-gutter: stable;
  }

  body {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--paper);
  }

  h1,
  h2,
  h3,
  h4 {
    line-height: 1.3;
    font-weight: 700;
    text-wrap: balance;
  }

  a {
    color: var(--brand);
    text-underline-offset: 3px;
  }

  :focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
  }

  [tabindex="-1"]:focus {
    outline: none;
  }

  kbd {
    display: inline-block;
    min-width: 1.6em;
    padding: 0 5px;
    border: 1px solid var(--line-strong);
    border-bottom-width: 2px;
    border-radius: 5px;
    background: var(--surface-2);
    color: var(--ink);
    font-family: var(--font-mono);
    font-size: var(--fs-12);
    line-height: 1.5;
    text-align: center;
  }

  ::selection {
    background: var(--brand-soft);
    color: var(--ink);
  }

  @media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
      scroll-behavior: auto !important;
    }
  }
}

@layer layout {
  .container {
    width: 100%;
    max-width: calc(var(--container) + var(--gutter) * 2);
    margin-inline: auto;
    padding-inline: var(--gutter);
  }

  .skip-link {
    position: fixed;
    top: var(--sp-2);
    left: var(--sp-2);
    z-index: var(--z-toast);
    padding: var(--sp-2) var(--sp-4);
    border-radius: var(--r-md);
    background: var(--ink);
    color: var(--paper);
    font-weight: 700;
    text-decoration: none;
    transform: translateY(-200%);
  }

  .skip-link:focus-visible {
    transform: none;
  }

  .app-bar {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
  }

  .app-bar__inner {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    min-height: var(--app-bar-h);
  }

  .brand {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    min-height: 44px;
    margin-right: auto;
    color: var(--ink);
    font-weight: 700;
    font-size: var(--fs-18);
    text-decoration: none;
  }

  .brand__logo {
    width: 32px;
    height: 32px;
    padding: 2px;
    border-radius: 8px;
    background: var(--logo-tile);
  }

  .app-nav__link {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    min-height: 44px;
    padding-inline: var(--sp-3);
    border-radius: var(--r-md);
    color: var(--ink);
    font-weight: 600;
    text-decoration: none;
  }

  .app-nav__link[aria-current="page"] {
    background: var(--brand-soft);
    color: var(--brand);
  }

  .app-main {
    flex: 1;
  }

  .app-main:focus {
    outline: none;
  }

  .view {
    padding-block: var(--sp-6) var(--sp-12);
  }

  .app-footer {
    border-top: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink-2);
    font-size: var(--fs-14);
  }

  .app-footer__inner {
    display: grid;
    gap: var(--sp-2);
    padding-block: var(--sp-6);
  }

  .app-footer__links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-1) var(--sp-4);
  }

  .app-footer a,
  .link-button {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
  }

  .link-button {
    min-height: 44px;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
  }

  body[data-view="exam"] .app-bar,
  body[data-view="exam"] .app-footer {
    display: none;
  }

  @media (min-width: 1024px) {
    .view {
      padding-block: var(--sp-8) var(--sp-12);
    }
  }
}

@layer components {
  .icon {
    width: 1.25em;
    height: 1.25em;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  [data-when-scheme="light"] {
    display: var(--show-when-light);
  }

  [data-when-scheme="dark"] {
    display: var(--show-when-dark);
  }

  .btn {
    --btn-bg: var(--surface);
    --btn-fg: var(--ink);
    --btn-border: var(--line-strong);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    min-height: 44px;
    padding: 0 var(--sp-4);
    border: 1px solid var(--btn-border);
    border-radius: var(--r-md);
    background: var(--btn-bg);
    color: var(--btn-fg);
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    touch-action: manipulation;
    transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
  }

  .btn:active:not(:disabled) {
    transform: scale(0.98);
  }

  .btn--primary {
    --btn-bg: var(--brand);
    --btn-fg: var(--brand-ink);
    --btn-border: var(--brand);
  }

  .btn--ghost {
    --btn-bg: transparent;
    --btn-border: transparent;
  }

  .btn--danger {
    --btn-bg: var(--bad);
    --btn-fg: var(--on-bad);
    --btn-border: var(--bad);
  }

  .btn--sm {
    min-height: 36px;
    padding: 0 var(--sp-3);
    font-size: var(--fs-14);
  }

  .btn--lg {
    min-height: 52px;
    padding: 0 var(--sp-6);
    font-size: var(--fs-16);
  }

  .btn--block {
    width: 100%;
  }

  .btn:disabled {
    --btn-bg: var(--disabled-bg);
    --btn-fg: var(--disabled-ink);
    --btn-border: var(--disabled-bg);
    cursor: not-allowed;
  }

  .btn[aria-pressed="true"] {
    --btn-bg: var(--flag-soft);
    --btn-fg: var(--flag);
    --btn-border: var(--flag);
  }

  @media (hover: hover) {
    .btn:hover:not(:disabled) {
      --btn-bg: var(--surface-2);
    }

    .btn--primary:hover:not(:disabled) {
      --btn-bg: var(--brand-hover);
      --btn-border: var(--brand-hover);
    }

    .btn--ghost:hover:not(:disabled) {
      --btn-bg: var(--brand-soft);
    }

    .btn--danger:hover:not(:disabled) {
      --btn-bg: var(--bad);
      filter: brightness(1.08);
    }
  }

  @media (pointer: coarse) {
    .btn--sm {
      min-height: 44px;
    }
  }

  .icon-btn {
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: var(--r-md);
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    touch-action: manipulation;
  }

  @media (hover: hover) {
    .icon-btn:hover {
      background: var(--brand-soft);
    }
  }

  .tag {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    padding: 1px var(--sp-2);
    border-radius: var(--r-sm);
    background: var(--brand-soft);
    color: var(--brand);
    font-size: var(--fs-12);
    font-weight: 700;
    line-height: 1.6;
    white-space: nowrap;
  }

  .tag--neutral {
    background: var(--surface-2);
    color: var(--ink-2);
  }

  .tag--ok {
    background: var(--ok-soft);
    color: var(--ok);
  }

  .tag--bad {
    background: var(--bad-soft);
    color: var(--bad);
  }

  .tag--flag {
    background: var(--flag-soft);
    color: var(--flag);
  }

  .card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-1);
  }

  .page-title {
    font-size: var(--fs-28);
  }

  .page-lead {
    max-width: 40em;
    margin-top: var(--sp-2);
    color: var(--ink-2);
    text-wrap: pretty;
  }

  .section-title {
    font-size: var(--fs-20);
  }

  .input {
    width: 100%;
    min-height: 44px;
    padding: 0 var(--sp-3);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-md);
    background: var(--surface);
    color: var(--ink);
    font-size: var(--fs-16);
  }

  textarea.input {
    min-height: 140px;
    padding: var(--sp-3);
    line-height: 1.6;
    resize: vertical;
  }

  .input:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 1px;
  }

  .input[aria-invalid="true"] {
    border-color: var(--bad);
  }

  .sr-input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
    opacity: 0;
  }

  .field {
    display: grid;
    gap: var(--sp-2);
    min-width: 0;
    padding: 0;
    border: 0;
  }

  .field__label {
    padding: 0;
    color: var(--ink-2);
    font-size: var(--fs-14);
    font-weight: 700;
  }

  .field__hint {
    color: var(--ink-2);
    font-size: var(--fs-14);
  }

  .field__error {
    color: var(--bad);
    font-size: var(--fs-14);
    font-weight: 600;
  }

  .segmented {
    display: grid;
    grid-auto-columns: minmax(0, 1fr);
    grid-auto-flow: column;
    gap: 3px;
    padding: 3px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-md);
    background: var(--surface-2);
  }

  .segmented__item {
    position: relative;
    display: block;
  }

  .segmented__label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-1);
    min-height: 40px;
    padding: 0 var(--sp-3);
    border-radius: 7px;
    color: var(--ink-2);
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
  }

  .segmented__item input:checked+.segmented__label {
    background: var(--brand);
    color: var(--brand-ink);
  }

  .segmented__item input:focus-visible+.segmented__label {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
  }

  .segmented--sm .segmented__label {
    min-height: 32px;
    padding: 0 var(--sp-2);
    font-size: var(--fs-13);
  }

  .segmented__count {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    opacity: 0.85;
  }

  .chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
  }

  .chip {
    position: relative;
  }

  .chip__label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 56px;
    min-height: 40px;
    padding: 0 var(--sp-4);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-full);
    background: var(--surface);
    color: var(--ink);
    font-weight: 600;
    cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
  }

  .chip input:checked+.chip__label {
    border-color: var(--brand);
    background: var(--brand);
    color: var(--brand-ink);
  }

  .chip input:focus-visible+.chip__label {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
  }

  .chip input:disabled+.chip__label {
    border-color: var(--disabled-bg);
    background: var(--disabled-bg);
    color: var(--disabled-ink);
    cursor: not-allowed;
  }

  @media (pointer: coarse) {

    .chip__label,
    .segmented__label,
    .segmented--sm .segmented__label {
      min-height: 44px;
    }
  }

  .switch {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--sp-3);
    min-height: 44px;
    cursor: pointer;
  }

  .switch__text {
    display: grid;
    font-weight: 600;
  }

  .switch__hint {
    color: var(--ink-2);
    font-size: var(--fs-13);
    font-weight: 400;
  }

  .switch__input {
    position: relative;
    width: 44px;
    height: 26px;
    margin: 0;
    border-radius: var(--r-full);
    background: var(--line-strong);
    cursor: pointer;
    appearance: none;
    transition: background-color var(--dur) var(--ease);
  }

  .switch__input::before {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--surface);
    box-shadow: var(--shadow-1);
    transition: transform var(--dur) var(--ease);
  }

  .switch__input:checked {
    background: var(--brand);
  }

  .switch__input:checked::before {
    transform: translateX(18px);
  }

  .number-field {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 96px auto;
    align-items: center;
    gap: var(--sp-3);
    font-weight: 600;
  }

  .number-field .input {
    text-align: center;
    font-variant-numeric: tabular-nums;
  }

  .progress {
    display: block;
    width: 100%;
    height: 6px;
    border: 0;
    border-radius: var(--r-full);
    background: var(--brand-soft);
    overflow: hidden;
    appearance: none;
  }

  .progress::-webkit-progress-bar {
    border-radius: var(--r-full);
    background: var(--brand-soft);
  }

  .progress::-webkit-progress-value {
    border-radius: var(--r-full);
    background: var(--brand);
  }

  .progress::-moz-progress-bar {
    border-radius: var(--r-full);
    background: var(--brand);
  }

  .disclosure {
    border-top: 1px solid var(--line);
  }

  .disclosure>summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2);
    min-height: 48px;
    font-weight: 700;
    list-style: none;
    cursor: pointer;
  }

  .disclosure>summary::-webkit-details-marker {
    display: none;
  }

  .disclosure__chevron,
  .review-item__chevron {
    color: var(--ink-2);
    transition: transform var(--dur) var(--ease);
  }

  .disclosure[open] .disclosure__chevron,
  .review-item[open] .review-item__chevron {
    transform: rotate(180deg);
  }

  .disclosure__body {
    display: grid;
    gap: var(--sp-2);
    padding-bottom: var(--sp-2);
  }

  .alert {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    gap: var(--sp-1) var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    border: 1px solid var(--bad);
    border-radius: var(--r-md);
    background: var(--bad-soft);
    color: var(--ink);
  }

  .alert>.icon {
    margin-top: 2px;
    color: var(--bad);
  }

  .alert__body {
    display: grid;
    gap: var(--sp-2);
    justify-items: start;
  }

  .badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: var(--sp-1) var(--sp-3);
    border-radius: var(--r-full);
    font-size: var(--fs-14);
    font-weight: 700;
  }

  .badge--ok {
    background: var(--ok-soft);
    color: var(--ok);
  }

  .badge--bad {
    background: var(--bad-soft);
    color: var(--bad);
  }

  .badge--neutral {
    background: var(--surface-2);
    color: var(--ink-2);
  }

  .dialog {
    width: min(100% - 32px, 480px);
    max-height: min(100dvh - 32px, 760px);
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-2);
  }

  .dialog--wide {
    width: min(100% - 32px, 560px);
  }

  .dialog:modal,
  .sheet:modal {
    overscroll-behavior: contain;
  }

  .dialog::backdrop,
  .sheet::backdrop {
    overflow: hidden;
    overscroll-behavior: contain;
    background: var(--backdrop);
  }

  .dialog__inner {
    display: grid;
    gap: var(--sp-4);
    padding: var(--sp-6);
  }

  .dialog__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2);
  }

  .dialog__title {
    font-size: var(--fs-20);
  }

  .dialog__body {
    display: grid;
    gap: var(--sp-3);
    color: var(--ink);
  }

  .dialog__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: var(--sp-2);
  }

  .dialog__actions--split {
    justify-content: space-between;
  }

  .dialog__actions-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
  }

  .sheet {
    width: 100%;
    max-width: none;
    max-height: 85dvh;
    margin: auto 0 0;
    padding: 0;
    border: 0;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-2);
  }

  .sheet__inner {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: var(--sp-3);
    max-height: 85dvh;
    padding: var(--sp-4) var(--gutter) calc(var(--sp-4) + env(safe-area-inset-bottom));
  }

  @media (min-width: 640px) {
    .sheet {
      width: min(100% - 32px, 560px);
      margin: auto;
      border-radius: var(--r-lg);
    }
  }

  @media (prefers-reduced-motion: no-preference) {
    .dialog[open] {
      animation: rise-in var(--dur) var(--ease);
    }

    .sheet[open] {
      animation: sheet-in 260ms var(--ease);
    }

    @media (min-width: 640px) {
      .sheet[open] {
        animation: rise-in var(--dur) var(--ease);
      }
    }
  }

  @keyframes rise-in {
    from {
      opacity: 0;
      transform: translateY(8px);
    }
  }

  @keyframes sheet-in {
    from {
      transform: translateY(100%);
    }
  }

  @media (max-width: 479px) {

    .dialog__actions,
    .dialog__actions-group {
      flex-direction: column-reverse;
      align-items: stretch;
    }
  }

  .toast-region {
    position: fixed;
    inset-inline: 0;
    bottom: calc(var(--sp-4) + env(safe-area-inset-bottom));
    z-index: var(--z-toast);
    display: grid;
    justify-items: center;
    gap: var(--sp-2);
    padding-inline: var(--sp-4);
    pointer-events: none;
  }

  .toast {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    max-width: 480px;
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--r-md);
    background: var(--ink);
    color: var(--paper);
    box-shadow: var(--shadow-2);
    font-size: 0.9375rem;
    pointer-events: auto;
  }

  @media (prefers-reduced-motion: no-preference) {
    .toast {
      animation: rise-in var(--dur) var(--ease);
    }
  }

  .empty-state {
    display: grid;
    justify-items: center;
    gap: var(--sp-3);
    padding: var(--sp-12) var(--sp-4);
    color: var(--ink-2);
    text-align: center;
  }

  .empty-state>.icon {
    width: 40px;
    height: 40px;
    color: var(--line-strong);
  }

  .empty-state__title {
    color: var(--ink);
    font-size: var(--fs-18);
  }

  .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--brand-soft);
    border-top-color: var(--brand);
    border-radius: 50%;
  }

  @media (prefers-reduced-motion: no-preference) {
    .spinner {
      animation: spin 0.8s linear infinite;
    }
  }

  @keyframes spin {
    to {
      transform: rotate(360deg);
    }
  }

  .visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }

  @media (forced-colors: active) {
    .switch__input {
      appearance: auto;
    }

    .switch__input::before {
      display: none;
    }

    .segmented__item input:checked+.segmented__label,
    .chip input:checked+.chip__label {
      outline: 2px solid CanvasText;
    }
  }
}

@layer views {
  .boot {
    display: grid;
    place-items: center;
    gap: var(--sp-4);
    min-height: calc(100dvh - var(--app-bar-h));
    text-align: center;
  }

  .boot__panel {
    display: grid;
    justify-items: center;
    gap: var(--sp-3);
    max-width: 480px;
  }

  /* 首頁 */
  .home-intro {
    margin-bottom: var(--sp-6);
  }

  .resume-card {
    display: grid;
    gap: var(--sp-4);
    margin-bottom: var(--sp-6);
    padding: var(--sp-4) var(--sp-6);
    border-color: var(--brand);
  }

  .resume-card__title {
    font-size: var(--fs-18);
  }

  .resume-card__bank {
    margin-top: var(--sp-1);
    font-weight: 700;
  }

  .resume-card__meta {
    color: var(--ink-2);
    font-size: var(--fs-14);
  }

  .resume-card__progress {
    max-width: 320px;
    margin-top: var(--sp-2);
  }

  .resume-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
  }

  @media (min-width: 720px) {
    .resume-card {
      grid-template-columns: minmax(0, 1fr) auto;
      align-items: center;
    }
  }

  .home-layout {
    display: grid;
    gap: var(--sp-6);
  }

  .bank-picker__title {
    margin-bottom: var(--sp-4);
  }

  .bank-group {
    min-width: 0;
    margin: 0 0 var(--sp-6);
    padding: 0;
    border: 0;
  }

  .bank-group__title {
    margin-bottom: var(--sp-3);
    padding: 0;
    color: var(--ink-2);
    font-size: var(--fs-14);
    font-weight: 700;
    letter-spacing: 0.04em;
  }

  .bank-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
    gap: var(--sp-3);
  }

  @media (max-width: 639px) {
    .bank-grid {
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: var(--sp-2);
    }

    .bank-card {
      min-height: 0;
      padding: var(--sp-3);
    }

    .bank-card__check {
      top: var(--sp-2);
      right: var(--sp-2);
    }
  }

  .bank-card {
    position: relative;
    display: grid;
    align-content: start;
    gap: 2px;
    min-height: 116px;
    padding: var(--sp-4);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--surface);
    cursor: pointer;
    transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
  }

  .bank-card:has(input:checked) {
    border-color: var(--brand);
    background: var(--brand-soft);
    box-shadow: inset 0 0 0 1px var(--brand);
  }

  .bank-card:has(input:focus-visible) {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
  }

  @media (hover: hover) {
    .bank-card:hover {
      border-color: var(--line-strong);
    }
  }

  .bank-card__check {
    position: absolute;
    top: var(--sp-3);
    right: var(--sp-3);
    display: none;
    color: var(--brand);
  }

  .bank-card:has(input:checked) .bank-card__check {
    display: block;
  }

  .bank-card__title {
    padding-right: var(--sp-6);
    font-size: var(--fs-16);
    font-weight: 700;
  }

  .bank-card__subtitle {
    color: var(--ink-2);
    font-size: var(--fs-14);
  }

  .bank-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-1) var(--sp-2);
    margin-top: var(--sp-2);
    color: var(--ink-2);
    font-size: var(--fs-13);
  }

  .bank-card__score {
    margin-top: var(--sp-1);
    font-size: var(--fs-13);
    font-weight: 700;
  }

  .start-panel {
    display: grid;
    gap: var(--sp-6);
    padding: var(--sp-6);
  }

  .start-panel__bank {
    display: grid;
    gap: 2px;
  }

  .start-panel__bank-label {
    color: var(--ink-2);
    font-size: var(--fs-14);
    font-weight: 700;
  }

  .start-panel__bank-name {
    font-size: var(--fs-18);
    font-weight: 700;
  }

  .start-panel__bank-meta {
    color: var(--ink-2);
    font-size: var(--fs-14);
  }

  .start-panel__note {
    color: var(--ink-2);
    font-size: var(--fs-13);
    text-align: center;
  }

  .start-panel__go {
    display: grid;
    gap: var(--sp-2);
  }

  .custom-count {
    display: grid;
    grid-template-columns: auto 120px;
    align-items: center;
    gap: var(--sp-3);
  }

  .custom-count .input {
    text-align: center;
    font-variant-numeric: tabular-nums;
  }

  .floating-cta {
    position: fixed;
    inset-inline: 0;
    bottom: 0;
    z-index: var(--z-dock);
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--gutter) calc(var(--sp-3) + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: var(--surface);
    box-shadow: var(--shadow-2);
  }

  .floating-cta__bank {
    min-width: 0;
    color: var(--ink-2);
    font-size: var(--fs-13);
    line-height: 1.4;
  }

  .floating-cta__bank strong {
    display: block;
    overflow: hidden;
    color: var(--ink);
    font-size: var(--fs-14);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .floating-cta .btn {
    flex: none;
    margin-left: auto;
  }

  body:has(.floating-cta:not([hidden])) .app-footer {
    padding-bottom: 76px;
  }

  @media (min-width: 1024px) {
    .home-layout {
      grid-template-columns: minmax(0, 1fr) 360px;
      align-items: start;
    }

    .start-panel {
      position: sticky;
      top: calc(var(--app-bar-h) + var(--sp-6));
    }

    .floating-cta {
      display: none;
    }
  }

  /* 考試頁 */
  .view--exam {
    padding-block: 0;
  }

  .exam-bar {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
  }

  .exam-bar__inner {
    display: grid;
    grid-template-areas:
      "leave title submit"
      "progress progress timer";
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--sp-2) var(--sp-3);
    padding-block: var(--sp-2);
  }

  .exam-bar__leave {
    grid-area: leave;
  }

  .exam-bar__title {
    grid-area: title;
    min-width: 0;
  }

  .exam-bar__bank-full {
    display: none;
  }

  @media (min-width: 960px) {
    .exam-bar__bank-full {
      display: inline;
    }

    .exam-bar__bank-short {
      display: none;
    }
  }

  .exam-bar__bank {
    overflow: hidden;
    font-size: var(--fs-16);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .exam-bar__sub {
    color: var(--ink-2);
    font-size: var(--fs-13);
  }

  .exam-bar__progress {
    grid-area: progress;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: var(--sp-3);
    color: var(--ink-2);
    font-size: var(--fs-13);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  .exam-bar__timer {
    grid-area: timer;
    display: flex;
    align-items: center;
    gap: var(--sp-1);
    color: var(--ink-2);
    font-family: var(--font-mono);
    font-size: var(--fs-14);
    font-variant-numeric: tabular-nums;
  }

  .exam-bar__timer .icon-btn {
    width: 40px;
    height: 40px;
  }

  .exam-bar__submit {
    grid-area: submit;
  }

  .exam-bar__leave-text {
    display: none;
  }

  @media (min-width: 960px) {
    .exam-bar__inner {
      grid-template-areas: "leave title progress timer submit";
      grid-template-columns: auto minmax(0, 1fr) minmax(160px, 220px) auto auto;
      gap: var(--sp-4);
      min-height: 64px;
    }

    .exam-bar__progress {
      grid-template-columns: minmax(0, 1fr);
      gap: var(--sp-1);
    }

    .exam-bar__leave-text {
      display: inline;
    }
  }

  .exam-layout {
    display: grid;
    gap: var(--sp-6);
    padding-block: var(--sp-6) calc(var(--sp-12) + 72px + env(safe-area-inset-bottom));
  }

  @media (min-width: 960px) {
    .exam-layout {
      grid-template-columns: minmax(0, 1fr) 280px;
      align-items: start;
      padding-bottom: var(--sp-12);
    }
  }

  .question {
    padding: var(--sp-4);
  }

  @media (min-width: 640px) {
    .question {
      padding: var(--sp-6);
    }
  }

  .question__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2);
    margin-bottom: var(--sp-3);
  }

  .question__no {
    font-size: var(--fs-16);
    font-variant-numeric: tabular-nums;
  }

  .question__flag {
    margin-left: auto;
  }

  .question__stem {
    max-width: 40em;
    margin-bottom: var(--sp-6);
    font-size: var(--fs-18);
    font-weight: 500;
    text-wrap: pretty;
    line-height: 1.7;
    white-space: pre-line;
    overflow-wrap: anywhere;
  }

  .options {
    display: grid;
    gap: 10px;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
  }

  .option {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    min-height: 52px;
    padding: var(--sp-3) 14px;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    font-size: var(--fs-16);
    cursor: pointer;
    transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
  }

  .option__key {
    display: grid;
    flex: none;
    place-items: center;
    width: 30px;
    height: 30px;
    border: 1.5px solid var(--line-strong);
    border-radius: 8px;
    color: var(--ink-2);
    font-family: var(--font-mono);
    font-size: var(--fs-14);
    font-weight: 700;
  }

  .option__text {
    flex: 1;
    min-width: 0;
    padding-top: 2px;
    line-height: 1.6;
    overflow-wrap: anywhere;
  }

  .option__mark {
    display: inline-flex;
    flex: none;
    align-items: center;
    align-self: center;
    gap: var(--sp-1);
    font-size: var(--fs-13);
    font-weight: 700;
    white-space: nowrap;
  }

  .option:has(input:checked) {
    border-color: var(--brand);
    background: var(--brand-soft);
  }

  .option:has(input:checked) .option__key {
    border-color: var(--brand);
    background: var(--brand);
    color: var(--brand-ink);
  }

  .option:has(input:focus-visible) {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
  }

  .option:has(input:disabled) {
    cursor: default;
  }

  @media (hover: hover) {
    .option:not(:has(input:disabled)):hover {
      border-color: var(--line-strong);
    }

    .option:has(input:checked):not(:has(input:disabled)):hover {
      border-color: var(--brand);
    }
  }

  .option.is-correct,
  .option.is-correct:has(input:checked) {
    border-color: var(--ok);
    background: var(--ok-soft);
  }

  .option.is-correct .option__key,
  .option.is-correct:has(input:checked) .option__key {
    border-color: var(--ok);
    background: var(--ok);
    color: var(--on-ok);
  }

  .option.is-correct .option__mark {
    color: var(--ok);
  }

  .option.is-wrong,
  .option.is-wrong:has(input:checked) {
    border-color: var(--bad);
    background: var(--bad-soft);
  }

  .option.is-wrong .option__key,
  .option.is-wrong:has(input:checked) .option__key {
    border-color: var(--bad);
    background: var(--bad);
    color: var(--on-bad);
  }

  .option.is-wrong .option__mark {
    color: var(--bad);
  }

  .saq {
    display: grid;
    gap: var(--sp-2);
  }

  .saq__label {
    color: var(--ink-2);
    font-size: var(--fs-14);
    font-weight: 700;
  }

  .choice {
    display: grid;
    gap: var(--sp-4);
  }

  .answer-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
  }

  .feedback {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2);
    margin-top: var(--sp-4);
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--r-md);
    font-weight: 700;
  }

  .feedback--correct {
    background: var(--ok-soft);
    color: var(--ok);
  }

  .feedback--wrong {
    background: var(--bad-soft);
    color: var(--bad);
  }

  .feedback--pending {
    background: var(--brand-soft);
    color: var(--ink);
  }

  .reference,
  .explanation {
    margin-top: var(--sp-4);
    padding: var(--sp-4);
    border-left: 4px solid var(--brand);
    border-radius: var(--r-md);
    background: var(--surface-2);
  }

  .reference__title,
  .explanation__title {
    margin-bottom: var(--sp-1);
    color: var(--ink-2);
    font-size: var(--fs-14);
  }

  .reference__text,
  .explanation__text {
    line-height: 1.7;
    white-space: pre-line;
    overflow-wrap: anywhere;
    text-wrap: pretty;
  }

  .self-grade {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2);
    margin-top: var(--sp-3);
  }

  .self-grade__prompt {
    margin-right: var(--sp-2);
    font-weight: 600;
  }

  .self-grade .btn[aria-pressed="true"][data-grade="correct"] {
    --btn-bg: var(--ok-soft);
    --btn-fg: var(--ok);
    --btn-border: var(--ok);
  }

  .self-grade .btn[aria-pressed="true"][data-grade="wrong"] {
    --btn-bg: var(--bad-soft);
    --btn-fg: var(--bad);
    --btn-border: var(--bad);
  }

  .question__nav {
    display: none;
  }

  @media (min-width: 960px) {
    .question__nav {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: var(--sp-3);
      margin-top: var(--sp-6);
      padding-top: var(--sp-4);
      border-top: 1px solid var(--line);
    }
  }

  .question__hint {
    color: var(--ink-2);
    font-size: var(--fs-13);
    text-align: center;
  }

  @media (hover: none),
  (pointer: coarse) {
    .question__hint {
      visibility: hidden;
    }
  }

  .qmap-panel {
    display: none;
  }

  @media (min-width: 960px) {
    .qmap-panel {
      position: sticky;
      top: calc(var(--exam-bar-h, 64px) + var(--sp-4));
      display: flex;
      flex-direction: column;
      gap: var(--sp-3);
      max-height: calc(100dvh - var(--exam-bar-h, 64px) - var(--sp-8));
      padding: var(--sp-4);
    }
  }

  .qmap-panel__title {
    font-size: var(--fs-14);
  }

  .qmap {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    min-height: 0;
  }

  .qmap__legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-1) var(--sp-3);
    color: var(--ink-2);
    font-size: var(--fs-12);
  }

  .qmap__legend span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
  }

  .qmap__swatch {
    position: relative;
    width: 12px;
    height: 12px;
    border: 1.5px solid var(--line-strong);
    border-radius: 3px;
  }

  .qmap__swatch--current {
    border: 2px solid var(--brand);
  }

  .qmap__swatch--answered {
    border-color: transparent;
    background: var(--brand-soft);
    box-shadow: inset 0 0 0 1px var(--brand);
  }

  .qmap__swatch--correct {
    border-color: transparent;
    background: var(--ok-soft);
    box-shadow: inset 0 0 0 1px var(--ok);
  }

  .qmap__swatch--wrong {
    border-color: transparent;
    background: var(--bad-soft);
    box-shadow: inset 0 0 0 1px var(--bad);
  }

  .qmap__swatch--flag {
    width: 8px;
    height: 8px;
    border: 0;
    border-radius: 50%;
    background: var(--flag);
  }

  .qmap__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
    gap: 6px;
    min-height: 0;
    padding: 3px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .qmap__cell {
    position: relative;
    display: grid;
    place-items: center;
    width: 100%;
    min-height: 36px;
    aspect-ratio: 1;
    padding: 0;
    border: 1.5px solid var(--line-strong);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink-2);
    font-family: var(--font-mono);
    font-size: var(--fs-13);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    touch-action: manipulation;
  }

  .qmap__cell.is-answered {
    border-color: transparent;
    background: var(--brand-soft);
    box-shadow: inset 0 0 0 1px var(--brand);
    color: var(--ink);
  }

  .qmap__cell.is-correct {
    border-color: transparent;
    background: var(--ok-soft);
    box-shadow: inset 0 0 0 1px var(--ok);
    color: var(--ok);
  }

  .qmap__cell.is-wrong {
    border-color: transparent;
    background: var(--bad-soft);
    box-shadow: inset 0 0 0 1px var(--bad);
    color: var(--bad);
  }

  .qmap__cell[aria-current="step"] {
    border: 2px solid var(--brand);
    box-shadow: none;
    color: var(--brand);
  }

  .qmap__cell.is-flagged::after {
    content: "";
    position: absolute;
    top: 3px;
    right: 3px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--flag);
  }

  .qmap__mark {
    position: absolute;
    right: 2px;
    bottom: 2px;
    width: 10px;
    height: 10px;
    stroke-width: 3;
  }

  @media (hover: hover) {
    .qmap__cell:hover {
      border-color: var(--brand);
    }
  }

  .qmap__empty {
    color: var(--ink-2);
    font-size: var(--fs-14);
  }

  .sheet .qmap__grid {
    grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  }

  .exam-dock {
    position: fixed;
    inset-inline: 0;
    bottom: 0;
    z-index: var(--z-dock);
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--gutter) calc(var(--sp-2) + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: var(--surface);
  }

  .exam-dock .btn {
    min-height: 48px;
  }

  .exam-dock__map {
    font-variant-numeric: tabular-nums;
  }

  @media (min-width: 960px) {
    .exam-dock {
      display: none;
    }
  }

  body[data-view="exam"] .toast-region {
    bottom: calc(80px + env(safe-area-inset-bottom));
  }

  @media (min-width: 960px) {
    body[data-view="exam"] .toast-region {
      bottom: calc(var(--sp-4) + env(safe-area-inset-bottom));
    }
  }

  .submit-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--sp-2);
  }

  .submit-stats div {
    padding: var(--sp-3);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
  }

  .submit-stats dt {
    color: var(--ink-2);
    font-size: var(--fs-13);
  }

  .submit-stats dd {
    font-size: var(--fs-20);
    font-weight: 700;
  }

  .shortcut-list {
    display: grid;
    gap: var(--sp-2);
  }

  .shortcut-list div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    padding-bottom: var(--sp-2);
    border-bottom: 1px solid var(--line);
  }

  .shortcut-list dd {
    display: flex;
    gap: var(--sp-1);
  }

  /* 結果頁 */
  .result-head {
    margin-bottom: var(--sp-6);
  }

  .result-head__bank {
    margin-top: var(--sp-2);
    font-weight: 700;
  }

  .result-head__meta {
    color: var(--ink-2);
  }

  .summary {
    --ring-fill: var(--bad);
    --ring-track: var(--bad-soft);
    display: grid;
    gap: var(--sp-6);
    padding: var(--sp-6);
  }

  .summary.is-passed {
    --ring-fill: var(--ok);
    --ring-track: var(--ok-soft);
  }

  @media (min-width: 720px) {
    .summary {
      grid-template-columns: 180px minmax(0, 1fr);
      align-items: center;
    }
  }

  .score-ring {
    position: relative;
    width: 168px;
    height: 168px;
    margin-inline: auto;
  }

  .score-ring svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
  }

  .score-ring__track {
    fill: none;
    stroke: var(--ring-track);
    stroke-width: 12;
  }

  .score-ring__value {
    fill: none;
    stroke: var(--ring-fill);
    stroke-width: 12;
    stroke-linecap: round;
  }

  .score-ring__threshold {
    stroke: var(--ink);
    stroke-width: 2.5;
    stroke-linecap: round;
  }

  .score-ring__label {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    text-align: center;
  }

  .score-ring__score {
    font-size: var(--fs-48);
    font-weight: 700;
    line-height: 1;
  }

  .score-ring__sub {
    margin-top: var(--sp-1);
    color: var(--ink-2);
    font-size: var(--fs-13);
  }

  .summary__main {
    display: grid;
    gap: var(--sp-4);
    min-width: 0;
  }

  .verdict {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2);
  }

  .kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: var(--sp-2);
  }

  .kpi {
    padding: var(--sp-3);
    border: 1px solid var(--line);
    border-radius: 12px;
  }

  .kpi__label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--ink-2);
    font-size: var(--fs-13);
  }

  .kpi__label .icon {
    width: 16px;
    height: 16px;
    stroke-width: 2.5;
  }

  .kpi--correct .icon {
    color: var(--ok);
  }

  .kpi--wrong .icon {
    color: var(--bad);
  }

  .kpi--pending .icon {
    color: var(--brand);
  }

  .kpi__value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.3;
  }

  .summary__meta {
    color: var(--ink-2);
    font-size: var(--fs-14);
  }

  .actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
  }

  .menu {
    position: relative;
  }

  .menu__panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: var(--z-dock);
    display: grid;
    min-width: 200px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface);
    box-shadow: var(--shadow-2);
  }

  .menu__item {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    min-height: 44px;
    padding: 0 var(--sp-3);
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--ink);
    font-weight: 600;
    text-align: left;
    cursor: pointer;
  }

  .menu__item:focus-visible {
    outline-offset: -2px;
  }

  @media (hover: hover) {
    .menu__item:hover {
      background: var(--brand-soft);
    }
  }

  .pending-note {
    grid-template-columns: auto minmax(0, 1fr);
    border-color: var(--brand);
    background: var(--brand-soft);
  }

  .pending-note>.icon {
    color: var(--brand);
  }

  .review {
    margin-top: var(--sp-8);
  }

  .review__head {
    display: grid;
    gap: var(--sp-3);
    margin-bottom: var(--sp-4);
  }

  .review__tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2);
  }

  .review__filters {
    min-width: 0;
    max-width: 100%;
    margin: 0;
    padding: 3px;
    border: 0;
    overflow-x: auto;
  }

  .review__filters .segmented {
    grid-auto-columns: max-content;
    width: max-content;
  }

  .review-list {
    display: grid;
    gap: 10px;
  }

  .review-item {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
  }

  .review-item>summary {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--sp-2) var(--sp-3);
    min-height: 52px;
    padding: var(--sp-3) var(--sp-4);
    list-style: none;
    cursor: pointer;
  }

  .review-item>summary::-webkit-details-marker {
    display: none;
  }

  .review-item__no {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  .review-item__preview {
    display: -webkit-box;
    overflow: hidden;
    color: var(--ink-2);
    -webkit-line-clamp: 1;
    line-clamp: 1;
    -webkit-box-orient: vertical;
  }

  .review-item[open] .review-item__preview {
    display: block;
    color: var(--ink);
    font-weight: 500;
    line-height: 1.7;
    white-space: pre-line;
    overflow-wrap: anywhere;
  }

  @media (max-width: 639px) {
    .review-item>summary {
      grid-template-columns: auto minmax(0, 1fr) auto;
    }

    .review-item__preview {
      grid-column: 1 / -1;
      grid-row: 2;
    }
  }

  .review-item__flag {
    color: var(--flag);
  }

  .review-item__body {
    display: grid;
    gap: var(--sp-3);
    padding: var(--sp-4);
    border-top: 1px solid var(--line);
  }

  .review-item__stem {
    font-size: var(--fs-16);
    font-weight: 500;
    line-height: 1.7;
    white-space: pre-line;
    overflow-wrap: anywhere;
  }

  .review-options {
    display: grid;
    gap: var(--sp-2);
  }

  .review-option {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: 10px var(--sp-3);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
  }

  .review-option .option__key {
    width: 26px;
    height: 26px;
    font-size: var(--fs-13);
  }

  .review-option.is-correct {
    border-color: var(--ok);
    background: var(--ok-soft);
  }

  .review-option.is-correct .option__key {
    border-color: var(--ok);
    background: var(--ok);
    color: var(--on-ok);
  }

  .review-option.is-correct .option__mark {
    color: var(--ok);
  }

  .review-option.is-wrong {
    border-color: var(--bad);
    background: var(--bad-soft);
  }

  .review-option.is-wrong .option__key {
    border-color: var(--bad);
    background: var(--bad);
    color: var(--on-bad);
  }

  .review-option.is-wrong .option__mark {
    color: var(--bad);
  }

  .saq-compare {
    display: grid;
    gap: var(--sp-3);
  }

  @media (min-width: 640px) {
    .saq-compare {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
  }

  .saq-compare__box {
    padding: var(--sp-3);
    border-radius: var(--r-md);
    background: var(--surface-2);
  }

  .saq-compare__title {
    margin-bottom: var(--sp-1);
    color: var(--ink-2);
    font-size: var(--fs-13);
  }

  .saq-compare__text {
    white-space: pre-line;
    overflow-wrap: anywhere;
  }

  .review__more {
    display: flex;
    justify-content: center;
    margin-top: var(--sp-4);
  }

  /* 歷史紀錄 */
  .history-list {
    display: grid;
    gap: var(--sp-6);
    margin-top: var(--sp-6);
  }

  .history-bank {
    display: grid;
    gap: var(--sp-4);
    min-width: 0;
    padding: var(--sp-6);
  }

  .history-bank__head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--sp-2) var(--sp-4);
  }

  .history-bank__title {
    font-size: var(--fs-18);
  }

  .history-stats {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-1) var(--sp-4);
    color: var(--ink-2);
    font-size: var(--fs-14);
  }

  .history-stats strong {
    color: var(--ink);
    font-size: var(--fs-16);
  }

  .trend {
    position: relative;
  }

  .trend__caption {
    margin-bottom: var(--sp-2);
    color: var(--ink-2);
    font-size: var(--fs-13);
  }

  .trend__svg {
    width: 100%;
    height: 148px;
    overflow: visible;
  }

  .trend__grid {
    stroke: var(--line);
    stroke-width: 1;
  }

  .trend__pass {
    stroke: var(--ink-2);
    stroke-width: 1;
  }

  .trend__label {
    fill: var(--ink-2);
    font-size: 11px;
  }

  .trend__line {
    fill: none;
    stroke: var(--brand);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .trend__dot {
    fill: var(--brand);
    stroke: var(--surface);
    stroke-width: 2;
  }

  .trend__value {
    fill: var(--ink);
    font-size: 12px;
    font-weight: 700;
  }

  .trend__hit {
    fill: transparent;
    cursor: crosshair;
  }

  .trend__focus {
    stroke: var(--ink-2);
    stroke-width: 1;
  }

  .trend__tooltip {
    position: absolute;
    z-index: 1;
    padding: 6px 8px;
    border-radius: var(--r-sm);
    background: var(--ink);
    color: var(--paper);
    font-size: var(--fs-13);
    line-height: 1.4;
    white-space: nowrap;
    pointer-events: none;
    transform: translate(-50%, calc(-100% - 12px));
  }

  .table-wrap {
    display: none;
    overflow-x: auto;
  }

  .record-list {
    display: grid;
  }

  .record-item {
    display: grid;
    gap: 2px;
    padding-block: var(--sp-3);
    border-bottom: 1px solid var(--line);
  }

  .record-item:last-child {
    border-bottom: 0;
  }

  .record-item__main {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
  }

  .record-item__score {
    font-size: var(--fs-18);
  }

  .record-item__meta {
    color: var(--ink-2);
    font-size: var(--fs-13);
  }

  @media (min-width: 640px) {
    .table-wrap {
      display: block;
    }

    .record-list {
      display: none;
    }
  }

  .records {
    width: 100%;
    min-width: 560px;
    border-collapse: collapse;
    font-size: var(--fs-14);
  }

  .records caption {
    margin-bottom: var(--sp-2);
    color: var(--ink-2);
    font-size: var(--fs-13);
    text-align: left;
  }

  .records th {
    padding: var(--sp-2) var(--sp-3);
    border-bottom: 1px solid var(--line);
    color: var(--ink-2);
    font-size: var(--fs-12);
    font-weight: 700;
    text-align: left;
    white-space: nowrap;
  }

  .records td {
    padding: 10px var(--sp-3);
    border-bottom: 1px solid var(--line);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  .records tr:last-child td {
    border-bottom: 0;
  }

  .records .num {
    text-align: right;
  }

  /* 對話框內容 */
  .privacy-list {
    display: grid;
    gap: var(--sp-2);
    padding-left: 1.2em;
    list-style: disc;
  }

  .danger-zone {
    display: grid;
    gap: var(--sp-2);
    justify-items: start;
    padding: var(--sp-4);
    border: 1px solid var(--bad);
    border-radius: var(--r-md);
  }

  .danger-zone__title {
    font-size: var(--fs-16);
  }

  .danger-zone p {
    color: var(--ink-2);
    font-size: var(--fs-14);
  }
}

@layer utilities {
  .muted {
    color: var(--ink-2);
  }

  .nowrap {
    white-space: nowrap;
  }
}