/* ONE — Twitter/X-inspired theme. Dark is the baseline :root below; the full
   light theme lives right after it (section 4A-3) and only ever redefines
   these same custom properties, so every rule in this file that consumes a
   var() is theme-safe for free. */
:root {
  --bg: #0a0a0a;
  --card: #15202b;
  --card-hover: #1a2530;
  --border: #1e2732;
  --text: #e7e9ea;
  --text-muted: #8b98a5;
  --accent: #1d9bf0;
  --accent-hover: #1a8cd8;
  --agree: #00ba7c;
  --challenge: #f4212e;
  --continue: #1d9bf0;
  --radius-full: 9999px;
  /* 8px spacing grid (section E) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 32px;

  /* ---- Phase 4 (4A-3): semantic surface tokens. Everything that used to be
     a raw rgba(255,255,255,X)/rgba(0,0,0,X)/hex literal in this file has
     been rerouted through one of these, so the light theme block only has
     to redefine ~20 variables instead of hunting every rule. ---- */
  --hover-1: rgba(231, 233, 234, 0.1);
  --hover-weak: rgba(255, 255, 255, 0.025);
  --hover-soft: rgba(255, 255, 255, 0.035);
  --hover-med: rgba(255, 255, 255, 0.06);
  --hover-strong: rgba(255, 255, 255, 0.1);
  --overlay-dot: rgba(255, 255, 255, 0.15);
  --track-bg: rgba(255, 255, 255, 0.08);
  --header-bg: rgba(10, 10, 10, 0.85);
  --topbar-bg: rgba(10, 10, 10, 0.9);
  --scrim-light: rgba(0, 0, 0, 0.55);
  --scrim-mid: rgba(0, 0, 0, 0.6);
  --scrim-heavy: rgba(0, 0, 0, 0.72);
  --shadow-color: rgba(0, 0, 0, 0.45);
  --skeleton-a: rgba(255, 255, 255, 0.04);
  --skeleton-b: rgba(255, 255, 255, 0.09);
  --map-ocean: #0a121a;
  --map-land: #132030;
  --map-border: #1e2732;
  --map-border-opacity: 0.5;
  --pulse-bubble-opacity: 0.5;
  color-scheme: dark;
}

/* ---------- Phase 4 (4A-3): full light theme ----------
   Twitter-light-inspired: white bg, near-black text, the same accent blue,
   soft gray borders. Applies in two cases: the OS prefers light AND the
   user hasn't explicitly picked a theme (`:root:not([data-theme])` inside
   the media query), OR the user explicitly picked Light regardless of the
   OS setting (`:root[data-theme="light"]`, outside the media query so it
   always wins). Dark needs no explicit block — the base :root above already
   holds the dark values and nothing here overrides them unless one of the
   two light conditions is true. */
:root[data-theme='light'] {
  --bg: #ffffff;
  --card: #f7f9f9;
  --card-hover: #eff3f4;
  --border: #eff3f4;
  --text: #0f1419;
  --text-muted: #536471;
  --accent: #1d9bf0;
  --accent-hover: #1a8cd8;
  --agree: #00a670;
  --challenge: #e0182b;
  --continue: #1d9bf0;

  --hover-1: rgba(15, 20, 25, 0.06);
  --hover-weak: rgba(15, 20, 25, 0.03);
  --hover-soft: rgba(15, 20, 25, 0.035);
  --hover-med: rgba(15, 20, 25, 0.06);
  --hover-strong: rgba(15, 20, 25, 0.08);
  --overlay-dot: rgba(15, 20, 25, 0.15);
  --track-bg: rgba(15, 20, 25, 0.09);
  --header-bg: rgba(255, 255, 255, 0.85);
  --topbar-bg: rgba(255, 255, 255, 0.9);
  --shadow-color: rgba(15, 20, 25, 0.15);
  --skeleton-a: rgba(15, 20, 25, 0.045);
  --skeleton-b: rgba(15, 20, 25, 0.09);
  --map-ocean: #d8e9f2;
  --map-land: #eaf1f5;
  --map-border: #c7d7e0;
  --map-border-opacity: 0.7;
  --pulse-bubble-opacity: 0.65;
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #ffffff;
    --card: #f7f9f9;
    --card-hover: #eff3f4;
    --border: #eff3f4;
    --text: #0f1419;
    --text-muted: #536471;
    --accent: #1d9bf0;
    --accent-hover: #1a8cd8;
    --agree: #00a670;
    --challenge: #e0182b;
    --continue: #1d9bf0;

    --hover-1: rgba(15, 20, 25, 0.06);
    --hover-weak: rgba(15, 20, 25, 0.03);
    --hover-soft: rgba(15, 20, 25, 0.035);
    --hover-med: rgba(15, 20, 25, 0.06);
    --hover-strong: rgba(15, 20, 25, 0.08);
    --overlay-dot: rgba(15, 20, 25, 0.15);
    --track-bg: rgba(15, 20, 25, 0.09);
    --header-bg: rgba(255, 255, 255, 0.85);
    --topbar-bg: rgba(255, 255, 255, 0.9);
    --shadow-color: rgba(15, 20, 25, 0.15);
    --skeleton-a: rgba(15, 20, 25, 0.045);
    --skeleton-b: rgba(15, 20, 25, 0.09);
    --map-ocean: #d8e9f2;
    --map-land: #eaf1f5;
    --map-border: #c7d7e0;
    --map-border-opacity: 0.7;
    --pulse-bubble-opacity: 0.65;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

#app {
  display: flex;
  justify-content: center;
  min-height: 100vh;
}

.layout {
  display: grid;
  grid-template-columns: 275px minmax(0, 600px) 320px;
  width: 100%;
  max-width: 1265px;
}

/* ---------- Sidebar (left) ---------- */
.sidebar {
  padding: 12px 8px 12px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
}

.logo {
  font-size: 26px;
  font-weight: 800;
  padding: 12px;
  letter-spacing: 1px;
  color: var(--accent);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  font-size: 20px;
  border-radius: var(--radius-full);
  cursor: pointer;
  color: var(--text);
  width: fit-content;
}
.nav-link:hover { background: var(--hover-1); }
.nav-link.active { font-weight: 700; }
.nav-icon { font-size: 20px; width: 24px; text-align: center; }

.post-btn {
  margin-top: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  padding: 14px 0;
  width: 90%;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
}
.post-btn:hover { background: var(--accent-hover); }

.sidebar-user {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
}
.sidebar-user:hover { background: var(--hover-1); }

/* ---------- Center column ---------- */
.main {
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  min-height: 100vh;
}

.main-header {
  position: sticky;
  top: 0;
  background: var(--header-bg);
  backdrop-filter: blur(8px);
  padding: 16px;
  font-size: 20px;
  font-weight: 800;
  border-bottom: 1px solid var(--border);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 16px;
}
.back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}
.back-btn:hover { background: var(--hover-1); }

/* ---------- Composer ---------- */
.composer {
  display: flex;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
  text-transform: uppercase;
}
.avatar.small { width: 32px; height: 32px; font-size: 14px; }

.composer-body { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.composer-input {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 22px;
  outline: none;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  width: 100%;
}
.composer-input::placeholder { color: var(--text-muted); }
.composer-input.shake { animation: shake 0.4s; border-bottom-color: var(--challenge); }

@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}

.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.composer-options {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 14px;
}
.toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}
.counter { font-size: 13px; color: var(--text-muted); }
.counter.over { color: var(--challenge); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  padding: 10px 20px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.error-msg {
  color: var(--challenge);
  font-size: 14px;
  padding: 4px 0;
}

/* ---------- Daily banner ---------- */
.daily-banner {
  display: block;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(29,155,240,0.08);
  cursor: pointer;
  font-size: 15px;
}
.daily-banner:hover { background: rgba(29,155,240,0.14); }
.daily-banner b { color: var(--accent); }

/* ---------- Feed / cards ---------- */
.card {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3) var(--space-3) 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s ease;
}
.card:hover { background: var(--hover-weak); }

.card-body { flex: 1; min-width: 0; }
.card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.card-meta .handle { color: var(--text); font-weight: 700; }

.card-word {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.25;
  margin: 4px 0 8px;
  word-break: break-word;
  letter-spacing: -0.01em;
}

/* Micro-interaction (section E): new post slides in from the top. */
@keyframes cardSlideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}
.card.new-post { animation: cardSlideIn 0.4s ease; background: rgba(29,155,240,0.06); }

