/* ============================================
   Neumorphism Design System — Cool Grey
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,700&family=Plus+Jakarta+Sans:wght@500;600;700;800&display=swap');

/* ========== Design Tokens ========== */

:root {
  /* Base colours */
  --bg: #E0E5EC;
  --fg: #3D4852;
  --muted: #6B7280;
  --muted-light: #A0AEC0;
  --accent: #6C63FF;
  --accent-light: #8B84FF;
  --accent-secondary: #38B2AC;
  --warning: #ED8936;
  --danger: #E53E3E;
  
  /* Neu shadows — light + dark pair */
  --shadow-ext: 9px 9px 16px rgb(163,177,198,0.6), -9px -9px 16px rgba(255,255,255,0.5);
  --shadow-ext-hover: 12px 12px 20px rgb(163,177,198,0.7), -12px -12px 20px rgba(255,255,255,0.6);
  --shadow-ext-sm: 5px 5px 10px rgb(163,177,198,0.6), -5px -5px 10px rgba(255,255,255,0.5);
  --shadow-inset: inset 6px 6px 10px rgb(163,177,198,0.6), inset -6px -6px 10px rgba(255,255,255,0.5);
  --shadow-inset-deep: inset 10px 10px 20px rgb(163,177,198,0.7), inset -10px -10px 20px rgba(255,255,255,0.6);
  --shadow-inset-sm: inset 3px 3px 6px rgb(163,177,198,0.6), inset -3px -3px 6px rgba(255,255,255,0.5);
  
  /* Colours for class badges */
  --c1: 247, 115%, 70%;
  --c2: 267, 84%, 76%;
  --c3: 155, 56%, 62%;
  --c4: 18, 88%, 65%;
  --c5: 340, 78%, 70%;
  --c6: 33, 82%, 62%;
  --c7: 195, 75%, 65%;
  --c8: 128, 55%, 55%;
  
  scroll-behavior: smooth;
}

/* ========== Reset & Base ========== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--fg);
  padding: 24px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
}

h1 { font-size: 22px; margin-bottom: 14px; }
h2 { font-size: 1.25rem; margin-bottom: 0.75rem; }

.container { max-width: 1400px; margin: 0 auto; }

a { color: var(--accent); }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ========== Card (Extruded) ========== */

.card {
  background: var(--bg);
  border-radius: 32px;
  box-shadow: var(--shadow-ext);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

/* ========== App Shell & Lock ========== */

.app-locked {
  opacity: 0.35;
  pointer-events: none;
  user-select: none;
  transform: scale(0.985);
  filter: saturate(0.9);
}
#appShell { transition: opacity .2s ease, transform .2s ease, filter .2s ease; }

/* ========== Login Gate (Neumorph) ========== */

.pro-gate {
  max-width: 620px;
  margin: 40px auto 24px;
  padding: 40px 32px;
  background: var(--bg);
  border-radius: 32px;
  box-shadow: var(--shadow-ext);
}
.gate-header { text-align: center; margin-bottom: 20px; }
.gate-logo {
  width: 64px; height: 64px;
  margin: 0 auto 14px;
  display: grid; place-items: center;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 800; font-size: 20px; letter-spacing: 1px;
  border-radius: 16px;
  color: var(--accent);
  background: var(--bg);
  box-shadow: var(--shadow-inset);
  transition: box-shadow 0.3s ease-out;
}
.gate-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.4rem; font-weight: 800;
  line-height: 1.3;
  color: var(--fg);
}
.gate-subtitle { margin: 8px 0 0; color: var(--muted); font-size: 0.95rem; line-height: 1.5; }
.gate-actions { display: grid; place-items: center; gap: 14px; padding: 8px 0 4px; }
.gate-msg { margin-top: 8px; font-size: 0.9rem; color: var(--muted); text-align: center; }
.gate-msg.error { color: var(--danger); font-weight: 700; }
.gate-foot { margin-top: 12px; text-align: center; color: var(--muted-light); font-size: 0.85rem; }
.gate-foot a { color: var(--accent); text-decoration: none; }
.gate-foot a:hover { text-decoration: underline; }

/* ========== Profile Row ========== */

#profileRow {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  margin-bottom: 1rem; padding: 14px 20px;
  background: var(--bg);
  border-radius: 32px;
  box-shadow: var(--shadow-ext-sm);
}
#profileRow .spacer { flex: 1; }

/* ========== Buttons (Neumorph) ========== */

.btn {
  position: relative;
  font-family: 'DM Sans', sans-serif;
  font-weight: 700; font-size: 14px;
  padding: 10px 18px;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  background: var(--bg);
  color: var(--fg);
  box-shadow: var(--shadow-ext-sm);
}
.btn:hover {
  box-shadow: var(--shadow-ext-hover);
}
.btn:active {
  box-shadow: var(--shadow-inset-sm);
}
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Accent primary */
.btn.info,
.btn[style*="font-size:12px"] {
  background: var(--accent);
  color: #fff;
  box-shadow: 7px 7px 14px rgb(163,177,198,0.6), -7px -7px 14px rgba(255,255,255,0.5);
}
.btn.info:hover {
  background: var(--accent-light);
  box-shadow: 10px 10px 18px rgb(163,177,198,0.7), -10px -10px 18px rgba(255,255,255,0.6);
}
.btn.info:active {
  box-shadow: inset 4px 4px 8px rgba(0,0,0,0.15), inset -4px -4px 8px rgba(255,255,255,0.1);
}

/* Success (teal) */
.btn.success {
  background: var(--accent-secondary);
  color: #fff;
  box-shadow: 7px 7px 14px rgb(163,177,198,0.6), -7px -7px 14px rgba(255,255,255,0.5);
}
.btn.success:hover {
  box-shadow: 10px 10px 18px rgb(163,177,198,0.7), -10px -10px 18px rgba(255,255,255,0.6);
}
.btn.success:active {
  box-shadow: inset 4px 4px 8px rgba(0,0,0,0.15), inset -4px -4px 8px rgba(255,255,255,0.1);
}
.btn.success.active {
  background: #2C9A92;
  box-shadow: var(--shadow-inset-sm);
}

/* Warning */
.btn.warn {
  background: var(--warning);
  color: #fff;
  box-shadow: 7px 7px 14px rgb(163,177,198,0.6), -7px -7px 14px rgba(255,255,255,0.5);
}

/* Danger */
.btn.danger {
  background: var(--danger);
  color: #fff;
  box-shadow: 7px 7px 14px rgb(163,177,198,0.6), -7px -7px 14px rgba(255,255,255,0.5);
}

/* Theme toggle (no longer functional, kept for compatibility) */
.btn.theme-toggle {
  background: var(--bg);
  color: var(--muted);
  box-shadow: var(--shadow-inset-sm);
  cursor: not-allowed; opacity: 0.6;
}

