/* Backbeat — drum class PWA prototype */

:root {
  /* default: Studio dark theme */
  --bg: #0e0e10;
  --bg-2: #16161a;
  --surface: #1c1c21;
  --surface-2: #24242b;
  --surface-3: #2e2e36;
  --border: rgba(255,255,255,0.07);
  --border-strong: rgba(255,255,255,0.14);
  --fg: #f4f4f5;
  --fg-2: #c4c4c8;
  --fg-3: #8a8a92;
  --fg-4: #5e5e66;
  --accent: oklch(0.78 0.14 65);
  --accent-fg: #18120a;
  --danger: oklch(0.66 0.21 25);
  --good: oklch(0.74 0.16 145);

  --radius-card: 18px;
  --radius-pill: 999px;
  --radius-inner: 12px;

  --pad: 16px;

  --font-sans: 'Inter', -apple-system, system-ui, 'SF Pro', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

[data-theme="rock"] {
  --bg: #0c0a09;
  --bg-2: #15110f;
  --surface: #1a1614;
  --surface-2: #221d1a;
  --surface-3: #2c2622;
  --border: rgba(255,255,255,0.06);
  --border-strong: rgba(255,200,170,0.12);
  --fg: #fbf6f1;
  --fg-2: #d2c8be;
  --fg-3: #8a7f74;
  --fg-4: #5a5048;
  --accent: oklch(0.66 0.21 30);
  --accent-fg: #fff;
}

[data-theme="clean"] {
  --bg: #faf8f3;
  --bg-2: #f3f0e9;
  --surface: #ffffff;
  --surface-2: #f7f5ef;
  --surface-3: #ebe8e0;
  --border: rgba(20,18,12,0.08);
  --border-strong: rgba(20,18,12,0.16);
  --fg: #16140e;
  --fg-2: #3a3730;
  --fg-3: #6e6a60;
  --fg-4: #9a958a;
  --accent: oklch(0.55 0.13 35);
  --accent-fg: #fff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #1f1f23;
  color: #fff;
  font-family: var(--font-sans);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 0;
  overflow-x: hidden;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  padding: 0;
}

/* App-scoped */
.app {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.app-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 100px;
  scrollbar-width: none;
}
.app-scroll::-webkit-scrollbar { display: none; }

/* HEADER */
.app-header {
  padding: 56px 20px 8px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 5;
}
.app-header-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0;
}
.app-header-sub {
  font-size: 13px;
  color: var(--fg-3);
  margin-top: 2px;
  letter-spacing: -0.01em;
}
.app-header-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--surface-3));
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600;
  color: var(--accent-fg);
  border: 1px solid var(--border-strong);
}

/* TAB BAR */
.tabbar {
  position: absolute;
  left: 12px; right: 12px;
  bottom: 26px;
  z-index: 10;
  display: flex;
  background: color-mix(in oklab, var(--surface) 86%, transparent);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  padding: 6px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.35);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px 6px;
  border-radius: 16px;
  color: var(--fg-3);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: background 0.15s, color 0.15s;
}
.tab.active {
  background: var(--surface-3);
  color: var(--fg);
}
.tab svg { width: 22px; height: 22px; }

/* CARD */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px;
}
.card-tight { padding: 12px; }
.card-flush { padding: 0; overflow: hidden; }

.row { display: flex; }
.col { display: flex; flex-direction: column; }
.gap-4 { gap: 4px; }
.gap-6 { gap: 6px; }
.gap-8 { gap: 8px; }
.gap-10 { gap: 10px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.between { justify-content: space-between; }
.center { align-items: center; }

.section {
  padding: 0 20px;
}
.section + .section { margin-top: 18px; }

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-3);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0 0 8px;
  padding: 0 4px;
}
.section-title-row {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 0 4px; margin: 0 0 8px;
}
.section-title-row .section-title { margin: 0; padding: 0; }
.section-title-row a {
  font-size: 12px; color: var(--accent); font-weight: 600; text-decoration: none;
  letter-spacing: -0.01em;
}