.action-row {
  display: flex;
  gap: 8px;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.pill {
  display: flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: 14px;
}
.pill:hover { background: rgba(29,155,240,0.1); color: var(--accent); }
.pill.active { color: var(--continue); background: rgba(29,155,240,0.12); }
.pill.active[data-kind="agree"] { color: var(--agree); background: rgba(0,186,124,0.12); }
.pill.active[data-kind="challenge"] { color: var(--challenge); background: rgba(244,33,46,0.12); }

/* ---------- Empty / loading / states ---------- */
.state-msg {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 16px;
}

/* ---------- Right sidebar ---------- */
.rail {
  padding: 12px;
}
.rail-card {
  background: var(--card);
  border-radius: 16px;
  padding: 12px 16px;
  margin-bottom: 16px;
}
.rail-title { font-size: 20px; font-weight: 800; margin-bottom: 8px; }
.rail-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.rail-item:last-child { border-bottom: none; }
.rail-item:hover { color: var(--accent); }
.rail-word { font-weight: 700; }
.rail-count { color: var(--text-muted); font-size: 13px; }

/* ---------- Thread view ---------- */
.chain-sentence {
  padding: 12px 16px 0;
  color: var(--text-muted);
  font-style: italic;
  font-size: 15px;
}
.thread-root {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.thread-root .card-word { font-size: 30px; }

.reply-tree { padding: 0 16px; }
.reply-node {
  position: relative;
  padding: 12px 0 12px 24px;
  border-left: 2px solid var(--border);
  margin-left: 10px;
}
.reply-node .card-word { font-size: 20px; margin: 2px 0 6px; }
.reply-node .card-meta { font-size: 13px; }
.reply-node .action-row .pill { padding: 4px 10px; font-size: 13px; }

.reply-box {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.reply-box input {
  flex: 1;
  min-width: 0; /* UX sweep fix: same input-overflow issue as onboarding */
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 8px 14px;
  color: var(--text);
  outline: none;
  font-size: 14px;
}
.reply-box input:focus { border-color: var(--accent); }
.reply-box button { flex-shrink: 0; }

/* ---------- Auth ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  grid-column: 1 / -1;
  padding: 24px 16px;
}
.auth-hero {
  width: 380px;
  max-width: 90vw;
  text-align: center;
}
.auth-tagline {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 12px;
}
.auth-values {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.auth-values li {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.4;
}
.auth-card {
  background: var(--card);
  border-radius: 16px;
  padding: 32px;
  width: 380px;
  max-width: 90vw;
}
.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}
.auth-tab {
  flex: 1;
  text-align: center;
  padding: 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 700;
}
.auth-tab.active { background: var(--accent); color: #fff; }
.auth-field {
  width: 100%;
  padding: 12px;
  margin-bottom: 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 15px;
  outline: none;
}
.auth-field:focus { border-color: var(--accent); }
.auth-logo {
  font-size: 32px;
  font-weight: 800;
  color: var(--accent);
  text-align: center;
  margin-bottom: 24px;
}
.auth-privacy-link, .settings-privacy-link {
  color: var(--text-muted);
  font-size: 13px;
  text-decoration: none;
}
.auth-privacy-link:hover, .settings-privacy-link:hover { text-decoration: underline; color: var(--text); }
.settings-privacy-link { display: inline-block; margin-top: 12px; }

/* ---------- Search ---------- */
.search-box {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.search-box input {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 12px 16px;
  color: var(--text);
  font-size: 16px;
  outline: none;
}
.search-box input:focus { border-color: var(--accent); }
.search-result {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.search-result:hover { background: var(--hover-soft); }
.search-result .word { font-size: 20px; font-weight: 700; }
.search-result .stats { color: var(--text-muted); font-size: 13px; }

/* ---------- Profile ---------- */
.profile-header {
  padding: 24px 16px;
  border-bottom: 1px solid var(--border);
}
.profile-name { font-size: 24px; font-weight: 800; }
.profile-handle { color: var(--text-muted); margin-bottom: 16px; }
.stat-row { display: flex; gap: 24px; margin-top: 12px; }
.stat { display: flex; flex-direction: column; }
.stat-value { font-size: 20px; font-weight: 800; }
.stat-label { color: var(--text-muted); font-size: 13px; }

.join-banner {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.join-banner a { color: var(--accent); font-weight: 700; cursor: pointer; }

/* ---------- Mobile ---------- */
.tabbar {
  display: none;
}

@media (max-width: 1000px) {
  .layout { grid-template-columns: 68px minmax(0, 600px); }
  .rail { display: none; }
  .sidebar .nav-label, .logo-text { display: none; }
  .sidebar { padding: 12px 4px; align-items: center; }
  .logo { font-size: 0; padding: 12px 0; }
  .logo::before { content: "1"; font-size: 26px; font-weight: 800; }
  .nav-link { padding: 12px; }
  .post-btn { width: 44px; height: 44px; padding: 0; font-size: 0; margin: 12px auto 0; }
  .post-btn::after { content: "+"; font-size: 22px; font-weight: 700; }
  .sidebar-user { padding: 8px; }
  .sidebar-user > :not(.avatar) { display: none; }
}

@media (max-width: 680px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .main { border-left: none; border-right: none; }
  body { padding-bottom: 56px; }
  .tabbar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card);
    border-top: 1px solid var(--border);
    z-index: 10;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
  }
  .tabbar .nav-link {
    flex: 1;
    justify-content: center;
    border-radius: 0;
    padding: 14px 0;
  }
}

/* Standalone/installed-app mode: also pad the sticky main header for the
   status-bar notch/safe area (iOS/Android PWA chrome). */
@media all and (display-mode: standalone) {
  .main-header {
    padding-top: calc(16px + env(safe-area-inset-top, 0px));
  }
  body {
    padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
  }
}

/* ---------- Phase 4 (4A-1): language/script pill — ONE consistent pattern
   for every language or script selector in the app (UI-language switcher in
   the sidebar/mobile top bar/auth page, Home's language filter, Pulse's
   script filter). A pill button showing the current selection opens a
   dropdown (desktop) or bottom sheet (mobile) with ALL options at once —
   see openPickerSheet()'s `grid` mode a few rules down. ---------- */
.lang-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius-full);
  font-size: 14px;
  cursor: pointer;
  max-width: 100%;
  min-height: 40px;
}
.lang-pill:hover { background: var(--hover-med); }
.lang-pill-emoji { font-size: 16px; flex-shrink: 0; }
.lang-pill-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 1000px) {
  .sidebar .lang-pill { width: 44px; height: 44px; padding: 0; justify-content: center; border-radius: 50%; }
  .sidebar .lang-pill-label { display: none; }
}

/* ---------- Script filter chips (kept for any chip row that legitimately
   stays horizontally scrollable — 4A-1's last bullet: make the scrollability
   obvious via edge-fade + a peek of the next chip). Pulse's script filter no
   longer uses this (it's a lang-pill + grid picker now, like Home), but the
   affordance stays defined in case a chip row is reintroduced. ---------- */
.chip-row {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
  scroll-padding-left: 16px;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 16px, #000 calc(100% - 28px), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 16px, #000 calc(100% - 28px), transparent 100%);
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
  min-height: 40px;
  box-sizing: border-box;
}
.chip:hover { background: var(--hover-med); }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.hidden { display: none !important; }

/* ---------- Phase 2: nav notification badge ---------- */
.notif-badge {
  background: var(--challenge);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: var(--radius-full);
  min-width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  margin-left: 6px;
}
.tabbar .nav-link { position: relative; }
.tabbar .notif-badge { position: absolute; top: 4px; right: 18px; margin-left: 0; }

/* ---------- Phase 2: category tag on cards ---------- */
.category-tag {
  background: rgba(29,155,240,0.12);
  color: var(--accent);
  font-size: 12px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  cursor: pointer;
  white-space: nowrap;
}
.category-tag:hover { background: rgba(29,155,240,0.22); }
.category-row { border-bottom: 1px solid var(--border); }

/* ---------- Phase 2: twins pill ---------- */
.twins-pill { color: var(--text-muted); }

/* ---------- Phase 3 (section E): redesigned toast — bottom-center,
   rounded-full, icon + one line, auto-dismiss, max 1 visible. ---------- */
.one-toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translate(-50%, 20px);
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 20px;
  border-radius: var(--radius-full);
  max-width: 90vw;
  width: max-content;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 8px 24px var(--shadow-color);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 200;
  font-size: 14px;
}
.one-toast.clickable { cursor: pointer; }
.one-toast.show { opacity: 1; transform: translate(-50%, 0); }
.one-toast-icon { font-size: 16px; flex-shrink: 0; }
.one-toast-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 70vw; }
@media (max-width: 680px) {
  .one-toast { bottom: 76px; }
}

