/* ديوان الشباب — design system. Tokens live in tokens.css; both themes are designed separately. */
@import url('/css/tokens.css');

/* ---------------- base ---------------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; }
body.app {
  font-family: var(--font); color: var(--text); background: var(--bg); line-height: 1.6;
  min-height: 100vh; min-height: 100dvh; overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }

/* ---------------- shell ---------------- */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; gap: 6px;
  padding: 18px 14px; background: var(--bg-2); border-inline-start: 1px solid var(--line); overflow-y: auto; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.brand-logo {
  width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; flex-shrink: 0; font-size: 1.35rem;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); box-shadow: 0 6px 18px var(--hero-glow);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text b { font-family: var(--font-head); font-size: 1.08rem; }
.brand-text small { color: var(--muted); font-size: 0.78rem; }
.nav-group { display: flex; flex-direction: column; gap: 2px; padding: 6px 0; }
.nav-group + .nav-group { border-top: 1px solid var(--line); }
.nav-title { font-size: 0.72rem; color: var(--muted); padding: 6px 12px 2px; letter-spacing: 0.02em; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; font-size: 0.95rem; transition: background 0.18s, color 0.18s; position: relative;
}
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.nav-item:hover { background: var(--tint-2); color: var(--text); }
.nav-item.active { background: var(--brand-soft); color: var(--brand-text); font-weight: 700; }
.nav-item.active::before { content: ''; position: absolute; inset-inline-start: -14px; top: 8px; bottom: 8px; width: 4px; border-radius: 4px; background: var(--brand); }
.nav-item .pill-count { margin-inline-start: auto; }
.sidebar-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 25; height: var(--topbar); display: flex; align-items: center; gap: 12px;
  padding: 0 24px; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar .menu-btn { display: none; }
.search { position: relative; flex: 1; max-width: 520px; }
.search input {
  width: 100%; height: 42px; padding: 0 42px 0 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); transition: border-color 0.2s, box-shadow 0.2s;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.search > svg { position: absolute; inset-inline-start: 14px; top: 11px; width: 20px; height: 20px; color: var(--muted); pointer-events: none; }
.search-results {
  position: absolute; top: 48px; inset-inline: 0; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 6px; max-height: 70vh; overflow-y: auto; z-index: 40;
}
.search-results h6 { margin: 8px 10px 4px; color: var(--muted); font-size: 0.75rem; font-weight: 500; }
.search-results a { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px; }
.search-results a:hover, .search-results a.focus { background: var(--tint-2); }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-inline-start: auto; }
.icon-btn {
  position: relative; width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; cursor: pointer; color: var(--text-2); transition: background 0.2s, color 0.2s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }
.badge-dot {
  position: absolute; top: -4px; inset-inline-end: -4px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px;
  background: var(--danger); color: #fff; font-size: 0.7rem; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--bg);
}
.account-btn {
  display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 12px; height: 46px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer;
}
.account-btn .who { display: flex; flex-direction: column; line-height: 1.2; text-align: start; }
.account-btn .who b { font-size: 0.9rem; }
.account-btn .who small { color: var(--muted); font-size: 0.74rem; }
.menu {
  position: absolute; top: calc(100% + 8px); inset-inline-end: 0; min-width: 230px; background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 6px; z-index: 50;
  animation: pop 0.16s var(--ease);
}
.menu a, .menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-radius: 9px; border: 0; background: none;
  cursor: pointer; color: var(--text); font-size: 0.93rem; text-align: start;
}
.menu a:hover, .menu button:hover { background: var(--tint-2); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }
.menu svg { width: 18px; height: 18px; color: var(--muted); }

#page { padding: 26px 28px 60px; max-width: 1360px; width: 100%; margin: 0 auto; animation: page-in 0.32s var(--ease); }
@keyframes page-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes pop { from { opacity: 0; transform: scale(0.96) translateY(-4px); } }

