/* PandaLinks dashboard. Dark by default, light when the system asks for it. */
:root {
  --bg: #080c11;
  --bg2: #0d131b;
  --card: rgba(18, 26, 35, 0.82);
  --card-solid: #121a23;
  --line: #213041;
  --line2: #2b3d52;
  --ink: #e9eff6;
  --ink2: #b7c4d3;
  --mute: #8193a8;
  --acc: #3ddc97;
  --acc-ink: #03140c;
  --acc-soft: rgba(61, 220, 151, 0.12);
  --warn: #f0b429;
  --err: #ff7a6b;
  --people: #1fa56d;
  --bots: #8a7fe0;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --head: Montserrat, system-ui, sans-serif;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #eef2f6;
    --bg2: #e4eaf1;
    --card: rgba(255, 255, 255, 0.9);
    --card-solid: #ffffff;
    --line: #d9e1ea;
    --line2: #c7d2de;
    --ink: #0e1822;
    --ink2: #34465a;
    --mute: #5d6e82;
    --acc: #0f9d67;
    --acc-ink: #ffffff;
    --acc-soft: rgba(15, 157, 103, 0.1);
    --warn: #a86b00;
    --err: #c8372a;
    --people: #0f8a5f;
    --bots: #7b6fd6;
    --shadow: 0 16px 40px rgba(20, 40, 60, 0.12);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow-x: hidden;
}
/* Static, never animated: a viewport-sized animated layer flickers. */
.glow {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(900px 500px at 10% -10%, rgba(61, 220, 151, 0.13), transparent 60%),
    radial-gradient(800px 500px at 100% 0%, rgba(138, 127, 224, 0.12), transparent 60%);
}
header, main { position: relative; z-index: 1; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.mono { font-family: var(--mono); }
.mute { color: var(--mute); }
.err { color: var(--err); min-height: 1.2em; margin: 8px 0 0; font-size: 14px; }
.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; max-width: 100%; }
h2, h3 { font-family: var(--head); font-weight: 900; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 20px; }
h3 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink2); margin: 22px 0 10px; }

/* Header */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 1120px; margin: 0 auto; padding: 22px 16px 8px;
}
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand img { width: 40px; height: 40px; filter: drop-shadow(0 4px 12px rgba(61, 220, 151, 0.35)); }
.brand b { display: block; font: 900 24px/1 var(--head); letter-spacing: -0.02em; }
.brand small { display: block; color: var(--mute); font-size: 13px; margin-top: 3px; }
.top-actions { display: flex; gap: 8px; }

main { max-width: 1120px; margin: 0 auto; padding: 8px 16px 80px; display: grid; gap: 18px; }
#unlocked { display: grid; gap: 18px; }
#unlocked[hidden] { display: none; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  min-width: 0;
}

/* Controls */
input, select, button, .btn {
  font: inherit; color: inherit;
  border-radius: 12px; border: 1px solid var(--line2);
  background: var(--bg2); padding: 10px 12px;
}
input:focus, select:focus { outline: 2px solid var(--acc); outline-offset: 1px; border-color: transparent; }
input::placeholder { color: var(--mute); }
button, .btn { cursor: pointer; font-weight: 700; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
button:focus-visible, .btn:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
.primary { background: var(--acc); color: var(--acc-ink); border-color: transparent; }
.primary:hover { filter: brightness(1.08); }
.primary:disabled { opacity: 0.5; cursor: default; }
.ghost { background: transparent; }
.ghost:hover { border-color: var(--acc); }
.danger { background: transparent; color: var(--err); border-color: color-mix(in srgb, var(--err) 45%, transparent); }
.danger.armed { background: var(--err); color: #fff; }
.icon { background: transparent; border: none; padding: 6px; color: var(--mute); border-radius: 10px; }
.icon:hover { color: var(--ink); background: var(--acc-soft); }
.masked { -webkit-text-security: disc; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row input { flex: 1; min-width: 0; }

/* Lock */
.lock { max-width: 520px; width: 100%; margin: 40px auto; text-align: center; }
.lock .row { margin-top: 14px; }

/* Composer */
.big-url input {
  width: 100%;
  font: 600 20px/1.3 var(--mono);
  padding: 18px 18px;
  border-radius: 16px;
  background: var(--bg2);
}
.domains { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 4px; }
.domains button {
  background: transparent; font: 700 14px var(--mono); padding: 9px 14px; border-radius: 999px;
  color: var(--ink2);
}
.domains button[aria-checked="true"] { background: var(--acc-soft); border-color: var(--acc); color: var(--ink); }
.domains button .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--acc); display: inline-block; }
.domains button .dot.pending { background: var(--warn); }
.domain-note { font-size: 13px; margin: 4px 0 0; min-height: 1.2em; }
.domain-note b { color: var(--warn); font-weight: 700; }

.slug-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 10px; }
.slug-box {
  display: flex; align-items: center; flex: 1; min-width: 0;
  border: 1px solid var(--line2); background: var(--bg2); border-radius: 12px; padding-left: 12px;
}
.slug-box:focus-within { outline: 2px solid var(--acc); outline-offset: 1px; border-color: transparent; }
.slug-host { font: 500 15px var(--mono); color: var(--mute); white-space: nowrap; }
.slug-box input { flex: 1; min-width: 60px; border: none; background: transparent; font: 700 15px var(--mono); padding-left: 2px; }
.slug-box input:focus { outline: none; }
.slug-status { font-size: 13px; font-weight: 700; min-width: 8ch; }
.slug-status.ok { color: var(--acc); }
.slug-status.bad { color: var(--err); }
.slug-status.warn { color: var(--warn); }

