@font-face { font-family: "Geist"; src: url("fonts/geist.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("fonts/geist-mono.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Instrument Serif"; src: url("fonts/instrument-serif.woff2") format("woff2"); font-style: normal; font-weight: 400; font-display: swap; }
@font-face { font-family: "Instrument Serif"; src: url("fonts/instrument-serif-italic.woff2") format("woff2"); font-style: italic; font-weight: 400; font-display: swap; }
/* Layout: one quiet centered column per screen. The gate is a single key field, home is four
   destinations, the dashboard is a list of keys with sheets that slide over it. */
:root {
  --bg: #ffffff;
  --surface: #f5f5f7;
  --raised: #ffffff;
  --line: #e5e5ea;
  --line-strong: #d2d2d9;
  --fg: #0b0b0d;
  --muted: #66666f;
  --faint: #a1a1aa;
  --star: #a8730f;
  --star-soft: rgba(168, 115, 15, .12);
  --danger: #c0352b;
  --danger-soft: rgba(192, 53, 43, .09);
  --ok: #1d8549;
  --scrim: rgba(250, 250, 252, .72);
  --shadow: 0 1px 2px rgba(12, 12, 24, .05), 0 12px 32px rgba(12, 12, 24, .07);
  --display: "Instrument Serif", "Cormorant Garamond", Georgia, serif;
  --body: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --surface: #0a0a0b; --raised: #0d0d0f; --line: #1b1b1f; --line-strong: #2a2a30;
    --fg: #f4f4f6; --muted: #8c8c95; --faint: #55555d; --star: #e9b84f; --star-soft: rgba(233, 184, 79, .13);
    --danger: #ff6a5c; --danger-soft: rgba(255, 106, 92, .1); --ok: #4ec27e; --scrim: rgba(0, 0, 0, .74);
    --shadow: 0 0 0 1px var(--line); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000000; --surface: #0a0a0b; --raised: #0d0d0f; --line: #1b1b1f; --line-strong: #2a2a30;
  --fg: #f4f4f6; --muted: #8c8c95; --faint: #55555d; --star: #e9b84f; --star-soft: rgba(233, 184, 79, .13);
  --danger: #ff6a5c; --danger-soft: rgba(255, 106, 92, .1); --ok: #4ec27e; --scrim: rgba(0, 0, 0, .74);
  --shadow: 0 0 0 1px var(--line); color-scheme: dark;
}

html, body { height: 100%; }
body {
  background: var(--bg); color: var(--fg); font: 15px/1.5 var(--body);
  font-variant-numeric: lining-nums; -webkit-font-smoothing: antialiased;
  transition: background-color .5s var(--ease), color .5s var(--ease);
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--star); outline-offset: 2px; border-radius: 8px; }

.app { min-height: 100%; display: grid; grid-template-rows: auto 1fr; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-block: 18px; padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px));
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-size: 22px; letter-spacing: .01em; background: none; border: 0; padding: 0; }
.brand .mark { width: 18px; height: 18px; color: var(--star); }
.top-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px;
  border: 1px solid transparent; background: none; color: var(--muted);
  transition: background-color .2s, color .2s, border-color .2s;
}
.icon-btn:hover { background: var(--surface); color: var(--fg); border-color: var(--line); }
.icon-btn svg { width: 18px; height: 18px; }

.screen {
  padding-block: 24px 64px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  animation: screen-in .7s var(--ease) both;
}
@keyframes screen-in { from { opacity: 0; transform: translateY(10px) scale(.99); filter: blur(4px); } }
.screen.leaving { animation: screen-out .32s var(--ease) both; }
@keyframes screen-out { to { opacity: 0; transform: translateY(-8px) scale(.99); filter: blur(4px); } }

