:root {
  --bg: #0c1412;
  --panel: #121d1a;
  --line: #213430;
  --text: #e4eee9;
  --muted: #84978f;
  --up: #52e0a3;
  --up-bg: rgba(82, 224, 163, 0.16);
  --down: #ff7a6b;
  --down-bg: rgba(255, 122, 107, 0.16);
  --lamp: #f0c05a;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); }
body {
  margin: 0;
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
main { max-width: 620px; margin: 0 auto; padding: 20px 16px 48px; }
header { margin-bottom: 8px; }
h1 { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 28px; letter-spacing: -0.02em; }
h2 { margin: 0 0 10px; font-size: 18px; }
h3 { margin: 14px 0 6px; font-size: 14px; font-weight: 600; color: var(--muted); }
section { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); }
.muted { color: var(--muted); font-size: 14px; margin: 6px 0 0; }
.error { color: var(--down); font-size: 14px; min-height: 1.2em; margin: 6px 0 0; }
.head { display: flex; justify-content: space-between; align-items: center; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }

.lamp { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); }
.lamp.on { background: var(--lamp); box-shadow: 0 0 0 4px rgba(240, 192, 90, 0.18); animation: glow 2.4s ease-in-out infinite; }
.lamp.bad { background: var(--down); }
@keyframes glow { 50% { box-shadow: 0 0 0 7px rgba(240, 192, 90, 0.05); } }
@media (prefers-reduced-motion: reduce) { .lamp.on { animation: none; } }