/* ---------- Phase 2: meaning card ---------- */
.meaning-wrap { margin-top: 8px; }
.meaning-why {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 0;
}
.meaning-body {
  color: var(--text-muted);
  font-size: 14px;
  font-style: italic;
  padding: 6px 0 2px;
  line-height: 1.4;
}

/* ---------- Phase 2: badges + mood ring ---------- */
.badges-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.badge-pill {
  background: var(--hover-med);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 5px 12px;
  font-size: 13px;
  color: var(--text);
}
.mood-ring {
  margin-top: 12px;
  padding: 8px 14px;
  background: rgba(29,155,240,0.08);
  border-radius: var(--radius-full);
  display: inline-block;
  font-size: 14px;
  color: var(--text);
}

/* ---------- Phase 2: weekly recap card ---------- */
.recap-card {
  margin: 16px;
  padding: 16px;
  background: var(--card);
  border-radius: 16px;
  border: 1px solid var(--border);
}
.recap-title { font-size: 18px; font-weight: 800; margin-bottom: 12px; }
.recap-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.recap-stat { text-align: center; }
.recap-stat-value { font-size: 20px; font-weight: 800; }
.recap-stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ---------- Phase 2: notifications ---------- */
.notif-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.notif-row:hover { background: var(--hover-soft); }
.notif-row.unread { background: rgba(29,155,240,0.06); }
.notif-icon { font-size: 18px; flex-shrink: 0; }
.notif-text { flex: 1; font-size: 14px; }
.notif-time { color: var(--text-muted); font-size: 12px; flex-shrink: 0; }
.mark-read-btn { font-size: 13px; }

/* ---------- Phase 2: reply language-purity hint ---------- */
.reply-box-wrap { margin-top: 8px; }
.reply-hint { color: var(--text-muted); font-size: 12px; margin-bottom: 4px; }