.h-title {
  font-size: 17px; font-weight: 600; letter-spacing: -0.01em; margin: 0;
}
.h-eyebrow {
  font-size: 11px; font-weight: 600; color: var(--fg-3);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.h-num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 9px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--fg-2);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: -0.01em;
  border: 1px solid var(--border);
  white-space: nowrap;
}
.chip-accent {
  background: color-mix(in oklab, var(--accent) 22%, transparent);
  color: var(--accent);
  border-color: color-mix(in oklab, var(--accent) 30%, transparent);
}
.chip-solid {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: transparent;
  font-weight: 600;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.btn-solid {
  background: var(--accent); color: var(--accent-fg);
}
.btn-ghost {
  background: var(--surface-2); color: var(--fg); border: 1px solid var(--border);
}
.btn-block { width: 100%; }
.btn-sm { padding: 7px 11px; font-size: 12.5px; border-radius: 10px; }

.progress {
  height: 6px;
  width: 100%;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s;
}

.divider {
  height: 1px; background: var(--border); margin: 0;
}

/* DASHBOARD GREETING */
.hero {
  margin: 4px 20px 14px;
  padding: 16px;
  border-radius: var(--radius-card);
  background:
    radial-gradient(circle at 100% 0%, color-mix(in oklab, var(--accent) 30%, transparent), transparent 60%),
    var(--surface);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.hero-eyebrow { color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.hero-quote { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; margin: 4px 0 0; line-height: 1.25; }
.hero-meta { color: var(--fg-3); font-size: 12px; margin-top: 8px; }

/* TASK ROW */
.task {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px;
}
.task + .task { border-top: 1px solid var(--border); }
.task-check {
  width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid var(--fg-4);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  margin-top: 1px;
  transition: all 0.15s;
}
.task-check.done {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}
.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 14.5px; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
.task.done .task-title { color: var(--fg-3); text-decoration: line-through; }
.task-meta { font-size: 12px; color: var(--fg-3); margin-top: 3px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* BPM CARD */
.bpm-card {
  background: linear-gradient(180deg, color-mix(in oklab, var(--accent) 12%, var(--surface)) 0%, var(--surface) 60%);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-card);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.bpm-big {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 56px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
}
.bpm-target {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--fg-3);
}

/* VIDEO TILE */
.video-tile {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface-2);
  aspect-ratio: 16/10;
  border: 1px solid var(--border);
}
.video-tile-bg {
  position: absolute; inset: 0;
  background-size: 8px 8px;
  background-image: linear-gradient(45deg, rgba(255,255,255,0.04) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.04) 50%, rgba(255,255,255,0.04) 75%, transparent 75%);
}
[data-theme="clean"] .video-tile-bg {
  background-image: linear-gradient(45deg, rgba(0,0,0,0.04) 25%, transparent 25%, transparent 50%, rgba(0,0,0,0.04) 50%, rgba(0,0,0,0.04) 75%, transparent 75%);
}
.video-tile-play {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
}
.video-tile-time {
  position: absolute; right: 8px; bottom: 8px;
  background: rgba(0,0,0,0.6); color: #fff;
  font-family: var(--font-mono); font-size: 11px;
  padding: 2px 6px; border-radius: 6px;
}

/* HORIZONTAL SCROLL ROW */
.h-scroll {
  display: flex; gap: 12px;
  overflow-x: auto; overflow-y: hidden;
  padding: 0 20px 4px;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.h-scroll::-webkit-scrollbar { display: none; }
.h-scroll > * { scroll-snap-align: start; flex-shrink: 0; }

/* SEGMENTED CONTROL */
.seg {
  display: flex;
  background: var(--surface-2);
  border-radius: 12px;
  padding: 3px;
  border: 1px solid var(--border);
  gap: 2px;
}
.seg-item {
  flex: 1;
  padding: 8px 10px;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--fg-3);
  text-align: center;
  letter-spacing: -0.01em;
}
.seg-item.active {
  background: var(--surface);
  color: var(--fg);
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
  font-weight: 600;
}

/* SHEET (modal sliding from bottom) */
.sheet-backdrop {
  position: absolute; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(2px);
}
.sheet {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: var(--bg-2);
  border-top-left-radius: 28px;
  border-top-right-radius: 28px;
  border-top: 1px solid var(--border-strong);
  padding: 8px 0 0;
  max-height: 90%;
  display: flex; flex-direction: column;
  z-index: 101;
}
.sheet-grab {
  width: 38px; height: 4px; border-radius: 999px;
  background: var(--fg-4); margin: 4px auto 6px;
}
.sheet-head {
  padding: 8px 20px 12px;
  display: flex; align-items: center; justify-content: space-between;
}
.sheet-head h3 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.sheet-body { overflow-y: auto; padding: 0 20px 24px; }

/* METRONOME */
.metronome-disc {
  aspect-ratio: 1;
  width: 220px;
  margin: 12px auto 16px;
  border-radius: 50%;
  background:
    radial-gradient(circle, var(--surface) 50%, var(--surface-2) 70%, var(--surface-3) 100%);
  border: 1px solid var(--border-strong);
  position: relative;
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 8px 24px rgba(0,0,0,0.3);
}
.metronome-disc::before {
  content: '';
  position: absolute; inset: 8px;
  border-radius: 50%;
  border: 1px dashed var(--border);
}
.metronome-bpm {
  font-family: var(--font-mono);
  font-size: 64px;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
}
.metronome-bpm-label {
  text-align: center; font-size: 11px; color: var(--fg-3);
  letter-spacing: 0.1em; text-transform: uppercase; margin-top: 6px;
}
.metronome-dots {
  display: flex; gap: 8px; justify-content: center; margin: 12px 0;
}
.metronome-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface-3);
  border: 1px solid var(--border);
  transition: all 0.12s;
}
.metronome-dot.on { background: var(--accent); border-color: var(--accent); transform: scale(1.3); }
.metronome-dot.accent { background: var(--fg-4); }
.metronome-dot.accent.on { background: var(--accent); transform: scale(1.4); }

