/*
 * 共用元件樣式。每個區塊對應 02-design-foundation.md §5 的一個 Component。
 * .proto-* 開頭的是原型外框（畫布、標題、說明），不屬於設計本身。
 */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--text);
  background: #E5E7EB;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }

/* ════════════════════════════════════════════
   原型外框
   ════════════════════════════════════════════ */
.proto-bar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 24px;
  background: #111827; color: #F9FAFB;
  font-size: 13px;
}
.proto-bar a { color: #93C5FD; text-decoration: none; }
.proto-bar .title { font-weight: 600; font-size: 14px; }
.proto-bar .spacer { flex: 1; }
.proto-bar button {
  background: #374151; border: 0; color: #F9FAFB;
  padding: 4px 10px; border-radius: 6px; cursor: pointer; font-size: 12px;
}
.proto-bar button[aria-pressed="true"] { background: #2563EB; }

.proto-canvas { padding: 32px 40px 80px; }
.proto-intro {
  max-width: 960px; margin: 0 0 32px;
  font-size: 14px; color: #374151;
}
.proto-intro h1 { font-size: 22px; margin: 0 0 8px; color: #111827; }
.proto-intro p { margin: 4px 0; }

.proto-section { margin-bottom: 56px; }
.proto-section > h2 {
  font-size: 18px; margin: 0 0 4px; color: #111827;
}
.proto-section > .proto-sub { font-size: 13px; color: #4B5563; margin: 0 0 16px; }

.proto-row { display: flex; gap: 32px; align-items: flex-start; flex-wrap: wrap; }
.proto-frame-wrap { display: flex; flex-direction: column; gap: 8px; }
.proto-frame-label {
  font-size: 13px; font-weight: 600; color: #374151;
  display: flex; gap: 8px; align-items: baseline;
}
.proto-frame-label span { font-weight: 400; color: #6B7280; }
.proto-frame {
  position: relative; overflow: hidden;
  background: var(--bg-app);
  box-shadow: 0 0 0 1px rgba(0,0,0,.08), 0 8px 24px rgba(0,0,0,.12);
  border-radius: 4px;
}
.proto-frame.tablet  { width: 1180px; height: 820px; }
.proto-frame.desktop { width: 1440px; height: 900px; }
.proto-frame.mobile  { width: 390px;  height: 844px; }
.proto-frame.tv      { width: 1920px; height: 1080px; }
.proto-frame.kiosk   { width: 820px;  height: 1180px; }

.proto-notes {
  width: 320px; font-size: 13px; color: #374151;
  background: #FFFFFF; border-radius: 8px; padding: 16px;
  box-shadow: 0 0 0 1px rgba(0,0,0,.06);
}
.proto-notes h3 { font-size: 13px; margin: 0 0 8px; }
.proto-notes ul { margin: 0; padding-left: 18px; }
.proto-notes li { margin-bottom: 6px; }
.proto-notes code { font-size: 12px; background: #F3F4F6; padding: 0 4px; border-radius: 4px; }

/* 設計標註：[A-XX] 暫用假設、[?] 未定、💡 推導設計 */
.anno {
  display: inline-flex; align-items: center; gap: 2px;
  font-size: 11px; font-weight: 600; line-height: 1;
  color: var(--anno); background: var(--anno-tint);
  border: 1px dashed var(--anno); border-radius: 4px;
  padding: 3px 5px; white-space: nowrap; vertical-align: middle;
  font-family: ui-monospace, Menlo, monospace;
}
.anno-box { outline: 2px dashed var(--anno); outline-offset: 3px; border-radius: 4px; }
body.hide-anno .anno { display: none; }
body.hide-anno .anno-box { outline: none; }

/* ════════════════════════════════════════════
   Icon
   ════════════════════════════════════════════ */
.ic {
  display: inline-flex; width: 1em; height: 1em; flex: none;
  vertical-align: -0.125em;
}
.ic svg { width: 100%; height: 100%; }

/* ════════════════════════════════════════════
   Button
   ════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border-radius: var(--r-md); border: 1px solid transparent;
  font-size: var(--fs-body); font-weight: var(--fw-medium);
  white-space: nowrap; cursor: pointer; user-select: none;
}
.btn .ic { font-size: 18px; }
.btn-lg { height: var(--touch); padding: 0 20px; font-size: 16px; }
.btn-lg .ic { font-size: 20px; }
.btn-sm { height: 32px; padding: 0 12px; font-size: var(--fs-body-sm); }
.btn-icon { width: 40px; padding: 0; }
.btn-lg.btn-icon { width: var(--touch); }

.btn-primary { background: var(--action); color: var(--action-fg); }
.btn-primary:hover, .btn-primary.is-hover { background: var(--action-hover); }
.btn-primary.is-pressed { background: var(--action-pressed); }

.btn-secondary { background: var(--bg-surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover, .btn-secondary.is-hover { background: var(--bg-subtle); }
.btn-secondary.is-pressed { background: var(--n-200); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover, .btn-danger.is-hover { background: var(--danger-hover); }
.btn-danger.is-pressed { background: #991B1B; }

.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover, .btn-ghost.is-hover { background: var(--bg-subtle); color: var(--text); }
.btn-ghost.is-pressed { background: var(--n-200); }

.btn.is-disabled, .btn:disabled {
  background: var(--n-100); color: var(--text-disabled); border-color: var(--n-200);
  cursor: not-allowed;
}
.btn-ghost.is-disabled { background: transparent; border-color: transparent; }
.btn.is-loading { pointer-events: none; opacity: .85; }
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ════════════════════════════════════════════
   Status Badge（作業 3 種、學生 5 種 × S/M/L/XL）
   ════════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 28px; padding: 0 10px;
  border-radius: var(--r-pill); border: 1px solid transparent;
  font-size: var(--fs-caption); font-weight: var(--fw-medium);
  white-space: nowrap; line-height: 1;
}
.badge .ic { font-size: 14px; }
.badge-s  { height: 22px; padding: 0 8px; font-size: var(--fs-micro); gap: 3px; }
.badge-s .ic { font-size: 12px; }
.badge-l  { height: 36px; padding: 0 14px; font-size: var(--fs-body); gap: 6px; }
.badge-l .ic { font-size: 18px; }
.badge-xl { height: 56px; padding: 0 22px; font-size: 28px; gap: 10px; font-weight: var(--fw-bold); }
.badge-xl .ic { font-size: 30px; }

.badge--hw-writing     { color: var(--hw-writing-ink);     background: var(--hw-writing-tint);     border-color: #E2E8F0; }
.badge--hw-correcting  { color: var(--hw-correcting-ink);  background: var(--hw-correcting-tint);  border-color: #FED7AA; }
.badge--hw-done        { color: var(--hw-done-ink);        background: var(--hw-done-tint);        border-color: #BBF7D0; }
.badge--st-not-arrived { color: var(--st-not-arrived-ink); background: var(--st-not-arrived-tint); border-color: #E2E8F0; }
.badge--st-absent      { color: var(--st-absent-ink);      background: var(--st-absent-tint);      border-color: #D6D3D1; }
.badge--st-in-progress { color: var(--st-in-progress-ink); background: var(--st-in-progress-tint); border-color: #BFDBFE; }
.badge--st-stay        { color: var(--st-stay-ink);        background: var(--st-stay-tint);        border-color: #DDD6FE; }
.badge--st-done        { color: var(--st-done-ink);        background: var(--st-done-tint);        border-color: #BBF7D0; }
.badge--st-left        { color: var(--st-left-ink);        background: var(--st-left-tint);        border-color: var(--st-left); border-width: 1.5px; }

/* ════════════════════════════════════════════
   Tag（特殊標記 6 種）
   ════════════════════════════════════════════ */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 8px; border-radius: var(--r-sm);
  font-size: var(--fs-micro); font-weight: var(--fw-medium); line-height: 1;
  white-space: nowrap; border: 1px solid transparent;
}
.tag .ic { font-size: 12px; }
.tag--early-leave, .tag--unregistered-leave {
  color: var(--warn-ink); background: var(--warn-tint); border-color: var(--warn-border);
}
.tag--unknown-time { color: var(--n-600); background: var(--n-100); border-color: var(--n-200); }
.tag--prefilled    { color: var(--n-600); background: var(--n-0); border: 1.5px dashed var(--n-400); }
.tag--draft        { color: var(--n-0); background: var(--n-500); }
.tag--present      { color: var(--st-done-ink); background: var(--st-done-tint); border: 1.5px solid #BBF7D0; }
.tag--arriving     { color: var(--st-in-progress-ink); background: var(--st-in-progress-tint); border: 1.5px solid #BFDBFE; }
.tag--notyet       { color: var(--st-not-arrived-ink); background: var(--st-not-arrived-tint); border: 1.5px solid #CBD5E1; }
.tag--absent       { color: var(--st-absent-ink); background: var(--st-absent-tint); border: 1.5px solid #D6D3D1; }
.tag--submitted    { color: var(--n-700); background: var(--n-0); border-color: var(--n-300); }
.tag--quick        { color: var(--hw-done-ink); background: var(--hw-done-tint); border-color: #BBF7D0; }
.tag--source       { color: var(--n-700); background: var(--n-100); }
.tag--lock         { color: var(--n-600); background: var(--n-100); }

/* ════════════════════════════════════════════
   Form controls
   ════════════════════════════════════════════ */
.field-label { font-size: var(--fs-caption); color: var(--text-2); font-weight: var(--fw-medium); margin-bottom: 6px; display: block; }
.input, .select {
  display: flex; align-items: center; gap: 8px;
  height: var(--touch); padding: 0 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
  font-size: var(--fs-body); color: var(--text);
  min-width: 0;
}
.input .ic, .select .ic { font-size: 18px; color: var(--text-3); flex: none; }
.input .ph { color: var(--text-disabled); }
.input .val, .select .val { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.input.is-focus, .select.is-focus { border-color: var(--focus); box-shadow: 0 0 0 3px rgba(37,99,235,.18); }
.input.is-error { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(220,38,38,.12); }
.input.is-disabled, .select.is-disabled { background: var(--bg-subtle); color: var(--text-3); }
.caret { width: 1.5px; height: 20px; background: var(--focus); display: inline-block; margin-left: 1px; vertical-align: middle; animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }

.checkbox {
  width: 22px; height: 22px; flex: none;
  border: 1.5px solid var(--border-strong); border-radius: 5px; background: #fff;
  display: inline-flex; align-items: center; justify-content: center; color: #fff;
}
.checkbox .ic { font-size: 16px; }
.checkbox.is-checked { background: var(--action); border-color: var(--action); }
.checkbox.is-disabled { background: var(--n-100); border-color: var(--n-200); }
.check-hit { width: var(--touch); height: var(--touch); display: inline-flex; align-items: center; justify-content: center; }

.switch {
  width: 48px; height: 28px; border-radius: 999px; background: var(--n-300);
  position: relative; flex: none;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-1);
}
.switch.is-on { background: var(--action); }
.switch.is-on::after { left: 23px; }

.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--bg-subtle); border-radius: var(--r-md); height: var(--touch);
}
.segmented > span {
  display: inline-flex; align-items: center; padding: 0 12px; border-radius: 6px;
  font-size: var(--fs-body-sm); color: var(--text-2); font-weight: var(--fw-medium);
}
.segmented > span.is-on { background: #fff; color: var(--text); box-shadow: var(--shadow-1); }

/* ════════════════════════════════════════════
   Creatable Combobox（FR-018）
   ════════════════════════════════════════════ */
.combo { position: relative; }
.combo-menu {
  position: absolute; left: 0; top: calc(100% + 4px); z-index: 20;
  min-width: 100%; width: 260px;
  background: #fff; border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow-2); padding: 6px;
}
.combo-group { font-size: var(--fs-micro); color: var(--text-3); padding: 6px 10px 4px; }
.combo-opt {
  display: flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 10px; border-radius: 6px; font-size: var(--fs-body);
}
.combo-opt.is-active { background: var(--bg-subtle); }
.combo-opt mark { background: none; color: inherit; font-weight: var(--fw-bold); }
.combo-opt .hint { margin-left: auto; font-size: var(--fs-micro); color: var(--text-3); }
.combo-opt.create { color: var(--text); font-weight: var(--fw-medium); border-top: 1px solid var(--border); border-radius: 0 0 6px 6px; margin-top: 4px; }
.combo-opt.create .ic { font-size: 18px; }

/* ════════════════════════════════════════════
   Filter Chips（顯示數量）
   ════════════════════════════════════════════ */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 40px; padding: 0 14px; border-radius: var(--r-pill);
  border: 1px solid var(--border-strong); background: #fff;
  font-size: var(--fs-body-sm); font-weight: var(--fw-medium); color: var(--text-2);
}
.chip .count { font-variant-numeric: tabular-nums; color: var(--text-3); font-weight: var(--fw-regular); }
.chip.is-on { background: var(--action); border-color: var(--action); color: #fff; }
.chip.is-on .count { color: #CBD5E1; }

/* ════════════════════════════════════════════
   Data Table
   ════════════════════════════════════════════ */
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-body-sm); }
.table th {
  text-align: left; font-weight: var(--fw-medium); color: var(--text-3); font-size: var(--fs-caption);
  height: 40px; padding: 0 12px; border-bottom: 1px solid var(--border); background: var(--bg-surface);
  position: sticky; top: 0;
}
.table td { height: 56px; padding: 0 12px; border-bottom: 1px solid var(--border); background: var(--bg-surface); }
.table tr.is-selected td { background: #F8FAFF; }
.table tr.is-muted td { color: var(--text-3); }
.table .name { font-weight: var(--fw-medium); color: var(--text); font-size: var(--fs-body); }
.table .chev { color: var(--text-3); font-size: 18px; text-align: right; }
.table td.cb, .table th.cb { width: 56px; padding: 0 4px 0 8px; }

/* ════════════════════════════════════════════
   Banner（頁內提示）
   ════════════════════════════════════════════ */
.banner {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: var(--r-md); border: 1px solid;
  font-size: var(--fs-body-sm);
}
.banner .ic { font-size: 18px; margin-top: 1px; }
.banner--info  { background: var(--info-tint); border-color: var(--info-border); color: var(--info-ink); }
.banner--warn  { background: var(--warn-tint); border-color: var(--warn-border); color: var(--warn-ink); }
.banner--error { background: var(--danger-tint); border-color: #FECACA; color: #991B1B; }

/* ════════════════════════════════════════════
   Confirm Dialog
   ════════════════════════════════════════════ */
.scrim {
  position: absolute; inset: 0; background: var(--bg-scrim); z-index: 50;
  display: flex; align-items: center; justify-content: center;
}
.dialog {
  width: 520px; background: #fff; border-radius: var(--r-lg); box-shadow: var(--shadow-3);
  padding: 24px;
}
.dialog h3 { margin: 0 0 12px; font-size: var(--fs-section); font-weight: var(--fw-bold); }
.dialog p { margin: 0 0 12px; color: var(--text-2); }
.dialog .effects { display: flex; flex-direction: column; gap: 8px; margin: 0 0 16px; }
.dialog .effect { display: flex; gap: 10px; align-items: flex-start; font-size: var(--fs-body-sm); color: var(--text-2); }
.dialog .effect .ic { font-size: 18px; color: var(--text-3); margin-top: 2px; }
.dialog .preview {
  background: var(--bg-subtle); border-radius: var(--r-md); padding: 12px 14px;
  font-size: var(--fs-body-sm); color: var(--text); margin-bottom: 16px;
  border-left: 3px solid #06C755; /* LINE 綠：只用在「家長會收到」預覽 */
}
.dialog .preview .from { font-size: var(--fs-micro); color: var(--text-3); margin-bottom: 4px; display: flex; align-items: center; gap: 4px; }
.dialog .actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 8px; }

/* ════════════════════════════════════════════
   Tablet shell（側欄收合成 72px 圖示列）
   ════════════════════════════════════════════ */
.app-tablet { display: grid; grid-template-columns: var(--nav-w) 1fr; height: 100%; }
.rail {
  background: var(--n-900); color: var(--n-400);
  display: flex; flex-direction: column; align-items: center; padding: 12px 0; gap: 4px;
}
.rail .logo {
  width: 40px; height: 40px; border-radius: 10px; background: #fff; color: var(--n-900);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px;
  margin-bottom: 16px;
}
.rail-item {
  width: 60px; height: 60px; border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 11px; line-height: 1;
}
.rail-item .ic { font-size: 22px; }
.rail-item.is-active { background: var(--n-700); color: #fff; }
.rail .spacer { flex: 1; }
.rail .me {
  width: 40px; height: 40px; border-radius: 50%; background: var(--n-700); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 14px;
}

.main { display: flex; flex-direction: column; min-width: 0; height: 100%; }
.header {
  height: var(--header-h); flex: none;
  display: flex; align-items: center; gap: 12px; padding: 0 24px;
  background: var(--bg-surface); border-bottom: 1px solid var(--border);
}
.header h1 { margin: 0; font-size: var(--fs-page); font-weight: var(--fw-bold); line-height: 1; }
.header .sub { font-size: var(--fs-body-sm); color: var(--text-2); }
.header .right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.header .clock { font-size: var(--fs-body-sm); color: var(--text-2); font-variant-numeric: tabular-nums; }
.content { flex: 1; min-height: 0; overflow: hidden; padding: 20px 24px; display: flex; flex-direction: column; gap: 16px; }
.footer-bar {
  flex: none; height: 72px; padding: 0 24px;
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-surface); border-top: 1px solid var(--border);
}
.footer-bar .right { margin-left: auto; display: flex; gap: 12px; }

.card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-lg); }
.section-title { font-size: var(--fs-section); font-weight: var(--fw-bold); margin: 0; }

/* ════════════════════════════════════════════
   QR Scanner
   ════════════════════════════════════════════ */
.scanner {
  position: relative; border-radius: var(--r-lg); overflow: hidden;
  background: radial-gradient(ellipse at 40% 35%, #475569 0%, #1E293B 55%, #0F172A 100%);
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.scanner .reticle {
  width: 56%; aspect-ratio: 1; position: relative;
  display: flex; align-items: center; justify-content: center; text-align: center;
  font-size: var(--fs-body); color: rgba(255,255,255,.9);
}
.scanner .reticle::before {
  content: ""; position: absolute; inset: 0; border-radius: 16px;
  --c: rgba(255,255,255,.95);
  background:
    linear-gradient(var(--c),var(--c)) top left / 36px 4px,
    linear-gradient(var(--c),var(--c)) top left / 4px 36px,
    linear-gradient(var(--c),var(--c)) top right / 36px 4px,
    linear-gradient(var(--c),var(--c)) top right / 4px 36px,
    linear-gradient(var(--c),var(--c)) bottom left / 36px 4px,
    linear-gradient(var(--c),var(--c)) bottom left / 4px 36px,
    linear-gradient(var(--c),var(--c)) bottom right / 36px 4px,
    linear-gradient(var(--c),var(--c)) bottom right / 4px 36px;
  background-repeat: no-repeat;
}
.scanner.is-detecting .reticle::before { --c: #60A5FA; }
.scanner.is-success   .reticle::before { --c: #4ADE80; }
.scanner.is-error     .reticle::before { --c: #F87171; }
.scanner .cam-label {
  position: absolute; left: 12px; top: 12px; font-size: var(--fs-micro);
  background: rgba(0,0,0,.4); padding: 3px 8px; border-radius: 999px; display: flex; gap: 6px; align-items: center;
}
.scanner .cam-label::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #F87171; }
.scanner.is-off { background: var(--n-100); color: var(--text-2); }
.scanner.is-off .reticle::before { display: none; }

/* ════════════════════════════════════════════
   Student Search 結果列
   ════════════════════════════════════════════ */
.result-list { display: flex; flex-direction: column; }
.result-row {
  display: flex; align-items: center; gap: 12px;
  min-height: 64px; padding: 8px 16px;
  border-bottom: 1px solid var(--border);
}
.result-row:last-child { border-bottom: 0; }
.result-row .who { flex: 1; min-width: 0; }
.result-row .nm { font-size: 17px; font-weight: var(--fw-bold); }
.result-row .nm mark { background: #FEF08A; color: inherit; border-radius: 2px; }
.result-row .meta { font-size: var(--fs-caption); color: var(--text-2); }
.result-row .chev { color: var(--text-3); font-size: 20px; }
.result-row.is-active { background: var(--bg-subtle); }

/* ════════════════════════════════════════════
   Homework Row Editor
   ════════════════════════════════════════════ */
.hw-head, .hw-row {
  display: grid;
  grid-template-columns: 196px 128px 220px 1fr 48px;
  gap: 10px; align-items: center;
}
.hw-head { font-size: var(--fs-caption); color: var(--text-3); padding: 0 12px 6px; }
.hw-row { padding: 8px 12px; border-radius: var(--r-md); }
.hw-row + .hw-row { border-top: 1px solid var(--border); }
.hw-row.is-prefilled { background: #FAFBFC; }
.hw-row.is-locked { background: var(--bg-subtle); }
.hw-row.is-locked .input, .hw-row.is-locked .select { background: var(--bg-subtle); color: var(--text-2); border-color: var(--border); }
.hw-src { display: flex; align-items: center; gap: 6px; }
.hw-del { color: var(--text-3); }

/* ════════════════════════════════════════════
   Toggle with Field（留班開關＋原因，FR-020 U-02）
   ════════════════════════════════════════════ */
.stay-head { display: flex; align-items: center; gap: 12px; min-height: var(--touch); }
.stay-head .lbl { font-size: var(--fs-body); font-weight: var(--fw-medium); }
.stay-body { margin-top: 8px; padding-left: 60px; display: flex; flex-direction: column; gap: 8px; }
.stay-body .input { max-width: 640px; }
.stay-body .input .tpl-blank { color: var(--text-disabled); }
.parent-says { font-size: var(--fs-caption); color: var(--text-2); display: flex; gap: 6px; align-items: center; }
.parent-says .ic { color: #06C755; font-size: 15px; }

/* 卡片區塊（表單分區） */
.form-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px 16px 12px; }
.form-card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.form-card-head .right { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: var(--fs-body); }
.form-card.is-collapsed { padding-bottom: 16px; }
.add-row { margin: 8px 12px 0; }

/* ════════════════════════════════════════════
   Desktop shell（左側欄 240px）
   ════════════════════════════════════════════ */
.app-desktop { display: grid; grid-template-columns: var(--nav-w) 1fr; height: 100%; }
.sidebar {
  background: var(--n-900); color: var(--n-300);
  display: flex; flex-direction: column; padding: 16px 12px; gap: 2px;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; color: #fff; font-weight: 600; font-size: 15px; }
.sidebar .brand .logo { width: 32px; height: 32px; border-radius: 8px; background: #fff; color: var(--n-900); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.side-group { font-size: 11px; color: var(--n-500); padding: 12px 10px 6px; letter-spacing: .04em; }
.side-item {
  display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 10px;
  border-radius: 8px; font-size: var(--fs-body-sm);
}
.side-item .ic { font-size: 18px; }
.side-item.is-active { background: var(--n-700); color: #fff; font-weight: var(--fw-medium); }
.side-item .count { margin-left: auto; font-size: 12px; color: var(--n-400); font-variant-numeric: tabular-nums; }
.sidebar .spacer { flex: 1; }
.sidebar .user { display: flex; align-items: center; gap: 10px; padding: 12px 8px 4px; border-top: 1px solid var(--n-800); }
.sidebar .user .me { width: 32px; height: 32px; border-radius: 50%; background: var(--n-700); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; flex: none; }
.sidebar .user .who { flex: 1; min-width: 0; font-size: 13px; color: #fff; line-height: 1.3; }
.sidebar .user .who small { display: block; color: var(--n-400); font-size: 11px; }

.live { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-caption); color: var(--text-2); }
.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--hw-done); box-shadow: 0 0 0 3px rgba(22,163,74,.18); }
.live.is-off { color: var(--danger); }
.live.is-off::before { background: var(--danger); box-shadow: 0 0 0 3px rgba(220,38,38,.18); }

/* 科目篩選：● 我負責 */
.chip .mine { width: 7px; height: 7px; border-radius: 50%; background: var(--st-in-progress); }
.chip.is-on .mine { background: #93C5FD; }

/* ════════════════════════════════════════════
   批改按鈕（全對／有錯）：用結果的狀態色
   ════════════════════════════════════════════ */
.btn-ok { background: #fff; color: var(--hw-done-ink); border-color: #86EFAC; min-width: 92px; }
.btn-ok:hover, .btn-ok.is-hover { background: var(--hw-done-tint); border-color: var(--hw-done); }
.btn-ng { background: #fff; color: var(--hw-correcting-ink); border-color: #FDBA74; min-width: 92px; }
.btn-ng:hover, .btn-ng.is-hover { background: var(--hw-correcting-tint); border-color: var(--hw-correcting); }

/* ════════════════════════════════════════════
   Group Header ＋ Grading Row
   ════════════════════════════════════════════ */
.grade-section { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.grade-section.quick { border-color: #86EFAC; }
.grade-section.quick .group-head { background: var(--hw-done-tint); }
.group-head {
  display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 16px;
  font-size: var(--fs-body); font-weight: var(--fw-bold); border-bottom: 1px solid var(--border);
}
.group-head .ic { font-size: 18px; color: var(--text-3); }
.group-head .cnt { font-weight: var(--fw-regular); color: var(--text-2); font-size: var(--fs-body-sm); font-variant-numeric: tabular-nums; }
.group-head .right { margin-left: auto; display: flex; gap: 12px; align-items: center; font-weight: var(--fw-regular); font-size: var(--fs-caption); color: var(--text-3); }
.grade-section.is-collapsed .group-head { border-bottom: 0; }

.g-row {
  display: grid; grid-template-columns: 120px 150px 1fr auto; gap: 12px; align-items: center;
  height: 56px; padding: 0 16px; border-bottom: 1px solid var(--n-100); font-size: var(--fs-body-sm);
}
.g-row:last-child { border-bottom: 0; }
.g-row.has-hw { grid-template-columns: 120px 150px 200px 1fr auto; }
.g-row .nm { font-size: var(--fs-body); font-weight: var(--fw-medium); }
.g-row .cls { color: var(--text-2); }
.g-row .st { display: flex; gap: 8px; align-items: center; }
.g-row .acts { display: flex; gap: 12px; align-items: center; justify-content: flex-end; min-width: 196px; }
.g-row.quick { box-shadow: inset 4px 0 0 var(--hw-done); }
.g-row.is-just { background: #FFFBF5; }
.g-row.is-just .acts { font-size: var(--fs-caption); color: var(--text-2); }
.g-row .countdown { font-variant-numeric: tabular-nums; font-weight: var(--fw-medium); color: var(--text); }
.g-row.is-conflict { background: var(--bg-subtle); }
.g-row.is-conflict .msg { font-size: var(--fs-caption); color: var(--text-2); display: flex; gap: 6px; align-items: center; }
.g-row.is-done { opacity: .5; }

/* ════════════════════════════════════════════
   Undo Toast（2:00 倒數）
   ════════════════════════════════════════════ */
.toast {
  position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 40;
  display: flex; align-items: center; gap: 16px; min-width: 480px;
  background: var(--n-900); color: #fff; border-radius: var(--r-lg); padding: 12px 12px 12px 18px;
  box-shadow: var(--shadow-3); font-size: var(--fs-body-sm); overflow: hidden;
}
.toast .ic { font-size: 18px; color: #FDBA74; }
.toast .msg { flex: 1; }
.toast .t { font-variant-numeric: tabular-nums; color: var(--n-400); font-size: var(--fs-caption); }
.toast .btn { background: #fff; color: var(--n-900); }
.toast .bar { position: absolute; left: 0; bottom: 0; height: 3px; background: #FDBA74; }

/* ════════════════════════════════════════════
   Stat Tile（今日總覽，可點擊篩選）
   ════════════════════════════════════════════ */
.stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.stat {
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; position: relative; overflow: hidden;
}
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c, var(--n-300)); }
.stat .lbl { display: flex; align-items: center; gap: 6px; font-size: var(--fs-body-sm); color: var(--text-2); }
.stat .lbl .ic { color: var(--c); font-size: 16px; }
.stat .v { font-size: 32px; font-weight: var(--fw-bold); line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat.is-on { border-color: var(--c); box-shadow: 0 0 0 1px var(--c); }

/* ════════════════════════════════════════════
   Waiting Row／需要處理列
   ════════════════════════════════════════════ */
.list-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
.list-card > .head { display: flex; align-items: center; gap: 8px; height: 52px; padding: 0 16px; border-bottom: 1px solid var(--border); font-weight: var(--fw-bold); flex: none; }
.list-card > .head .cnt { font-weight: var(--fw-regular); color: var(--text-2); font-variant-numeric: tabular-nums; }
.list-card > .head .right { margin-left: auto; font-weight: var(--fw-regular); }
.w-row { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 8px 16px; border-bottom: 1px solid var(--n-100); font-size: var(--fs-body-sm); }
.w-row:last-child { border-bottom: 0; }
.w-row .nm { font-size: var(--fs-body); font-weight: var(--fw-medium); min-width: 72px; }
.w-row .cls { color: var(--text-2); min-width: 120px; }
.w-row .wait { font-variant-numeric: tabular-nums; color: var(--text); font-weight: var(--fw-medium); }
.w-row .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.w-row .ic.warn { color: var(--warn); font-size: 18px; }
.w-row .ic.err { color: var(--danger); font-size: 18px; }
.w-row .time { color: var(--text-3); font-variant-numeric: tabular-nums; font-size: var(--fs-caption); }

/* ════════════════════════════════════════════
   Timeline（狀態歷史，FR-011）
   ════════════════════════════════════════════ */
.timeline { display: flex; flex-direction: column; }
.tl-row { display: grid; grid-template-columns: 64px 20px 1fr auto; gap: 12px; align-items: start; padding: 10px 0; font-size: var(--fs-body-sm); position: relative; }
.tl-row .t { font-variant-numeric: tabular-nums; color: var(--text-2); padding-top: 2px; }
.tl-row .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c, var(--n-300)); margin: 5px 4px 0; position: relative; z-index: 1; box-shadow: 0 0 0 3px #fff; }
.tl-row:not(:last-child)::after { content: ""; position: absolute; left: 85px; top: 22px; bottom: -10px; width: 2px; background: var(--n-200); }
.tl-row .what { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tl-row .what .arrow { color: var(--text-3); }
.tl-row .by { color: var(--text-3); font-size: var(--fs-caption); text-align: right; }
.tl-row.is-hw .what { color: var(--text-2); }

/* ════════════════════════════════════════════
   Tabs
   ════════════════════════════════════════════ */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.tab { height: 44px; padding: 0 14px; display: inline-flex; align-items: center; font-size: var(--fs-body-sm); color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.is-on { color: var(--text); border-bottom-color: var(--action); font-weight: var(--fw-medium); }

/* ════════════════════════════════════════════
   Mobile shell（底部分頁列）
   ════════════════════════════════════════════ */
.app-mobile { display: flex; flex-direction: column; height: 100%; background: var(--bg-app); }
.m-status { height: 44px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; font-size: 14px; font-weight: 600; background: var(--bg-surface); }
.m-header { height: 52px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 12px 0 16px; background: var(--bg-surface); border-bottom: 1px solid var(--border); }
.m-header h1 { font-size: 20px; margin: 0; font-weight: 600; }
.m-header .right { margin-left: auto; display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--text-2); }
.m-content { flex: 1; min-height: 0; overflow: hidden; padding: 12px 16px; display: flex; flex-direction: column; gap: 12px; }
.m-tabs { height: 83px; flex: none; display: grid; grid-template-columns: repeat(3, 1fr); background: var(--bg-surface); border-top: 1px solid var(--border); padding-bottom: 28px; }
.m-tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; color: var(--text-3); }
.m-tab .ic { font-size: 22px; }
.m-tab.is-on { color: var(--text); font-weight: 600; }

/* ════════════════════════════════════════════
   OTP Input（FR-015）
   ════════════════════════════════════════════ */
.otp { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.otp span { height: 52px; border: 1px solid var(--border-strong); border-radius: var(--r-md); display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 600; background: #fff; font-variant-numeric: tabular-nums; }
.otp span.is-focus { border-color: var(--focus); box-shadow: 0 0 0 3px rgba(37,99,235,.18); }
.otp.is-error span { border-color: var(--danger); color: var(--danger); }

/* LINE 品牌按鈕（只用在 LINE 相關畫面） */
.btn-line { background: #06C755; color: #fff; }
.proto-frame.line { width: 375px; height: 812px; }

/* ════════════════════════════════════════════
   Nav（兩層側欄：大項 › 子項；電腦與平板共用）
   大項只展開／收合，不換頁；預設全部展開
   ════════════════════════════════════════════ */
.nav2 { background: var(--n-900); color: var(--n-300); display: flex; flex-direction: column; height: 100%; min-height: 0; }
.nav2 .brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px 12px; color: #fff; font-weight: 600; font-size: 15px; flex: none; }
.nav2 .brand .logo { width: 32px; height: 32px; border-radius: 8px; background: #fff; color: var(--n-900); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.nav2 .menu { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav2 .grp { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 10px; border-radius: 8px; color: #E2E8F0; font-size: 14px; font-weight: 600; margin-top: 6px; }
.nav2 .grp:first-child { margin-top: 0; }
.nav2 .grp .ic { font-size: 18px; color: var(--n-400); }
.nav2 .grp .chev { margin-left: auto; font-size: 16px; color: var(--n-500); }
.nav2 .grp .sum { margin-left: auto; }
.nav2 .grp .sum + .chev { margin-left: 6px; }
.nav2 .sub { display: flex; align-items: center; height: 40px; padding: 0 10px 0 38px; border-radius: 8px; font-size: 14px; color: var(--n-300); }
.nav2 .sub.is-active { background: var(--n-700); color: #fff; font-weight: 500; }
.nav2 .cnt { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; }
.nav2 .user { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--n-800); flex: none; }
.nav2 .user .me { width: 32px; height: 32px; border-radius: 50%; background: var(--n-700); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; flex: none; }
.nav2 .user .who { flex: 1; min-width: 0; font-size: 13px; color: #fff; line-height: 1.3; }
.nav2 .user .who small { display: block; color: var(--n-400); font-size: 11px; }
.nav2 .user .ic { font-size: 18px; color: var(--n-400); }
/* 平板：觸控目標 48 */
.app-tablet .nav2 .grp { height: 44px; }
.app-tablet .nav2 .sub { height: 48px; }

/* ════════════════════════════════════════════
   Side Panel：當天作業紀錄（P06、P07 共用）
   不離開目前頁面，右側滑出；沒有遮罩，左邊仍可操作
   ════════════════════════════════════════════ */
.side-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: 420px; z-index: 45;
  background: #fff; box-shadow: -12px 0 32px rgba(15,23,42,.14); border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.side-panel .sp-hd { padding: 16px 20px 12px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.side-panel .sp-hd .row1 { display: flex; align-items: center; gap: 10px; }
.side-panel .sp-hd h2 { margin: 0; font-size: 20px; }
.side-panel .sp-hd .meta { font-size: 13px; color: var(--text-2); }
.side-panel .sp-hd .x { margin-left: auto; }
.side-panel .sp-bd { flex: 1; overflow: hidden; padding: 12px 20px; display: flex; flex-direction: column; gap: 10px; }
.side-panel .sp-sec { font-size: 12px; color: var(--text-3); font-weight: 600; letter-spacing: .04em; margin-top: 4px; }
.hw-card { border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.hw-card .top { display: flex; align-items: center; gap: 8px; }
.hw-card .top b { font-size: 15px; }
.hw-card .top .badge { margin-left: auto; }
.hw-card .log { font-size: 12.5px; color: var(--text-2); display: flex; flex-direction: column; gap: 2px; }
.hw-card .log span { display: flex; gap: 8px; }
.hw-card .log .t { font-variant-numeric: tabular-nums; color: var(--text-3); width: 40px; flex: none; }
.side-panel .sp-ft { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--text-2); }
.side-panel .sp-ft a { color: var(--focus); text-decoration: none; font-weight: 500; }
.g-row.is-open { background: var(--info-tint); box-shadow: inset 4px 0 0 var(--focus); }

/* 原型標籤：這個畫面給誰用（只用在原型外框，不屬於設計；由 proto.js 依 data-aud 產生） */
.aud { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; font-weight: 700; padding: 2px 9px; border-radius: 999px; white-space: nowrap; vertical-align: middle; line-height: 1.5; }
.aud.dir     { background: #E0E7FF; color: #3730A3; }
.aud.adm     { background: #EDE9FE; color: #5B21B6; }
.aud.tch     { background: #FEF3C7; color: #92400E; }
.aud.reg     { background: #FCE7F3; color: #9D174D; }
.aud.desk    { background: #CFFAFE; color: #155E75; }
.aud.pub     { background: #0F172A; color: #fff; }
.aud.parent  { background: #D1FAE5; color: #065F46; }
.aud.student { background: #FFEDD5; color: #9A3412; }
.aud.all     { background: #E2E8F0; color: #334155; }
.aud.ro      { background: #fff; box-shadow: inset 0 0 0 1.5px currentColor; }
.aud-row { display: inline-flex; gap: 4px; flex-wrap: wrap; vertical-align: middle; }
.proto-frame-label .aud-row { margin-right: 6px; }
.proto-frame-label { flex-wrap: wrap; align-items: center; }

/* 頁首：這一頁在選單的位置、給誰用、裝置 */
.proto-meta { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; padding: 8px 24px; background: #1F2937; color: #E5E7EB; font-size: 12.5px; }
.proto-meta .k { color: #9CA3AF; margin-right: 6px; }
.proto-meta .path { font-weight: 700; color: #fff; font-size: 13.5px; }