button, input, select {
  font: inherit; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; min-height: 44px;
}
button { background: var(--lamp); color: #1a1405; border-color: var(--lamp); font-weight: 600; cursor: pointer; }
button.ghost { background: transparent; color: var(--text); border-color: var(--line); }
button:disabled { opacity: 0.5; cursor: default; }
button.x { min-height: 32px; padding: 2px 10px; background: transparent; color: var(--muted); border-color: var(--line); }
:focus-visible { outline: 2px solid var(--lamp); outline-offset: 2px; }

form { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
form input[type=number] { grid-column: 1; }
#r-symbol { text-transform: uppercase; }

ul { list-style: none; margin: 0; padding: 0; }
.movers li {
  --w: 0%;
  display: grid; grid-template-columns: 1fr auto 74px; gap: 12px; align-items: center;
  padding: 9px 10px; border-radius: 6px; margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}
.movers li.up { background: linear-gradient(90deg, var(--up-bg) var(--w), transparent var(--w)); }
.movers li.down { background: linear-gradient(90deg, var(--down-bg) var(--w), transparent var(--w)); }
.movers .sym { font-weight: 600; }
.movers .px { color: var(--muted); font-size: 14px; }
.movers .chg { text-align: right; font-weight: 600; }
.movers .up .chg { color: var(--up); }
.movers .down .chg { color: var(--down); }

.plain li { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.plain .t { font-weight: 600; }
.plain .b { color: var(--muted); font-size: 14px; }
.plain time { color: var(--muted); font-size: 13px; white-space: nowrap; }
.empty { color: var(--muted); font-size: 14px; padding: 6px 0; }

/* ---------- Shared additions: auth, tabs, cards, switches, admin ---------- */
a { color: var(--lamp); }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 6px; }
.topbar .who { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.topbar nav { display: flex; gap: 8px; align-items: center; }
.linkbtn { background: none; border: 0; color: var(--lamp); padding: 6px 4px; min-height: 36px; font-weight: 500; text-decoration: underline; cursor: pointer; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: 4px; }
.seg button, .tabs button { background: transparent; color: var(--muted); border: 0; border-radius: 0; font-weight: 600; min-height: 40px; padding: 8px 18px; }
.seg button[aria-pressed=true], .tabs button[aria-current=page] { background: var(--lamp); color: #1a1405; }

.check { display: flex; align-items: center; gap: 10px; padding: 8px 0; cursor: pointer; }
.check input { width: 22px; height: 22px; min-height: 0; accent-color: var(--lamp); }

.badge { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 2px 7px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); vertical-align: middle; }
.badge.alpha { color: var(--lamp); border-color: rgba(240,192,90,.5); }
.badge.spot { color: #7fb7ff; border-color: rgba(127,183,255,.5); }
.badge.admin { color: var(--up); border-color: rgba(82,224,163,.5); }
.badge.off { color: var(--down); border-color: rgba(255,122,107,.5); }

button.switch { position: relative; flex: none; width: 52px; height: 30px; min-height: 30px; padding: 0; border-radius: 15px; background: var(--panel); border: 1px solid var(--line); }
button.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
button.switch[aria-checked=true] { background: var(--lamp); border-color: var(--lamp); }
button.switch[aria-checked=true]::after { transform: translateX(22px); background: #1a1405; }
@media (prefers-reduced-motion: reduce) { button.switch::after { transition: none; } }

.auth { max-width: 400px; margin: 0 auto; padding: 56px 16px 40px; }
.auth h1 { margin-bottom: 4px; }
.auth form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.auth .tabs { margin-top: 24px; }
.tabs { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.tabs button { flex: 1; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.field input, .field select { width: 100%; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 14px; }
.card h3 { margin-top: 0; font-size: 16px; color: var(--text); }
.card p { margin: 6px 0 0; }
.split { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.grid2 .card { margin-bottom: 0; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 14px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin: 14px 0; }
.stat { border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.stat b { display: block; font-size: 24px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 13px; }

.wide main { max-width: 880px; }
.wide .tabs { margin: 18px 0 8px; }
.user { display: flex; flex-direction: column; gap: 10px; }
.user .meta { color: var(--muted); font-size: 13px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions button { min-height: 36px; padding: 4px 12px; font-size: 14px; background: transparent; color: var(--text); border-color: var(--line); font-weight: 500; }
.actions button.danger { color: var(--down); border-color: rgba(255,122,107,.5); }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: var(--text); color: #0c1412; padding: 10px 16px; border-radius: 8px; font-weight: 600; transition: opacity .2s, transform .2s; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--down); }
textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; width: 100%; min-height: 80px; resize: vertical; }
.plain li > div { min-width: 0; overflow-wrap: anywhere; }
#rule-form input[type=number] { grid-column: auto; }
#rule-form button { grid-column: 1 / -1; }

/* ---------- App pages: tab bar, history, settings ---------- */
body.has-nav main { padding-bottom: calc(92px + env(safe-area-inset-bottom)); }
body.has-nav .toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
section.first { border-top: 0; margin-top: 14px; padding-top: 0; }
.pagehead p { margin: 4px 0 0; }

.bottomnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: rgba(14, 24, 21, .96); backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.bottomnav ul { display: flex; max-width: 620px; margin: 0 auto; }
.bottomnav li { flex: 1; }
.bottomnav a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 4px 8px; color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 600; }
.bottomnav a[aria-current=page] { color: var(--lamp); }
.bottomnav svg { width: 24px; height: 24px; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.seg.full { display: flex; width: 100%; }
.seg.full button { flex: 1; padding-left: 6px; padding-right: 6px; }
.hist li { align-items: flex-start; }
.hist .side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
.hist .reason { color: var(--muted); font-size: 13px; margin-top: 2px; }
.pill { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: 2px 9px; border-radius: 99px; border: 1px solid; white-space: nowrap; }
.pill.sent { color: var(--up); border-color: rgba(82, 224, 163, .5); }
.pill.skipped { color: var(--lamp); border-color: rgba(240, 192, 90, .5); }
.pill.muted { color: var(--muted); border-color: var(--line); }
.badge.meme { color: #d9a0ff; border-color: rgba(217, 160, 255, .5); }

.setting { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; }
.setting .name { font-weight: 600; }
.setting .desc { color: var(--muted); font-size: 14px; margin-top: 2px; }
.setting.stack { flex-direction: column; align-items: stretch; }

/* ---------- Unread badge, muted-coin chips ---------- */
.bottomnav a { position: relative; }
.navbadge { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--lamp); color: #1a1405; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.hist li.unread { box-shadow: inset 3px 0 0 var(--lamp); padding-left: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 99px; padding: 3px 4px 3px 12px; font-weight: 600; }
.chip .x { min-height: 28px; min-width: 28px; padding: 0; border: 0; border-radius: 50%; font-size: 18px; line-height: 1; }
#mute-symbol { flex: 1; min-width: 0; text-transform: uppercase; }

/* ---------- Sign-in extras ---------- */
.ok { color: var(--up); font-size: 14px; min-height: 1.2em; margin: 6px 0 0; }
.auth-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; }
.auth-links .linkbtn { padding: 4px 0; min-height: 32px; }

/* ---------- Critical alerts ---------- */
.badge.critical { color: #ff6b6b; border-color: rgba(255, 107, 107, .6); font-weight: 700; }
.critical-overlay { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; background: #7a0f0f; color: #fff; animation: crit-flash 1s steps(2, end) infinite; }
@keyframes crit-flash { 50% { background: #b21818; } }
@media (prefers-reduced-motion: reduce) { .critical-overlay { animation: none; } }
.critical-overlay h2 { margin: 0; font-size: 28px; }
.critical-overlay p { margin: 0; font-size: 18px; max-width: 30em; }
.critical-overlay .crit-icon { font-size: 64px; line-height: 1; }
.critical-overlay button { background: #fff; color: #7a0f0f; border-color: #fff; font-size: 18px; min-height: 52px; padding: 0 28px; }
details.howto { margin-top: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 4px 14px; background: var(--panel); }
details.howto summary { cursor: pointer; font-weight: 600; padding: 10px 0; }
details.howto h3 { margin: 14px 0 4px; color: var(--text); }
details.howto ol { margin: 0 0 8px; padding-left: 20px; }
details.howto li, details.howto p { color: var(--muted); font-size: 14px; margin-bottom: 6px; }

/* ---------- Coins page, wall / aggression badges ---------- */
.badge.up { color: var(--up); border-color: rgba(82, 224, 163, .5); }
.badge.down { color: var(--down); border-color: rgba(255, 122, 107, .5); }
.bigsearch { width: 100%; font-size: 17px; padding: 12px 14px; margin-bottom: 12px; }
.coins li { display: grid; grid-template-columns: 1fr auto 76px; gap: 12px; align-items: center; padding: 11px 4px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.coins .cn { min-width: 0; display: flex; flex-direction: column; }
.coins .sym { font-weight: 600; }
.coins .nm { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.coins .cp { display: flex; flex-direction: column; align-items: flex-end; font-size: 15px; }
.coins .vol { color: var(--muted); font-size: 12px; }
.coins .cc { text-align: right; font-weight: 600; color: var(--muted); }
.coins .cc.up { color: var(--up); }
.coins .cc.down { color: var(--down); }
#more { margin-top: 12px; width: 100%; }

/* ---------- Newer alert types ---------- */
.badge.warn { color: var(--lamp); border-color: rgba(240, 192, 90, .6); }
.plain .b, .hist .b { white-space: pre-line; }

#delist-box { margin-bottom: 22px; }
.user h2 { margin: 6px 0 10px; }

.appbox { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 22px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.appbox strong { display: block; font-size: 15px; }
.appbox span { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.appbtn { flex: none; padding: 10px 16px; border-radius: 10px; border: 0; background: var(--lamp); color: #1a1405; font: 600 14px system-ui, sans-serif; text-decoration: none; cursor: pointer; }

.logo { display: block; flex: none; }

/* Admin tab bar: five tabs must fit on a narrow phone. Tighter padding, and it scrolls sideways if still too wide. */
.wide .tabs { overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.wide .tabs::-webkit-scrollbar { display: none; }
.wide .tabs button { flex: 1 0 auto; padding: 8px 6px; font-size: 14px; white-space: nowrap; }
@media (min-width: 480px) { .wide .tabs button { padding: 8px 18px; } }