.bottom-nav { display: none; }
.scrim { position: fixed; inset: 0; background: rgba(5, 5, 20, 0.5); z-index: 29; backdrop-filter: blur(2px); }

/* tablet: icon sidebar */
@media (max-width: 1180px) and (min-width: 761px) {
  .shell { --sidebar: 78px; }
  .sidebar { padding: 18px 10px; align-items: center; }
  .brand-text, .nav-item span, .nav-title, .nav-item .pill-count { display: none; }
  .nav-item { justify-content: center; padding: 11px; }
  .nav-item.active::before { inset-inline-start: -10px; }
  .brand { padding: 4px 0 14px; }
  .sidebar.open { position: fixed; inset-block: 0; inset-inline-start: 0; width: 252px; align-items: stretch; box-shadow: var(--shadow); }
  .sidebar.open .brand-text, .sidebar.open .nav-item span, .sidebar.open .nav-title { display: initial; }
  .sidebar.open .nav-item { justify-content: flex-start; }
}

/* phone: drawer + bottom navigation */
@media (max-width: 760px) {
  .shell { display: block; }
  .sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0; width: min(86vw, 300px); transform: translateX(105%);
    transition: transform 0.25s var(--ease); box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .topbar { padding: 0 12px; gap: 8px; height: 58px; }
  .topbar .menu-btn { display: grid; }
  .search { max-width: none; }
  .search input { height: 40px; }
  .account-btn .who { display: none; }
  .account-btn { padding: 3px; height: 42px; }
  #page { padding: 18px 14px calc(96px + env(safe-area-inset-bottom)); }
  .bottom-nav {
    position: fixed; inset-inline: 0; bottom: 0; z-index: 28; display: grid; grid-template-columns: repeat(5, 1fr);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(16px); border-top: 1px solid var(--line);
  }
  .bottom-nav a, .bottom-nav button {
    display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border: 0; background: none;
    color: var(--muted); font-size: 0.7rem; font-weight: 500; border-radius: 12px; cursor: pointer; position: relative;
  }
  .bottom-nav svg { width: 23px; height: 23px; }
  .bottom-nav .active { color: var(--brand-text); }
  .bottom-nav .active svg { filter: drop-shadow(0 2px 6px var(--hero-glow)); }
}

