:root {
  --bg: #0b0b0d;
  --surface: #141417;
  --surface-2: #1c1c21;
  --line: #26262d;
  --text: #f3f3f5;
  --muted: #8d8d98;
  --faint: #5d5d68;
  --accent: #e0242f;
  --accent-2: #ff4a54;
  --accent-soft: rgba(224, 36, 47, 0.14);
  --ok: #34c77b;
  --ok-soft: rgba(52, 199, 123, 0.14);
  --warn: #f5a524;
  --warn-soft: rgba(245, 165, 36, 0.14);
  --radius: 18px;
  --tab-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --display: "Unbounded", var(--font);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 500 15px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
img { display: block; }
svg { width: 18px; height: 18px; flex: none; }

#app { max-width: 560px; margin: 0 auto; min-height: 100vh; }
#main { padding: 16px 16px calc(var(--tab-h) + var(--safe-b) + 24px); }

/* ---------- boot / screens ---------- */
.boot { min-height: 80vh; display: grid; place-items: center; }
.logo {
  font: 800 28px/1 var(--display);
  letter-spacing: 0.14em;
  background: linear-gradient(180deg, #fff 0%, #ffd9db 45%, var(--accent) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.boot .logo { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }

.screen { min-height: 80vh; display: flex; flex-direction: column; justify-content: center; gap: 14px; text-align: center; padding: 0 8px; }
.screen .logo { font-size: 34px; margin-bottom: 8px; }
.screen p { color: var(--muted); margin: 0; }
.code-box {
  font: 800 38px/1 var(--display); letter-spacing: 0.18em;
  padding: 22px 12px; border-radius: var(--radius);
  background: var(--surface); border: 1px dashed var(--accent);
  user-select: all;
}
.cmd { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text); background: var(--surface-2); padding: 2px 6px; border-radius: 6px; }

/* ---------- header ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 2px 16px; }
.page-head h1 { font: 800 22px/1.15 var(--display); margin: 0; letter-spacing: 0.01em; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.brand { font: 800 13px/1 var(--display); letter-spacing: 0.22em; color: var(--accent-2); }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
}
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 12px; font-weight: 700; font-size: 15px; }
.card-title .muted { font-weight: 500; font-size: 13px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.section-label { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; margin: 22px 4px 10px; }

/* hero */
.hero { position: relative; overflow: hidden; padding: 18px; }
.hero::before {
  content: ""; position: absolute; inset: -40% -20% auto auto; width: 240px; height: 240px;
  background: radial-gradient(circle, var(--accent-soft) 0%, transparent 70%); pointer-events: none;
}
.hero-row { display: flex; align-items: center; gap: 14px; position: relative; }
.hero-name { font: 800 19px/1.2 var(--display); margin: 0 0 4px; word-break: break-word; }
.hero-user { color: var(--muted); font-size: 13px; }
.status { display: inline-flex; align-items: center; gap: 6px; margin-top: 14px; font-size: 13px; color: var(--muted); position: relative; }
.status.live { color: var(--ok); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.live .dot { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); animation: pulse 1.6s infinite; }

/* avatar */
.ava {
  --s: 40px; width: var(--s); height: var(--s); flex: none; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--line); position: relative; overflow: hidden;
  display: grid; place-items: center; font-weight: 800; color: var(--muted); font-size: calc(var(--s) * 0.4);
}
.ava img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* rank */
.rank {
  --c: var(--muted);
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700;
  color: var(--c); padding: 3px 9px 3px 7px; border-radius: 999px;
  background: color-mix(in srgb, var(--c) 14%, transparent);
  white-space: nowrap;
}
.rank::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--c); }

