:root {
  --bg: #16131c;
  --panel: #201b29;
  --panel-2: #2a2335;
  --line: #3a3147;
  --text: #f1ecf7;
  --muted: #a99fb8;
  --accent: #f6b8d1;
  --accent-ink: #2b1622;
  --accent-2: #a9d8f5;
  --ok: #9be3b6;
  --err: #ff9a9a;
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
code, .mono { font-family: var(--mono); font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* ---------- layout ---------- */
.topbar {
  display: flex; align-items: center; gap: 1.25rem;
  padding: .75rem max(16px, calc((100vw - 1100px) / 2));
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 85%, transparent);
  position: sticky; top: 0; z-index: 5; backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 6px;
  background:
    linear-gradient(var(--line), var(--line)) 50% 0 / 1px 100% no-repeat,
    linear-gradient(var(--line), var(--line)) 0 50% / 100% 1px no-repeat,
    linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: inset 0 0 0 2px #0003;
}
.nav { display: flex; gap: .25rem; flex: 1; }
.nav a { color: var(--muted); padding: .35rem .7rem; border-radius: 999px; }
.nav a:hover { color: var(--text); text-decoration: none; background: var(--panel-2); }
.nav a.active { color: var(--accent-ink); background: var(--accent); }
.who { display: flex; align-items: center; gap: .6rem; color: var(--muted); font-size: .9rem; }

main { max-width: 1100px; margin: 0 auto; padding: 1.5rem 16px 4rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.crumbs { color: var(--muted); font-size: .9rem; margin-bottom: .25rem; }
.crumbs a { color: var(--muted); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; }
.card + .card { margin-top: 1rem; }
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1rem; align-items: start; }
.stack > * + * { margin-top: 1rem; }
@media (max-width: 820px) { .grid-2 { grid-template-columns: 1fr; } .nav { display: none; } }

.stats { display: flex; gap: .75rem; flex-wrap: wrap; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: .3rem .9rem; color: var(--muted); font-size: .9rem; }
.stat b { color: var(--text); }

/* ---------- forms ---------- */
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .3rem; }
input[type=text], input[type=password], input[type=number], select {
  width: 100%; padding: .55rem .7rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit;
}
input:focus, select:focus { outline: 2px solid var(--accent-2); outline-offset: 1px; border-color: transparent; }
input[type=color] { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.field { margin-bottom: .85rem; }
.row { display: flex; gap: .75rem; align-items: end; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 120px; }
.check { display: flex; align-items: center; gap: .5rem; color: var(--text); font-size: .95rem; margin-bottom: .6rem; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.hint { font-size: .8rem; color: var(--muted); margin-top: .25rem; }

.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .55rem 1rem; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { border-color: var(--accent-2); text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--err); }
.btn.danger:hover { border-color: var(--err); }
.btn.sm { padding: .3rem .7rem; font-size: .85rem; }
.btn.ghost { background: transparent; }

.drop {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 1.2rem; text-align: center;
  color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s;
}
.drop.over, .drop:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.drop input { display: none; }
.drop strong { color: var(--text); }

.flash { padding: .7rem 1rem; border-radius: 10px; margin-bottom: 1rem; border: 1px solid; }
.flash.ok { border-color: color-mix(in srgb, var(--ok) 50%, transparent); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.flash.error { border-color: color-mix(in srgb, var(--err) 50%, transparent); background: color-mix(in srgb, var(--err) 10%, transparent); }

/* ---------- streamer cards ---------- */
.streamers { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 1rem; }
.streamer-card { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: var(--text); }
.streamer-card:hover { text-decoration: none; border-color: var(--accent); }
.streamer-card .cover { aspect-ratio: 16 / 10; background: var(--panel-2) center / cover no-repeat; image-rendering: pixelated; display: grid; place-items: center; color: var(--muted); font-size: 2rem; }
.streamer-card .body { padding: .7rem .9rem; }
.streamer-card .body .mono { color: var(--muted); }

/* ---------- image gallery ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; }
.tile-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: var(--text); display: block; }
.tile-card:hover { text-decoration: none; border-color: var(--accent); }
.tile-card .thumb { background: var(--checker); background-color: var(--bg); padding: .6rem; display: grid; place-items: center; aspect-ratio: 1; }
.tile-card .body { padding: .6rem .8rem; }
.badge { display: inline-block; font-size: .75rem; padding: .05rem .5rem; border-radius: 999px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }

/* ---------- map preview with tile grid ---------- */
:root {
  --checker: conic-gradient(#ffffff0d 25%, transparent 0 50%, #ffffff0d 0 75%, transparent 0) 0 0 / 16px 16px;
}
.mapframe { position: relative; width: 100%; max-height: 100%; background: var(--checker); background-color: #0d0b11; border-radius: 6px; overflow: hidden; }
.mapframe img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.mapframe .grid {
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(to right, #000a 1px, transparent 1px),
    linear-gradient(to bottom, #000a 1px, transparent 1px);
  box-shadow: inset 0 0 0 1px #000a;
}
.thumb .mapframe { max-width: 100%; }
.preview-wrap { background: var(--bg); border-radius: var(--radius); border: 1px solid var(--line); padding: 1rem; }
.preview-empty { color: var(--muted); text-align: center; padding: 2.5rem 1rem; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
tr.revoked td { opacity: .45; }

.keybox { display: flex; gap: .5rem; align-items: center; background: var(--bg); border: 1px solid var(--accent); border-radius: 10px; padding: .6rem .8rem; }
.keybox code { flex: 1; word-break: break-all; }
pre.config { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: .8rem 1rem; overflow-x: auto; font-family: var(--mono); font-size: .85rem; margin: .5rem 0 0; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: min(380px, 100%); }
.login .brand { justify-content: center; margin-bottom: 1rem; font-size: 1.15rem; }

details summary { cursor: pointer; color: var(--muted); }
details[open] summary { margin-bottom: .75rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }
