/* R2a: full-height outer shell; legacy IT keeps a local scrolling stage until R2b. */
html,body { height: 100%; overflow: hidden; }
body { margin: 0; background: var(--g2); }
[hidden] { display: none !important; }
.farm-shell { display: grid; grid-template-columns: 248px minmax(0,1fr); height: 100dvh; }
.farm-main { min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.shell-bar { display: flex; align-items: center; gap: 12px; height: 60px; flex: none; padding: 0 24px; border-bottom: 1px solid var(--g5); background: var(--g1); }
.shell-bar h1 { font-size: 17px; margin: 0; white-space: nowrap; }
.shell-acts { display: flex; gap: 8px; margin-left: auto; }
.shell-stage { flex: 1; min-height: 0; position: relative; overflow: hidden; }
#main { height: 100%; box-sizing: border-box; padding: 18px 24px; }
#main.legacy-stage { overflow: auto; overscroll-behavior: contain; }
.side .brand { text-decoration: none; }
.side .brand small { white-space: nowrap; }
.side .nav { width: auto; border: 0; background: transparent; border-radius: 0; }
.side-foot svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.login-side-note { margin: auto 14px; color: var(--g11); font-size: 15px; line-height: 2; }
.home-grid { height: 100%; display: grid; grid-template-columns: minmax(0,1.35fr) minmax(0,1fr) minmax(0,1fr); grid-template-rows: 116px minmax(0,1.1fr) minmax(0,1fr); gap: 14px; }
.home-grid > .card { min-width: 0; min-height: 0; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.home-grid .card-h { margin: 0; flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0; border: 0; }
.home-grid .card-h h2 { margin: 0; font-size: 15px; white-space: nowrap; }
.today-banner { grid-column: 1 / -1; display: flex; align-items: center; gap: 24px; padding: 16px 22px; border-radius: var(--r-lg); background: linear-gradient(120deg,var(--a9),var(--a11)); color: var(--white); min-width: 0; }
.today-banner h2 { font-size: 24px; margin: 2px 0; color: inherit; }
.today-banner p { margin: 0; font-size: 12px; color: inherit; opacity: .85; }
.today-stats { display: flex; gap: 24px; margin-left: auto; flex: none; }
.today-stats button { text-align: left; padding: 4px; color: inherit; border: 0; background: transparent; }
.today-stats b { display: block; font-size: 26px; line-height: 1.25; font-weight: 600; }
.today-stats span { display: block; font-size: 12px; opacity: .85; }
.home-list { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.home-lane { display: flex; gap: 10px; align-items: center; min-height: 52px; padding: 7px 0; border-bottom: 1px solid var(--g4); }
.home-lane:last-child { border: 0; }
.home-lane.now { background: var(--a2); border-radius: var(--r-md); }
.home-lane time { flex: none; width: 42px; font-weight: 600; font-size: 13px; }
.lesson-info { flex: 1; min-width: 0; text-align: left; padding: 0; border: 0; background: transparent; }
.lesson-info strong,.home-task strong { display: block; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lesson-info small,.home-task small { display: block; font-size: 11px; color: var(--g11); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.teacher-tag { font-size: 11px; border-radius: 4px; padding: 0 3px; margin-right: 3px; }
.teacher-tag.wang { background: var(--info-3); color: var(--info-11); }
.teacher-tag.me { background: var(--ok-3); color: var(--ok-11); }
.home-task { display: flex; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--g4); align-items: center; }
.home-task input { flex: none; width: 16px; height: 16px; margin: 0; }
.home-task button { min-width: 0; flex: 1; text-align: left; border: 0; background: transparent; padding: 0; }
.home-ai { flex: none; width: 100%; font-size: 11px; }
.home-links { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; align-content: start; }
.home-link { display: flex; align-items: center; flex-direction: column; gap: 5px; padding: 8px 0; text-decoration: none; font-size: 11px; color: var(--g11); border-radius: var(--r-md); min-width: 0; }
.home-link:hover { background: var(--g3); }
.home-link > span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bookmark-mark { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 10px; background: var(--a3); color: var(--a11); font-size: 17px; font-weight: 600; }
.home-metrics { flex: none; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; align-content: start; }
.home-metrics b { display: block; font-size: 24px; font-weight: 600; line-height: 1.15; }
.home-metrics span { font-size: 12px; color: var(--g11); }
.subject-go { margin-top: auto; display: flex; justify-content: space-between; border-top: 1px solid var(--g4); padding-top: 8px; color: var(--a11); font-size: 12px; text-decoration: none; }
.home-empty.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; padding: 0; height: 100%; min-height: 0; text-align: center; }
.home-empty svg { flex: none; max-height: 50px; }
.home-empty p { font-size: 12px; color: var(--g11); margin: 0; }
.home-empty .btn { flex: none; }
.home-links > .home-empty { grid-column: 1 / -1; min-height: 140px; }
.home-term-body { display: flex; flex: 1; flex-direction: column; gap: 12px; justify-content: center; min-height: 0; font-size: 12px; }
.home-term-body strong { font-size: 14px; }
.home-term-body p { color: var(--g11); margin: 0; }
.term-progress { display: flex; justify-content: space-between; gap: 8px; }
.home-term progress { appearance: none; width: 100%; height: 6px; border: 0; border-radius: 3px; background: var(--g4); color: var(--a9); }
.home-term progress::-webkit-progress-bar { background: var(--g4); border-radius: 3px; }
.home-term progress::-webkit-progress-value { background: var(--a9); border-radius: 3px; }
.home-term progress::-moz-progress-bar { background: var(--a9); border-radius: 3px; }
#main.login-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 42px; align-items: center; padding: 6%; overflow: auto; }
.login-story h2 { font-size: 38px; margin: 18px 0; }
.login-story p { color: var(--g11); font-size: 14px; line-height: 1.8; }

.login-card { padding: 28px; }
.login-card h2 { font-size: 24px; margin-bottom: 8px; }
.login-card form { margin-top: 24px; }
.login-note { margin-top: 18px; font-size: 12px; color: var(--g11); }
.detail-view { overflow: auto; }
.shell-detail { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; }
@media (max-width: 1100px) {
 .farm-shell { grid-template-columns: 204px minmax(0,1fr); }
 #main { padding: 14px; }
 .today-stats { gap: 12px; }
 .today-banner { gap: 12px; padding: 14px; }
 .today-banner h2 { font-size: 21px; }
 .home-grid { gap: 10px; }
 .home-grid > .card { padding: 12px; }
}
@media (max-width: 800px) {
 .farm-shell { grid-template-columns: 184px minmax(0,1fr); }
 #main.home-view { overflow: auto; }
 .home-grid { height: auto; grid-template-columns: 1fr; grid-template-rows: auto; }
 .home-grid > .card { min-height: 220px; max-height: 350px; }
 .today-banner { flex-wrap: wrap; }
 .today-stats { margin-left: 0; }
 #main.login-layout { grid-template-columns: 1fr; gap: 18px; }
 .login-story h2 { font-size: 26px; }

}
.home-subject { color: var(--g12); text-decoration: none; }
.side { width: auto; }

@media print {
 .side, .shell-bar, .skip, #toast { display: none !important; }
 html, body, .farm-shell, .farm-main, .shell-stage, #main, #main.legacy-stage {
  height: auto !important; min-height: 0 !important; max-height: none !important;
  overflow: visible !important; position: static !important;
  display: block !important; transform: none !important; animation: none !important;
 }
 /* reports.css may load after the shell: override its absolute print overlay. */
 body:has(.reports-print) #main .reports-print {
  position: static !important; inset: auto !important; visibility: visible;
 }
 body:has(.reports-print) #main :has(.reports-print) {
  display: block; height: auto; max-height: none; overflow: visible; position: static;
  margin: 0; padding: 0; border: 0; box-shadow: none;
 }
 body:has(.reports-print) #main :not(:has(.reports-print), .reports-print, .reports-print *) { display: none !important; }
}

