/* LoraGPT — liquid glass interface over a plain, themeable whiteboard. */

/* ───────────── tokens ───────────── */
:root {
  --ui-font: 'Readex Pro', 'Noto Sans Arabic', system-ui, 'Segoe UI', Tahoma, sans-serif;
  --board-font: 'Playpen Sans Arabic', 'Noto Sans Arabic', 'Segoe UI', Tahoma, sans-serif;

  --accent: #2F6BFF;
  --accent-2: #2F6BFF;
  --accent-soft: rgb(47 107 255 / 0.12);
  --grad: linear-gradient(#2F6BFF, #2F6BFF);

  --ink: #14161c;
  --ink-2: #4b505c;
  --ink-3: #8b909c;
  --line: rgb(20 22 28 / 0.09);

  --board-bg: #F6F7F9;
  --dot: transparent;
  --accent-ink: #ffffff;
  --glow: 0 10px 24px -12px rgb(47 107 255 / 0.75);
  --aura-a: rgb(255 154 31 / 0.16);
  --aura-b: rgb(120 110 255 / 0.13);
  --aura-c: rgb(40 200 170 / 0.12);

  --glass-top: rgb(255 255 255 / 0.74);
  --glass-bot: rgb(255 255 255 / 0.44);
  --glass-clear: rgb(255 255 255 / 0.3);
  --glass-rim: rgb(255 255 255 / 0.85);
  --glass-edge: rgb(255 255 255 / 0.5);
  --glass-shadow: 0 1px 1px rgb(16 20 32 / 0.05), 0 10px 26px -8px rgb(16 20 32 / 0.2), 0 30px 60px -24px rgb(16 20 32 / 0.22);
  --glass-solid: #ffffff;
  --scrim: rgb(240 238 232 / 0.55);
  --field: rgb(20 22 28 / 0.055);
  --field-hover: rgb(20 22 28 / 0.09);

  /* board ink */
  --b-ink: #1b1e26; --b-mute: #7a8090; --b-blue: #2563eb; --b-green: #169c48; --b-orange: #e8770f;
  --b-red: #e03a3a; --b-purple: #7a4bfa; --b-teal: #0c9488; --b-pink: #df3f8e; --b-accent: #2F6BFF;
  --b-hl: rgb(255 212 60 / 0.62); --b-grid: rgb(20 22 28 / 0.12);

  --r-pill: 999px;
  --ease: cubic-bezier(0.22, 0.9, 0.26, 1);
  --top: max(12px, env(safe-area-inset-top));
  --bottom: max(14px, env(safe-area-inset-bottom));
  color-scheme: light;
}

[data-mode='dark'] {
  --ink: #f2f0e8;
  --ink-2: #c4c6c2;
  --ink-3: #8c918f;
  --line: rgb(255 255 255 / 0.1);
  --dot: transparent;
  --aura-a: rgb(255 154 31 / 0.1);
  --aura-b: rgb(120 110 255 / 0.12);
  --aura-c: rgb(40 200 170 / 0.09);
  --glass-top: rgb(58 66 68 / 0.62);
  --glass-bot: rgb(26 32 32 / 0.5);
  --glass-clear: rgb(40 48 48 / 0.34);
  --glass-rim: rgb(255 255 255 / 0.26);
  --glass-edge: rgb(255 255 255 / 0.12);
  --glass-shadow: 0 1px 1px rgb(0 0 0 / 0.3), 0 12px 30px -8px rgb(0 0 0 / 0.55), 0 30px 60px -24px rgb(0 0 0 / 0.6);
  --glass-solid: #222a29;
  --scrim: rgb(8 12 11 / 0.6);
  --field: rgb(255 255 255 / 0.08);
  --field-hover: rgb(255 255 255 / 0.13);
  --b-ink: #f1efe6; --b-mute: #98a19e; --b-blue: #8dbbff; --b-green: #7fe3a6; --b-orange: #ffb86b;
  --b-red: #ff8f8f; --b-purple: #c9b3ff; --b-teal: #70e2d1; --b-pink: #ff9fd0;
  --b-hl: rgb(255 214 64 / 0.3); --b-grid: rgb(255 255 255 / 0.12);
  color-scheme: dark;
}

/* ───────────── base ───────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body {
  font-family: var(--ui-font);
  color: var(--ink);
  background: var(--board-bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: background-color 0.5s ease, color 0.4s ease;
}
button, input, select { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; padding: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; }
.defs { position: absolute; width: 0; height: 0; }

/* ───────────── the board ───────────── */
.stage {
  position: fixed; inset: 0; overflow: hidden;
  touch-action: none;
  cursor: grab;
  --gx: 0px; --gy: 0px; --gs: 30px;
  background:
    var(--board-bg);
  transition: background-color 0.5s ease;
}
.stage.grabbing { cursor: grabbing; }
.stage[data-tool='pen'], .stage[data-tool='marker'] { cursor: crosshair; }
.stage[data-tool='eraser'] { cursor: cell; }

.board-svg { position: absolute; left: 0; top: 0; overflow: visible; display: block; transform-origin: 0 0; }
.board-grid {
  position: absolute; left: 0; top: 0; width: calc(100% + 140px); height: calc(100% + 140px); pointer-events: none;
  background: radial-gradient(circle at 1.2px 1.2px, var(--dot) 1.2px, transparent 1.7px) 0 0 / 30px 30px;
  will-change: transform;
}
.board-svg .st { stroke-linecap: round; stroke-linejoin: round; }
.bt { font-family: var(--board-font); }
.emoji { font-family: 'Noto Color Emoji', 'Apple Color Emoji', 'Segoe UI Emoji', sans-serif; }
.pop { transform-box: fill-box; transform-origin: center; }
.board-svg text.speak { cursor: pointer; }
.board-svg text.speak:hover { text-decoration: underline dotted 2px; text-underline-offset: 6px; }
.halo { paint-order: stroke; stroke: var(--board-bg); stroke-width: 6px; stroke-linejoin: round; }

.st-ink { stroke: var(--b-ink); } .st-mute { stroke: var(--b-mute); } .st-blue { stroke: var(--b-blue); }
.st-green { stroke: var(--b-green); } .st-orange { stroke: var(--b-orange); } .st-red { stroke: var(--b-red); }
.st-purple { stroke: var(--b-purple); } .st-teal { stroke: var(--b-teal); } .st-pink { stroke: var(--b-pink); }
.st-accent { stroke: var(--b-accent); } .st-hl { stroke: var(--b-hl); stroke-linecap: butt !important; } .st-grid { stroke: var(--b-grid); }
.st-yellow { stroke: #f5c400; }

.fl-ink { fill: var(--b-ink); } .fl-mute { fill: var(--b-mute); } .fl-blue { fill: var(--b-blue); }
.fl-green { fill: var(--b-green); } .fl-orange { fill: var(--b-orange); } .fl-red { fill: var(--b-red); }
.fl-purple { fill: var(--b-purple); } .fl-teal { fill: var(--b-teal); } .fl-pink { fill: var(--b-pink); }
.fl-accent { fill: var(--b-accent); }

.tx-ink { fill: var(--b-ink); } .tx-mute { fill: var(--b-mute); } .tx-blue { fill: var(--b-blue); }
.tx-green { fill: var(--b-green); } .tx-orange { fill: var(--b-orange); } .tx-red { fill: var(--b-red); }
.tx-purple { fill: var(--b-purple); } .tx-teal { fill: var(--b-teal); } .tx-pink { fill: var(--b-pink); }
.tx-accent { fill: var(--b-accent); }

.quiz-hit { fill: transparent; cursor: pointer; transition: fill 0.15s ease; outline: none; }
.quiz-hit:hover, .quiz-hit:focus-visible { fill: color-mix(in srgb, var(--b-accent) 10%, transparent); }
.quiz-hit:active { fill: color-mix(in srgb, var(--b-accent) 18%, transparent); }
.answered .quiz-hit { pointer-events: none; fill: transparent; }
.photo-frame { fill: #fff; stroke: rgb(0 0 0 / 0.1); filter: drop-shadow(0 8px 16px rgb(0 0 0 / 0.18)); }
.photo-tape { fill: rgb(255 214 110 / 0.8); }
.annot-pen, .annot-marker { stroke-linecap: round; stroke-linejoin: round; }
.annot-marker { stroke-opacity: 0.34; }

/* The tutor's pen */
#pen {
  position: absolute; left: 0; top: 0; width: 0; height: 0;
  pointer-events: none; will-change: transform;
  opacity: 0; transition: opacity 0.3s ease;
  z-index: 2;
}
#pen[data-mode='write'], #pen[data-mode='think'], #pen[data-mode='rest'] { opacity: 1; }
.pen-glow {
  position: absolute; left: -11px; top: -11px; width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle, rgb(255 110 60 / 0.75), rgb(255 110 60 / 0) 68%);
}
.pen-body {
  position: absolute; left: -2px; top: -46px; width: 46px; height: 46px;
  transform-origin: 2px 44px;
  filter: drop-shadow(0 6px 8px rgb(20 20 30 / 0.28));
}
#pen[data-mode='write'] .pen-body { animation: pen-write 0.24s ease-in-out infinite alternate; }
#pen[data-mode='think'] .pen-body { animation: pen-think 1.5s ease-in-out infinite; }
#pen[data-mode='think'] .pen-glow { animation: pulse 1.5s ease-in-out infinite; }
@keyframes pen-write { from { transform: rotate(-4deg); } to { transform: rotate(5deg) translateY(-1px); } }
@keyframes pen-think { 0%, 100% { transform: translateY(-3px) rotate(-3deg); } 50% { transform: translateY(-11px) rotate(4deg); } }
@keyframes pulse { 0%, 100% { transform: scale(0.8); opacity: 0.6; } 50% { transform: scale(1.5); opacity: 1; } }

/* ───────────── liquid glass ───────────── */
.glass {
  position: relative;
  isolation: isolate;
  background: linear-gradient(180deg, var(--glass-top), var(--glass-bot));
  -webkit-backdrop-filter: blur(22px) saturate(185%);
  backdrop-filter: blur(22px) saturate(185%);
  box-shadow:
    inset 0 1px 0 0 var(--glass-rim),
    inset 0 -1px 0.5px 0 var(--glass-edge),
    inset 0 0 0 1px var(--glass-edge),
    inset 0 10px 18px -12px rgb(255 255 255 / 0.5),
    var(--glass-shadow);
}
/* A soft specular sweep, as if lit from the top-left. */
.glass::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: -1;
  background:
    radial-gradient(120% 90% at 12% -20%, rgb(255 255 255 / 0.5), transparent 46%),
    radial-gradient(90% 70% at 100% 130%, rgb(255 255 255 / 0.2), transparent 50%);
  opacity: 0.9;
}
[data-mode='dark'] .glass::before { opacity: 0.22; }
/* Chromium: real refraction at the rim (filter is injected by liquid.js). */
.glass.liquid { background: linear-gradient(180deg, var(--glass-clear), color-mix(in srgb, var(--glass-clear) 70%, transparent)); }