.stepper {
  display: flex; align-items: center; gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
}
.stepper-btn {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--fg-2);
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border);
}
.stepper-val {
  min-width: 56px; text-align: center;
  font-family: var(--font-mono); font-weight: 700; font-size: 16px;
  font-variant-numeric: tabular-nums;
}

/* BPM CHART */
.chart {
  display: flex; align-items: flex-end; gap: 4px;
  height: 80px;
  padding: 6px 0 0;
}
.chart-bar {
  flex: 1;
  background: var(--surface-3);
  border-radius: 4px 4px 2px 2px;
  position: relative;
  min-height: 4px;
}
.chart-bar.current { background: var(--accent); }
.chart-target {
  position: absolute;
  left: 0; right: 0;
  border-top: 1.5px dashed var(--accent);
  pointer-events: none;
}
.chart-axis {
  display: flex; justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10px; color: var(--fg-4);
  margin-top: 6px;
}

/* PLAYER */
.player-card {
  background: linear-gradient(180deg, color-mix(in oklab, var(--accent) 14%, var(--surface)), var(--surface));
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-card);
  padding: 16px;
}
.player-wave {
  height: 36px;
  display: flex; align-items: center; gap: 2px;
  margin: 12px 0 6px;
}
.player-wave-bar {
  flex: 1;
  background: var(--fg-4);
  border-radius: 1px;
  min-height: 4px;
}
.player-wave-bar.played { background: var(--accent); }
.player-time {
  display: flex; justify-content: space-between;
  font-family: var(--font-mono); font-size: 11px; color: var(--fg-3);
}
.player-controls {
  display: flex; align-items: center; justify-content: center; gap: 22px;
  margin-top: 10px;
}
.player-play {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent);
  color: var(--accent-fg);
  display: flex; align-items: center; justify-content: center;
}
.player-toggle {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 13px;
}
.player-toggle.active {
  background: color-mix(in oklab, var(--accent) 20%, var(--surface-2));
  border-color: color-mix(in oklab, var(--accent) 40%, transparent);
  color: var(--accent);
}