/* ---------- gate ---------- */
.gate { display: grid; place-items: center; min-height: calc(100% - 40px); }
.gate-inner { width: min(440px, 100%); display: grid; justify-items: center; gap: 28px; text-align: center; margin-top: -6vh; }
.gate-star { width: 64px; height: 64px; color: var(--star); filter: drop-shadow(0 0 22px var(--star-soft)); animation: breathe 5s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.06) rotate(8deg); } }
.gate h1 { font-family: var(--display); font-weight: 400; font-size: clamp(38px, 8vw, 52px); line-height: 1; margin: 0; letter-spacing: -.01em; text-wrap: balance; }
.gate p.lede { margin: -14px 0 0; color: var(--muted); }
.key-form { width: 100%; display: grid; gap: 12px; }
.key-field {
  position: relative; display: flex; align-items: center; gap: 8px; height: 58px; padding: 0 8px 0 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  transition: border-color .25s, box-shadow .35s var(--ease), background-color .25s;
}
.key-field:focus-within { border-color: var(--star); box-shadow: 0 0 0 5px var(--star-soft); background: var(--raised); }
.key-field.bad { border-color: var(--danger); box-shadow: 0 0 0 5px var(--danger-soft); animation: shake .42s var(--ease); }
@keyframes shake { 20% { transform: translateX(-7px); } 45% { transform: translateX(6px); } 70% { transform: translateX(-3px); } }
.key-field input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: none; height: 100%;
  font-family: var(--mono); font-size: 17px; letter-spacing: .08em; text-transform: uppercase;
}
.key-field input::placeholder { color: var(--faint); letter-spacing: .08em; }
.go {
  height: 42px; padding: 0 16px; border-radius: 11px; border: 0; background: var(--fg); color: var(--bg);
  font-weight: 500; display: flex; align-items: center; gap: 6px; transition: opacity .2s, transform .2s var(--ease);
}
.go:disabled { opacity: .25; cursor: default; }
.go:not(:disabled):hover { transform: translateX(2px); }
.go svg { width: 16px; height: 16px; }
.gate .hint { font-size: 13px; color: var(--muted); min-height: 20px; transition: color .2s; }
.gate .hint.bad { color: var(--danger); }
.unlocking .gate-star { animation: unlock .9s var(--ease) forwards; }
@keyframes unlock { 40% { transform: scale(.82) rotate(-20deg); } 100% { transform: scale(1.5) rotate(180deg); opacity: 0; } }

/* ---------- home ---------- */
.home { width: min(760px, 100%); margin: 0 auto; display: grid; gap: 28px; padding-top: 4vh; }
.home h1 { font-family: var(--display); font-weight: 400; font-size: clamp(40px, 9vw, 64px); line-height: 1; margin: 0; text-wrap: balance; text-align: center; }
.home h1 em { color: var(--star); }
.home .sub { color: var(--muted); margin: -16px 0 0; text-align: center; }
/* icon-only destinations: the name is in the tooltip and for screen readers */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 128px)); justify-content: center; gap: 12px; }
.tile {
  position: relative; display: grid; place-items: center; aspect-ratio: 1; max-width: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: 22px; overflow: hidden;
  transition: transform .45s var(--ease), border-color .3s, background-color .3s;
  animation: tile-in .8s var(--ease) both; animation-delay: calc(var(--i) * 70ms + 120ms);
}
@keyframes tile-in { from { opacity: 0; transform: translateY(14px) scale(.96); } }
.tile::after {
  content: ""; position: absolute; inset: 15%; border-radius: 50%;
  background: radial-gradient(closest-side, var(--star-soft), transparent); opacity: 0; transition: opacity .5s;
}
.tile:hover { transform: translateY(-3px); border-color: var(--line-strong); background: var(--raised); }
.tile:hover::after { opacity: 1; }
.tile:active { transform: translateY(-1px) scale(.97); }
.tile svg { position: relative; z-index: 1; width: clamp(26px, 30%, 36px); height: auto; aspect-ratio: 1; transition: transform .45s var(--ease), color .3s; }
.tile:hover svg { transform: scale(1.08); color: var(--star); }
.whoami { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 16px; }
.link-btn { background: none; border: 0; padding: 4px 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-strong); }
.link-btn:hover { color: var(--fg); }

