/* TeachBoard web. Colours follow the Android app's theme (Theme.kt). */
:root {
  --primary: #3D6BFF;
  --on-primary: #FFFFFF;
  --primary-container: #E6ECFF;
  --on-primary-container: #0F2260;
  --secondary-container: #ECEEF2;
  --surface: #F4F5F7;
  --on-surface: #111318;
  --on-surface-variant: #5A6170;
  --surface-dim: #DDE0E6;
  --surface-container-low: #FAFBFC;
  --surface-container: #FFFFFF;
  --surface-container-high: #F0F2F5;
  --surface-container-highest: #E8EBEF;
  --outline: #CDD2DA;
  --outline-variant: #E2E5EA;
  --error: #D63B3B;
  --error-container: #FCEAEA;
  --record-red: #E53935;
  --scrim: rgba(12, 14, 18, 0.45);
  --shadow: 0 6px 24px rgba(17, 19, 24, 0.14), 0 1px 3px rgba(17, 19, 24, 0.10);
  --shadow-soft: 0 1px 2px rgba(17, 19, 24, 0.06);
  --radius-l: 26px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", "Noto Sans Devanagari", "Nirmala UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: #7D9BFF;
    --on-primary: #07143D;
    --primary-container: #1B2A5A;
    --on-primary-container: #DDE5FF;
    --secondary-container: #232832;
    --surface: #0C0E12;
    --on-surface: #E7E9EE;
    --on-surface-variant: #99A1B0;
    --surface-dim: #08090C;
    --surface-container-low: #111318;
    --surface-container: #161920;
    --surface-container-high: #1C2028;
    --surface-container-highest: #232832;
    --outline: #3A404C;
    --outline-variant: #262B34;
    --error: #FF8A80;
    --error-container: #3A1A1A;
    --scrim: rgba(0, 0, 0, 0.6);
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --primary: #7D9BFF;
  --on-primary: #07143D;
  --primary-container: #1B2A5A;
  --on-primary-container: #DDE5FF;
  --secondary-container: #232832;
  --surface: #0C0E12;
  --on-surface: #E7E9EE;
  --on-surface-variant: #99A1B0;
  --surface-dim: #08090C;
  --surface-container-low: #111318;
  --surface-container: #161920;
  --surface-container-high: #1C2028;
  --surface-container-highest: #232832;
  --outline: #3A404C;
  --outline-variant: #262B34;
  --error: #FF8A80;
  --error-container: #3A1A1A;
  --scrim: rgba(0, 0, 0, 0.6);
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--surface);
  color: var(--on-surface);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}

#app { height: 100%; }
button { font: inherit; color: inherit; }
a { color: var(--primary); }
h1, h2, h3 { margin: 0; }
p { margin: 0 0 8px; }
.hidden { display: none !important; }
.muted { color: var(--on-surface-variant); }
.accent { color: var(--primary); display: block; }
.error-text { color: var(--error); min-height: 1em; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.icon { width: 24px; height: 24px; fill: currentColor; flex: none; }
.fatal { padding: 24px; max-width: 640px; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------------- Buttons and fields ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 18px;
  border: 0;
  border-radius: 20px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s, transform 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn .icon { width: 18px; height: 18px; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-text { background: transparent; color: var(--primary); padding: 0 12px; }
.btn-text:hover { background: color-mix(in srgb, var(--primary) 10%, transparent); }
.btn-tonal { background: var(--primary-container); color: var(--on-primary-container); }
.btn.danger, .btn-text.danger { color: var(--error); }
.btn-tonal.danger { background: var(--error-container); color: var(--error); }
.btn:disabled { opacity: 0.45; cursor: default; }

.icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--on-surface-variant);
  cursor: pointer;
  flex: none;
}
.icon-btn:hover { background: var(--surface-container-high); color: var(--on-surface); }
.icon-btn.tonal { background: var(--surface-container-highest); color: var(--on-surface); }
.icon-btn.small { width: 34px; height: 34px; }
.icon-btn.small .icon { width: 20px; height: 20px; }

.badge {
  position: absolute;
  top: -2px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--error);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.field {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--outline);
  border-radius: 12px;
  background: var(--surface-container);
  color: var(--on-surface);
  font: inherit;
  resize: vertical;
}
.field:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.field-label { display: flex; flex-direction: column; gap: 6px; }
.field-label > span { font-size: 13px; color: var(--on-surface-variant); font-weight: 600; }