[data-glass='calm'] .glass, [data-glass='calm'] .glass.liquid {
  -webkit-backdrop-filter: none !important; backdrop-filter: none !important;
  background: var(--glass-solid);
}

/* ───────────── top bar ───────────── */
.topbar {
  position: fixed; top: var(--top); inset-inline: 12px; z-index: 20;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
  pointer-events: none;
}
.pill { pointer-events: auto; display: flex; align-items: center; border-radius: var(--r-pill); height: 50px; padding: 0 6px; }
.brand { gap: 10px; padding: 0 16px 0 18px; min-width: 0; max-width: min(56vw, 520px); }
.logo { width: 30px; height: 30px; flex: none; border-radius: 10px; display: grid; place-items: center; background: var(--grad); color: var(--accent-ink); box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.45), 0 4px 10px -3px var(--accent-soft); }
.logo svg { width: 22px; height: 22px; }
.brand b { font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.lesson-title { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--ink-2); font-size: 14.5px; }
.lesson-title::before { content: ''; width: 1px; height: 18px; background: var(--line); flex: none; }
.lesson-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ibtn {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none;
  color: var(--ink-2);
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.12s ease-out;
}
.ibtn svg { width: 21px; height: 21px; }
.ibtn:hover { background: var(--field); color: var(--ink); }
.ibtn:active { transform: scale(0.92); background: var(--field-hover); }
.ibtn.on { background: var(--accent-soft); color: var(--accent); }
.ibtn[disabled] { opacity: 0.35; pointer-events: none; }
.tools { gap: 2px; }

/* ───────────── side tools ───────────── */
.side {
  position: fixed; left: 12px; top: calc(var(--top) + 62px); z-index: 15;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px; border-radius: 28px;
}
.side hr { width: 22px; border: 0; border-top: 1px solid var(--line); margin: 5px 0; }
.swatches { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 6px 4px; }
.swatch { width: 15px; height: 15px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.12); transition: transform 0.15s var(--ease); }
.swatch.on { transform: scale(1.3); box-shadow: 0 0 0 2px var(--glass-solid), 0 0 0 4px var(--c); }
.side { max-height: calc(100dvh - var(--top) - 62px - 200px); overflow-y: auto; scrollbar-width: none; }
.side::-webkit-scrollbar { display: none; }
.side .ink-only { display: none; }
.side.inking .zoom-only, .side.inking .zoom-label { display: none; }
.side.inking .ink-only { display: grid; }
.side.inking .swatches.ink-only { display: grid; }
.zoom-label { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; padding: 2px 0 4px; direction: ltr; }

.follow-chip {
  position: fixed; top: calc(var(--top) + 62px); left: 50%; z-index: 18;
  transform: translate(-50%, -12px) scale(0.96); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px 0 14px; border-radius: var(--r-pill);
  font-size: 14px; font-weight: 500; color: var(--ink);
  transition: transform 0.35s var(--ease), opacity 0.25s ease;
}
.follow-chip svg { width: 17px; height: 17px; color: var(--accent); }
.follow-chip.show { transform: translate(-50%, 0) scale(1); opacity: 1; pointer-events: auto; }

/* ───────────── hero (empty board) ───────────── */
.hero {
  position: fixed; inset: 0; z-index: 5; pointer-events: none;
  display: grid; place-items: center;
  padding: calc(var(--top) + 64px) 20px calc(var(--bottom) + 96px);
  transition: opacity 0.4s ease, transform 0.5s var(--ease), filter 0.4s ease;
}
.hero.gone { opacity: 0; transform: scale(0.97) translateY(-10px); filter: blur(6px); visibility: hidden; transition: opacity 0.3s ease, transform 0.4s var(--ease), filter 0.3s ease, visibility 0s 0.4s; }
.hero-inner { width: min(860px, 100%); max-height: 100%; overflow-y: auto; scrollbar-width: none; text-align: center; pointer-events: auto; padding: 4px 14px 30px; -webkit-mask-image: linear-gradient(#000 calc(100% - 30px), transparent); mask-image: linear-gradient(#000 calc(100% - 30px), transparent); }
.hero-inner::-webkit-scrollbar { display: none; }
.hero-badge { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px; border-radius: var(--r-pill); font-size: 13px; color: var(--ink-2); margin-bottom: 18px; }
.hero-badge svg { width: 15px; height: 15px; color: var(--accent); }
.hero-title {
  font-family: var(--board-font); font-weight: 800; margin: 0;
  font-size: clamp(2rem, 5.4vw, 3.9rem); line-height: 1.38; letter-spacing: -0.012em;
  color: var(--b-ink);
}
.hero-title em { font-style: normal; position: relative; display: inline-block; color: var(--accent); }
.hero-title em svg { position: absolute; inset-inline: -2%; bottom: -0.18em; width: 104%; height: 0.32em; overflow: visible; }
.hero-title em path { fill: none; stroke: var(--accent-2); stroke-width: 5; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 0.9s 0.35s var(--ease) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.hero-sub { margin: 16px auto 0; max-width: 560px; color: var(--ink-2); font-size: clamp(0.95rem, 1.6vw, 1.08rem); line-height: 1.9; font-weight: 300; }
.hero-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 24px; }
.chip {
  height: 40px; padding: 0 16px; border-radius: var(--r-pill); font-size: 14.5px; color: var(--ink);
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  transition: transform 0.14s ease-out, box-shadow 0.2s ease;
}
.chip svg { width: 16px; height: 16px; color: var(--accent); flex: none; }
.chip:hover { transform: translateY(-1.5px); }
.chip:active { transform: scale(0.96); }
.chip.strong { background: var(--grad); color: var(--accent-ink); font-weight: 500; box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.4), 0 10px 22px -8px var(--accent-soft); -webkit-backdrop-filter: none; backdrop-filter: none; }
.chip.strong::before { display: none; }
.chip.strong svg { color: var(--accent-ink); }

.hero-label { margin: 30px 0 12px; font-size: 13px; color: var(--ink-3); display: flex; align-items: center; justify-content: center; gap: 12px; }
.hero-label::before, .hero-label::after { content: ''; height: 1px; width: 54px; background: var(--line); }
.hero-demos { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: 10px; }
.demo {
  border-radius: 22px; padding: 14px 16px; text-align: start; display: flex; align-items: center; gap: 12px;
  transition: transform 0.16s ease-out;
}
.demo:hover { transform: translateY(-2px); }
.demo:active { transform: scale(0.97); }
.demo-emoji { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; font-size: 22px; background: var(--field); flex: none; }
.demo b { display: block; font-weight: 600; font-size: 14.5px; line-height: 1.5; }
.demo small { color: var(--ink-3); font-size: 12.5px; }

/* ───────────── bottom cluster ───────────── */
.bottom {
  position: fixed; bottom: var(--bottom); left: 50%; transform: translateX(-50%); z-index: 20;
  width: min(760px, calc(100vw - 24px));
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  pointer-events: none;
}
.bottom > * { pointer-events: auto; }

.suggest { display: flex; gap: 8px; max-width: 100%; overflow-x: auto; scrollbar-width: none; padding: 4px 14px; -webkit-mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 14px), transparent); mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 14px), transparent); }
.suggest::-webkit-scrollbar { display: none; }
.suggest:empty { display: none; }
.suggest .chip { height: 38px; font-size: 14px; animation: rise 0.45s var(--ease) both; }
@keyframes rise { from { transform: translateY(8px); } }

.caption {
  width: 100%; border-radius: 24px; padding: 12px 14px 10px;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px 6px;
  animation: rise 0.4s var(--ease) both;
}
.cap-text {
  margin: 0; grid-column: 2; text-align: center; font-size: 16.5px; line-height: 1.85; font-weight: 400; color: var(--ink);
  min-height: 1.85em; max-height: 5.55em; overflow: hidden; text-wrap: balance;
}
.cap-text .w { color: var(--ink-3); transition: color 0.18s ease; }
.cap-text .w.said { color: var(--ink); }
.cap-text .w.now { color: var(--accent); }
.cap-text.status { color: var(--ink-2); font-weight: 300; }
.dots { display: inline-flex; gap: 4px; margin-inline-start: 8px; vertical-align: middle; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); animation: dot 1.1s ease-in-out infinite; }
.dots i:nth-child(2) { animation-delay: 0.15s; } .dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot { 0%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
[data-captions='off'] .cap-text:not(.status) { display: none; }

.progress { grid-column: 1 / -1; display: flex; gap: 3px; padding: 6px 4px 2px; direction: rtl; }
.seg { flex: 1; height: 14px; display: flex; align-items: center; min-width: 3px; }
.seg i { display: block; width: 100%; height: 4px; border-radius: 4px; background: var(--field-hover); transition: background-color 0.25s ease, height 0.2s var(--ease); }
.seg:hover i { height: 8px; }
.seg.done i { background: color-mix(in srgb, var(--accent) 55%, transparent); }
.seg.now i { background: var(--accent); height: 6px; }
.seg.fu.done i, .seg.fu.now i { background: #7a4bfa; }
.cap-side { display: flex; flex-direction: column; gap: 0; }
.tbtn { height: 30px; min-width: 34px; padding: 0 6px; border-radius: 10px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); display: grid; place-items: center; direction: ltr; font-variant-numeric: tabular-nums; transition: background-color 0.15s, transform 0.12s; }
.tbtn svg { width: 18px; height: 18px; }
.tbtn:hover { background: var(--field); color: var(--ink); }
.tbtn:active { transform: scale(0.92); }
.tbtn.on { color: var(--accent); }

.dockrow { width: 100%; display: flex; align-items: center; gap: 10px; }
.orb {
  width: 60px; height: 60px; border-radius: 50%; flex: none; display: grid; place-items: center; color: var(--ink);
  transition: transform 0.14s ease-out;
}
.orb svg { width: 24px; height: 24px; }
.orb:active { transform: scale(0.93); }
.orb.busy svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.dock {
  flex: 1; min-width: 0; height: 60px; border-radius: 30px; padding: 0 8px;
  display: flex; align-items: center; gap: 4px;
  transition: box-shadow 0.3s ease;
}
.dock:focus-within { box-shadow: inset 0 1px 0 0 var(--glass-rim), inset 0 0 0 1px var(--glass-edge), 0 0 0 4px var(--accent-soft), var(--glass-shadow); }
.dock input[type='text'] {
  flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none;
  font-size: 16.5px; padding: 0 8px; user-select: text;
}
.dock input::placeholder { color: var(--ink-3); font-weight: 300; }
.dbtn {
  width: 44px; height: 44px; border-radius: 50%; flex: none; display: grid; place-items: center; color: var(--ink-2);
  transition: background-color 0.18s ease, transform 0.12s ease-out, color 0.18s;
}
.dbtn svg { width: 22px; height: 22px; }
.dbtn:hover { background: var(--field); color: var(--ink); }
.dbtn:active { transform: scale(0.9); }
.dbtn.primary { background: var(--grad); color: var(--accent-ink); box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.45), 0 8px 18px -6px var(--accent-soft); }
.dbtn.primary:hover { color: var(--accent-ink); filter: brightness(1.06); }
.dbtn.stop { background: var(--ink); color: var(--board-bg); }

