@font-face {
  font-family: "Hanken Grotesk";
  src: url("/static/fonts/hanken-grotesk-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/static/fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 800;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --paper: #eef1f6;
  --surface: #ffffff;
  --ink: #131a2e;
  --muted: #5a637c;
  --line: #d6dce8;
  --accent: #3f4fe8;
  --accent-ink: #ffffff;
  --accent-wash: #e4e7ff;
  --good: #0b7f63;
  --danger: #c22f48;
  --plate: #1a2150;
  --plate-ink: #eef0ff;
  --radius: 10px;
  --sans: "Hanken Grotesk", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0d111e;
    --surface: #151a2c;
    --ink: #e8ebf7;
    --muted: #9aa3be;
    --line: #29314b;
    --accent: #909cff;
    --accent-ink: #0d111e;
    --accent-wash: #20275a;
    --good: #5fd6b4;
    --danger: #ff7d92;
    --plate: #1a2150;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 1.9rem; line-height: 1.1; letter-spacing: -.03em; font-weight: 720; margin: 0; }
h2 { font-size: 1.1rem; letter-spacing: -.01em; font-weight: 680; margin: 0 0 .75rem; }
p { margin: 0; }
a { color: var(--accent); }
code, .mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--muted); }
.lede { color: var(--muted); margin-top: .4rem; max-width: 62ch; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- Controls ---------- */
.btn {
  font: inherit;
  font-weight: 600;
  font-size: .93rem;
  padding: .5rem .95rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}
a.btn { display: inline-block; text-decoration: none; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: var(--surface); }
.btn.quiet { background: transparent; }
.btn.small { font-size: .84rem; padding: .3rem .65rem; }
.btn:disabled { opacity: .55; cursor: default; }
.link { font: inherit; font-weight: 600; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; }

label { display: block; font-size: .88rem; font-weight: 620; }
input:not([type=checkbox]), textarea {
  display: block;
  width: 100%;
  margin-top: .3rem;
  font: inherit;
  font-weight: 400;
  padding: .55rem .7rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}
textarea { min-height: 7rem; resize: vertical; }
input:focus-visible, textarea:focus-visible { outline-offset: 0; border-color: var(--accent); }
.check { display: flex; gap: .55rem; align-items: center; font-weight: 500; font-size: .95rem; }
.check input { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); }
.stack > * + * { margin-top: .9rem; }
.hint { font-size: .86rem; color: var(--muted); margin-top: .35rem !important; overflow-wrap: anywhere; }
.form-error { color: var(--danger); font-weight: 600; font-size: .92rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }

.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.segmented button { font: inherit; font-size: .9rem; font-weight: 600; padding: .4rem .85rem; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.segmented button + button { border-left: 1px solid var(--line); }
.segmented button[aria-pressed=true] { background: var(--accent-wash); color: var(--ink); }

/* ---------- Signed out ---------- */
/* Signed out: the site's own look. Black, the rain, Courier, thin pale lines. */
.auth {
  position: fixed; inset: 0; overflow: auto;
  background: #000; color: #fff;
  font-family: "Courier New", Courier, monospace;
  font-size: 12px; letter-spacing: .15em;
  text-transform: lowercase;
}
#auth-rain { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; opacity: .55; pointer-events: none; }
.auth-forms {
  position: relative; z-index: 1;
  min-height: 100%; display: grid; align-content: center; justify-items: center;
  padding: 2.5rem 1.25rem; gap: 2.2rem;
}
.auth-forms form { width: 100%; max-width: 20rem; }
.auth-host { color: rgba(255,255,255,.6); letter-spacing: .25em; }
.auth h1 { font: inherit; font-size: 12px; color: rgba(255,255,255,.6); letter-spacing: .25em; margin: 0 0 1.6rem; text-align: center; }
.auth label { font: inherit; color: rgba(255,255,255,.4); }
.auth input:not([type=checkbox]) {
  font: inherit; letter-spacing: .1em; text-transform: none;
  background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.15); border-radius: 0;
  padding: .7rem .8rem; margin-top: .45rem; caret-color: #fff;
}
.auth input:focus-visible { outline: none; border-color: rgba(255,255,255,.6); }
.auth input:-webkit-autofill { -webkit-text-fill-color: #fff; -webkit-box-shadow: 0 0 0 100px #000 inset; }
.auth .btn.primary {
  font: inherit; letter-spacing: .2em; text-transform: lowercase;
  width: 100%; margin-top: 1.4rem; padding: 10px 24px; border-radius: 40px;
  background: transparent; color: rgba(255,255,255,.4); border: 1px solid rgba(255,255,255,.15);
  transition: color .3s, border-color .3s;
}
.auth .btn.primary:hover, .auth .btn.primary:focus-visible { color: rgba(255,255,255,.8); border-color: rgba(255,255,255,.4); filter: none; outline: none; }
.auth .btn.primary:disabled { opacity: .5; }
.auth .hint, .auth .switch { font: inherit; color: rgba(255,255,255,.35); line-height: 1.7; }
.auth .switch { text-align: center; }
.auth .link { font: inherit; color: rgba(255,255,255,.6); text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.25); }
.auth .link:hover { color: rgba(255,255,255,.9); border-color: rgba(255,255,255,.6); }
.auth .form-error { font: inherit; color: rgba(255,120,140,.9); line-height: 1.7; }
.auth-links { display: flex; justify-content: center; gap: 28px; }
.auth-links a { color: rgba(255,255,255,.35); text-decoration: none; transition: color .2s; }
.auth-links a:hover, .auth-links a:focus-visible { color: rgba(255,255,255,.8); outline: none; }