.undo-btn {
  padding: 4px 12px !important;
  font-size: 12px !important;
  margin-left: 10px;
  border-radius: 12px !important;
}

/* ========== Inputs (Inset Deep) ========== */

input[type="text"],
input[type="date"],
input[type="file"],
input[type="number"],
textarea,
select,
input[type="url"] {
  width: 100%;
  background: var(--bg);
  color: var(--fg);
  border: none;
  border-radius: 16px;
  padding: 12px 16px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  box-shadow: var(--shadow-inset);
  transition: box-shadow 0.3s ease-out;
  -webkit-appearance: none;
  appearance: none;
}
input[type="text"]:focus,
input[type="date"]:focus,
input[type="file"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus,
input[type="url"]:focus {
  outline: none;
  box-shadow: var(--shadow-inset-deep), 0 0 0 3px var(--accent);
}
input[type="text"]::placeholder,
input[type="date"]::placeholder,
input[type="file"]::placeholder,
input[type="number"]::placeholder,
textarea::placeholder,
select::placeholder,
input[type="url"]::placeholder {
  color: var(--muted-light);
}

label {
  display: block;
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.01em;
}

/* ========== Layout & Timetable Grid ========== */

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1.5rem; }
.timetable-container {
  overflow-x: auto;
}

/* Wrapper holds the card + side buttons */
.timetable-wrapper {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

/* Week nav buttons on calendar sides */
.week-nav-btn {
  flex-shrink: 0;
  width: 28px;
  border: none;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  padding: 0;
  margin: 0;
  box-shadow: var(--shadow-ext-sm);
  transition: box-shadow 0.3s ease-out, color 0.2s;
}
.week-nav-btn:hover {
  color: var(--accent);
  box-shadow: var(--shadow-ext-hover);
}
.week-nav-btn:active {
  box-shadow: var(--shadow-inset-sm);
}

.timetable-grid {
  display: grid;
  grid-template-columns: 110px repeat(5, minmax(160px, 1fr));
  gap: 12px;
}

/* ========== Grid Header (Day labels) ========== */

.grid-header {
  position: sticky; top: 0;
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: var(--bg);
  border-radius: 16px;
  box-shadow: var(--shadow-ext-sm);
  padding: 12px 8px;
  font-weight: 700; font-size: 13px; text-align: center;
  z-index: 2; cursor: pointer;
  user-select: none;
  color: var(--fg);
}
.grid-header:hover {
  box-shadow: var(--shadow-ext-hover);
}
.grid-header.active {
  box-shadow: var(--shadow-inset);
  color: var(--accent);
}
.grid-header.corner { cursor: default; }
.grid-header.corner-toggle { cursor: pointer; }
.grid-header.corner-toggle:hover {
  box-shadow: var(--shadow-ext-hover);
  color: var(--accent);
}

/* ========== Time Labels ========== */

.time-label {
  background: var(--bg);
  border-radius: 16px;
  box-shadow: var(--shadow-inset-sm);
  padding: 8px 6px;
  display: flex; flex-direction: column; gap: 4px;
  justify-content: center; align-items: center;
  font-weight: 600; font-size: 12px;
  color: var(--fg);
}
.time-label .period-id {
  color: var(--muted-light);
  font-size: 11px;
  font-weight: 500;
}

/* ========== Lesson Slots ========== */

.lesson-slot {
  background: var(--bg);
  border-radius: 16px;
  box-shadow: var(--shadow-inset);
  padding: 8px;
  min-height: 76px;
  display: flex; align-items: stretch;
  position: relative;
}
.lesson-slot.empty {
  background: var(--bg);
  color: var(--muted-light);
  box-shadow: var(--shadow-inset-sm);
  display: flex; align-items: center;
  justify-content: center;
  font-style: italic; font-size: 12px;
  cursor: pointer;
  min-height: 76px;
}
.lesson-slot.scheduled {
  /* Card inside a well — shows nested depth */
}

.lesson-card {
  display: flex; flex-direction: column; gap: 4px;
  width: 100%; cursor: pointer;
}
.lesson-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700; font-size: 13px;
  color: var(--fg);
}
.lesson-meta { color: var(--muted); font-size: 11px; font-weight: 500; }

/* Note badge */
.note-badge {
  position: absolute; top: 6px; right: 6px;
  background: var(--bg);
  color: var(--warning);
  font-family: 'DM Sans', sans-serif;
  font-weight: 700; font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  box-shadow: var(--shadow-ext-sm);
}
/* Duty styling — clean pill badge with red tone */
.lesson-slot.duty {
  outline: 2px solid var(--danger);
  outline-offset: -2px;
  border-radius: 16px;
  background: color-mix(in oklab, var(--danger) 6%, var(--bg));
}
.duty-badge-inline {
  display: inline-block;
  background: var(--danger);
  color: #fff;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  font-size: 10px;
  padding: 1px 10px;
  border-radius: 999px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  margin-bottom: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}
