:root {
  color-scheme: light;
  --bg: #fff;
  --surface: #f3f3f1;
  --line: #d5d5d2;
  --ink: #111;
  --muted: #5d5d59;
  --accent: #dc351b;
  --accent-hover: #b92912;
  --header: 72px;
  --rail: 252px;
  --sans: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 100px; }
body { margin: 0; color: var(--ink); background: var(--bg); font: 15px/1.65 var(--sans); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
button, input { font: inherit; }
button, a, summary, label { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .42; }
button, input, summary { border-radius: 0; }
button, h1, h2, h3, p, pre, figure { margin: 0; }
h1 { font-size: 32px; font-weight: 800; line-height: 1.3; letter-spacing: -.035em; overflow-wrap: anywhere; }
h2, h3 { line-height: 1.4; }
h2 { font-size: 18px; } h3 { font-size: 18px; }
pre { font: inherit; white-space: pre-wrap; overflow-wrap: anywhere; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
[tabindex="-1"]:focus { outline: none; }
.muted, .meta { color: var(--muted); }
.meta { font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.num { font-variant-numeric: tabular-nums; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; min-height: 42px; border: 1px solid var(--accent); background: var(--accent); color: white; font-size: 13px; font-weight: 650; line-height: 1.5; text-align: center; flex-shrink: 0; }
.btn:hover:enabled, a.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: white; }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.secondary:hover:enabled, a.btn.secondary:hover { background: #e8e8e5; color: var(--ink); border-color: #999; }
.text-link { color: var(--accent); font-size: 13px; }
.text-link:hover { text-decoration: underline; }
.text-button { border: 0; background: none; padding: 10px 8px; color: inherit; font-size: 13px; }
.skip-link { position: fixed; top: -80px; left: 16px; padding: 12px 18px; z-index: 100; background: var(--ink); color: white; }
.skip-link:focus { top: 8px; }

/* The shell follows the 1440px Pencil grid: a 252px index + 36px gutters. */
.site-header { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 36px; height: var(--header); padding: 0 40px; background: var(--bg); border-bottom: 2px solid var(--ink); }
.brand { font-size: 19px; font-weight: 800; letter-spacing: -.04em; white-space: nowrap; }
.header-nav, .header-actions { display: flex; align-items: center; gap: 32px; font-size: 14px; }
.header-nav a[aria-current] { color: var(--accent); }
.header-actions { margin-left: auto; }
.repo-link { color: var(--muted); font-size: 13px; }
.app-layout { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); }
.sidebar { position: sticky; top: var(--header); height: calc(100vh - var(--header)); height: calc(100dvh - var(--header)); padding: 28px 24px; display: flex; flex-direction: column; gap: 22px; border-right: 1px solid var(--line); background: var(--surface); overflow-y: auto; }
.sidebar-heading { font-size: 14px; color: var(--muted); }
.sidebar nav { display: grid; gap: 8px; }
.sidebar nav a { display: flex; align-items: flex-start; gap: 12px; padding: 10px 8px; border-left: 3px solid transparent; font-size: 13px; font-weight: 600; }
.sidebar nav a span:first-child { flex: 1; min-width: 0; }
.sidebar nav .num { font-size: 12px; font-weight: 400; color: var(--muted); }
.sidebar nav a:hover { background: var(--bg); }
.sidebar nav a[aria-current] { color: var(--ink); background: var(--bg); border-left-color: var(--accent); }
.sidebar-foot { margin-top: auto; padding-top: 40px; font-size: 12px; color: var(--muted); }
.sidebar-foot p + p { margin-top: 22px; }
main { min-width: 0; width: 100%; max-width: 1700px; padding: 28px 36px 0; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 28px; margin-bottom: 32px; }
.page-heading > div { min-width: 0; }
.page-heading p { color: var(--muted); margin-top: 8px; }
.inventory { flex-shrink: 0; font-size: 13px; }
.section-label { font-size: 15px; color: var(--muted); font-weight: 500; margin-bottom: 12px; }
.test-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.test-card { min-width: 0; border: 1px solid var(--line); }
.test-preview { display: block; height: 256px; background: var(--surface); overflow: hidden; }
.test-preview img { width: 100%; height: 100%; object-fit: contain; display: block; }
.cover-fallback { display: flex; height: 100%; align-items: center; justify-content: center; padding: 24px; color: var(--muted); font-size: 14px; text-align: center; }
.test-body { padding: 22px; display: flex; flex-direction: column; gap: 12px; }
.test-title-row { display: flex; align-items: flex-start; gap: 16px; justify-content: space-between; }
.test-title-row h2 { font-size: 20px; font-weight: 750; letter-spacing: -.025em; }
.test-title-row .meta { white-space: nowrap; margin-top: 3px; }
.test-description { color: var(--muted); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.test-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 2px; }
.pending-section { margin-top: 36px; }
.pending-row { display: flex; align-items: center; gap: 18px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.pending-row h3 { flex: 1; font-weight: 500; font-size: 16px; min-width: 0; }
.pending-actions { display: flex; gap: 18px; align-items: center; flex-shrink: 0; }
.collection-foot { display: flex; justify-content: space-between; gap: 20px; padding: 30px 0 6px; font-size: 13px; color: var(--muted); }

/* The sample gallery is the primary work surface; guidance sits beside it. */
.back-link { display: none; color: var(--muted); font-size: 14px; margin-bottom: 20px; }
.detail-heading { margin-bottom: 24px; align-items: flex-start; }
.detail-heading .btn { margin-top: 12px; }
.detail-heading .meta { margin-top: 10px; }
.source { font-size: 13px; margin-top: 5px; color: var(--muted); }
.source a { text-decoration: underline; text-underline-offset: 3px; }
.source details { display: inline; }
.source summary { cursor: pointer; }
.source-note { margin-top: 6px; max-width: 78ch; }
.prompt-panel { display: flex; gap: 24px; align-items: center; padding: 20px; background: var(--surface); margin-bottom: 24px; }
.prompt-content, .prompt-panel pre { flex: 1; min-width: 0; }
.prompt-panel pre { font-size: 14px; line-height: 1.8; }
.prompt-label { display: none; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.detail-workspace { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 28px; align-items: start; }
.sample-section { grid-area: 1 / 1; min-width: 0; }
.samples-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 20px; min-height: 48px; margin-bottom: 24px; }
.samples-toolbar h2 { font-size: 16px; font-weight: 500; margin-right: auto; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 42px; padding: 8px 13px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 13px; font-weight: 600; }
.chip:hover { border-color: #999; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: white; }
.sample-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.sample { min-width: 0; border: 1px solid var(--line); background: var(--bg); }
.sample.picked { border-color: var(--accent); }
.sample-body { padding: 16px; display: grid; gap: 10px; }
.sample-title-row { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; }
.sample-model { min-width: 0; font-size: 16px; overflow-wrap: anywhere; font-weight: 650; }
.pick { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: 13px; white-space: nowrap; cursor: pointer; padding: 2px 0; min-height: 28px; }
.pick input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
.picked .pick { color: var(--accent); }
.sample-answer { font-size: 24px; font-weight: 700; white-space: pre-wrap; overflow-wrap: anywhere; }
.sample-note { font-size: 13px; color: var(--muted); }
.sample-note summary { cursor: pointer; width: fit-content; padding: 4px 0; }
.sample-note p { margin-top: 8px; overflow-wrap: anywhere; }
.observation { color: var(--muted); font-size: 12px; }
.note-preview { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sample-note[open] + .note-preview { display: none; }
.sample-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.sample-actions .btn { padding: 7px 11px; min-height: 36px; font-size: 12px; }
.sample-actions a { margin-left: auto; font-size: 12px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.preview { position: relative; width: 100%; aspect-ratio: 3 / 2; overflow: hidden; background: var(--surface); }
.preview img { display: block; width: 100%; height: 100%; object-fit: contain; }
.preview iframe { position: absolute; left: 0; top: 0; width: 1200px; height: 800px; border: 0; transform-origin: top left; background: white; }
.preview-placeholder { height: 100%; min-height: 150px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 20px; text-align: center; color: var(--muted); }
.preview-placeholder strong { font-size: 14px; font-weight: 500; }
.preview-placeholder span { font-size: 12px; }
.preview-loading { position: absolute; inset: 0; z-index: 1; display: flex; align-items: center; justify-content: center; background: var(--surface); color: var(--muted); font-size: 13px; }
.guide { grid-area: 1 / 2; border-left: 1px solid var(--line); padding-left: 20px; margin-top: 72px; }
.guide summary { font-size: 17px; font-weight: 600; cursor: pointer; list-style: none; }
.guide summary::-webkit-details-marker { display: none; }
.guide > details > summary::after { content: "＋"; float: right; color: var(--muted); }
.guide > details[open] > summary::after { content: "−"; }
.guide-mobile-title { display: none; }
.guide-body { padding-top: 18px; }
.guide-body > .muted { font-size: 13px; margin-bottom: 20px; }
.reference-section + .reference-section { margin-top: 22px; }
.reference-section h3 { font-size: 14px; margin-bottom: 12px; font-weight: 650; }
.reference-section ul, .reference-section ol { font-size: 13px; color: var(--muted); padding-left: 18px; margin: 0; }
.reference-section li + li { margin-top: 9px; }
.reference-section details { color: var(--muted); font-size: 13px; margin-top: 12px; }
.reference-section details summary { font-size: 13px; font-weight: 400; color: var(--accent); }
.reference-section details p { margin-top: 12px; }
.answer { font-size: 32px; font-weight: 750; font-variant-numeric: tabular-nums; }
.empty-state { padding: 28px 0; border-top: 1px solid var(--line); }
.empty-state h3 { font-size: 23px; font-weight: 700; margin-bottom: 12px; }
.empty-state p { color: var(--muted); max-width: 50ch; margin: 12px 0 20px; }
.empty-state .meta { margin: 12px 0; }
.empty-steps { border-top: 1px solid var(--line); padding-top: 24px; margin-top: 32px; }
.empty-steps ol { padding-left: 22px; color: var(--muted); font-size: 14px; }
.empty-steps li { margin: 12px 0; padding-left: 4px; }
.empty-steps li::marker { color: var(--accent); }

/* Native dialog keeps background controls out of the keyboard focus order. */
.compare-bar { position: fixed; bottom: 22px; left: calc(var(--rail) + 36px); right: 324px; z-index: 30; display: flex; align-items: center; gap: 16px; padding: 12px 16px; color: white; background: var(--ink); }
.selection-count { white-space: nowrap; font-size: 13px; }
.selection-names { flex: 1; min-width: 0; color: #ddd; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.selection-hint { font-size: 12px; color: #ddd; }
.compare-bar .text-button { color: #ddd; }
body.has-selection main { padding-bottom: 90px; }
#cmp { position: fixed; inset: 0; width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; padding: 0; border: 0; background: var(--bg); color: var(--ink); }
#cmp[open] { display: flex; flex-direction: column; }
#cmp::backdrop { background: var(--bg); }
.compare-header { display: flex; align-items: center; gap: 24px; padding: 18px 32px; border-bottom: 2px solid var(--ink); flex-shrink: 0; }
.compare-heading { flex: 1; min-width: 0; }
.compare-heading h2 { font-size: 26px; font-weight: 800; letter-spacing: -.025em; }
.compare-heading p { margin-top: 3px; font-size: 13px; color: var(--muted); }
.compare-limit { font-size: 13px; }
.compare-body { flex: 1; min-height: 0; overflow: auto; padding: 30px 32px; }
.compare-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; align-items: start; }
.compare-grid .sample-header { display: flex; align-items: center; gap: 16px; justify-content: space-between; padding: 20px; }
.compare-grid .sample-header h3 { font-size: 19px; overflow-wrap: anywhere; }
.compare-grid .sample-header .meta { margin-top: 5px; }
.compare-grid .preview { aspect-ratio: 3 / 2; max-height: 480px; }
.compare-grid .sample-actions { padding: 12px 20px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.compare-grid .sample-actions .btn { min-height: 40px; padding: 9px 14px; font-size: 13px; }
.compare-observation { padding: 18px 20px; font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.compare-observation p + p { margin-top: 10px; }
.compare-caption { font-size: 13px; color: var(--muted); margin-top: 24px; }
.compare-prompt pre { flex: 1; }

.submit-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px; list-style: none; padding: 0; margin: 40px 0; counter-reset: steps; }
.submit-steps li { border-top: 1px solid var(--line); padding-top: 20px; counter-increment: steps; }
.submit-steps li::before { content: counter(steps, decimal-leading-zero); color: var(--accent); font-size: 14px; }
.submit-steps h2 { margin: 12px 0; font-size: 19px; }
.submit-steps p { color: var(--muted); margin-bottom: 12px; }
.submit-steps a { color: var(--accent); }
#view-submit > .muted { margin-top: 16px; font-size: 13px; }
.site-footer { margin-top: 44px; padding: 24px 0 36px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.site-footer p + p { margin-top: 6px; }
.site-footer a { text-decoration: underline; text-underline-offset: 3px; }
#toast { position: fixed; z-index: 100; left: 50%; bottom: 110px; transform: translateX(-50%); padding: 10px 18px; max-width: calc(100vw - 32px); color: white; background: var(--ink); font-size: 13px; pointer-events: none; visibility: hidden; }
#toast.show { visibility: visible; }
.noscript { padding: 24px; }

@media (min-width: 1800px) { .sample-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1199px) {
  :root { --rail: 216px; }
  .site-header { padding: 0 28px; gap: 28px; }
  main { padding: 28px; }
  .detail-workspace { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .guide { grid-area: auto; margin: 0; border-left: 0; padding-left: 0; border-bottom: 1px solid var(--line); }
  .guide summary { padding: 12px 0; font-size: 14px; }
  .guide-body { padding: 10px 0 20px; }
  #d-refs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
  .reference-section + .reference-section { margin: 0; }
  .sample-section { grid-area: auto; }
  .samples-toolbar { margin-bottom: 18px; }
  .guide-mobile-title { display: inline; }
  .guide-desktop-title { display: none; }
  .compare-bar { left: calc(var(--rail) + 28px); right: 28px; }
  .test-preview { height: 225px; }
  .pending-row { flex-wrap: wrap; }
  .pending-row h3 { flex-basis: 50%; }
}
@media (max-width: 760px) {
  :root { --header: 64px; --rail: 0px; }
  html { scroll-padding-top: 84px; }
  .site-header { padding: 0 20px; gap: 16px; }
  .brand { font-size: 18px; }
  .header-nav { margin-left: auto; gap: 18px; }
  .header-actions { display: none; }
  .app-layout { display: block; }
  .sidebar { display: none; }
  main { padding: 24px 20px 0; }
  h1 { font-size: 28px; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 12px; margin-bottom: 24px; }
  .page-heading p { font-size: 14px; }
  .inventory { font-size: 14px; }
  .test-grid { grid-template-columns: 1fr; gap: 22px; }
  .test-preview { height: auto; aspect-ratio: 7 / 4; }
  .test-body { padding: 16px; }
  .test-title-row h2 { font-size: 19px; }
  .test-actions { gap: 10px; }
  .btn { min-height: 44px; padding: 10px 14px; font-size: 14px; }
  .test-description { font-size: 13px; }
  .pending-row { padding: 18px 0; gap: 10px; }
  .pending-row h3 { flex-basis: 100%; font-size: 16px; }
  .pending-row > .meta { display: none; }
  .pending-actions { width: 100%; justify-content: space-between; }
  .collection-foot { display: block; line-height: 1.8; }
  .collection-foot a { display: inline-block; margin-top: 8px; }
  .back-link { display: inline-block; }
  .detail-heading { margin-bottom: 20px; }
  .detail-heading .btn { margin: 0; }
  .detail-heading .meta { margin-top: 12px; }
  .prompt-panel { flex-direction: column; align-items: stretch; padding: 16px; gap: 16px; margin-bottom: 20px; }
  .prompt-panel pre { font-size: 15px; line-height: 1.7; }
  .prompt-label { display: block; }
  .prompt-panel > .btn { align-self: flex-start; }
  .detail-workspace { gap: 20px; }
  .guide summary { padding: 14px 0; }
  #d-refs { grid-template-columns: 1fr; gap: 22px; }
  .samples-toolbar { gap: 12px; }
  .samples-toolbar h2 { font-size: 14px; color: var(--muted); }
  .filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .chip { min-height: 44px; font-size: 14px; padding: 9px; }
  .sample-grid { grid-template-columns: 1fr; gap: 20px; }
  .sample-title-row { display: block; }
  .sample-title-row .pick { margin-top: 6px; min-height: 36px; }
  .sample-model { font-size: 17px; }
  .sample-body { gap: 10px; }
  .sample .meta, .observation { font-size: 13px; }
  .sample-actions .btn { min-height: 42px; font-size: 14px; }
  .sample-actions a { font-size: 13px; padding: 10px 0; }
  .pick { font-size: 14px; }
  .preview-placeholder { min-height: 190px; }
  .compare-bar { left: 0; right: 0; bottom: 0; padding: 14px 20px max(14px, env(safe-area-inset-bottom)); gap: 12px; }
  .selection-names { display: none; }
  .selection-count { margin-right: auto; font-size: 14px; }
  .selection-hint { display: none; }
  .compare-bar .text-button { padding: 10px 0; }
  .compare-header { padding: 12px 20px; gap: 14px; flex-wrap: wrap; }
  .compare-heading { flex: 1 1 100%; order: 3; }
  .compare-heading h2 { font-size: 23px; }
  .compare-limit { display: none; }
  #cmp-adjust { margin-left: auto; }
  .compare-body { padding: 20px; }
  .compare-grid { grid-template-columns: 1fr; gap: 20px; }
  .compare-grid .sample-header { padding: 16px; }
  .compare-grid .sample-header h3 { font-size: 17px; }
  .compare-grid .sample-actions { padding: 12px 16px; }
  .compare-observation { padding: 16px; }
  .compare-grid .preview { max-height: none; }
  .empty-state { border-top: 0; padding-top: 12px; }
  .empty-state h3 { font-size: 22px; }
  .empty-state .btn { width: 100%; }
  .empty-state .meta { font-size: 13px; }
  .submit-steps { grid-template-columns: 1fr; gap: 24px; margin: 28px 0; }
  .site-footer { line-height: 1.8; margin-top: 32px; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
