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

:root {
  --bg:       #080808;
  --fg:       #c8c8c8;
  --fg-dim:   #3a3a3a;
  --red:      #ff3b3b;
  --red-a:    rgba(255, 59, 59, 0.15);

  --c-el:   #4fc3f7;
  --c-math: #ff8a65;
  --c-sci:  #81c784;
  --c-hum:  #ce93d8;
  --c-mt:   #fff176;
  --c-sw:   #ef5350;
  --c-cce:  #b0bec5;
  --c-hsl:  #80cbc4;
  --c-hbl:  #ffb74d;
  --c-cm:   #f48fb1;
  --c-admt: #ff8fab;
  --c-ict:  #80deea;
}

html, body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'Space Mono', monospace;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ── Scanlines ─────────────────────────────────────────────── */
.scanlines {
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0,0,0,0.08) 3px,
    rgba(0,0,0,0.08) 4px
  );
  pointer-events: none;
  z-index: 999;
}

/* ── Topbar ────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 10px;
  flex-shrink: 0;
  gap: 8px;
  flex-wrap: wrap;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.topbar-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.title {
  font-family: 'VT323', monospace;
  font-size: 2.8rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  color: #fff;
  line-height: 1;
}

.cursor {
  display: inline-block;
  color: var(--red);
  font-size: 2.2rem;
  margin-left: 2px;
  animation: blink 1.1s step-end infinite;
  vertical-align: baseline;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.today-pill {
  font-family: 'Space Mono', monospace;
  font-size: 0.7rem;
  color: rgba(255,255,255,0.2);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  line-height: 1;
}

.term-pill {
  font-family: 'Space Mono', monospace;
  font-size: 0.68rem;
  color: rgba(255,59,59,0.55);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: 1px solid rgba(255,59,59,0.2);
  border-radius: 4px;
  padding: 1px 6px;
  line-height: 1.5;
}

/* ── Toggle ────────────────────────────────────────────────── */
.tog-group {
  display: flex;
  position: relative;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 999px;
  padding: 3px;
  overflow: hidden;
}

.tog-pill {
  position: absolute;
  top: 3px;
  bottom: 3px;
  border-radius: 999px;
  background: rgba(255,255,255,0.10);
  transition: left .28s cubic-bezier(.4,0,.2,1), width .28s cubic-bezier(.4,0,.2,1);
  pointer-events: none;
}

.tog-btn {
  font-family: 'VT323', monospace;
  font-size: 1.4rem;
  letter-spacing: 0.1em;
  padding: 4px 18px;
  background: none;
  border: none;
  color: rgba(255,255,255,0.25);
  cursor: pointer;
  transition: color .25s;
  position: relative;
  z-index: 1;
  border-radius: 999px;
  line-height: 1.3;
}

.tog-btn.active { color: #fff; }

/* ── Now bar ───────────────────────────────────────────────── */
.now-bar {
  align-items: center;
  gap: 8px;
  padding: 5px 14px 5px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  flex-shrink: 0;
}

.now-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
  flex-shrink: 0;
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 var(--red-a); }
  50%       { opacity: 0.75; box-shadow: 0 0 6px 4px var(--red-a); }
}

.now-label {
  font-family: 'Space Mono', monospace;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.2);
  letter-spacing: 0.12em;
  flex-shrink: 0;
}

.now-subject {
  font-family: 'VT323', monospace;
  font-size: 1.6rem;
  letter-spacing: 0.1em;
  color: #fff;
  text-transform: uppercase;
}