.opts { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.opts input[type="text"] { flex: 1; min-width: 200px; }
.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; color: var(--ink2); font-size: 14px; user-select: none; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle span { width: 38px; height: 22px; border-radius: 999px; background: var(--line2); position: relative; flex: none; transition: background 0.15s; }
.toggle span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.toggle input:checked + span { background: var(--acc); }
.toggle input:checked + span::after { transform: translateX(16px); }
.toggle input:focus-visible + span { outline: 2px solid var(--acc); outline-offset: 2px; }

.compose-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.preview { font-size: 15px; min-width: 0; overflow-wrap: anywhere; }
.preview b { color: var(--acc); }
.big { padding: 14px 30px; font-size: 16px; border-radius: 14px; }

.result {
  margin-top: 18px; padding-top: 18px; border-top: 1px dashed var(--line2);
  display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: center;
}
.result-main { display: grid; gap: 8px; min-width: 0; }
.result-url { font-size: clamp(18px, 3.4vw, 28px); font-weight: 700; color: var(--acc); text-decoration: none; overflow-wrap: anywhere; }

/* QR */
.qr-panel { display: grid; gap: 8px; justify-items: center; }
.qr-panel canvas { width: 168px; height: 168px; border-radius: 14px; background: #fff; padding: 0; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25); image-rendering: pixelated; }
.qr-panel .row { justify-content: center; }
.qr-panel button { padding: 6px 10px; font-size: 13px; }
.qr-note { font-size: 12px; color: var(--mute); max-width: 180px; text-align: center; }

/* Overview */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-head h3 { margin: 0; }
.legend { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink2); }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; margin-left: 6px; }
.sw.people { background: var(--people); }
.sw.bots { background: var(--bots); }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 16px 0; }
.tile { background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; min-width: 0; }
.tile b { display: block; font: 900 28px/1.1 var(--head); letter-spacing: -0.02em; }
.tile span { color: var(--mute); font-size: 13px; }
.tiles.small { grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 10px 0; }
.tiles.small b { font-size: 22px; }

.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .axis text { fill: var(--mute); font: 11px system-ui, sans-serif; }
.chart rect.p { fill: var(--people); }
.chart rect.b { fill: var(--bots); }
.chart rect.hit { fill: transparent; }
.chart rect.hit:hover + g rect, .chart g.col:hover rect.p, .chart g.col:hover rect.b { filter: brightness(1.2); }
.chart .empty { fill: var(--mute); font: 13px system-ui; }
.tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--card-solid); border: 1px solid var(--line2); border-radius: 10px;
  padding: 8px 10px; font-size: 13px; box-shadow: var(--shadow); white-space: nowrap;
  transform: translate(-50%, calc(-100% - 10px));
}
.tip b { display: block; }
.tip i { font-style: normal; color: var(--ink2); }

