/* pks-agent-dns — the phone overview.
 *
 * Ember-dark base, Agentic Orange earned rather than sprayed: it marks the one
 * write in the app (create a subdomain), the live serial, and nothing else.
 * Fonts are self-hosted; a PWA that hits Google Fonts is not offline-capable.
 */

@font-face {
  font-family: "Geist";
  src: url("GeistVF.woff") format("woff-variations"), url("GeistVF.woff") format("woff");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("GeistMono-400.woff") format("woff");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("GeistMono-700.woff") format("woff");
  font-weight: 700;
  font-display: swap;
}

:root {
  --night: #0d0d10;
  --surface: #15151a;
  --elevated: #1e1e25;
  --border: #2a2a31;
  --fg: #ededf0;
  --muted: #b4b4ba;
  --faint: #7c7c85;

  --orange: #f87f2e;
  --ember: #ffa85e;
  --forge: #d66a1f;
  --orange-12: rgba(248, 127, 46, 0.12);
  --orange-22: rgba(248, 127, 46, 0.22);
  --on-orange: #1a0f06;

  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;

  --mono: "Geist Mono", ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
  --sans: "Geist", -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, sans-serif;

  --radius: 12px;
  --shell: 620px;
}

* { box-sizing: border-box; }

/* The whole app shows and hides with the `hidden` attribute, and any class rule
   that sets its own `display` silently outranks the UA rule behind `hidden`.
   Losing that fight leaves the sign-in gate painted over a signed-in app. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--night);
  color: var(--fg);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

/* The house glow. Fixed and inert so it never intercepts a tap. */
.glow {
  position: fixed;
  inset: -30vh 0 auto 0;
  height: 60vh;
  pointer-events: none;
  background: radial-gradient(50% 50% at 50% 50%, var(--orange-12), transparent 70%);
}

/* ---- update banner ------------------------------------------------------- */
/* MUST precede .app-banner: the class sets `display:flex`, which beats the
   `hidden` attribute's UA display:none, so without this guard the banner is
   visible from first paint and detection looks permanently fired. */
.app-banner[hidden] { display: none !important; }
.app-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 9px) 16px 9px;
  background: var(--orange); color: var(--on-orange);
  font-family: var(--mono); font-size: 12px;
}
.app-banner .btn {
  background: rgba(0, 0, 0, 0.18); border-color: transparent; color: var(--on-orange);
  padding: 5px 12px; border-radius: 999px; font-size: 12px;
}
/* --banner-h is measured and written by app.js when the banner appears; the
   fallback errs high, because too much padding is a gap and too little is the
   topbar disappearing under the banner. */
body.has-banner #app { padding-top: var(--banner-h, 52px); }
/* The banner is fixed at z 30; a sticky topbar pinned to top:0 slides underneath
   it as soon as the page scrolls. Park it below the banner instead, and drop the
   safe-area padding the banner has already absorbed. */
body.has-banner .topbar {
  top: var(--banner-h, 52px);
  padding-top: 14px;
}

/* ---- chrome -------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) 18px 13px;
  background: rgba(13, 13, 16, 0.84);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand {
  font-family: var(--mono); font-size: 14px; letter-spacing: 0.02em; color: var(--fg);
}
.brand .caret { color: var(--orange); }
.status { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.status.bad { color: var(--err); }

main {
  padding: 16px 18px calc(96px + env(safe-area-inset-bottom));
  max-width: var(--shell); margin: 0 auto;
}

.crumbs {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  font-family: var(--mono); font-size: 12px; color: var(--faint);
  margin: 0 0 14px;
}
.crumbs button {
  font: inherit; color: var(--orange); background: none; border: 0; padding: 0; cursor: pointer;
}
.crumbs .sep { color: var(--border); }

.section-title {
  margin: 22px 0 10px;
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint);
}
section > .section-title:first-child { margin-top: 4px; }

.lede { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.hint { margin: 10px 0 0; color: var(--faint); font-size: 12.5px; line-height: 1.55; }
.mono { font-family: var(--mono); }

/* ---- cards, rows --------------------------------------------------------- */
.cards { display: flex; flex-direction: column; gap: 10px; }

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.card.pad { padding: 14px 15px; }