.app { min-height: 100dvh; display: grid; grid-template-columns: 15rem minmax(0, 1fr); }
.rail {
  position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column; gap: 1.6rem;
  padding: 1.5rem 1rem;
  border-right: 1px solid var(--line);
  background: var(--surface);
}
.rail-host { font-weight: 760; font-size: 1.2rem; letter-spacing: -.03em; color: var(--ink); text-decoration: none; padding: 0 .6rem; overflow-wrap: anywhere; }
.rail-nav { display: flex; flex-direction: column; gap: .15rem; flex: 1; }
.rail-nav a { display: block; padding: .5rem .6rem; border-radius: 8px; color: var(--muted); font-weight: 600; text-decoration: none; }
.rail-nav a:hover { color: var(--ink); }
.rail-nav a[aria-current=page] { background: var(--accent-wash); color: var(--ink); }
.rail-nav .nav-gap { margin-top: 1.1rem; padding: 0 .6rem .3rem; font-size: .8rem; font-weight: 600; color: var(--muted); }
.rail-foot { display: flex; flex-direction: column; gap: .6rem; padding: 0 .6rem; }
.rail-user { font-weight: 650; overflow-wrap: anywhere; }

.view { padding: clamp(1.25rem, 3.5vw, 2.75rem); max-width: 68rem; width: 100%; outline: none; }
.view-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.6rem; }
.block { margin-top: 2.2rem; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel.pad { padding: 1.1rem 1.2rem; }

/* Address list */
.lines { list-style: none; margin: 0; padding: 0; }
.lines li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .7rem 1.2rem; }
.lines li + li { border-top: 1px solid var(--line); }
.lines .address { font-weight: 620; overflow-wrap: anywhere; }

/* Invite tickets */
.tickets { display: grid; grid-template-columns: repeat(auto-fill, minmax(17.5rem, 1fr)); gap: .9rem; }
.ticket {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.ticket-main { padding: 1rem 1.1rem; min-width: 0; }
.ticket-code { font-family: var(--mono); font-size: 1.12rem; font-weight: 600; letter-spacing: .01em; overflow-wrap: anywhere; }
.ticket-status { margin-top: .3rem; font-size: .9rem; color: var(--muted); }
.ticket-stub {
  position: relative;
  display: flex; flex-direction: column; justify-content: center; gap: .4rem;
  padding: .8rem .9rem;
  border-left: 1.5px dashed var(--line);
}
/* The two notches where the stub tears off */
.ticket-stub::before, .ticket-stub::after {
  content: ""; position: absolute; left: -9px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--paper); border: 1px solid var(--line);
}
.ticket-stub::before { top: -9px; clip-path: inset(50% 0 0 0); }
.ticket-stub::after { bottom: -9px; clip-path: inset(0 0 50% 0); }
.ticket.open { border-color: var(--accent); }
.ticket.open .ticket-stub { border-left-color: var(--accent); }
.ticket.open .ticket-stub::before, .ticket.open .ticket-stub::after { border-color: var(--accent); }
.ticket.used .ticket-code, .ticket.revoked .ticket-code { color: var(--muted); text-decoration: line-through; }
.ticket.used .ticket-status { color: var(--good); font-weight: 620; }
.ticket-stub .stamp { font-size: .84rem; color: var(--muted); text-align: center; min-width: 4.5rem; }