.duty-banner {
  display: inline-block;
  background: var(--danger);
  color: #fff;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  font-size: 11px;
  padding: 2px 14px;
  border-radius: 999px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

/* ECA styling — teal accent */
.lesson-slot.eca {
  outline: 2px solid var(--accent-secondary);
  outline-offset: -2px;
  border-radius: 16px;
  background: color-mix(in oklab, var(--accent-secondary) 6%, var(--bg));
}
.eca-badge-inline {
  display: inline-block;
  background: var(--accent-secondary);
  color: #fff;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  font-size: 10px;
  padding: 1px 10px;
  border-radius: 999px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  margin-bottom: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}
.eca-banner {
  display: inline-block;
  background: var(--accent-secondary);
  color: #fff;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  font-size: 11px;
  padding: 2px 14px;
  border-radius: 999px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

/* Order badge */
.order-badge {
  position: absolute; bottom: 6px; right: 6px;
  background: var(--bg);
  color: var(--accent-secondary);
  font-weight: 700; font-size: 12px;
  width: 22px; height: 22px;
  border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-ext-sm);
  user-select: none;
}
/* Classroom link icon */
.lesson-class-link {
  position: absolute; bottom: 6px; right: 6px;
  width: 26px; height: 26px;
  background: var(--bg);
  border-radius: 10px;
  color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  text-decoration: none;
  box-shadow: var(--shadow-ext-sm);
  transition: box-shadow 0.3s ease-out, color 0.2s;
}
.lesson-class-link:hover {
  box-shadow: var(--shadow-ext-hover);
  color: var(--accent);
}
.lesson-class-link svg { width: 14px; height: 14px; }

/* Class colour coding — outline for visibility + subtle background tint */
.lesson-slot[class*="cc-"] { box-shadow: var(--shadow-inset); }
.cc-1 { outline: 3px solid hsl(var(--c1)); outline-offset: -3px; border-radius: 16px; background: color-mix(in oklab, hsl(var(--c1)) 16%, var(--bg)); }
.cc-2 { outline: 3px solid hsl(var(--c2)); outline-offset: -3px; border-radius: 16px; background: color-mix(in oklab, hsl(var(--c2)) 16%, var(--bg)); }
.cc-3 { outline: 3px solid hsl(var(--c3)); outline-offset: -3px; border-radius: 16px; background: color-mix(in oklab, hsl(var(--c3)) 16%, var(--bg)); }
.cc-4 { outline: 3px solid hsl(var(--c4)); outline-offset: -3px; border-radius: 16px; background: color-mix(in oklab, hsl(var(--c4)) 16%, var(--bg)); }
.cc-5 { outline: 3px solid hsl(var(--c5)); outline-offset: -3px; border-radius: 16px; background: color-mix(in oklab, hsl(var(--c5)) 16%, var(--bg)); }
.cc-6 { outline: 3px solid hsl(var(--c6)); outline-offset: -3px; border-radius: 16px; background: color-mix(in oklab, hsl(var(--c6)) 16%, var(--bg)); }
.cc-7 { outline: 3px solid hsl(var(--c7)); outline-offset: -3px; border-radius: 16px; background: color-mix(in oklab, hsl(var(--c7)) 16%, var(--bg)); }
.cc-8 { outline: 3px solid hsl(var(--c8)); outline-offset: -3px; border-radius: 16px; background: color-mix(in oklab, hsl(var(--c8)) 16%, var(--bg)); }

/* Current period highlight */
.lesson-slot.current {
  box-shadow: var(--shadow-ext-sm), 0 0 0 3px var(--warning);
  background: color-mix(in oklab, var(--warning) 12%, var(--bg));
}
/* Past lessons */
.lesson-slot.past { opacity: 0.5; filter: saturate(50%); }
.lesson-slot.past::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  border-radius: 16px;
  background-image: linear-gradient(to top right, transparent calc(50% - 0.5px), rgba(107,114,128,0.2) calc(50% - 0.5px), rgba(107,114,128,0.2) calc(50% + 0.5px), transparent calc(50% + 0.5px)), linear-gradient(to top left, transparent calc(50% - 0.5px), rgba(107,114,128,0.2) calc(50% - 0.5px), rgba(107,114,128,0.2) calc(50% + 0.5px), transparent calc(50% + 0.5px));
}

/* Moved class indicator */
.lesson-slot.moved {
  box-shadow: var(--shadow-inset), 0 0 0 2px var(--warning);
}
.lesson-slot.moved .lesson-title .moved-indicator {
  display: inline-block;
  color: var(--warning);
  font-weight: 700;
  margin-right: 4px;
}

/* Custom color */
.has-custom-color { border-radius: 16px; }

/* Drag and drop */
.lesson-card[draggable="true"] {
  cursor: grab; user-select: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.lesson-card[draggable="true"]:active { cursor: grabbing; }
.lesson-card.dragging { opacity: 0.4; transform: scale(0.95); }
.lesson-slot.drag-over {
  box-shadow: var(--shadow-inset-deep), 0 0 0 3px var(--accent) !important;
}
.timetable-grid.focusing .lesson-slot.dimmed {
  filter: grayscale(100%) saturate(40%); opacity: 0.35;
}

/* ========== Notes Sidebar ========== */

.notes-sidebar {
  position: sticky; top: 1.5rem; height: fit-content; align-self: start;
  display: flex; flex-direction: column;
  max-height: calc(100vh - 3rem);
}
.notes-sidebar-head { display: grid; gap: 10px; margin-bottom: 10px; }
.day-header-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.day-tab-btn {
  background: var(--bg);
  border: none;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 999px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 600; font-size: 12px;
  cursor: pointer;
  box-shadow: var(--shadow-ext-sm);
  transition: box-shadow 0.3s ease-out, transform 0.3s ease-out;
}
.day-tab-btn:hover {
  box-shadow: var(--shadow-ext-hover);
  transform: translateY(-1px);
}
.day-tab-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: inset 3px 3px 6px rgba(0,0,0,0.1), inset -3px -3px 6px rgba(255,255,255,0.1);
}
.day-tab-btn.preview {
  box-shadow: var(--shadow-inset-sm);
  color: var(--accent);
}
.note-day-date { color: var(--muted-light); font-size: 12px; }

.notes-panel {
  display: grid; gap: 10px;
  overflow-y: auto;
  padding-right: 8px;
  margin-right: -8px;
}

.note-item {
  background: var(--bg);
  border-radius: 16px;
  padding: 12px;
  box-shadow: var(--shadow-ext-sm);
  border-left: 4px solid transparent;
  transition: box-shadow 0.3s ease-out;
}
.note-item:hover {
  box-shadow: var(--shadow-ext-hover);
}
.note-item.collapsed .note-body { grid-template-rows: 0fr; }
.note-body { display: grid; grid-template-rows: 1fr; transition: grid-template-rows 180ms ease; }
.note-body-inner { overflow: hidden; }
.note-item.current-note {
    border-left: 3px solid var(--accent);
}

/* Cover Work Button */
.cover-work-btn {
    display: block;
    margin-top: 8px;
    padding: 4px 10px;
    font-size: 12px;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    transition: opacity 0.15s ease;
}
.cover-work-btn:hover {
    opacity: 0.85;
}

/* Cover Work Modal */
#coverWorkContent {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin: 8px 0;
    white-space: pre-wrap;
    font-size: 14px;
    line-height: 1.6;
    max-height: 60vh;
    min-height: 120px;
    overflow-y: auto;
    color: var(--text);
    font-family: inherit;
}
.note-next-lesson {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-secondary);
  cursor: pointer;
  padding: 4px 8px;
  margin-bottom: 6px;
  background: color-mix(in oklab, var(--accent-secondary) 8%, var(--bg));
  border-radius: 999px;
  text-align: center;
  transition: box-shadow 0.2s ease;
}
.note-next-lesson:hover {
  box-shadow: var(--shadow-ext-sm);
  color: var(--accent);
}
.note-item-empty { color: var(--muted-light); font-size: 13px; }

.note-item.highlighted {
  box-shadow: 0 0 0 3px var(--accent), var(--shadow-ext-sm);
}

.note-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 6px;
}
.note-head button.note-toggle {
  all: unset;
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; padding: 4px 8px; border-radius: 12px;
  box-shadow: var(--shadow-inset-sm);
  font-family: 'DM Sans', sans-serif;
  font-weight: 600; font-size: 12px;
  color: var(--fg);
}
.note-head button.note-toggle:hover { box-shadow: var(--shadow-inset); }
.note-head .chevron { display: inline-block; transition: transform 180ms ease; }
.note-item.collapsed .note-head .chevron { transform: rotate(-90deg); }

