:root {
  --bg: #0c1210;
  --bg-2: #111a16;
  --surface: #15201b;
  --surface-2: #1b2923;
  --line: #24352d;
  --line-2: #30463b;
  --ink: #e9f2ed;
  --ink-2: #b4c4bb;
  --muted: #84978d;
  --accent: #5fd38d;
  --accent-ink: #062014;
  --accent-soft: rgba(95, 211, 141, .14);
  --live: #ff5468;
  --warn: #f2b84b;
  --bad: #ff7a7a;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  background-image: radial-gradient(1200px 500px at 15% -10%, rgba(95, 211, 141, .10), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(120, 140, 255, .07), transparent 60%);
  background-attachment: fixed;
  color: var(--ink);
  font: 15px/1.5 var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }

/* ---------- top bar ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 12px max(16px, calc((100vw - 1500px) / 2));
  background: rgba(12, 18, 16, .82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { white-space: nowrap; display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; letter-spacing: .01em; }
.brand:hover { text-decoration: none; }
.brand img { width: 30px; height: 30px; }
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; line-height: 1.1; }
.top .spacer { flex: 1; }
.live-count {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px; border-radius: 99px;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--ink-2); font-size: 13px; white-space: nowrap;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--live); box-shadow: 0 0 0 0 rgba(255, 84, 104, .6); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(255, 84, 104, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 84, 104, 0); } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--surface-2); color: var(--ink); cursor: pointer; font-weight: 600; font-size: 14px;
  white-space: nowrap; text-decoration: none;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.twitch { background: #9146ff; border-color: #9146ff; color: #fff; }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.ghost { background: transparent; }
.btn.danger { border-color: rgba(255, 122, 122, .5); color: var(--bad); background: transparent; }
.btn.danger.solid { background: var(--bad); color: #250606; }
.who { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 600; font-size: 14px; }
.who .av { width: 28px; height: 28px; border-radius: 50%; flex: none; }
.who:hover { text-decoration: none; }

main { flex: 1; width: 100%; max-width: 1500px; margin: 0 auto; padding: 22px 16px 48px; }
.foot { padding: 20px 16px 28px; text-align: center; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }
.foot a { color: var(--ink-2); }

h1 { font-size: 26px; line-height: 1.2; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 0 0 12px; }
.lede { color: var(--ink-2); margin: 0 0 20px; }
.section-head { display: flex; align-items: baseline; gap: 10px; margin: 26px 0 12px; }
.section-head h2 { margin: 0; }
.section-head .sub { color: var(--muted); font-size: 13px; }

/* ---------- live wall ---------- */
.wall {
  display: grid; gap: 14px; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr));
  /* Players stay a normal size; "Bigger" lifts the cap. */
  max-width: calc(var(--cols, 2) * var(--tilew, 640px) + (var(--cols, 2) - 1) * 14px); margin: 0 auto;
}
.wall.has-focus { max-width: none; }
/* A big player never gets taller than the window; spare width shows as black. */
.tile.focus .player { max-height: calc(100vh - 210px); min-height: 240px; }
.tile.focus .player iframe { left: 50%; width: min(100%, calc((100vh - 210px) * 16 / 9)); transform: translateX(-50%); }
.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; min-width: 0;
  transform-origin: top left; will-change: transform;
}
.tile.focus { grid-column: 1 / -1; border-color: var(--line-2); }
.tile .stage { display: grid; grid-template-columns: minmax(0, 1fr); background: #000; }
.tile.focus.chat .stage { grid-template-columns: minmax(0, 1fr) 340px; }
.tile .player { position: relative; aspect-ratio: 16 / 9; background: #000; }
.tile .player iframe, .tile .chatbox iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.tile .chatbox { position: relative; display: none; border-left: 1px solid var(--line); }
.tile.focus.chat .chatbox { display: block; }
.tile .info { display: flex; gap: 12px; align-items: center; padding: 10px 12px; min-width: 0; }
.tile .info .av { width: 40px; height: 40px; border-radius: 50%; flex: none; outline: 2px solid var(--live); outline-offset: 2px; }
.tile .meta { min-width: 0; flex: 1; }
.tile .name { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.tile .title { color: var(--ink-2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .acts { display: flex; gap: 6px; flex: none; }
.badge-live { background: var(--live); color: #fff; font-size: 11px; font-weight: 800; letter-spacing: .06em; padding: 1px 6px; border-radius: 5px; }
.empty-live {
  border: 1px dashed var(--line-2); border-radius: var(--radius); padding: 34px 20px; text-align: center; color: var(--ink-2);
  background: rgba(21, 32, 27, .5);
}
.empty-live b { display: block; color: var(--ink); font-size: 17px; margin-bottom: 4px; }

/* ---------- offline cards ---------- */
.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; display: flex; gap: 12px; align-items: center; min-width: 0;
  transform-origin: top left; will-change: transform;
}
.card .av { width: 48px; height: 48px; border-radius: 50%; flex: none; filter: grayscale(.35); }
.card .meta { min-width: 0; flex: 1; }
.card .name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .sub { color: var(--muted); font-size: 12.5px; }
.card .links { display: flex; gap: 10px; margin-top: 4px; font-size: 13px; }
.av.blank { background: var(--surface-2); display: inline-block; }

/* ---------- panels, forms ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.panel + .panel, .grid2 + .panel { margin-top: 14px; }
.grid2 > .panel { margin-top: 0; }
.grid2 { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); align-items: start; }
label.field { display: block; margin: 0 0 12px; }
label.field span { display: block; font-weight: 600; font-size: 13px; margin-bottom: 5px; }
label.field small { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
input[type=text], input[type=url], textarea {
  width: 100%; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--bg-2); outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }
textarea { min-height: 76px; resize: vertical; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 12px; cursor: pointer; }
.check input { margin-top: 4px; accent-color: var(--accent); }
.row input[type=text] { flex: 1 1 220px; width: auto; max-width: 360px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.msg { padding: 10px 12px; border-radius: 10px; font-size: 14px; margin: 10px 0 0; }
.msg.ok { background: var(--accent-soft); color: var(--accent); }
.msg.err { background: rgba(255, 122, 122, .12); color: var(--bad); }
.msg.info { background: var(--surface-2); color: var(--ink-2); }
.note-box { border: 1px solid var(--line-2); border-radius: 10px; padding: 12px; margin-top: 12px; background: var(--bg-2); }

/* ---------- me page ---------- */
.hello { display: flex; gap: 14px; align-items: center; margin-bottom: 18px; }
.hello .av { width: 58px; height: 58px; border-radius: 50%; }
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .k { color: var(--muted); font-size: 12.5px; }
.stat .v { font-size: 26px; font-weight: 750; line-height: 1.25; font-variant-numeric: tabular-nums; }
.stat .s { color: var(--ink-2); font-size: 12.5px; }

.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 4px; width: max-content; }
.heat-wrap { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.heat-days { display: grid; grid-template-rows: repeat(7, 1fr); gap: 4px; font-size: 11px; color: var(--muted); }
.heat-days span { height: 16px; line-height: 16px; }
.cell { width: 16px; height: 16px; border-radius: 4px; background: var(--surface-2); outline: none; }
.cell:focus-visible { box-shadow: 0 0 0 2px var(--ink); }
.cell.l1 { background: #1f5b3b; }
.cell.l2 { background: #2f8a57; }
.cell.l3 { background: #46b273; }
.cell.l4 { background: #7fe3a8; }
.cell.future { background: transparent; }
.cell.today { box-shadow: 0 0 0 1.5px var(--ink-2); }
.legend { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 12px; margin-top: 10px; }
.legend .cell { width: 12px; height: 12px; border-radius: 3px; }

.today-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 4px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; }
.chip .av { width: 22px; height: 22px; border-radius: 50%; }
.chip.off { opacity: .45; }
.chip.live .av { outline: 2px solid var(--live); outline-offset: 1px; }
.big-count { font-size: 30px; font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1.2; }

.bars { display: grid; gap: 7px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 150px) 1fr 64px; gap: 10px; align-items: center; font-size: 13px; }
.bar-row .n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.bar-row.me .n { color: var(--ink); font-weight: 700; }
.bar-row .track { height: 14px; border-radius: 4px; background: var(--bg-2); position: relative; }
.bar-row .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 4px 4px 0; background: #46b273; min-width: 2px; }
.bar-row.me .fill { background: #7fe3a8; }
.bar-row .h { text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums; }

table.list { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.list th.num { text-align: right; }
table.list td:first-child { white-space: nowrap; }
table.list th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.list td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.list .t { color: var(--ink-2); max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-wrap { overflow-x: auto; }

/* ---------- admin ---------- */
.person { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.person:last-child { border-bottom: 0; }
.person .av { width: 40px; height: 40px; border-radius: 50%; flex: none; }
.person .meta { flex: 1; min-width: 0; }
.person .sub { color: var(--muted); font-size: 12.5px; }
.person .quote { color: var(--ink-2); font-size: 13.5px; margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.confirm { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); }

.tip {
  position: fixed; z-index: 100; pointer-events: none; padding: 6px 9px; border-radius: 8px;
  background: #050807; border: 1px solid var(--line-2); color: var(--ink); font-size: 12.5px; white-space: nowrap;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .4);
}
.prose { max-width: 760px; }
.prose h2 { margin-top: 24px; }
.prose p, .prose li { color: var(--ink-2); }

@media (max-width: 700px) {
  .top { gap: 10px; }
  .brand small { display: none; }
  .who span { display: none; }
  #auth { flex-wrap: nowrap; }
  .tile.focus.chat .stage { grid-template-columns: minmax(0, 1fr); }
  .tile.focus.chat .chatbox { display: none; }
  .tile .info { flex-wrap: wrap; }
  .tile .acts { width: 100%; flex-wrap: wrap; }
  .tile .acts .btn { flex: 1; }
  .brand { font-size: 14px; }
  .person { flex-wrap: wrap; }
  .bar-row { grid-template-columns: 90px 1fr 52px; }
  h1 { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  .dot.on { animation: none; }
}