/* ── Table wrap ────────────────────────────────────────────── */
.table-wrap {
  flex: 1;
  min-height: 0;
  overflow-x: auto;
  overflow-y: visible;
  padding: 10px 14px 20px;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

/* ── Table ─────────────────────────────────────────────────── */
.tt-table {
  border-collapse: separate;
  border-spacing: 3px;
  table-layout: fixed;
  min-width: 900px;
  width: 100%;
  transition: opacity .2s ease;
}

.tt-table.hidden {
  opacity: 0;
  pointer-events: none;
  position: absolute;
  top: 0; left: 0; right: 0;
}

/* ── Thead ──────────────────────────────────────────────────── */
.th-day {
  width: 46px;
  background: transparent;
}

.th-time {
  font-family: 'Space Mono', monospace;
  font-size: 0.65rem;
  font-weight: 400;
  color: rgba(255,255,255,0.35);
  padding: 6px 2px;
  text-align: center;
  background: rgba(255,255,255,0.03);
  border-radius: 3px;
  letter-spacing: -0.02em;
  line-height: 1.6;
}

/* ── Cells ──────────────────────────────────────────────────── */
td {
  padding: 3px;
  height: 64px;
  vertical-align: stretch;
}

.td-day {
  font-family: 'VT323', monospace;
  font-size: 1.35rem;
  color: rgba(200,200,200,0.4);
  text-align: center;
  vertical-align: middle;
  padding: 3px;
  letter-spacing: 0.04em;
  position: sticky;
  left: 0;
  background: var(--bg);
  z-index: 2;
  transition: color .2s;
}

tr.today-row .td-day {
  color: #fff;
  text-shadow: 0 0 10px rgba(255,59,59,0.4);
}

.cell {
  height: 58px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2px 4px;
  overflow: hidden;
  position: relative;
  border-left: 4px solid transparent;
  background: rgba(255,255,255,0.025);
  transition: filter .15s ease, background .15s ease, box-shadow .15s ease;
}

.cell .subj {
  font-family: 'VT323', monospace;
  font-size: 1.15rem;
  letter-spacing: 0.07em;
  line-height: 1;
  text-transform: uppercase;
  color: rgba(180,180,180,0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ── Subject colours ────────────────────────────────────────── */
.cell.el   { border-left-color: var(--c-el);   background: rgba(79,  195, 247, 0.06); }
.cell.el   .subj { color: var(--c-el); }

.cell.math { border-left-color: var(--c-math); background: rgba(255, 138, 101, 0.06); }
.cell.math .subj { color: var(--c-math); }

.cell.sci  { border-left-color: var(--c-sci);  background: rgba(129, 199, 132, 0.06); }
.cell.sci  .subj { color: var(--c-sci); }

.cell.hum  { border-left-color: var(--c-hum);  background: rgba(206, 147, 216, 0.06); }
.cell.hum  .subj { color: var(--c-hum); }

.cell.mt   { border-left-color: var(--c-mt);   background: rgba(255, 241, 118, 0.05); }
.cell.mt   .subj { color: var(--c-mt); }

.cell.sw   { border-left-color: var(--c-sw);   background: rgba(239,  83,  80, 0.06); }
.cell.sw   .subj { color: var(--c-sw); }

.cell.cce  { border-left-color: var(--c-cce);  background: rgba(176, 190, 197, 0.05); }
.cell.cce  .subj { color: var(--c-cce); }

.cell.hsl  { border-left-color: var(--c-hsl);  background: rgba(128, 203, 196, 0.06); }
.cell.hsl  .subj { color: var(--c-hsl); }

.cell.hbl  { border-left-color: var(--c-hbl);  background: rgba(255, 183,  77, 0.06); }
.cell.hbl  .subj { color: var(--c-hbl); }

.cell.cm   { border-left-color: var(--c-cm);   background: rgba(244, 143, 177, 0.06); }
.cell.cm   .subj { color: var(--c-cm); }

.cell.admt { border-left-color: var(--c-admt); background: rgba(255, 143, 171, 0.06); }
.cell.admt .subj { color: var(--c-admt); }

.cell.ict  { border-left-color: var(--c-ict);  background: rgba(128, 222, 234, 0.06); }
.cell.ict  .subj { color: var(--c-ict); }

.cell.brk {
  border-left: none;
  background: rgba(255,255,255,0.015);
}
.cell.brk .subj { color: rgba(255,255,255,0.15); font-size: 0.9rem; }

.cell.empty {
  border-left: none;
  background: transparent;
}

/* ── Today row ──────────────────────────────────────────────── */
tr.today-row td .cell:not(.empty) {
  box-shadow: inset 0 0 0 1px rgba(255,59,59,0.1);
}

/* ── Active (now) cell ──────────────────────────────────────── */
.cell.now {
  filter: brightness(1.3);
  box-shadow: inset 0 0 0 1px rgba(255,59,59,0.35) !important;
}
.cell.now .subj { color: #fff !important; }

/* ── Period progress bar ────────────────────────────────────── */
.cell .period-bar {
  position: absolute;
  bottom: 0; left: 0;
  height: 2px;
  width: 0;
  background: var(--red);
  transition: width 0.8s linear;
  border-radius: 0 1px 1px 0;
  pointer-events: none;
}

/* ── Time line ──────────────────────────────────────────────── */
.time-line {
  position: absolute;
  width: 2px;
  background: var(--red);
  pointer-events: none;
  z-index: 10;
  box-shadow: 0 0 8px 1px rgba(255,59,59,0.35);
}

.time-line::before {
  content: '';
  position: absolute;
  top: -5px;
  left: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 10px 3px rgba(255,59,59,0.5);
}

/* ── Footer ─────────────────────────────────────────────────── */
.bottom {
  text-align: center;
  font-family: 'Space Mono', monospace;
  font-size: 0.65rem;
  color: rgba(255,255,255,0.07);
  padding: 10px;
  flex-shrink: 0;
  letter-spacing: 0.18em;
}

/* ── Topbar right layout ────────────────────────────────────── */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── CLR (colour customiser) button ─────────────────────────── */
.clr-btn {
  font-family: 'VT323', monospace;
  font-size: 1.4rem;
  letter-spacing: 0.1em;
  padding: 4px 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 999px;
  color: rgba(255,255,255,0.3);
  cursor: pointer;
  transition: color .2s, border-color .2s;
  flex-shrink: 0;
  line-height: 1.3;
}
.clr-btn:hover { color: #fff; border-color: rgba(255,255,255,0.2); }

/* ── Now-bar countdown ──────────────────────────────────────── */
.now-countdown {
  font-family: 'Space Mono', monospace;
  font-size: 0.7rem;
  color: rgba(255,255,255,0.2);
  letter-spacing: 0.08em;
  flex-shrink: 0;
  margin-left: auto;
}

/* ── Upcoming bar ───────────────────────────────────────────── */
.upcoming-bar {
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  flex-shrink: 0;
}

.upcoming-label {
  font-family: 'Space Mono', monospace;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.15);
  letter-spacing: 0.12em;
  flex-shrink: 0;
}

.upcoming-day {
  font-family: 'VT323', monospace;
  font-size: 1.5rem;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
}

.upcoming-detail {
  font-family: 'Space Mono', monospace;
  font-size: 0.68rem;
  color: rgba(255,255,255,0.2);
  letter-spacing: 0.05em;
  margin-left: auto;
  text-align: right;
}

.upcoming-detail.has-sw { color: rgba(255,59,59,0.65); }

/* ── Next bar ───────────────────────────────────────────────── */
.next-bar {
  align-items: center;
  gap: 8px;
  padding: 4px 14px 5px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  flex-shrink: 0;
}

.next-label {
  font-family: 'Space Mono', monospace;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.15);
  letter-spacing: 0.12em;
  flex-shrink: 0;
}

.next-subject {
  font-family: 'VT323', monospace;
  font-size: 1.5rem;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.45);
  text-transform: uppercase;
}

.next-time {
  font-family: 'Space Mono', monospace;
  font-size: 0.7rem;
  color: rgba(255,255,255,0.2);
  letter-spacing: 0.06em;
  margin-left: auto;
}

/* ── Theme overlay ──────────────────────────────────────────── */
.theme-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s;
  z-index: 100;
}
.theme-overlay.open {
  opacity: 1;
  pointer-events: all;
}

/* ── Theme panel (bottom sheet) ─────────────────────────────── */
.theme-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #0e0e0e;
  border-top: 1px solid rgba(255,255,255,0.08);
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  z-index: 101;
  max-height: 75vh;
  overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom);
}
.theme-panel.open { transform: translateY(0); }