/* ---------- dashboard ---------- */
.dash { width: min(920px, 100%); margin: 0 auto; display: grid; gap: 22px; }
.dash-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 14px; }
.dash-head h1 { font-family: var(--display); font-weight: 400; font-size: clamp(34px, 7vw, 48px); line-height: 1; margin: 0; }
.eyebrow { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.example { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--star); background: var(--star-soft); padding: 3px 9px; border-radius: 999px; }
.btn {
  height: 40px; padding: 0 16px; border-radius: 11px; border: 1px solid var(--line); background: var(--raised);
  font-weight: 500; display: inline-flex; align-items: center; gap: 8px; transition: background-color .2s, border-color .2s, transform .2s var(--ease);
}
.btn:hover { border-color: var(--line-strong); }
.btn.primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.btn.primary:hover { transform: translateY(-1px); }
.btn.danger { color: var(--danger); }
.btn.danger.armed { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn svg { width: 16px; height: 16px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stat { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 2px; }
.stat b { font-size: 26px; font-weight: 500; font-variant-numeric: tabular-nums lining-nums; }
.stat span { font-size: 13px; color: var(--muted); }
.stat.warn b { color: var(--danger); }

.panel { border: 1px solid var(--line); border-radius: 18px; overflow: hidden; background: var(--raised); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.keys { list-style: none; margin: 0; padding: 0; }
.key-row {
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.4fr) minmax(0, .9fr) auto; align-items: center; gap: 14px;
  padding: 14px 18px; border-bottom: 1px solid var(--line); transition: background-color .2s;
  animation: tile-in .6s var(--ease) both; animation-delay: calc(var(--i) * 50ms);
}
.key-row:last-child { border-bottom: 0; }
.key-row:hover { background: var(--surface); }
.key-row.revoked { opacity: .45; }
.key-name { display: grid; gap: 2px; min-width: 0; }
.key-name b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.key-name small { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.chip.owner { color: var(--star); border-color: transparent; background: var(--star-soft); }
.meta { font-size: 13px; color: var(--muted); display: grid; gap: 1px; font-variant-numeric: tabular-nums lining-nums; }
.meta .live { color: var(--ok); }
.row-actions { display: flex; gap: 4px; }

.activity { list-style: none; margin: 0; padding: 6px 0; }
.activity li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 12px; align-items: baseline; padding: 9px 18px; font-size: 14px; }
.activity .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); transform: translateY(-1px); }
.activity .dot.bad { background: var(--danger); }
.activity .dot.mid { background: var(--faint); }
.activity time { color: var(--muted); font-size: 13px; white-space: nowrap; }
.activity .what { min-width: 0; overflow-wrap: anywhere; }
.activity .what span { color: var(--muted); }