.row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; text-align: left;
  padding: 13px 15px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--fg);
  font: inherit; cursor: pointer;
}
.row:active { background: var(--elevated); }
.row-main { min-width: 0; }
.row-title { font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-title.mono { font-family: var(--mono); font-size: 14px; }
.row-sub {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.row-meta { font-family: var(--mono); font-size: 11px; color: var(--faint); text-align: right; white-space: nowrap; }
.chev { color: var(--faint); font-family: var(--mono); }

/* ---- zone header --------------------------------------------------------- */
.zone-head { padding: 15px; }
.zone-name { font-family: var(--mono); font-size: 17px; word-break: break-all; }
.zone-serial {
  display: inline-block; margin-top: 8px;
  font-family: var(--mono); font-size: 11px;
  padding: 3px 9px; border-radius: 999px;
  background: var(--orange-12); color: var(--ember); border: 1px solid var(--orange-22);
}
.kv { display: grid; grid-template-columns: 128px 1fr; gap: 6px 12px; margin-top: 14px; }
.kv dt { font-family: var(--mono); font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: 0.05em; }
.kv dd { margin: 0; font-family: var(--mono); font-size: 12.5px; color: var(--muted); word-break: break-all; white-space: pre-line; }

/* ---- rrsets -------------------------------------------------------------- */
.rr-group + .rr-group { margin-top: 10px; }
.rr-name {
  padding: 10px 15px 9px;
  font-family: var(--mono); font-size: 13px; color: var(--fg);
  background: var(--elevated); border-bottom: 1px solid var(--border);
  word-break: break-all;
}
.rr-name .zsfx { color: var(--faint); }
.rr-set { padding: 11px 15px; }
.rr-set + .rr-set { border-top: 1px solid var(--border); }
.rr-head { display: flex; align-items: baseline; gap: 9px; }
.rr-type {
  font-family: var(--mono); font-size: 11px; font-weight: 700; letter-spacing: 0.05em;
  color: var(--ember); background: var(--orange-12);
  border: 1px solid var(--orange-22); border-radius: 5px; padding: 1px 7px;
}
.rr-ttl { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.rr-data {
  margin: 8px 0 0; padding: 0; list-style: none;
  font-family: var(--mono); font-size: 12.5px; color: var(--muted);
}
.rr-data li { word-break: break-all; }
.rr-data li + li { margin-top: 4px; }

/* ---- audit --------------------------------------------------------------- */
.audit-item { padding: 12px 15px; }
.audit-item + .audit-item { border-top: 1px solid var(--border); }
.audit-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.audit-event { font-family: var(--mono); font-size: 12.5px; color: var(--fg); }
.audit-when { font-family: var(--mono); font-size: 11px; color: var(--faint); white-space: nowrap; }
.audit-sub { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 4px; word-break: break-all; }
.chan {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--faint); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; margin-left: 6px;
}

/* ---- states -------------------------------------------------------------- */
.empty {
  font-family: var(--mono); font-size: 12px; color: var(--faint);
  padding: 26px 6px; text-align: center; line-height: 1.7;
}
.stale {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0 0 12px; padding: 10px 13px;
  border: 1px solid rgba(239, 68, 68, 0.32); border-radius: var(--radius);
  background: rgba(239, 68, 68, 0.08);
  font-family: var(--mono); font-size: 12px; color: #ffb3b3;
}
.stale button {
  font: inherit; color: var(--fg); background: none;
  border: 1px solid var(--border); border-radius: 999px; padding: 4px 11px; cursor: pointer;
}
.skeleton {
  height: 58px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface);
  opacity: 0.55;
}

/* ---- buttons ------------------------------------------------------------- */
.btn {
  font: inherit; font-family: var(--mono); font-size: 13px;
  padding: 10px 16px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--elevated); color: var(--fg);
  cursor: pointer; text-decoration: none; display: inline-block; text-align: center;
}
.btn:active { background: var(--surface); }
.btn-primary { background: var(--orange); border-color: var(--orange); color: var(--on-orange); font-weight: 700; }
.btn-primary:active { background: var(--forge); border-color: var(--forge); }
.btn-primary[disabled] { opacity: 0.5; }
.btn-block { display: block; width: 100%; }

/* The one write in the app gets the one orange button that floats. */
.fab {
  position: fixed; right: 18px; z-index: 20;
  bottom: calc(18px + env(safe-area-inset-bottom));
  padding: 13px 20px; border-radius: 999px;
  border: 0; background: var(--orange); color: var(--on-orange);
  font-family: var(--mono); font-size: 13px; font-weight: 700;
  box-shadow: 0 8px 26px rgba(248, 127, 46, 0.26);
  cursor: pointer;
}
.fab:active { background: var(--forge); }

/* ---- gate ---------------------------------------------------------------- */
.gate {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 24px; position: relative; z-index: 1;
}
.gate-card {
  width: 100%; max-width: 360px; text-align: center;
  border: 1px solid var(--border); border-radius: 16px;
  background: var(--surface); padding: 28px 22px;
}
.gate-brand { font-family: var(--mono); font-size: 17px; margin-bottom: 12px; }
.gate-brand .caret { color: var(--orange); }
.gate-lede { color: var(--muted); font-size: 14px; margin: 0 0 20px; }
.gate-note { color: var(--faint); font-family: var(--mono); font-size: 11.5px; margin: 16px 0 0; line-height: 1.6; }

/* ---- sheet --------------------------------------------------------------- */
body.sheet-open { overflow: hidden; }
.sheet-back {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0, 0, 0, 0.6);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: var(--shell);
  background: var(--surface);
  border: 1px solid var(--border); border-bottom: 0;
  border-radius: 18px 18px 0 0;
  padding: 18px 18px calc(20px + env(safe-area-inset-bottom));
  max-height: 88dvh; overflow-y: auto;
}
.sheet-grip { width: 38px; height: 4px; border-radius: 999px; background: var(--border); margin: 0 auto 14px; }
.sheet h2 { margin: 0 0 4px; font-size: 17px; }
.sheet .lede { font-size: 13px; margin-bottom: 16px; }

.field { margin-bottom: 14px; }
.field label {
  display: block; margin-bottom: 6px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--faint);
}
.field input, .field select, .field textarea {
  width: 100%; font: inherit; font-family: var(--mono); font-size: 15px;
  padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--night); color: var(--fg);
  -webkit-appearance: none; appearance: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--forge);
}
.field textarea { min-height: 82px; resize: vertical; line-height: 1.5; }
.field .field-hint { margin: 6px 0 0; font-size: 11.5px; color: var(--faint); font-family: var(--mono); line-height: 1.55; }
.field-row { display: grid; grid-template-columns: 1fr 110px; gap: 10px; }
.fqdn-preview {
  font-family: var(--mono); font-size: 12px; color: var(--muted);
  margin: -6px 0 14px; word-break: break-all;
}
.fqdn-preview b { color: var(--fg); font-weight: 400; }
.sheet-err {
  margin: 0 0 12px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid rgba(239, 68, 68, 0.32); background: rgba(239, 68, 68, 0.08);
  font-family: var(--mono); font-size: 12px; color: #ffb3b3; line-height: 1.5;
}
/* wildcard toggle: a real 44px target, not a 13px browser checkbox */
.check {
  display: flex; align-items: center; gap: 11px;
  margin: 2px 0 0; padding: 11px 12px;
  background: var(--elevated); border: 1px solid var(--border); border-radius: 12px;
  font-size: 14px; color: var(--fg); cursor: pointer;
}
.check input { width: 20px; height: 20px; accent-color: var(--orange); flex: none; }
.check b { font-family: var(--mono); font-weight: 400; color: var(--orange); }
.check + .field-hint { margin-top: 8px; }

.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }

/* ---- toast --------------------------------------------------------------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 50;
  bottom: calc(84px + env(safe-area-inset-bottom));
  max-width: min(92vw, var(--shell));
  padding: 10px 16px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--elevated); color: var(--fg);
  font-family: var(--mono); font-size: 12.5px; text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* topbar right cluster */
.topbar-right { display: flex; align-items: center; gap: 12px; }
.iconbtn {
  font: inherit; font-family: var(--mono); font-size: 15px; line-height: 1;
  color: var(--muted); background: none; border: 0; padding: 4px 2px; cursor: pointer;
}
.iconbtn:active { color: var(--orange); }