/* stats */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.stat-v { font: 800 20px/1.1 var(--display); letter-spacing: -0.01em; }
.stat-l { color: var(--muted); font-size: 12px; margin-top: 6px; }
.stat.accent { background: linear-gradient(160deg, #2a0d10 0%, var(--surface) 70%); border-color: #3a1519; }

/* chart */
.chart { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding-top: 6px; }
.bar { flex: 1; height: 100%; display: flex; align-items: flex-end; border-radius: 4px; min-width: 0; }
.bar i {
  display: block; width: 100%; height: var(--h); min-height: 2px; border-radius: 4px 4px 2px 2px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  opacity: 0.85; transition: opacity 0.15s, transform 0.15s;
}
.bar.zero i { background: var(--line); opacity: 1; }
.bar.sel i { opacity: 1; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85); }
.chart-axis { display: flex; justify-content: space-between; color: var(--faint); font-size: 11px; margin-top: 8px; }
.chart-cap { color: var(--muted); font-size: 13px; margin-bottom: 10px; min-height: 18px; }
.chart-cap b { color: var(--text); }

/* lists */
.list { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); width: 100%; text-align: left; }
.row:first-child { border-top: 0; padding-top: 0; }
.row:last-child { padding-bottom: 0; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.row-end { text-align: right; flex: none; font-weight: 700; }
.row.locked { opacity: 0.55; }
.row.me { background: var(--accent-soft); margin: 0 -10px; padding-left: 10px; padding-right: 10px; border-radius: 12px; border-top-color: transparent; }
.row.me + .row { border-top-color: transparent; }

.place { width: 26px; text-align: center; font: 800 14px/1 var(--display); color: var(--faint); flex: none; }
.place.p1 { color: #ffd34d; } .place.p2 { color: #d7dbe3; } .place.p3 { color: #e39a5c; }

.meter { height: 4px; border-radius: 4px; background: var(--surface-2); margin-top: 6px; overflow: hidden; }
.meter i { display: block; height: 100%; width: var(--w); background: var(--accent); border-radius: 4px; }

.icons { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); }
.icons svg { width: 15px; height: 15px; }
.warn-count { color: var(--warn); font-weight: 800; font-size: 12px; display: inline-flex; gap: 3px; align-items: center; }
.warn-count svg { width: 14px; height: 14px; }

/* chips / segmented */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 12px; padding: 0 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 8px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line);
  font-size: 13px; font-weight: 700; color: var(--muted);
}
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 4px; margin-bottom: 14px; }
.seg button { padding: 9px 6px; border-radius: 10px; font-weight: 700; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--surface-2); color: var(--text); box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 12px; padding: 4px 9px; border-radius: 8px; background: var(--surface-2); color: var(--muted); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 18px; border-radius: 14px; font-weight: 800; font-size: 15px;
  background: var(--accent); color: #fff; width: 100%;
  transition: transform 0.1s, opacity 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.danger { background: transparent; color: var(--accent-2); border: 1px solid #3a1519; }
.btn.sm { padding: 9px 14px; font-size: 13px; width: auto; border-radius: 12px; }
.icon-btn { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; color: var(--muted); background: var(--surface-2); flex: none; }
.icon-btn svg { width: 18px; height: 18px; }

/* events */
.event { display: flex; gap: 14px; align-items: flex-start; cursor: pointer; }
.ev-date {
  width: 52px; flex: none; text-align: center; border-radius: 14px; padding: 8px 0;
  background: var(--accent-soft); color: var(--accent-2);
}
.ev-date b { display: block; font: 800 20px/1 var(--display); color: var(--text); }
.ev-date span { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; }
.ev-body { flex: 1; min-width: 0; }
.ev-body h3 { margin: 2px 0 4px; font-size: 16px; font-weight: 800; }
.counts { display: flex; gap: 10px; margin-top: 8px; font-size: 13px; color: var(--muted); font-weight: 700; }
.counts .y { color: var(--ok); } .counts .m { color: var(--warn); } .counts .n { color: var(--accent-2); }
.rsvp { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 14px; }
.rsvp button {
  padding: 10px 4px; border-radius: 12px; background: var(--surface-2); font-weight: 700; font-size: 13px; color: var(--muted);
  border: 1px solid transparent;
}
.rsvp button.on.yes { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.rsvp button.on.maybe { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.rsvp button.on.no { background: var(--accent-soft); color: var(--accent-2); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.soon { color: var(--warn); font-weight: 800; }
.desc { white-space: pre-wrap; word-break: break-word; margin: 0; }
.avatars { display: flex; flex-wrap: wrap; gap: 10px 8px; }
.person { display: flex; align-items: center; gap: 8px; background: var(--surface-2); padding: 4px 10px 4px 4px; border-radius: 999px; font-size: 13px; font-weight: 700; max-width: 100%; }
.person span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* news */
.news-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.news-head .row-main { min-width: 0; }
.news-text { white-space: pre-wrap; word-break: break-word; line-height: 1.5; }

/* warnings */
.warning { border-left: 3px solid var(--warn); padding: 2px 0 2px 12px; margin-top: 12px; display: flex; gap: 10px; align-items: flex-start; }
.warning:first-of-type { margin-top: 0; }
.warning .row-main { font-weight: 600; }
.warn-card { border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); }

/* forms */
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 700; }
.input {
  width: 100%; padding: 13px 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line);
  outline: none; font-size: 15px; resize: vertical;
}
.input:focus { border-color: var(--accent); }
textarea.input { min-height: 96px; }
.search { position: relative; margin-bottom: 12px; }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--faint); }
.search .input { padding-left: 40px; }
input[type="datetime-local"].input { color-scheme: dark; min-height: 48px; }

/* voice */
.channel-name { display: flex; align-items: center; gap: 8px; font-weight: 800; margin-bottom: 12px; }
.channel-name svg { width: 16px; height: 16px; color: var(--muted); }
.channel-name .faint { font-weight: 600; font-size: 12px; }

/* empty / skeleton */
.empty { text-align: center; color: var(--muted); padding: 36px 16px; }
.empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }
.sk { background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: sk 1.2s linear infinite; border-radius: var(--radius); margin-bottom: 12px; }
@keyframes sk { to { background-position: -200% 0; } }

/* tabbar */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center;
  background: rgba(11, 11, 13, 0.88); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
#tabbar .inner { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; width: 100%; max-width: 560px; height: var(--tab-h); }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--faint); font-size: 11px; font-weight: 700; }
.tab svg { width: 22px; height: 22px; }
.tab.on { color: var(--text); }
.tab.on svg { color: var(--accent-2); }

/* sheet */
.sheet-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); z-index: 40; animation: fade 0.2s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-width: 560px; margin: 0 auto;
  background: var(--surface); border-radius: 22px 22px 0 0; border: 1px solid var(--line); border-bottom: 0;
  padding: 10px 16px calc(16px + var(--safe-b)); max-height: 90vh; overflow-y: auto;
  animation: up 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet .grip { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 0 auto 14px; }
.sheet h2 { font: 800 18px/1.2 var(--display); margin: 0 0 16px; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(100%); } }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-b) + 16px); transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 700; font-size: 14px;
  opacity: 0; pointer-events: none; transition: 0.2s; z-index: 50; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--accent); color: #fff; }

.mt { margin-top: 12px; }
.gap { display: flex; gap: 8px; }
@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }
