/* ==========================================================================
   Gulfie, application shell + shared UI kit
   Owned by the integration lead. Screen modules add their own scoped CSS.
   Class inventory is documented in docs/UI-KIT.md, reuse these, do not fork.
   ========================================================================== */

.app {
  /* Mobile only: one phone-width column on every screen size. */
  position: relative;
  min-height: 100dvh;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  isolation: isolate;
  background: linear-gradient(180deg, rgba(10, 8, 22, 0.82), rgba(7, 6, 15, 0.92));
  border-inline: 1px solid var(--line);
  box-shadow: 0 0 140px -50px #000;
}

/* ---------------------------------- rail --------------------------------- */
.rail {
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100dvh;
  width: var(--rail);
  flex: 0 0 var(--rail);
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 26px 18px 22px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(18, 15, 36, 0.9), rgba(7, 6, 15, 0.72));
  backdrop-filter: blur(14px);
  z-index: 20;
}

.rail__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 12px;
  text-decoration: none;
  color: var(--ink);
}
.rail__brand img,
.rail__brand .brandmark {
  width: 46px; height: 46px;
  border-radius: 14px;
  background: var(--surface-2);
  box-shadow: var(--glow-cyan);
}
.rail__brand b {
  font-family: var(--font-display);
  font-size: 1.36rem;
  letter-spacing: 0.06em;
  display: block;
  line-height: 1;
  background: linear-gradient(100deg, var(--cyan) 0%, #fff 42%, var(--magenta) 96%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.rail__brand span {
  font-size: 0.66rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.rail__nav { display: flex; flex-direction: column; gap: 4px; }

.navitem {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border-radius: var(--r-sm);
  color: var(--ink-dim);
  text-decoration: none;
  font-weight: 500;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  cursor: pointer;
  background: none;
  text-align: left;
  width: 100%;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.navitem:hover { color: var(--ink); background: rgba(139, 92, 255, 0.12); }
.navitem.is-active {
  color: #fff;
  background: linear-gradient(100deg, rgba(255, 46, 151, 0.22), rgba(139, 92, 255, 0.16));
  border-color: rgba(255, 46, 151, 0.42);
  box-shadow: 0 8px 24px -16px var(--magenta);
}
.navitem__icon { width: 24px; height: 24px; display: grid; place-items: center; flex: 0 0 24px; }
.navitem__icon svg { width: 22px; height: 22px; }
.navitem__label { font-size: 0.95rem; }
.navitem__hint {
  margin-left: auto;
  font-family: var(--font-display);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  padding: 3px 7px;
  border-radius: var(--r-pill);
  background: rgba(40, 227, 255, 0.14);
  color: var(--cyan-soft);
}

.rail__foot { margin-top: auto; display: grid; gap: 12px; }

/* ---------------------------------- main --------------------------------- */
.main {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--tabbar) + 26px);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px clamp(16px, 3vw, 34px);
  background: linear-gradient(180deg, rgba(7, 6, 15, 0.94), rgba(7, 6, 15, 0.55) 70%, transparent);
  backdrop-filter: blur(10px);
}
.topbar__spacer { flex: 1 1 auto; min-width: 0; }
.topbar__brand { display: inline-grid; place-items: center; flex: 0 0 auto; text-decoration: none; }
.topbar__brand .brandmark { width: 26px; height: 26px; border-radius: 9px; }

.topbar__title {
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.04em;
  margin: 0;
  color: var(--ink);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar__title em { display: none; } /* the phone bar has room for the section name only */

.view {
  width: min(100%, var(--content));
  margin: 0 auto;
  padding: 8px clamp(16px, 3vw, 34px) 40px;
  animation: view-in 0.4s var(--ease) both;
}
.view--wide { width: min(100%, 1120px); }

@keyframes view-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* stat chips (streak / xp / hearts) */
.stats { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: nowrap; overflow: hidden; }

.stat {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: var(--r-pill);
  background: rgba(25, 20, 54, 0.86);
  border: 1px solid var(--line);
  font-family: var(--font-display);
  font-size: 0.86rem;
  letter-spacing: 0.04em;
  color: var(--ink);
  white-space: nowrap;
}
.stat svg { width: 16px; height: 16px; }
.stat--streak { border-color: rgba(255, 194, 71, 0.4); color: #ffd98a; }
.stat--xp { border-color: rgba(182, 255, 60, 0.36); color: #dcff9a; }
.stat--level { border-color: rgba(40, 227, 255, 0.36); color: var(--cyan-soft); }
.stat__label { font-family: var(--font-body); font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); }

/* --------------------------------- buttons -------------------------------- */
.btn {
  --btn-bg: var(--grad-hot);
  --btn-fg: #14031a;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 24px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.98rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 10px 0 -2px rgba(0, 0, 0, 0.55), 0 18px 38px -22px var(--magenta);
  transition: transform 0.12s var(--ease), box-shadow 0.18s var(--ease), filter 0.18s var(--ease);
  min-height: 50px;
  touch-action: manipulation;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(3px); box-shadow: 0 5px 0 -2px rgba(0, 0, 0, 0.6), 0 10px 24px -18px var(--magenta); }
.btn[disabled], .btn[aria-disabled="true"] {
  filter: grayscale(0.7) brightness(0.7);
  cursor: not-allowed;
  transform: none;
}
.btn svg { width: 20px; height: 20px; }

.btn--ghost {
  --btn-bg: rgba(25, 20, 54, 0.9);
  --btn-fg: var(--ink);
  border: 1px solid var(--line-strong);
  box-shadow: none;
}
.btn--ghost:hover { border-color: var(--cyan); color: #fff; box-shadow: var(--glow-cyan); }

.btn--quiet {
  --btn-bg: transparent;
  --btn-fg: var(--ink-dim);
  box-shadow: none;
  text-transform: none;
  letter-spacing: 0.02em;
  font-family: var(--font-body);
  font-weight: 500;
  min-height: 40px;
  padding: 8px 14px;
}
.btn--quiet:hover { color: #fff; background: rgba(139, 92, 255, 0.14); }

.btn--danger { --btn-bg: linear-gradient(135deg, #ff4d6d, #ff2e97); --btn-fg: #1a0210; }
.btn--cool { --btn-bg: var(--grad-cool); --btn-fg: #04121a; box-shadow: 0 10px 0 -2px rgba(0,0,0,.55), 0 18px 38px -22px var(--cyan); }
.btn--mint { --btn-bg: var(--grad-mint); --btn-fg: #101a02; box-shadow: 0 10px 0 -2px rgba(0,0,0,.55), 0 18px 38px -22px var(--lime); }
.btn--block { width: 100%; }
.btn--lg { padding: 17px 30px; font-size: 1.06rem; min-height: 58px; }
.btn--sm { padding: 9px 15px; font-size: 0.8rem; min-height: 38px; }

.iconbtn {
  display: inline-grid;
  place-items: center;
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(25, 20, 54, 0.8);
  color: var(--ink-dim);
  cursor: pointer;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.iconbtn:hover { color: #fff; border-color: var(--cyan); background: rgba(40, 227, 255, 0.12); }
.iconbtn svg { width: 20px; height: 20px; }

/* ---------------------------------- cards --------------------------------- */
.card {
  position: relative;
  padding: 22px;
  border-radius: var(--r-lg);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0)) ,
    var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
}
.card--glass { background: var(--surface-glass); backdrop-filter: blur(16px); }
.card--hot { border-color: rgba(255, 46, 151, 0.4); box-shadow: var(--glow-magenta); }
.card--cool { border-color: rgba(40, 227, 255, 0.38); box-shadow: var(--glow-cyan); }
.card--flat { box-shadow: none; }
.card__title { margin: 0 0 6px; font-size: 1.1rem; }
.card__hint { color: var(--ink-dim); font-size: 0.9rem; margin: 0; }
.card--chamfer {
  clip-path: polygon(var(--chamfer) 0, 100% 0, 100% calc(100% - var(--chamfer)), calc(100% - var(--chamfer)) 100%, 0 100%, 0 var(--chamfer));
  border-radius: var(--r-md);
}

/* grid helpers */
.grid { display: grid; gap: 14px; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.row { display: flex; align-items: center; gap: 12px; }
.row--wrap { flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.stack { display: grid; gap: 14px; }
.stack--sm { gap: 8px; }
.stack--lg { gap: 24px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* chips & pills */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: var(--r-pill);
  background: rgba(139, 92, 255, 0.16);
  border: 1px solid var(--line);
  font-size: 0.76rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--violet-soft);
  font-family: var(--font-display);
  white-space: nowrap;
}
.chip--hot { background: rgba(255, 46, 151, 0.16); border-color: rgba(255, 46, 151, 0.4); color: var(--magenta-soft); }
.chip--cool { background: rgba(40, 227, 255, 0.14); border-color: rgba(40, 227, 255, 0.4); color: var(--cyan-soft); }
.chip--mint { background: rgba(182, 255, 60, 0.14); border-color: rgba(182, 255, 60, 0.38); color: var(--lime); }
.chip--sun { background: rgba(255, 194, 71, 0.16); border-color: rgba(255, 194, 71, 0.4); color: #ffd98a; }
.chip--muted { background: rgba(255, 255, 255, 0.05); color: var(--ink-dim); }

/* --------------------------------- progress ------------------------------- */
.bar {
  position: relative;
  height: 12px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.bar__fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: inherit;
  background: var(--grad-mint);
  box-shadow: 0 0 18px -2px rgba(182, 255, 60, 0.6);
  transition: width 0.5s var(--ease);
}
.bar--thin { height: 8px; }
.bar--hot .bar__fill { background: var(--grad-hot); box-shadow: 0 0 18px -2px rgba(255, 46, 151, 0.65); }
.bar__label { display: flex; justify-content: space-between; font-size: 0.76rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 6px; }

.ring {
  --pct: 0;
  position: relative;
  width: 74px; height: 74px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--cyan) calc(var(--pct) * 1%), rgba(255, 255, 255, 0.09) 0);
}
.ring::after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  background: var(--surface);
}
.ring > * { position: relative; z-index: 1; }
.ring__value { font-family: var(--font-display); font-size: 1rem; }

/* ------------------------------ path / units ------------------------------ */
.path { display: grid; gap: 10px; justify-items: center; padding: 10px 0 30px; }

.path-unit { width: 100%; display: grid; justify-items: center; gap: 10px; }

.unitplate {
  align-self: stretch;
  margin: 6px 0 2px;
  padding: 12px 18px;
  border-radius: var(--r-md);
  background: linear-gradient(100deg, rgba(255, 46, 151, 0.2), rgba(139, 92, 255, 0.14));
  border: 1px solid rgba(255, 46, 151, 0.34);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink);
}
.unitplate b { font-family: var(--font-display); letter-spacing: 0.04em; font-size: 0.98rem; }
.unitplate span { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.14em; color: var(--ink-faint); }

.node {
  position: relative;
  width: 84px; height: 84px;
  border-radius: 50%;
  border: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  background: radial-gradient(circle at 32% 26%, #322964, #1a1537 68%);
  box-shadow: 0 8px 0 -1px #0b0918, 0 14px 30px -18px #000, 0 0 0 3px rgba(255, 255, 255, 0.05) inset;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.4rem;
  transition: transform 0.14s var(--ease), box-shadow 0.2s var(--ease), filter 0.2s var(--ease);
  offset-anchor: center;
}
.node:hover { transform: translateY(-2px) scale(1.03); }
.node:active { transform: translateY(2px); }
.node svg { width: 34px; height: 34px; }
.node--start {
  background: radial-gradient(circle at 32% 26%, #ff6fbd, #b3237a 62%);
  box-shadow: 0 8px 0 -1px #5d0d3c, 0 16px 34px -14px var(--magenta), 0 0 0 3px rgba(255, 255, 255, 0.18) inset;
  animation: node-bob 2.6s var(--ease) infinite;
}
.node--done {
  background: radial-gradient(circle at 32% 26%, #8dff8b, #1f9c74 62%);
  box-shadow: 0 8px 0 -1px #0a4436, 0 16px 34px -16px var(--green);
}
.node--locked {
  background: radial-gradient(circle at 32% 26%, #232038, #141126 70%);
  color: var(--ink-faint);
  cursor: not-allowed;
  box-shadow: 0 8px 0 -1px #0b0918, 0 0 0 3px rgba(255, 255, 255, 0.04) inset;
}
.node--gold {
  background: radial-gradient(circle at 32% 26%, #ffe08a, #d79a12 62%);
  box-shadow: 0 8px 0 -1px #6b4a03, 0 16px 34px -14px var(--amber), 0 0 0 3px rgba(255, 255, 255, 0.22) inset;
  color: #3a2604;
}
.node__badge {
  position: absolute;
  bottom: -8px;
  font-family: var(--font-display);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  color: var(--ink-dim);
}
.node--start .node__badge { background: #2a0a20; border-color: rgba(255, 46, 151, 0.5); color: var(--magenta-soft); }
.node__bubble {
  position: absolute;
  top: -34px;
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 12px;
  border-radius: var(--r-pill);
  background: #fff;
  color: #14102a;
  font-family: var(--font-body);
  font-size: 0.74rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 10px 22px -14px #000;
}
.node__bubble::after {
  content: "";
  position: absolute;
  bottom: -5px;
  left: 50%;
  width: 10px; height: 10px;
  transform: translateX(-50%) rotate(45deg);
  background: #fff;
}
.node__bubble--marker {
  background: var(--amber);
  color: #2a1c02;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.64rem;
}
.node__bubble--marker::after { background: var(--amber); }

@keyframes node-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.path__line {
  width: 4px;
  height: 26px;
  border-radius: 4px;
  background: repeating-linear-gradient(180deg, var(--line-strong) 0 5px, transparent 5px 10px);
  justify-self: center;
}

/* -------------------------------- exercise -------------------------------- */
.exercise { display: grid; gap: 18px; }

.prompt {
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 1rem + 0.9vw, 1.6rem);
  line-height: 1.28;
  color: var(--ink);
  margin: 0;
}
.prompt--sub { font-family: var(--font-body); font-size: 0.95rem; color: var(--ink-dim); }

.options { display: grid; gap: 12px; }
.options--grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 16px 18px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--line);
  box-shadow: 0 5px 0 -1px #0c0a1a;
  color: var(--ink);
  text-align: left;
  font-size: 1.02rem;
  cursor: pointer;
  transition: transform 0.12s var(--ease), border-color 0.16s var(--ease), background 0.16s var(--ease), box-shadow 0.16s var(--ease);
}
.option:hover { border-color: var(--line-strong); background: var(--surface-3); }
.option:active { transform: translateY(2px); box-shadow: 0 2px 0 -1px #0c0a1a; }
.option.is-selected { border-color: var(--cyan); background: rgba(40, 227, 255, 0.12); box-shadow: 0 5px 0 -1px rgba(40, 227, 255, 0.45); }
.option.is-correct { border-color: var(--green); background: rgba(53, 227, 155, 0.14); box-shadow: 0 5px 0 -1px rgba(53, 227, 155, 0.5); }
.option.is-wrong { border-color: var(--red); background: rgba(255, 77, 109, 0.14); box-shadow: 0 5px 0 -1px rgba(255, 77, 109, 0.5); }
.option__key {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  flex: 0 0 30px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  font-family: var(--font-display);
  font-size: 0.82rem;
  color: var(--ink-dim);
}
.option__body { display: grid; gap: 2px; min-width: 0; }
.option__main { font-weight: 500; }
.option__sub { font-size: 0.82rem; color: var(--ink-faint); }

.answerbox {
  min-height: 76px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  border: 1px dashed var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.answerbox--filled { border-style: solid; }

.token {
  padding: 8px 13px;
  border-radius: var(--r-sm);
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  box-shadow: 0 3px 0 -1px #0b0918;
  font-size: 0.98rem;
  cursor: pointer;
  color: var(--ink);
  transition: transform 0.1s var(--ease), background 0.16s var(--ease);
}
.token:hover { background: #2a2154; }
.token:active { transform: translateY(2px); }
.token[disabled] { opacity: 0.32; cursor: default; }

.listen {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  border-radius: var(--r-pill);
  border: 1px solid rgba(40, 227, 255, 0.45);
  background: rgba(40, 227, 255, 0.1);
  color: var(--cyan-soft);
  font-family: var(--font-display);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.84rem;
  cursor: pointer;
}
.listen:hover { background: rgba(40, 227, 255, 0.18); }
.listen svg { width: 20px; height: 20px; }

/* feedback bar */
.feedback {
  position: sticky;
  bottom: calc(env(safe-area-inset-bottom, 0px));
  margin-top: auto;
  padding: 16px clamp(16px, 3vw, 30px);
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--surface-glass);
  backdrop-filter: blur(18px);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  animation: feedback-in 0.28s var(--ease) both;
}
.feedback--good { border-color: rgba(53, 227, 155, 0.5); background: linear-gradient(180deg, rgba(53, 227, 155, 0.16), rgba(18, 15, 36, 0.9)); }
.feedback--bad { border-color: rgba(255, 77, 109, 0.5); background: linear-gradient(180deg, rgba(255, 77, 109, 0.16), rgba(18, 15, 36, 0.9)); }
.feedback__text { flex: 1 1 240px; min-width: 0; }
.feedback__text b { display: block; font-family: var(--font-display); letter-spacing: 0.04em; margin-bottom: 2px; }
.feedback__text p { margin: 0; font-size: 0.9rem; color: var(--ink-dim); }

@keyframes feedback-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------- mascot ---------------------------------- */
.mascot { position: relative; display: flex; align-items: flex-end; gap: 14px; }
.mascot__img {
  width: 108px;
  height: 108px;
  object-fit: contain;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.6));
  flex: 0 0 auto;
}
.mascot--sm .mascot__img { width: 64px; height: 64px; }
.mascot--lg .mascot__img { width: 168px; height: 168px; }

.bubble {
  position: relative;
  padding: 14px 18px;
  border-radius: var(--r-lg);
  background: #fff;
  color: #14102a;
  font-weight: 500;
  box-shadow: 0 16px 30px -22px #000;
  max-width: 42ch;
}
.bubble::after {
  content: "";
  position: absolute;
  left: -7px;
  bottom: 18px;
  width: 14px; height: 14px;
  background: #fff;
  transform: rotate(45deg);
  border-radius: 3px;
}
.bubble--dark { background: var(--surface-3); color: var(--ink); border: 1px solid var(--line-strong); }
.bubble--dark::after { background: var(--surface-3); border-left: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong); }

/* ------------------------------- forms ----------------------------------- */
.field { display: grid; gap: 8px; }
.field__label { font-family: var(--font-display); font-size: 0.74rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-faint); }
.input {
  width: 100%;
  padding: 15px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-strong);
  background: rgba(10, 8, 22, 0.9);
  color: var(--ink);
  font-size: 1.05rem;
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}
.input::placeholder { color: var(--ink-faint); }
.input:focus { border-color: var(--cyan); box-shadow: var(--glow-cyan); outline: none; }
.input--ar { font-family: var(--font-ar); direction: rtl; font-size: 1.3rem; }

.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: var(--r-pill);
  background: rgba(10, 8, 22, 0.8);
  border: 1px solid var(--line);
}
.segmented button {
  border: 0;
  background: none;
  padding: 8px 16px;
  border-radius: var(--r-pill);
  color: var(--ink-dim);
  font-size: 0.86rem;
  cursor: pointer;
}
.segmented button[aria-pressed="true"] { background: var(--surface-3); color: #fff; box-shadow: var(--glow-cyan); }

.choicecard {
  display: grid;
  gap: 8px;
  text-align: left;
  padding: 20px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.14s var(--ease), border-color 0.16s var(--ease), background 0.16s var(--ease), box-shadow 0.2s var(--ease);
  box-shadow: var(--shadow-card);
}
.choicecard:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.choicecard[aria-pressed="true"] {
  border-color: var(--magenta);
  background: linear-gradient(160deg, rgba(255, 46, 151, 0.16), rgba(139, 92, 255, 0.1));
  box-shadow: var(--glow-magenta);
}
.choicecard__emoji { font-size: 1.8rem; line-height: 1; }
.choicecard b { font-family: var(--font-display); font-size: 1.05rem; letter-spacing: 0.02em; }
.choicecard span { font-size: 0.9rem; color: var(--ink-dim); }

.agegrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 10px; }
.agegrid button {
  padding: 14px 8px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--font-display);
  cursor: pointer;
  box-shadow: 0 5px 0 -1px #0b0918;
}
.agegrid button[aria-pressed="true"] { border-color: var(--cyan); background: rgba(40, 227, 255, 0.14); box-shadow: 0 5px 0 -1px rgba(40, 227, 255, 0.5); }

/* ------------------------------- modal/sheet ----------------------------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(4, 3, 10, 0.72);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 20px;
  animation: fade-in 0.2s var(--ease);
}
.sheet {
  width: min(560px, 100%);
  max-height: min(86dvh, 720px);
  overflow: auto;
  padding: 26px;
  border-radius: var(--r-xl);
  background: linear-gradient(180deg, #1a1533, #0e0b1d);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-pop);
  animation: sheet-in 0.3s var(--ease);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-in { from { opacity: 0; transform: translateY(18px) scale(0.98); } to { opacity: 1; transform: none; } }

/* --------------------------------- toast --------------------------------- */
.toast-host {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar) + 20px);
  transform: translateX(-50%);
  z-index: 80;
  display: grid;
  gap: 8px;
  justify-items: center;
  pointer-events: none;
  width: min(92vw, 460px);
}
.toast {
  padding: 12px 18px;
  border-radius: var(--r-pill);
  background: #fff;
  color: #14102a;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: 0 18px 40px -24px #000;
  animation: toast-in 0.3s var(--ease);
  text-align: center;
}
.toast--good { background: var(--green); color: #04231a; }
.toast--bad { background: #ff6f88; color: #2a0209; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ------------------------------- vocab / text ---------------------------- */
.deck {
  display: grid;
  gap: 10px;
  padding: 18px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(139, 92, 255, 0.16), rgba(18, 15, 36, 0.9));
  box-shadow: var(--shadow-card);
  cursor: pointer;
  text-align: left;
  color: var(--ink);
  transition: transform 0.16s var(--ease), border-color 0.16s var(--ease), box-shadow 0.2s var(--ease);
}
.deck:hover { transform: translateY(-3px); border-color: rgba(40, 227, 255, 0.5); box-shadow: var(--glow-cyan); }
.deck__emoji { font-size: 1.9rem; }
.deck__title { font-family: var(--font-display); font-size: 1.1rem; }
.deck__count { font-size: 0.8rem; color: var(--ink-faint); letter-spacing: 0.08em; text-transform: uppercase; }

.wordrow {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface-2);
}
.wordrow__ar { font-family: var(--font-ar); font-size: 1.5rem; direction: rtl; }
.wordrow__meta { display: grid; gap: 2px; min-width: 0; }
.wordrow__en { font-weight: 500; }
.wordrow__tr { font-size: 0.82rem; color: var(--cyan-soft); }

.reader {
  font-family: var(--font-ar);
  direction: rtl;
  font-size: 1.55rem;
  line-height: 2.15;
  letter-spacing: 0;
}

.w {
  cursor: pointer;
  border-radius: 8px;
  padding: 0 2px;
  transition: background 0.14s var(--ease), color 0.14s var(--ease);
  border-bottom: 2px solid rgba(40, 227, 255, 0.28);
}
.w:hover { background: rgba(40, 227, 255, 0.16); }
.w.is-known { border-bottom-color: rgba(182, 255, 60, 0.5); }
.w.is-active { background: var(--cyan); color: #06131a; }

.gloss-pop {
  position: fixed;
  z-index: 70;
  max-width: 280px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: #fff;
  color: #14102a;
  box-shadow: 0 24px 50px -30px #000;
  font-size: 0.92rem;
}
.gloss-pop b { display: block; font-family: var(--font-ar); direction: rtl; font-size: 1.2rem; margin-bottom: 2px; }
.gloss-pop i { font-style: normal; color: #5b5480; font-size: 0.82rem; display: block; }

/* letters */
.lettercard {
  display: grid;
  gap: 8px;
  place-items: center;
  padding: 18px 12px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: transform 0.16s var(--ease), border-color 0.16s var(--ease);
}
.lettercard:hover { transform: translateY(-2px); border-color: var(--cyan); }
.lettercard .glyph { font-family: var(--font-ar-naskh); font-size: 2.6rem; line-height: 1; }
.lettercard .name { font-family: var(--font-display); font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-faint); }
.lettercard.is-learned { border-color: rgba(53, 227, 155, 0.5); box-shadow: 0 0 0 1px rgba(53, 227, 155, 0.3), var(--shadow-card); }

.glyphbig { font-family: var(--font-ar-naskh); font-size: clamp(5rem, 16vw, 9rem); line-height: 1; text-align: center; }
.formcards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.formcards div {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 6px 11px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  text-align: center;
}
.formcards .f { font-family: var(--font-ar); font-size: 2.1rem; line-height: 1; direction: rtl; }
.formcards .k { font-size: 0.72rem; letter-spacing: 0.01em; color: var(--ink-dim); line-height: 1.2; }

/* the sentence above the four shapes, and the line that explains joining */
.form-explain { margin: 12px 0 8px; font-size: 0.84rem; color: var(--ink-dim); line-height: 1.4; }
.form-note { margin: 8px 0 0; font-size: 0.78rem; color: var(--ink-faint); line-height: 1.4; }

/* misc */
.divider { height: 1px; background: var(--line); border: 0; margin: 20px 0; }
.muted { color: var(--ink-dim); }
.faint { color: var(--ink-faint); }
.small { font-size: 0.86rem; }
.center { text-align: center; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.noglow { filter: none; }

.hearts { display: inline-flex; gap: 3px; }
.heart { width: 15px; height: 15px; color: var(--red); }
.heart--off { color: rgba(255, 77, 109, 0.22); }

.badge-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--magenta);
  box-shadow: 0 0 10px var(--magenta);
}

/* ---------------------------- bottom tabbar ------------------------------ */
.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  z-index: 25;
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
  background: rgba(9, 7, 20, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.tabbar a,
.tabbar button {
  flex: 1 1 0;
  display: grid;
  justify-items: center;
  gap: 3px;
  padding: 8px 4px 6px;
  border: 0;
  background: none;
  border-radius: var(--r-sm);
  color: var(--ink-faint);
  font-size: 0.63rem;
  letter-spacing: 0.04em;
  min-width: 0;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  font-family: var(--font-display);
}
.tabbar svg { width: 22px; height: 22px; }
.tabbar .is-active { color: #fff; background: rgba(255, 46, 151, 0.16); }

/* -------------------------------- responsive ----------------------------- */
@media (max-width: 1023px) {
  .main { padding-bottom: calc(var(--tabbar) + 20px); }
  .view { padding-top: 0; }
}

/* Phone rules. The app column is always phone width, so these always apply,
   with pixel values rather than viewport units. */
.topbar { padding: 10px 14px; gap: 8px; }
.stats { gap: 6px; }
.topbar .stat { padding: 5px 9px; font-size: 0.78rem; }
.topbar .stat svg { width: 14px; height: 14px; }
.topbar .stat--level { display: none; }
.topbar .stat--xp { display: none; }
.topbar .stat__label { display: none; }
.topbar__spacer { display: none; }
.topbar__title {
  flex: 1 1 auto;
  font-size: 0.88rem;
  letter-spacing: 0.02em;
  line-height: 1.15;
  max-width: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.view { padding: 4px 14px 32px; }
.card { padding: 18px; border-radius: var(--r-md); }
.node { width: 76px; height: 76px; }
.bubble { max-width: none; }
.mascot__img { width: 84px; height: 84px; }
.btn { width: 100%; }
.btn--quiet, .btn--sm { width: auto; }
.formcards { grid-template-columns: repeat(2, 1fr); }
.tabbar button, .tabbar a { font-size: 0.58rem; padding: 8px 2px 6px; letter-spacing: 0.02em; }

@media (max-width: 420px) {
  /* on a real phone the five tabs go icon-only */
  .tabbar button span:last-child,
  .tabbar a span:last-child { display: none; }
  .tabbar svg { width: 24px; height: 24px; }
  .tabbar button, .tabbar a { padding: 10px 4px; gap: 0; }
}

/* a heading focused for screen readers should not draw a focus box */
[data-focus]:focus,
.ob-h:focus,
.pl-h:focus,
h1:focus,
h2:focus { outline: none; }