.note-text {
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word;
  font-size: 13px; line-height: 1.5;
}
.note-text a { color: var(--accent); text-decoration: underline; word-break: break-all; }

/* ========== Status Bar ========== */

.status-bar {
  display: flex; flex-direction: column; gap: 12px;
  width: 100%; margin-top: 0.75rem;
  padding-top: 1.25rem;
  box-shadow: 0 -1px 0 var(--bg);
}
.header-action-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
}
.header-action-bar .spacer { flex: 1 1 auto; }
.header-actions-group { display: flex; flex-wrap: wrap; gap: 8px; }

#weekRangeDisplay {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.1rem; font-weight: 700;
  color: var(--fg);
}
#status { color: var(--muted); font-weight: 600; font-size: 14px; }

/* ========== Control Panel ========== */

.control-panel-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem;
}
.cp-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700; font-size: 1rem;
  color: var(--muted);
}
.cp-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg);
  border: none;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-weight: 600; font-size: 13px;
  box-shadow: var(--shadow-ext-sm);
  transition: box-shadow 0.3s ease-out;
}
.cp-toggle:hover { box-shadow: var(--shadow-ext-hover); }
.cp-toggle .chev { transition: transform 180ms ease; }
.cp-toggle[aria-expanded="false"] .chev { transform: rotate(-90deg); }
.cp-collapsible { display: grid; grid-template-rows: 1fr; transition: grid-template-rows 220ms ease; }
.cp-collapsible.collapsed { grid-template-rows: 0fr; }
.cp-inner { overflow: hidden; }

.control-panel { display: flex; flex-direction: column; gap: 1.25rem; }
.controls-row { display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: flex-end; }
.input-group { flex: 1 1 250px; min-width: 200px; }
.input-group.button-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.quick-jump-group { flex-grow: 0.5; }
.help-text-group { flex-grow: 2; }
.help-text-group p { font-size: 0.8rem; color: var(--muted-light); padding-bottom: 0.5rem; }
.quick-jump-input { display: flex; gap: 0.5rem; }

/* ========== Sidebar Toggle ========== */

.sidebar-toggle-btn { padding: 6px 12px !important; font-size: 12px !important; flex-shrink: 0; }

/* Collapsed sidebar */
.layout.sidebar-collapsed { grid-template-columns: 1fr !important; }
.layout.sidebar-collapsed .notes-sidebar { display: none !important; }
.layout.sidebar-collapsed .timetable-grid {
  grid-template-columns: 110px repeat(5, minmax(180px, 1fr));
}

/* Maximized notes sidebar — full-screen overlay */
.notes-sidebar.maximized {
  position: fixed !important;
  inset: 0 !important;
  z-index: 60 !important;
  width: 100% !important;
  max-width: 100% !important;
  max-height: 100vh !important;
  height: 100vh !important;
  border-radius: 0 !important;
  padding: 2rem !important;
  overflow-y: auto !important;
  box-shadow: none !important;
}
.notes-sidebar.maximized .notes-sidebar-head {
  position: sticky;
  top: 0;
  z-index: 1;
  padding-bottom: 1rem;
}
.notes-sidebar.maximized .notes-panel {
  max-height: none !important;
  padding-bottom: 4rem;
}
.notes-sidebar.maximized .sidebar-toggle-btn {
  display: none !important;
}
.notes-maximize-close {
  position: fixed !important;
  top: 1rem !important;
  right: 1rem !important;
  z-index: 61 !important;
  width: 40px !important;
  height: 40px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 18px !important;
  font-weight: 700 !important;
  border-radius: 12px !important;
  background: var(--bg) !important;
  color: var(--muted) !important;
  box-shadow: var(--shadow-ext-sm) !important;
  cursor: pointer !important;
  border: none !important;
  padding: 0 !important;
  line-height: 1 !important;
}
.notes-maximize-close:hover {
  color: var(--danger) !important;
  box-shadow: var(--shadow-ext-hover) !important;
}

/* Floating Show Notes button */
.sidebar-show-btn {
  position: fixed !important;
  right: 0 !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  padding: 14px 10px !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  border-radius: 16px 0 0 16px !important;
  z-index: 49 !important;
  cursor: pointer !important;
  background: var(--bg) !important;
  color: var(--muted) !important;
  border: none !important;
  box-shadow: var(--shadow-ext-sm) !important;
  opacity: 0.7 !important;
  transition: opacity 0.3s ease-out, box-shadow 0.3s ease-out !important;
  display: none;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  letter-spacing: 2px;
  min-height: 130px;
}
.sidebar-show-btn:hover {
  opacity: 1 !important;
  color: var(--accent) !important;
  box-shadow: var(--shadow-ext-hover) !important;
}
.layout.sidebar-collapsed .sidebar-show-btn { display: flex !important; align-items: center; justify-content: center; }

/* ========== Modals (Neumorph Overlay) ========== */

