/* Savinet Console. Phone first: one column, thumb-reachable navigation, no
   horizontal scroll. Dark by default because this is mostly read at night. */

:root {
  --bg: #0d1117;
  --card: #161b22;
  --card2: #1c2330;
  --line: #2a3240;
  --ink: #e6edf3;
  --dim: #8b949e;
  --accent: #4493f8;
  --ok: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --radius: 14px;
}

* { box-sizing: border-box; }

/* The `hidden` attribute is only display:none in the UA stylesheet, so ANY author
   `display` rule beats it. Without this, .sheet/header/nav (all display:flex) stayed
   visible while marked hidden — the confirmation modal showed itself, empty, over
   the lock screen. Every visibility toggle in app.js relies on this line. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 .4rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; margin-top: 1.5rem; }
p { margin: .4rem 0; }
em { color: var(--ink); font-style: normal; font-weight: 600; }

.hint { color: var(--dim); font-size: .875rem; margin-bottom: 1rem; }
.fine { color: var(--dim); font-size: .8rem; }
.err  { color: var(--bad); font-size: .875rem; }

/* ── Lock screen ─────────────────────────────────────────────────────────── */

.lock {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 1.25rem; background: var(--bg);
}
.lock-card { width: 100%; max-width: 22rem; }
.lock-card h1 { font-size: 1.75rem; letter-spacing: -.02em; }
.lock-card .sub { color: var(--dim); margin-bottom: 1.5rem; }

label { display: block; font-size: .8rem; color: var(--dim); margin: 1rem 0 .35rem; }
label.check {
  display: flex; align-items: center; gap: .55rem;
  color: var(--ink); font-size: .9rem; margin: 1rem 0;
}
label.check input { width: 1.15rem; height: 1.15rem; accent-color: var(--accent); margin: 0; }

input[type=password], input[type=text], textarea {
  width: 100%; padding: .8rem .9rem;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px;
  font: inherit;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { resize: vertical; }

button {
  font: inherit; font-weight: 600;
  padding: .8rem 1rem; width: 100%;
  background: var(--accent); color: #fff;
  border: 0; border-radius: 10px; cursor: pointer;
  /* Comfortably tappable on a phone. */
  min-height: 44px;
}
button:active { filter: brightness(.9); }
button:disabled { opacity: .5; }
button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button.danger { background: var(--bad); }
button.approve { background: var(--ok); }
button.icon {
  width: auto; padding: .4rem .6rem; background: transparent;
  color: var(--dim); font-size: 1.25rem;
}

/* ── Chrome ──────────────────────────────────────────────────────────────── */

header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: .75rem;
  padding: max(.75rem, env(safe-area-inset-top)) 1rem .75rem;
  background: rgba(13,17,23,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: -.01em; }
.state { flex: 1; font-size: .78rem; color: var(--dim); text-align: right; }
.state .pill { display: inline-block; margin-left: .4rem; }

main { padding: 1rem 1rem calc(5.5rem + env(safe-area-inset-bottom)); max-width: 46rem; margin: 0 auto; }

nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(13,17,23,.96); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}
nav button {
  flex: 1; background: transparent; color: var(--dim);
  border-radius: 0; padding: .55rem .2rem; font-size: .7rem; font-weight: 500;
  display: flex; flex-direction: column; align-items: center; gap: .15rem;
  min-height: 56px;
}
nav button span { font-size: 1.1rem; line-height: 1; }
nav button.on { color: var(--accent); }

/* ── Cards ───────────────────────────────────────────────────────────────── */

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem; margin-bottom: .85rem;
}
.card.irreversible { border-color: var(--bad); }
.card h4 { margin: 0 0 .5rem; font-size: 1rem; }
.card .meta { color: var(--dim); font-size: .78rem; margin-bottom: .6rem; }
.card dl { margin: .5rem 0 0; font-size: .875rem; }
.card dt { color: var(--dim); font-size: .75rem; margin-top: .55rem; }
.card dd { margin: .1rem 0 0; }

.row { display: flex; gap: .6rem; margin-top: .9rem; }
.row button { flex: 1; }

.pill {
  display: inline-block; padding: .1rem .45rem; border-radius: 999px;
  font-size: .7rem; font-weight: 600; border: 1px solid var(--line);
  color: var(--dim);
}
.pill.ok   { color: var(--ok);   border-color: var(--ok); }
.pill.warn { color: var(--warn); border-color: var(--warn); }
.pill.bad  { color: var(--bad);  border-color: var(--bad); }

.empty { color: var(--dim); padding: 1.5rem 0; text-align: center; }

/* Long values (hashes, connection strings) scroll inside their own box rather
   than making the page scroll sideways. */
.mono, pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .78rem;
}
pre {
  background: var(--card2); border: 1px solid var(--line); border-radius: 8px;
  padding: .6rem .7rem; overflow-x: auto; margin: .4rem 0 0;
}

/* ── Confirmation sheet ──────────────────────────────────────────────────── */

.sheet {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0,0,0,.6); padding: 0;
}
.sheet-card {
  width: 100%; max-width: 30rem;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 1.25rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom));
  max-height: 88vh; overflow-y: auto;
}
.sheet-card .c-what { color: var(--dim); font-size: .8rem; margin-bottom: .3rem; }
.sheet-card ul { margin: .2rem 0 .8rem; padding-left: 1.1rem; }
.sheet-card li { margin: .3rem 0; }
.warn {
  background: rgba(248,81,73,.1); border: 1px solid var(--bad);
  border-radius: 10px; padding: .7rem .8rem; font-size: .85rem; margin: .6rem 0;
}

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(5rem + env(safe-area-inset-bottom)); z-index: 70;
  background: var(--card2); border: 1px solid var(--line);
  border-radius: 10px; padding: .7rem 1rem; font-size: .875rem;
  max-width: calc(100vw - 2rem);
}
.toast.bad { border-color: var(--bad); }

@media (prefers-color-scheme: light) {
  :root {
    --bg: #ffffff; --card: #f6f8fa; --card2: #eef1f4; --line: #d0d7de;
    --ink: #1f2328; --dim: #656d76; --accent: #0969da;
    --ok: #1a7f37; --warn: #9a6700; --bad: #cf222e;
  }
  header { background: rgba(255,255,255,.92); }
  nav { background: rgba(255,255,255,.96); }
  button.ghost { color: var(--ink); }
}