.theme-inner { padding: 16px 20px 20px; }

.theme-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.theme-title {
  font-family: 'VT323', monospace;
  font-size: 1.6rem;
  letter-spacing: 0.15em;
  color: rgba(255,255,255,0.6);
}

.theme-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.3);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
  transition: color .2s;
}
.theme-close:hover { color: #fff; }

/* ── Theme colour grid ──────────────────────────────────────── */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px 16px;
  margin-bottom: 20px;
}

.theme-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
}

.theme-var-name {
  font-family: 'VT323', monospace;
  font-size: 1.15rem;
  letter-spacing: 0.06em;
  color: rgba(200,200,200,0.55);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.theme-color-input {
  width: 32px;
  height: 22px;
  padding: 0;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 4px;
  cursor: pointer;
  background: none;
  flex-shrink: 0;
}
.theme-color-input::-webkit-color-swatch-wrapper { padding: 2px; }
.theme-color-input::-webkit-color-swatch { border: none; border-radius: 2px; }

/* ── Theme action buttons ───────────────────────────────────── */
.theme-actions {
  display: flex;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.theme-btn {
  font-family: 'VT323', monospace;
  font-size: 1.3rem;
  letter-spacing: 0.1em;
  padding: 6px 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  color: rgba(255,255,255,0.45);
  cursor: pointer;
  transition: color .2s, background .2s;
  flex: 1;
  text-align: center;
}
.theme-btn:hover { color: #fff; background: rgba(255,255,255,0.08); }
.theme-btn.confirm {
  color: #fff;
  background: rgba(255,59,59,0.12);
  border-color: rgba(255,59,59,0.3);
}

/* ── Settings sections ──────────────────────────────────────── */
.settings-section {
  margin-bottom: 20px;
}

.settings-section-hd {
  font-family: 'Space Mono', monospace;
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  color: rgba(255,255,255,0.18);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

/* ── Demo banner ─────────────────────────────────────────────── */
.demo-banner {
  align-items: center;
  gap: 10px;
  padding: 4px 14px;
  background: rgba(255,59,59,0.07);
  border-bottom: 1px solid rgba(255,59,59,0.14);
  flex-shrink: 0;
}

.demo-badge {
  font-family: 'VT323', monospace;
  font-size: 1.1rem;
  letter-spacing: 0.12em;
  color: var(--red);
  flex-shrink: 0;
}

.demo-banner-info {
  font-family: 'Space Mono', monospace;
  font-size: 0.68rem;
  color: rgba(255,59,59,0.65);
  letter-spacing: 0.1em;
}

/* ── Demo toggle ─────────────────────────────────────────────── */
.demo-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 4px 0 12px;
  gap: 12px;
}

.demo-toggle-label {
  font-family: 'VT323', monospace;
  font-size: 1.15rem;
  letter-spacing: 0.06em;
  color: rgba(200,200,200,0.55);
}

.toggle-wrap {
  position: relative;
  flex-shrink: 0;
}
.toggle-wrap input[type=checkbox] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-track {
  display: block;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  position: relative;
  transition: background .25s, border-color .25s;
  cursor: pointer;
}
.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
  transition: transform .25s, background .25s;
}
.toggle-wrap input:checked + .toggle-track {
  background: rgba(255,59,59,0.25);
  border-color: rgba(255,59,59,0.45);
}
.toggle-wrap input:checked + .toggle-track .toggle-thumb {
  transform: translateX(18px);
  background: var(--red);
}

/* ── Demo controls ───────────────────────────────────────────── */
.demo-controls {
  padding-top: 2px;
}

.demo-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.demo-label {
  font-family: 'Space Mono', monospace;
  font-size: 0.62rem;
  letter-spacing: 0.15em;
  color: rgba(255,255,255,0.2);
  width: 36px;
  flex-shrink: 0;
}

.demo-chip-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.demo-chip {
  font-family: 'VT323', monospace;
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  padding: 3px 10px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 4px;
  color: rgba(255,255,255,0.3);
  cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
}
.demo-chip:hover { color: rgba(255,255,255,0.65); }
.demo-chip.active {
  color: #fff;
  background: rgba(255,59,59,0.1);
  border-color: rgba(255,59,59,0.35);
}

.demo-time {
  font-family: 'Space Mono', monospace;
  font-size: 0.75rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 4px;
  color: rgba(255,255,255,0.7);
  padding: 4px 8px;
  letter-spacing: 0.05em;
}
.demo-time:focus {
  outline: 1px solid rgba(255,59,59,0.35);
  border-color: rgba(255,59,59,0.25);
}
.demo-time::-webkit-calendar-picker-indicator {
  filter: invert(0.6);
  cursor: pointer;
}

/* ── Compact mode ────────────────────────────────────────────── */
body.compact td      { height: 40px; }
body.compact .cell   { height: 34px; }
body.compact .cell .subj { font-size: 0.95rem; }

/* ── Notification settings ───────────────────────────────────── */
.notif-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
}

.notif-time-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0 4px;
  margin-top: 4px;
}