.modal {
  position: fixed; inset: 0;
  background: rgba(224,229,236,0.6);
  backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center;
  padding: 16px; z-index: 50;
}
.modal.open { display: flex; }
.modal-content {
  width: 100%; max-width: 520px;
  background: var(--bg);
  border-radius: 32px;
  box-shadow: var(--shadow-ext);
  padding: 24px;
  max-height: 90vh; overflow-y: auto;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.modal-header h2 { font-size: 1.1rem; margin: 0; }
.modal-close-btn {
  background: var(--bg);
  border: none;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  box-shadow: var(--shadow-ext-sm);
  transition: box-shadow 0.3s ease-out;
}
.modal-close-btn:hover { box-shadow: var(--shadow-ext-hover); }
#modalMeta { color: var(--muted); margin: 8px 0 12px; font-size: 13px; }
#teacherNoteText, #technicianOrderText { min-height: 120px; }

/* Wider Note Modal with Two-Column Layout */
.note-modal-content {
  max-width: 800px !important;
}
.note-modal-body {
  margin: 8px 0;
}
.note-modal-columns {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.note-modal-col {
  flex: 1;
  min-width: 0;
}
.note-modal-col-settings {
  flex: 0 0 260px;
}
@media (max-width: 700px) {
  .note-modal-columns {
    flex-direction: column;
  }
  .note-modal-col-settings {
    flex: auto;
  }
}

.modal-form-group { margin-bottom: 16px; }
.modal-form-group label {
  font-family: 'DM Sans', sans-serif;
  font-weight: 600; margin-bottom: 6px;
  color: var(--muted); font-size: 0.85rem;
}
.modal-input-group { display: flex; gap: 8px; }
.modal-input-group input { flex-grow: 1; }
.modal-input-group .btn { flex-shrink: 0; }
.modal-footer {
  display: flex; justify-content: flex-start; gap: 8px; margin-top: 20px;
  align-items: center; flex-wrap: wrap;
}
.modal-footer .spacer { flex-grow: 1; }

/* Export Modal */
.export-modal-content {
  margin-top: 12px;
  background: var(--bg);
  border-radius: 16px;
  box-shadow: var(--shadow-inset);
  padding: 16px;
  max-height: 60vh; overflow-y: auto;
}
.export-group { margin-bottom: 16px; }
.export-group:last-child { margin-bottom: 0; }
.export-group h3 {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 14px; font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px; padding-bottom: 4px;
}
.export-item { padding: 8px 0; font-size: 13px; }
.export-item:last-child { border-bottom: none; }
.export-item-meta { font-weight: 600; margin-bottom: 4px; color: var(--fg); }
.export-item-meta span { font-weight: 400; color: var(--muted); margin-left: 8px; font-size: 12px; }
.export-item-note { white-space: pre-wrap; word-break: break-word; padding-left: 4px; color: var(--muted); font-size: 12px; }

/* Copy Similar Modal */
.copy-similar-list {
  max-height: 50vh; overflow-y: auto;
  background: var(--bg);
  border-radius: 16px;
  box-shadow: var(--shadow-inset);
  padding: 8px; margin-bottom: 12px;
}
.copy-similar-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 8px;
  cursor: pointer; border-radius: 12px;
  transition: box-shadow 0.3s ease-out;
}
.copy-similar-item:hover { box-shadow: var(--shadow-ext-sm); }
.copy-similar-item input[type="checkbox"] {
  margin-top: 3px; flex-shrink: 0;
  width: 18px; height: 18px;
  accent-color: var(--accent);
}
.copy-similar-item-info { flex: 1; line-height: 1.5; font-size: 13px; color: var(--fg); }
.copy-similar-item-info strong { color: var(--fg); }
.copy-similar-item-info span { color: var(--muted); font-size: 12px; }
.copy-similar-item-info div { color: var(--muted-light); font-size: 12px; margin-top: 2px; }

/* ========== Color Picker ========== */
.color-picker-group { align-items: center; }
#classColorPicker {
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  width: 50px; height: 40px;
  background: var(--bg);
  border: none;
  cursor: pointer; padding: 0;
  border-radius: 12px;
  box-shadow: var(--shadow-inset-sm);
}
#classColorPicker::-webkit-color-swatch {
  border-radius: 10px; border: none;
}
#classColorPicker::-moz-color-swatch {
  border-radius: 10px; border: none;
}

/* ========== Holiday / Special Event Styling ========== */

.day-badge {
  display: block; font-size: 10px; font-weight: 600;
  margin-top: 4px; padding: 2px 8px;
  border-radius: 999px; line-height: 1.3;
}
.holiday-badge { background: var(--accent-secondary); color: #fff; }
.event-badge { background: var(--warning); color: #fff; }
.grid-header.holiday, .grid-header.special-event { padding-bottom: 8px; }
.lesson-slot.holiday, .lesson-slot.special-event {
  background: var(--bg);
  opacity: 0.6; filter: saturate(0.5);
  font-weight: 600; color: var(--muted);
  cursor: not-allowed;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-inset-sm);
}
.note-item-empty.holiday-note, .note-item-empty.event-note {
  padding: 1rem; text-align: center;
  background: var(--bg);
  border-radius: 16px; line-height: 1.5;
  box-shadow: var(--shadow-inset-sm);
}
.note-item-empty.holiday-note strong { color: var(--accent-secondary); }
.note-item-empty.event-note strong { color: var(--warning); }

/* ========== AI Chatbox ========== */

.chatbox-container { padding: 1rem 1.25rem; }
.chatbox-container.maximized {
  position: fixed !important;
  inset: 0 !important;
  z-index: 60 !important;
  width: 100% !important;
  max-width: 100% !important;
  height: 100vh !important;
  max-height: 100vh !important;
  border-radius: 0 !important;
  padding: 2rem !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
}
.chatbox-container.maximized .chatbox-header {
  flex-shrink: 0;
}
.chatbox-container.maximized .chatbox-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chatbox-container.maximized .chat-messages {
  flex: 1;
  max-height: none !important;
  min-height: 0 !important;
}
.chatbox-container.maximized .chat-input-area {
  flex-shrink: 0;
}
.chat-maximize-close {
  position: fixed !important;
  top: 1rem !important;
  right: 1rem !important;
  z-index: 61 !important;
  width: 40px !important;
  height: 40px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 18px !important;
  font-weight: 700 !important;
  border-radius: 12px !important;
  background: var(--bg) !important;
  color: var(--muted) !important;
  box-shadow: var(--shadow-ext-sm) !important;
  cursor: pointer !important;
  border: none !important;
  padding: 0 !important;
  line-height: 1 !important;
}
.chat-maximize-close:hover {
  color: var(--danger) !important;
  box-shadow: var(--shadow-ext-hover) !important;
}
.chatbox-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px;
}
.chatbox-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700; font-size: 1rem;
  color: var(--fg);
}
.chatbox-header-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chat-date-range { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chat-date-range input[type="date"] {
  width: auto; padding: 6px 10px; font-size: 12px; max-width: 130px;
  border-radius: 12px;
}
.chat-popup-btn { padding: 6px 12px !important; font-size: 12px !important; border-radius: 12px !important; }
.chatbox-body { display: block; margin-top: 10px; }

/* Chat Popup Overlay */
.chat-popup-content {
  width: 90vw !important; max-width: 1000px !important;
  max-height: 90vh !important;
  height: 85vh; display: flex; flex-direction: column; padding: 24px;
}
.chat-popup-content .modal-header { flex-shrink: 0; flex-wrap: wrap; gap: 8px; }
.chat-popup-content .chat-input-area { flex-shrink: 0; }
.chat-popup-content .chat-messages { flex: 1; }
.chat-popup-header-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Chat messages area */
.chat-messages {
  display: flex; flex-direction: column; gap: 8px; overflow-y: auto;
  max-height: 420px; min-height: 120px;
  background: var(--bg);
  border-radius: 16px;
  box-shadow: var(--shadow-inset);
  padding: 12px; margin-bottom: 10px;
}
.chat-messages:empty::after {
  content: 'No messages yet. Ask something!';
  display: flex; align-items: center; justify-content: center;
  color: var(--muted-light); font-style: italic; font-size: 13px;
  height: 80px;
}

.chat-msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13px; line-height: 1.5;
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word;
  animation: chatFadeIn 0.2s ease;
}
@keyframes chatFadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.chat-msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg.assistant {
  align-self: flex-start;
  background: var(--bg);
  color: var(--fg);
  box-shadow: var(--shadow-ext-sm);
  border-bottom-left-radius: 4px;
}
.chat-msg.error {
  align-self: center;
  background: rgba(229,62,62,0.08);
  color: var(--danger);
  font-size: 12px;
}