@media (width < 1000px) {
 .farm-shell { grid-template-columns: 64px minmax(0,1fr); }
 .farm-main { grid-column: 2; }
 .side { position: absolute; inset: 0 auto 0 0; width: 64px; z-index: 20; background: var(--g2); }
 .side:hover, .side:focus-within { width: 248px; box-shadow: var(--shadow-md); }
 .side:not(:hover):not(:focus-within) .brand { padding-inline: 4px; }
 .side:not(:hover):not(:focus-within) .brand > div,
 .side:not(:hover):not(:focus-within) .who-seg,
 .side:not(:hover):not(:focus-within) .sec-h,
 .side:not(:hover):not(:focus-within) .sub,
 .side:not(:hover):not(:focus-within) .chev,
 .side:not(:hover):not(:focus-within) .side-user,
 .side:not(:hover):not(:focus-within) .side-foot .avatar,
 .side:not(:hover):not(:focus-within) .login-side-note { display: none; }
 .side:not(:hover):not(:focus-within) .item { font-size: 0; gap: 0; justify-content: center; }
 .side:not(:hover):not(:focus-within) .grp:has([aria-current="page"]) > .item { background: var(--a9); color: var(--white); }
 .side:not(:hover):not(:focus-within) .side-foot { padding-inline: 0; justify-content: center; }
 .side:not(:hover):not(:focus-within) .side-foot > button { margin: 0; }
}