.notif-btn { flex: 0 0 auto; min-width: 90px; }

/* ── B2: School-ends label ───────────────────────────────────── */
.now-ends {
  font-family: 'Space Mono', monospace;
  font-size: 0.62rem;
  color: rgba(255,255,255,0.1);
  letter-spacing: 0.06em;
  flex-shrink: 0;
}

/* ── B4: Duration label in cells ─────────────────────────────── */
.cell .dur {
  font-family: 'Space Mono', monospace;
  font-size: 0.5rem;
  color: rgba(255,255,255,0.15);
  letter-spacing: 0.03em;
  display: block;
  margin-top: 1px;
  line-height: 1;
}

/* ── B7: Note dot ────────────────────────────────────────────── */
.cell.has-note::after {
  content: '';
  position: absolute;
  top: 4px;
  right: 5px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255,59,59,0.75);
  box-shadow: 0 0 4px rgba(255,59,59,0.4);
}

/* ── B7: Note modal ──────────────────────────────────────────── */
.note-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 200;
}
.note-modal {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: #0e0e0e;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 20px;
  width: 90%;
  max-width: 340px;
  z-index: 201;
}
.note-modal-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.note-modal-title {
  font-family: 'VT323', monospace;
  font-size: 1.35rem;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.55);
  text-transform: uppercase;
}
.note-input {
  display: block;
  width: 100%;
  font-family: 'Space Mono', monospace;
  font-size: 0.78rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 5px;
  color: rgba(255,255,255,0.8);
  padding: 8px 10px;
  margin-bottom: 14px;
  letter-spacing: 0.04em;
}
.note-input:focus {
  outline: 1px solid rgba(255,59,59,0.35);
  border-color: rgba(255,59,59,0.25);
}
.note-actions { display: flex; gap: 8px; }

