:root {
  --ink: #1d2923;
  --muted: #5c6961;
  --paper: #fffef9;
  --canvas: #edf1ec;
  --line: #cbd4cc;
  --green: #24543c;
  --green-light: #e1eee5;
  --blue: #315e78;
  --blue-light: #e4eef4;
  --red: #a33b35;
  --red-light: #f7e4e1;
  --code: #17251e;
  --radius: 8px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { min-width: 320px; margin: 0; background: var(--canvas); color: var(--ink); font-family: Inter, system-ui, sans-serif; line-height: 1.55; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid #e0a52b; outline-offset: 3px; }
.skip-link { position: fixed; left: 1rem; top: -5rem; z-index: 50; padding: .65rem .9rem; background: var(--ink); color: white; }
.skip-link:focus { top: 1rem; }
.app-header { position: sticky; top: 0; z-index: 20; min-height: 4.5rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--line); padding: .65rem max(.8rem, calc((100vw - 1500px) / 2)); background: rgba(255,254,249,.96); backdrop-filter: blur(12px); }
.brand { display: inline-flex; align-items: center; gap: .7rem; color: var(--ink); text-decoration: none; }
.brand-mark { width: 2.6rem; height: 2.6rem; display: grid; place-items: center; border-radius: 50%; background: var(--green); color: white; font: 700 1.35rem Georgia, serif; }
.brand strong, .brand small { display: block; line-height: 1.1; }
.brand small { margin-top: .15rem; color: var(--muted); font-size: .72rem; font-weight: 700; text-transform: uppercase; }
.cycle-label { color: var(--muted); font-size: .82rem; }
main { width: min(1500px, calc(100% - 20px)); margin: 0 auto; padding: 2rem 0 4rem; }
h1, h2, p { margin-top: 0; }
h1, h2 { font-family: Georgia, serif; line-height: 1.06; }
h1 { margin-bottom: .8rem; font-size: clamp(2.5rem, 5vw, 5rem); }
h2 { margin-bottom: .55rem; font-size: clamp(1.7rem, 3vw, 2.6rem); }
.eyebrow { margin: 0 0 .4rem; color: var(--red); font-size: .73rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.intro, .identity-panel, .set-toolbar, .problem-nav, .algorithm-panel, .state-panel, .completion { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.intro { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, .65fr); gap: 2rem; padding: clamp(1.4rem, 4vw, 3rem); }
.intro p { max-width: 75ch; color: var(--muted); }
.intro ol { margin: 0; padding-left: 1.5rem; }
.header-right { display: flex; align-items: center; gap: 1rem; }
.teacher-link { color: var(--green); font-size: .82rem; font-weight: 850; text-decoration: none; }
.teacher-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.learner-status { display: flex; align-items: center; gap: .65rem; border-left: 1px solid var(--line); padding-left: 1rem; color: var(--muted); font-size: .8rem; }
.learner-status span { font-weight: 800; color: var(--ink); }
.text-button { border: 0; padding: .25rem; background: transparent; color: var(--green); font-size: .78rem; font-weight: 850; text-decoration: underline; text-underline-offset: 3px; }
.identity-panel { display: grid; grid-template-columns: minmax(260px, .8fr) minmax(520px, 1.2fr); gap: 1.5rem; align-items: center; margin-top: 1rem; padding: 1.4rem; }
.identity-panel p { color: var(--muted); }
.identity-panel .privacy-note { margin-bottom: 0; font-size: .85rem; }
.identity-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .65rem; align-items: end; }
.identity-form input { width: 100%; min-height: 2.75rem; border: 1px solid var(--line); border-radius: 5px; padding: .5rem; background: white; color: var(--ink); }
.identity-form button { grid-column: 1 / -1; justify-self: end; }
.set-toolbar { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(560px, 1.5fr); gap: 1.5rem; margin-top: 1rem; padding: 1.2rem; }
.set-toolbar p { color: var(--muted); }
.set-controls { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .65rem; }
label span { display: block; margin-bottom: .25rem; color: var(--muted); font-size: .72rem; font-weight: 800; text-transform: uppercase; }
select, input[type=file] { width: 100%; min-height: 2.75rem; border: 1px solid var(--line); border-radius: 5px; padding: .5rem; background: white; color: var(--ink); }
.problem-nav { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1rem; padding: .8rem 1rem; }
.problem-nav span { display: block; color: var(--muted); font-size: .8rem; }
.problem-nav button + button { margin-left: .4rem; }
.trace-workspace { display: grid; grid-template-columns: minmax(360px, .85fr) minmax(620px, 1.35fr); gap: 1rem; margin-top: 1rem; }
.algorithm-panel, .state-panel { min-width: 0; overflow: hidden; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); }
.language-badge, .step-badge { flex: 0 0 auto; border-radius: 999px; padding: .35rem .6rem; background: var(--blue-light); color: var(--blue); font-size: .75rem; font-weight: 850; }
.problem-prompt, .problem-goal { margin: 1rem 1.2rem; }
.problem-goal { border-left: 4px solid var(--green); padding: .65rem .8rem; background: var(--green-light); }
.code-view { margin: 0; min-height: 300px; overflow: auto; padding: .8rem 0; background: var(--code); color: #f4f7f4; font: .88rem/1.7 "SFMono-Regular", Consolas, monospace; }
.code-line { display: block; padding: 0 1rem; white-space: pre; }
.code-line.current { background: #315f47; box-shadow: inset 5px 0 #f1c75b; }
.line-number { display: inline-block; width: 2rem; color: #91a499; user-select: none; }
.memory-view { padding: .85rem 1rem; border-bottom: 1px solid var(--line); background: #f7f9f6; }
.memory-title { margin-bottom: .55rem; color: var(--muted); font-size: .75rem; font-weight: 850; text-transform: uppercase; }
.memory-cells { display: flex; flex-wrap: wrap; gap: .35rem; }
.memory-cell { min-width: 3rem; text-align: center; }
.memory-index { display: block; color: var(--muted); font: .68rem monospace; }
.memory-value { display: block; border: 1px solid var(--line); padding: .4rem .6rem; background: white; font-family: monospace; }
.step-instruction { margin: 0; padding: .8rem 1rem; color: var(--muted); font-size: .85rem; }
.table-scroll { overflow-x: auto; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; }
th, td { min-width: 78px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: .55rem; text-align: center; }
th { background: var(--canvas); color: var(--muted); font-size: .72rem; }
th:first-child, td:first-child { min-width: 52px; }
th:last-child, td:last-child { border-right: 0; }
tr.current-row td { background: var(--green-light); }
td input { width: 100%; min-width: 58px; border: 1px solid #91a499; border-radius: 4px; padding: .42rem; text-align: center; background: white; }
.pending-cell { color: #9aa49d; font-size: .75rem; font-style: italic; }
.feedback { margin: .8rem 1rem 0; border-left: 5px solid var(--red); padding: .8rem 1rem; background: var(--red-light); }
.feedback.correct { border-color: var(--green); background: var(--green-light); }
.trace-actions { display: flex; justify-content: flex-end; gap: .6rem; padding: 1rem; }
.primary-button, .secondary-button { border-radius: 5px; padding: .65rem .9rem; font-weight: 850; }
.primary-button { border: 1px solid var(--green); background: var(--green); color: white; }
.secondary-button { border: 1px solid var(--line); background: white; color: var(--ink); }
.completion { margin-top: 1rem; padding: 1.5rem; text-align: center; }
.completion-actions { margin-bottom: 1.4rem; }
.trace-receipt { display: grid; grid-template-columns: minmax(260px, .8fr) minmax(420px, 1.2fr); gap: 1.2rem; align-items: center; border-top: 1px solid var(--line); padding: 1.4rem 0 0; text-align: left; }
.trace-receipt h3 { margin: 0 0 .45rem; font: 700 1.35rem/1.15 Georgia, serif; }
.trace-receipt p { margin-bottom: 0; color: var(--muted); }
.receipt-download { border: 1px solid var(--line); border-radius: 6px; padding: 1rem; background: #f7f9f6; }
.receipt-download .receipt-identity { margin: 0; color: var(--ink); font-weight: 850; }
.receipt-download .receipt-id { margin: .25rem 0 .8rem; font-family: ui-monospace, monospace; font-size: .78rem; }
.download-status { min-height: 1.4rem; margin: .6rem 0 0 !important; font-size: .82rem; }
.error-message { position: fixed; right: 1rem; bottom: 1rem; max-width: 420px; border-radius: 6px; padding: 1rem; background: #7d2d29; color: white; }
@media (max-width: 1050px) { .identity-panel, .set-toolbar, .trace-workspace, .trace-receipt { grid-template-columns: 1fr; } .set-controls { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 650px) { .intro { grid-template-columns: 1fr; } .identity-form, .set-controls { grid-template-columns: 1fr; } .identity-form button { grid-column: auto; width: 100%; } .problem-nav, .app-header { align-items: flex-start; } .cycle-label { display: none; } .learner-status { border-left: 0; padding-left: 0; } .problem-nav { flex-direction: column; } .problem-nav > div:last-child { width: 100%; display: grid; grid-template-columns: 1fr 1fr; } .problem-nav button + button { margin-left: 0; } }