/* ---------------- typography + layout helpers ---------------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-family: var(--font-head); font-size: clamp(1.5rem, 2.6vw, 2.05rem); margin: 0; line-height: 1.3; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.section { margin-top: 30px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head h2 { font-family: var(--font-head); font-size: 1.2rem; margin: 0; display: flex; align-items: center; gap: 8px; }
.section-head a { color: var(--brand-text); font-size: 0.9rem; font-weight: 500; }
.grid { display: grid; gap: 18px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-auto { grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
@media (max-width: 1000px) { .cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .cols-2, .cols-3 { grid-template-columns: minmax(0, 1fr); } .grid { gap: 14px; } }

/* ---------------- surfaces ---------------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow-sm); min-width: 0;
}
.card.flat { box-shadow: none; }
.card.pad-sm { padding: 14px; }
.card-link { transition: transform 0.2s var(--ease), border-color 0.2s, box-shadow 0.2s; display: block; }
.card-link:hover { transform: translateY(-3px); border-color: var(--line-strong); box-shadow: var(--shadow); }
.card h3 { margin: 0 0 6px; font-size: 1.05rem; }

/* ---------------- buttons + inputs ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 18px;
  border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text);
  font-weight: 700; font-size: 0.93rem; cursor: pointer; white-space: nowrap; transition: transform 0.15s, background 0.2s, box-shadow 0.2s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: var(--brand-ink); border-color: transparent; box-shadow: 0 6px 18px var(--hero-glow); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.warm { background: var(--warm); color: #2b1800; border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--tint-2); }
.btn.danger { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.btn.sm { height: 34px; padding: 0 12px; font-size: 0.85rem; border-radius: 10px; }
.btn.lg { height: 52px; padding: 0 26px; font-size: 1.02rem; border-radius: 14px; }
.btn.block { width: 100%; }
.input, .select, .textarea {
  width: 100%; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text); border-radius: 12px;
  padding: 10px 14px; transition: border-color 0.2s, box-shadow 0.2s;
}
.input, .select { height: 44px; }
.textarea { resize: vertical; min-height: 90px; line-height: 1.7; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: 0.92rem; }
.field small { color: var(--muted); font-weight: 400; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch .track { width: 44px; height: 26px; border-radius: 13px; background: var(--tint-3); position: relative; transition: background 0.2s; flex-shrink: 0; }
.switch .track::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: inset-inline-start 0.2s; }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { inset-inline-start: 21px; }
.switch input:focus-visible + .track { outline: 2px solid var(--brand); outline-offset: 2px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 999px; font-size: 0.88rem;
  border: 1px solid var(--line); background: var(--surface); color: var(--text-2); cursor: pointer; transition: all 0.18s; white-space: nowrap;
}
.chip:hover { border-color: var(--line-strong); color: var(--text); }
.chip.on { background: var(--brand-soft); border-color: transparent; color: var(--brand-text); font-weight: 700; }
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--tint-2); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1 0 auto; height: 38px; padding: 0 16px; border-radius: 11px; border: 0; background: none; color: var(--text-2);
  font-weight: 500; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.tab.on { background: var(--surface); color: var(--text); font-weight: 700; box-shadow: var(--shadow-sm); }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; background: var(--tint-2); color: var(--text-2); white-space: nowrap; }
.pill.brand { background: var(--brand-soft); color: var(--brand-text); }
.pill.warm { background: var(--warm-soft); color: var(--warm-text); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill-count { min-width: 22px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--danger); color: #fff; font-size: 0.72rem; display: grid; place-items: center; font-weight: 700; }

/* ---------------- avatars ---------------- */
.av {
  --s: 40px; width: var(--s); height: var(--s); border-radius: 50%; object-fit: cover; flex-shrink: 0; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font-family: var(--font-head); font-weight: 700;
  font-size: calc(var(--s) * 0.42); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line);
}
.av.xs { --s: 26px; } .av.sm { --s: 32px; } .av.md { --s: 48px; } .av.lg { --s: 72px; } .av.xl { --s: 116px; border-width: 4px; }
.av-stack { display: flex; }
.av-stack .av { margin-inline-start: -10px; }
.av-stack .av:first-child { margin-inline-start: 0; }

/* ---------------- hero ---------------- */
.hero {
  position: relative; overflow: hidden; border-radius: 24px; padding: clamp(22px, 4vw, 40px); color: #fff; background: var(--hero);
  min-height: 230px; display: flex; flex-direction: column; justify-content: flex-end; isolation: isolate; box-shadow: var(--shadow);
}
.hero::before {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: radial-gradient(circle at 18% 20%, rgba(255, 181, 71, 0.38), transparent 42%), radial-gradient(circle at 85% 80%, rgba(90, 139, 255, 0.45), transparent 50%);
}
.hero .hero-img { position: absolute; inset: 0; z-index: -2; width: 100%; height: 100%; object-fit: cover; opacity: 0.4; }
.hero .hero-img + .hero-shade { position: absolute; inset: 0; z-index: -1; background: linear-gradient(0deg, rgba(10, 8, 30, 0.85), rgba(10, 8, 30, 0.2)); }
.hero h1 { font-family: var(--font-head); font-size: clamp(1.6rem, 3.6vw, 2.5rem); line-height: 1.25; margin: 0; text-shadow: 0 2px 20px rgba(0, 0, 0, 0.35); }
.hero p { margin: 8px 0 0; color: rgba(255, 255, 255, 0.86); }
.hero .date { position: absolute; top: 20px; inset-inline-end: 22px; font-size: 0.86rem; color: rgba(255, 255, 255, 0.86); background: rgba(255, 255, 255, 0.14); padding: 4px 12px; border-radius: 999px; backdrop-filter: blur(6px); }
.hero .btn { margin-top: 18px; align-self: flex-start; }
.hero-wheat { position: absolute; inset-inline-end: 26px; bottom: 18px; font-size: 3.2rem; opacity: 0.9; animation: sway 5s ease-in-out infinite; transform-origin: bottom; }
@keyframes sway { 50% { transform: rotate(7deg); } }