/* SWITCH */
.switch {
  width: 38px; height: 22px; border-radius: 999px;
  background: var(--surface-3);
  position: relative; cursor: pointer;
  transition: background 0.18s;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.switch::after {
  content: ''; position: absolute; top: 1.5px; left: 1.5px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: transform 0.18s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.25);
}
.switch.on { background: var(--accent); border-color: transparent; }
.switch.on::after { transform: translateX(16px); }

/* CALENDAR */
.calendar-strip {
  display: flex; gap: 6px;
  padding: 4px 20px 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.calendar-strip::-webkit-scrollbar { display: none; }
.cal-day {
  display: flex; flex-direction: column; align-items: center;
  padding: 8px 4px; min-width: 44px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: var(--surface);
  flex-shrink: 0;
}
.cal-day.today { border-color: var(--accent); }
.cal-day.selected { background: var(--accent); color: var(--accent-fg); }
.cal-day.has-event::after {
  content: '';
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--accent); margin-top: 4px;
}
.cal-day.selected.has-event::after { background: var(--accent-fg); }
.cal-day-dow { font-size: 10px; color: var(--fg-3); letter-spacing: 0.06em; text-transform: uppercase; }
.cal-day.selected .cal-day-dow { color: var(--accent-fg); opacity: 0.7; }
.cal-day-num { font-family: var(--font-mono); font-size: 17px; font-weight: 700; line-height: 1; margin-top: 4px; }

.event {
  display: flex; gap: 12px;
  padding: 14px 16px;
}
.event + .event { border-top: 1px solid var(--border); }
.event-time {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--fg-3);
  min-width: 50px;
  padding-top: 1px;
}
.event-time strong { display: block; color: var(--fg); font-size: 14px; }
.event-bar {
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
  flex-shrink: 0;
}
.event-bar.makeup { background: var(--good); }
.event-bar.event-special { background: oklch(0.75 0.15 240); }
.event-body { flex: 1; }
.event-title { font-size: 14.5px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.event-sub { font-size: 12px; color: var(--fg-3); margin-top: 2px; }

/* BACHECA */
.broadcast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 14px 16px;
}
.broadcast.unread { border-color: color-mix(in oklab, var(--accent) 35%, transparent); }
.broadcast-head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 6px;
}
.broadcast-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface-3);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.broadcast-name { font-size: 13px; font-weight: 600; letter-spacing: -0.01em; }
.broadcast-time { font-size: 11px; color: var(--fg-3); margin-left: auto; font-family: var(--font-mono); }
.broadcast-body { font-size: 14px; line-height: 1.45; color: var(--fg-2); }
.broadcast-tags { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.broadcast-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}

/* LIBRARY */
.book-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 0 20px;
}
.book {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  display: flex; flex-direction: column;
}
.book-cover {
  aspect-ratio: 3/4;
  position: relative;
  background: var(--surface-2);
  overflow: hidden;
}
.book-cover-stripes {
  position: absolute; inset: 0;
  background:
    linear-gradient(180deg, color-mix(in oklab, var(--cover, var(--surface-3)) 100%, transparent), color-mix(in oklab, var(--cover, var(--surface-3)) 70%, black));
}
.book-cover-stripes::after {
  content: '';
  position: absolute; inset: 0;
  background-image: repeating-linear-gradient(
    transparent 0,
    transparent 7px,
    rgba(255,255,255,0.05) 7px,
    rgba(255,255,255,0.05) 8px
  );
}
.book-spine {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 6px;
  background: rgba(0,0,0,0.3);
  box-shadow: inset -2px 0 6px rgba(0,0,0,0.3);
}
.book-cover-label {
  position: absolute;
  inset: 0;
  padding: 14px 12px 12px 18px;
  display: flex; flex-direction: column; justify-content: space-between;
  color: #fff;
}
.book-cover-title {
  font-size: 13px; font-weight: 700; letter-spacing: -0.01em;
  line-height: 1.15;
}
.book-cover-author {
  font-size: 10px;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.8;
}
.book-meta {
  padding: 9px 11px 11px;
}
.book-meta-title { font-size: 12.5px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; }
.book-meta-sub { font-size: 11px; color: var(--fg-3); margin-top: 2px; }

