:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-soft: #eef3ed;
  --ink: #18211d;
  --muted: #64716b;
  --line: #dce3dd;
  --accent: #12805c;
  --accent-strong: #0b5e45;
  --blue: #2563eb;
  --amber: #b7791f;
  --red: #b42318;
  --green: #0a8f65;
  --violet: #6d4aff;
  --shadow: 0 18px 40px rgba(23, 33, 29, 0.09);
  --radius: 8px;
  --sidebar: 280px;
  --topbar: 86px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, "Noto Sans TC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 18px;
  color: #f6fbf8;
  background: #14211c;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: #102018;
  background: #7ee2b8;
  border-radius: 8px;
  font-size: 1.15rem;
  font-weight: 800;
}

.brand-title {
  font-weight: 800;
  line-height: 1.1;
}

.brand-subtitle {
  color: #b9cac1;
  font-size: 0.78rem;
  margin-top: 3px;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-link {
  width: 100%;
  min-height: 44px;
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #d7e4dd;
  background: transparent;
  text-align: left;
}

.nav-link:hover,
.nav-link:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}

.nav-link.active {
  color: #102018;
  background: #7ee2b8;
}

.nav-link[hidden] {
  display: none;
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  font-weight: 700;
}

.privacy-note {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.privacy-note strong,
.privacy-note span {
  display: block;
}

.privacy-note strong {
  margin-bottom: 6px;
  font-size: 0.86rem;
}

.privacy-note span {
  color: #c0d0c7;
  font-size: 0.78rem;
  line-height: 1.5;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar {
  min-height: var(--topbar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}

.eyebrow {
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.05em;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  margin-top: 5px;
  font-size: clamp(1.8rem, 2.8vw, 2.55rem);
  line-height: 1.08;
}

.staff-switcher {
  min-width: 240px;
  display: grid;
  gap: 6px;
}

.staff-switcher[hidden] {
  display: none;
}

.auth-panel {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 220px;
}

.auth-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent-strong);
  background: var(--surface);
  font-size: 0.8rem;
  font-weight: 800;
}

.auth-user {
  display: grid;
  gap: 2px;
  min-width: 0;
  text-align: right;
}

.auth-user span {
  max-width: 210px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-user strong {
  font-size: 0.86rem;
}

.identity-switch {
  flex-shrink: 0;
}

.identity-switch button {
  min-width: 88px;
  min-height: 30px;
  padding: 0 9px;
  font-size: 0.76rem;
}

.auth-gate {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.auth-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.staff-switcher label,
.field label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
}

select,
input {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 96px;
  resize: vertical;
  padding: 10px 12px;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.status-item {
  min-height: 68px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.status-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.status-item strong {
  font-size: 1rem;
}

.view-root {
  display: grid;
  gap: 18px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.segmented button {
  min-width: 84px;
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
}

.segmented button.active {
  color: var(--surface);
  background: var(--ink);
}

.action-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.week-nav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  font-weight: 800;
}

.btn.primary {
  border-color: var(--accent);
  color: white;
  background: var(--accent);
}

.btn.primary:hover {
  background: var(--accent-strong);
}

.btn.danger {
  color: var(--red);
  border-color: #f4c7c2;
}

.btn.tiny {
  min-height: 30px;
  padding: 0 9px;
  font-size: 0.76rem;
}

.btn:disabled {
  color: #98a19d;
  background: #eef1ee;
  cursor: not-allowed;
}

.btn.is-loading,
.icon-btn.is-loading {
  position: relative;
  cursor: wait;
  opacity: 0.78;
}

.btn.is-loading::after,
.icon-btn.is-loading::after {
  content: "";
  width: 0.72em;
  height: 0.72em;
  margin-left: 8px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

.icon-btn.is-loading::after {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 8px;
  height: 8px;
  margin-left: 0;
  border-width: 1.5px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.date-switcher {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.date-switcher-main {
  display: flex;
  align-items: center;
  gap: 12px;
}

.date-pill-row {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(7, minmax(72px, 1fr));
  gap: 8px;
  flex: 1;
}

.date-pill {
  min-height: 66px;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fbfcfa;
  text-align: center;
}

.date-pill span,
.date-pill small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.date-pill strong {
  font-size: 0.96rem;
}

.date-pill.active {
  border-color: var(--accent);
  color: white;
  background: var(--accent);
}

.date-pill.active span,
.date-pill.active small {
  color: rgba(255, 255, 255, 0.8);
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.85fr);
  gap: 18px;
  align-items: start;
}

.scheduler-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.scheduler-aside {
  position: sticky;
  top: 18px;
  min-width: 0;
}

.scheduler-stack {
  display: grid;
  gap: 14px;
}

.mini-metric-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.mini-metric {
  min-height: 70px;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.mini-metric span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.mini-metric strong {
  font-size: 1.35rem;
  line-height: 1;
}

.schedule-watchlist {
  display: grid;
  gap: 8px;
}

.watch-title {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.compact-schedule {
  width: 100%;
  display: grid;
  gap: 3px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.compact-schedule:hover,
.compact-schedule:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.compact-schedule span,
.compact-schedule small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.compact-schedule strong {
  min-width: 0;
  overflow: hidden;
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: clip;
}

.panel-header {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-title {
  font-size: 1rem;
  font-weight: 800;
}

.panel-subtitle {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.8rem;
}

.panel-body {
  padding: 16px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.metric span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 1.55rem;
  line-height: 1;
}

.agenda-list,
.student-list,
.staff-list,
.sync-list {
  display: grid;
  gap: 10px;
}

.agenda-item,
.student-item,
.staff-item,
.sync-item {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.agenda-item {
  grid-template-columns: 76px minmax(0, 1fr) auto;
  align-items: center;
}

.agenda-time {
  font-size: 0.9rem;
  font-weight: 800;
}

.agenda-main {
  min-width: 0;
}

.agenda-title,
.student-name,
.staff-name {
  font-weight: 800;
}

.student-name-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.agenda-meta,
.student-meta,
.staff-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.84rem;
}

.meta-line {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.coach-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 22px;
  padding: 0 8px;
  border: 1px solid color-mix(in srgb, var(--coach-color, var(--accent)) 42%, white);
  border-radius: 999px;
  color: var(--ink);
  background: color-mix(in srgb, var(--coach-color, var(--accent)) 14%, white);
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.coach-tag::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--coach-color, var(--accent));
}

.badge-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--muted);
  background: #edf1ee;
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.badge.green {
  color: #08563f;
  background: #dff7ec;
}

.badge.blue {
  color: #1d4ed8;
  background: #dbeafe;
}

.badge.amber {
  color: #8a5a10;
  background: #fff3d6;
}

.badge.red {
  color: #9b1c13;
  background: #fee4e2;
}

.badge.violet {
  color: #5631d2;
  background: #e8e1ff;
}

.schedule-grid {
  min-width: 900px;
  display: grid;
  grid-template-columns: 84px repeat(7, minmax(108px, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: visible;
  background: var(--surface);
}

.timeline-grid {
  position: relative;
}

.schedule-wrap {
  overflow-x: auto;
}

.coach-calendar-bar {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.coach-calendar-label {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.coach-calendar-label strong {
  font-size: 0.94rem;
}

.coach-calendar-label span {
  color: var(--muted);
  font-size: 0.82rem;
}

.coach-chip-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.coach-filter {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  font-size: 0.8rem;
  font-weight: 800;
  text-decoration: none;
}

.coach-filter::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--coach-color, var(--accent));
}

.coach-filter.active {
  border-color: var(--coach-color, var(--ink));
  background: #f2f6f4;
}

.coach-filter.inactive {
  color: #8b9691;
  background: #f4f5f3;
  opacity: 0.6;
}

.coach-filter.inactive::before {
  background: #a8b0ac;
}

.coach-filter.reset {
  border-color: #cfd8d2;
  background: var(--surface);
}

.coach-filter.reset::before {
  background: var(--ink);
}

.coach-filter:disabled {
  color: #98a19d;
  background: #eef1ee;
}

.grid-head {
  min-height: 54px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 8px;
}

.grid-head {
  display: grid;
  align-content: center;
  background: var(--surface-soft);
  font-size: 0.82rem;
  font-weight: 800;
}

.grid-head.selected-day {
  color: white;
  background: var(--accent);
}

.grid-head.today-day:not(.selected-day) {
  color: var(--accent-strong);
  box-shadow: inset 0 0 0 2px rgba(18, 128, 92, 0.35);
}

.grid-time-corner,
.grid-time {
  position: sticky;
  left: 0;
  z-index: 4;
  box-shadow: 1px 0 0 var(--line);
}

.grid-time-corner {
  background: var(--surface-soft);
}

.grid-time,
.grid-cell {
  min-height: 72px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid #dde5df;
  padding: 0 6px;
}

.grid-time {
  display: grid;
  align-content: start;
  color: var(--muted);
  background: #fbfcfa;
  font-size: 0.78rem;
  font-weight: 800;
  padding-top: 4px;
}

.grid-cell {
  position: relative;
  overflow: visible;
  background:
    linear-gradient(to bottom, transparent 0, transparent calc(50% - 1px), #f0f3f1 calc(50% - 1px), #f0f3f1 50%, transparent 50%),
    #ffffff;
}

.grid-time.hour-slot,
.grid-cell.hour-slot {
  border-top: 1px solid #cfd8d2;
}

.schedule-event {
  width: 100%;
  min-height: 62px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 8px;
  border: 1px solid #cfe3d8;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: #f4fbf7;
  color: var(--ink);
  text-align: left;
}

.timeline-event {
  position: relative;
  left: var(--event-left, 0);
  z-index: 2;
  width: var(--event-width, calc(100% - 8px));
  height: var(--event-height, 68px);
  min-height: 0;
  align-content: start;
  align-self: start;
  margin: 0 4px 0 0;
  overflow: hidden;
  padding: 6px 8px;
  box-shadow: 0 6px 14px rgba(23, 33, 29, 0.08);
  transform: translateY(var(--event-offset, 0));
}

.schedule-event.locked {
  border-color: #e2e5e3;
  border-left-color: #99a39e;
  background: #f6f7f6;
}

.event-time {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
}

.event-student {
  font-size: 0.82rem;
  font-weight: 800;
}

.event-coach {
  color: var(--muted);
  font-size: 0.72rem;
}

.student-item {
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
}

.student-db-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.student-db-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.search-box.compact {
  max-width: 360px;
  flex: 1;
}

.search-box span,
.student-db-count {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
}

.student-db-table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
  background: var(--surface);
}

.student-db-table th,
.student-db-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 0.84rem;
}

.student-db-table th {
  color: var(--muted);
  background: var(--surface-soft);
  font-weight: 800;
}

.student-db-table tr:last-child td {
  border-bottom: 0;
}

.student-row-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.74rem;
}

.link-button {
  padding: 0;
  border: 0;
  color: var(--ink);
  background: transparent;
  font-weight: 800;
  text-align: left;
}

.link-button:hover,
.link-button:focus-visible {
  color: var(--accent-strong);
  outline: none;
}

.goal-input {
  min-height: 58px;
  min-width: 260px;
  resize: vertical;
  font-size: 0.84rem;
}

.table-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: white;
  background: var(--accent);
  font-weight: 800;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.callout {
  padding: 14px;
  border: 1px solid #c9ded3;
  border-radius: 8px;
  background: #f1faf5;
  color: #164b38;
  line-height: 1.55;
}

.callout strong {
  display: block;
  margin-bottom: 4px;
}

.danger-callout {
  border-color: #f4c7c2;
  color: #7a271a;
  background: #fff1f0;
}

.preview-result {
  display: grid;
  gap: 12px;
}

.preview-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.preview-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  background: var(--surface);
}

.preview-table th,
.preview-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 0.82rem;
}

.preview-table th {
  color: var(--muted);
  background: var(--surface-soft);
  font-weight: 800;
}

.preview-table tr:last-child td {
  border-bottom: 0;
}

.empty-state {
  padding: 34px;
  text-align: center;
  color: var(--muted);
}

.prep-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.prep-main-panel {
  min-width: 0;
}

.prep-aside {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 18px;
  min-width: 0;
}

.prep-stack,
.prep-library,
.prep-history {
  display: grid;
  gap: 14px;
}

.prep-student-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.prep-summary-item {
  min-height: 76px;
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.prep-summary-item span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.prep-summary-item strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 0.9rem;
  line-height: 1.35;
}

.prep-editor {
  display: grid;
  gap: 12px;
}

.prep-editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.prep-exercise-list {
  display: grid;
  gap: 10px;
}

.prep-exercise-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 38px;
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  transition: border-color 0.15s ease, opacity 0.15s ease, transform 0.15s ease;
}

.prep-exercise-row.is-dragging {
  opacity: 0.45;
  transform: scale(0.995);
}

.prep-exercise-row.is-drag-over {
  border-color: var(--accent);
  background: #f2faf6;
}

.prep-row-order {
  display: grid;
  gap: 6px;
  justify-items: center;
}

.prep-row-order strong {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: white;
  background: var(--ink);
  font-size: 0.82rem;
}

.drag-handle {
  width: 30px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface);
  cursor: grab;
  font-weight: 900;
  line-height: 1;
}

.drag-handle:active {
  cursor: grabbing;
}

.prep-row-fields {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(180px, 1.3fr) minmax(110px, 0.7fr) 96px 88px 74px minmax(230px, 1.5fr);
  gap: 10px;
  align-items: end;
}

.prep-name-field,
.prep-cue-field {
  min-width: 0;
}

.prep-name-suggestions {
  display: grid;
  gap: 6px;
  margin-top: 6px;
  max-height: 220px;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 24px rgba(23, 33, 29, 0.08);
}

.prep-name-suggestions[hidden] {
  display: none;
}

.prep-name-suggestion {
  width: 100%;
  display: grid;
  gap: 3px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fbfcfa;
  text-align: left;
}

.prep-name-suggestion:focus-visible,
.prep-name-suggestion:hover {
  border-color: var(--accent);
  outline: none;
}

.prep-name-suggestion strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 0.84rem;
}

.prep-name-suggestion span,
.prep-name-suggestion.empty {
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.35;
}

.prep-row-fields input,
.prep-row-fields select,
.prep-row-fields textarea {
  min-width: 0;
}

.prep-row-fields textarea {
  min-height: 62px;
  resize: vertical;
}

.prep-subset-editor {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
  align-items: start;
}

.prep-subset-list {
  display: grid;
  gap: 8px;
}

.prep-subset-row {
  display: grid;
  grid-template-columns: minmax(96px, 1fr) minmax(86px, 0.9fr) 74px 34px;
  gap: 8px;
  align-items: end;
  padding: 8px;
  border: 1px dashed #c9d6ce;
  border-radius: 8px;
  background: #f4f8f5;
}

.prep-subset-row .icon-btn {
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
}

.prep-reason-line {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

.prep-reason-line > span {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.prep-subsets {
  color: var(--accent-strong);
}

.prep-row-actions {
  display: grid;
  gap: 6px;
}

.prep-row-actions .icon-btn {
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
}

.success-icon {
  color: var(--accent-strong);
  border-color: #b9dec8;
  background: #eef8f2;
}

.danger-icon {
  color: var(--red);
  border-color: #f4c7c2;
  background: #fff8f7;
}

.prep-insert-panel {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px dashed #b9c8c0;
  border-radius: 8px;
  background: #f4f8f5;
}

.prep-insert-head {
  display: grid;
  gap: 8px;
}

.prep-insert-head > strong {
  color: var(--ink);
  font-size: 0.86rem;
}

.prep-insert-library {
  display: grid;
  gap: 7px;
  max-height: 260px;
  overflow: auto;
}

.prep-insert-create {
  display: grid;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.prep-library-group {
  display: grid;
  gap: 8px;
}

.library-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  font-weight: 800;
}

.library-toggle strong {
  min-width: 28px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: var(--accent-strong);
  background: #eef8f2;
  font-size: 0.78rem;
}

.library-exercise-list {
  display: grid;
  gap: 8px;
}

.library-exercise {
  width: 100%;
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fbfcfa;
  text-align: left;
}

.library-exercise.is-filtered-out {
  display: none !important;
}

.library-exercise:hover,
.library-exercise:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.library-exercise strong {
  min-width: 0;
  overflow: hidden;
  font-size: 0.86rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-exercise span {
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.35;
}

.exercise-create-box {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px dashed #b9c7bf;
  border-radius: 8px;
  background: #f8fbf8;
}

.exercise-create-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(110px, 0.8fr);
  gap: 8px;
}

.exercise-create-grid input,
.exercise-create-grid select {
  min-height: 38px;
  font-size: 0.82rem;
}

.prep-history-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.prep-history-item > div:first-child {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.prep-history-item strong {
  font-size: 0.86rem;
}

.prep-history-item span,
.prep-history-item p {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

.prep-history-exercises {
  display: grid;
  gap: 4px;
}

.prep-history-exercises > span {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--surface);
}

.history-record-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.student-session-history,
.session-record-list {
  display: grid;
  gap: 8px;
}

.session-record-card {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.session-record-card > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.session-record-card strong {
  font-size: 0.84rem;
}

.session-record-card span,
.session-record-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

.classroom-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.classroom-aside {
  position: sticky;
  top: 18px;
}

.classroom-stack,
.class-exercise-list {
  display: grid;
  gap: 12px;
}

.class-live-pill {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid #bddfd0;
  border-radius: 999px;
  color: #0b5f46;
  background: #e8f7f0;
  font-size: 0.84rem;
  font-weight: 900;
}

.class-live-pill span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #0a8f65;
  box-shadow: 0 0 0 5px rgba(10, 143, 101, 0.14);
}

.class-exercise-row {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 12px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  overflow: visible;
}

.class-done {
  display: grid;
  justify-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.class-done span {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: white;
  background: var(--ink);
  font-size: 0.82rem;
}

.class-exercise-main {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.class-exercise-title {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.class-exercise-title strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 1.08rem;
}

.class-title-actions {
  display: grid;
  grid-template-columns: repeat(2, 30px);
  gap: 5px;
  flex: 0 0 auto;
}

.square-icon {
  width: 30px;
  height: 30px;
  min-width: 30px;
  border-radius: 6px;
  font-size: 1rem;
}

.class-field-grid {
  display: grid;
  grid-template-columns: minmax(88px, 1fr) minmax(82px, 0.85fr) minmax(70px, 0.7fr);
  gap: 10px;
  align-items: end;
}

.class-field-grid input,
.class-field-grid select,
.class-field-grid textarea {
  min-width: 0;
}

.class-notes-field textarea {
  min-height: 62px;
  resize: vertical;
}

.class-next-action-field,
.class-subset-editor,
.class-notes-field {
  grid-column: 1 / -1;
}

.class-subset-editor {
  display: grid;
  gap: 8px;
}

.class-subset-list {
  display: grid;
  gap: 8px;
}

.class-subset-row {
  display: grid;
  grid-template-columns: minmax(96px, 1fr) minmax(86px, 0.9fr) 74px 34px;
  gap: 8px;
  align-items: end;
  padding: 8px;
  border: 1px dashed #c9d6ce;
  border-radius: 8px;
  background: #f4f8f5;
}

.class-subset-row .icon-btn {
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
}

.next-action-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(70px, 1fr));
  gap: 7px;
  min-width: 0;
}

.next-action-tile {
  min-height: 54px;
  display: grid;
  place-items: center;
  padding: 6px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-align: center;
  line-height: 1.25;
}

.next-action-tile span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.next-action-tile input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.next-action-tile:has(input:checked) {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: #e8f7f0;
}

.class-add-library {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
}

.class-insert-panel {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px dashed #b9c8c0;
  border-radius: 8px;
  background: #f4f8f5;
}

.class-insert-library {
  display: grid;
  gap: 7px;
  max-height: 260px;
  overflow: auto;
}

.library-exercise.manual {
  border-style: dashed;
}

.classroom-history-panel {
  background: #f6f8f6;
}

.classroom-history-panel .panel-body {
  background: #f6f8f6;
}

.history-compare-stack,
.history-compare-exercises,
.history-mini-list {
  display: grid;
  gap: 10px;
}

.history-compare-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.history-compare-card {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.history-compare-card.muted {
  min-height: 92px;
  align-content: center;
  opacity: 0.55;
}

.history-compare-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
}

.history-compare-head strong {
  color: var(--ink);
}

.history-compare-row,
.history-signal-row {
  display: grid;
  gap: 3px;
  padding: 8px;
  border-radius: 6px;
  background: var(--surface);
}

.history-compare-row strong,
.history-signal-row strong {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-size: 0.84rem;
}

.history-action-badge {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #c7d8ce;
  border-radius: 999px;
  color: var(--accent-strong);
  background: #eef8f2;
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1;
}

.history-compare-row span,
.history-compare-row em,
.history-signal-row span,
.history-signal-row em,
.history-compare-card p {
  color: var(--muted);
  font-size: 0.76rem;
  font-style: normal;
  line-height: 1.5;
}

.history-signal-box {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid #d5dfd8;
  border-radius: 8px;
  background: #f4f8f5;
}

.body-phone-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.body-phone-panel span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.body-phone-panel strong {
  font-size: 1.2rem;
  letter-spacing: 0;
}

.renewal-callout {
  border-color: #f2d38b;
  color: #6a4900;
  background: #fff8e6;
}

.body-history-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.body-history-cell {
  min-height: 96px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 4px;
  padding: 10px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  text-align: center;
}

.body-history-cell.muted {
  opacity: 0.42;
}

.body-history-cell span,
.body-history-cell em {
  color: var(--muted);
  font-size: 0.72rem;
  font-style: normal;
}

.body-history-cell strong {
  font-size: 1rem;
}

.body-history-cell small {
  margin-left: 2px;
  color: var(--muted);
  font-size: 0.62rem;
}

.body-input-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.body-check-field input {
  min-height: 46px;
  text-align: center;
  font-size: 1rem;
  font-weight: 800;
}

.body-diff {
  min-height: 24px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 900;
  text-align: center;
}

.body-diff.up {
  color: var(--red);
}

.body-diff.down {
  color: var(--green);
}

.body-diff.flat {
  color: var(--muted);
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  background: rgba(12, 18, 15, 0.45);
  -webkit-overflow-scrolling: touch;
}

.modal-root[hidden] {
  display: none;
}

.modal {
  width: min(720px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 22px 70px rgba(8, 18, 13, 0.25);
  -webkit-overflow-scrolling: touch;
}

.modal-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.modal-title {
  font-weight: 800;
}

.modal-body {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 16px 16px;
}

.checkout-body {
  justify-items: center;
  text-align: center;
}

.checkout-balance {
  width: min(320px, 100%);
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid #bddfd0;
  border-radius: 8px;
  background: #e8f7f0;
}

.checkout-balance span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.checkout-balance strong {
  color: #0b5f46;
  font-size: 1.5rem;
}

.checkout-balance em {
  color: var(--red);
  font-style: normal;
  font-weight: 900;
}

.checkout-balance.is-low {
  border-color: #f4c7c2;
  background: #fff0ee;
}

.checkout-qr {
  display: grid;
  justify-items: center;
  gap: 10px;
}

.checkout-qr img {
  width: 220px;
  height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.checkout-qr span {
  color: var(--muted);
  font-size: 0.82rem;
}

.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-size: 1.2rem;
  font-weight: 800;
}

.icon-btn.square-icon {
  width: 30px;
  height: 30px;
  min-width: 30px;
  min-height: 30px;
  border-radius: 6px;
  font-size: 1rem;
}

.icon-btn.compact {
  width: 34px;
  height: 34px;
  min-height: 34px;
  font-size: 1.05rem;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  color: white;
  background: #14211c;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 16px;
  }

  .nav-list {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .nav-link {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    gap: 2px;
    font-size: 0.78rem;
  }

  .privacy-note {
    display: none;
  }

  .workspace {
    padding: 18px;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .scheduler-layout {
    grid-template-columns: 1fr;
  }

  .scheduler-aside {
    position: static;
  }

  .prep-layout {
    grid-template-columns: 1fr;
  }

  .classroom-layout {
    grid-template-columns: 1fr;
  }

  .classroom-aside {
    position: static;
  }

  .prep-aside {
    position: static;
  }

  .prep-student-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .prep-row-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .prep-subset-row {
    grid-template-columns: minmax(96px, 1fr) minmax(86px, 1fr) 74px 34px;
  }

  .class-subset-row {
    grid-template-columns: minmax(96px, 1fr) minmax(86px, 1fr) 74px 34px;
  }

  .class-field-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .body-history-grid,
  .body-input-grid,
  .history-compare-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .date-switcher-main {
    align-items: stretch;
    flex-direction: column;
  }

  .date-pill-row {
    overflow-x: auto;
    grid-template-columns: repeat(7, minmax(84px, 1fr));
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .auth-panel {
    align-items: stretch;
    justify-content: stretch;
    min-width: 0;
  }

  .auth-user {
    text-align: left;
  }

  .auth-gate {
    align-items: stretch;
    flex-direction: column;
  }

  .staff-switcher {
    min-width: 0;
  }

  .status-strip,
  .metric-grid,
  .field-grid,
  .prep-student-summary,
  .prep-row-fields,
  .class-field-grid,
  .body-history-grid,
  .body-input-grid,
  .history-compare-grid,
  .exercise-create-grid {
    grid-template-columns: 1fr;
  }

  .nav-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .agenda-item,
  .student-item {
    grid-template-columns: 1fr;
  }

  .prep-exercise-row {
    grid-template-columns: 1fr;
  }

  .prep-subset-row {
    grid-template-columns: 1fr 1fr minmax(72px, 0.8fr) 34px;
  }

  .class-subset-row {
    grid-template-columns: 1fr 1fr minmax(72px, 0.8fr) 34px;
  }

  .prep-row-order {
    grid-template-columns: 30px 34px;
    justify-content: start;
  }

  .class-exercise-row {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .class-done {
    grid-template-columns: auto auto;
    justify-content: start;
  }

  .class-field-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .next-action-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 5px;
  }

  .next-action-tile {
    min-height: 50px;
    padding: 4px 2px;
    font-size: 0.62rem;
    line-height: 1.18;
  }

  .danger-icon {
    width: 100%;
  }

  .prep-row-actions {
    grid-template-columns: repeat(2, 34px);
    justify-content: start;
  }

  .prep-row-actions .icon-btn,
  .prep-subset-row .icon-btn,
  .class-subset-row .icon-btn {
    width: 34px;
  }

  .square-icon {
    width: 30px;
    min-width: 30px;
  }

  .action-row {
    width: 100%;
  }

  .btn {
    flex: 1;
  }
}