/* ── B8: Exam countdown bar ──────────────────────────────────── */
.exam-bar {
  align-items: center;
  gap: 8px;
  padding: 4px 14px;
  background: rgba(255,183,77,0.05);
  border-bottom: 1px solid rgba(255,183,77,0.12);
  flex-shrink: 0;
}
.exam-icon { font-size: 0.9rem; flex-shrink: 0; }
.exam-text {
  font-family: 'Space Mono', monospace;
  font-size: 0.65rem;
  color: rgba(255,183,77,0.75);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ── B9: Print mode ──────────────────────────────────────────── */
@media print {
  .scanlines, .topbar-right, .now-bar, .next-bar, .upcoming-bar,
  .exam-bar, .bring-bar, .sw-update-bar, .demo-banner, .time-line,
  .theme-overlay, .theme-panel, .note-overlay, .note-modal, .bottom,
  .offlineBadge { display: none !important; }
  .topbar { border-bottom: 1px solid #ccc; }
  body { background: #fff; color: #000; min-height: unset; }
  .tt-table.hidden { display: none !important; position: static; }
  .td-day { background: #fff !important; color: #333 !important; }
  .cell .subj { color: #111 !important; }
  .cell { border-left-width: 3px; background: rgba(0,0,0,0.04) !important; }
}

/* ── B11: Bring-today bar ────────────────────────────────────── */
.bring-bar {
  align-items: center;
  gap: 10px;
  padding: 4px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  flex-shrink: 0;
}
.bring-label {
  font-family: 'Space Mono', monospace;
  font-size: 0.6rem;
  color: rgba(255,255,255,0.1);
  letter-spacing: 0.15em;
  flex-shrink: 0;
}
.bring-subjects {
  font-family: 'VT323', monospace;
  font-size: 1.2rem;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.28);
  text-transform: uppercase;
}

/* ── B12: Offline badge ──────────────────────────────────────── */
.offline-badge {
  font-family: 'Space Mono', monospace;
  font-size: 0.58rem;
  color: rgba(255,183,77,0.9);
  letter-spacing: 0.1em;
  border: 1px solid rgba(255,183,77,0.3);
  border-radius: 4px;
  padding: 2px 6px;
  flex-shrink: 0;
  animation: pulse 1.8s ease-in-out infinite;
}

/* ── B14: Stats grid ─────────────────────────────────────────── */
.stats-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding-top: 2px;
}
.stats-chip {
  font-family: 'VT323', monospace;
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  padding: 1px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.02);
}

/* ── B15: Absent day ─────────────────────────────────────────── */
tr.day-absent .td-day {
  opacity: 0.25;
  text-decoration: line-through;
}
tr.day-absent td .cell:not(.empty) {
  opacity: 0.15;
  filter: grayscale(1);
}

/* ── B16: SW update bar ──────────────────────────────────────── */
.sw-update-bar {
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 14px;
  background: rgba(79,195,247,0.05);
  border-bottom: 1px solid rgba(79,195,247,0.14);
  flex-shrink: 0;
}
.sw-update-bar span {
  font-family: 'Space Mono', monospace;
  font-size: 0.65rem;
  color: rgba(79,195,247,0.75);
  letter-spacing: 0.1em;
}
.sw-refresh-btn {
  font-family: 'VT323', monospace;
  font-size: 1.15rem;
  letter-spacing: 0.08em;
  padding: 2px 12px;
  background: rgba(79,195,247,0.08);
  border: 1px solid rgba(79,195,247,0.25);
  border-radius: 5px;
  color: rgba(79,195,247,0.85);
  cursor: pointer;
  flex-shrink: 0;
  transition: background .2s;
}
.sw-refresh-btn:hover { background: rgba(79,195,247,0.16); }

/* ── Break pill ──────────────────────────────────────────────── */
.break-pill {
  font-family: 'Space Mono', monospace;
  font-size: 0.68rem;
  color: rgba(255, 183, 77, 0.75);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: 1px solid rgba(255, 183, 77, 0.25);
  border-radius: 4px;
  padding: 1px 6px;
  line-height: 1.5;
}

/* ── Homework tracker ────────────────────────────────────────── */
#btnTheme { position: relative; }
#btnTheme.has-hw::after {
  content: attr(data-hw-count);
  position: absolute; top: -4px; right: -4px;
  background: var(--red); color: #fff;
  font-family: 'Space Mono', monospace;
  font-size: 0.55rem; line-height: 1;
  padding: 2px 4px; border-radius: 8px;
  min-width: 14px; text-align: center;
}

.hw-subj {
  border-left: 2px solid;
  padding: 6px 0 6px 10px;
  margin-bottom: 10px;
}
.hw-subj-hd {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  opacity: 0.5;
  margin-bottom: 6px;
}
.hw-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  cursor: pointer;
}
.hw-item input[type=checkbox] { accent-color: var(--red); flex-shrink: 0; }
.hw-text { flex: 1; font-size: 0.8rem; font-family: 'Space Mono', monospace; }
.hw-done .hw-text { opacity: 0.35; text-decoration: line-through; }
.hw-del {
  background: none; border: none;
  color: rgba(255,255,255,0.2);
  cursor: pointer; font-size: 0.8rem;
  padding: 0 4px;
}
.hw-del:hover { color: var(--red); }
.hw-add-row { display: flex; gap: 6px; margin-top: 6px; }
.hw-input {
  flex: 1;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--fg);
  font-family: 'Space Mono', monospace;
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: 4px;
  outline: none;
}
.hw-input:focus { border-color: rgba(255,255,255,0.25); }
.hw-add-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--fg);
  font-size: 1rem;
  padding: 2px 10px;
  cursor: pointer;
  border-radius: 4px;
}
.hw-add-btn:hover { background: rgba(255,255,255,0.12); }