/* v4 outer chrome; page grids above remain available to V2–V4. */
body { background:var(--bg); }
.shell-bar { background:var(--surface); border-color:var(--line); }
.shell-bar h1 { font-size:14px; font-weight:600; }
.shell-date { font-size:12px; color:var(--ink-3); white-space:nowrap; }
.role-switch { position:relative; flex:none; }
.role-button { display:flex; align-items:center; gap:8px; min-height:38px; padding:4px 10px 4px 4px; border:1px solid var(--line); border-radius:var(--r-pill); background:var(--surface); font-size:13px; }
.role-button .avatar { width:28px; height:28px; }
.role-check { margin-left:auto; visibility:hidden; color:var(--accent); }
[aria-checked="true"] .role-check { visibility:visible; }
.role-switch .menu { min-width:190px; }
.login-mark { display:grid; place-items:center; width:64px; height:64px; border-radius:var(--r-xl); background:var(--accent-grad); color:var(--accent-ink); margin-bottom:24px; }
.is-login { grid-template-columns:minmax(0,1fr); }
.is-login .side,.is-login .shell-bar { display:none; }
.is-login .farm-main { grid-column:1; }
.login-layout { max-width:1120px; margin:auto; }
.login-card { border-radius:var(--r-xl); box-shadow:var(--sh-2); }
@media (640px <= width < 1000px) {
 .side:not(:hover):not(:focus-within) .item > span { display:none; }
 .side:not(:hover):not(:focus-within) .cnt { display:none; }
}
@media (width < 850px) { .shell-date { display:none; } .shell-bar { padding-inline:12px; gap:8px; } }
@media (height < 760px) and (width >= 640px) { .side { padding-top:16px; gap:8px; } .side .brand { padding-bottom:8px; } .side .item { min-height:32px; padding-block:6px; } .side .sec-h { padding-top:10px; } }

/* Keep the filing link visible outside the independently scrolling workspace. */
.site-filing { flex: none; padding: 4px 12px; border-top: 1px solid var(--line); background: var(--bg); color: var(--ink-3); text-align: center; font-size: 12px; line-height: 1.5; }
.site-filing a { display: inline-flex; align-items: center; min-height: 24px; color: inherit; text-decoration: none; }
.site-filing a:hover { text-decoration: underline; }
.site-filing a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
@media print { .site-filing { display: none; } }
