:root {
  --bg: #fff8f3;
  --surface: #ffffff;
  --surface-muted: #fff3eb;
  --border: #f0dfd3;
  --text: #3b2f2f;
  --text-muted: #7c6b65;

  --primary: #ff7a59;
  --primary-2: #ff9a76;
  --primary-hover: #f26444;
  --primary-soft: #fff0ea;
  --primary-shadow: #e05636;

  --emerald: #10b981;
  --emerald-soft: #e6fbf2;
  --emerald-border: #86efac;
  --emerald-text: #047857;

  --rose: #f43f5e;
  --rose-soft: #fff0f3;
  --rose-border: #fda4af;
  --rose-text: #be123c;

  --amber: #f59e0b;
  --amber-soft: #fff8e1;
  --amber-border: #fcd34d;
  --amber-text: #b45309;

  --blue: #38bdf8;
  --blue-soft: #e0f2fe;
  --blue-border: #7dd3fc;
  --blue-text: #0369a1;

  --radius: 22px;
  --radius-sm: 16px;
  --shadow: 0 6px 20px rgba(124, 92, 70, 0.08);
  --shadow-lg: 0 18px 40px rgba(92, 64, 51, 0.16);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: "Zen Maru Gothic", "Noto Sans TC", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  background-color: var(--bg);
  background-image:
    radial-gradient(#ffd6c2 1.2px, transparent 1.2px),
    radial-gradient(at 10% 10%, rgba(255, 182, 193, 0.25) 0px, transparent 45%),
    radial-gradient(at 90% 15%, rgba(167, 243, 208, 0.25) 0px, transparent 45%),
    radial-gradient(at 50% 95%, rgba(253, 230, 138, 0.25) 0px, transparent 50%);
  background-size: 26px 26px, 100% 100%, 100% 100%, 100% 100%;
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.55;
  padding-bottom: 64px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 252, 249, 0.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 2px solid var(--border);
}

.topbar-inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: linear-gradient(135deg, #ff7a59 0%, #ffb36b 100%);
  box-shadow: 0 4px 0 #e05636, 0 8px 16px rgba(255, 122, 89, 0.25);
  display: grid;
  place-items: center;
  font-size: 26px;
  flex-shrink: 0;
}

.brand-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  line-height: 1.2;
}

.class-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  padding: 2px 6px 2px 0;
  font-family: inherit;
  font-size: 20px;
  font-weight: 900;
  color: var(--text);
  cursor: pointer;
}

.class-pill:hover {
  color: var(--primary);
}

.class-pill .chevron {
  font-size: 13px;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 2px 8px;
  border-radius: 999px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.status-pill,
.mode-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border: 2px solid var(--border);
  background: #ffffff;
  color: var(--text);
  box-shadow: 0 3px 0 var(--border);
  transition: all 0.15s ease;
}

.status-pill:active,
.mode-pill:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--border);
}

.status-pill .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--amber);
}

.status-pill.synced .dot { background: var(--emerald); }
.status-pill.syncing .dot { background: var(--blue); animation: pulse 1s infinite; }
.status-pill.error .dot { background: var(--rose); }

.mode-pill.unlocked {
  background: var(--emerald-soft);
  border-color: var(--emerald-border);
  color: var(--emerald-text);
  box-shadow: 0 3px 0 #6ee7b7;
}

.mode-pill.locked {
  background: var(--surface-muted);
  color: var(--text-muted);
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

/* Main Navigation */
.main-nav {
  max-width: 1160px;
  margin: 18px auto 0;
  padding: 0 18px;
  display: flex;
  gap: 10px;
}

.nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 18px;
  border: 2px solid var(--border);
  background: rgba(255, 255, 255, 0.85);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--border);
  transition: all 0.15s ease;
}

.nav-tab:hover {
  background: #ffffff;
  color: var(--text);
  transform: translateY(-1px);
}