/* ---------------- quotes ---------------- */
.quote-text { font-family: var(--font-quote); font-weight: 700; line-height: 1.75; font-size: 1.2rem; margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.quote-text::before { content: '« '; color: var(--brand-text); }
.quote-text::after { content: ' »'; color: var(--brand-text); }
.quote-lg { font-size: clamp(1.35rem, 2.6vw, 1.85rem); }
.saying-card { display: flex; flex-direction: column; gap: 12px; }
.saying-card .who { display: flex; align-items: center; gap: 10px; }
.saying-card .who b { font-size: 0.95rem; }
.saying-card .who small { color: var(--muted); font-size: 0.78rem; display: block; }
.saying-card .ctx { color: var(--muted); font-size: 0.86rem; }
.saying-card .photo { border-radius: 12px; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.saying-card .foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: auto; }

/* ---------------- reactions + comments ---------------- */
.reactions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.react {
  display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--tint-1); cursor: pointer; font-size: 0.86rem; color: var(--text-2); transition: transform 0.12s, background 0.15s, border-color 0.15s;
}
.react:hover { background: var(--tint-2); }
.react:active { transform: scale(0.92); }
.react .e { font-size: 1.02rem; line-height: 1; }
.react.mine { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-text); font-weight: 700; }
.react.bump .e { animation: bump 0.35s var(--ease); }
@keyframes bump { 40% { transform: scale(1.45); } }
.react-total { font-size: 0.8rem; color: var(--muted); margin-inline-start: 4px; }
.comments { display: flex; flex-direction: column; gap: 14px; }
.comment { display: flex; gap: 10px; align-items: flex-start; }
.comment .bubble { background: var(--tint-2); border-radius: 4px 16px 16px 16px; padding: 10px 14px; min-width: 0; flex: 1; }
.comment .bubble b { font-size: 0.9rem; }
.comment .bubble time { color: var(--muted); font-size: 0.76rem; margin-inline-start: 6px; }
.comment .bubble p { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment.deleted .bubble { opacity: 0.6; font-style: italic; }
.comment .actions { display: flex; gap: 2px; margin-top: 4px; }
.comment .actions button { border: 0; background: none; color: var(--muted); font-size: 0.8rem; cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.comment .actions button:hover { color: var(--text); background: var(--tint-2); }
.composer { display: flex; gap: 10px; align-items: flex-end; }
.composer .textarea { min-height: 46px; height: 46px; max-height: 160px; }

/* ---------------- lists, feed ---------------- */
.feed { display: flex; flex-direction: column; }
.feed-item { display: flex; gap: 12px; align-items: center; padding: 12px 10px; border-radius: 14px; transition: background 0.15s; }
.feed-item:hover { background: var(--tint-2); }
.feed-item + .feed-item { border-top: 1px solid var(--line); }
.feed-item .ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 1.2rem; background: var(--brand-soft); flex-shrink: 0; }
.feed-item .txt { flex: 1; min-width: 0; }
.feed-item .txt b { display: block; font-size: 0.93rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-item .txt span { color: var(--muted); font-size: 0.82rem; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-item .thumb { width: 64px; height: 46px; border-radius: 10px; object-fit: cover; flex-shrink: 0; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px 6px; }
.list-row + .list-row { border-top: 1px solid var(--line); }

/* ---------------- feature tiles ---------------- */
.tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1180px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } .tiles .tile:last-child:nth-child(odd) { grid-column: span 2; } }
.tile {
  position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 20px 12px 18px;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); overflow: hidden; transition: transform 0.2s var(--ease), box-shadow 0.2s;
}
.tile::before { content: ''; position: absolute; inset: 0; background: radial-gradient(circle at 50% 0%, var(--tile-glow, var(--brand-soft)), transparent 65%); pointer-events: none; }
.tile:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.tile .art { position: relative; width: 66px; height: 66px; display: grid; place-items: center; font-size: 2.3rem; border-radius: 20px; background: var(--tile-bg, var(--brand-soft)); }
.tile b { position: relative; font-family: var(--font-head); font-size: 1.02rem; }
.tile small { position: relative; color: var(--muted); font-size: 0.8rem; }
.tile .pill { position: absolute; top: 10px; inset-inline-end: 10px; }