.thumb { position: relative; width: 44px; height: 44px; flex: none; border-radius: 13px; overflow: hidden; box-shadow: 0 0 0 1.5px var(--glass-rim), 0 4px 10px rgb(0 0 0 / 0.2); animation: rise 0.3s var(--ease) both; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button { position: absolute; inset: 0; display: grid; place-items: center; background: rgb(0 0 0 / 0.45); color: #fff; opacity: 0; transition: opacity 0.15s; }
.thumb:hover button, .thumb button:focus-visible { opacity: 1; }
.thumb svg { width: 18px; height: 18px; }

/* recording */
.rec { display: none; flex: 1; min-width: 0; align-items: center; gap: 10px; height: 100%; }
.dock.recording { background: var(--accent); color: var(--accent-ink); box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.5), 0 14px 34px -10px var(--accent-soft); }
.dock.recording > :not(.rec) { display: none; }
.dock.recording .rec { display: flex; }
.dock.recording .dbtn { color: var(--accent-ink); }
.dock.recording .dbtn:hover { background: rgb(255 255 255 / 0.2); }
.dock.recording .dbtn.ok { background: #fff; color: var(--accent); }
.rec canvas { flex: 1; min-width: 0; height: 40px; }
.rec time { font-variant-numeric: tabular-nums; font-size: 14.5px; font-weight: 500; direction: ltr; min-width: 38px; text-align: center; }
.rec-dot { width: 9px; height: 9px; border-radius: 50%; background: #fff; animation: pulse 1.1s ease-in-out infinite; flex: none; }
.rec-hint {
  position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%); max-width: 92%;
  padding: 9px 16px; border-radius: 16px; font-size: 14.5px; line-height: 1.7; text-align: center; color: var(--ink);
  animation: rise 0.3s var(--ease) both; pointer-events: none;
}
.dockwrap { position: relative; flex: 1; min-width: 0; display: flex; }

/* ───────────── menus, sheets, toasts ───────────── */
.menu {
  position: fixed; z-index: 60; min-width: 230px; padding: 7px; border-radius: 22px;
  transform-origin: var(--ox, 50%) var(--oy, 0%);
  animation: menu-in 0.26s var(--ease) both;
}
.menu.out { animation: menu-out 0.16s ease-in both; }
@keyframes menu-in { from { opacity: 0; transform: scale(0.9); filter: blur(6px); } }
@keyframes menu-out { to { opacity: 0; transform: scale(0.94); filter: blur(4px); } }
.mi { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 15px; font-size: 14.5px; text-align: start; transition: background-color 0.14s; }
.mi svg { width: 19px; height: 19px; color: var(--ink-2); flex: none; }
.mi:hover, .mi:focus-visible { background: var(--field); }
.mi:active { background: var(--field-hover); }
.mi small { display: block; color: var(--ink-3); font-size: 12px; margin-top: 1px; }
.menu-note { padding: 8px 12px 6px; font-size: 12px; color: var(--ink-3); line-height: 1.7; }

.scrim { position: fixed; inset: 0; z-index: 70; background: var(--scrim); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); opacity: 0; transition: opacity 0.3s ease; display: grid; place-items: center; padding: 16px; }
.scrim.show { opacity: 1; }
.sheet {
  width: min(600px, 100%); max-height: min(86vh, 780px); border-radius: 32px; display: flex; flex-direction: column; overflow: hidden;
  transform: translateY(26px) scale(0.97); opacity: 0; filter: blur(8px);
  transition: transform 0.42s var(--ease), opacity 0.26s ease, filter 0.3s ease;
}
.scrim.show .sheet { transform: none; opacity: 1; filter: none; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px 12px 14px; flex: none; }
.sheet-head h2 { margin: 0; font-size: 19px; font-weight: 700; flex: 1; letter-spacing: -0.01em; }
.sheet-body { overflow-y: auto; padding: 4px 20px 22px; user-select: text; scrollbar-width: thin; }
.sec { margin-top: 20px; }
.sec:first-child { margin-top: 4px; }
.sec h3 { margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--ink-3); letter-spacing: 0.01em; }
.sec p.help { margin: 8px 0 0; font-size: 13px; line-height: 1.85; color: var(--ink-2); font-weight: 300; }
.opts { display: flex; flex-wrap: wrap; gap: 7px; }
.opt { height: 38px; padding: 0 15px; border-radius: var(--r-pill); background: var(--field); font-size: 14px; transition: background-color 0.15s, color 0.15s, transform 0.12s; display: inline-flex; align-items: center; gap: 7px; }
.opt:hover { background: var(--field-hover); }
.opt:active { transform: scale(0.95); }
.opt.on { background: var(--accent); color: var(--accent-ink); font-weight: 500; }
.opt svg { width: 16px; height: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.row + .row { margin-top: 10px; }
.field { flex: 1; min-width: 0; height: 44px; border-radius: 14px; border: 0; outline: 0; background: var(--field); padding: 0 14px; font-size: 14.5px; direction: ltr; text-align: left; user-select: text; }
.field:focus { box-shadow: 0 0 0 2.5px var(--accent-soft), inset 0 0 0 1.5px var(--accent); }
select.field { direction: rtl; text-align: right; appearance: none; }
.btn { height: 44px; padding: 0 18px; border-radius: 14px; background: var(--field); font-size: 14.5px; font-weight: 500; white-space: nowrap; transition: background-color 0.15s, transform 0.12s, filter 0.15s; display: inline-flex; align-items: center; gap: 8px; }
.btn:hover { background: var(--field-hover); }
.btn:active { transform: scale(0.96); }
.btn.primary { background: var(--grad); color: var(--accent-ink); box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.4), 0 8px 18px -8px var(--accent-soft); }
.btn.primary:hover { filter: brightness(1.06); }
.btn svg { width: 18px; height: 18px; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.card { border-radius: 18px; padding: 12px 14px; background: var(--field); text-align: start; transition: background-color 0.15s, box-shadow 0.15s, transform 0.12s; }
.card:active { transform: scale(0.97); }
.card b { display: flex; align-items: center; gap: 8px; font-size: 14.5px; font-weight: 600; }
.card small { display: block; margin-top: 4px; font-size: 12.3px; line-height: 1.7; color: var(--ink-2); font-weight: 300; }
.card.on { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
.badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: rgb(22 156 72 / 0.14); color: #16803c; }
[data-mode='dark'] .badge { color: #7fe3a6; }
.note-box { border-radius: 18px; padding: 12px 14px; background: var(--accent-soft); font-size: 13.5px; line-height: 1.9; color: var(--ink); }
.note-box a { color: var(--accent); font-weight: 500; }
.result { font-size: 13.5px; line-height: 1.8; margin-top: 10px; }
.result.ok { color: #16803c; } .result.bad { color: var(--b-red); }
[data-mode='dark'] .result.ok { color: #7fe3a6; }
.kbd { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 13.5px; color: var(--ink-2); align-items: center; }
kbd { font-family: ui-monospace, monospace; font-size: 12px; background: var(--field); border-radius: 7px; padding: 3px 8px; direction: ltr; display: inline-block; }

/* library */
.lib-list { display: flex; flex-direction: column; gap: 6px; }
.lib-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 18px; text-align: start; transition: background-color 0.15s; width: 100%; }
.lib-item:hover { background: var(--field); }
.lib-item .demo-emoji { width: 44px; height: 44px; }
.lib-item .meta { flex: 1; min-width: 0; }
.lib-item > svg { width: 18px; height: 18px; flex: none; color: var(--ink-3); margin-inline-end: 10px; }
.lib-item b { display: block; font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-item small { color: var(--ink-3); font-size: 12.5px; }
.empty { text-align: center; color: var(--ink-3); font-size: 14px; line-height: 2; padding: 26px 10px; font-weight: 300; }

.toasts { position: fixed; top: calc(var(--top) + 62px); left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; width: min(520px, calc(100vw - 24px)); }
.toast { padding: 11px 18px; border-radius: 18px; font-size: 14.5px; line-height: 1.7; text-align: center; animation: toast-in 0.4s var(--ease) both; pointer-events: auto; }
.toast.out { animation: menu-out 0.25s ease-in both; }
.toast.err { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--b-red) 60%, transparent), var(--glass-shadow); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-14px) scale(0.94); filter: blur(6px); } }

.drop-veil { position: fixed; inset: 12px; z-index: 80; border-radius: 34px; display: grid; place-items: center; font-size: 20px; font-weight: 600; color: var(--accent); border: 2.5px dashed var(--accent); background: color-mix(in srgb, var(--board-bg) 78%, transparent); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); pointer-events: none; opacity: 0; transition: opacity 0.2s; }
.drop-veil.show { opacity: 1; }