.nav-tab.active {
  background: linear-gradient(135deg, #ff7a59 0%, #ff9a76 100%);
  border-color: #ff7a59;
  color: #ffffff;
  box-shadow: 0 4px 0 var(--primary-shadow), 0 8px 18px rgba(255, 122, 89, 0.25);
}

/* Container & Cards */
.container {
  max-width: 1160px;
  margin: 18px auto 0;
  padding: 0 18px;
}

.view-panel {
  display: none;
  animation: fadeIn 0.2s ease;
}

.view-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.card-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 900;
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  font-size: 13px;
  font-weight: 800;
  padding: 3px 11px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
}

/* Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 18px;
  border-radius: 16px;
  border: 2px solid transparent;
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.12s ease;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(2px);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 14.5px;
  border-radius: 13px;
}

.btn-icon {
  padding: 9px 14px;
  background: #ffffff;
  border-color: var(--border);
  color: var(--text);
  box-shadow: 0 3px 0 var(--border);
}

.btn-primary {
  background: linear-gradient(135deg, #ff7a59 0%, #ff9a76 100%);
  border-color: #ff7a59;
  color: #ffffff;
  box-shadow: 0 4px 0 var(--primary-shadow);
}
.btn-primary:hover { filter: brightness(1.04); }
.btn-primary:active { box-shadow: 0 1px 0 var(--primary-shadow); }

.btn-secondary {
  background: #ffffff;
  border-color: var(--border);
  color: var(--text);
  box-shadow: 0 3px 0 var(--border);
}
.btn-secondary:hover { background: var(--surface-muted); }
.btn-secondary:active { box-shadow: 0 1px 0 var(--border); }

.btn-ghost {
  background: rgba(255, 243, 235, 0.7);
  color: var(--text-muted);
}
.btn-ghost:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.btn-emerald {
  background: linear-gradient(135deg, #10b981 0%, #34d399 100%);
  border-color: #10b981;
  color: #ffffff;
  box-shadow: 0 4px 0 #059669;
}
.btn-emerald:active { box-shadow: 0 1px 0 #059669; }

.btn-danger {
  background: var(--rose-soft);
  color: var(--rose-text);
  border-color: var(--rose-border);
}

.input,
.input-date {
  width: 100%;
  padding: 11px 14px;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: #ffffff;
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  outline: none;
  transition: all 0.15s ease;
}

.input:focus,
.input-date:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.input-date {
  width: auto;
  font-weight: 700;
}

.textarea {
  resize: vertical;
  line-height: 1.7;
}

/* Empty Hero */
.empty-hero {
  text-align: center;
  padding: 48px 24px;
  margin-bottom: 18px;
  background: linear-gradient(135deg, #ffffff 0%, #fff0ea 100%);
  border-color: #ffd0bd;
}

.empty-hero-icon {
  font-size: 60px;
  margin-bottom: 10px;
}

.empty-hero h2 {
  margin: 0 0 10px;
  font-size: 26px;
  font-weight: 900;
}

.empty-hero p {
  margin: 0 0 22px;
  font-size: 17px;
  color: var(--text-muted);
}

.empty-hero-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Panel Header */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.month-nav,
.checklist-date-bar,
.panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.month-title {
  margin: 0 8px;
  font-size: 24px;
  font-weight: 900;
}

/* Calendar */
.calendar-card {
  padding: 18px;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  text-align: center;
  font-size: 15px;
  font-weight: 800;
  color: var(--text-muted);
  padding-bottom: 12px;
}

.calendar-weekdays > div {
  background: var(--surface-muted);
  padding: 6px 0;
  border-radius: 10px;
}

.calendar-weekdays .weekend {
  background: var(--rose-soft);
  color: var(--rose-text);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 9px;
  margin-top: 6px;
}

.cal-cell {
  min-height: 112px;
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 10px;
  background: #ffffff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.16s ease;
}

.cal-cell:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(255, 122, 89, 0.16);
}

.cal-cell.empty {
  background: transparent;
  border-color: transparent;
  cursor: default;
}
.cal-cell.empty:hover {
  transform: none;
  box-shadow: none;
}