/* ---------- sheets (block everything behind; click outside closes) ---------- */
.scrim {
  position: fixed; inset: 0; z-index: 40; background: var(--scrim); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  display: grid; place-items: center; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-bottom, 0px));
  animation: fade .35s var(--ease) both;
}
.scrim.closing { animation: fade .25s var(--ease) reverse both; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: min(480px, 100%); max-height: 100%; overflow: auto; background: var(--raised); border: 1px solid var(--line);
  border-radius: 20px; box-shadow: var(--shadow); padding: 22px; display: grid; gap: 18px;
  animation: sheet-in .5s var(--ease) both;
}
.scrim.closing .sheet { animation: sheet-in .25s var(--ease) reverse both; }
@keyframes sheet-in { from { opacity: 0; transform: translateY(16px) scale(.98); } }
.sheet h3 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 30px; line-height: 1.05; }
.sheet .note { margin: -8px 0 0; color: var(--muted); font-size: 14px; }
.field { display: grid; gap: 7px; }
.field > span { font-size: 13px; color: var(--muted); }
.text {
  height: 44px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface); padding: 0 14px; outline: 0;
  transition: border-color .2s, box-shadow .3s var(--ease);
}
.text:focus { border-color: var(--star); box-shadow: 0 0 0 4px var(--star-soft); }
.toggles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.toggle {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); text-align: left; transition: border-color .2s, background-color .2s;
}
.toggle .box { width: 18px; height: 18px; border-radius: 6px; border: 1.5px solid var(--line-strong); display: grid; place-items: center; flex: none; transition: background-color .2s, border-color .2s; }
.toggle .box svg { width: 12px; height: 12px; color: var(--bg); opacity: 0; transform: scale(.6); transition: opacity .2s, transform .3s var(--ease); }
.toggle[aria-pressed="true"] { border-color: var(--fg); background: var(--raised); }
.toggle[aria-pressed="true"] .box { background: var(--fg); border-color: var(--fg); }
.toggle[aria-pressed="true"] .box svg { opacity: 1; transform: none; }
.toggle small { display: block; color: var(--muted); font-size: 12px; }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line); border-radius: 11px; padding: 3px; background: var(--surface); }
.segmented button { height: 34px; border: 0; border-radius: 8px; background: none; color: var(--muted); transition: background-color .25s, color .25s; }
.segmented button[aria-pressed="true"] { background: var(--raised); color: var(--fg); box-shadow: 0 0 0 1px var(--line); }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.reveal { display: grid; gap: 10px; padding: 16px; border-radius: 14px; background: var(--surface); border: 1px dashed var(--line-strong); }
.reveal code { font-family: var(--mono); font-size: clamp(16px, 4.6vw, 20px); letter-spacing: .06em; overflow-wrap: anywhere; }
.reveal .warn { font-size: 13px; color: var(--danger); }
.devices { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.devices li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; }
.devices b { font-weight: 500; }
.devices small { display: block; color: var(--muted); font-size: 12px; }
.this-device { color: var(--star); font-size: 12px; margin-left: 6px; }

.toast {
  position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom, 0px)); z-index: 60; transform: translateX(-50%);
  background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: calc(100% - 32px);
  animation: toast 2.6s var(--ease) both;
}
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, 10px); } 12%, 85% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; transform: translate(-50%, 4px); } }

@media (max-width: 640px) {
  .ban-form { grid-template-columns: minmax(0, 1fr); }
  .tiles { gap: 10px; }
  .stats { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .stats .stat:last-child { grid-column: 1 / -1; }
  .key-row { grid-template-columns: minmax(0, 1fr) auto; }
  .key-row .chips, .key-row .meta { grid-column: 1 / -1; }
  .key-row .row-actions { grid-row: 1; grid-column: 2; }
  .toggles { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; }
}

/* ---------- added for the real page ---------- */
body { margin: 0; }
[hidden] { display: none !important; }
:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack { display: grid; gap: 8px; }
.stack-lg { display: grid; gap: 18px; }
.loading { display: grid; place-items: center; min-height: 60vh; }
.loading svg { width: 34px; height: 34px; color: var(--star); animation: breathe 1.6s ease-in-out infinite; }
.notice { display: grid; place-items: center; min-height: calc(100% - 40px); text-align: center; }
.notice .gate-inner { gap: 16px; }
.notice p { color: var(--muted); margin: 0; }
.bans { list-style: none; margin: 0; padding: 0; }
.bans li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.bans li:last-child { border-bottom: 0; }
.bans code { font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; }
.bans small { display: block; color: var(--muted); font-size: 12px; }
.empty { padding: 18px; color: var(--muted); font-size: 14px; }
.activity .act { background: none; border: 0; padding: 0; color: var(--danger); font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }
.ban-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line); }
.form-error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 0; }
.danger-zone { display: grid; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.danger-zone p { margin: 0; font-size: 13px; color: var(--muted); }
a.tile { color: inherit; text-decoration: none; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.notice h1 { font-family: var(--display); font-weight: 400; font-size: clamp(34px, 7vw, 46px); line-height: 1.05; margin: 0; text-wrap: balance; }
.notice .row { justify-content: center; margin-top: 6px; }
/* the key page fills exactly the space under the top bar, so focusing the field never scrolls */
#view { display: grid; min-height: 0; }
.screen { box-sizing: border-box; min-width: 0; }
.gate, .notice { min-height: 0; }