.segmented { display: inline-flex; border: 1px solid var(--outline); border-radius: 20px; overflow: hidden; flex: none; max-width: 100%; }
.segmented button {
  border: 0;
  border-left: 1px solid var(--outline);
  background: transparent;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.segmented button:first-child { border-left: 0; }
.segmented button.on { background: var(--primary-container); color: var(--on-primary-container); font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip, .chip-toggle {
  border: 1px solid var(--outline);
  background: transparent;
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}
.chip.on, .chip-toggle.on { background: var(--primary-container); color: var(--on-primary-container); border-color: transparent; font-weight: 600; }

.switch { position: relative; display: inline-block; width: 46px; height: 28px; flex: none; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .slider { position: absolute; inset: 0; border-radius: 14px; background: var(--surface-container-highest); border: 2px solid var(--outline); transition: 0.2s; }
.switch .slider::before { content: ""; position: absolute; width: 16px; height: 16px; left: 4px; top: 4px; border-radius: 50%; background: var(--on-surface-variant); transition: 0.2s; }
.switch input:checked + .slider { background: var(--primary); border-color: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(18px); background: var(--on-primary); width: 20px; height: 20px; top: 2px; }
.switch input:focus-visible + .slider { outline: 2px solid var(--primary); outline-offset: 2px; }

input[type="range"] { width: 100%; accent-color: var(--primary); }

/* ---------------- Board screen ---------------- */

.editor {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: row;
  background: var(--surface-container-high);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
/* Tall window (phone held upright): toolbars above and below so the board gets the full width */
.editor.tall { flex-direction: column; }

.rail {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-container-low);
  width: 64px;
  padding: 8px 0;
}
.editor.tall .rail { width: auto; height: 60px; padding: 5px 8px; }

.capsule {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  max-height: 100%;
  overflow-y: auto;
  scrollbar-width: none;
  padding: 6px 4px;
  border-radius: var(--radius-l);
  background: var(--surface-container);
  border: 1px solid var(--outline-variant);
}
.editor.tall .capsule { flex-direction: row; max-width: 100%; max-height: none; overflow-x: auto; overflow-y: hidden; padding: 2px 6px; }
.capsule::-webkit-scrollbar { display: none; }

.tool {
  position: relative;
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--on-surface);
  cursor: pointer;
  transform: scale(0.92);
  transition: background-color 0.2s, color 0.2s, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.tool:hover { background: var(--surface-container-high); }
.tool.selected { background: var(--primary-container); color: var(--on-primary-container); transform: scale(1); }
.tool:disabled { color: color-mix(in srgb, var(--on-surface) 30%, transparent); cursor: default; background: transparent; }
.tool .icon { width: 24px; height: 24px; }
/* A small corner mark meaning "has options" */
.tool.has-menu::after {
  content: "";
  position: absolute;
  right: 3px;
  bottom: 3px;
  border-left: 6px solid transparent;
  border-bottom: 6px solid color-mix(in srgb, var(--on-surface) 60%, transparent);
}
.color-dot { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--outline); }
.divider { flex: none; width: 36px; height: 1px; margin: 3px 0; background: var(--outline-variant); }
.editor.tall .divider { width: 1px; height: 32px; margin: 0 3px; }
.gap { flex: none; height: 16px; width: 16px; }
.page-chip {
  flex: none;
  border: 0;
  border-radius: 8px;
  background: var(--surface-container-high);
  padding: 4px 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

/* The area around the board, and the 16:9 board itself */
.board-area {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  background: var(--surface-dim);
  overflow: hidden;
}
.board {
  position: absolute;
  overflow: hidden;
  box-shadow: var(--shadow);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.board canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.board.drop-target { outline: 4px solid var(--primary); outline-offset: -4px; }

.selection-bar {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  gap: 2px;
  max-width: calc(100% - 16px);
  overflow-x: auto;
  scrollbar-width: none;
  padding: 4px;
  border-radius: 20px;
  background: var(--surface-container);
  box-shadow: var(--shadow);
}
.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  background: transparent;
  color: var(--primary);
  padding: 7px 10px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.chip-btn:hover { background: color-mix(in srgb, var(--primary) 10%, transparent); }
.chip-btn.danger { color: var(--error); }

.zoom-badge, .gesture-hint, .finger-tip {
  position: absolute;
  z-index: 6;
  background: rgba(30, 34, 40, 0.92);
  color: #fff;
  box-shadow: var(--shadow);
}
.zoom-badge {
  right: 10px;
  bottom: 10px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  border-radius: 18px;
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
}
.gesture-hint {
  top: 14px;
  left: 50%;
  transform: translateX(-50%) scale(0.8);
  border-radius: 16px;
  padding: 6px 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.gesture-hint.show { opacity: 1; transform: translateX(-50%) scale(1); }
.finger-tip {
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 16px;
  padding: 8px 6px 8px 16px;
  font-size: 13px;
  width: max-content;
  max-width: calc(100% - 24px);
}
.finger-tip .btn-text { color: #8FB4FF; }

.recording-bar {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 7;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 20px;
  background: rgba(30, 34, 40, 0.92);
  color: #fff;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--record-red); animation: blink 1.2s infinite; }
.rec-dot.paused { background: #9E9E9E; animation: none; }
@keyframes blink { 50% { opacity: 0.35; } }
.mic-meter { width: 36px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.2); overflow: hidden; }
.mic-fill { display: block; width: 100%; height: 100%; background: #4ADE80; transform-origin: left; transform: scaleX(0); transition: transform 0.08s linear; }
.rec-controls { display: none; gap: 2px; }
.recording-bar.open .rec-controls, .recording-bar.paused .rec-controls { display: inline-flex; }
.rec-btn { width: 34px; height: 34px; border: 0; border-radius: 50%; background: transparent; color: #fff; display: grid; place-items: center; cursor: pointer; }
.rec-btn:hover { background: rgba(255, 255, 255, 0.14); }
.rec-btn.stop { color: var(--record-red); }

.shapes-panel {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 8;
  width: min(420px, calc(100% - 12px));
  max-height: calc(100% - 12px);
  overflow-y: auto;
  padding: 10px;
  border-radius: 18px;
  background: var(--surface-container);
  border: 1px solid var(--outline-variant);
  box-shadow: var(--shadow);
  animation: pop-in 0.14s ease-out;
}
.shapes-title { font-weight: 700; padding: 0 4px 8px; display: flex; flex-direction: column; }
.shapes-title small { font-weight: 400; color: var(--on-surface-variant); }
.shapes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 4px; }
.shape-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  padding: 6px 2px;
  font-size: 10.5px;
  line-height: 1.15;
  cursor: grab;
  touch-action: none;
}
.shape-tile:hover { background: var(--surface-container-high); }
.shape-tile.chosen { background: var(--primary-container); }
.shape-tile span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shape-ghost {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  padding: 4px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface-container) 90%, transparent);
  box-shadow: var(--shadow);
}

/* ---------------- Pop-up panels and menus ---------------- */

.popover {
  position: fixed;
  z-index: 60;
  min-width: 200px;
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 16px);
  overflow-y: auto;
  background: var(--surface-container);
  color: var(--on-surface);
  border: 1px solid var(--outline-variant);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 6px 0;
  animation: pop-in 0.14s ease-out;
}
@keyframes pop-in { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }
.menu { display: flex; flex-direction: column; min-width: 220px; }
.menu-title { font-size: 12px; color: var(--on-surface-variant); padding: 6px 16px; }
.menu-divider { height: 1px; background: var(--outline-variant); margin: 4px 0; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  background: transparent;
  padding: 9px 16px;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-container-high); outline: none; }
.menu-item:disabled { opacity: 0.4; cursor: default; background: transparent; }
.menu-item .icon { width: 20px; height: 20px; color: var(--on-surface-variant); }
.menu-item.danger, .menu-item.danger .icon { color: var(--error); }
.menu-label { flex: 1; }
.menu-icon-space { width: 20px; flex: none; }
.brush-sample { width: 72px; height: 28px; flex: none; }
.bg-sample { width: 44px; height: 25px; border-radius: 4px; border: 1px solid var(--outline); flex: none; }

.style-panel { width: 290px; padding: 4px 14px 8px; display: flex; flex-direction: column; gap: 8px; }
.panel-label { font-size: 12px; color: var(--on-surface-variant); margin-top: 4px; }
.swatches { display: grid; grid-template-columns: repeat(6, 34px); gap: 8px; }
.swatch {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid #9E9E9E;
  padding: 0;
  cursor: pointer;
}
.swatch.chosen { border: 3px solid var(--primary); box-shadow: 0 0 0 2px var(--surface-container) inset; }
.custom-color-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--on-surface-variant); cursor: pointer; }
.custom-color { width: 34px; height: 34px; border: 0; padding: 0; background: none; cursor: pointer; }
.width-preview { height: 48px; border-radius: 8px; background: #FFFFFF; display: block; width: 100%; }
.color-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------------- Dialogs ---------------- */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--scrim);
  animation: fade-in 0.15s ease-out;
}
@keyframes fade-in { from { opacity: 0; } }
.dialog {
  width: min(440px, 100%);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 22px 22px 14px;
  border-radius: 24px;
  background: var(--surface-container);
  color: var(--on-surface);
  box-shadow: var(--shadow);
  animation: pop-in 0.16s ease-out;
}
.dialog.wide { width: min(640px, 100%); }
.dialog-icon { display: flex; justify-content: center; color: var(--primary); margin-bottom: 8px; }
.dialog-title { font-size: 20px; font-weight: 600; margin-bottom: 12px; }
.dialog-icon + .dialog-title { text-align: center; }
.dialog-body { color: var(--on-surface-variant); }
.dialog-body p { margin: 0 0 10px; }
.dialog-buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin-top: 16px; }
.choice-list { display: flex; flex-direction: column; margin: 0 -8px; }
.choice {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 0;
  background: transparent;
  padding: 10px 8px;
  border-radius: 12px;
  text-align: left;
  cursor: pointer;
  color: var(--on-surface);
}
.choice:hover { background: var(--surface-container-high); }
.choice .radio { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--on-surface-variant); flex: none; }
.choice.chosen .radio { border-color: var(--primary); box-shadow: inset 0 0 0 4px var(--surface-container), inset 0 0 0 10px var(--primary); }
.choice-text { display: flex; flex-direction: column; }
.choice-text small { color: var(--on-surface-variant); }
.progress-body { display: flex; align-items: center; gap: 16px; }
.progress { height: 6px; border-radius: 3px; background: var(--surface-container-highest); overflow: hidden; margin-top: 6px; }
.progress-fill { height: 100%; width: 30%; background: var(--primary); border-radius: 3px; animation: indeterminate 1.2s ease-in-out infinite; }
.progress.known .progress-fill { animation: none; transition: width 0.2s; }
@keyframes indeterminate { from { transform: translateX(-100%); } to { transform: translateX(350%); } }
.spinner { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--primary-container); border-top-color: var(--primary); animation: spin 0.9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.text-dialog { display: flex; flex-direction: column; gap: 10px; }
.text-options { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.hint { color: var(--on-surface-variant); font-size: 12px; }
.camera-view { width: 100%; border-radius: 12px; background: #000; max-height: 60vh; }
.props { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; }
.props dt { color: var(--on-surface-variant); }
.props dd { margin: 0; color: var(--on-surface); font-weight: 500; word-break: break-word; }
.version-list { display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow-y: auto; }
.version-row { display: flex; align-items: center; gap: 12px; padding: 6px; border-radius: 12px; background: var(--surface-container-high); color: var(--on-surface); }
.version-row small { display: block; }

.toast-host {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 32px);
}
.toast {
  padding: 10px 18px;
  border-radius: 12px;
  background: #2B2F36;
  color: #fff;
  box-shadow: var(--shadow);
  animation: toast-in 0.2s ease-out;
  transition: opacity 0.35s, transform 0.35s;
}
.toast.leaving { opacity: 0; transform: translateY(8px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------------- Home ---------------- */

.home { display: flex; height: 100%; }
.side-nav {
  flex: none;
  width: 236px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 14px;
  background: var(--surface-container-low);
  border-right: 1px solid var(--outline-variant);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; font-size: 19px; font-weight: 700; color: var(--on-surface); text-decoration: none; }
.logo { display: inline-block; flex: none; }
.logo svg { display: block; }
.new-board { margin: 0 0 12px; height: 48px; border-radius: 16px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-radius: 24px;
  color: var(--on-surface-variant);
  text-decoration: none;
  font-weight: 600;
}
.nav-item:hover { background: var(--surface-container-high); color: var(--on-surface); }
.nav-item.active { background: var(--primary-container); color: var(--on-primary-container); }
.nav-icon { position: relative; display: inline-flex; }
.side-foot { margin-top: auto; padding: 8px; font-size: 12px; color: var(--on-surface-variant); }
.bottom-nav { display: none; }
.page-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.page { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0 28px; }
.page-body { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 2px 28px; }
.page-body.narrow { max-width: 720px; }

.screen-header { padding: 22px 2px 14px; display: flex; flex-direction: column; gap: 14px; }
.header-row { display: flex; align-items: center; gap: 12px; }
.header-text { flex: 1; min-width: 0; }
.header-text h1 { font-size: 26px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-text p { margin: 2px 0 0; color: var(--on-surface-variant); }
.header-actions { display: flex; gap: 8px; align-items: center; }
.title-with-icon { display: inline-flex; align-items: center; gap: 10px; }
.pill-toggle { display: inline-flex; padding: 4px; gap: 4px; border-radius: 22px; background: var(--surface-container-high); align-self: flex-start; }
.pill-toggle button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  border-radius: 18px;
  padding: 8px 16px;
  font-weight: 600;
  color: var(--on-surface-variant);
  cursor: pointer;
}
.pill-toggle button .icon { width: 18px; height: 18px; }
.pill-toggle button.on { background: var(--surface-container); color: var(--on-surface); box-shadow: var(--shadow-soft); }

.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px; padding: 64px 24px; color: var(--on-surface-variant); }
.empty .icon { color: color-mix(in srgb, var(--primary) 60%, transparent); margin-bottom: 6px; }
.empty h3 { color: var(--on-surface); font-size: 18px; }
.empty .btn { margin-top: 12px; }

.card-grid { display: grid; gap: 16px; }
.card-grid.boards { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.card-grid.videos { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.card-grid.folders { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.card-grid.doubts { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); align-items: start; }
.card-grid.bin { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

.board-card {
  position: relative;
  border-radius: 20px;
  background: var(--surface-container);
  border: 1px solid var(--outline-variant);
  overflow: hidden;
  cursor: pointer;
  animation: rise 0.3s ease-out both;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  user-select: none;
}
.board-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.board-card.selected { border: 2px solid var(--primary); transform: scale(0.97); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.thumb-wrap { position: relative; margin: 6px; border-radius: 14px; overflow: hidden; }
.thumb { aspect-ratio: 16 / 9; background: #fff center / cover no-repeat; }
.thumb.video { background-color: #000; position: relative; }
.thumb.small { width: 112px; flex: none; border-radius: 8px; }
.check { position: absolute; top: 8px; left: 8px; color: var(--primary); background: #fff; border-radius: 50%; display: none; }
.board-card.selected .check { display: flex; }
.play-badge { position: absolute; inset: 0; margin: auto; width: 48px; height: 48px; border-radius: 50%; background: rgba(0, 0, 0, 0.45); color: #fff; display: grid; place-items: center; }
.duration { position: absolute; right: 8px; bottom: 8px; padding: 1px 7px; border-radius: 6px; background: rgba(0, 0, 0, 0.65); color: #fff; font-size: 12px; font-weight: 600; }
.card-info { display: flex; align-items: flex-start; gap: 4px; padding: 2px 4px 10px 12px; }
.card-text { flex: 1; min-width: 0; }
.card-text h3 { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-text p { margin: 2px 0 0; font-size: 13px; color: var(--on-surface-variant); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-chip { display: inline-block; margin-top: 5px; padding: 2px 9px; border-radius: 10px; background: var(--primary-container); color: var(--on-primary-container); font-size: 12px; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.selection-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 4px 6px;
  border-radius: 16px;
  background: var(--primary-container);
  color: var(--on-primary-container);
}
.selection-scroll { display: flex; overflow-x: auto; scrollbar-width: none; margin-left: 8px; }
.selection-actions .btn-text { color: var(--on-primary-container); }

.folder-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 6px 14px 16px;
  border-radius: 16px;
  background: var(--surface-container);
  border: 1px solid var(--outline-variant);
  cursor: pointer;
  transition: box-shadow 0.15s;
}
.folder-card:hover { box-shadow: var(--shadow); }
.folder-icon { display: inline-flex; }

.doubt-card { padding: 16px; border-radius: 16px; background: var(--surface-container); border: 1px solid var(--outline-variant); display: flex; flex-direction: column; gap: 8px; }
.doubt-card.saved { background: var(--secondary-container); }
.doubt-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.doubt-head small { display: block; color: var(--on-surface-variant); }
.status { flex: none; padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; background: var(--surface-container-high); }
.status.positive { background: var(--primary); color: var(--on-primary); }
.question { font-size: 16px; white-space: pre-wrap; margin: 0; }
.reply { padding: 10px 12px; border-radius: 10px; background: var(--primary-container); color: var(--on-primary-container); }
.reply small { font-weight: 600; }
.reply p { margin: 2px 0 0; white-space: pre-wrap; }
.doubt-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; margin: 0 -8px -6px; }

/* Settings */
.settings { max-width: 760px; }
.settings-section { margin-bottom: 22px; }
.settings-section h2 { font-size: 13px; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: 0.04em; margin: 0 0 8px 6px; }
.settings-card { border-radius: 18px; background: var(--surface-container); border: 1px solid var(--outline-variant); overflow: hidden; }
.setting-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 60px;
  padding: 10px 16px;
  border: 0;
  border-top: 1px solid var(--outline-variant);
  background: transparent;
  text-align: left;
  color: var(--on-surface);
  text-decoration: none;
}
.settings-card > :first-child, .settings-card > .section-note + .setting-row { border-top: 0; }
.setting-row.clickable { cursor: pointer; }
.setting-row.clickable:hover { background: var(--surface-container-high); }
.setting-row > .icon:last-child { color: var(--on-surface-variant); }
.row-icon { width: 24px; flex: none; color: var(--on-surface-variant); display: inline-flex; }
.profile-row .row-icon { width: 48px; }
.row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-title { font-weight: 600; }
.row-text small { color: var(--on-surface-variant); }
.section-note { padding: 12px 16px 0; margin: 0; color: var(--on-surface-variant); font-size: 13px; }
.row-pad { padding: 12px 16px; border-top: 1px solid var(--outline-variant); display: flex; flex-direction: column; gap: 8px; color: var(--on-surface-variant); }
.settings-card > .row-pad:first-child { border-top: 0; }
.brand-preview { width: 100%; max-width: 480px; aspect-ratio: 16 / 9; border-radius: 10px; border: 1px solid var(--outline); }
.shortcuts { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 16px; padding: 14px 16px; }
.shortcut { display: flex; align-items: center; gap: 10px; font-size: 14px; }
kbd {
  min-width: 34px;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid var(--outline);
  border-bottom-width: 2px;
  background: var(--surface-container-high);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}

.avatar { display: inline-grid; place-items: center; border-radius: 50%; overflow: hidden; background: var(--primary-container); color: var(--on-primary-container); flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar .icon { opacity: 0.8; transform: translateY(8%); }
.profile-form { display: flex; flex-direction: column; gap: 18px; padding-top: 6px; max-width: 520px; }
.photo-row { display: flex; align-items: center; gap: 16px; }
.photo-btn { position: relative; border: 0; padding: 0; background: none; cursor: pointer; border-radius: 50%; }
.photo-btn .cam { position: absolute; right: 2px; bottom: 2px; width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; }
.crop { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.crop-canvas { border-radius: 12px; touch-action: none; cursor: grab; background: #000; }

.about-hero { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 0 22px; text-align: center; }
.about-hero h2 { font-size: 24px; margin-top: 8px; }
.about-hero p { color: var(--on-surface-variant); margin: 0; }
.made-with-love { font-weight: 600; }
.beat { display: inline-block; animation: beat 1s ease-in-out infinite; }
@keyframes beat { 15% { transform: scale(1.25); } 30% { transform: scale(1); } 45% { transform: scale(1.18); } 60% { transform: scale(1); } }
.rainbow {
  font-weight: 800;
  background: linear-gradient(90deg, #E53935, #FB8C00, #FDD835, #43A047, #1E88E5, #8E24AA, #E53935);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: flow 4s linear infinite;
}
@keyframes flow { to { background-position: 300% 0; } }

/* Recycle bin */
.bin-card { display: flex; flex-direction: column; border-radius: 18px; background: var(--surface-container); border: 1px solid var(--outline-variant); overflow: hidden; transition: transform 0.4s, opacity 0.4s; }
.bin-card .thumb { margin: 6px; border-radius: 12px; }
.bin-card .card-text { padding: 2px 14px; }
.bin-card .card-text p { white-space: normal; }
.kind { font-size: 11px; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: 0.05em; }
.bin-actions { display: flex; gap: 8px; padding: 10px 14px 14px; }
.bin-actions .btn { flex: 1; }
.bin-card.restored { transform: translateY(-24px); opacity: 0; }
.bin-card.discarded { animation: shake 0.25s; transform: scale(0.6) rotate(-8deg) translateY(40px); opacity: 0; }
@keyframes shake { 25% { translate: -6px; } 75% { translate: 6px; } }

/* Video player */
.player { position: fixed; inset: 0; background: #000; display: flex; flex-direction: column; }
.player-bar { display: flex; align-items: center; gap: 6px; padding: 8px 10px; background: rgba(0, 0, 0, 0.75); color: #fff; }
.player-title { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-btn { display: inline-flex; align-items: center; gap: 4px; border: 0; border-radius: 18px; background: transparent; color: #fff; padding: 8px 10px; cursor: pointer; font-weight: 700; }
.player-btn:hover { background: rgba(255, 255, 255, 0.14); }
.player-btn.on { color: #8FB4FF; }
.player-video { flex: 1; min-height: 0; width: 100%; background: #000; }

/* Lock screen */
.lock-screen { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; background: var(--surface); padding: 16px; }
.lock-card { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.lock-icon { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-container); color: var(--on-primary-container); margin-bottom: 6px; }
.pin-dots { display: flex; gap: 14px; margin: 8px 0 16px; }
.pin-dots span { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--on-surface-variant); }
.pin-dots span.on { background: var(--primary); border-color: var(--primary); }
.pin-dots.shake { animation: shake 0.3s 2; }
.keypad { display: grid; grid-template-columns: repeat(3, 72px); gap: 12px; }
.keypad button { height: 64px; border: 0; border-radius: 50%; background: var(--surface-container-high); font-size: 24px; font-weight: 500; cursor: pointer; display: grid; place-items: center; }
.keypad button:hover { background: var(--surface-container-highest); }
.keypad button.quiet { background: transparent; color: var(--on-surface-variant); }
.pin-field { letter-spacing: 0.5em; font-size: 20px; text-align: center; }

/* Opening animation and welcome tour */
.intro {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: linear-gradient(160deg, #2B54E0, #3D6BFF 55%, #5B4BD6);
  color: #fff;
  cursor: pointer;
  transition: opacity 0.35s;
}
.intro.leaving { opacity: 0; }
.intro-logo .i-bg { opacity: 0; }
.intro-logo .i-board { transform-origin: 54px 52px; animation: board-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both 0.15s; }
.intro-logo .i-curve, .intro-logo .i-dash { stroke-dasharray: 1; stroke-dashoffset: 1; }
.intro-logo .i-curve { animation: draw 0.9s ease-in-out forwards 0.65s; }
.intro-logo .i-dash { animation: draw 0.3s ease-out forwards 1.55s; }
@keyframes board-in { from { transform: scale(0); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
.intro-name { font-size: 34px; animation: rise 0.5s ease-out both 1.6s; }
.intro-tag { opacity: 0.85; animation: rise 0.5s ease-out both 1.8s; }
.intro-love { position: absolute; bottom: 36px; }
.intro-love .made-with-love { font-weight: 600; }

.tour { position: fixed; inset: 0; z-index: 250; display: grid; place-items: center; padding: 16px; background: var(--surface); }
.tour-card { position: relative; width: min(560px, 100%); max-height: 100%; overflow-y: auto; padding: 28px 24px 18px; border-radius: 28px; background: var(--surface-container); box-shadow: var(--shadow); }
.tour-skip { position: absolute; top: 10px; right: 10px; }
.tour-page { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; min-height: 330px; animation: rise 0.3s ease-out; }
.tour-page h2 { font-size: 24px; margin-top: 8px; }
.tour-page > p { color: var(--on-surface-variant); }
.tour-page .profile-form { text-align: left; width: 100%; }
.feature-row { display: flex; align-items: flex-start; gap: 14px; text-align: left; width: 100%; }
.feature-row strong { display: block; }
.feature-row p { margin: 0; color: var(--on-surface-variant); font-size: 14px; }
.feature-icon { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--primary-container); color: var(--on-primary-container); flex: none; }
.tour-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 18px; }
.tour-dots { display: flex; gap: 6px; }
.tour-dots span { width: 8px; height: 8px; border-radius: 4px; background: var(--outline); transition: width 0.25s; }
.tour-dots span.on { width: 24px; background: var(--primary); }

/* Passes (Microsoft Store copy only) */
.pass-screen { position: fixed; inset: 0; z-index: 240; display: grid; place-items: center; padding: 16px; background: var(--surface); overflow-y: auto; }
.pass-screen.closable { background: var(--scrim); }
.pass-card { position: relative; width: min(760px, 100%); padding: 28px 24px 18px; border-radius: 28px; background: var(--surface-container); box-shadow: var(--shadow); }
.pass-close { position: absolute; top: 12px; right: 12px; }
.pass-head { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; margin-bottom: 14px; }
.pass-head h2 { font-size: 24px; }
.pass-status { color: var(--on-surface-variant); max-width: 520px; }
.pass-status.ok { color: var(--primary); font-weight: 600; }
.pass-trial { display: flex; margin: 0 auto 18px; height: 48px; padding: 0 28px; font-size: 16px; }
.pass-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.pass-option {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 18px 12px 14px;
  border-radius: 18px;
  border: 1px solid var(--outline-variant);
  background: var(--surface-container-low);
  text-align: center;
}
.pass-option.best { border: 2px solid var(--primary); }
.pass-option strong { font-size: 16px; }
.pass-price { font-size: 26px; font-weight: 800; color: var(--on-surface); }
.pass-option small { color: var(--on-surface-variant); min-height: 2.6em; }
.pass-option .btn { margin-top: 6px; width: 100%; }
.pass-badge { position: absolute; top: -11px; padding: 2px 10px; border-radius: 10px; background: var(--primary); color: var(--on-primary); font-size: 11px; font-weight: 700; }
.pass-note { margin: 14px 0 0; text-align: center; color: var(--on-surface-variant); font-size: 13px; }
.pass-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* ---------------- Phones and narrow windows ---------------- */

@media (max-width: 760px) {
  .side-nav { display: none; }
  .home { flex-direction: column; }
  .page { padding: 0 14px; }
  .page-body { padding-bottom: 96px; }
  .screen-header { padding-top: 14px; }
  .header-text h1 { font-size: 22px; }
  .header-actions .btn { padding: 0 12px; }
  .pill-toggle { align-self: stretch; }
  .pill-toggle button { flex: 1; justify-content: center; padding: 8px; }
  .card-grid { gap: 10px; }
  .card-grid.boards, .card-grid.videos, .card-grid.folders { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .card-grid.doubts, .card-grid.bin { grid-template-columns: 1fr; }
  .bottom-nav {
    position: fixed;
    left: 14px;
    right: 14px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 20;
    display: flex;
    align-items: center;
    height: 64px;
    padding: 0 6px;
    border-radius: 30px;
    background: color-mix(in srgb, var(--surface-container-high) 97%, transparent);
    border: 1px solid var(--outline-variant);
    box-shadow: var(--shadow);
  }
  .bottom-nav .nav-item { flex: 1; flex-direction: column; gap: 2px; padding: 4px 0; border-radius: 22px; font-size: 11px; background: none; }
  .bottom-nav .nav-item .nav-icon { padding: 3px 16px; border-radius: 15px; }
  .bottom-nav .nav-item.active { background: none; color: var(--primary); }
  .bottom-nav .nav-item.active .nav-icon { background: var(--primary-container); }
  .bottom-nav .plus { width: 56px; height: 46px; margin: 0 4px; border: 0; border-radius: 20px; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; box-shadow: var(--shadow); cursor: pointer; }
  .setting-row { flex-wrap: wrap; }
  .setting-row .segmented { margin-left: 38px; }
  .toast-host { bottom: 96px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