.cal-cell.today {
  border-color: var(--primary);
  background: linear-gradient(180deg, #fff0ea 0%, #ffffff 100%);
}

.cal-day-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cal-day-num {
  font-size: 17px;
  font-weight: 900;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 10px;
}

.cal-cell.today .cal-day-num {
  background: var(--primary);
  color: #ffffff;
}

.cal-hw-preview {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cal-footer {
  margin-top: 8px;
  display: grid;
  gap: 5px;
}

.cal-badges {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.cal-pill {
  font-size: 12px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
}

.cal-pill.done {
  background: var(--emerald-soft);
  color: var(--emerald-text);
}

.cal-pill.pending {
  background: var(--amber-soft);
  color: var(--amber-text);
}

.cal-progress-track {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-muted);
  overflow: hidden;
}

.cal-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #10b981, #34d399);
}

/* Checklist */
.hw-tabs {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 14px;
}

.hw-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: #ffffff;
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 3px 0 var(--border);
  transition: all 0.15s ease;
}

.hw-tab.active {
  background: linear-gradient(135deg, #ff7a59 0%, #ff9a76 100%);
  border-color: #ff7a59;
  color: #ffffff;
  box-shadow: 0 4px 0 var(--primary-shadow);
}

.hw-tab .hw-count {
  font-size: 13px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text);
}

.hw-tab.active .hw-count {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

.summary-box {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 18px;
  padding: 15px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  font-variant-numeric: tabular-nums;
}

.summary-box .label {
  font-size: 15px;
  font-weight: 800;
}

.summary-box .num {
  font-size: 30px;
  font-weight: 900;
}

.summary-box.green { background: var(--emerald-soft); border-color: var(--emerald-border); }
.summary-box.green .label, .summary-box.green .num { color: var(--emerald-text); }

.summary-box.red { background: var(--rose-soft); border-color: var(--rose-border); }
.summary-box.red .label, .summary-box.red .num { color: var(--rose-text); }

.summary-box.orange { background: var(--amber-soft); border-color: var(--amber-border); }
.summary-box.orange .label, .summary-box.orange .num { color: var(--amber-text); }

.summary-box.blue { background: var(--blue-soft); border-color: var(--blue-border); }
.summary-box.blue .label, .summary-box.blue .num { color: var(--blue-text); }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.filter-pills,
.batch-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-pill {
  padding: 8px 15px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--surface-muted);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
}

.filter-pill.active {
  background: var(--text);
  border-color: var(--text);
  color: #ffffff;
}

/* Student Cards */
.student-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
}

.stu-card {
  position: relative;
  border: 2px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  padding: 18px 14px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 4px 0 var(--border);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  font-family: inherit;
}

.stu-card:active {
  transform: translateY(3px);
}

.stu-card .stu-no {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 900;
  background: #ffffff;
  border: 2px solid rgba(0,0,0,0.06);
}

.stu-card .stu-name {
  font-size: 22px;
  font-weight: 900;
  color: var(--text);
  letter-spacing: 0.03em;
}