/* ───────────── small screens ───────────── */
@media (max-width: 720px) {
  .pill { height: 46px; }
  .brand { padding: 0 12px 0 14px; max-width: 46vw; }
  .brand b { font-size: 16px; }
  .ibtn { width: 38px; height: 38px; }
  .tools .wide-only { display: none; }
  .side { left: 8px; top: calc(var(--top) + 56px); padding: 4px; border-radius: 24px; }
  .side .zoom-only, .zoom-label { display: none; }
  .orb { width: 54px; height: 54px; }
  .dock { height: 54px; border-radius: 27px; padding: 0 6px; }
  .dbtn { width: 42px; height: 42px; }
  .cap-text { font-size: 15px; max-height: 5.4em; }
  .caption { padding: 10px 10px 8px; border-radius: 22px; }
  .hero { padding-bottom: calc(var(--bottom) + 84px); align-items: start; }
  .hero-demos { grid-template-columns: 1fr 1fr; }
  .demo { padding: 11px 12px; border-radius: 18px; gap: 10px; }
  .demo-emoji { width: 36px; height: 36px; font-size: 19px; border-radius: 12px; }
  .hero-chips { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; scrollbar-width: none; margin-inline: -20px; padding-inline: 20px; }
  .scrim { place-items: end center; padding: 0; }
  .sheet { border-radius: 30px 30px 0 0; max-height: 90vh; width: 100%; transform: translateY(100%); filter: none; opacity: 1; }
  .sheet-body { padding-bottom: calc(22px + env(safe-area-inset-bottom)); }
}
/* Short windows: keep the ready-made lessons above the fold. */
@media (max-height: 800px) and (min-width: 721px) {
  .hero-title { font-size: clamp(1.9rem, 4.4vw, 3rem); line-height: 1.34; }
  .hero-badge { margin-bottom: 10px; }
  .hero-sub { margin-top: 10px; font-size: 0.95rem; line-height: 1.75; }
  .hero-chips { margin-top: 16px; }
  .hero-chips .chip:nth-child(n + 4) { display: none; }
  .hero-label { margin: 18px 0 10px; }
}
@media (max-height: 560px) {
  .hero-sub, .hero-label, .hero-demos { display: none; }
}

/* ───────────── accessibility ───────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.12s !important; }
  .hero-title em path { stroke-dashoffset: 0; }
}
@media (prefers-reduced-transparency: reduce) {
  .glass, .glass.liquid { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; background: var(--glass-solid); }
}
@media (prefers-contrast: more) {
  .glass, .glass.liquid { background: var(--glass-solid); box-shadow: 0 0 0 2px var(--ink); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media print {
  .topbar, .bottom, .side, .hero, .follow-chip, #pen, .toasts { display: none !important; }
}

/* ───────────── new pieces, in the original look ───────────── */

.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #22b35e; flex: none; box-shadow: 0 0 0 0 rgb(34 179 94 / 0.55); animation: live 2.2s ease-out infinite; }
@keyframes live { to { box-shadow: 0 0 0 8px rgb(34 179 94 / 0); } }

/* Quick-start tiles on the empty board */
.hero-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 24px; }
.tile {
  border-radius: 22px; padding: 14px 14px 13px; text-align: start; display: grid; gap: 2px; align-content: start;
  transition: transform 0.16s ease-out; animation: rise 0.5s var(--ease) both; animation-delay: calc(var(--i, 0) * 60ms + 100ms);
}
.tile:hover { transform: translateY(-2px); }
.tile:active { transform: scale(0.97); }
.tile-ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; margin-bottom: 8px; background: var(--accent-soft); color: var(--accent); }
.tile-ic svg { width: 20px; height: 20px; }
.tile b { font-size: 14.5px; font-weight: 600; }
.tile small { font-size: 12.3px; line-height: 1.65; color: var(--ink-3); font-weight: 400; }
.hero-chips { margin-top: 16px; }
.demo { animation: rise 0.5s var(--ease) both; animation-delay: calc(var(--i, 0) * 50ms + 260ms); min-width: 0; }
.hero-demos { grid-template-columns: repeat(4, 1fr); }
.demo > span:last-child { min-width: 0; }
.demo b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1000px) { .hero-demos { grid-template-columns: 1fr 1fr; } }

