:root {
  font-family: Inter, Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172033;
  background: #f5f7fb;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.app-shell { width: min(1040px, calc(100% - 32px)); margin: 0 auto; padding: 32px 0 64px; }
.topbar, .student-summary, .session-bar, .page-toolbar, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.topbar { margin-bottom: 28px; }
.eyebrow { margin: 0 0 4px; font-weight: 800; letter-spacing: .08em; }
h1 { margin: 0; font-size: clamp(1.5rem, 5vw, 2.7rem); line-height: 1.05; }
h2, h3, h4 { color: #172033; }
.muted, .card-kicker { color: #677289; }
.health, .progress-pill, .state-badge, .auto-label {
  border: 1px solid #dce2ee;
  background: #fff;
  border-radius: 999px;
  padding: 10px 14px;
  white-space: nowrap;
  font-size: .9rem;
}
.health.ok { border-color: #a9dcc0; }
.health.error { border-color: #f1b8b8; }
.progress-pill.done, .state-badge.done { border-color: #a9dcc0; background: #effaf3; color: #276744; }

.auth-card, .student-summary, .role-panel, .learning-section {
  border-radius: 22px;
  background: #fff;
  border: 1px solid #e3e8f2;
  box-shadow: 0 10px 36px rgba(23, 32, 51, .06);
}
.auth-card { width: min(100%, 620px); margin: 0 auto; padding: clamp(22px, 5vw, 34px); }
.auth-copy h2 { margin: 4px 0 8px; font-size: 1.75rem; }
.auth-copy p { margin: 0 0 20px; line-height: 1.55; }
.form-stack { display: grid; gap: 16px; }
.form-stack label { display: grid; gap: 7px; font-weight: 700; }
.form-stack input { width: 100%; border: 1px solid #ccd5e5; border-radius: 13px; padding: 13px 14px; background: #fff; color: #172033; outline: none; }
.form-stack input:focus { border-color: #7c91bf; box-shadow: 0 0 0 3px rgba(89, 116, 176, .12); }
.form-error { min-height: 1.4em; margin: 0; color: #b13b3b; font-size: .92rem; }
.demo-accounts { margin-top: 22px; color: #566176; }
.demo-accounts summary { cursor: pointer; font-weight: 700; }
.demo-accounts p { margin: 8px 0; }
code { background: #eef1f6; border-radius: 6px; padding: 2px 5px; }

.session-bar { margin-bottom: 18px; }
.session-bar h2, .page-toolbar h2 { margin: 3px 0 0; }
.session-bar p, .page-toolbar p { margin: 0; }
.ghost-action { border: 1px solid #d8dfeb; border-radius: 12px; background: #fff; padding: 10px 14px; color: #44506a; font-weight: 700; }
.student-summary { padding: 22px; }
.student-summary h3 { margin: 3px 0 7px; }
.student-summary p { margin: 0; }

.primary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-top: 20px; }
.card { min-height: 300px; padding: 24px; display: flex; flex-direction: column; justify-content: space-between; border-radius: 24px; background: #fff; border: 1px solid #e3e8f2; box-shadow: 0 10px 36px rgba(23, 32, 51, .05); }
.card-learning { border-color: #cbd9ff; }
.card-icon { font-size: 2rem; margin-bottom: 18px; }
.card h3 { margin: 4px 0 10px; font-size: 1.45rem; }
.card p { line-height: 1.55; }
.card-metric { margin: 12px 0 0; font-weight: 800; color: #3e5b97; }
.gate-state { font-size: .94rem; color: #677289; }
.primary-action, .secondary-action, .check-answer { width: 100%; border: 0; border-radius: 14px; padding: 13px 16px; font-weight: 800; }
.primary-action, .check-answer { background: #172033; color: white; }
.secondary-action { background: #edf0f5; color: #7b8495; cursor: not-allowed; }

.role-panel { padding: 28px; }
.role-panel h3 { margin-top: 0; }
.role-panel p { margin-bottom: 0; color: #566176; line-height: 1.6; }
.status-panel { margin-top: 20px; padding: 16px 18px; border-radius: 16px; border: 1px dashed #cfd6e4; color: #566176; background: rgba(255,255,255,.65); }
.status-panel.error { border-color: #e7b5b5; color: #9a3333; }

.page-toolbar { margin-bottom: 18px; justify-content: flex-start; }
.page-toolbar > div { flex: 1; }
.passage-toolbar .progress-pill { flex: 0 0 auto; }
.list-grid { display: grid; gap: 12px; }
.list-card { width: 100%; border: 1px solid #e1e7f0; border-radius: 18px; background: #fff; padding: 18px 20px; display: flex; justify-content: space-between; align-items: center; gap: 16px; text-align: left; box-shadow: 0 8px 24px rgba(23,32,51,.04); color: inherit; }
.list-card:hover { border-color: #bfcbe2; transform: translateY(-1px); }
.list-card strong { display: block; font-size: 1.05rem; }
.list-card small { display: block; margin-top: 6px; color: #69758a; }
.empty-panel { padding: 26px; text-align: center; color: #69758a; border: 1px dashed #cfd6e4; border-radius: 18px; background: #fff; }

.section-nav { position: sticky; top: 0; z-index: 5; display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 14px; background: rgba(245,247,251,.94); backdrop-filter: blur(10px); }
.section-nav a { flex: 0 0 auto; text-decoration: none; color: #59657a; background: #fff; border: 1px solid #dce2ee; border-radius: 999px; padding: 9px 12px; font-size: .9rem; font-weight: 700; }
.section-nav a.done { border-color: #a9dcc0; color: #276744; background: #effaf3; }
.passage-content { display: grid; gap: 18px; }
.learning-section { padding: clamp(20px, 4vw, 30px); scroll-margin-top: 72px; }
.section-heading { margin-bottom: 18px; align-items: flex-start; }
.section-heading h3 { margin: 2px 0 0; font-size: 1.45rem; }
.section-number { margin: 0; color: #8a96aa; font-size: .8rem; font-weight: 800; letter-spacing: .08em; }
.section-complete { border: 1px solid #cfd8e7; background: #fff; border-radius: 12px; padding: 9px 12px; font-weight: 800; color: #4b5870; }
.section-complete.done { border-color: #9cd0b2; background: #effaf3; color: #276744; }
.section-help { color: #667187; line-height: 1.6; margin-top: -6px; }
.source-box { padding: 20px; border-radius: 16px; background: #f8f9fc; border: 1px solid #e4e8f0; }
.source-box p { margin: 0; line-height: 1.9; font-size: 1.05rem; }
.original-question { margin-top: 20px; border-top: 1px solid #edf0f5; padding-top: 20px; }
.original-question .label { margin: 0 0 6px; color: #69758a; font-weight: 800; font-size: .86rem; }
.original-question h4 { margin: 0 0 12px; }
.original-question ol { padding-left: 1.6rem; line-height: 1.7; }
.answer-note { margin-top: 14px; padding: 14px 16px; border-radius: 14px; background: #eef4ff; }
.answer-note p { margin: 6px 0 0; line-height: 1.55; }

.vocab-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.vocab-card { border: 1px solid #e2e7ef; border-radius: 16px; padding: 17px; }
.vocab-card h4 { margin: 0; font-size: 1.15rem; }
.vocab-card p { margin: 7px 0 0; line-height: 1.5; }
.vocab-card p span { display: inline-block; min-width: 48px; color: #7c8799; font-size: .84rem; font-weight: 800; }
.vocab-meaning { font-weight: 800; color: #355388; }
.note { color: #667187; }

.syntax-list, .practice-list { display: grid; gap: 14px; }
.syntax-card, .practice-card { border: 1px solid #e2e7ef; border-radius: 16px; padding: 18px; }
.syntax-index, .practice-type { margin: 0 0 8px; color: #768298; font-size: .82rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.syntax-card blockquote { margin: 0 0 14px; padding: 12px 14px; background: #f8f9fc; border-left: 3px solid #91a4cc; line-height: 1.65; }
.syntax-card p { line-height: 1.55; }

.flow-list { display: grid; gap: 10px; }
.flow-item { display: grid; grid-template-columns: 38px 1fr; gap: 12px; align-items: start; padding: 14px 0; border-bottom: 1px solid #edf0f5; }
.flow-item:last-child { border-bottom: 0; }
.flow-dot { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: #172033; color: #fff; font-weight: 800; }
.flow-item p { margin: 5px 0 0; color: #657086; line-height: 1.5; }
.summary-list { margin: 0; display: grid; gap: 10px; }
.summary-list > div { display: grid; grid-template-columns: 110px 1fr; gap: 14px; padding: 13px 0; border-bottom: 1px solid #edf0f5; }
.summary-list dt { font-weight: 800; color: #53617a; }
.summary-list dd { margin: 0; line-height: 1.55; }
.auto-label { color: #58657b; }

.practice-card h4 { margin: 0 0 14px; }
.choice-list { display: grid; gap: 8px; margin-bottom: 14px; }
.choice-list label { cursor: pointer; }
.choice-list input { position: absolute; opacity: 0; pointer-events: none; }
.choice-list span { display: grid; grid-template-columns: 30px 1fr; gap: 8px; align-items: center; border: 1px solid #dfe5ee; border-radius: 12px; padding: 11px 12px; line-height: 1.45; }
.choice-list input:checked + span { border-color: #7d96c8; background: #f1f5ff; }
.choice-list b { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 50%; background: #eef1f6; }
.check-answer { width: auto; min-width: 120px; padding: 10px 14px; }
.feedback { margin-top: 14px; border-radius: 13px; padding: 13px 14px; }
.feedback.correct { background: #effaf3; color: #276744; }
.feedback.incorrect { background: #fff4f2; color: #8e3e33; }
.feedback p { margin: 5px 0 0; line-height: 1.5; }
.feedback-error { color: #a13c3c; margin: 12px 0 0; }

@media (max-width: 760px) {
  .app-shell { width: min(100% - 24px, 620px); padding-top: 22px; }
  .topbar { align-items: flex-start; }
  .health { margin-top: 2px; }
  .student-summary { align-items: flex-start; }
  .primary-grid { grid-template-columns: 1fr; }
  .card { min-height: 235px; }
  .vocab-grid { grid-template-columns: 1fr; }
  .summary-list > div { grid-template-columns: 1fr; gap: 4px; }
}

@media (max-width: 520px) {
  .topbar { flex-direction: column; }
  .student-summary { flex-direction: column; }
  .progress-pill { align-self: flex-start; }
  .session-bar, .page-toolbar { align-items: flex-start; }
  .passage-toolbar { display: grid; grid-template-columns: auto 1fr; }
  .passage-toolbar .progress-pill { grid-column: 2; }
  .section-heading { flex-direction: column; }
  .section-complete, .auto-label { align-self: flex-start; }
}

/* P4 assessment + scoring operations */
.assessment-toolbar { align-items: center; }
.assessment-time { margin-left: auto; padding: 8px 12px; border-radius: 999px; background: #eef7f1; color: #2f6b45; font-size: .85rem; font-weight: 800; white-space: nowrap; }
.assessment-progress-panel { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin: 16px 0; padding: 14px 16px; border: 1px solid #e1e6ee; border-radius: 16px; background: #fff; }
.assessment-progress-panel > div:first-child { display: flex; gap: 8px; align-items: baseline; }
.assessment-progress-panel strong { font-size: 1.1rem; }
.assessment-progress-panel span { color: #758094; font-size: .85rem; }
.save-state { font-size: .88rem; font-weight: 800; color: #657086; }
.save-state.saving { color: #7a6634; }
.save-state.saved { color: #2f6b45; }
.save-state.failed { color: #9a3c35; }
.assessment-question { min-height: 420px; }
.assessment-passage { margin-bottom: 16px; padding: 20px; border-radius: 18px; background: #f7f9fc; border: 1px solid #e2e7ef; }
.assessment-passage p:last-child { margin-bottom: 0; line-height: 1.75; white-space: pre-wrap; }
.assessment-item { padding: 22px; border-radius: 20px; border: 1px solid #dde3ec; background: #fff; }
.assessment-item h3 { margin: 6px 0 18px; line-height: 1.55; }
.question-meta { margin: 0; color: #738097; font-size: .84rem; font-weight: 800; }
.assessment-choices { display: grid; gap: 10px; }
.assessment-choices label { cursor: pointer; }
.assessment-choices input { position: absolute; opacity: 0; pointer-events: none; }
.assessment-choices span { display: grid; grid-template-columns: 32px 1fr; gap: 10px; align-items: center; padding: 13px 14px; border: 1px solid #dce2ec; border-radius: 14px; line-height: 1.45; transition: .15s ease; }
.assessment-choices b { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: #eef1f6; }
.assessment-choices input:checked + span { border-color: #7d96c8; background: #f1f5ff; box-shadow: 0 0 0 2px rgba(96, 124, 181, .08); }
.assessment-nav { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; margin-top: 16px; }
.assessment-nav button:last-child { justify-self: end; }
.assessment-nav span { color: #69758a; font-weight: 800; }
.submit-assessment { width: 100%; margin-top: 16px; }
.primary-action.compact { width: auto; min-width: 105px; padding: 10px 14px; }
.danger-action { border: 1px solid #efc9c5; background: #fff5f4; color: #963e35; border-radius: 12px; padding: 10px 14px; font-weight: 800; cursor: pointer; }
.danger-action:disabled, .primary-action:disabled, .secondary-action:disabled, .ghost-action:disabled { opacity: .55; cursor: not-allowed; }

.teacher-dashboard { display: grid; gap: 18px; }
.teacher-class-card { border: 1px solid #dfe5ee; border-radius: 20px; background: #fff; padding: 18px; }
.teacher-class-heading { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 14px; }
.teacher-class-heading h3 { margin: 4px 0 0; }
.teacher-assessment-list { display: grid; gap: 12px; }
.teacher-assessment-card { border: 1px solid #e4e8ef; border-radius: 16px; padding: 16px; background: #fbfcfe; }
.teacher-assessment-main { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.teacher-assessment-main h4 { margin: 4px 0 8px; font-size: 1.05rem; }
.teacher-counts { min-width: 76px; text-align: right; }
.teacher-counts strong { display: block; font-size: 1.3rem; }
.teacher-counts span { color: #7a8496; font-size: .8rem; }
.teacher-stats { display: flex; gap: 12px; flex-wrap: wrap; margin: 12px 0; color: #647086; font-size: .9rem; }
.teacher-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.teacher-status-panel { margin-top: 18px; border: 1px solid #dbe2eb; border-radius: 20px; background: #fff; padding: 18px; }
.teacher-status-heading { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.teacher-status-heading h3 { margin: 4px 0 0; }
.status-summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0; }
.status-summary-grid > div { padding: 14px; border-radius: 14px; background: #f6f8fb; text-align: center; }
.status-summary-grid strong { display: block; font-size: 1.25rem; }
.status-summary-grid span { color: #788398; font-size: .82rem; }
.student-status-list { border-top: 1px solid #e8ebf0; }
.student-status-row { display: grid; grid-template-columns: 70px minmax(90px, 1fr) 80px 70px 100px; gap: 10px; align-items: center; padding: 12px 0; border-bottom: 1px solid #edf0f4; }
.student-status-row small { color: #7a8496; text-align: right; }
.student-code { color: #6d788d; font-variant-numeric: tabular-nums; }
.student-state { justify-self: start; padding: 5px 8px; border-radius: 999px; font-size: .78rem; font-weight: 800; }
.student-state.submitted { background: #eaf7ef; color: #2b6e45; }
.student-state.in_progress { background: #fff6df; color: #7c6225; }
.student-state.not_started { background: #f1f3f6; color: #727d8f; }

@media (max-width: 680px) {
  .assessment-toolbar { display: grid; grid-template-columns: auto 1fr; }
  .assessment-time { grid-column: 2; margin-left: 0; justify-self: start; }
  .assessment-progress-panel { align-items: flex-start; flex-direction: column; }
  .assessment-question { min-height: 0; }
  .assessment-item, .assessment-passage { padding: 16px; }
  .teacher-assessment-main { flex-direction: column; }
  .teacher-counts { text-align: left; }
  .student-status-row { grid-template-columns: 58px 1fr 72px 52px; }
  .student-status-row small { grid-column: 2 / -1; text-align: left; }
}


/* P4 scoring */
.teacher-heading-actions { display:flex; align-items:center; gap:.6rem; flex-wrap:wrap; justify-content:flex-end; }
.grade-table-wrap { overflow-x:auto; margin-top:1rem; border:1px solid #e4e8f0; border-radius:16px; }
.grade-table { width:100%; min-width:780px; border-collapse:collapse; font-size:.9rem; }
.grade-table th, .grade-table td { padding:.75rem .7rem; text-align:center; border-bottom:1px solid #edf0f5; white-space:nowrap; }
.grade-table th { background:#f7f9fc; font-size:.78rem; color:#566076; }
.grade-table td:nth-child(2), .grade-table th:nth-child(2) { text-align:left; }
.grade-actions { margin-top:1rem; align-items:center; flex-wrap:wrap; }
.student-state.retrying { background:#fff4d6; color:#8a5a00; }
@media (max-width: 720px) { .teacher-heading-actions { justify-content:flex-start; } }

/* P5 Teacher Studio */
.teacher-mode-tabs{display:flex;gap:.65rem;margin:1rem 0 1.2rem;flex-wrap:wrap}.teacher-mode-tabs .active{box-shadow:0 0 0 2px rgba(15,23,42,.12) inset}.studio-toolbar,.studio-import-section,.studio-workspace{background:#fff;border:1px solid #e5e7eb;border-radius:20px;padding:1.15rem;margin-bottom:1rem}.studio-toolbar{display:flex;align-items:center;justify-content:space-between;gap:1rem}.studio-overview{display:grid;gap:1rem}.studio-lesson-card{background:#fff;border:1px solid #e5e7eb;border-radius:20px;padding:1.1rem}.studio-lesson-heading{display:flex;justify-content:space-between;gap:1rem;align-items:flex-start;margin-bottom:.9rem}.studio-passage-list{display:grid;gap:.65rem}.studio-passage-row{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:.75rem;padding:.8rem;border:1px solid #eef0f4;border-radius:14px;align-items:center}.studio-passage-row p{margin:.2rem 0}.studio-row-actions{display:flex;gap:.45rem;flex-wrap:wrap;justify-content:flex-end}.studio-import-grid{display:grid;gap:.75rem;margin:1rem 0}.studio-import-grid label{display:grid;gap:.35rem}.studio-import-grid select,.studio-import-grid textarea,.studio-json-editor,.studio-question-editor input,.studio-question-editor textarea,.studio-question-editor select{width:100%;border:1px solid #d8dde7;border-radius:12px;padding:.7rem;background:#fff;font:inherit}.studio-import-grid textarea,.studio-json-editor{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.85rem;line-height:1.5}.studio-validation{margin-top:.8rem;display:grid;gap:.4rem}.validation-item{padding:.6rem .75rem;border-radius:10px;background:#f7f8fa}.validation-item.error{background:#fff1f2}.validation-item.warning{background:#fff8e6}.validation-item.info{background:#eff6ff}.studio-job{display:flex;justify-content:space-between;gap:.8rem;align-items:center;padding:.75rem 0;border-bottom:1px solid #eef0f4}.studio-job:last-child{border-bottom:0}.studio-question-editor{border:1px solid #e5e7eb;border-radius:14px;padding:.85rem;margin:.7rem 0;display:grid;gap:.55rem}.studio-choice-grid{display:grid;gap:.4rem}.studio-review-actions{display:flex;gap:.5rem;flex-wrap:wrap;margin-top:1rem}.code-block{white-space:pre-wrap;word-break:break-word;background:#111827;color:#f9fafb;border-radius:14px;padding:1rem;max-height:420px;overflow:auto;font-size:.82rem}.status-chip{display:inline-flex;border-radius:999px;background:#f1f5f9;padding:.25rem .55rem;font-size:.78rem}.status-chip.approved,.status-chip.active{background:#ecfdf5}.status-chip.review,.status-chip.draft{background:#fff7ed}@media(max-width:720px){.studio-passage-row{grid-template-columns:1fr}.studio-row-actions{justify-content:flex-start}.studio-toolbar,.studio-lesson-heading,.studio-job{align-items:flex-start;flex-direction:column}}
.settings-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:12px}.check-row{display:flex!important;flex-direction:row!important;align-items:center;gap:8px}.check-row input{width:auto!important}

/* P8 stabilization: connectivity + mobile assessment ergonomics */
.connection-state{padding:7px 10px;border-radius:999px;font-size:.78rem;font-weight:850;white-space:nowrap;background:#eef7f1;color:#2f6b45}
.connection-state.offline{background:#fff1f2;color:#9a3c35}
.connection-state.pending{background:#fff7df;color:#7c6225}
.connection-state.online{background:#eef7f1;color:#2f6b45}
button,.assessment-choices span,input,select,textarea{touch-action:manipulation}
.assessment-choices span{min-height:48px}
.primary-action,.secondary-action,.ghost-action,.danger-action{min-height:44px}
@media (max-width:680px){
  .app-shell{padding-left:max(14px,env(safe-area-inset-left));padding-right:max(14px,env(safe-area-inset-right));padding-bottom:max(18px,env(safe-area-inset-bottom))}
  .assessment-toolbar{grid-template-columns:auto 1fr;gap:8px}
  .assessment-toolbar .connection-state{grid-column:2;justify-self:start}
  .assessment-choices span{padding:14px 12px;min-height:52px}
  .assessment-nav{position:sticky;bottom:max(6px,env(safe-area-inset-bottom));z-index:5;background:rgba(245,247,251,.96);padding:8px 0;backdrop-filter:blur(8px)}
  .submit-assessment{min-height:50px}
}