.chat-msg.loading {
  align-self: flex-start;
  display: flex; align-items: center; gap: 6px;
  padding: 14px 18px;
}
.chat-msg.loading .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted); display: inline-block;
  animation: dotPulse 1.4s ease-in-out infinite both;
}
.chat-msg.loading .dot:nth-child(1) { animation-delay: -0.32s; }
.chat-msg.loading .dot:nth-child(2) { animation-delay: -0.16s; }
.chat-msg.loading .dot:nth-child(3) { animation-delay: 0s; }
@keyframes dotPulse {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

.chat-input-area {
  display: flex; gap: 10px; align-items: stretch;
}
.chat-input-area textarea {
  flex: 1; resize: vertical; min-height: 42px; max-height: 120px;
  padding: 10px 14px; font-size: 13px; line-height: 1.4;
  border-radius: 16px;
}
.chat-input-area .btn {
  flex-shrink: 0; padding: 10px 20px; align-self: flex-end;
}

/* ========== Responsive ========== */

/* Tablet (768–1100px): narrower sidebar, compact grid */
@media (max-width: 1100px) {
  .layout { grid-template-columns: minmax(0, 1fr) 260px; gap: 1rem; }
  .timetable-grid {
    grid-template-columns: 80px repeat(5, minmax(130px, 1fr));
    gap: 8px;
  }
  .grid-header { font-size: 11px; padding: 10px 6px; }
  .time-label { font-size: 11px; padding: 6px 4px; }
  .lesson-slot { min-height: 64px; padding: 6px; }
  .lesson-title { font-size: 12px; }
  .lesson-meta { font-size: 10px; }
  .week-nav-btn { width: 24px; font-size: 12px; border-radius: 10px; }
  .timetable-wrapper { gap: 6px; }
  .notes-sidebar-head { gap: 6px; }
  .day-tab-btn { font-size: 11px; padding: 6px 10px; }
  .note-item { padding: 10px; }
  body { padding: 16px; }
  .card { padding: 1.25rem; border-radius: 28px; width: 100%; }
  .btn { font-size: 13px; padding: 8px 14px; }
  h1 { font-size: 20px; }
  h2 { font-size: 1.1rem; }
  .profileRow { padding: 10px 16px; }
  .control-panel-header { flex-wrap: wrap; gap: 8px; }
  .controls-row { gap: 1rem; }
  .input-group { flex: 1 1 200px; min-width: 160px; }
  .quick-jump-input input { max-width: 70px; }
  .chatbox-container { padding: 0.75rem 1rem; }
  .chatbox-header { gap: 8px; }
  .chat-date-range input[type="date"] { max-width: 110px; font-size: 11px; }
  .sidebar-show-btn { min-height: 100px; font-size: 12px !important; padding: 12px 8px !important; }
}

/* Small tablet / large phone (480–768px): single column, thinner */
@media (max-width: 768px) {
  .layout { grid-template-columns: 1fr; gap: 1rem; }
  .timetable-grid {
    grid-template-columns: 70px repeat(5, minmax(100px, 1fr));
    gap: 6px;
  }
  .grid-header { font-size: 10px; padding: 8px 4px; border-radius: 12px; }
  .time-label { font-size: 10px; padding: 4px; border-radius: 12px; }
  .time-label .period-id { font-size: 9px; }
  .lesson-slot { min-height: 56px; padding: 4px; border-radius: 12px; }
  .lesson-title { font-size: 11px; }
  .lesson-meta { font-size: 9px; }
  .note-badge { font-size: 8px; padding: 1px 5px; top: 4px; right: 4px; }
  .order-badge { width: 18px; height: 18px; font-size: 10px; bottom: 4px; right: 4px; }
  .lesson-class-link { width: 22px; height: 22px; bottom: 4px; right: 4px; }
  .lesson-class-link svg { width: 12px; height: 12px; }
  .week-nav-btn { width: 20px; font-size: 10px; border-radius: 8px; }
  .timetable-wrapper { gap: 4px; }
  .pro-gate { margin: 12px 8px; padding: 24px 16px; border-radius: 24px; }
  .gate-title { font-size: 1rem; }
  .gate-subtitle { font-size: 0.85rem; }
  body { padding: 12px; }
  .notes-sidebar.card { padding: 0.75rem; }
  .card { padding: 0.85rem; border-radius: 24px; margin-bottom: 1rem; width: 100%; }
  .notes-sidebar { width: 100%; }
  .notes-sidebar-head { width: 100%; }
  .notes-panel { width: 100%; }
  .day-header-tabs { width: 100%; }
  .day-tab-btn { flex: 1 1 auto; text-align: center; }
  .btn { font-size: 12px; padding: 8px 12px; border-radius: 12px; }
  h1 { font-size: 18px; margin-bottom: 10px; }
  h2 { font-size: 1rem; }
  #profileRow { padding: 8px 14px; border-radius: 24px; gap: 8px; }
  #profileRow .btn { padding: 5px 10px; font-size: 11px; }
  .header-action-bar { gap: 8px; }
  .header-actions-group { gap: 6px; }
  .header-actions-group .btn { padding: 5px 10px; }
  .control-panel-header { flex-wrap: wrap; }
  .control-panel-header .cp-title { font-size: 0.9rem; }
  .cp-toggle { font-size: 12px; padding: 6px 12px; }
  .controls-row { gap: 0.75rem; }
  .input-group { flex: 1 1 100%; min-width: 0; }
  .quick-jump-group { flex: 1 1 100%; }
  .quick-jump-input { flex-wrap: wrap; }
  .quick-jump-input input { max-width: 100%; flex: 1; }
  .notes-sidebar { position: static; max-height: none; }
  .notes-panel { max-height: 300px; }
  .day-tab-btn { font-size: 10px; padding: 5px 8px; }
  .note-item { padding: 8px; border-radius: 12px; }
  .note-head { font-size: 11px; }
  .note-text { font-size: 12px; }
  .modal-content { padding: 16px; border-radius: 24px; max-width: 100%; margin: 8px; }
  .modal-close-btn { font-size: 14px; padding: 6px 10px; }
  #teacherNoteText, #technicianOrderText { min-height: 80px; }
  .modal-footer { gap: 6px; margin-top: 14px; }
  .modal-form-group { margin-bottom: 12px; }
  .export-modal-content { padding: 12px; }
  .status-bar { gap: 8px; margin-top: 0.5rem; padding-top: 0.75rem; }
  #weekRangeDisplay { font-size: 1rem; }
  #status { font-size: 12px; }
  .copy-similar-list { padding: 6px; }
  .copy-similar-item { padding: 8px 6px; }
  .sidebar-show-btn { min-height: 90px; font-size: 11px !important; padding: 10px 6px !important; }
  .chatbox-container { padding: 0.75rem; }
  .chatbox-title { font-size: 0.9rem; }
  .chatbox-header-controls { gap: 6px; }
  .chat-date-range input[type="date"] { max-width: 100px; font-size: 10px; padding: 4px 6px; }
  .chat-popup-btn { font-size: 11px !important; padding: 5px 10px !important; }
  .chat-messages { max-height: 250px; min-height: 80px; padding: 8px; }
  .chat-msg { font-size: 12px; padding: 8px 10px; max-width: 92%; }
  .chat-input-area textarea { min-height: 36px; padding: 8px 10px; font-size: 12px; }
  .chat-input-area .btn { padding: 8px 14px; font-size: 12px; }
  .chat-popup-content { padding: 16px; }
  .layout.sidebar-collapsed .timetable-grid {
    grid-template-columns: 70px repeat(5, minmax(100px, 1fr));
  }
}

/* Small phone (< 480px): minimal layout */
@media (max-width: 480px) {
  body { padding: 8px; }
  .card { padding: 0.65rem; border-radius: 20px; margin-bottom: 0.75rem; }
  .timetable-grid {
    grid-template-columns: 55px repeat(5, minmax(80px, 1fr));
    gap: 4px;
  }
  .grid-header { font-size: 9px; padding: 6px 3px; border-radius: 10px; }
  .time-label { font-size: 9px; padding: 3px; border-radius: 10px; }
  .time-label .period-id { font-size: 8px; }
  .lesson-slot { min-height: 48px; padding: 3px; border-radius: 10px; }
  .lesson-title { font-size: 10px; }
  .lesson-meta { font-size: 8px; }
  .note-badge { font-size: 7px; padding: 1px 4px; top: 3px; right: 3px; }
  .order-badge { width: 16px; height: 16px; font-size: 9px; bottom: 3px; right: 3px; }
  .lesson-class-link { width: 18px; height: 18px; bottom: 3px; right: 3px; border-radius: 6px; }
  .lesson-class-link svg { width: 10px; height: 10px; }
  .week-nav-btn { width: 18px; font-size: 9px; border-radius: 6px; }
  .timetable-wrapper { gap: 3px; }
  .btn { font-size: 11px; padding: 6px 10px; border-radius: 10px; }
  h1 { font-size: 16px; }
  h2 { font-size: 0.9rem; }
  .pro-gate { margin: 8px 4px; padding: 20px 12px; border-radius: 20px; }
  .gate-title { font-size: 0.9rem; }
  .gate-subtitle { font-size: 0.8rem; }
  .gate-logo { width: 48px; height: 48px; font-size: 16px; }
  #profileRow { padding: 6px 10px; border-radius: 20px; gap: 6px; }
  #profileRow .btn { padding: 4px 8px; font-size: 10px; }
  .layout.sidebar-collapsed .timetable-grid {
    grid-template-columns: 55px repeat(5, minmax(80px, 1fr));
  }
  .chat-messages { max-height: 200px; }
  .chat-date-range input[type="date"] { max-width: 85px; }
}

/* ========== AI Action Cards ========== */

.chat-action-card {
  align-self: flex-start;
  max-width: 92%;
  margin: 4px 0 4px 8px;
  background: var(--bg);
  border: 2px dashed var(--accent-secondary);
  border-radius: 16px;
  box-shadow: var(--shadow-ext-sm);
  padding: 12px 14px;
  animation: chatFadeIn 0.25s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-action-card .action-card-header {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  font-size: 12px;
  color: var(--accent-secondary);
  letter-spacing: 0.02em;
}

.chat-action-card .action-card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-action-card .action-description {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  line-height: 1.4;
}

.chat-action-card .action-detail {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 12px;
  box-shadow: var(--shadow-inset-sm);
}

.chat-action-card .action-confirm {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

.chat-action-card .action-card-buttons {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.chat-action-card .action-btn {
  flex: 1;
  font-size: 13px;
  padding: 8px 14px;
  text-align: center;
  cursor: pointer;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  font-family: 'DM Sans', sans-serif;
  transition: box-shadow 0.2s ease;
}

.chat-action-card .action-btn.apply {
  background: var(--accent-secondary);
  color: #fff;
  box-shadow: 4px 4px 8px rgb(163,177,198,0.5), -4px -4px 8px rgba(255,255,255,0.4);
}
.chat-action-card .action-btn.apply:hover {
  box-shadow: 6px 6px 12px rgb(163,177,198,0.6), -6px -6px 12px rgba(255,255,255,0.5);
}
.chat-action-card .action-btn.apply:active {
  box-shadow: var(--shadow-inset-sm);
}

.chat-action-card .action-btn.ignore {
  background: var(--bg);
  color: var(--muted);
  box-shadow: var(--shadow-ext-sm);
}
.chat-action-card .action-btn.ignore:hover {
  box-shadow: var(--shadow-ext-hover);
  color: var(--danger);
}
.chat-action-card .action-btn.ignore:active {
  box-shadow: var(--shadow-inset-sm);
}

/* Action done states */
.chat-action-card.action-done .action-card-buttons {
  display: flex;
  align-items: center;
}
.chat-action-card.action-done .action-card-buttons .action-result {
  flex: 1;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}
.chat-action-card.action-success {
  border-color: var(--accent-secondary);
  background: color-mix(in oklab, var(--accent-secondary) 8%, var(--bg));
}
.chat-action-card.action-success .action-result.success {
  color: var(--accent-secondary);
}
.chat-action-card.action-failed {
  border-color: var(--danger);
  background: color-mix(in oklab, var(--danger) 8%, var(--bg));
}
.chat-action-card.action-failed .action-result.failed {
  color: var(--danger);
}
.chat-action-card.action-ignored {
  border-color: var(--muted-light);
  opacity: 0.6;
}
.chat-action-card.action-ignored .action-result.ignored {
  color: var(--muted-light);
}

/* ========== Mobile Day View ========== */

.timetable-grid.day-view {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
  /* Allow vertical scroll but let our JS handle horizontal swipes */
  touch-action: pan-y pinch-zoom;
}

.day-view-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow-ext-sm);
  margin-bottom: 8px;
}
.day-view-header .dv-date {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: var(--fg);
}

.dv-slot {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  margin-bottom: 6px;
  background: var(--bg);
  border-radius: 18px;
  box-shadow: var(--shadow-ext-sm);
  border-left: 4px solid var(--border);
  transition: box-shadow 0.2s ease;
}
.dv-slot.past {
  opacity: 0.55;
}
.dv-slot.scheduled {
  border-left-color: var(--accent);
}
.dv-slot.current {
  box-shadow: var(--shadow-ext-sm), 0 0 0 3px var(--warning);
  background: color-mix(in oklab, var(--warning) 12%, var(--bg));
  border-left-color: var(--warning);
}
.dv-slot.empty {
  border-left-color: var(--border);
  border-style: dashed;
}

.dv-period-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 8px;
}
.dv-period-time {
  font-weight: 500;
  font-size: 11px;
  color: var(--muted);
}

.dv-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--fg);
  line-height: 1.3;
}
.dv-meta {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  align-items: center;
}
.dv-link {
  color: var(--accent);
  text-decoration: underline;
  font-weight: 600;
}
.dv-email {
  color: var(--muted);
  font-size: 11px;
}