/* Subject badges (replace emoji everywhere) */
.subj { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; flex: none; color: var(--tone); background: color-mix(in srgb, var(--tone) 13%, transparent); }
.subj svg { width: 21px; height: 21px; }
.lesson-title .subj { width: 24px; height: 24px; border-radius: 8px; }
.lesson-title .subj svg { width: 14px; height: 14px; }
.lib-item > svg { width: 18px; height: 18px; flex: none; color: var(--ink-3); margin-inline-end: 10px; }

/* Experiments on the board */
.lab-hit { cursor: ew-resize; touch-action: none; }
.lab-knob { stroke: var(--board-bg); stroke-width: 3; filter: drop-shadow(0 2px 3px rgb(0 0 0 / 0.22)); }
.lab-slider.drag .lab-knob { r: 14; }

/* PDF page picker */
.pdf-top { position: sticky; top: -4px; z-index: 2; padding: 6px 4px 10px; margin: 0 -4px; background: linear-gradient(var(--glass-solid) 72%, transparent); }
.pdf-count { flex: 1; font-size: 13.5px; color: var(--ink-2); }
.pdf-top .btn { height: 36px; padding: 0 13px; font-size: 13px; border-radius: 12px; }
.pdf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.pdf-page { position: relative; border-radius: 12px; overflow: hidden; background: #fff; aspect-ratio: 0.72; box-shadow: 0 0 0 1px var(--line), 0 6px 14px -8px rgb(0 0 0 / 0.3); transition: transform 0.15s var(--ease), box-shadow 0.15s; }
.pdf-page:hover { transform: translateY(-2px); }
.pdf-page.on { box-shadow: 0 0 0 3px var(--accent), 0 10px 22px -10px var(--accent-soft); }
.pdf-thumb, .pdf-ph { width: 100%; height: 100%; object-fit: cover; display: block; }
.pdf-ph { background: linear-gradient(110deg, #eee 30%, #f7f7f7 50%, #eee 70%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.pdf-num { position: absolute; bottom: 5px; inset-inline-start: 6px; font-size: 11px; font-weight: 600; color: #333; background: rgb(255 255 255 / 0.88); border-radius: 6px; padding: 1px 6px; direction: ltr; }
.pdf-badge { position: absolute; top: 6px; inset-inline-end: 6px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12.5px; font-weight: 700; color: var(--accent-ink); background: var(--grad); opacity: 0; transform: scale(0.5); transition: opacity 0.15s, transform 0.2s var(--ease); }
.pdf-page.on .pdf-badge { opacity: 1; transform: scale(1); }
.pdf-foot { position: sticky; bottom: -22px; background: linear-gradient(transparent, var(--glass-solid) 22px); padding: 26px 0 4px; margin-top: 8px; }
.pdf-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-top: 10px; transition: opacity 0.2s; }
.pdf-actions.off { opacity: 0.4; pointer-events: none; }
.pdf-task b svg { width: 17px; height: 17px; color: var(--accent); }
.pdf-task:hover { background: var(--accent-soft); }

@media (max-width: 720px) {
  .hero-tiles { grid-template-columns: 1fr 1fr; margin-top: 18px; }
  .tile { padding: 11px 12px; border-radius: 18px; }
  .tile-ic { width: 32px; height: 32px; border-radius: 10px; margin-bottom: 5px; }
  .tile small { display: none; }
  .hero-label, .hero-demos { display: none; }
  .subj { width: 36px; height: 36px; border-radius: 12px; }
}
@media (max-height: 800px) and (min-width: 721px) {
  .hero-tiles { margin-top: 16px; }
  .tile small { display: none; }
  .demo { padding: 11px 14px; }
  .tile { padding: 11px 13px; }
  .tile-ic { width: 32px; height: 32px; margin-bottom: 5px; }
  .hero-chips { display: none; }
}

/* ───────────── refinement pass ───────────── */
::selection { background: color-mix(in srgb, var(--accent) 24%, transparent); color: inherit; }
input, textarea { caret-color: var(--accent); }
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--ink) 22%, transparent) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--ink) 20%, transparent); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }
.tbtn, .rec time, .zoom-label, .pdf-count, .lib-item small { font-variant-numeric: tabular-nums; }

.hero-title { margin-top: 4px; }
.hero-sub { max-width: 34em; }

/* One row of quiet actions instead of a grid of cards */
.hero-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 26px; }
.act {
  height: 46px; padding: 0 18px 0 20px; border-radius: var(--r-pill); display: inline-flex; align-items: center; gap: 9px;
  font-size: 15px; font-weight: 500; color: var(--ink);
  transition: transform 0.14s ease-out, box-shadow 0.2s ease;
  animation: rise 0.45s var(--ease) both; animation-delay: calc(var(--i, 0) * 50ms + 80ms);
}
.act svg { width: 19px; height: 19px; color: var(--accent); flex: none; }
.act:hover { transform: translateY(-1.5px); }
.act:active { transform: scale(0.97); }

/* Ready-made lessons: one calm panel with rows */
.hero-shelf { margin: 30px auto 0; max-width: 720px; border-radius: 26px; padding: 16px 10px 8px; text-align: start; animation: rise 0.5s var(--ease) both; animation-delay: 260ms; }
.hero-shelf h2 { margin: 0 12px 8px; font-size: 13px; font-weight: 600; color: var(--ink-3); letter-spacing: 0; }
.hero-shelf .hero-demos { display: grid !important; grid-template-columns: 1fr 1fr; gap: 2px 6px; }
.hero-shelf .demo {
  background: none; box-shadow: none; animation: none; border-radius: 16px; padding: 9px 10px; gap: 12px;
  transition: background-color 0.15s ease;
}
.hero-shelf .demo::before, .hero-shelf .demo::after { display: none; }
.hero-shelf .demo:hover { background: var(--field); transform: none; }
.hero-shelf .demo:active { background: var(--field-hover); transform: none; }
.hero-shelf .demo b { font-size: 14.5px; }
.hero-shelf .subj { width: 38px; height: 38px; border-radius: 12px; }

@media (max-width: 720px) {
  .hero-actions { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; margin-inline: -20px; padding: 2px 20px; scrollbar-width: none; }
  .hero-actions::-webkit-scrollbar { display: none; }
  .act { height: 42px; padding: 0 14px; font-size: 14px; white-space: nowrap; }
  .hero-shelf { display: block; margin-top: 20px; }
  .hero-shelf .hero-demos { grid-template-columns: 1fr; }
  .hero-shelf .demo:nth-child(n + 4) { display: none; }
}
@media (max-height: 800px) and (min-width: 721px) {
  .hero-actions { margin-top: 18px; }
  .hero-shelf { margin-top: 20px; padding-top: 12px; }
  .hero-shelf .demo { padding: 7px 10px; }
}

/* No theme cross-fade while the page is still starting up. */
.booting, .booting * { transition: none !important; }