/* Tables */
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th { text-align: left; font-size: .84rem; font-weight: 620; color: var(--muted); padding: .7rem 1rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: .7rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.right, th.right { text-align: right; }
.name { font-weight: 650; }
.tag { display: inline-block; font-size: .78rem; font-weight: 650; padding: .08rem .45rem; border-radius: 999px; background: var(--accent-wash); margin-left: .4rem; vertical-align: 1px; }
.tag.gone { background: transparent; border: 1px solid var(--line); color: var(--muted); }
tr.gone .name { text-decoration: line-through; color: var(--muted); }
.status-used { color: var(--good); font-weight: 620; }
.empty { padding: 2rem 1.2rem; color: var(--muted); }

/* Who invited whom */
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { margin-left: .7rem; padding-left: 1.1rem; border-left: 1.5px solid var(--line); }
.tree li { padding: .28rem 0; }
.tree .count { color: var(--muted); font-size: .88rem; margin-left: .45rem; }
.tree .gone { text-decoration: line-through; color: var(--muted); }

/* Sites */
.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr)); gap: 1.6rem; align-items: start; }
.video { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr) auto; gap: .8rem; align-items: start; padding: .8rem 1.2rem; }
.video + .video { border-top: 1px solid var(--line); }
.video .thumb { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; background: var(--line); display: block; }
.video .title { font-weight: 620; overflow-wrap: anywhere; }
.video-quote { margin: .3rem 0 0; white-space: pre-line; overflow-wrap: anywhere; font-weight: 560; line-height: 1.35; }
.video-meta { gap: .35rem 1rem; margin-top: .3rem; }
.video-meta .hint { margin-top: 0 !important; }
.video-actions { display: flex; flex-direction: column; gap: .4rem; align-items: stretch; }
.status-busy { color: var(--accent, var(--ink)); }
.status-bad { color: var(--danger); }
.add-form { padding: 1.1rem 1.2rem; border-top: 1px solid var(--line); }

/* Dialog and toast */
.dialog {
  border: 1px solid var(--line); border-radius: 14px; padding: 0;
  width: min(30rem, calc(100vw - 2rem));
  background: var(--surface); color: var(--ink);
  box-shadow: 0 24px 70px rgba(10, 14, 40, .28);
}
.dialog::backdrop { background: rgba(10, 14, 30, .5); }
.dialog-body { padding: 1.4rem 1.5rem 1.5rem; }
.dialog-body h2 { font-size: 1.25rem; letter-spacing: -.02em; margin-bottom: .5rem; }
.dialog-actions { margin-top: 1.4rem; }
.secret {
  display: flex; justify-content: space-between; align-items: center; gap: .8rem;
  padding: .7rem .85rem; border-radius: 8px; background: var(--paper); border: 1px solid var(--line);
  font-family: var(--mono); font-weight: 600; overflow-wrap: anywhere;
}
.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%);
  background: var(--ink); color: var(--paper);
  padding: .6rem 1rem; border-radius: 999px; font-weight: 600; font-size: .92rem;
  max-width: calc(100vw - 2rem); z-index: 10;
}

/* ---------- Small screens ---------- */
@media (max-width: 52rem) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; padding: .8rem 1rem; border-right: 0; border-bottom: 1px solid var(--line); }
  .rail-nav { flex-direction: row; flex: 1 1 100%; order: 3; overflow-x: auto; gap: .2rem; }
  .rail-nav a { white-space: nowrap; }
  .rail-nav .nav-gap { display: none; }
  .rail-foot { flex-direction: row; align-items: center; margin-left: auto; padding: 0; }
  .video { grid-template-columns: 5rem minmax(0, 1fr); }
  .video-actions { grid-column: 2; flex-direction: row; flex-wrap: wrap; }
}

/* Small pieces */
.block-tight { margin-top: 1rem; }
.tools { margin-bottom: 1rem; }
.narrow { max-width: 26rem; }
.label-text { font-size: .88rem; font-weight: 620; margin-bottom: .45rem; }
.check + .check { margin-top: .35rem; }
.row > input { flex: 1; min-width: 10rem; margin-top: 0; }
.thumb { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; background: var(--line); display: block; }
input[type=file] { padding: .4rem; }