.dv-note-section {
  margin-top: 6px;
  font-size: 13px;
  color: var(--fg);
  line-height: 1.5;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 12px;
  box-shadow: var(--shadow-inset-sm);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.dv-note-section strong {
  color: var(--accent-secondary);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.dv-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.dv-edit-btn {
  font-size: 12px !important;
  padding: 6px 12px !important;
  border-radius: 10px !important;
  font-weight: 600 !important;
}

.dv-no-class {
  font-size: 13px;
  color: var(--muted-light);
  font-weight: 500;
}
.dv-empty {
  padding: 24px 16px;
  text-align: center;
  font-size: 15px;
  color: var(--muted);
  background: var(--bg);
  border-radius: 18px;
  box-shadow: var(--shadow-ext-sm);
}
.dv-order-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--success);
}
.day-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
}
.day-badge.holiday-badge {
  background: color-mix(in oklab, var(--danger) 25%, var(--bg));
  color: var(--danger);
}
.day-badge.event-badge {
  background: color-mix(in oklab, var(--accent-secondary) 25%, var(--bg));
  color: var(--accent-secondary);
}

.view-mode-toggle {
  display: none;
  width: 100%;
  margin-bottom: 8px;
  font-size: 13px !important;
  padding: 8px 14px !important;
  border-radius: 14px !important;
  font-weight: 700 !important;
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-ext-sm);
}
@media (max-width: 768px) {
  .view-mode-toggle {
    display: block;
  }
}