/* ---------------- member cards ---------------- */
.member { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 22px 14px 16px; position: relative; overflow: hidden; }
.member::before { content: ''; position: absolute; inset: 0 0 auto; height: 74px; background: linear-gradient(135deg, var(--m1, var(--brand)), var(--m2, var(--brand-2))); opacity: 0.85; }
.member .av { position: relative; margin-top: 18px; }
.member b { font-family: var(--font-head); font-size: 1.08rem; margin-top: 4px; }
.member .nick { color: var(--brand-text); font-size: 0.86rem; margin-top: -4px; }
.member .stats { display: flex; gap: 14px; color: var(--muted); font-size: 0.8rem; margin-top: 4px; }
.member .latest { font-family: var(--font-quote); font-size: 0.95rem; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 3.2em; }

/* ---------------- stat tiles ---------------- */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.stat { padding: 16px 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.stat .v { font-size: 1.7rem; font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; display: block; }
.stat .l { color: var(--muted); font-size: 0.85rem; display: block; }
.stat .d { font-size: 0.78rem; color: var(--muted); display: block; margin-top: 2px; }
.stat.accent .v { color: var(--brand-text); }

/* ---------------- states ---------------- */
.skel { background: var(--skeleton); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; border-radius: 10px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.skel-card { height: 160px; border-radius: var(--radius); }
.skel-line { height: 14px; margin: 8px 0; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .art { font-size: 3rem; margin-bottom: 6px; }
.empty b { display: block; color: var(--text); font-size: 1.1rem; margin-bottom: 4px; font-family: var(--font-head); }
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--brand-soft); color: var(--text); }
.notice.warm { background: var(--warm-soft); }

/* ---------------- dialogs + toasts ---------------- */
dialog.modal {
  border: 1px solid var(--line-strong); border-radius: 20px; padding: 0; background: var(--surface); color: var(--text);
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 40px); box-shadow: var(--shadow);
}
dialog.modal::backdrop { background: rgba(6, 6, 22, 0.55); backdrop-filter: blur(3px); }
dialog.modal[open] { animation: pop 0.18s var(--ease); }
.modal-body { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-body h3 { margin: 0; font-family: var(--font-head); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
#toasts { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; align-items: center; width: max-content; max-width: calc(100vw - 24px); }
@media (max-width: 760px) { #toasts { bottom: calc(86px + env(safe-area-inset-bottom)); } }
.toast { display: flex; align-items: center; gap: 12px; background: var(--surface-3); color: var(--text); border: 1px solid var(--line-strong); padding: 11px 16px; border-radius: 14px; box-shadow: var(--shadow); animation: pop 0.2s var(--ease); transition: opacity 0.3s, transform 0.3s; }
.toast.err { border-color: var(--danger); }
.toast.out { opacity: 0; transform: translateY(8px); }
.toast button { border: 0; background: none; color: var(--brand-text); font-weight: 700; cursor: pointer; padding: 0; }

/* ---------------- tables ---------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th { text-align: start; font-weight: 500; color: var(--muted); font-size: 0.8rem; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--tint-1); }

/* ---------------- audio player ---------------- */
.player { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: var(--tint-2); }
.player .play {
  width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer; flex-shrink: 0;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; box-shadow: 0 4px 12px var(--hero-glow);
}
.player .play svg { width: 18px; height: 18px; }
.player .bars { flex: 1; height: 34px; display: flex; align-items: center; gap: 2px; cursor: pointer; direction: ltr; }
.player .bars i { flex: 1; border-radius: 2px; background: var(--line-strong); min-height: 4px; transition: background 0.2s; }
.player .bars i.on { background: var(--brand); }
.player time { font-size: 0.8rem; color: var(--muted); min-width: 42px; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------------- games ---------------- */
.game { max-width: 760px; margin: 0 auto; }
.game-top { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.progress { flex: 1; height: 10px; border-radius: 6px; background: var(--tint-3); overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); transition: width 0.4s var(--ease); }
.timer { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--danger-soft); color: var(--danger); font-weight: 800; font-variant-numeric: tabular-nums; }
.timer.calm { background: var(--brand-soft); color: var(--brand-text); }
.timer svg { width: 16px; height: 16px; }
.q-card { text-align: center; padding: clamp(24px, 5vw, 42px) clamp(16px, 4vw, 34px); border-radius: 24px; background: var(--hero); color: #fff; position: relative; overflow: hidden; box-shadow: var(--shadow); }
.q-card .quote-text { color: #fff; font-size: clamp(1.4rem, 3.4vw, 2rem); }
.q-card .quote-text::before, .q-card .quote-text::after { color: var(--warm); }
.q-card .lbl { display: inline-block; margin-bottom: 12px; font-size: 0.88rem; color: rgba(255, 255, 255, 0.82); }
.choices { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-top: 20px; }
.choices.n2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choices.n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 640px) { .choices, .choices.n3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.choice {
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 18px 10px; border-radius: 18px; cursor: pointer;
  background: var(--surface); border: 2px solid var(--line); font-weight: 700; color: var(--text); transition: transform 0.15s, border-color 0.2s, background 0.2s;
}
.choice:hover:not(:disabled) { transform: translateY(-3px); border-color: var(--brand); }
.choice:disabled { cursor: default; }
.choice.picked { border-color: var(--brand); background: var(--brand-soft); }
.choice.right { border-color: var(--ok); background: var(--ok-soft); }
.choice.wrong { border-color: var(--danger); background: var(--danger-soft); }
.result-burst { text-align: center; padding: 10px 0 0; font-weight: 800; font-size: 1.15rem; }
.result-burst.ok { color: var(--ok); }
.result-burst.bad { color: var(--danger); }
.big-score { font-size: clamp(2.6rem, 8vw, 4rem); font-weight: 900; line-height: 1; background: linear-gradient(135deg, var(--warm), var(--brand)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 90; }

/* battles */
.vs-wrap { display: grid; grid-template-columns: 1fr auto 1fr; gap: 18px; align-items: stretch; }
.vs { align-self: center; width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; color: #fff; background: linear-gradient(135deg, var(--brand), var(--danger)); box-shadow: 0 6px 18px var(--hero-glow); }
@media (max-width: 760px) { .vs-wrap { grid-template-columns: 1fr; } .vs { justify-self: center; margin: -8px 0; z-index: 1; } }
.fighter { display: flex; flex-direction: column; gap: 14px; text-align: center; align-items: center; }
.fighter .quote-text { font-size: 1.25rem; }
.meter { width: 100%; height: 10px; border-radius: 6px; background: var(--tint-3); overflow: hidden; }
.meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); border-radius: 6px; transition: width 0.6s var(--ease); }
.meter.warm i { background: linear-gradient(90deg, var(--warm), var(--danger)); }

/* leaderboard */
.podium { display: grid; grid-template-columns: 1fr 1.15fr 1fr; gap: 14px; align-items: end; margin-bottom: 18px; }
.podium .p { text-align: center; padding: 18px 10px 14px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); }
.podium .p.first { padding-top: 26px; background: linear-gradient(180deg, var(--warm-soft), var(--surface)); border-color: var(--warm); }
.podium .crown { font-size: 1.8rem; display: block; }
.podium b { display: block; margin-top: 6px; }
.podium .pts { font-weight: 900; font-size: 1.25rem; color: var(--brand-text); }
.rank { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; background: var(--tint-2); flex-shrink: 0; }
.rank.r1 { background: var(--warm-soft); color: var(--warm-text); }
.lb-row.me { background: var(--brand-soft); border-radius: 12px; }

/* timeline */
.timeline { position: relative; padding-inline-start: 26px; }
.timeline::before { content: ''; position: absolute; inset-inline-start: 8px; top: 6px; bottom: 6px; width: 2px; background: var(--line-strong); border-radius: 2px; }
.tl-group { position: relative; margin-bottom: 26px; }
.tl-group > h3 { margin: 0 0 12px; font-family: var(--font-head); font-size: 1.15rem; position: relative; }
.tl-group > h3::before { content: ''; position: absolute; inset-inline-start: -24px; top: 9px; width: 14px; height: 14px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.memory-card { overflow: hidden; padding: 0; }
.memory-card .cover { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; background: var(--tint-2); display: grid; place-items: center; font-size: 2.6rem; }
.memory-card .body { padding: 14px 16px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; cursor: zoom-in; }

/* profile */
.profile-head { overflow: hidden; padding: 0; }
.profile-cover { height: 180px; background: var(--hero); position: relative; }
.profile-cover img { width: 100%; height: 100%; object-fit: cover; opacity: 0.55; }
.profile-info { display: flex; align-items: flex-end; gap: 18px; padding: 0 24px 20px; margin-top: -58px; position: relative; flex-wrap: wrap; }
.profile-info h1 { margin: 0; font-family: var(--font-head); font-size: 1.7rem; }
@media (max-width: 760px) { .profile-info { flex-direction: column; align-items: center; text-align: center; } .profile-cover { height: 130px; } }

/* charts */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .grid-line { stroke: var(--line); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.82rem; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 6px; }
.hbar { display: grid; grid-template-columns: minmax(80px, 34%) 1fr auto; gap: 10px; align-items: center; font-size: 0.86rem; padding: 5px 0; }
.hbar .lab { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .bar { height: 10px; border-radius: 6px; background: var(--tint-3); overflow: hidden; }
.hbar .bar i { display: block; height: 100%; border-radius: 6px; background: var(--chart-1); }

/* owner */
.live-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 var(--ok); animation: live 1.8s infinite; display: inline-block; }
.live-dot.idle { background: var(--warm); animation: none; }
@keyframes live { 70% { box-shadow: 0 0 0 8px transparent; } }
.ev { display: grid; grid-template-columns: 74px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 0.88rem; }
.ev time { color: var(--muted); font-variant-numeric: tabular-nums; }
.ev.inferred { color: var(--muted); font-style: italic; }
.ev .fail { color: var(--danger); }
.drawer {
  position: fixed; inset-block: 0; inset-inline-end: 0; width: min(440px, 100vw); background: var(--surface); z-index: 60;
  border-inline-start: 1px solid var(--line-strong); box-shadow: var(--shadow); padding: 20px; overflow-y: auto; animation: slide-in 0.22s var(--ease);
}
@keyframes slide-in { from { transform: translateX(-30px); opacity: 0; } }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: 0.88rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* banner (privacy, updates) */
.banner {
  position: fixed; bottom: 18px; inset-inline-start: 50%; transform: translateX(50%); width: min(680px, calc(100vw - 24px)); z-index: 80;
  display: flex; gap: 14px; align-items: center; padding: 14px 18px; border-radius: 18px; background: var(--surface-3); border: 1px solid var(--line-strong); box-shadow: var(--shadow);
}
@media (max-width: 760px) { .banner { bottom: calc(84px + env(safe-area-inset-bottom)); flex-direction: column; align-items: stretch; } }

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