:root {
  color-scheme: dark;
  --bg: #100c18;
  --card: #1b1430;
  --sunken: #120e1e;
  --ink: #f6f1ff;
  --muted: #b3a6c9;
  --line: #3a2d52;
  --accent: #8b5cf6;
  --accent-ink: #ffffff;
  --accent-soft: rgba(139, 92, 246, 0.2);
  --danger: #ff9b9b;
  --danger-bg: rgba(255, 90, 110, 0.14);
  --ok: #8ee0b0;
  --ok-bg: rgba(80, 200, 140, 0.16);
  --warn: #f0c36a;
  --warn-bg: rgba(240, 195, 106, 0.16);
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
  --radius: 16px;
  --pad: 16px;
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button, input, textarea { font: inherit; color: inherit; }

h1, h2, p { margin: 0; }

.app, .gate {
  width: min(760px, 100%);
  margin: 0 auto;
}

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px var(--pad);
}

.gate-card, .card, .stat, .table-wrap {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.gate-card {
  display: grid;
  gap: 12px;
  padding: 28px 24px;
  width: min(100%, 420px);
}

.eyebrow {
  color: #c4b5fd;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; }
h2, .page-title { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
p { line-height: 1.45; }

.top {
  position: sticky;
  top: 0;
  z-index: 4;
  display: grid;
  gap: 10px;
  padding: calc(12px + env(safe-area-inset-top)) var(--pad) 12px;
  background: rgba(16, 12, 24, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.top-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  align-items: flex-end;
}

.back {
  justify-self: start;
  width: fit-content;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #2a2144;
  color: #d8ccf5;
  font-weight: 700;
  cursor: pointer;
}

.back:hover, button.stat:hover, .item:hover { border-color: #6d4ec2; }
.back:active { transform: translateY(1px); }
.back:focus-visible, button.stat:focus-visible, .tabs button:focus-visible, .item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.who {
  margin-left: auto;
  color: var(--muted);
  font-size: 14px;
  text-align: right;
}

.view {
  padding: 16px var(--pad) calc(108px + env(safe-area-inset-bottom));
  display: grid;
  gap: 16px;
  align-content: start;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat { padding: 14px var(--pad); }

button.stat {
  position: relative;
  display: block;
  width: 100%;
  padding-right: 36px;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

button.stat::after {
  content: "›";
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
}

button.stat:active { transform: translateY(1px); }

.stat span { display: block; color: var(--muted); font-size: 13px; }
.stat strong {
  display: block;
  margin-top: 4px;
  font-size: clamp(18px, 5vw, 26px);
  letter-spacing: -0.03em;
  overflow-wrap: anywhere;
}
.stat.wide { grid-column: 1 / -1; }

.card {
  display: grid;
  gap: 12px;
  padding: var(--pad);
  align-content: start;
}

.list { display: grid; gap: 10px; }

.item {
  display: grid;
  gap: 6px;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px var(--pad);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.item:active { transform: translateY(1px); }

.row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.title { font-weight: 700; min-width: 0; }
.muted { color: var(--muted); font-size: 14px; }
.meta { color: var(--ink); }

.pill {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 4px 10px;
  background: #2a223c;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  white-space: nowrap;
}

.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--danger-bg); color: var(--danger); }

.actions, .form, .presets { display: grid; gap: 10px; }

.presets { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.presets.pair { grid-template-columns: 1fr 1fr; }

.btn, .presets button {
  width: 100%;
  border-radius: 12px;
  border: 1px solid #6d4ec2;
  background: #2a2144;
  color: var(--ink);
  min-height: 44px;
  padding: 10px 14px;
  cursor: pointer;
}

.btn.primary, .presets button.on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}

.btn.danger {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: rgba(255, 155, 155, 0.45);
}

.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: #d8ccf5;
}

.btn:disabled, .presets button:disabled { opacity: 0.45; cursor: default; }

.field { display: grid; gap: 6px; font-size: 14px; }
.field span { color: var(--muted); }

input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--sunken);
  color: var(--ink);
  padding: 12px 14px;
}

textarea { min-height: 88px; resize: vertical; }

input:focus, textarea:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

.search { margin: 0; }
.tools { display: grid; gap: 10px; }

.tabs {
  position: fixed;
  left: 50%;
  bottom: 0;
  width: min(760px, 100%);
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: rgba(16, 12, 24, 0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.tabs button {
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  min-height: 44px;
  padding: 8px 4px;
  font-size: 11px;
  line-height: 1.2;
  white-space: normal;
  cursor: pointer;
}

.tabs button.active {
  color: var(--accent-ink);
  font-weight: 700;
  background: var(--accent);
}

.link {
  color: #c4b5fd;
  font-weight: 700;
  word-break: break-word;
}

.empty {
  padding: 28px 8px;
  text-align: center;
  color: var(--muted);
}

.toast {
  position: fixed;
  left: var(--pad);
  right: var(--pad);
  bottom: calc(84px + env(safe-area-inset-bottom));
  margin: 0 auto;
  width: min(728px, calc(100% - 32px));
  background: #2a2148;
  color: var(--ink);
  border: 1px solid #6d4ec2;
  border-radius: 14px;
  padding: 12px 14px;
  z-index: 5;
}

.note {
  padding: 12px;
  border-radius: 12px;
  background: var(--sunken);
  color: var(--ink);
  font-size: 14px;
}

.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.metric {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--sunken);
  border: 1px solid var(--line);
}

.metric span { display: block; color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin-top: 2px; font-size: 18px; font-variant-numeric: tabular-nums; }

.player-wrap {
  width: min(100%, 325px);
  height: 575px;
  justify-self: center;
  border-radius: 16px;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--line);
}

.player {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.proofs {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.proof {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
  background: var(--sunken);
  border: 1px solid var(--line);
}

.table-wrap { overflow-x: auto; }

.authors {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
}

.authors th, .authors td {
  padding: 12px 14px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
}

.authors th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: #221838;
}

.authors tr:last-child td { border-bottom: 0; }

.authors tbody tr { cursor: pointer; }
.authors tbody tr:hover, .authors tbody tr:focus { background: var(--accent-soft); outline: none; }

.authors .num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.person { display: grid; gap: 2px; }
.person span { color: var(--muted); font-size: 13px; }

@media (max-width: 760px) {
  .table-wrap { overflow: visible; }
  .authors { min-width: 0; }
  .authors thead { display: none; }
  .authors tr {
    display: grid;
    gap: 8px;
    padding: 14px;
    border-bottom: 1px solid var(--line);
  }
  .authors tr:last-child { border-bottom: 0; }
  .authors td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 0;
    border: 0;
    white-space: normal;
  }
  .authors td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }
}