/* Hide week grid by default on mobile, show day view */
@media (max-width: 768px) {
  .timetable-grid:not(.day-view) {
    display: grid;
  }
  .notes-sidebar {
    display: none !important;
  }
  .sidebar-show-btn {
    display: none !important;
  }
}

/* ========== @Mention Autocomplete Dropdown ========== */

.at-mention-dropdown {
  position: absolute;
  left: 0;
  z-index: 100;
  background: var(--bg);
  border-radius: 14px;
  box-shadow: var(--shadow-ext);
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 2px;
  max-height: 200px;
  overflow-y: auto;
  min-width: 240px;
}
.at-mention-dropdown.open {
  display: flex;
}
.mention-item {
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--fg);
  transition: background 0.15s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}
.mention-item:hover,
.mention-item.selected {
  background: var(--bg);
  box-shadow: var(--shadow-inset-sm);
  color: var(--accent);
}
.mention-email {
  font-weight: 600;
  font-size: 13px;
}

/* ========== Slash Command Dropdown ========== */

.teacher-id-dropdown {
  position: absolute;
  left: 0;
  z-index: 100;
  background: var(--bg);
  border-radius: 14px;
  box-shadow: var(--shadow-ext);
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 2px;
  max-height: 180px;
  overflow-y: auto;
  min-width: 100%;
  top: 100%;
  margin-top: 4px;
}
.teacher-id-dropdown.open {
  display: flex;
}
.teacher-id-item {
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--fg);
  transition: background 0.15s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}
.teacher-id-item:hover,
.teacher-id-item.selected {
  background: var(--bg);
  box-shadow: var(--shadow-inset-sm);
  color: var(--accent);
}

.slash-dropdown {
  position: absolute;
  left: 0;
  z-index: 100;
  background: var(--bg);
  border-radius: 14px;
  box-shadow: var(--shadow-ext);
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 2px;
  max-height: 200px;
  overflow-y: auto;
  min-width: 280px;
}
.slash-dropdown.open {
  display: flex;
}
.slash-item {
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--fg);
  transition: background 0.15s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}
.slash-item:hover,
.slash-item.selected {
  background: var(--bg);
  box-shadow: var(--shadow-inset-sm);
  color: var(--accent);
}
.slash-cmd {
  font-weight: 700;
  font-size: 14px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  color: var(--accent-secondary);
  min-width: 60px;
}
.slash-desc {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

/* ========== Class & Unit Mention Dropdowns ========== */

.class-mention-dropdown,
.unit-mention-dropdown {
  position: absolute;
  left: 0;
  z-index: 200;
  background: var(--bg);
  border-radius: 14px;
  box-shadow: var(--shadow-ext);
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 2px;
  max-height: 200px;
  overflow-y: auto;
  min-width: 260px;
}
.class-mention-dropdown.open,
.unit-mention-dropdown.open {
  display: flex;
}
.class-item,
.unit-item {
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--fg);
  transition: background 0.15s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}
.class-item:hover,
.class-item.selected,
.unit-item:hover,
.unit-item.selected {
  background: var(--bg);
  box-shadow: var(--shadow-inset-sm);
  color: var(--accent);
}
.class-code {
  font-weight: 700;
  font-size: 13px;
  font-family: 'Plus Jakarta Sans', sans-serif;
}
.class-desc {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}
.unit-name {
  font-weight: 600;
  font-size: 13px;
}

/* ========== Enhanced Lesson Plan Action Card ========== */

.chat-action-card.lesson-plan .action-plan-unit {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 4px;
}
.chat-action-card.lesson-plan .action-plan-topic {
  font-size: 13px;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 2px;
}
.chat-action-card.lesson-plan .action-plan-lesson {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 12px;
  box-shadow: var(--shadow-inset-sm);
  margin-top: 6px;
}
.chat-action-card.lesson-plan .action-plan-technician {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 12px;
  box-shadow: var(--shadow-inset-sm);
  margin-top: 4px;
  border-left: 3px solid var(--accent-secondary);
}
.chat-action-card.lesson-plan .action-plan-technician::before {
  content: "🔧 Technician: ";
  font-weight: 600;
  color: var(--accent-secondary);
  font-size: 11px;
  display: block;
  margin-bottom: 2px;
}
.chat-action-card.lesson-plan .action-plan-lesson::before {
  content: "📝 Lesson: ";
  font-weight: 600;
  color: var(--accent);
  font-size: 11px;
  display: block;
  margin-bottom: 2px;
}