/* ── Announcement toast ──────────────────────────────────────── */
.annc-toast {
  position: fixed;
  top: 16px; right: 16px;
  z-index: 2000;
  background: #111;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  min-width: 220px; max-width: 320px;
  display: flex;
  align-items: stretch;
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0,0,0,0.6);
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}
.annc-toast.visible { opacity: 1; transform: none; pointer-events: auto; }
.annc-toast-stripe { width: 4px; background: var(--red); flex-shrink: 0; }
.annc-toast-body {
  flex: 1;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.annc-toast-cat {
  font-family: 'Space Mono', monospace;
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  opacity: 0.5;
}
.annc-toast-cat.homework { color: #ff6b6b; opacity: 1; }
.annc-toast-cat.exam     { color: #ffb74d; opacity: 1; }
.annc-toast-cat.event    { color: #4fc3f7; opacity: 1; }
.annc-toast-title {
  font-family: 'VT323', monospace;
  font-size: 1rem;
  line-height: 1.2;
  color: var(--fg);
}
.annc-toast-close {
  background: none; border: none;
  color: rgba(255,255,255,0.3);
  font-size: 0.85rem;
  padding: 0 10px;
  cursor: pointer;
  flex-shrink: 0;
  align-self: center;
}
.annc-toast-close:hover { color: var(--fg); }

/* ── Bottom panel ─────────────────────────────────────────────── */
.bottom-panel {
  width: 100%;
  box-sizing: border-box;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  height: 260px;
  min-height: 100px;
  max-height: 70vh;
  flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px;
  height: 36px;
  flex-shrink: 0;
  cursor: ns-resize;
  user-select: none;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.bottom-panel-toolbar:hover .resize-grip { opacity: 0.4; }

.resize-grip {
  width: 32px; height: 3px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  flex-shrink: 0;
  opacity: 0.2;
  transition: opacity 0.2s;
  pointer-events: none;
}

.bottom-toolbar-center { flex: 1; display: flex; justify-content: center; }

.bottom-layout-tog .tog-btn { font-size: 1rem; padding: 2px 12px; }

.bottom-panes {
  flex: 1;
  display: flex;
  flex-direction: row;
  overflow: hidden;
}

.bottom-panel.single-mode .bottom-panes { flex-direction: column; }

.bottom-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 10px 14px;
  min-width: 0;
  overflow: hidden;
}
.bottom-panel.split-mode .bottom-pane + .bottom-pane {
  border-left: 1px solid rgba(255,255,255,0.06);
}
.bottom-panel.single-mode .bottom-pane.hidden { display: none; }

.bottom-pane-hd {
  font-family: 'VT323', monospace;
  font-size: 1rem;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.3);
  margin-bottom: 6px;
  flex-shrink: 0;
}

.journal-textarea {
  flex: 1;
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--fg);
  font-family: 'Space Mono', monospace;
  font-size: 0.75rem;
  line-height: 1.6;
  resize: none;
  box-sizing: border-box;
  overflow-y: auto;
}

.bottom-hint {
  font-family: 'Space Mono', monospace;
  font-size: 0.58rem;
  color: rgba(255,255,255,0.12);
  letter-spacing: 0.08em;
  margin-top: 4px;
  flex-shrink: 0;
}

.anncs-list { overflow-y: auto; flex: 1; }

/* ── Public announcements cards ──────────────────────────────── */
.anncs-list { display: flex; flex-direction: column; gap: 8px; }
.anncs-empty {
  font-family: 'Space Mono', monospace;
  font-size: 0.7rem;
  color: rgba(255,255,255,0.2);
}
.anncs-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 4px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.anncs-card-hd { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.anncs-cat-pill {
  font-family: 'Space Mono', monospace;
  font-size: 0.55rem;
  letter-spacing: 0.1em;
  padding: 2px 5px;
  border-radius: 3px;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.5);
  flex-shrink: 0;
}
.anncs-cat-pill.homework { background: rgba(255,107,107,0.15); color: #ff6b6b; }
.anncs-cat-pill.exam     { background: rgba(255,183,77,0.15);  color: #ffb74d; }
.anncs-cat-pill.event    { background: rgba(79,195,247,0.15);  color: #4fc3f7; }
.anncs-card-title {
  font-family: 'VT323', monospace;
  font-size: 1rem;
  color: var(--fg);
  flex: 1;
}
.anncs-card-text {
  font-family: 'Space Mono', monospace;
  font-size: 0.72rem;
  color: rgba(255,255,255,0.6);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.anncs-card-meta {
  font-family: 'Space Mono', monospace;
  font-size: 0.6rem;
  color: rgba(255,255,255,0.2);
  letter-spacing: 0.05em;
}


/* ── B17: Reduced motion ─────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .scanlines { display: none; }
  .cursor    { animation: none; opacity: 1; }
  .now-dot   { animation: none; }
  .offline-badge { animation: none; }
  .tog-pill, .toggle-track, .toggle-thumb { transition: none; }
  .theme-panel, .theme-overlay { transition: none; }
  .tt-table { transition: none; }
}
