/* Code Detective. Approved AI Labs style (see CLAUDE.md): Lessonsmith greens and
   gold, roomy cards, big text, accessibility first. */
.cd-main { padding-block: 24px 80px; max-width: 1680px; }
.cd-logo { font-size: 1.5rem; }
.cd-py { font-size: .85rem; font-family: var(--font-mono); background: rgb(255 255 255 / .12); border-radius: 999px; padding: 4px 12px; }
.cd-py.ok { background: var(--mint); color: #08201A; }
.cd-sherlock-big { font-size: 4.5rem; line-height: 1; display: block; }
.lab-start .cd-sherlock-big { margin: 0 auto 6px; }
.cd-hero .cd-sherlock-big { width: 120px; height: 120px; display: grid; place-items: center; background: rgb(255 255 255 / .12); border-radius: 28px; }

/* Intake interview */
.cd-interview { max-width: 900px; margin: 0 auto; }
.cd-say { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 18px; }
.cd-avatar { flex: none; width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; font-size: 2rem; background: var(--soft); border: 3px solid var(--accent); }
.cd-bubble-say { flex: 1; background: var(--deep); color: #FFFFFF; border-radius: 4px 22px 22px 22px; padding: 16px 20px; font-size: 1.2rem; line-height: 1.5; }
.cd-bubble-say b { color: var(--chalk); }
.cd-case-no { display: inline-block; font-family: var(--font-mono); font-size: .78rem; letter-spacing: .1em; text-transform: uppercase; background: var(--chalk); color: var(--chalk-ink); border-radius: 999px; padding: 2px 10px; margin-right: 6px; }
.cd-big-options button { min-height: 66px; font-size: 1.1rem; }
.cd-snippet { background: #0B2A22; color: #E7F6EF; border-radius: 16px; padding: 16px 18px; font-family: var(--font-mono); font-size: 1.05rem; line-height: 1.6; overflow-x: auto; margin: 0 0 16px; white-space: pre; }
.cd-line-pick { display: flex; gap: 14px; width: 100%; text-align: left; background: transparent; border: 2px solid transparent; color: inherit; font: inherit; padding: 2px 8px; border-radius: 8px; white-space: pre; }
.cd-line-pick span { color: #7FB8A4; min-width: 1.5em; }
.cd-line-pick:hover:not(:disabled) { border-color: var(--chalk); }
.cd-line-pick.right { background: var(--accent) !important; }
.cd-line-pick.wrong { background: #B3261E !important; }
.cd-answer { display: flex; gap: 10px; max-width: 420px; }
.cd-answer input { font-size: 1.3rem !important; padding: 12px !important; }
.cd-order { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 12px; }
.cd-order button { min-height: 60px; font-size: 1.05rem; border: 3px solid var(--accent); background: var(--surface); color: var(--deep); font-weight: 700; border-radius: 16px; }
.cd-order button:disabled { opacity: .35; }
.cd-order-done { margin: 0; padding-left: 26px; font-size: 1.1rem; font-weight: 600; display: grid; gap: 4px; }
.cd-badge { display: grid; justify-items: center; gap: 4px; text-align: center; margin: 10px 0 4px; }
.cd-badge span:first-child { font-size: 4rem; }
.cd-badge b { font-family: var(--font-display); font-size: 2rem; color: var(--accent); }

/* Case board */
.cd-next-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 22px; align-items: center; background: var(--bg); border: 3px solid var(--accent); border-radius: 22px; padding: 22px; }
.cd-next-card h3 { font-family: var(--font-display); font-size: 1.7rem; margin: 0 0 4px; }
.cd-next-card p { margin: 0 0 6px; }
.cd-case-icon { width: 84px; height: 84px; border-radius: 22px; background: #FFFFFF; display: grid; place-items: center; font-size: 2.8rem; box-shadow: 0 4px 12px rgb(14 77 62 / .12); flex: none; }
.cd-files { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cd-file { display: grid; gap: 6px; justify-items: start; text-align: left; padding: 20px; border-radius: 20px; border: 3px solid var(--line); background: var(--bg); font-weight: 400; }
.cd-file > span:first-child { font-size: 2.4rem; }
.cd-file b { font-family: var(--font-display); font-size: 1.3rem; }
.cd-file.solved { border-color: var(--accent); background: var(--soft); }

/* Case room: Sherlock | editor | views */
.cd-room:not([hidden]) { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(0, 1.6fr) minmax(0, 1.4fr); gap: 18px; align-items: start; }
.cd-room > .panel { border-radius: 24px; padding: 18px; box-shadow: 0 8px 26px rgb(14 77 62 / .07); min-width: 0; }
.cd-side { position: sticky; top: 74px; display: grid; gap: 12px; max-height: calc(100vh - 90px); overflow: hidden; grid-template-rows: auto auto minmax(80px, 1fr) auto auto; }
.cd-case-head { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; align-items: center; }
.cd-case-head > button { grid-column: 1 / -1; justify-self: start; }
.cd-case-head .cd-case-icon { width: 56px; height: 56px; font-size: 1.9rem; grid-row: span 2; }
.cd-case-head h1 { font-family: var(--font-display); font-size: 1.35rem; margin: 0; line-height: 1.15; }
.cd-case-head p { margin: 0; }
.cd-stages { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.cd-stages li { display: grid; justify-items: center; gap: 2px; font-size: .72rem; font-weight: 600; color: var(--muted); text-align: center; }
.cd-stages b { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--soft); font-size: .95rem; }
.cd-stages li.done b { background: var(--accent); color: var(--accent-ink); }
.cd-stages li.here { color: var(--deep); }
.cd-stages li.here b { background: var(--chalk); box-shadow: 0 0 0 3px #FFF3C4; }
.cd-chat { overflow-y: auto; display: grid; gap: 10px; align-content: start; padding-right: 4px; }
.cd-msg { display: flex; gap: 10px; align-items: flex-start; }
.cd-msg .cd-avatar { width: 38px; height: 38px; font-size: 1.3rem; border-width: 2px; }
.cd-msg > div:last-child { background: var(--bg); border-radius: 4px 16px 16px 16px; padding: 10px 14px; font-size: .98rem; line-height: 1.5; }
.cd-msg.win > div:last-child { background: var(--soft); border: 2px solid var(--mint); }
.cd-msg.alert > div:last-child { background: #FFF6D6; border: 2px solid var(--chalk); }
.cd-msg.you { justify-content: flex-end; }
.cd-msg.you > div { background: var(--accent); color: var(--accent-ink); border-radius: 16px 4px 16px 16px; padding: 8px 14px; max-width: 80%; }
.cd-stage { display: grid; gap: 10px; }
.cd-task { margin: 0; font-size: 1.02rem; background: color-mix(in srgb, var(--chalk) 16%, var(--surface)); border-radius: 14px; padding: 12px 14px; }
.cd-stage .lab-options { grid-template-columns: 1fr; }
.cd-stage .lab-options button { min-height: 50px; }
.cd-results { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.cd-results li.ok { color: var(--accent); font-weight: 600; }
.cd-checkpoint { background: var(--deep); color: #FFFFFF; border-radius: 16px; padding: 14px; display: grid; gap: 8px; }
.cd-checkpoint p { margin: 0; font-size: 1.05rem; }
.cd-checkpoint input { font-size: 1.2rem !important; }
.cd-ask { display: flex; gap: 8px; }
.cd-ask input { flex: 1; min-width: 0; }

/* Editor */
.cd-toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.cd-toolbar button { font-size: 1.02rem; padding: 12px 18px; }
.cd-editor { --lh: 26px; display: grid; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; grid-template-columns: 52px minmax(0, 1fr); background: #0B2A22; border-radius: 18px; overflow: auto; max-height: 70vh; border: 3px solid #0E4D3E; }
.cd-editor:focus-within { border-color: var(--chalk); }
.cd-gutter { position: sticky; left: 0; z-index: 2; padding: 12px 0; background: #082119; text-align: right; font-family: var(--font-mono); font-size: 15px; line-height: var(--lh); color: #5E8F7E; user-select: none; }
.cd-gutter span { display: block; padding-right: 10px; position: relative; }
.cd-gutter span.seen { color: #9FD9C3; }
.cd-gutter span.here { color: #1B1A12; background: var(--chalk); font-weight: 700; }
.cd-gutter span.err { color: #FFFFFF; background: #B3261E; }
.cd-code { position: relative; min-width: 100%; width: max-content; }
.cd-hl, .cd-code textarea { margin: 0; padding: 12px 16px; font-family: var(--font-mono); font-size: 16px; line-height: var(--lh); white-space: pre; tab-size: 4; letter-spacing: 0; word-spacing: 0; border: 0; }
.cd-hl { position: absolute; inset: 0; color: #E7F6EF; pointer-events: none; overflow: hidden; }
.cd-code textarea { position: relative; display: block; width: calc(var(--cols, 0) * 1ch + 32px); min-width: 100%; min-height: 320px; resize: none; background: transparent; color: transparent; caret-color: #F4C842; outline: none; overflow: hidden; }
.cd-code textarea::selection { background: rgb(244 200 66 / .35); }
.tk-k { color: #F4C842; font-weight: 500; } .tk-b { color: #7FE0BE; } .tk-s { color: #FFC9A8; } .tk-n { color: #A8D8FF; } .tk-c { color: #7FA99A; font-style: italic; }
.cd-mark { position: absolute; left: 0; right: 0; height: var(--lh); background: rgb(244 200 66 / .22); border-left: 5px solid var(--chalk); pointer-events: none; transition: top .2s ease; }
.cd-note { position: absolute; right: 12px; max-width: 46%; background: var(--chalk); color: var(--chalk-ink); border-radius: 10px; padding: 1px 10px; font-size: .85rem; font-weight: 700; line-height: var(--lh); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; transition: top .2s ease; box-shadow: 0 4px 12px rgb(0 0 0 / .25); }
.cd-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.cd-controls button { min-width: 52px; min-height: 48px; font-size: 1.1rem; }
.cd-speed { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: .9rem; }
.cd-count { margin-left: auto; font-family: var(--font-mono); font-size: .9rem; color: var(--muted); }
.cd-explain { margin-top: 12px; background: var(--bg); border-left: 5px solid var(--accent); border-radius: 0 14px 14px 0; padding: 10px 16px; min-height: 60px; }
.cd-explain p { margin: 4px 0; }
.cd-explain ul { margin: 4px 0; padding-left: 20px; font-weight: 600; }
.cd-explain code { background: #0B2A22; color: #E7F6EF; border-radius: 6px; padding: 1px 6px; }

/* Views */
.cd-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-bottom: 12px; }
.cd-tabs button { min-height: 48px; font-size: 1rem; border: 2px solid var(--line); background: var(--bg); }
.cd-tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
#canvas { display: block; width: 100%; height: auto; border-radius: 16px; border: 2px solid var(--line); background: #FFFFFF; margin-bottom: 10px; }
.cd-console { background: #0B2A22; color: #E7F6EF; border-radius: 14px; padding: 12px 16px; min-height: 90px; max-height: 260px; overflow: auto; font-family: var(--font-mono); font-size: 15px; margin: 0; white-space: pre-wrap; }
.cd-flow { overflow: auto; max-height: 520px; background: var(--bg); border-radius: 16px; padding: 10px; }
.fc { display: block; margin: 0 auto; max-width: none; }
.fc-node rect, .fc-node polygon { fill: #FFFFFF; stroke: #137A5E; stroke-width: 2.5; }
.fc-if polygon, .fc-loop polygon { fill: #FFF6D6; stroke: #B8870F; }
.fc-io polygon { fill: #E1F4EB; }
.fc-end rect { fill: #0E4D3E; stroke: #0E4D3E; }
.fc-node text { font-family: var(--font-mono); font-size: 13px; fill: #10211C; }
.fc-node.fc-end text { fill: #FFFFFF; font-weight: 700; }
.fc-node.seen rect, .fc-node.seen polygon { fill: #D7F0E4; }
.fc-node.on rect, .fc-node.on polygon { fill: #F4C842; stroke: #0E4D3E; stroke-width: 4; }
.fc-arrow { fill: none; stroke: #4E625C; stroke-width: 2; }
.fc-head { fill: #4E625C; }
.fc-label { font-family: var(--font-body); font-size: 12px; font-weight: 700; fill: #137A5E; }
.cd-pstyle { margin: 0 0 10px; }
.cd-pstyle [aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.ps { list-style: none; margin: 0; padding: 12px; background: var(--bg); border-radius: 16px; font-family: var(--font-mono); font-size: 15px; line-height: 1.9; max-height: 520px; overflow: auto; counter-reset: ps; }
.ps li { padding-left: calc(var(--indent) * 1.6em + 2.4em); position: relative; border-radius: 8px; counter-increment: ps; }
.ps li::before { content: counter(ps); position: absolute; left: .6em; color: var(--muted); font-size: .8em; }
.ps li.on { background: var(--chalk); font-weight: 700; }
.cd-mem-title { font-family: var(--font-display); font-size: 1.2rem; margin: 18px 0 8px; }
.cd-memory { display: grid; gap: 10px; }
.mem-frame { background: var(--bg); border-radius: 14px; padding: 10px 12px; }
.mem-call { border-left: 5px solid var(--chalk); }
.mem-frame h4 { margin: 0 0 6px; font-size: .95rem; }
.cd-memory { min-width: 0; overflow-x: auto; }
.mem { width: 100%; border-collapse: collapse; table-layout: fixed; }
.mem th, .mem td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.mem th { font-family: var(--font-mono); width: 28%; }
.mem tr.changed { background: #FFF3C4; animation: mem-flash .8s ease; }
@keyframes mem-flash { from { background: var(--chalk); } }
.mem-t { color: var(--muted); font-size: .8rem; width: 6.4em; }
.mem-v { font-family: var(--font-mono); overflow-wrap: anywhere; }
.mem-str { color: #8A4B10; } .mem-int, .mem-float { color: #0E4D3E; font-weight: 700; } .mem-bool { color: #6B5200; font-weight: 700; }
.mem-list { display: inline-flex; flex-wrap: wrap; gap: 3px; }
.mem-cell { display: inline-grid; justify-items: center; min-width: 34px; border: 2px solid var(--accent); border-radius: 6px; padding: 0 5px 2px; background: #FFFFFF; font-family: var(--font-mono); }
.mem-cell small { font-size: .65rem; color: var(--muted); line-height: 1.2; }
.mem-dict { display: grid; gap: 3px; }
.mem-pair { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
.mem-pair b::after { content: " →"; color: var(--muted); font-weight: 400; }
.mem-loops .pill, .cd-room .pill { display: inline-block; background: var(--soft); border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px; font-size: .9rem; margin: 2px 0; }
.mem-ret { font-weight: 600; margin: 0; }

@media (max-width: 1280px) {
  .cd-room:not([hidden]) { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
  .cd-side { grid-column: 1 / -1; position: static; max-height: none; grid-template-rows: none; }
  .cd-chat { max-height: 280px; }
}
@media (max-width: 860px) {
  .cd-room:not([hidden]) { grid-template-columns: minmax(0, 1fr); }
  .cd-files { grid-template-columns: minmax(0, 1fr); }
  .cd-next-card { grid-template-columns: minmax(0, 1fr); }
  .cd-note { display: none !important; }
  .mem th { width: 30%; overflow-wrap: anywhere; }
}

/* The way out: exit menu, and Sherlock's offer when a case is too tricky */
dialog.lab-ended.cd-exit { width: min(720px, calc(100vw - 32px)); max-width: none; }
.cd-exit-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 14px 0; }
.cd-exit-options > * { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; align-items: center; text-align: left; padding: 14px 16px; min-height: 72px; border: 3px solid var(--line); border-radius: 18px; background: var(--bg); color: var(--ink); text-decoration: none; font-weight: 400; }
.cd-exit-options > *:hover { border-color: var(--accent); background: var(--soft); }
.cd-exit-options span { grid-row: span 2; font-size: 2rem; }
.cd-exit-options b { font-family: var(--font-display); font-size: 1.15rem; }
.cd-exit-options small { color: var(--muted); font-size: .9rem; }
.cd-exit-options [hidden] { display: none; }
.cd-way-out { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.cd-way-out .btn, .cd-way-out button { min-height: 44px; }
@media (max-width: 600px) { .cd-exit-options { grid-template-columns: minmax(0, 1fr); } }
.cd-mark.err { background: rgb(179 38 30 / .3); border-left-color: #FF8A80; }
