:root {
  color-scheme: light;
  --paper: #f7f3eb;
  --surface: #fffcf5;
  --ink: #332e32;
  --muted: #6c6469;
  --line: #d8cfcf;
  --plum: #76576e;
  --plum-deep: #61445a;
  --wash: #eee5eb;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; font-size: 15px; line-height: 1.5; }
button, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { min-height: 44px; padding: 9px 15px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--ink); cursor: pointer; font-weight: 550; transition: background 130ms, transform 100ms; }
button:hover:not(:disabled) { background: var(--wash); border-color: var(--plum); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .48; cursor: not-allowed; }
button:focus-visible, a:focus-visible, textarea:focus-visible { outline: 3px solid var(--plum-deep); outline-offset: 3px; }
a { color: var(--plum-deep); text-underline-offset: 3px; }
h1, h2, p { margin: 0; }
h1 { font-family: Georgia, serif; font-size: clamp(30px, 4vw, 42px); font-weight: 400; line-height: 1.2; letter-spacing: -.8px; }
h2 { font-size: 19px; font-weight: 600; margin-bottom: 9px; letter-spacing: -.3px; }
.muted { color: var(--muted); }
.small { font-size: 12px; line-height: 1.5; }
.topbar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 20px; padding: 15px max(20px, calc((100vw - 1080px) / 2)); background: var(--paper); border-bottom: 1px solid var(--line); }
.wordmark { display: inline-flex; min-height: 44px; align-items: baseline; flex-wrap: wrap; gap: 10px; padding-top: 5px; font-family: Georgia, serif; font-size: 24px; color: var(--ink); text-decoration: none; }
.wordmark span { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 11px; color: var(--muted); }
.study-label { color: var(--plum-deep); font-size: 12px; font-weight: 650; }
main { max-width: 1120px; margin: auto; padding: 40px 20px 32px; scroll-margin-top: 110px; }
.workspace-layout { display: grid; grid-template-columns: minmax(0, 1fr) 338px; gap: 64px; }
.section-kicker { text-transform: uppercase; font-size: 10px; letter-spacing: 1.6px; color: var(--muted); margin-bottom: 16px; font-weight: 650; }
.chart-panel, .context-panel { min-width: 0; }
.chart-heading { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 25px; }
.chart-heading .muted { font-size: 12px; margin-top: 7px; }
.count { display: flex; flex-direction: column; align-items: flex-end; flex-shrink: 0; }
.count output { font-size: 25px; letter-spacing: -1px; font-variant-numeric: tabular-nums; color: var(--plum-deep); }
.count span { font-size: 11px; color: var(--muted); }
.chart-tools { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.chart-tools p { font-size: 13px; max-width: 245px; }
.chart-tools button { flex-shrink: 0; }
#chart-help { margin-bottom: 10px; }
.chart-scroll { overflow-x: auto; overscroll-behavior-x: contain; padding: 4px 4px 12px; background: var(--surface); border-block: 1px solid var(--line); scrollbar-color: var(--plum) var(--paper); }
.chart { width: max-content; display: grid; grid-template-columns: 24px repeat(10, 44px); grid-template-rows: 24px repeat(10, 44px); padding-right: 2px; }
.axis { display: flex; align-items: center; justify-content: center; font-size: 10px; color: var(--muted); user-select: none; }
.cell { width: 44px; height: 44px; padding: 0; border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); border-radius: 0; font-size: 23px; font-weight: 400; line-height: 1; background: var(--surface); position: relative; }
.cell.edge-top { border-top: 1px solid var(--plum); }
.cell.edge-left { border-left: 1px solid var(--plum); }
.cell.major-right { border-right-color: var(--plum); }
.cell.major-bottom { border-bottom-color: var(--plum); }
.cell[aria-pressed="true"] { background: var(--plum); color: var(--surface); }
.cell[aria-pressed="true"]::after { content: "✓"; position: absolute; top: 3px; right: 3px; font: 10px sans-serif; }
.cell[aria-pressed="true"]:hover { background: var(--plum-deep); }
.cell:focus-visible { z-index: 1; outline-offset: -4px; outline-color: var(--ink); }
.cell[aria-pressed="true"]:focus-visible { outline-color: var(--surface); }
.chart-footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--muted); font-size: 11px; padding: 12px 0; }
.legend { font-size: 17px; color: var(--ink); }
.legend span { font-size: 11px; color: var(--muted); margin-left: 10px; }
.action-status { font-size: 13px; min-height: 40px; padding-top: 4px; }
.text-button { border: 0; background: transparent; text-decoration: underline; text-underline-offset: 3px; color: var(--plum-deep); font-size: 12px; padding-inline: 4px; }
.reset-area { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 4px; }
.reset-confirmation { border-left: 3px solid var(--plum); padding: 10px 0 10px 16px; font-size: 13px; margin-top: 8px; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.context-panel { border-left: 1px solid var(--line); padding-left: 28px; }
.context-panel .muted { font-size: 13px; }
.save-controls { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 18px; }
.primary { background: var(--plum); border-color: var(--plum); color: var(--surface); }
.primary:hover:not(:disabled) { background: var(--plum-deep); color: var(--surface); }
.storage-status { border-left: 3px solid var(--line); padding: 12px; margin: 16px 0 9px; font-size: 12px; }
.storage-status strong { display: block; margin-bottom: 4px; font-size: 13px; }
.storage-status[data-state="saved"] { border-color: var(--plum); background: var(--wash); }
.storage-status[data-state="unsaved"] { border-style: dashed; border-color: var(--plum); }
.storage-status[data-state="error"] { border: 2px solid var(--plum-deep); background: var(--surface); }
.context-panel .small { font-size: 12px; }
.backup-section { margin-top: 30px; padding-top: 25px; border-top: 1px solid var(--line); }
.wide { width: 100%; margin-top: 15px; }
#export-status { margin-top: 8px; }
#export-status:empty { display: none; }
.textarea-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-top: 12px; gap: 0 8px; }
label { font-size: 12px; font-weight: 600; }
textarea { width: 100%; max-width: 100%; resize: vertical; display: block; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--ink); padding: 12px; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
#restore-help { margin-top: 8px; }
.restore-status { margin-top: 10px; min-height: 18px; overflow-wrap: anywhere; }
.restore-status[data-error="true"] { font-weight: 600; border-left: 3px solid var(--plum); padding-left: 10px; }
.scope-note { display: grid; grid-template-columns: 1fr 338px; gap: 64px; border-top: 1px solid var(--line); margin-top: 45px; padding-top: 24px; font-size: 12px; }
.scope-note h2 { font-size: 13px; }
.scope-note p + p { margin-top: 7px; }
.price { font-size: 14px; color: var(--plum-deep); }
.price span { display: block; font-size: 11px; color: var(--muted); }
.scope-note a { display: inline-flex; min-height: 44px; align-items: center; }
.research-invitation { grid-column: 1 / -1; max-width: 680px; border-top: 1px solid var(--line); padding-top: 24px; }
#study-feedback { font-size: 14px; font-weight: 600; margin-block: 6px; }
#email-fallback { overflow-wrap: anywhere; }
.notice { border: 2px solid var(--plum); padding: 16px; margin-bottom: 20px; }
[hidden] { display: none !important; }
@media (max-width: 850px) {
  .workspace-layout { grid-template-columns: minmax(0, 1fr); gap: 30px; }
  .chart-panel { max-width: 560px; width: 100%; margin-inline: auto; }
  .context-panel { border-left: 0; border-top: 1px solid var(--line); padding: 25px 0 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; }
  .backup-section { margin: 0; padding: 0; border: 0; }
  .scope-note { grid-template-columns: minmax(0, 1fr); gap: 18px; }
}
@media (max-width: 560px) {
  .topbar { padding: 9px 20px; gap: 0; }
  .wordmark { width: 100%; min-height: 34px; font-size: 23px; }
  .study-label { display: block; padding-bottom: 3px; }
  main { padding-top: 25px; }
  .section-kicker { margin-bottom: 12px; }
  .chart-heading { margin-bottom: 20px; }
  .chart-tools p { max-width: 200px; }
  .context-panel { display: block; }
  .backup-section { margin-top: 27px; padding-top: 25px; border-top: 1px solid var(--line); }
  .save-controls { grid-template-columns: minmax(0, 1fr) auto; }
  .save-controls button { padding-inline: 10px; font-size: 13px; }
  textarea { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