.stu-card .stu-status-badge {
  font-size: 14.5px;
  font-weight: 800;
  padding: 5px 14px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.stu-card.status-red {
  border-color: var(--rose-border);
  background: linear-gradient(180deg, #ffffff 0%, #ffe8ed 100%);
  box-shadow: 0 4px 0 var(--rose-border);
}
.stu-card.status-red .stu-no { color: var(--rose-text); }
.stu-card.status-red .stu-status-badge { background: var(--rose); color: #ffffff; }

.stu-card.status-green {
  border-color: var(--emerald-border);
  background: linear-gradient(180deg, #ffffff 0%, #e1faee 100%);
  box-shadow: 0 4px 0 var(--emerald-border);
}
.stu-card.status-green .stu-no { color: var(--emerald-text); }
.stu-card.status-green .stu-status-badge { background: var(--emerald); color: #ffffff; }

.stu-card.status-orange {
  border-color: var(--amber-border);
  background: linear-gradient(180deg, #ffffff 0%, #fef3c7 100%);
  box-shadow: 0 4px 0 var(--amber-border);
}
.stu-card.status-orange .stu-no { color: var(--amber-text); }
.stu-card.status-orange .stu-status-badge { background: var(--amber); color: #ffffff; }

.stu-card.status-blue {
  border-color: var(--blue-border);
  background: linear-gradient(180deg, #ffffff 0%, #e0f2fe 100%);
  box-shadow: 0 4px 0 var(--blue-border);
}
.stu-card.status-blue .stu-no { color: var(--blue-text); }
.stu-card.status-blue .stu-status-badge { background: var(--blue); color: #ffffff; }

/* Table View */
.table-wrapper {
  overflow-x: auto;
  padding: 0;
}

.checklist-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
}

.checklist-table th,
.checklist-table td {
  padding: 14px 16px;
  border-bottom: 1.5px solid var(--border);
  text-align: center;
  white-space: nowrap;
}

.checklist-table thead th {
  background: var(--surface-muted);
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
}

.checklist-table tbody td.stu-col {
  text-align: left;
  font-weight: 800;
  font-size: 17px;
  cursor: pointer;
  position: sticky;
  left: 0;
  background: var(--surface);
  border-right: 1.5px solid var(--border);
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
  border: none;
  cursor: pointer;
  font-family: inherit;
  color: #ffffff;
}
.status-chip:active { transform: scale(0.95); }

.status-chip.red { background: var(--rose); }
.status-chip.green { background: var(--emerald); }
.status-chip.orange { background: var(--amber); }
.status-chip.blue { background: var(--blue); }

/* Tracking */
.sub-tabs {
  display: flex;
  gap: 10px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.sub-tab {
  padding: 10px 18px;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: var(--surface-muted);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 700;
  cursor: pointer;
}

.sub-tab.active {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary);
}

.track-pane { display: none; }
.track-pane.active { display: block; }

.form-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.form-field {
  flex: 1;
  min-width: 170px;
}

.form-field label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-btn { flex: 0 0 auto; }

.tracking-results {
  margin-top: 16px;
  display: grid;
  gap: 12px;
}

.track-item-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 18px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: var(--shadow);
}

.track-item-title {
  font-weight: 800;
  font-size: 17px;
}

.track-item-meta {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* Settings */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}

.inline-add-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.bulk-box {
  background: var(--surface-muted);
  padding: 14px;
  border-radius: 16px;
  margin-bottom: 14px;
}

.bulk-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.class-manage-list,
.student-manage-list,
.quick-class-list {
  display: grid;
  gap: 9px;
  max-height: 380px;
  overflow-y: auto;
}

.manage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  font-size: 16px;
}

.manage-row.active-class {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.manage-row-actions {
  display: flex;
  gap: 6px;
}

.sync-info-box {
  background: var(--surface-muted);
  padding: 14px 16px;
  border-radius: 14px;
  font-size: 15px;
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

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

.qr-box {
  text-align: center;
  margin-top: 14px;
}

.qr-box img {
  width: 156px;
  height: 156px;
  padding: 8px;
  background: #ffffff;
  border-radius: 16px;
  border: 2px solid var(--border);
}

/* Modals */
.modal-backdrop,
.projection-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(59, 47, 47, 0.45);
  backdrop-filter: blur(6px);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.open,
.projection-backdrop.open {
  display: flex;
}

.modal-card {
  width: 100%;
  max-width: 580px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: popIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-card.modal-sm {
  max-width: 440px;
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 18px 22px;
  border-bottom: 2px solid var(--border);
  background: var(--surface-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 900;
}

.btn-close {
  background: #ffffff;
  border: 2px solid var(--border);
  width: 36px;
  height: 36px;
  border-radius: 999px;
  font-size: 16px;
  color: var(--text-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.modal-body {
  padding: 20px 22px;
}

.modal-footer {
  padding: 14px 22px;
  border-top: 2px solid var(--border);
  background: var(--surface-muted);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.quick-tags {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.quick-tags-label {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text-muted);
}

.tag-btn {
  padding: 6px 13px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--surface-muted);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.tag-btn:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 12px;
  font-size: 14.5px;
  color: var(--text-muted);
  cursor: pointer;
}

.muted-text {
  font-size: 14.5px;
  color: var(--text-muted);
  margin: 6px 0;
}

.error-text {
  font-size: 14.5px;
  color: var(--rose-text);
  background: var(--rose-soft);
  padding: 10px 12px;
  border-radius: 12px;
  margin-top: 10px;
}

/* Projection Modal */
.projection-card {
  width: 100%;
  max-width: 860px;
  max-height: 90vh;
  overflow-y: auto;
  background: #ffffff;
  border: 3px solid var(--border);
  border-radius: 28px;
  padding: 34px 38px;
  box-shadow: var(--shadow-lg);
}

.projection-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  border-bottom: 2px solid var(--border);
  padding-bottom: 16px;
  margin-bottom: 22px;
}

.proj-class {
  font-size: 18px;
  font-weight: 800;
  color: var(--primary);
}

.proj-date {
  margin: 4px 0 0;
  font-size: 32px;
  font-weight: 900;
}

.proj-list {
  margin: 0;
  padding-left: 38px;
  font-size: 32px;
  font-weight: 800;
  line-height: 1.85;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 26px;
  right: 20px;
  z-index: 999;
  display: grid;
  gap: 8px;
}

.toast {
  background: #3b2f2f;
  color: #ffffff;
  padding: 12px 20px;
  border-radius: 16px;
  font-size: 15.5px;
  font-weight: 700;
  box-shadow: var(--shadow-lg);
  animation: fadeUp 0.2s ease;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.empty-state {
  text-align: center;
  padding: 42px 20px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
}

/* Incomplete Summary Modal */
.incomplete-summary-list {
  display: grid;
  gap: 14px;
}

.inc-hw-card {
  border: 2px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  background: var(--bg);
}

.inc-hw-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.inc-hw-title {
  font-size: 18px;
  font-weight: 900;
  color: var(--text);
}

.inc-group {
  margin-top: 8px;
}

.inc-group-label {
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 6px;
}

.inc-group-label.red { color: var(--rose-text); }
.inc-group-label.orange { color: var(--amber-text); }

.inc-stu-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.inc-stu-pill {
  padding: 6px 14px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.1s ease;
}

.inc-stu-pill:active {
  transform: scale(0.95);
}

.inc-stu-pill.red {
  background: var(--rose-soft);
  color: var(--rose-text);
  border-color: var(--rose-border);
}

.inc-stu-pill.orange {
  background: var(--amber-soft);
  color: var(--amber-text);
  border-color: var(--amber-border);
}

/* Mobile Responsive */
@media (max-width: 768px) {
  body {
    padding-bottom: 94px;
  }

  .brand-title {
    display: none;
  }

  .class-pill {
    font-size: 18px;
  }

  .main-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    background: rgba(255, 252, 249, 0.96);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 2px solid var(--border);
    z-index: 100;
    justify-content: space-around;
    gap: 6px;
  }

  .nav-tab {
    flex: 1;
    flex-direction: column;
    gap: 3px;
    padding: 8px 4px;
    font-size: 12.5px;
    border: none;
    box-shadow: none;
    background: transparent;
  }

  .nav-tab.active {
    background: var(--primary-soft);
    color: var(--primary);
    box-shadow: none;
  }

  .nav-icon {
    font-size: 20px;
  }

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

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

  .cal-cell {
    min-height: 74px;
    padding: 6px;
    border-radius: 12px;
  }

  .cal-hw-preview {
    display: none;
  }

  .toast-container {
    bottom: 94px;
    left: 16px;
    right: 16px;
  }
}

@media print {
  .topbar, .main-nav, .panel-header, .toolbar, .hw-tabs, .toast-container {
    display: none !important;
  }
  body {
    background: #ffffff;
    padding: 0;
  }
  .card {
    box-shadow: none;
    border: none;
  }
  #checklistCardsContainer {
    display: none !important;
  }
  #checklistTableContainer {
    display: block !important;
  }
}