.two { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
ol.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
ol.bars li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; font-size: 14px; position: relative; padding: 6px 10px; border-radius: 8px; overflow: hidden; }
ol.bars li .fill { position: absolute; inset: 0 auto 0 0; background: var(--acc-soft); border-radius: 8px; z-index: 0; }
ol.bars li > span { position: relative; z-index: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
ol.bars li > b { position: relative; z-index: 1; font-variant-numeric: tabular-nums; }
ol.bars li.clickable { cursor: pointer; }
ol.bars li.clickable:hover > span { color: var(--acc); }
ol.bars .none { color: var(--mute); padding: 6px 0; }

/* Links */
.tools { display: flex; gap: 8px; flex-wrap: wrap; }
.tools input { width: 220px; max-width: 100%; }
.count { color: var(--mute); font: 700 15px var(--mono); margin-left: 6px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 14px 0; }
.chips button { background: transparent; border-radius: 999px; padding: 6px 12px; font-size: 13px; color: var(--ink2); }
.chips button[aria-pressed="true"] { background: var(--acc-soft); border-color: var(--acc); color: var(--ink); }
.link-list { display: grid; gap: 8px; }
.link {
  display: grid; grid-template-columns: minmax(0, 1fr) 120px 70px auto; gap: 14px; align-items: center;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg2);
  cursor: pointer; transition: border-color 0.12s;
}
.link:hover { border-color: var(--line2); }
.link:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
.link .who { min-width: 0; display: grid; gap: 2px; }
.link .short { font: 700 15px var(--mono); color: var(--acc); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link .short i { font-style: normal; color: var(--mute); font-weight: 500; }
.link .label { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link .dest { font-size: 13px; color: var(--mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link .spark { width: 120px; height: 30px; }
.link .spark path { fill: none; stroke: var(--people); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.link .spark path.area { fill: var(--people); opacity: 0.15; stroke: none; }
.link .hits { text-align: right; font: 900 18px var(--head); font-variant-numeric: tabular-nums; }
.link .hits small { display: block; font: 500 11px system-ui; color: var(--mute); }
.link .acts { display: flex; gap: 2px; }
.empty-list { text-align: center; color: var(--mute); padding: 30px 0; }

/* Drawer */
.drawer { position: fixed; inset: 0; z-index: 20; }
.drawer[hidden] { display: none; }
.drawer-scrim { position: absolute; inset: 0; background: rgba(3, 6, 10, 0.55); }
.drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(760px, 100%);
  background: var(--card-solid); border-left: 1px solid var(--line); overflow-y: auto;
  padding: 26px 24px 60px; box-shadow: var(--shadow);
}
.drawer-panel .close { position: absolute; top: 14px; right: 14px; }
.drawer-panel h2 { font-size: clamp(18px, 3vw, 24px); color: var(--acc); overflow-wrap: anywhere; margin: 2px 40px 6px 0; font-family: var(--mono); font-weight: 700; }
#dHost { margin: 0; font-size: 13px; }
.drawer-panel .dest { color: var(--ink2); margin-bottom: 14px; font-size: 14px; text-decoration: none; }
.drawer-panel .dest:hover { color: var(--acc); }
.d-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; align-items: start; margin-top: 18px; }
.d-grid .qr-panel { margin-top: 34px; }
.breakdowns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 18px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table.recent { width: 100%; border-collapse: collapse; font-size: 13px; }
table.recent th, table.recent td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.recent th { color: var(--mute); font-weight: 600; background: var(--bg2); }
table.recent tr:last-child td { border-bottom: none; }
table.recent .botrow td { color: var(--mute); }
.tag { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--line2); color: var(--ink2); }
.edit { display: grid; gap: 10px; }
.small-print { font-size: 12px; margin: 0; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0;
  background: var(--acc); color: var(--acc-ink); font-weight: 700; padding: 10px 18px; border-radius: 12px;
  transition: opacity 0.18s, transform 0.18s; z-index: 40; pointer-events: none; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 820px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two, .breakdowns { grid-template-columns: 1fr; }
  .link { grid-template-columns: minmax(0, 1fr) auto; }
  .link .spark, .link .acts { display: none; }
  .result, .d-grid { grid-template-columns: 1fr; }
  .d-grid .qr-panel { margin-top: 0; }
  .brand small { display: none; }
}
@media (max-width: 480px) {
  .card { padding: 16px; border-radius: 16px; }
  .big-url input { font-size: 16px; padding: 14px; }
  .compose-foot .big { width: 100%; }
  .tools input { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