.search-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 0 20px 12px;
}
.search-bar input {
  flex: 1; background: transparent; border: 0; color: var(--fg);
  font: inherit; font-size: 14px;
  outline: none;
}
.search-bar input::placeholder { color: var(--fg-4); }

.filter-row {
  display: flex; gap: 6px;
  padding: 0 20px 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.filter-row::-webkit-scrollbar { display: none; }
.filter-chip {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--fg-2);
  white-space: nowrap;
  flex-shrink: 0;
}
.filter-chip.active {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

/* PDF row */
.pdf-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
}
.pdf-row + .pdf-row { border-top: 1px solid var(--border); }
.pdf-icon {
  width: 38px; height: 46px;
  border-radius: 6px;
  background: var(--surface-3);
  position: relative;
  flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 1px solid var(--border);
}
.pdf-icon::before {
  content: '';
  position: absolute; top: 0; right: 0;
  width: 10px; height: 10px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-bottom-left-radius: 3px;
}
.pdf-icon span {
  font-family: var(--font-mono); font-size: 8px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-top: 12px;
}
.pdf-body { flex: 1; min-width: 0; }
.pdf-title { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
.pdf-meta { font-size: 11.5px; color: var(--fg-3); margin-top: 2px; }
.pdf-dl {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--fg-2);
}

/* Achievement badges */
.badges-row {
  display: flex; gap: 10px; padding: 0 20px;
}
.badge {
  flex: 1;
  aspect-ratio: 1;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
  padding: 8px;
  position: relative;
  overflow: hidden;
}
.badge.earned { border-color: var(--border-strong); }
.badge.locked { opacity: 0.5; }
.badge-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), color-mix(in oklab, var(--accent) 60%, black));
  display: flex; align-items: center; justify-content: center;
  color: var(--accent-fg);
  font-weight: 800;
  font-family: var(--font-mono);
}
.badge.locked .badge-icon {
  background: var(--surface-3); color: var(--fg-4);
}
.badge-label {
  font-size: 10px; text-align: center; color: var(--fg-3); font-weight: 500;
  letter-spacing: -0.01em;
}

/* HOMEWORK PROGRESS */
.hw-progress {
  display: flex; align-items: center; gap: 12px;
}
.hw-progress-ring {
  width: 56px; height: 56px;
  flex-shrink: 0;
  position: relative;
}
.hw-progress-ring svg { transform: rotate(-90deg); }
.hw-progress-ring-txt {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-weight: 700; font-size: 14px;
  font-variant-numeric: tabular-nums;
}

/* PILL TABS (within screens) */
.pill-tabs {
  display: flex; gap: 6px;
  padding: 0 20px 12px;
  overflow-x: auto;
  scrollbar-width: none;
}
.pill-tabs::-webkit-scrollbar { display: none; }
.pill-tab {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg-2);
  font-size: 13px;
  font-weight: 500;
  flex-shrink: 0;
}
.pill-tab.active {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: transparent;
  font-weight: 600;
}

/* ICON COLOR HINTS */
.icon-accent { color: var(--accent); }
.muted { color: var(--fg-3); }
.muted-2 { color: var(--fg-4); }

/* Tabular */
.tab-num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* INSTALL CARD */
.install-card {
  margin: 0 20px 16px;
  background: linear-gradient(135deg,
    color-mix(in oklab, var(--accent) 18%, var(--surface)),
    var(--surface) 60%);
  border: 1px solid color-mix(in oklab, var(--accent) 30%, var(--border));
  border-radius: var(--radius-card);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  overflow: hidden;
}
.install-card-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.install-card-icon-inner {
  font-weight: 800; font-size: 22px;
  color: var(--accent);
  letter-spacing: -0.04em;
  position: relative;
}
.install-card-icon-inner::after {
  content: '';
  position: absolute;
  top: -1px; right: -5px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.install-card-body { flex: 1; min-width: 0; }
.install-card-title {
  font-size: 14px; font-weight: 600; letter-spacing: -0.01em;
  line-height: 1.2;
}
.install-card-sub {
  font-size: 12px; color: var(--fg-3); margin-top: 3px;
  line-height: 1.3;
}
.install-card-btn {
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 10px;
  flex-shrink: 0;
}
.install-card-x {
  position: absolute;
  top: 8px; right: 8px;
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  color: var(--fg-3);
  border-radius: 6px;
}
.install-card-x:hover { background: var(--surface-3); }

/* INSTALL STEPS */
.install-step {
  display: flex; gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.install-step:last-of-type { border-bottom: 0; }
.install-step-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-fg);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}
.install-step-title {
  font-size: 14.5px; font-weight: 600; letter-spacing: -0.01em;
  line-height: 1.3;
}
.install-step-sub {
  font-size: 12.5px; color: var(--fg-3); margin-top: 4px;
  line-height: 1.4;
}
.ios-share-icon {
  display: inline-flex; align-items: center;
  padding: 2px 5px; margin: 0 2px;
  vertical-align: -3px;
  background: var(--surface-3);
  border-radius: 5px;
  color: oklch(0.72 0.15 240);
}

