/* IA-02: one hierarchy, quiet theme colours, content in normal document flow. */
:root { --radius:16px; --shell-shadow:0 4px 20px rgba(30,35,60,.025); }
html { scroll-behavior:auto; scroll-padding-block:24px 100px; }
body { font-size:16px; line-height:1.7; }
body::before, .page::before { display:none; }
.topbar { position:relative; z-index:30; background:var(--card); box-shadow:none; }
.topbar-inner { max-width:none; height:auto; min-height:76px; padding:16px 32px; display:flex; gap:16px; flex-wrap:wrap; }
.brand { flex:1; font-size:19px; letter-spacing:-.03em; }
.brand::before { width:30px; height:30px; font-size:16px; }
.subject-switch { margin:0; max-width:100%; background:var(--bg); }
.subject-switch button { min-height:42px; padding:8px 14px; }
:root[data-study-theme="starlight"] .topbar .brand { color:var(--sc-ink); }
:root[data-study-theme="starlight"] .topbar .brand::before { background:var(--primary-soft); color:var(--primary); }
:root[data-study-theme="starlight"] .topbar .subject-switch button { color:var(--muted); }
:root[data-study-theme="starlight"] .topbar .subject-switch button.active { background:var(--primary); color:white; }
.theme-menu, .device-menu { position:relative; flex:none; }
.theme-menu>summary, .device-menu>summary { min-height:42px; padding:8px 12px; border:1px solid var(--line); border-radius:10px; background:var(--card); color:var(--text); cursor:pointer; font-size:14px; list-style:none; }
.device-panel { position:absolute; right:0; top:calc(100% + 8px); width:300px; max-width:calc(100vw - 24px); padding:14px; background:var(--card); border:1px solid var(--line); border-radius:16px; box-shadow:0 12px 30px #20204018; z-index:60; }
.device-panel .btn { display:block; width:100%; margin-bottom:8px; text-align:left; white-space:normal; }
#version-info { font-size:13px; overflow-wrap:anywhere; }
.theme-panel { z-index:60; }
.workspace { display:grid; grid-template-columns:236px minmax(0,1fr); max-width:1800px; margin:auto; align-items:start; }
.sidebar { position:sticky; top:0; height:100dvh; overflow-y:auto; padding:30px 18px; border-right:1px solid var(--line); background:var(--card); }
#nav-toggle { display:none; }
#nav { position:static; display:block; width:100%; padding:0; margin:0; border:0; background:transparent; overflow:visible; }
.nav-caption { color:var(--muted); font-size:12px; letter-spacing:.14em; padding:0 12px; margin:0 0 22px; }
#nav details { margin:0 0 7px; }
#nav summary { display:flex; align-items:center; justify-content:space-between; min-height:48px; padding:10px 12px; border-radius:10px; cursor:pointer; font-size:15px; font-weight:650; list-style:none; }
#nav summary::-webkit-details-marker { display:none; }
#nav summary::after { content:'＋'; font-weight:400; color:var(--muted); }
#nav details[open]>summary::after { content:'−'; }
#nav details[open]>summary { color:var(--primary); }
#nav summary:hover { background:var(--bg); }
.nav-children { padding:4px 0 8px 10px; }
#nav a { display:block; white-space:normal; padding:9px 12px; margin:2px 0; min-height:44px; font-size:14px; box-shadow:none; }
#nav a.active { background:var(--primary-soft); color:var(--primary); box-shadow:inset 3px 0 var(--primary); font-weight:650; }
#nav-advanced { border-top:1px solid var(--line); padding-top:16px; margin-top:26px !important; }
#nav-advanced>summary { font-size:13px; color:var(--muted); }
#mobile-nav { display:none; }
.page { min-width:0; width:100%; max-width:1240px; margin:0 auto; padding:36px clamp(24px,3.5vw,60px) 80px; }
.page h1 { font-size:28px; line-height:1.4; letter-spacing:-.035em; }
.page h2 { font-size:19px; line-height:1.5; margin-top:26px; }
.page h3 { font-size:16px; }
.page h1:focus, .page section:focus { outline:none; }
.lead { font-size:15px; margin-top:8px; }
.card { padding:22px; border-radius:var(--radius); box-shadow:var(--shell-shadow); }
.btn { min-height:44px; padding:9px 16px; border-radius:10px; font-weight:600; white-space:normal; }
.btn.primary { background:var(--primary); box-shadow:none; }
input[type=text],input[type=password],input[type=number],input[type=date],input[type=search],textarea,select { min-height:44px; padding:10px 12px; border-radius:10px; max-width:100%; }
input,select,textarea,button { min-width:0; }
textarea { font-size:16px; scroll-margin-block:24px 100px; }
.actions { flex-wrap:wrap; gap:10px; }
.row { flex-wrap:wrap; }
.row>* { min-width:0; flex:1 1 160px; }
.card-row { flex-wrap:wrap; }
.q-stem,.card p,.lead { overflow-wrap:anywhere; }
.katex-display { max-width:100%; overflow-x:auto; overflow-y:hidden; }
table { max-width:100%; }
.category-links { display:grid; gap:0; margin:28px 0; border:1px solid var(--line); border-radius:16px; background:var(--card); overflow:hidden; }
.category-link { display:flex; align-items:center; gap:18px; padding:22px; color:var(--text); border-bottom:1px solid var(--line); }
.category-link:last-child { border-bottom:0; }
.category-link:hover { text-decoration:none; background:var(--primary-soft); }
.category-link strong { flex:1; }
.category-index { color:var(--muted); font-size:13px; font-variant-numeric:tabular-nums; }
.advanced-tools summary { cursor:pointer; color:var(--muted); }
.advanced-tools a { padding:14px 22px; border-bottom:1px solid var(--line); }
.eyebrow { color:var(--muted); font-size:12px; letter-spacing:.1em; margin:0 0 8px; }
.home-heading { display:flex; align-items:flex-end; justify-content:space-between; gap:16px; margin-bottom:28px; }
.home-heading>span { font-size:13px; white-space:nowrap; }
.home-focus { background:var(--sc-tint); border:0; padding:30px; margin-bottom:28px; }
.page .home-focus h2 { margin:0; font-size:clamp(22px,2.4vw,30px); max-width:36ch; }
.home-focus p:not(.eyebrow) { font-size:14px; color:var(--muted); }
.home-focus .btn { margin-top:8px; }
.home-resume { margin-bottom:28px; }
.page .home-resume h2 { font-size:15px; margin:0 0 10px; }
.resume-link { display:flex; align-items:center; justify-content:space-between; gap:16px; padding:18px 0; border-block:1px solid var(--line); }
.resume-link>span:first-child { min-width:0; }
.resume-link strong { display:block; color:var(--text); overflow-wrap:anywhere; }
.resume-link small { color:var(--muted); }
.resume-link>span:last-child { white-space:nowrap; font-size:14px; }
.home-shortcuts { display:grid; grid-template-columns:1fr 1fr; gap:18px; margin-bottom:32px; }
.home-shortcuts>a { display:grid; gap:8px; padding:20px 22px; border:1px solid var(--line); border-radius:var(--radius); background:var(--card); }
.home-shortcuts strong { display:flex; justify-content:space-between; color:var(--text); }
.home-shortcuts>a>span { color:var(--muted); font-size:13px; }
.home-review,.home-feedback { border-top:1px solid var(--line); padding-top:4px; margin-top:28px; }
.home-progress { font-size:15px; }
#kg-today>h2 { font-size:15px; }
#kg-today>p { font-size:13px; color:var(--muted); }
#kg-today .card { padding:14px 18px; box-shadow:none; }
.home-feedback p { font-size:14px; }
.home-management { margin-top:44px; border-top:1px solid var(--line); padding-top:12px; }
#capacity { max-width:520px; }
#task-create { grid-template-columns:repeat(2,minmax(0,1fr)); }
#task-create h2,#task-create .tutor-status { grid-column:1/-1; }
#task-create h2 { margin:0; }
#task-create button { align-self:end; }
.access-shell { min-height:65vh; }
.access-card { box-shadow:none; }
.tutor-layout { grid-template-columns:200px minmax(0,1fr); gap:20px; }
#tutor-message { scroll-margin-block:20px 100px; }
@media (min-width:768px) and (max-width:1399px) {
  .topbar-inner { padding:14px 22px; gap:10px; }
  .workspace { grid-template-columns:72px minmax(0,1fr); }
  .sidebar { padding:20px 8px; }
  #nav-toggle { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:2px; padding:6px; width:56px; min-height:56px; font-size:13px; white-space:nowrap; }
  #nav-toggle span:first-child { font-size:22px; line-height:1; }
  #nav { display:none; }
  .nav-expanded .workspace { grid-template-columns:226px minmax(0,1fr); }
  .nav-expanded .sidebar { padding:20px 14px; }
  .nav-expanded #nav { display:block; margin-top:22px; }
  .page { padding:28px 26px 70px; }
  .tutor-layout { grid-template-columns:minmax(0,1fr); }
  .tutor-history { max-height:160px; overflow:auto; }
  .subject-switch { order:4; width:100%; }
  .subject-switch button { flex:1; }
}
@media (min-width:768px) and (max-width:999px) {
  /* Portrait navigation expands in document flow, never over an editor. */
  .nav-expanded .workspace { grid-template-columns:minmax(0,1fr); }
  .nav-expanded .sidebar { position:static; height:auto; border-right:0; border-bottom:1px solid var(--line); }
  .nav-expanded #nav-toggle { width:auto; }
}
@media (max-width:767px) {
  .topbar-inner { padding:12px 14px; gap:8px; }
  .brand { font-size:17px; gap:6px; }
  .brand::before { width:25px; height:25px; }
  .theme-menu>summary,.device-menu>summary { font-size:12px; padding:8px; }
  .subject-switch { order:4; width:100%; overflow:visible; }
  .subject-switch button { flex:1; padding:8px 0; font-size:13px; }
  .theme-panel { position:fixed; top:68px; right:12px; width:min(300px,calc(100vw - 24px)); max-height:calc(100dvh - 160px); overflow:auto; }
  .workspace { display:block; }
  .sidebar { display:none; }
  .page { max-width:none; padding:24px 16px calc(100px + env(safe-area-inset-bottom)); }
  .page h1 { font-size:24px; }
  .page h2 { font-size:18px; }
  .card { padding:18px; }
  #mobile-nav { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); position:fixed; bottom:0; left:0; right:0; z-index:25; padding:7px 6px calc(7px + env(safe-area-inset-bottom)); background:var(--card); border-top:1px solid var(--line); }
  #mobile-nav a { display:grid; justify-items:center; gap:2px; padding:4px 0; min-height:48px; color:var(--muted); font-size:11px; white-space:nowrap; border-radius:8px; }
  #mobile-nav a[aria-current] { background:var(--primary-soft); color:var(--primary); font-weight:700; }
  .nav-number { font-size:10px; letter-spacing:.08em; }
  body.editing #mobile-nav { display:none; }
  .home-heading { margin-bottom:22px; }
  .home-focus { padding:24px 20px; }
  .home-shortcuts { gap:10px; }
  .home-shortcuts>a { padding:16px 14px; }
  .home-shortcuts strong { font-size:15px; }
  .home-shortcuts>a>span { font-size:12px; }
  .home-management { margin-top:32px; }
  #task-create { grid-template-columns:minmax(0,1fr); }
  .tutor-layout { grid-template-columns:minmax(0,1fr); }
  .tutor-history { max-height:140px; overflow:auto; }
  .summary { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .toast { bottom:calc(84px + env(safe-area-inset-bottom)); }
  body.editing .toast { bottom:12px; }
}
@media (prefers-reduced-motion:reduce) { * { scroll-behavior:auto !important; } }

.home-jumps { display:flex; flex-wrap:wrap; gap:8px 20px; margin:-8px 0 20px; }
.home-jumps a { display:inline-flex; align-items:center; min-height:44px; }

/* Pilot: portrait menu stays in flow but never consumes the whole screen. */
@media (min-width:768px) and (max-width:999px) and (orientation:portrait) {
  .nav-expanded .sidebar { padding:12px 14px; }
  .nav-expanded #nav { max-height: min(34dvh, 360px); overflow-y:auto; overscroll-behavior:contain; margin-top:10px; scrollbar-gutter:stable; }
}
.pilot-banner { padding:10px 20px; background:var(--primary-soft); color:var(--text); font-size:14px; line-height:1.6; }
.pilot-banner a { text-decoration:underline; }

/* Student selection remains legible for long names and touch input. */
#student-list { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,12rem),1fr)); gap:10px; }
#student-list .btn { white-space:normal; overflow-wrap:anywhere; min-height:48px; text-align:left; }

/* Review-01: touch-friendly capture, next steps and a denser knowledge library. */
.visually-hidden { position:absolute !important; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }
.photo-pick { position:relative; display:inline-flex; align-items:center; gap:8px; min-height:48px; padding:0 20px; cursor:pointer; }
.photo-work { margin-top:12px; }
.photo-work canvas { display:block; margin:8px 0; border:1px solid var(--line); border-radius:10px; }
.crop-exact summary, .optional-fields > summary { min-height:44px; display:flex; align-items:center; cursor:pointer; }
.next-steps .actions { margin-top:10px; }
#library-results { grid-template-columns:repeat(auto-fill,minmax(min(100%,15rem),1fr)); gap:10px; }
#library-results > article { padding:12px 14px; }
#library-results > article > p:first-child { font-size:12px; margin:0 0 4px; color:var(--muted); }
#library-results > article h2 { font-size:16px; margin:0 0 4px; }
#library-results > article h2 a { display:block; min-height:44px; display:flex; align-items:center; }
#library-results > article > p:nth-of-type(2) { display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; margin:0 0 4px; font-size:14px; }
#library-results > article > p:last-child { font-size:12px; margin:0; color:var(--muted); }
.study-directory li a, #library-tree li a { display:inline-flex; align-items:center; min-height:40px; }
