:root {
    --bg: #f2f4f0;
    --surface: #fff;
    --primary: #243d34;
    --accent: #285b47;
    --success: #285b47;
    --teacher: #40546b;
    --danger: #a13432;
    --ink: #29362f;
    --muted: #626d65;
    --border: #d7ddd6;
    --tint: #e8eee6;
    --radius: 4px;
    --ui-font: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; height: 100dvh; color: var(--ink); background: var(--bg); font-family: var(--ui-font); font-size: 14px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
input, textarea { caret-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
::selection { color: #162b20; background: #c9dfb9; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button:disabled { cursor: not-allowed; }
.hidden, [hidden] { display: none !important; }
h1, h2, h3, h4, p { margin-top: 0; }
#workbook-app { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.skip-link { position: fixed; left: 20px; top: -100px; padding: 12px 16px; background: var(--primary); color: #fff; z-index: 3000; }
.skip-link:focus { top: 10px; }
.app-header { display: flex; justify-content: space-between; align-items: center; gap: 24px; padding: 19px 32px 17px; background: #fff; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.app-identity h1 { font-size: 18px; font-weight: 650; letter-spacing: -.025em; margin: 0 0 5px; }
.app-identity p { font-size: 12px; color: var(--muted); margin: 0; }
.app-identity p span { padding: 0 8px; color: #849084; }
.session-tools { display: flex; align-items: center; gap: 22px; }
#session-name { font-size: 12px; color: var(--muted); }
.nav-group { display: flex; align-items: center; gap: 5px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; background: #fff; color: var(--ink); font-size: 12px; font-weight: 550; line-height: 1.4; transition: background-color 150ms, border-color 150ms, color 150ms; }
.btn:hover { background: var(--tint); border-color: #a5b3a6; }
.btn:active { background: #dce6d9; }
.mode-switch { gap: 0; border: 1px solid var(--border); border-radius: var(--radius); padding: 3px; }
.btn-mode { border: 0; min-height: 29px; padding: 5px 10px; color: var(--muted); font-size: 12px; }
.btn-mode.active { background: var(--primary); color: #fff; }
.activity-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 28px; padding: 11px 32px; background: #fff; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.activity-group { display: flex; align-items: center; gap: 12px; }
.activity-group-label { color: var(--muted); font-size: 12px; white-space: nowrap; }
.examples-group { padding-left: 25px; border-left: 1px solid var(--border); }
.btn-script { background: transparent; border-color: transparent; color: #536158; font-size: 12px; }
.btn-script.active { background: var(--tint); color: var(--primary); border-color: #c7d6c4; }
.btn-script:hover { background: #f2f4f0; border-color: transparent; }
.btn-script.active:hover { border-color: #a7bea4; background: #e1eadc; }
.workbook-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 22px 32px 17px; flex-shrink: 0; }
.workbook-heading h2 { font-size: 23px; font-weight: 600; letter-spacing: -.025em; margin: 0 0 5px; }
.workbook-heading p, .save-note { color: var(--muted); font-size: 12px; margin: 0; }
.save-note { padding-left: 12px; border-left: 1px solid #b7c1b4; }
#stage-tabs { display: none; margin: 0 32px; flex-shrink: 0; border-top: 1px solid #c3ccc0; border-bottom: 1px solid #c3ccc0; }
#stage-tabs.visible { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); }
.stage-tab { display: flex; align-items: flex-start; gap: 12px; padding: 16px 15px 14px; text-align: left; background: transparent; border: 0; border-right: 1px solid var(--border); color: #566357; position: relative; }
.stage-tab:last-of-type { border-right: 0; }
.stage-tab:hover { background: #e8eee4; }
.stage-tab.active { background: #e2eadd; color: var(--primary); box-shadow: inset 0 -2px var(--accent); }
.tab-num { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 27px; height: 27px; border: 1px solid #b4c0b0; border-radius: 50%; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.active .tab-num { background: var(--primary); border-color: var(--primary); color: #fff; }
.step-copy { display: flex; flex-direction: column; gap: 4px; }
.step-copy strong { font-weight: 600; font-size: 13px; line-height: 1.35; }
.step-copy > span { font-size: 11px; color: var(--muted); line-height: 1.4; }
.step-state { font-size: 11px; color: #5c685b; line-height: 1.5; }
.active .step-state { font-weight: 650; color: var(--accent); }
.stage-tab.tab-locked { cursor: help; }
.stage-tab.tab-locked .tab-num { border-style: dashed; }
.lesson-context { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 32px; flex-shrink: 0; }
.lesson-context h3 { font-size: 14px; font-weight: 600; margin: 0 0 3px; }
.lesson-context p { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 0; }
#stage-tab-nav { display: flex; gap: 6px; flex-shrink: 0; }
.stage-nav-prev, .stage-nav-next { padding: 7px 12px; min-height: 34px; border-radius: var(--radius); border: 1px solid #b7c3b3; background: transparent; font-size: 12px; color: var(--primary); }
.stage-nav-next { background: var(--accent); color: #fff; border-color: var(--accent); }
.stage-nav-prev:hover { background: var(--tint); }
.stage-nav-next:hover { background: #1f4b39; }
.stage-nav-prev:disabled, .stage-nav-next:disabled { color: #6a7568; background: #e6eae3; border-color: #cfd6cb; }
.stage-nav-prev:disabled { background: transparent; }
main { display: flex; flex: 1; min-height: 0; overflow: hidden; padding: 0 32px 20px; gap: 28px; }
main.coding-bar-visible { margin-bottom: 91px; }
.column { display: flex; flex: 1; min-width: 0; min-height: 0; gap: 20px; }
.workspace-card { display: flex; flex-direction: column; min-height: 0; width: 100%; background: #fff; border: 1px solid var(--border); border-radius: 3px; overflow: hidden; }
.card-header { padding: 11px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 12px; font-weight: 600; flex-shrink: 0; }
.card-header > div { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-header .btn { min-height: 30px; font-size: 11px !important; padding: 5px 9px !important; }
.content-area { padding: 28px 34px; overflow-y: auto; flex: 1; min-height: 0; font-family: Georgia, "Times New Roman", serif; font-size: 17px; line-height: 2.15; color: #29372f; -webkit-overflow-scrolling: touch; }
.p-block { max-width: 72ch; margin: 0 auto 25px; padding: 0; }
.speaker { display: block; margin: 0 0 5px; color: #687466; font: 600 11px/1.5 var(--ui-font); letter-spacing: .035em; }
.definition-box { padding: 13px 18px; background: #f4f5ef; border: 1px solid #dce0d3; border-radius: 3px; flex-shrink: 0; }
.def-label { color: #535e47; font-size: 11px; font-weight: 650; margin-bottom: 6px; }
.definition-box p { margin: 0; color: #505a47; font-size: 12px; line-height: 1.65; }
.stage-instructions { padding: 12px 18px; background: #edf2eb; border: 1px solid #d7e1d2; border-radius: 3px; color: #38513a; font-size: 12px; line-height: 1.65; flex-shrink: 0; }
#student-instructions { flex-shrink: 0; }
#student-instructions .definition-box { border: 0; border-bottom: 1px solid #e1e4d9; border-radius: 0; padding: 13px 22px; }
#student-instructions .stage-instructions { border: 0; border-bottom: 1px solid #d7e1d2; border-radius: 0; padding: 10px 22px; }
.definition-reference { margin: 0; }
.definition-reference summary { cursor: pointer; padding: 10px 22px; font-size: 12px; color: #58664f; background: #f4f5ef; border-bottom: 1px solid #e1e4d9; }
.definition-reference summary:hover { background: #e9eddf; }
.definition-reference .definition-box { background: #fbfcf8; }
.definition-reference .def-label { display: none; }
.summary-box { background: #fafbf8; border-top: 1px solid var(--border); padding: 12px 22px; max-height: 95px; overflow-y: auto; flex-shrink: 0; }
.summary-title { margin: 0 0 8px; color: var(--muted); font-size: 12px; font-weight: 600; }
#summary-content-1 > span:not(.teacher-label), #summary-content-2 > span:not(.teacher-label) { color: var(--muted) !important; font-size: 12px !important; }
#sidebar { width: 258px; flex-shrink: 0; display: flex; flex-direction: column; overflow-y: auto; padding-top: 1px; }
.sidebar-panel { padding: 18px 0; border-top: 1px solid #bdc8b7; }
.sidebar-panel + .sidebar-panel { margin-top: 12px; }
.sidebar-panel h3, .sidebar-panel h4 { font-size: 14px; font-weight: 600; margin: 0 0 8px; color: var(--primary); }
.panel-heading { display: flex; align-items: baseline; justify-content: space-between; }
#code-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.panel-help { margin: 0 0 14px; color: var(--muted); font-size: 12px; line-height: 1.6; }
#code-list { max-height: 280px !important; margin: 14px 0 !important; }
#code-list > p { color: var(--muted) !important; font-size: 12px !important; line-height: 1.7; }
.code-badge { position: relative; padding: 11px 28px 11px 11px; margin-bottom: 6px; background: #fff; border: 1px solid var(--border); border-left-width: 1px; border-radius: 3px; font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.code-badge strong { font-weight: 600; }
.code-badge span { color: #626d65 !important; }
.remove-code-btn { position: absolute; right: 6px; top: 6px; display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; cursor: pointer; border: 0; border-radius: 3px; font-size: 17px; background: transparent; }
.remove-code-btn:hover { background: #f4e8e5; color: var(--danger) !important; }
#codes-panel > .btn { min-height: 32px; width: auto !important; padding: 4px 0; border-color: transparent !important; font-size: 11px; color: var(--danger) !important; }
#codes-panel > .btn:hover { background: transparent; text-decoration: underline; text-underline-offset: 3px; }
#submitting-as { background: transparent !important; border: 0 !important; border-radius: 0 !important; padding: 0 !important; margin: 0 0 12px !important; }
#submitting-as > span:first-child { color: var(--muted) !important; font-size: 11px !important; font-weight: 400 !important; text-transform: none !important; letter-spacing: 0 !important; margin-bottom: 4px !important; }
#submitting-as-name { font-size: 13px; }
#submit-btn, #refresh-btn, .primary-btn, .s3-submit-btn { background: var(--accent); color: #fff; border: 1px solid var(--accent); min-height: 38px; padding: 9px 16px; border-radius: var(--radius); font-size: 12px; font-weight: 600; }
#submit-btn:hover, #refresh-btn:hover, .primary-btn:hover, .s3-submit-btn:hover { background: #1f4b39; border-color: #1f4b39; }
#submit-coding-status, #submit-analysis-status, #submit-theme-status { color: var(--muted) !important; font-size: 12px !important; line-height: 1.6; text-align: left !important; }
.input-label { display: block; color: var(--muted); font-size: 12px; font-weight: 500; margin: 0 0 7px; }
.student-select { padding: 8px; border-radius: var(--radius); border: 1px solid var(--border); background: #fff; font-size: 12px; max-width: 200px; width: 100%; }
.copyright { margin-top: auto; padding: 24px 0 4px; color: var(--muted); font-size: 11px; line-height: 1.65; }
#coding-bar { position: fixed; z-index: 100; bottom: 0; left: 0; right: 0; display: flex; align-items: center; gap: 28px; padding: 16px 32px; background: #fff; border-top: 1px solid #bdc8b7; }
.coding-selection { width: 250px; flex-shrink: 0; }
.coding-selection label { font-size: 12px; font-weight: 600; }
.coding-selection p { font-size: 12px; color: var(--muted); margin: 4px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 250px; }
.coding-entry { display: flex; flex: 1; gap: 8px; min-width: 0; }
#code-input { padding: 12px 14px; border: 1px solid #b6c2b0; border-radius: var(--radius); background: #fbfcf9; color: var(--ink); flex: 1; min-width: 0; font-size: 13px; }
#apply-btn { background: var(--accent); color: #fff; border: 1px solid var(--accent); padding: 11px 19px; border-radius: var(--radius); font-size: 12px; font-weight: 600; white-space: nowrap; }
#apply-btn span { margin-left: 12px; opacity: .8; }
#apply-btn:hover { background: #1f4b39; }
#apply-btn:disabled { background: #e8ece5; color: #66725f; border-color: #d5ddcf; }
.pending-selection { background: #dcebcf; border-bottom: 1px dashed var(--accent); }
.highlighted { display: inline; padding: .18em 0; border-radius: 2px; box-decoration-break: clone; -webkit-box-decoration-break: clone; position: relative; }
.teacher-label { display: inline-flex; align-items: center; vertical-align: middle; margin-left: 6px; padding: 3px 6px; border-radius: 2px; color: #fff; font: 600 11px/1.3 var(--ui-font); user-select: none; overflow-wrap: anywhere; max-width: 100%; }
.uncode-inline { margin-left: 6px; cursor: pointer; font-size: 15px; }
.sample-banner { background: #edf2eb; border: 1px solid #d7e1d2; padding: 10px 18px; font-size: 12px; color: #38513a; line-height: 1.6; }
#stage-workspace { display: none; flex: 1; min-height: 0; overflow: hidden; padding: 0 32px 24px; gap: 24px; }
#stage-workspace.visible { display: flex; }
.sw-main { flex: 1; overflow-y: auto; min-width: 0; display: flex; flex-direction: column; gap: 14px; padding-bottom: 12px; }
.sw-main > div:first-child { font-size: 12px !important; }
#code-pool-wrap { background: #fff; border: 1px solid var(--border); border-radius: 3px; padding: 18px; flex-shrink: 0; }
#code-pool-wrap h3 { font-size: 12px; font-weight: 500; color: var(--muted); line-height: 1.6; margin: 0 0 12px; }
#code-pool { display: flex; flex-wrap: wrap; gap: 8px; min-height: 36px; }
.pool-card, .sample-code-chip { display: inline-flex; align-items: center; gap: 5px; border: 1px solid #bfc9b9; border-radius: 3px; padding: 7px 10px; font-size: 12px; font-weight: 550; cursor: grab; user-select: none; touch-action: none; max-width: 100%; overflow-wrap: anywhere; }
.pool-card:active, .s3-code-block:active { cursor: grabbing; }
.pool-card.dragging, .s3-code-block.dragging { opacity: .45; }
.return-btn { cursor: pointer; padding: 2px 4px; margin-left: 3px; }
#clusters-wrap { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.cluster-card { background: #fff; border: 1px solid var(--border); border-radius: 3px; padding: 18px; min-width: 0; }
.cluster-top { display: flex; align-items: center; gap: 10px; margin-bottom: 13px; }
.cluster-name-input, .cluster-category-input, .s3-name-input { padding: 10px 11px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; color: var(--ink); min-width: 0; width: 100%; font-size: 13px; }
.cluster-name-input, .s3-name-input { font-weight: 600; }
.remove-cluster-btn { background: transparent; border: 0; padding: 8px 0 8px 6px; color: var(--danger); font-size: 11px; }
.cluster-drop-zone, .s3-drop-zone { min-height: 70px; border: 1px dashed #a8b7a0; border-radius: 3px; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 8px; padding: 12px; background: #fafcf7; }
.drop-placeholder { color: #65725e !important; font-size: 12px !important; }
.cluster-drop-zone.drag-over, .s3-drop-zone.drag-over { background: #e6efdf; border-color: var(--accent); }
.cluster-category-wrap { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 14px; }
.sample-field-text { margin: 0; font-size: 13px; line-height: 1.7; color: var(--ink); overflow-wrap: anywhere; }
.sample-category-title { font-size: 15px; font-weight: 600; line-height: 1.5; }
.cat-label { font-size: 11px; color: var(--muted); margin-bottom: 8px; }
#add-cluster-btn { align-self: flex-start; min-height: 38px; padding: 9px 16px; border: 1px solid #abb9a3; border-radius: var(--radius); background: #fff; color: var(--primary); font-size: 12px; }
#add-cluster-btn:hover { background: var(--tint); }
#s3-clusters-container { display: flex; flex-direction: column; gap: 16px; }
.s3-cluster-card { padding: 18px; background: #fff; border: 1px solid var(--border); border-radius: 3px; }
.s3-top { margin-bottom: 10px; }
.s3-category-label, .s3-prompt { color: var(--muted); font-size: 12px; line-height: 1.6; margin-bottom: 10px; }
.s3-drop-zone { flex-direction: column; }
.s3-code-block { background: #fff; border: 1px solid var(--border); border-left-width: 1px !important; border-radius: 3px; overflow: hidden; cursor: grab; }
.s3-code-block-header { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 9px 12px; }
.s3-code-label { padding: 3px 6px; border-radius: 2px; font-size: 12px; font-weight: 600; overflow-wrap: anywhere; }
.s3-code-count, .s3-drag-hint { font-size: 11px; color: var(--muted); }
.s3-drag-hint { margin-left: auto; }
.s3-extracts-list { padding: 10px 14px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.s3-extract-row { font: 15px/1.8 Georgia, serif; color: #485346; }
.s3-code-card { display: flex; align-items: flex-start; gap: 8px; padding: 10px; border: 1px solid var(--border); background: #fff; }
.s3-extract-text { font-size: 13px; line-height: 1.7; }
#s3-submit-bar, #s4-submit-bar { background: transparent !important; border: 0 !important; border-top: 1px solid #c3ccc0 !important; border-radius: 0 !important; padding: 16px 0 !important; display: flex; align-items: center; gap: 16px; flex-shrink: 0; }
#s3-submit-bar > span, #s4-submit-bar > span { flex: 1; font-size: 12px !important; color: var(--muted) !important; line-height: 1.6; }
.s3-submit-btn.sent { background: #697563; border-color: #697563; }
.s4-section { padding: 22px; background: #fff; border: 1px solid var(--border); border-radius: 3px; }
.s4-section h3 { font-size: 16px; font-weight: 600; margin: 0 0 8px; }
.s4-section .s4-sub { color: var(--muted); font-size: 12px; line-height: 1.6; margin-bottom: 18px; }
.s4-categories-list { display: flex; flex-direction: column; gap: 16px; }
.s4-cat-block { border-top: 1px solid var(--border); }
.s4-cat-header { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; padding: 14px 0 10px; }
.s4-cat-name { font-size: 14px; font-weight: 600; }
.s4-cat-phrase { font-size: 12px; color: var(--muted); }
.s4-cat-extracts { display: flex; flex-direction: column; gap: 10px; }
.s4-extract-row { display: flex; align-items: flex-start; gap: 12px; font-size: 13px; color: #485346; line-height: 1.8; }
.s4-extract-code { padding: 2px 6px; border-radius: 2px; font-size: 11px; font-weight: 600; flex-shrink: 0; max-width: 35%; overflow-wrap: anywhere; }
.s4-scaffold-box { background: #edf2eb; border: 1px solid #d7e1d2; padding: 12px 16px; }
.s4-scaffold-box p { font-size: 13px; color: #38513a; line-height: 1.7; margin: 0; }
.s4-field-label { font-size: 12px; font-weight: 600; margin: 16px 0 8px; }
.s4-textarea { width: 100%; padding: 13px 15px; border: 1px solid #b5c1ae; border-radius: var(--radius); font-size: 14px; line-height: 1.8; resize: vertical; min-height: 120px; color: var(--ink); }
.s4-divider { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
.pane-stage-btn { flex: 1; border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; background: #fff; font-size: 12px; color: var(--muted); }
.pane-stage-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
#analysis-workspace { min-height: 0; }
.analysis-pane-name { font-size: 12px; font-weight: 600; color: var(--muted); line-height: 1.6; }
.analysis-review-card { border: 1px solid var(--border); border-radius: 3px; background: #fff; }
.analysis-review-header { font-size: 13px; font-weight: 600; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.analysis-review-body { padding: 16px; font-size: 13px; line-height: 1.7; }
.analysis-section { margin-bottom: 16px; }
.analysis-section-label { font-weight: 600; margin-bottom: 6px; }
.analysis-cat-chip { display: inline-block; padding: 3px 7px; margin: 3px 3px 3px 0; border-radius: 3px; background: #e5edde; color: #38513a; font-size: 12px; }
#pool-tooltip { position: fixed; display: none; max-width: 280px; background: var(--primary); color: #fff; padding: 10px 13px; border-radius: var(--radius); font-size: 12px; line-height: 1.6; pointer-events: none; z-index: 9999; box-shadow: 0 5px 12px #17261d26; }
#gate-msg { top: auto !important; bottom: 112px; background: var(--primary) !important; border-radius: var(--radius) !important; width: calc(100% - 32px); }
.welcome { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; overflow-y: auto; padding: 50px; background: #f2f4f0; }
.welcome-sheet { display: grid; grid-template-columns: 1.1fr 1fr; max-width: 970px; width: 100%; background: #fff; border: 1px solid #c6cec1; }
.welcome-intro { padding: 52px 48px 35px; }
.welcome-intro h1 { font-size: 35px; font-weight: 600; letter-spacing: -.035em; line-height: 1.15; margin: 0 0 16px; }
.course-line { color: var(--muted); font-size: 12px; line-height: 1.8; margin-bottom: 30px; }
.welcome-description { font-size: 15px; line-height: 1.8; margin-bottom: 30px; max-width: 40ch; }
.welcome-form label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 9px; }
.welcome-form input { width: 100%; padding: 13px; border-radius: var(--radius); border: 1px solid #a6b49f; font-size: 15px; color: var(--ink); background: #fff; }
#name-help { font-size: 12px; color: var(--muted); margin: 8px 0 20px; }
.welcome-form .btn { width: 100%; justify-content: space-between; font-size: 13px; padding: 13px 16px; }
#landing-error { font-size: 12px; color: var(--danger); margin: 10px 0 0; }
.device-note { color: var(--muted); font-size: 12px; line-height: 1.65; margin: 22px 0 0; }
.welcome-route { padding: 54px 36px 35px; background: #e6eddf; border-left: 1px solid #c6cec1; }
.welcome-route > h2 { font-size: 19px; font-weight: 600; letter-spacing: -.02em; margin: 0 0 12px; }
.welcome-route > p { font-size: 13px; color: #586650; line-height: 1.7; margin-bottom: 32px; }
.welcome-route ol { list-style: none; padding: 0; margin: 0; }
.welcome-route li { display: flex; align-items: flex-start; gap: 16px; padding-bottom: 24px; }
.welcome-route li + li { border-top: 1px solid #cbd6c3; padding-top: 20px; }
.route-number { border: 1px solid #9ead96; border-radius: 50%; min-width: 29px; height: 29px; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; }
.welcome-route h3 { font-size: 14px; font-weight: 600; margin: 3px 0 6px; }
.welcome-route li p { font-size: 12px; color: #586650; line-height: 1.65; margin: 0; }
#pw-modal, #script-unlock-modal { position: fixed; inset: 0; z-index: 1000; background: #172a20a6; display: none; align-items: center; justify-content: center; padding: 24px; }
.pw-box { background: #fff; padding: 30px; border-radius: 6px; width: 100%; max-width: 390px; box-shadow: 0 15px 45px #14241b33; }
.pw-box h2 { font-size: 20px; font-weight: 600; margin: 0 0 16px; letter-spacing: -.02em; }
.pw-box p { font-size: 13px !important; line-height: 1.7; color: var(--muted) !important; margin-bottom: 20px; }
.pw-box input { width: 100%; padding: 12px; margin: 0 0 20px; border-radius: var(--radius); border: 1px solid #a6b49f; font-size: 16px; }
.pw-box #script-unlock-error { color: var(--danger) !important; }
.tour-replay { font-size: 12px; white-space: nowrap; }
body[data-mode="teacher"] .tour-replay { display: none; }
.tour-spotlight { position: fixed; z-index: 2300; border: 2px solid #b4d39f; border-radius: 5px; box-shadow: 0 0 0 100vmax #172a207d; pointer-events: none; }
.tour-panel { position: fixed; inset: auto; margin: 0; z-index: 2400; padding: 23px; border: 0; border-radius: 6px; color: var(--ink); background: var(--surface); box-shadow: 0 15px 45px #14241b33; overflow-y: auto; overflow-wrap: anywhere; }
.tour-panel h2 { font-size: 18px; font-weight: 600; letter-spacing: -.02em; line-height: 1.4; margin: 0 0 11px; }
.tour-panel .tour-copy > p { margin: 0; font-size: 14px; line-height: 1.7; color: var(--muted); }
.tour-progress { margin: 17px 0 13px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.tour-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tour-actions > div { display: flex; gap: 6px; }
.tour-actions .btn { min-height: 38px; padding: 8px 12px; }
.tour-actions .btn:disabled { background: var(--bg); color: var(--muted); border-color: var(--border); }
.tour-skip { padding: 8px 0; border: 0; background: transparent; color: var(--muted); font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }
.tour-skip:hover { color: var(--primary); }
@media (max-width: 480px) { .tour-panel { padding: 21px; } .tour-actions .btn { min-height: 42px; } }
body[data-sample="true"] #add-cluster-btn, body[data-sample="true"] #code-pool-wrap, body[data-sample="true"] #codes-panel > .btn { display: none; }
@media (min-width: 1700px) { .app-header, .activity-nav { padding-left: 48px; padding-right: 48px; } main, #stage-workspace { padding-left: 48px; padding-right: 48px; } #stage-tabs { margin-left: 48px; margin-right: 48px; } .workbook-heading, .lesson-context { padding-left: 48px; padding-right: 48px; } }
@media (max-width: 1150px) {
    .app-header { padding: 16px 24px; }
    .activity-nav { padding: 10px 24px; gap: 8px 20px; }
    .activity-group { gap: 8px; }
    .examples-group { padding-left: 0; border-left: 0; }
    .workbook-heading { padding: 18px 24px 15px; }
    #stage-tabs { margin: 0 24px; }
    .stage-tab { padding: 13px 10px; gap: 8px; }
    .step-copy strong { font-size: 12px; }
    .step-copy > span { font-size: 11px; }
    .lesson-context { padding: 13px 24px; }
    main { padding: 0 24px 20px; gap: 20px; }
    #sidebar { width: 235px; }
    .content-area { padding: 24px; font-size: 16px; }
    #stage-workspace { padding: 0 24px 20px; }
}
@media (max-width: 800px) {
    body { height: auto; min-height: 100dvh; }
    #workbook-app { height: auto; min-height: 100dvh; }
    .app-header { align-items: flex-start; padding: 17px 20px; gap: 16px; }
    .app-identity h1 { font-size: 16px; }
    .app-identity p { font-size: 11px; line-height: 1.7; }
    #session-name { display: none; }
    .session-tools { gap: 12px; }
    .activity-nav { padding: 10px 20px; gap: 10px; flex-direction: column; align-items: stretch; }
    .activity-group-label { min-width: 96px; font-size: 11px; }
    .btn-script { font-size: 11px; padding: 7px 8px; min-height: 34px; }
    .workbook-heading { padding: 20px 20px 16px; }
    .workbook-heading h2 { font-size: 22px; }
    .save-note { display: none; }
    #stage-tabs { margin: 0 20px; }
    #stage-tabs.visible { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .stage-tab { min-height: 80px; padding: 12px; }
    .stage-tab:nth-child(2) { border-right: 0; }
    .stage-tab:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
    .step-copy > span { display: none; }
    .step-copy strong { font-size: 12px; }
    .lesson-context { padding: 16px 20px; align-items: flex-start; }
    .lesson-context h3 { font-size: 13px; }
    .lesson-context p { font-size: 11px; max-width: 48ch; }
    #stage-tab-nav { gap: 4px; }
    .stage-nav-prev, .stage-nav-next { font-size: 11px; padding: 7px 8px; }
    main { display: flex; flex-direction: column; overflow: visible; padding: 0 20px 24px; gap: 24px; }
    main.coding-bar-visible { margin-bottom: 130px; }
    .column { min-height: 0; }
    .workspace-card { overflow: visible; }
    .content-area { overflow: visible; font-size: 17px; line-height: 2; padding: 25px 20px; }
    .card-header { padding: 10px 16px; }
    #student-instructions .stage-instructions { padding: 11px 16px; }
    .definition-reference summary { padding: 11px 16px; }
    .summary-box { padding: 14px 16px; max-height: 150px; }
    #sidebar { width: 100%; overflow: visible; display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
    .sidebar-panel + .sidebar-panel { margin-top: 0; }
    .copyright { grid-column: 1/-1; padding: 0; }
    #coding-bar { padding: 12px 20px; gap: 10px; flex-wrap: wrap; }
    .coding-selection { width: 100%; }
    .coding-selection p { max-width: 80vw; }
    .coding-entry { flex-basis: 100%; }
    #code-input { font-size: 16px; padding: 11px 12px; }
    #apply-btn { padding: 10px 14px; }
    #stage-workspace { overflow: visible; padding: 0 20px 24px; }
    .sw-main { overflow: visible; }
    #clusters-wrap { grid-template-columns: 1fr; }
    #analysis-workspace { flex-direction: column; }
    .welcome { padding: 24px; align-items: flex-start; }
    .welcome-sheet { max-width: 600px; grid-template-columns: 1fr; }
    .welcome-intro { padding: 35px; }
    .welcome-route { padding: 30px 35px 12px; border-left: 0; border-top: 1px solid #c6cec1; }
    .welcome-intro h1 { font-size: 31px; }
    .welcome-route > p { margin-bottom: 24px; }
    #gate-msg { bottom: 155px; }
}
@media (max-width: 480px) {
    .app-header { flex-direction: column; gap: 11px; padding: 16px; }
    .app-identity h1 { font-size: 17px; }
    .session-tools { align-self: flex-start; }
    .mode-switch { padding: 2px; }
    .btn-mode { min-height: 28px; }
    .activity-nav { padding: 12px 16px; }
    .activity-group { align-items: flex-start; flex-direction: column; gap: 5px; }
    .activity-group .nav-group { width: 100%; flex-wrap: wrap; gap: 2px; }
    .activity-group-label { font-size: 11px; }
    .btn-script { padding: 7px 8px; font-size: 11px; }
    .workbook-heading { padding: 19px 16px 15px; }
    #stage-tabs { margin: 0 16px; }
    .stage-tab { padding: 10px 9px; min-height: 70px; gap: 8px; }
    .tab-num { width: 23px; height: 23px; font-size: 11px; }
    .step-copy strong { font-size: 12px; }
    .step-state { font-size: 11px; }
    .lesson-context { padding: 14px 16px; flex-direction: row; gap: 10px; }
    .lesson-context > div:first-child { min-width: 0; }
    #stage-tab-nav { align-self: center; flex-direction: column; }
    main { padding-left: 16px; padding-right: 16px; }
    #sidebar { display: flex; gap: 12px; }
    .sidebar-panel { width: 100%; }
    .copyright { margin-top: 0; padding-bottom: 10px; }
    #coding-bar { padding: 12px 16px max(12px, env(safe-area-inset-bottom)); }
    #apply-btn span { display: none; }
    #apply-btn { padding: 10px 12px; }
    .card-header { flex-wrap: wrap; }
    #stage-workspace { padding-left: 16px; padding-right: 16px; }
    .s4-section, .s3-cluster-card, .cluster-card { padding: 16px; }
    .s4-extract-row { flex-direction: column; gap: 4px; }
    .s4-extract-code { max-width: 100%; }
    #s3-submit-bar, #s4-submit-bar { align-items: flex-start; flex-direction: column; }
    .welcome { padding: 16px; }
    .welcome-intro { padding: 28px 23px; }
    .welcome-route { padding: 27px 23px 8px; }
    .welcome-intro h1 { font-size: 29px; }
    .welcome-description { font-size: 14px; }
    .pw-box { padding: 25px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; } }
@media print {
    .app-header, .activity-nav, .workbook-heading, #stage-tabs, .lesson-context, #sidebar, #coding-bar, .btn, .student-select, #student-instructions, .uncode-inline, .welcome, .skip-link { display: none !important; }
    body, #workbook-app, main, .column, .workspace-card, #stage-workspace, .sw-main { background: #fff; height: auto; overflow: visible; display: block; padding: 0; margin: 0; }
    .content-area { overflow: visible; height: auto; line-height: 2.5; }
    .highlighted, .teacher-label { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