.install-mock {
  margin-top: 16px;
  padding: 16px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.install-mock-screen {
  background: var(--surface);
  border-radius: 10px;
  border: 1px solid var(--border);
  overflow: hidden;
}
.install-mock-title {
  padding: 8px 12px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--fg-3);
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}
.install-mock-share { padding: 6px 0; }
.install-mock-row {
  padding: 12px 14px;
  display: flex; align-items: center; gap: 14px;
  font-size: 14px;
  color: var(--fg);
}
.install-mock-dot {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--surface-3);
  color: oklch(0.72 0.15 240);
  display: flex; align-items: center; justify-content: center;
}

/* PWA STATUS CHIP */
.pwa-chip {
  font-size: 9.5px;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--fg-3);
  border: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  font-family: var(--font-mono);
}
.pwa-chip.installed {
  background: color-mix(in oklab, var(--good) 18%, transparent);
  color: var(--good);
  border-color: color-mix(in oklab, var(--good) 30%, transparent);
}

/* ────────────────────────────────────────────── */
/* TEACHER VIEW                                   */
/* ────────────────────────────────────────────── */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.kpi-val {
  font-size: 22px; font-weight: 700; line-height: 1;
  letter-spacing: -0.02em;
}
.kpi-val .kpi-of {
  color: var(--fg-4); font-weight: 500; font-size: 14px;
}
.kpi-lbl {
  font-size: 10px; color: var(--fg-3);
  letter-spacing: 0.02em;
  line-height: 1.2;
}

/* Student row */
.student-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  width: 100%; text-align: left;
  background: transparent; border: 0;
}
.student-row + .student-row { border-top: 1px solid var(--border); }
.student-row.alert {
  background: color-mix(in oklab, oklch(0.66 0.21 25) 8%, transparent);
}
.student-body { flex: 1; min-width: 0; }
.student-name {
  font-size: 14.5px; font-weight: 600; letter-spacing: -0.01em;
}
.student-meta {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-top: 3px; align-items: center;
}
.student-alert {
  font-size: 11.5px; color: oklch(0.66 0.21 25);
  margin-top: 3px;
  display: flex; align-items: center; gap: 4px;
}

/* Quick actions grid */
.quick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.quick-action {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}
.quick-action-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--surface-3);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.quick-action-lbl {
  font-size: 13px; font-weight: 600; letter-spacing: -0.01em;
  line-height: 1.2;
}

/* Compose launcher */
.compose-launcher,
.upload-launcher {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
}
.compose-launcher-icon,
.upload-launcher-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-fg);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* Forms */
.form-row {
  display: flex; flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}
.form-label {
  font-size: 11px;
  color: var(--fg-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  padding: 0 2px;
}
.form-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  color: var(--fg);
  font: inherit; font-size: 14px;
  outline: none;
  width: 100%;
  font-family: inherit;
}
.form-input:focus {
  border-color: color-mix(in oklab, var(--accent) 45%, var(--border));
}
textarea.form-input { resize: vertical; min-height: 80px; line-height: 1.4; }
select.form-input { appearance: none; cursor: pointer; }

