:root {
  --ink: #1d1d1f;
  --ink-soft: #3a3a3c;
  --muted: #6e6e73;
  --subtle: #86868b;
  --line: #d2d2d7;
  --line-soft: #e8e8ed;
  --canvas: #f5f5f7;
  --paper: #ffffff;
  --paper-tint: #fbfbfd;
  --blue: #3478f6;
  --blue-dark: #1d5dcc;
  --blue-soft: #edf4ff;
  --green: #248a5b;
  --green-soft: #eef9f3;
  --amber: #a46b00;
  --amber-soft: #fff7e5;
  --red: #c9342b;
  --red-soft: #fff5f4;
  --mine: #eaf2ff;
  --foreign: #fff4d8;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 22px rgba(30, 40, 60, .05);
  --shadow-md: 0 18px 50px rgba(30, 40, 60, .10);
  --ease: 200ms cubic-bezier(.2, .65, .25, 1);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "PingFang SC", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  padding: 0 0 72px;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--canvas);
  font-family: inherit;
  letter-spacing: 0;
  line-height: 1.45;
}

button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .58; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid rgba(52, 120, 246, .34);
  outline-offset: 2px;
}
h1, h2, h3, p { overflow-wrap: anywhere; }
small { color: var(--muted); font-weight: 500; line-height: 1.5; }
[hidden] { display: none !important; }