/* ───────────── accounts ───────────── */
.auth-open .topbar, .auth-open .bottom, .auth-open .side, .auth-open .hero { visibility: hidden; }
.auth-veil {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; overflow-y: auto;
  background: color-mix(in srgb, var(--board-bg) 55%, transparent);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  opacity: 0; transition: opacity 0.35s ease;
}
.auth-veil.show { opacity: 1; }
.auth-card {
  width: min(420px, 100%); border-radius: 30px; padding: 30px 30px 22px; text-align: start;
  transform: translateY(14px) scale(0.985); transition: transform 0.5s var(--ease);
}
.auth-veil.show .auth-card { transform: none; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth-brand b { font-size: 18px; font-weight: 700; }
.auth-card h1 { margin: 0; font-family: var(--board-font); font-size: 28px; line-height: 1.45; font-weight: 800; color: var(--b-ink); letter-spacing: -0.01em; }
.auth-sub { margin: 6px 0 0; color: var(--ink-2); font-size: 14.5px; line-height: 1.85; }
.auth-sub b { color: var(--ink); font-weight: 600; }
.auth-form { display: grid; gap: 12px; margin-top: 22px; }
.auth-field { position: relative; display: grid; gap: 6px; }
.auth-field > span { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.auth-input {
  height: 50px; border-radius: 15px; border: 0; outline: 0; padding: 0 16px; font-size: 16px;
  background: var(--field); color: var(--ink); transition: box-shadow 0.15s ease, background-color 0.15s;
}
.auth-input:hover { background: var(--field-hover); }
.auth-input:focus { box-shadow: 0 0 0 3px var(--accent-soft), inset 0 0 0 1.5px var(--accent); background: var(--field); }
.auth-input[dir='ltr'] { text-align: left; }
.auth-field:has(.auth-eye) .auth-input { padding-right: 50px; }
.auth-eye { position: absolute; right: 8px; bottom: 7px; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: var(--ink-3); }
.auth-eye svg { width: 19px; height: 19px; }
.auth-eye.on, .auth-eye:hover { color: var(--accent); }
.auth-btn {
  position: relative; height: 52px; border-radius: 16px; margin-top: 6px; font-size: 16px; font-weight: 600; color: #fff;
  background: var(--grad); box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.35), 0 10px 22px -10px var(--accent-soft);
  display: flex; align-items: center; justify-content: center; gap: 10px; transition: transform 0.12s ease-out, filter 0.15s;
}
.auth-btn:hover { filter: brightness(1.05); }
.auth-btn:active { transform: scale(0.98); }
.auth-btn[disabled] { opacity: 0.75; cursor: progress; }
.auth-btn .spin { display: none; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid rgb(255 255 255 / 0.45); border-top-color: #fff; animation: spin 0.8s linear infinite; }
.auth-btn.busy .spin { display: block; }
.auth-link { color: var(--accent); font-weight: 600; font-size: inherit; }
.auth-link:hover { text-decoration: underline; text-underline-offset: 4px; }
.auth-link.small { justify-self: start; font-size: 13px; font-weight: 500; margin-top: -4px; }
.auth-foot { margin: 18px 0 0; font-size: 14px; color: var(--ink-2); text-align: center; line-height: 1.9; }
.auth-error { margin: 0; min-height: 1.4em; font-size: 13.5px; color: var(--b-red); line-height: 1.6; }
.auth-error:empty { min-height: 0; }
.pw-meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-top: -4px; }
.pw-meter i { height: 4px; border-radius: 4px; background: var(--field-hover); transition: background-color 0.2s; }
.pw-meter[data-score='1'] i:nth-child(-n + 1) { background: var(--b-red); }
.pw-meter[data-score='2'] i:nth-child(-n + 2) { background: var(--b-orange); }
.pw-meter[data-score='3'] i:nth-child(-n + 3) { background: #e5b40c; }
.pw-meter[data-score='4'] i { background: var(--b-green); }
.pw-hint { font-size: 12.5px; color: var(--ink-3); margin-top: -6px; }
.code-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.code-box {
  height: 60px; min-width: 0; border-radius: 15px; border: 0; outline: 0; text-align: center;
  font: 700 26px/1 var(--ui-font); font-variant-numeric: tabular-nums; color: var(--ink);
  background: var(--field); transition: box-shadow 0.15s, background-color 0.2s, transform 0.2s var(--ease);
}
.code-box:focus { box-shadow: 0 0 0 3px var(--accent-soft), inset 0 0 0 1.5px var(--accent); }
.auth-card.checking .code-box { opacity: 0.6; }
.auth-card.success .code-box { background: color-mix(in srgb, var(--b-green) 16%, transparent); box-shadow: inset 0 0 0 1.5px var(--b-green); transform: translateY(-2px); }

/* avatar & profile */
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none; margin-inline-start: 4px; display: grid; place-items: center;
  font-size: 14px; font-weight: 700; color: var(--accent-ink); background: var(--grad); box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.35);
  transition: transform 0.12s ease-out;
}
.avatar:active { transform: scale(0.92); }
.avatar.big { width: 56px; height: 56px; font-size: 21px; margin: 0; }
.profile-head { display: flex; align-items: center; gap: 14px; }
.profile-head b { display: block; font-size: 18px; font-weight: 700; }
.profile-head small { color: var(--ink-3); font-size: 13px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { border-radius: 18px; padding: 14px; background: var(--field); text-align: center; }
.stat b { display: block; font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }
.stat small { color: var(--ink-3); font-size: 12.5px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.sec > .field { width: 100%; margin-bottom: 8px; }
.field.area { height: auto; padding: 12px 14px; line-height: 1.8; resize: vertical; font-family: inherit; direction: rtl; text-align: right; }
.btn.danger { color: var(--b-red); }
.btn.danger.armed { background: var(--b-red); color: #fff; }
.danger-zone h3 { color: var(--b-red); }
@media (max-width: 720px) {
  .auth-card { padding: 24px 20px 18px; border-radius: 26px; }
  .code-box { height: 52px; font-size: 22px; }
  .form-grid { grid-template-columns: 1fr; }
}

/* board font picker */
.font-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.font-card { border-radius: 16px; padding: 12px 12px 10px; background: var(--field); text-align: center; display: grid; gap: 4px; transition: background-color 0.15s, box-shadow 0.15s; }
.font-card:hover { background: var(--field-hover); }
.font-card.on { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
.font-sample { font-size: 19px; line-height: 1.7; color: var(--ink); font-weight: 600; }
.font-card small { font-size: 12px; color: var(--ink-3); }

/* themes */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.theme-card { display: grid; gap: 6px; justify-items: center; padding: 10px 6px 8px; border-radius: 16px; background: var(--field); transition: background-color 0.15s, box-shadow 0.15s, transform 0.12s; }
.theme-card:hover { background: var(--field-hover); }
.theme-card:active { transform: scale(0.96); }
.theme-card.on { box-shadow: inset 0 0 0 2px var(--accent); }
.theme-card small { font-size: 12.5px; color: var(--ink-2); }
.theme-swatch { position: relative; width: 56px; height: 38px; border-radius: 12px; background: var(--a); box-shadow: inset 0 0 0 1px rgb(127 127 127 / 0.25); }
.theme-swatch i { position: absolute; inset-inline-start: 8px; bottom: 8px; width: 18px; height: 18px; border-radius: 50%; background: var(--b); }
.swatch-pair { width: 22px; height: 22px; flex: none; border-radius: 7px; background: linear-gradient(135deg, var(--a) 55%, var(--b) 55%); box-shadow: inset 0 0 0 1px rgb(127 127 127 / 0.3); }
.mi > svg:last-child:not(:first-child) { margin-inline-start: auto; color: var(--accent); }

/* ───────────── sign-in v2: floating shapes, self-drawing board, motion ───────────── */
.auth-veil { background: var(--board-bg); -webkit-backdrop-filter: none; backdrop-filter: none; overflow: hidden auto; }
.auth-shapes { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.auth-shapes svg {
  position: absolute; width: 46px; height: 46px; color: var(--accent); opacity: 0.16; stroke-width: 1.4;
  animation: drift calc(16s + var(--i) * 1.3s) ease-in-out infinite alternate;
  animation-delay: calc(var(--i) * -2.1s);
}
.auth-shapes svg:nth-child(3n) { width: 64px; height: 64px; opacity: 0.1; }
.auth-shapes svg:nth-child(4n + 1) { width: 34px; height: 34px; opacity: 0.2; }
@keyframes drift {
  0% { transform: translate3d(0, 0, 0) rotate(-8deg); }
  50% { transform: translate3d(18px, -26px, 0) rotate(6deg); }
  100% { transform: translate3d(-14px, 16px, 0) rotate(-3deg); }
}

.auth-shell { position: relative; display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 360px); gap: 18px; align-items: stretch; margin: auto; }
.auth-card { width: 100%; padding: 30px 30px 24px; border-radius: 30px; }
.auth-veil .auth-card, .auth-veil .auth-show { opacity: 0; transform: translateY(18px) scale(0.98); filter: blur(6px); transition: opacity 0.5s ease, transform 0.7s var(--ease), filter 0.5s ease; }
.auth-veil.show .auth-card { opacity: 1; transform: none; filter: none; }
.auth-veil.show .auth-show { opacity: 1; transform: none; filter: none; transition-delay: 0.12s; }

.auth-view { animation: view-in 0.45s var(--ease) both; }
@keyframes view-in { from { opacity: 0; transform: translateX(-14px); } }
.auth-view > * { animation: rise 0.5s var(--ease) both; }
.auth-view > :nth-child(2) { animation-delay: 40ms; }
.auth-view > :nth-child(3) { animation-delay: 80ms; }
.auth-view > :nth-child(4) { animation-delay: 120ms; }

.auth-card .logo { width: 38px; height: 38px; border-radius: 12px; }
.auth-card .logo svg { width: 26px; height: 26px; }
.auth-card h1 { font-size: 30px; }
.auth-btn { background: var(--accent); color: var(--accent-ink); box-shadow: var(--glow); transition: transform 0.14s ease-out, box-shadow 0.2s, filter 0.15s; }
.auth-btn:hover { transform: translateY(-1px); filter: brightness(1.04); }
.auth-btn .spin { border-color: color-mix(in srgb, var(--accent-ink) 40%, transparent); border-top-color: var(--accent-ink); }
.auth-input { border: 1.5px solid transparent; }
.auth-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.auth-error:not(:empty) { padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--b-red) 10%, transparent); animation: rise 0.3s var(--ease) both; }
.auth-error .auth-link { font-size: 13.5px; }

.auth-card.shake { animation: shake 0.42s cubic-bezier(.36,.07,.19,.97); }
@keyframes shake { 15%, 85% { transform: translateX(-2px); } 30%, 70% { transform: translateX(4px); } 45%, 55% { transform: translateX(-6px); } 50% { transform: translateX(6px); } }

.code-box:not(:placeholder-shown), .code-box:valid { }
.code-box { caret-color: var(--accent); }
.code-row .code-box:focus { transform: translateY(-2px); }
.auth-card { position: relative; }
.auth-done { position: absolute; inset: 0; display: grid; place-items: center; border-radius: inherit; background: color-mix(in srgb, var(--glass-solid) 88%, transparent); animation: view-in 0.3s ease both; }
.auth-done svg { width: 92px; height: 92px; fill: none; stroke: var(--b-green); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.auth-done circle { stroke-dasharray: 150; stroke-dashoffset: 150; animation: draw-line 0.6s var(--ease) forwards; }
.auth-done path { stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw-line 0.4s 0.45s var(--ease) forwards; }
@keyframes draw-line { to { stroke-dashoffset: 0; } }

/* the self-drawing board */
.auth-show { border-radius: 30px; padding: 22px 22px 18px; display: flex; flex-direction: column; gap: 6px; }
.auth-show svg { width: 100%; height: auto; flex: 1; }
.auth-show p { margin: 0; text-align: center; font-size: 14px; line-height: 1.8; color: var(--ink-2); }
.sc-grid path { stroke: var(--line); }
.sc-draw { stroke: var(--b-ink); stroke-dasharray: 400; stroke-dashoffset: 400; animation: sc-draw 9s var(--ease) infinite; }
.sc-draw.acc { stroke: var(--accent); }
.sc-draw.d2 { animation-delay: 0.6s; } .sc-draw.d3 { animation-delay: 1.4s; } .sc-draw.d4 { animation-delay: 2.2s; }
@keyframes sc-draw { 0% { stroke-dashoffset: 400; } 22%, 82% { stroke-dashoffset: 0; } 96%, 100% { stroke-dashoffset: 400; opacity: 0; } }
.sc-text { fill: var(--b-ink); font: 700 30px var(--board-font); opacity: 0; animation: sc-fade 9s ease infinite; }
.sc-text.t2 { font-size: 15px; font-weight: 600; fill: var(--accent); animation-delay: 3.4s; }
.sc-dot { fill: var(--accent); opacity: 0; animation: sc-fade 9s ease infinite; animation-delay: 3.2s; }
@keyframes sc-fade { 0%, 6% { opacity: 0; } 14%, 80% { opacity: 1; } 92%, 100% { opacity: 0; } }

@media (max-width: 860px) {
  .auth-shell { grid-template-columns: minmax(0, 440px); }
  .auth-show { display: none; }
}
@media (max-width: 720px) {
  .auth-veil { padding: max(16px, env(safe-area-inset-top)) 14px max(16px, env(safe-area-inset-bottom)); place-items: start center; }
  .auth-shell { width: 100%; margin: 4vh auto 0; }
  .auth-card { padding: 24px 20px 20px; border-radius: 26px; }
  .auth-card h1 { font-size: 26px; }
  .auth-input, .code-box { font-size: 16px; }
  .auth-shapes svg { opacity: 0.1; }
}
@media (prefers-reduced-motion: reduce) {
  .auth-shapes svg, .sc-draw, .sc-text, .sc-dot { animation: none; }
  .sc-draw { stroke-dashoffset: 0; } .sc-text, .sc-dot { opacity: 1; }
}

/* The board tools only matter once a lesson is on the board. */
.hero:not(.gone) ~ .side { display: none; }