/* Upload drop */
.upload-drop {
  background: var(--surface);
  border: 1.5px dashed var(--border-strong);
  border-radius: 14px;
  padding: 28px 18px;
  text-align: center;
  margin-bottom: 16px;
  cursor: pointer;
}
.upload-drop:hover { background: var(--surface-2); }
.upload-drop-icon {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--accent);
  margin: 0 auto;
  display: flex; align-items: center; justify-content: center;
}

/* Role badge in header */
.role-badge {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--accent);
  font-family: var(--font-mono);
}

/* SETTINGS */
.settings-btn {
  width: 38px; height: 38px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center;
  color: var(--fg-2);
  position: relative;
}
.settings-btn-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--good);
  border: 1.5px solid var(--surface);
}
.settings-status {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 18px;
}
.settings-status-dot {
  width: 10px; height: 10px; border-radius: 50%;
  flex-shrink: 0;
  position: relative;
}
.settings-status-dot.ok    { background: var(--good); box-shadow: 0 0 0 4px color-mix(in oklab, var(--good) 22%, transparent); }
.settings-status-dot.warn  { background: var(--accent); box-shadow: 0 0 0 4px color-mix(in oklab, var(--accent) 22%, transparent); }
.settings-status-dot.off   { background: var(--fg-4); }

.settings-section {
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 12px;
}
.settings-card-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
}

.alert {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  display: flex; align-items: center; gap: 6px;
  line-height: 1.3;
}
.alert.ok {
  background: color-mix(in oklab, var(--good) 14%, transparent);
  color: var(--good);
  border: 1px solid color-mix(in oklab, var(--good) 30%, transparent);
}
.alert.err {
  background: color-mix(in oklab, oklch(0.66 0.21 25) 14%, transparent);
  color: oklch(0.66 0.21 25);
  border: 1px solid color-mix(in oklab, oklch(0.66 0.21 25) 30%, transparent);
}
.btn-link {
  background: none;
  border: 0;
  color: var(--fg-3);
  font-size: 12.5px;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 0;
}

.diag-grid {
  display: flex; flex-direction: column;
  gap: 0;
  background: var(--bg-2);
  border-radius: 10px;
  border: 1px solid var(--border);
  overflow: hidden;
}
.diag-row {
  display: flex; justify-content: space-between;
  padding: 9px 12px;
  font-size: 12.5px;
  font-family: var(--font-mono);
}
.diag-row + .diag-row { border-top: 1px solid var(--border); }
.diag-row span:first-child { color: var(--fg-3); }
.diag-row .ok { color: var(--good); }
.diag-row .no { color: var(--fg-4); }

/* ─── AUTH SCREEN ─────────────────────────────────── */
.auth-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px 16px;
  overflow-y: auto;
  z-index: 100;
}

.auth-card {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.auth-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
  color: var(--accent);
}

.auth-app-name {
  font-size: 26px;
  font-weight: 700;
  color: var(--fg-1);
  letter-spacing: -0.5px;
}

.auth-tabs {
  display: flex;
  background: var(--surface);
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
}

.auth-tab {
  flex: 1;
  padding: 9px 0;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: var(--fg-3);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.auth-tab.active {
  background: var(--accent);
  color: #000;
  font-weight: 600;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.input-pw-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-pw-wrap .form-input {
  width: 100%;
  padding-right: 44px;
}

.pw-toggle {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--fg-3);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
}

.auth-reset-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--fg-1);
  margin-bottom: 4px;
}

.auth-footer {
  margin-top: 24px;
  text-align: center;
  font-size: 11px;
  color: var(--fg-4, var(--fg-3));
  line-height: 1.5;
}

.role-badge-student {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
}

/* ─── APP ROOT — fullscreen, niente cornice iOS ─── */
.app-root {
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg, #0e0e10);
}

body, html, #root {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  background: #0e0e10;
}

/* ─── LOGOUT BUTTON ─── */
.btn-logout {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: 1.5px solid oklch(0.55 0.18 25);
  background: transparent;
  color: oklch(0.66 0.21 25);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-logout:hover {
  background: color-mix(in oklab, oklch(0.66 0.21 25) 10%, transparent);
}