/* Shared controls */
label { display: flex; flex-direction: column; gap: 7px; min-width: 0; color: var(--ink-soft); font-size: .87rem; font-weight: 650; }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--ink);
  background: var(--paper);
  outline: 0;
  transition: border-color var(--ease), box-shadow var(--ease), background var(--ease);
}
textarea { min-height: 150px; resize: vertical; line-height: 1.65; }
input:hover, select:hover, textarea:hover { border-color: #a1a1a6; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(52, 120, 246, .13); }
input:disabled, select:disabled, textarea:disabled { color: var(--subtle); background: var(--canvas); cursor: not-allowed; }

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px 16px;
  color: var(--ink);
  background: var(--paper);
  font-size: .9rem;
  font-weight: 680;
  text-align: center;
  transition: transform var(--ease), box-shadow var(--ease), border-color var(--ease), background var(--ease), color var(--ease);
}
.button:hover { transform: translateY(-1px); border-color: #a1a1a6; box-shadow: 0 6px 15px rgba(0, 0, 0, .08); }
.button.primary { border-color: var(--blue); color: #fff; background: var(--blue); box-shadow: 0 6px 16px rgba(52, 120, 246, .20); }
.button.primary:hover { border-color: var(--blue-dark); background: var(--blue-dark); }
.button.secondary { border-color: #c7d9fb; color: var(--blue-dark); background: var(--blue-soft); }
.button.secondary:hover { border-color: #9dbbf3; background: #e3eeff; }
.button.ghost { color: var(--muted); background: transparent; }
.button.ghost:hover { color: var(--ink); background: rgba(255, 255, 255, .7); }
.button.danger { border-color: #f0cfcc; color: var(--red); background: var(--red-soft); }
.button.danger:hover { border-color: #e7aaa4; background: #ffedeb; }
.text-button { min-height: 40px; border: 0; border-radius: 9px; padding: 8px 10px; color: var(--blue-dark); background: transparent; font-weight: 700; }
.text-button:hover { background: var(--blue-soft); }

/* App shell */
.app-header {
  display: flex;
  width: min(1240px, 100%);
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 0 auto;
  padding: 30px 28px 18px;
}
.brand { display: flex; min-width: 0; align-items: center; gap: 13px; }
.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 8px;
  border-radius: 13px;
  background: var(--ink);
}
.brand-mark span { min-width: 0; border-radius: 3px; background: #fff; }
.brand-mark span:last-child { background: #f7c04a; }
.eyebrow { margin: 0; color: var(--subtle); font-size: .68rem; font-weight: 750; letter-spacing: .18em; }
.app-header h1 { margin: 2px 0 0; color: var(--ink); font-size: clamp(1.45rem, 2.7vw, 2.05rem); font-weight: 760; letter-spacing: -.035em; line-height: 1.2; }
.account-tools { display: flex; min-width: 0; align-items: center; justify-content: flex-end; gap: 10px; }
.account-name, .logout-button, .save-state { display: inline-flex; height: 40px; min-height: 40px; align-items: center; border: 1px solid var(--line); border-radius: 10px; background: rgba(255, 255, 255, .82); box-shadow: none; backdrop-filter: blur(14px); line-height: 1.2; }
.save-state { position: relative; justify-content: center; padding: 8px 13px 8px 28px; color: var(--green); font-size: .78rem; font-weight: 650; white-space: nowrap; }
.save-state:before { content: ""; position: absolute; top: 50%; left: 12px; width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(36, 138, 91, .10); transform: translateY(-50%); }
.save-state[data-status="saving"] { color: var(--muted); }
.save-state[data-status="saving"]:before { background: var(--amber); box-shadow: 0 0 0 4px rgba(164, 107, 0, .10); }
.save-state[data-status="error"] { color: var(--red); }
.save-state[data-status="error"]:before { background: var(--red); box-shadow: 0 0 0 4px rgba(201, 52, 43, .10); }
.account-name { max-width: 170px; min-width: 0; overflow: hidden; justify-content: center; padding: 8px 11px; color: var(--muted); font-size: .78rem; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.account-name:hover { border-color: #a1a1a6; background: var(--paper); }
.logout-button { justify-content: center; padding: 8px 12px; color: var(--ink-soft); font-size: .78rem; font-weight: 650; white-space: nowrap; transition: border-color var(--ease), background var(--ease); }
.logout-button:hover { border-color: #a1a1a6; background: var(--paper); }

.top-tabs {
  display: grid;
  width: min(1184px, calc(100% - 40px));
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  margin: 0 auto 30px;
  padding: 4px;
  border-radius: 14px;
  background: #e8e8ed;
}
.top-tab { min-width: 0; min-height: 44px; border: 0; border-radius: 10px; padding: 10px 16px; color: var(--muted); background: transparent; font-size: .9rem; font-weight: 680; line-height: 1.35; overflow-wrap: anywhere; transition: background var(--ease), color var(--ease), box-shadow var(--ease); }
.top-tab:hover { color: var(--ink); }
.top-tab.active { color: var(--ink); background: var(--paper); box-shadow: 0 2px 8px rgba(0, 0, 0, .10); }
.tab-label-short, .button-label-short { display: none; }

main { width: min(1184px, calc(100% - 40px)); min-width: 0; margin: 0 auto; padding-bottom: 20px; }
.page { display: none; min-width: 0; }
.page.active { display: block; }
.intro-row { display: flex; min-width: 0; align-items: flex-end; justify-content: space-between; gap: 18px; margin: 27px 2px 17px; }
.intro-row h2, .result-head h2 { margin: 0; color: var(--ink); font-size: 1.55rem; font-weight: 760; letter-spacing: -.025em; line-height: 1.25; }
.intro-row p, .result-head p { margin: 6px 0 0; color: var(--muted); font-size: .94rem; line-height: 1.6; }
.intro-actions { display: flex; align-items: center; gap: 9px; }
.card, .results { min-width: 0; border: 1px solid var(--line-soft); border-radius: var(--radius-lg); background: var(--paper); box-shadow: var(--shadow-sm); }
.card { padding: 21px; margin-bottom: 16px; }

/* Setup and schedule */
.automation-note { display: flex; align-items: center; gap: 12px; margin: 0 0 14px; padding: 13px 16px; border: 1px solid #c9e8d8; border-radius: var(--radius-md); color: #286647; background: #f4fbf7; }
.automation-note .auto-icon { display: grid; width: 32px; height: 32px; flex: 0 0 auto; place-items: center; border-radius: 50%; color: #fff; background: var(--green); font-weight: 800; }
.automation-note strong, .automation-note small { display: block; }
.automation-note small { margin-top: 3px; color: #58766b; }
.setup-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 14px; background: var(--paper-tint); }
.setup-summary > label { min-height: 122px; justify-content: flex-start; padding: 15px; border: 1px solid var(--line-soft); border-radius: 14px; background: var(--paper); }
.setup-summary > label:focus-within { border-color: #a9c5fa; box-shadow: 0 0 0 3px rgba(52, 120, 246, .10); }
.setup-summary > label small { margin-top: auto; }
.homeroom-choice { min-width: 0; min-height: 122px; margin: 0; padding: 14px 15px; border: 1px solid var(--line-soft); border-radius: 14px; background: var(--paper); }
.homeroom-choice legend { padding: 0 4px; color: var(--ink-soft); font-size: .84rem; font-weight: 700; }
.choice-options { display: flex; gap: 10px; margin: 6px 0 8px; }
.choice-options label { display: flex; min-width: 0; min-height: 42px; flex: 1; align-items: center; gap: 8px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink-soft); background: var(--paper); cursor: pointer; }
.choice-options input { width: 18px; height: 18px; margin: 0; accent-color: var(--blue); }
.homeroom-choice small { display: block; color: var(--muted); line-height: 1.45; }
.homeroom-settings { display: grid; grid-column: 1 / -1; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.homeroom-settings[hidden] { display: none; }
.homeroom-settings > label { min-height: 104px; justify-content: flex-start; padding: 15px; border: 1px solid var(--line-soft); border-radius: 14px; background: var(--paper); }
.homeroom-settings > label small { margin-top: auto; }
.school-rule-card { display: flex; align-items: center; margin-bottom: 16px; padding: 15px 18px; background: var(--paper-tint); }
.school-rule-card .switch-field { width: 100%; min-height: 44px; flex-direction: row; align-items: center; justify-content: space-between; gap: 16px; }
.school-rule-card .switch-copy { min-width: 0; }
.school-rule-card .switch-copy small { max-width: 60em; margin-top: 3px; }
.switch-field { flex-direction: row; align-items: center; justify-content: space-between; gap: 16px; }
.switch-copy { display: flex; min-width: 0; flex-direction: column; gap: 5px; }
.switch-copy strong { color: var(--ink-soft); font-size: .9rem; }
.switch { position: relative; flex: 0 0 auto; }
.switch input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.switch-track { display: block; width: 49px; height: 28px; border-radius: 999px; padding: 3px; background: #c7c7cc; box-shadow: inset 0 1px 3px rgba(15, 35, 70, .12); transition: background var(--ease); }
.switch-track span { display: block; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(15, 35, 70, .25); transition: transform var(--ease); }
.switch input:focus-visible + .switch-track { outline: 3px solid rgba(52, 120, 246, .34); outline-offset: 2px; }
.switch input:checked + .switch-track { background: var(--blue); }
.switch input:checked + .switch-track span { transform: translateX(21px); }
.class-list-head { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 14px; margin: 23px 2px 12px; }
.class-list-head h3 { margin: 0; color: var(--ink); font-size: 1.05rem; }
.class-list-head small { display: block; margin-top: 4px; color: var(--muted); }
.class-validation, .paused-foreign-note { margin: 0 0 12px; padding: 10px 13px; border: 1px solid #f0d7a8; border-radius: 10px; color: #765318; background: #fff8e8; font-size: .86rem; line-height: 1.5; }
.class-validation[hidden], .paused-foreign-note[hidden] { display: none; }
.paused-foreign-note { border-color: #dce2eb; color: var(--muted); background: #f7f8fa; }
.class-stack { display: grid; gap: 18px; }
.class-card { overflow: hidden; padding: 0; border-radius: var(--radius-lg); }
.class-card > summary.class-summary { display: flex; min-height: 70px; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 21px; cursor: pointer; background: var(--paper); list-style: none; }
.class-card > summary.class-summary::-webkit-details-marker, .details-card > summary::-webkit-details-marker, .exception-group > summary::-webkit-details-marker { display: none; }
.class-card > summary.class-summary:after { content: "展开"; flex: 0 0 auto; color: var(--muted); font-size: .78rem; font-weight: 700; }
.class-card[open] > summary.class-summary:after { content: "收起"; }
.class-summary > span:first-child { display: flex; min-width: 0; flex-direction: column; gap: 4px; }
.class-summary strong { color: var(--ink); font-size: 1rem; }
.class-summary small { font-size: .82rem; }
.class-summary .summary-state { margin-left: auto; }
.class-card[open] > .class-summary { border-bottom: 1px solid var(--line-soft); }
.summary-state { display: inline-flex !important; min-height: 26px; align-items: center !important; justify-content: center; flex: 0 0 auto; border-radius: 999px; padding: 5px 9px; color: var(--muted); background: #f0f0f2; font-size: .75rem; font-weight: 750; line-height: 1; white-space: nowrap; }
.summary-state.done, .exception-status.done { color: var(--green); background: var(--green-soft); }
.summary-state.needs, .exception-status.needs { color: var(--amber); background: var(--amber-soft); }
.summary-state.auto { color: var(--blue-dark); background: var(--blue-soft); }
.class-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 13px; align-items: end; padding: 20px 21px 16px; border-bottom: 1px solid var(--line-soft); background: var(--paper-tint); }
.class-top input { background: var(--paper); }
.class-top .delete-class { min-height: 44px; white-space: nowrap; }
.class-body { padding: 20px; }
.schedule-help { display: flex; min-height: 31px; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; color: var(--muted); font-size: .84rem; }
.schedule-help > span { min-width: 0; }
.legend { display: flex; flex: 0 0 auto; flex-wrap: wrap; align-items: center; gap: 7px; }
.legend span { padding: 5px 8px; border-radius: 7px; font-size: .76rem; font-weight: 700; line-height: 1.2; white-space: nowrap; }
.legend .mine { color: #2153a6; background: var(--mine); }
.legend .foreign { color: #8c5d08; background: var(--foreign); }
.schedule-side { min-width: 0; }
.grid-wrap { position: relative; width: 100%; overflow-x: auto; overflow-y: hidden; border: 1px solid var(--line-soft); border-radius: 14px; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
.schedule-grid { width: 100%; min-width: 620px; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.schedule-grid th, .schedule-grid td { border-right: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); padding: 6px; text-align: center; }
.schedule-grid th:last-child, .schedule-grid td:last-child { border-right: 0; }
.schedule-grid tr:last-child td, .schedule-grid tr:last-child th { border-bottom: 0; }
.schedule-grid th { width: 68px; color: var(--muted); background: var(--canvas); font-size: .78rem; }
.schedule-grid th:first-child { width: 68px; }
.schedule-grid thead th:first-child, .schedule-grid tbody th:first-child { position: sticky; left: 0; z-index: 2; box-shadow: 1px 0 0 var(--line-soft), 5px 0 12px rgba(30, 40, 60, .06); }
.schedule-grid thead th:first-child { z-index: 3; }
.schedule-grid tbody th:first-child { background: var(--paper); }
.schedule-grid td { background: var(--paper); }
.cell-button { width: 100%; min-height: 38px; border: 0; border-radius: 8px; color: var(--subtle); background: var(--canvas); font-size: .78rem; font-weight: 750; transition: transform var(--ease), box-shadow var(--ease), background var(--ease); }
.cell-button:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0, 0, 0, .08); }
.cell-button.mine { color: #2153a6; background: var(--mine); }
.cell-button.foreign { color: #8c5d08; background: var(--foreign); }
.cell-button.paused { color: var(--muted); background: #eceef2; cursor: not-allowed; }
.cell-button.other { color: var(--muted); background: var(--canvas); }
.schedule-scroll-hint { display: none; }

.details-card { overflow: hidden; padding: 0; }
.details-card > summary { display: flex; min-height: 64px; align-items: center; justify-content: space-between; gap: 14px; padding: 18px 21px; cursor: pointer; list-style: none; }
.details-card > summary > span:first-child { display: flex; min-width: 0; align-items: baseline; gap: 10px; }
.details-card > summary strong { color: var(--ink); }
.details-card > summary small { display: block; }
.details-card > summary:after { content: "⌄"; flex: 0 0 auto; color: var(--muted); font-size: 1.15rem; transition: transform var(--ease); }
.details-card[open] > summary:after { transform: rotate(180deg); }
.details-card > summary:hover { background: var(--paper-tint); }
.details-card[open] > summary { border-bottom: 1px solid var(--line-soft); background: var(--paper-tint); }
.details-body { min-width: 0; padding: 20px 21px; border-top: 0; }
.setup-fold:not([open]) { margin-bottom: 16px; }
.duty-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.duty-grid > div { min-width: 0; padding: 16px; border: 1px solid var(--line-soft); border-radius: 14px; background: var(--paper-tint); }
.duty-grid > div > strong { display: block; color: var(--ink); }
.duty-grid > div > small { display: block; margin-top: 4px; }
.weekday-picks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.duty-assignment { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 8px; align-items: center; }
.duty-assignment select { min-height: 40px; padding: 8px 9px; font-size: .84rem; }
.weekday-check { position: relative; }
.weekday-check input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.weekday-check span { display: grid; min-height: 44px; place-items: center; border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px; color: var(--muted); background: var(--paper); font-size: .86rem; font-weight: 700; text-align: center; }
.weekday-check input:checked + span { border-color: #a8c6fb; color: var(--blue-dark); background: var(--blue-soft); }
.weekday-check input:focus-visible + span { outline: 3px solid rgba(52, 120, 246, .34); outline-offset: 2px; }
.bottom-actions { display: flex; justify-content: flex-end; margin-top: 20px; }

/* Monthly notice, exceptions, and report */
.notice-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: start; }
.notice-guide { display: flex; min-width: 0; align-items: center; gap: 12px; }
.notice-guide > span { display: grid; width: 34px; height: 34px; flex: 0 0 auto; place-items: center; border-radius: 11px; color: #fff; background: var(--ink); font-weight: 800; }
.notice-guide strong, .notice-guide small { display: block; }
.notice-guide small { margin-top: 3px; }
.notice-actions { display: flex; align-items: end; gap: 10px; grid-column: 2; }
.notice-actions label { width: 140px; }
.notice-card textarea { grid-column: 1 / -1; min-height: 150px; background: var(--paper-tint); }
.status-box { grid-column: 1 / -1; padding: 12px 14px; border: 1px solid #c7dcff; border-radius: 11px; color: #24508c; background: var(--blue-soft); font-size: .9rem; line-height: 1.55; }
.holiday-status[data-status="pending"] { border-color: #ead9a8; color: #765712; background: var(--amber-soft); }
.holiday-status[data-status="error"] { border-color: #f0c6c1; color: #914139; background: var(--red-soft); }
.compact-details { margin-bottom: 16px; }
.range-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.weekday-strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin: 14px 0; }
.weekday-item { min-width: 0; padding: 9px; border: 1px solid var(--line-soft); border-radius: 10px; background: var(--paper-tint); }
.weekday-item span { display: block; margin-bottom: 5px; color: var(--muted); font-size: .76rem; }
.weekday-item input { min-height: 40px; padding: 8px; text-align: center; font-weight: 750; }
.subhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 15px 0 9px; }
.subhead strong { color: var(--ink); }
.event-list { display: grid; gap: 8px; min-width: 0; }
.event-row { display: grid; grid-template-columns: 140px minmax(130px, 1.25fr) minmax(120px, .8fr) minmax(100px, 1fr) 40px; gap: 8px; align-items: center; padding: 9px; border: 1px solid var(--line-soft); border-radius: 11px; background: var(--paper-tint); }
.event-row.override { grid-template-columns: 140px minmax(120px, 1fr) minmax(120px, 1fr) minmax(120px, 1.2fr) 40px; }
.event-row .delete { min-height: 40px; border: 0; border-radius: 8px; color: var(--red); background: var(--red-soft); font-size: 1.15rem; font-weight: 750; }
.event-row .delete:hover { background: #ffedeb; }
.event-impact { display: flex; min-width: 0; grid-column: 1 / -1; align-items: center; gap: 14px; margin: 0; padding: 8px 10px; border: 1px solid var(--line-soft); border-radius: 10px; color: var(--ink-soft); background: var(--paper); }
.event-impact legend { padding: 0 5px; color: var(--muted); font-size: .78rem; font-weight: 750; }
.event-impact label { display: inline-flex; min-height: 36px; flex-direction: row; align-items: center; gap: 7px; white-space: nowrap; }
.event-impact input { width: 18px; min-height: 18px; }
.event-impact-confirm { color: var(--ink-soft); }
.event-impact-status { min-width: 0; margin-left: auto; color: var(--green); font-size: .78rem; line-height: 1.4; }
.event-impact-status.pending { color: var(--amber); }
.empty-note { padding: 18px 15px; border: 1px dashed var(--line); border-radius: 11px; color: var(--muted); background: var(--paper-tint); text-align: center; }
.optional-grid { display: grid; gap: 18px; }
.optional-block { min-width: 0; padding-bottom: 14px; border-bottom: 1px solid var(--line-soft); }
.adjust-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.foreign-adjustments { display: contents; }
.foreign-adjustments[hidden] { display: none; }
.override-help { margin: -2px 0 11px !important; padding: 10px 12px; border-radius: 10px; color: #526782 !important; background: var(--blue-soft); font-size: .84rem; line-height: 1.55; }
.official-calendar { display: grid; gap: 9px; }
.legal-summary { display: flex; flex-direction: column; gap: 5px; padding: 13px 14px; border: 1px solid #c6d7ff; border-radius: 12px; color: #294a9c; background: var(--blue-soft); }
.legal-summary span { font-size: .86rem; line-height: 1.55; }
.legal-summary small { color: #61729a; }
.official-row { display: grid; grid-template-columns: minmax(155px, .8fr) minmax(0, 1fr) minmax(0, 1fr); gap: 10px; align-items: end; padding: 12px; border: 1px solid var(--line-soft); border-radius: 12px; background: var(--paper-tint); }
.official-date { align-self: center; }
.official-date strong, .official-date small { display: block; }
.official-date small { margin-top: 4px; }
.schedule-mapping-list { display: grid; gap: 9px; }
.schedule-mapping-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(150px, .45fr) auto; gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--line-soft); border-radius: 12px; background: var(--paper-tint); }
.mapping-copy { min-width: 0; }
.mapping-copy strong, .mapping-copy small, .mapping-conflict { display: block; }
.mapping-copy small { margin-top: 4px; }
.mapping-conflict { margin-top: 4px; color: var(--amber); }
.mapping-enabled { flex-direction: row; align-items: center; gap: 8px; min-height: 44px; white-space: nowrap; }
.mapping-enabled input { width: 20px; min-height: 20px; }
.changes-card { overflow: hidden; padding: 0; }
.changes-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 22px 24px; border-bottom: 1px solid var(--line-soft); }
.changes-head h2 { margin: 4px 0; color: var(--ink); font-size: 1.28rem; line-height: 1.3; }
.changes-head p { margin: 0; color: var(--muted); }
.step-kicker { color: var(--blue); font-size: .75rem; font-weight: 800; letter-spacing: .08em; }
.default-pill { flex: 0 0 auto; padding: 8px 11px; border-radius: 999px; color: var(--green); background: var(--green-soft); font-size: .8rem; font-weight: 750; }
.exception-list { display: grid; padding: 10px 14px 14px; }
.exception-group { min-width: 0; border-bottom: 1px solid var(--line-soft); }
.exception-group:last-child { border-bottom: 0; }
.exception-group > summary { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 13px; align-items: center; padding: 15px 10px; border-radius: 13px; cursor: pointer; list-style: none; }
.exception-group > summary:hover { background: var(--paper-tint); }
.exception-group[open] > summary { background: #f7f9ff; }
.exception-icon { display: grid; width: 40px; height: 40px; place-items: center; border-radius: 11px; font-weight: 800; }
.exception-icon.calendar { color: var(--amber); background: var(--amber-soft); }
.exception-icon.morning { color: #9a6500; background: #fff6dc; }
.exception-icon.evening { color: #4b55af; background: #edf0ff; }
.exception-icon.other { color: var(--green); background: #edf8f5; }
.exception-copy { min-width: 0; }
.exception-copy strong, .exception-copy small { display: block; }
.exception-copy strong { color: var(--ink); }
.exception-copy small { margin-top: 4px; }
.exception-status { min-height: 26px; padding: 5px 9px; border-radius: 999px; color: var(--muted); background: #f0f0f2; font-size: .76rem; font-weight: 750; line-height: 1; white-space: nowrap; }
.exception-body { min-width: 0; padding: 4px 10px 18px 67px; }
.duty-questionnaire { padding-bottom: 20px; }
.question-summary-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(0, .75fr); gap: 10px; align-items: end; padding: 13px; border: 1px solid var(--line-soft); border-radius: 14px; background: var(--paper-tint); }
.duty-question-list { display: grid; gap: 9px; margin-top: 12px; }
.duty-question-row { display: grid; grid-template-columns: minmax(175px, .85fr) minmax(230px, 1.25fr) minmax(145px, .75fr); gap: 10px; align-items: end; padding: 12px; border: 1px solid var(--line-soft); border-radius: 13px; background: var(--paper-tint); }
.question-when { align-self: center; min-width: 0; }
.question-when strong, .question-when small { display: block; }
.question-when small { margin-top: 5px; }
.answer-ok { margin-top: 11px; padding: 12px 14px; border: 1px solid #c9e8d8; border-radius: 11px; color: #286647; background: var(--green-soft); font-size: .87rem; line-height: 1.55; }
.question-divider { height: 1px; margin: 18px 0; background: var(--line-soft); }
.extra-count[hidden] { display: none; }
.swap-day select:disabled { background: var(--canvas); }

.results { margin-top: 26px; padding: 25px; }
.result-head { display: flex; min-width: 0; align-items: flex-end; justify-content: space-between; gap: 16px; }
.result-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 9px; }
.record-meta { display: grid; grid-template-columns: minmax(220px, 360px) minmax(0, 1fr); gap: 12px; align-items: end; margin-top: 16px; padding: 13px 14px; border: 1px solid var(--line-soft); border-radius: 13px; background: var(--paper-tint); }
.record-meta small { padding-bottom: 11px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-top: 18px; }
.metric-grid.metric-grid-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric { position: relative; min-width: 0; overflow: hidden; padding: 19px; border: 1px solid var(--line-soft); border-radius: 15px; background: var(--paper-tint); }
.metric:first-child { border-color: var(--blue); color: #fff; background: var(--blue); }
.metric span { display: block; color: var(--muted); font-size: .86rem; font-weight: 700; }
.metric strong { display: block; margin-top: 7px; color: var(--ink); font-size: 2.15rem; letter-spacing: -.035em; line-height: 1; }
.metric small { display: block; margin-top: 7px; }
.metric:first-child span, .metric:first-child strong, .metric:first-child small { color: #fff; }
.metric:first-child small { opacity: .78; }
.metric.muted { opacity: .66; }
.audit { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.audit summary { min-height: 40px; padding: 9px 0; color: var(--blue-dark); cursor: pointer; font-weight: 750; }
.audit-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.audit-table th, .audit-table td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); text-align: left; font-size: .85rem; }
.audit-table th { color: var(--muted); background: var(--canvas); }
.audit-included { color: var(--green); font-weight: 700; }
.audit-excluded { color: var(--red); font-weight: 700; }
.audit-pending { color: var(--amber); font-weight: 700; }
.formula-box { margin-top: 12px; padding: 13px 14px; border: 1px solid var(--line-soft); border-radius: 10px; color: var(--ink-soft); background: var(--paper-tint); line-height: 1.65; }

/* History */
.history-card { padding: 14px; }
.history-list { display: grid; gap: 10px; min-width: 0; }
.history-record-items { display: grid; min-width: 0; gap: 10px; }
.history-row { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 16px; padding: 15px 16px; border: 1px solid var(--line-soft); border-radius: 14px; background: var(--paper); transition: border-color var(--ease), box-shadow var(--ease); }
.history-row:hover { border-color: #b8cef8; box-shadow: 0 5px 16px rgba(30, 70, 130, .07); }
.history-copy { min-width: 0; }
.history-copy strong, .history-copy span { display: block; }
.history-copy strong { overflow: hidden; color: var(--ink); font-size: 1rem; text-overflow: ellipsis; white-space: nowrap; }
.history-copy span { margin-top: 5px; color: var(--muted); font-size: .84rem; }
.history-actions { display: flex; flex: 0 0 auto; gap: 8px; }
.history-actions .button { min-height: 44px; padding: 9px 13px; }
.history-detail { display: grid; min-width: 0; gap: 16px; }
.history-detail-head { display: grid; grid-template-columns: max-content minmax(0, 1fr); align-items: center; gap: 18px; padding: 4px 2px 3px; }
.history-back { min-height: 44px; white-space: nowrap; }
.history-detail-heading { min-width: 0; }
.history-detail-heading h2 { margin: 3px 0 0; font-size: 1.55rem; line-height: 1.25; }
.history-detail-heading p { margin: 4px 0 0; color: var(--muted); }
.history-detail-section { min-width: 0; padding: 18px; border: 1px solid var(--line-soft); border-radius: 15px; background: var(--paper); }
.history-detail-section h3 { margin: 0 0 13px; color: var(--ink-soft); font-size: 1rem; }
.history-basic-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 0; }
.history-basic-grid > div { min-width: 0; padding: 11px 12px; border-radius: 11px; background: var(--paper-tint); }
.history-basic-grid dt { color: var(--muted); font-size: .78rem; font-weight: 650; }
.history-basic-grid dd { margin: 4px 0 0; color: var(--ink); font-size: .9rem; font-weight: 700; overflow-wrap: anywhere; }
.history-result-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 11px; }
.history-result-grid-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.result-class-summary { min-width: 0; margin: 12px 0; }
.result-class-summary h4 { margin: 0 0 8px; color: var(--ink-soft); font-size: .9rem; }
.history-result-card { min-width: 0; padding: 16px; border: 1px solid var(--line-soft); border-radius: 13px; background: var(--paper-tint); }
.history-result-card:first-child { border-color: #c8dafb; background: var(--blue-soft); }
.history-result-card span { display: block; color: var(--muted); font-size: .82rem; font-weight: 700; }
.history-result-card strong { display: block; margin-top: 5px; color: var(--ink); font-size: 1.7rem; line-height: 1.15; overflow-wrap: anywhere; }
.history-calculation-details { display: grid; min-width: 0; gap: 12px; }
.history-calculation-details > h3 { margin: 2px 2px 0; color: var(--ink-soft); font-size: 1.08rem; }
.history-detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 14px; min-width: 0; }
.history-detail-lines { display: grid; gap: 0; }
.history-detail-line { display: flex; min-width: 0; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); font-size: .86rem; }
.history-detail-line:first-child { padding-top: 0; }
.history-detail-line:last-child { padding-bottom: 0; border-bottom: 0; }
.history-detail-line > span { min-width: 0; color: var(--muted); overflow-wrap: anywhere; }
.history-detail-line > strong { max-width: 62%; color: var(--ink-soft); font-weight: 700; text-align: right; overflow-wrap: anywhere; }
.history-detail-line > strong.emphasis { color: var(--blue-dark); }
.history-detail-subgroup { margin-top: 15px; padding-top: 13px; border-top: 1px solid var(--line-soft); }
.history-detail-subgroup h4 { margin: 0 0 8px; color: var(--ink-soft); font-size: .87rem; }
.history-detail-counts { margin: 0; color: var(--ink); font-size: .87rem; line-height: 1.7; overflow-wrap: anywhere; }
.history-detail-note { margin: 0; color: var(--muted); font-size: .86rem; line-height: 1.6; }
.history-event-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(170px, .75fr); align-items: start; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.history-event-row:first-child { padding-top: 0; }
.history-event-row:last-child { padding-bottom: 0; border-bottom: 0; }
.history-event-row > div { min-width: 0; }
.history-event-row strong, .history-event-row small { display: block; overflow-wrap: anywhere; }
.history-event-row strong { color: var(--ink-soft); font-size: .87rem; }
.history-event-row small { margin-top: 3px; color: var(--muted); font-size: .78rem; }
.history-event-status { justify-self: end; padding: 5px 8px; border-radius: 9px; color: var(--blue-dark); background: var(--blue-soft); font-size: .76rem; line-height: 1.45; text-align: right; overflow-wrap: anywhere; }
.history-event-status.pending, .history-detail-pending { color: var(--amber) !important; }
.history-notice { padding: 0; overflow: hidden; }
.history-notice summary { min-height: 48px; padding: 14px 18px; color: var(--blue-dark); cursor: pointer; font-size: .9rem; font-weight: 750; }
.history-notice pre { margin: 0; padding: 0 18px 18px; color: var(--ink-soft); font: inherit; font-size: .84rem; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.history-detail-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; padding: 0 2px 2px; }
.history-detail-footer .button { min-height: 44px; }
.history-detail-footer [data-history-restore] { margin-left: auto; }

.powered { width: max-content; margin: 18px max(18px, calc((100% - 1184px) / 2)) 10px auto; padding: 8px 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: rgba(255, 255, 255, .86); box-shadow: 0 4px 16px rgba(0, 0, 0, .07); backdrop-filter: blur(14px); font-size: .72rem; letter-spacing: .035em; }
.powered strong { color: var(--blue); }
.toast { position: fixed; right: 16px; bottom: 18px; z-index: 30; max-width: min(420px, calc(100% - 32px)); padding: 11px 16px; border-radius: 12px; color: #fff; background: var(--ink); box-shadow: 0 12px 28px rgba(0, 0, 0, .18); opacity: 0; pointer-events: none; transform: translateY(10px); transition: opacity var(--ease), transform var(--ease); }
.toast.show { opacity: 1; transform: translateY(0); }

/* Authentication */
body:has(.auth-shell) { display: grid; place-items: center; min-height: 100vh; padding: 24px; background: var(--canvas); }
.auth-shell { display: grid; width: min(980px, 100%); grid-template-columns: 1.02fr .98fr; overflow: hidden; border: 1px solid var(--line-soft); border-radius: 26px; background: var(--paper); box-shadow: var(--shadow-md); }
.auth-intro { min-width: 0; padding: 54px 48px; color: #fff; background: var(--ink); }
.auth-intro .brand { color: #fff; }
.auth-intro .brand-mark { background: #fff; }
.auth-intro .brand-mark span { background: var(--ink); }
.auth-intro .brand-mark span:last-child { background: #f7c04a; }
.auth-kicker { margin: 40px 0 0; color: #a1a1a6; font-size: .68rem; font-weight: 700; letter-spacing: .15em; }
.auth-intro h1 { max-width: 14em; margin: 70px 0 17px; color: #fff; font-size: clamp(1.8rem, 4vw, 2.65rem); line-height: 1.15; letter-spacing: -.04em; }
.auth-intro h1 span { display: block; }
.auth-intro p:not(.auth-kicker) { max-width: 34rem; color: #d1d1d6; line-height: 1.8; }
.points { display: grid; gap: 13px; margin-top: 34px; }
.point { display: flex; align-items: center; gap: 10px; color: #f5f5f7; font-size: .92rem; }
.tick { display: grid; width: 23px; height: 23px; flex: 0 0 auto; place-items: center; border-radius: 50%; color: #fff; background: rgba(255, 255, 255, .16); font-size: .8rem; }
.auth-panel { min-width: 0; padding: 48px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 4px; border-radius: 12px; background: var(--canvas); }
.tab { min-height: 44px; border: 0; border-radius: 9px; padding: 10px 8px; color: var(--muted); background: transparent; font-weight: 700; white-space: nowrap; transition: color var(--ease), background var(--ease), box-shadow var(--ease); }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); background: var(--paper); box-shadow: 0 2px 8px rgba(0, 0, 0, .10); }
.auth-panel form { display: none; gap: 15px; margin-top: 30px; }
.auth-panel form.active { display: grid; }
.auth-panel input { min-height: 48px; }
button.submit { min-height: 48px; margin-top: 4px; border: 0; border-radius: 11px; color: #fff; background: var(--blue); font-weight: 700; box-shadow: 0 7px 18px rgba(52, 120, 246, .20); transition: background var(--ease), transform var(--ease), box-shadow var(--ease); }
button.submit:hover { background: var(--blue-dark); transform: translateY(-1px); }
.hint { margin: 0; color: var(--muted); font-size: .82rem; line-height: 1.55; }
.error { min-height: 22px; margin: 0; color: var(--red); font-size: .86rem; }
.auth-panel .powered { width: auto; margin: 24px 0 8px; padding: 0; border: 0; background: transparent; box-shadow: none; text-align: center; }

/* Account settings */
.account-dialog { width: min(560px, calc(100% - 28px)); max-height: min(760px, calc(100vh - 28px)); margin: auto; overflow-y: auto; padding: 0; border: 1px solid var(--line-soft); border-radius: 22px; color: var(--ink); background: var(--paper); box-shadow: var(--shadow-md); }
.account-dialog::backdrop { background: rgba(29, 29, 31, .42); backdrop-filter: blur(3px); }
.account-dialog-head { display: flex; min-width: 0; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 24px 24px 18px; border-bottom: 1px solid var(--line-soft); background: var(--paper-tint); }
.account-dialog-head h2 { margin: 3px 0 0; font-size: 1.45rem; letter-spacing: -.025em; }
.account-dialog-head p { margin: 5px 0 0; color: var(--muted); font-size: .88rem; }
.dialog-close { display: grid; width: 44px; height: 44px; flex: 0 0 auto; place-items: center; border: 1px solid var(--line); border-radius: 11px; color: var(--muted); background: var(--paper); font-size: 1.5rem; line-height: 1; }
.dialog-close:hover { color: var(--ink); border-color: #a1a1a6; }
.account-section { padding: 20px 24px; border-bottom: 1px solid var(--line-soft); }
.account-section:last-child { border-bottom: 0; }
.account-section h3 { margin: 0 0 14px; color: var(--ink-soft); font-size: .98rem; }
.account-form { display: grid; gap: 13px; }
.account-form .button { width: 100%; margin-top: 2px; }
.account-hint { margin: -3px 0 0; color: var(--muted); font-size: .8rem; }
.account-form .error { min-height: 20px; }

@media (max-width: 1000px) {
  .setup-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-grid.metric-grid-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .adjust-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .event-row, .event-row.override { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .event-row .delete { grid-column: 2; }
  .notice-card { grid-template-columns: minmax(0, 1fr); }
  .notice-actions { grid-column: 1; }
  .question-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .duty-question-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .question-when { grid-column: 1 / -1; }
}

@media (max-width: 820px) {
  #setupPage .intro-row { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; gap: 12px; }
  #setupPage .intro-row > div:first-child { min-width: 0; }
  #setupPage .intro-row h2 { overflow-wrap: normal; word-break: keep-all; }
  #setupPage .intro-actions { display: flex; width: 100%; flex-direction: row; align-items: stretch; gap: 9px; }
  #setupPage .intro-actions .button { flex: 1 1 0; white-space: nowrap; }
}

@media (max-width: 760px) {
  .app-header { display: grid; grid-template-columns: minmax(0, 1fr); align-items: center; gap: 10px; padding: 18px 15px 13px; }
  .brand { width: 100%; }
  .brand > div:last-child { min-width: 0; }
  .app-header h1 { white-space: nowrap; }
  .account-tools { display: flex; grid-column: 1; width: 100%; margin-left: 0; justify-content: flex-end; gap: 8px; }
  .save-state, .account-name, .logout-button { height: 44px; min-height: 44px; }
  .save-state { justify-self: start; padding: 8px 12px 8px 28px; }
  .account-name { width: auto; min-width: 72px; max-width: 120px; padding: 8px 12px; }
  .logout-button { justify-self: end; padding: 8px 12px; }
  .top-tabs { width: calc(100% - 24px); margin-bottom: 20px; }
  .top-tab { min-height: 48px; padding: 9px 5px; font-size: .78rem; white-space: nowrap; overflow: visible; }
  .top-tab .tab-label-full { display: none; }
  .top-tab .tab-label-short { display: block; white-space: nowrap; }
  main { width: calc(100% - 24px); }
  .intro-row { align-items: flex-start; gap: 12px; }
  .intro-row h2, .result-head h2 { font-size: 1.35rem; }
  .intro-actions { align-items: stretch; }
  .intro-actions .button { white-space: nowrap; }
  .class-top { grid-template-columns: 1fr; padding: 18px 16px 16px; }
  .homeroom-settings { grid-template-columns: minmax(0, 1fr); }
  .class-list-head { align-items: center; }
  .class-body { padding: 14px; }
  .cell-button { min-height: 44px; }
  .class-card > summary.class-summary { padding: 16px; }
  .class-top .delete-class { width: 100%; }
  .setup-fold > summary > span:first-child { flex-direction: column; align-items: flex-start; gap: 3px; }
  .setup-fold > summary strong { white-space: nowrap; }
  .setup-fold > summary .summary-state { margin-left: auto; }
  .duty-grid, .range-row, .question-summary-grid, .duty-question-row { grid-template-columns: 1fr; }
  .question-when { grid-column: auto; }
  .schedule-mapping-row { grid-template-columns: minmax(0, 1fr); align-items: stretch; }
  .mapping-day select { width: 100%; }
  .mapping-enabled { justify-content: flex-start; }
  .event-impact { flex-wrap: wrap; gap: 7px 12px; }
  .event-impact-status { flex-basis: 100%; margin-left: 0; }
  .weekday-picks { grid-template-columns: 1fr; }
  .weekday-strip { grid-template-columns: repeat(5, 90px); overflow-x: auto; padding-bottom: 3px; }
  .notice-actions { display: grid; width: 100%; grid-template-columns: 1fr 1fr; }
  .notice-actions label { width: auto; }
  .changes-head { align-items: flex-start; padding: 19px 17px; }
  .default-pill { display: none; }
  .exception-list { padding: 7px 8px 10px; }
  .exception-group > summary { grid-template-columns: 40px minmax(0, 1fr); gap: 10px; align-items: start; }
  .exception-status { grid-column: 2; justify-self: start; }
  .exception-body { padding: 4px 7px 16px; }
  .result-head { align-items: flex-start; flex-direction: column; }
  .result-actions { width: 100%; justify-content: stretch; }
  .result-actions .button { flex: 1; }
  .record-meta { grid-template-columns: 1fr; }
  .record-meta small { padding-bottom: 0; }
  .history-row { align-items: flex-start; flex-direction: column; }
  .history-actions { width: 100%; }
  .history-actions .button { flex: 1; }
  .history-detail-grid { grid-template-columns: minmax(0, 1fr); }
  .history-basic-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .history-result-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .history-result-grid-three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .history-detail-head { grid-template-columns: minmax(0, 1fr); align-items: start; gap: 10px; }
  .history-detail-heading h2 { font-size: 1.35rem; }
  .history-back { justify-self: start; }
  .history-event-row { grid-template-columns: minmax(0, 1fr); gap: 7px; }
  .history-event-status { justify-self: start; text-align: left; }
  .history-detail-footer { display: grid; grid-template-columns: minmax(0, 1fr); }
  .history-detail-footer .button { width: 100%; }
  .history-detail-footer [data-history-restore] { margin-left: 0; }
  #historyPage .intro-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 10px; }
  #historyPage .intro-row .button { min-width: 64px; white-space: nowrap; }
  #historyPage .button-label-full { display: none; }
  #historyPage .button-label-short { display: inline; }
  .bottom-actions .button { width: 100%; }
  .schedule-help { justify-content: flex-start; white-space: nowrap; }
  .schedule-help > span { overflow: hidden; text-overflow: ellipsis; }
  .schedule-help .legend { display: none; }
  .schedule-scroll-hint { display: block; margin: 7px 6px 0 0; color: var(--subtle); font-size: .76rem; text-align: right; }
  .powered { margin-right: 10px; margin-bottom: 10px; }
  .school-rule-card { padding: 14px 15px; }
  .school-rule-card .switch-copy small { max-width: none; }
  .audit { overflow-x: auto; }
  .audit-table { min-width: 720px; }
  .toast { right: 10px; bottom: 60px; max-width: calc(100% - 20px); }

  body:has(.auth-shell) { padding: 14px; }
  .auth-shell { grid-template-columns: 1fr; border-radius: 20px; }
  .auth-intro { padding: 28px 24px; }
  .auth-intro h1 { margin: 28px 0 10px; font-size: 1.65rem; }
  .auth-kicker { margin-top: 24px; }
  .points { display: none; }
  .auth-panel { padding: 28px 22px; }
  .account-dialog { width: calc(100% - 20px); border-radius: 18px; }
  .account-dialog-head, .account-section { padding-right: 18px; padding-left: 18px; }
}

@media (max-width: 420px) {
  .top-tab { font-size: .73rem; }
  .app-header h1 { font-size: 1.35rem; }
  .brand { gap: 10px; }
  .brand-mark { width: 40px; height: 40px; padding: 7px; }
  .card, .results { border-radius: 17px; }
  .card { padding: 16px; }
  .class-card, .details-card, .changes-card { padding: 0; }
  .setup-summary { grid-template-columns: 1fr; }
  .homeroom-settings { grid-column: 1; }
  .choice-options { gap: 8px; }
  .choice-options label { padding-right: 8px; padding-left: 8px; }
  .class-list-head { align-items: flex-start; }
  .class-list-head .button { min-height: 44px; padding-right: 12px; padding-left: 12px; white-space: nowrap; }
  .setup-summary > label { min-height: auto; }
  .adjust-grid { grid-template-columns: 1fr; }
  .event-row, .event-row.override { grid-template-columns: 1fr; }
  .event-row .delete { grid-column: auto; }
  .event-impact { align-items: flex-start; flex-direction: column; }
  .event-impact-status { flex-basis: auto; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .metric-grid.metric-grid-three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { padding: 14px 12px; }
  .metric strong { font-size: 1.7rem; }
  .metric small { font-size: .76rem; }
  .results { padding: 16px; }
  .history-card { padding: 12px; }
  .history-detail-section { padding: 14px; }
  .history-result-card { padding: 13px; }
  .history-result-card strong { font-size: 1.5rem; }
  .auth-intro, .auth-panel { padding-right: 18px; padding-left: 18px; }
}

@media (max-width: 380px) {
  #monthPage .intro-row { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; }
  #monthPage .intro-row h2 { white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media print {
  html, body { background: #fff; }
  body { padding: 0; }
  .app-header, .top-tabs, #setupPage, .intro-row, .notice-card, .details-card, .result-head .button, .record-meta, .powered, .toast { display: none !important; }
  .page#monthPage { display: block; }
  .changes-card, .results, .metric, .exception-group { break-inside: avoid; page-break-inside: avoid; }
  .results { margin: 0; border: 0; box-shadow: none; }
  .metric:first-child { border: 2px solid #000; color: #000; background: #fff; }
  .metric:first-child span, .metric:first-child strong, .metric:first-child small { color: #000; }
  .audit { display: block; }
}