/* ---------- Phase 2: word twins view ---------- */
.twins-head { padding: 8px 0; }
.twins-pioneer { color: var(--text-muted); font-size: 14px; margin-bottom: 16px; }
.twins-countries-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.twins-country-row { display: flex; align-items: center; gap: 10px; }
.twins-country-name { width: 120px; flex-shrink: 0; font-size: 13px; color: var(--text-muted); }
.twins-bar-track {
  flex: 1;
  height: 10px;
  background: var(--hover-med);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.twins-bar-fill { height: 100%; background: var(--accent); border-radius: var(--radius-full); }
.twins-country-count { width: 32px; text-align: right; font-size: 13px; color: var(--text-muted); }
.twins-timeline-label { color: var(--text-muted); font-size: 13px; margin-bottom: 8px; }
.sparkline {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 60px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.spark-bar { flex: 1; min-width: 3px; background: var(--accent); border-radius: 2px 2px 0 0; opacity: 0.8; }

/* ---------- Phase 2: Pulse map ---------- */
.pulse-controls {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  flex-wrap: wrap;
}
.pulse-select {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 8px 14px;
  font-size: 13px;
  outline: none;
}
.headline-strip {
  padding: 10px 16px;
  font-size: 14px;
  color: var(--text-muted);
  font-style: italic;
  min-height: 20px;
}
.pulse-map-wrap { padding: 0 16px 16px; min-height: 200px; }
.pulse-detail {
  margin: 0 16px 16px;
  padding: 12px 16px;
  background: var(--card);
  border-radius: 12px;
  border: 1px solid var(--border);
}
.pulse-detail-title { font-size: 16px; font-weight: 800; margin-bottom: 6px; }
.pulse-detail-row { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ================= PHASE 3 ================= */

/* ---------- B. Real world map v2 ---------- */
.pulse-map-svg {
  width: 100%;
  height: auto;
  min-height: 180px;
  display: block;
  border-radius: 16px;
  background: var(--map-ocean);
}
.pulse-ocean { fill: var(--map-ocean); }
.pulse-land { fill: var(--map-land); stroke: var(--map-border); stroke-width: 0.6; }
.pulse-borders path { fill: none; stroke: var(--map-border); stroke-width: 0.35; stroke-opacity: var(--map-border-opacity); }
.pulse-bubble {
  cursor: pointer;
  transition: r 0.2s ease, fill-opacity 0.2s ease;
  fill-opacity: var(--pulse-bubble-opacity);
}
.pulse-bubble:hover { fill-opacity: 0.85; }
@keyframes pulseGlow {
  0%, 100% { filter: drop-shadow(0 0 0px currentColor); opacity: 0.5; }
  50% { filter: drop-shadow(0 0 6px currentColor); opacity: 0.85; }
}
.pulse-bubble.top-active { animation: pulseGlow 2.4s ease-in-out infinite; }

/* ---------- C. Country Story slide-up panel ---------- */
.story-overlay {
  position: fixed;
  inset: 0;
  background: var(--scrim-mid);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 120;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.story-overlay.show { opacity: 1; }
.story-panel {
  background: var(--card);
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  border-radius: 20px 20px 0 0;
  padding: 20px;
  transform: translateY(24px);
  transition: transform 0.25s ease;
  position: relative;
}
.story-overlay.show .story-panel { transform: translateY(0); }
@media (min-width: 681px) {
  .story-overlay { align-items: center; }
  .story-panel { border-radius: 20px; max-height: 80vh; }
}
.story-close {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--hover-med);
  border: none;
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  flex-shrink: 0;
}
.story-title { font-size: 22px; font-weight: 800; margin-bottom: 12px; padding-right: 52px; }
.story-range-tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.story-range-tab {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: 12px;
}
.story-range-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.story-arc { margin-bottom: 20px; }
.story-narrative { font-size: 15px; line-height: 1.5; margin-bottom: 14px; }
.story-arc-slots { display: flex; justify-content: space-between; gap: 6px; }
.story-arc-slot { display: flex; flex-direction: column; align-items: center; flex: 1; gap: 6px; }
.story-arc-bar {
  width: 100%;
  max-width: 28px;
  min-height: 4px;
  background: linear-gradient(180deg, var(--accent), rgba(29,155,240,0.2));
  border-radius: 4px 4px 0 0;
}
.story-arc-emoji { font-size: 18px; }
.story-arc-label { font-size: 10px; color: var(--text-muted); text-align: center; }
.story-block { margin-bottom: 16px; padding: 12px 14px; background: var(--hover-soft); border-radius: 12px; }
.story-block-title { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; font-weight: 700; }
.story-block-line { font-size: 16px; font-weight: 600; }
.story-block-meaning { font-size: 13px; color: var(--text-muted); font-style: italic; margin-top: 6px; }
.story-contrast { font-size: 14px; color: var(--text-muted); font-style: italic; margin-bottom: 16px; line-height: 1.5; }

/* ---------- Share buttons (section F.4) ---------- */
.share-btn { color: var(--accent); border: 1px solid rgba(29,155,240,0.3); margin-top: 8px; }
.share-btn:hover { background: rgba(29,155,240,0.12); }
.chain-sentence-wrap { padding: 0 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.chain-sentence-wrap .chain-sentence { padding: 12px 0; flex: 1; }

/* ---------- D. Like Minds ---------- */
.likeminds-subtitle { padding: 0 16px 12px; color: var(--text-muted); font-size: 14px; }
.likemind-list { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 12px; }
.likemind-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
}
.likemind-top { display: flex; align-items: center; gap: 12px; }
.likemind-info { flex: 1; min-width: 0; }
.likemind-handle { font-weight: 700; font-size: 16px; cursor: pointer; }
.likemind-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.likemind-chip {
  background: var(--hover-med);
  color: var(--text-muted);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
}
.likemind-wave-btn { margin-top: 12px; color: var(--accent); border: 1px solid rgba(29,155,240,0.3); }
.affinity-ring {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.affinity-ring-inner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
}
.wave-compose { display: flex; gap: 8px; margin-top: 10px; }
.wave-compose input {
  flex: 1;
  min-width: 0; /* UX sweep fix: same input-overflow issue as onboarding */
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 8px 14px;
  color: var(--text);
  outline: none;
  font-size: 14px;
}
.wave-compose input:focus { border-color: var(--accent); }
.wave-compose button { flex-shrink: 0; }

/* ---------- D. Mind print + kindred ---------- */
.mindprint-strip { margin: 16px; padding: 14px 16px; background: var(--card); border-radius: 16px; border: 1px solid var(--border); }
.mindprint-title { font-size: 15px; font-weight: 800; margin-bottom: 10px; }
.mindprint-bars { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.mindprint-row { display: flex; align-items: center; gap: 10px; }
.mindprint-label { width: 110px; flex-shrink: 0; font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mindprint-track { flex: 1; height: 8px; background: var(--hover-med); border-radius: var(--radius-full); overflow: hidden; }
.mindprint-fill { height: 100%; border-radius: var(--radius-full); }
.mindprint-fill.cat-fill { background: var(--accent); }
.mindprint-fill.emo-fill { background: linear-gradient(90deg, #fb7185, #facc15); }
.kindred-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.kindred-pill {
  background: rgba(0,186,124,0.1);
  color: var(--agree);
  font-size: 13px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
}

/* ---------- F.3 Challenge duel bar ---------- */
.duel-bar { margin-top: 10px; padding: 10px 12px; background: rgba(244,33,46,0.05); border-radius: 12px; }
.duel-label { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; font-weight: 700; }
.duel-row { display: flex; align-items: center; gap: 8px; }
.duel-side { display: flex; flex-direction: column; align-items: center; gap: 2px; flex-shrink: 0; width: 64px; }
.duel-side.duel-right { align-items: center; }
.duel-word { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 64px; }
.duel-count { font-size: 12px; color: var(--text-muted); }
.duel-track { flex: 1; height: 8px; border-radius: var(--radius-full); overflow: hidden; display: flex; background: var(--hover-med); }
.duel-fill-a { background: var(--challenge); height: 100%; }
.duel-fill-b { background: var(--agree); height: 100%; }
.duel-vs { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }

/* ---------- F.5 Weekly leaderboard ---------- */
.leaderboard-rank { width: 28px; font-weight: 800; color: var(--text-muted); }
.leaderboard-row .stats { display: flex; align-items: center; gap: 6px; }
.rank-up { color: var(--agree); font-size: 12px; }
.rank-down { color: var(--challenge); font-size: 12px; }
.rank-new { color: var(--accent); font-size: 12px; }
.rank-steady { color: var(--text-muted); font-size: 12px; }

/* ---------- E. Feed tabs (FOR YOU / LATEST, Trending / Leaderboard) ---------- */
.feed-tabs { display: flex; gap: 4px; padding: 8px 16px 0; border-bottom: 1px solid var(--border); }
.feed-tab {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
}
.feed-tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- E. Compact filter bar + picker sheet ---------- */
.filter-bar { display: flex; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.filter-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 7px 14px;
  border-radius: var(--radius-full);
  font-size: 13px;
  cursor: pointer;
  max-width: 50%;
  min-height: 40px;
  box-sizing: border-box;
}
.filter-pill.active { color: var(--accent); border-color: rgba(29,155,240,0.4); background: rgba(29,155,240,0.08); }
.filter-pill-label { display: flex; align-items: center; gap: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filter-pill-x { font-size: 11px; opacity: 0.7; padding: 2px; }
.filter-pill-x:hover { opacity: 1; }

.picker-overlay {
  position: fixed;
  inset: 0;
  /* Above .onboarding-overlay (300) and .one-toast (200) — a picker can be
     opened from inside onboarding (the language step) and must render on
     top of it, not behind it. */
  z-index: 310;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.picker-overlay.is-sheet { background: var(--scrim-light); display: flex; align-items: flex-end; justify-content: center; }
.picker-overlay.is-dropdown { background: transparent; }
.picker-overlay.show { opacity: 1; }
.picker-sheet {
  background: var(--card);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 420px;
  max-height: 70vh;
  overflow-y: auto;
  padding: 16px;
}
.picker-overlay.is-sheet .picker-sheet {
  border-radius: 20px 20px 0 0;
  transform: translateY(16px);
  transition: transform 0.2s ease;
}
.picker-overlay.is-sheet.show .picker-sheet { transform: translateY(0); }
.picker-overlay.is-dropdown .picker-sheet {
  border-radius: 14px;
  width: 240px;
  box-shadow: 0 12px 28px var(--shadow-color);
}
.picker-title { font-size: 15px; font-weight: 800; margin-bottom: 10px; }
.picker-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 50vh;
  overflow-y: auto;
}
.picker-item {
  display: flex;
  align-items: center;
  background: none;
  border: none;
  color: var(--text);
  text-align: left;
  padding: 10px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  min-height: 40px;
  box-sizing: border-box;
}
.picker-item:hover { background: var(--hover-med); }
.picker-item.active { color: var(--accent); font-weight: 700; }

/* ---------- Phase 4 (4A-1): grid mode — used for every language/script
   picker so all options (10 languages + All) are visible at once, wrapped,
   with no internal scrolling needed. Non-grid pickers (e.g. category
   filter) keep the plain vertical list above. ---------- */
.picker-overlay.is-grid .picker-sheet { width: 100%; max-width: 380px; }
.picker-list.grid {
  flex-direction: row;
  flex-wrap: wrap;
  max-height: none;
  overflow: visible;
}
.picker-item.grid-item {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 8px 14px;
  gap: 6px;
}
.picker-item.grid-item.active {
  background: rgba(29,155,240,0.1);
  border-color: var(--accent);
}
.picker-item-check { color: var(--accent); font-weight: 700; }

/* ---------- E. Skeleton shimmer loaders ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--skeleton-a) 25%, var(--skeleton-b) 37%, var(--skeleton-a) 63%);
  background-size: 400% 100%;
  animation: skeletonShimmer 1.4s ease infinite;
  border-radius: 6px;
}
@keyframes skeletonShimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}
.skeleton-card { cursor: default; }
.skeleton-card:hover { background: none; }
.skeleton-avatar { width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0; }
.skeleton-line { border-radius: 6px; }

/* ---------- E. Micro-interactions ---------- */
@keyframes pillPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}
.pill.pop { animation: pillPop 0.3s ease; }

.fly-word {
  position: fixed;
  z-index: 300;
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
  pointer-events: none;
  transition: transform 0.45s cubic-bezier(0.2,0.8,0.3,1), opacity 0.45s ease;
}

/* ---------- E. Circular char-progress composer ---------- */
.composer-actions { display: flex; align-items: center; gap: 12px; }
.composer-input { font-size: 22px; }
.char-progress { position: relative; width: 28px; height: 28px; }
.char-progress-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.char-progress-bg { fill: none; stroke: var(--track-bg); stroke-width: 3; }
.char-progress-fg {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.15s ease, stroke 0.15s ease;
}
.char-progress-fg.near { stroke: #f4b400; }
.char-progress-fg.over { stroke: var(--challenge); }
.char-progress-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--text-muted);
}

/* ---------- E. Daily-word hero card ---------- */
.daily-hero { padding: 12px 16px 0; }
.daily-hero-card {
  background: linear-gradient(135deg, rgba(29,155,240,0.14), rgba(29,155,240,0.03));
  border: 1px solid rgba(29,155,240,0.25);
  border-radius: 18px;
  padding: 16px 18px;
  cursor: pointer;
}
.daily-hero-card.joined { border-color: rgba(0,186,124,0.35); background: linear-gradient(135deg, rgba(0,186,124,0.14), rgba(0,186,124,0.03)); }
.daily-hero-top { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--text-muted); }
.daily-hero-countdown { font-variant-numeric: tabular-nums; }
.daily-hero-word { font-size: 28px; font-weight: 800; margin: 8px 0; color: var(--accent); }
.daily-hero-joined { font-size: 13px; color: var(--agree); margin-bottom: 8px; font-weight: 700; }
.daily-hero-bottom { display: flex; align-items: center; gap: 10px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar.tiny { margin-left: -8px; border: 2px solid var(--bg); }
.avatar-stack .avatar.tiny:first-child { margin-left: 0; }
.avatar.tiny { width: 24px; height: 24px; font-size: 11px; }
.daily-hero-count { font-size: 13px; color: var(--text-muted); }
.daily-hero-streak { font-size: 13px; margin-left: auto; }

/* ---------- E. Onboarding ---------- */
.onboarding-overlay {
  position: fixed;
  inset: 0;
  background: var(--scrim-heavy);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  opacity: 0;
  animation: onboardFadeIn 0.2s ease forwards;
}
.onboarding-overlay.closing { animation: onboardFadeOut 0.2s ease forwards; }
@keyframes onboardFadeIn { to { opacity: 1; } }
@keyframes onboardFadeOut { to { opacity: 0; } }
.onboarding-card {
  background: var(--card);
  border-radius: 20px;
  padding: 32px 28px;
  width: 420px;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  text-align: center;
}
.onboarding-skip {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
}
.onboarding-emoji { font-size: 40px; margin-bottom: 8px; }
.onboarding-title { font-size: 22px; font-weight: 800; margin-bottom: 8px; }
.onboarding-sub { font-size: 14px; color: var(--text-muted); margin-bottom: 16px; line-height: 1.5; }
.onboarding-hint { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.onboarding-lang-pill {
  display: inline-flex;
  margin: 0 auto 20px;
  background: var(--bg);
}
.onboarding-interest-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 20px;
}
.onboarding-interest-pill {
  background: var(--hover-med);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius-full);
  font-size: 14px;
  cursor: pointer;
}
.onboarding-interest-pill.selected { background: var(--accent); border-color: var(--accent); color: #fff; }
.onboarding-composer { display: flex; gap: 8px; margin-bottom: 8px; }
.onboarding-composer input {
  flex: 1;
  min-width: 0; /* UX sweep fix: without this the input's default intrinsic
    width can push the Post button past the card's right edge at 375px. */
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 12px 16px;
  color: var(--text);
  font-size: 18px;
  outline: none;
}
.onboarding-composer .btn-primary { flex-shrink: 0; }
.onboarding-composer input:focus { border-color: var(--accent); }
.onboarding-next { width: 100%; padding: 12px; margin-top: 4px; }
.onboarding-dots { display: flex; justify-content: center; gap: 6px; margin-top: 20px; }
.onboarding-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--overlay-dot); }
.onboarding-dot.active { background: var(--accent); }

/* ---------- E. Mobile top bar (bell + lang) + bottom tab bar with FAB ----------
   IMPORTANT: this is `position: fixed`, not `sticky` — #app is a row flexbox
   (for centering `.layout` on desktop), so a `sticky` topbar would sit as an
   in-flow FLEX SIBLING of `.layout` and steal horizontal space from it,
   squeezing/mis-centering the whole app on narrow widths. `fixed` removes it
   from flow entirely, same trick `.tabbar` already uses. ---------- */
.mobile-topbar { display: none; }
@media (max-width: 680px) {
  .mobile-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 20;
    padding: 10px 14px;
    background: var(--topbar-bg);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
  }
  .mobile-topbar-logo { font-size: 18px; font-weight: 800; color: var(--accent); letter-spacing: 1px; }
  .mobile-bell {
    position: relative;
    font-size: 18px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }
  .mobile-bell .notif-badge { position: absolute; top: 0; right: 0; }
  body { padding-top: 52px; }
  .main-header { top: 52px; }
}
@media all and (display-mode: standalone) {
  .mobile-topbar { padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
  body { padding-top: calc(52px + env(safe-area-inset-top, 0px)); }
}
.tabbar-fab {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 700;
  margin: 0 8px;
  transform: translateY(-14px);
  box-shadow: 0 4px 14px rgba(29,155,240,0.5);
  cursor: pointer;
  flex-shrink: 0;
}

/* ---------- E. Empty states ---------- */
.state-msg { line-height: 1.5; }

/* ---------- Phase 4 (4A-3): system/light/dark theme toggle. Lives in the
   sidebar (desktop, compact) and as a fuller labeled control on the owner's
   own Profile page. ---------- */
.theme-toggle {
  display: flex;
  gap: 2px;
  background: var(--hover-med);
  border-radius: var(--radius-full);
  padding: 3px;
  margin: 6px 12px;
}
.theme-toggle-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-full);
  padding: 9px 8px;
  font-size: 12px;
  cursor: pointer;
  min-height: 36px;
}
.theme-toggle-btn.active {
  background: var(--card);
  color: var(--text);
  font-weight: 700;
  box-shadow: 0 1px 4px var(--shadow-color);
}
@media (max-width: 1000px) {
  .sidebar .theme-toggle { flex-direction: column; margin: 6px 0; padding: 4px; }
  .sidebar .theme-toggle-btn .theme-toggle-label { display: none; }
}
.settings-block {
  margin: 16px;
  padding: 16px;
  background: var(--card);
  border-radius: 16px;
  border: 1px solid var(--border);
}
.settings-title { font-size: 16px; font-weight: 800; margin-bottom: 12px; }
.settings-theme-row .theme-toggle { margin: 0; max-width: 320px; }
.settings-theme-row .theme-toggle-btn { font-size: 13px; padding: 10px; }

/* ---------- Phase 4: auth page's language pill sits fixed top-right so it
   doesn't fight the centered auth card for flex space in #app. ---------- */
.auth-lang-fixed { position: fixed; top: 16px; right: 16px; z-index: 30; }
@media all and (display-mode: standalone) {
  .auth-lang-fixed { top: calc(16px + env(safe-area-inset-top, 0px)); }
}
