/* KEYSTONE command center: black and charcoal, metallic gold, white text. */

@font-face {
  font-family: "Playfair Display";
  src: url("/fonts/PlayfairDisplay-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #0B0B0C;
  --bg-elevated: #111113;
  --surface: #18181B;
  --surface-alt: #222226;
  --border: #2E2E33;
  --text: #FFFFFF;
  --muted: #B4B4BC;
  --faint: #7C7C86;
  --gold-dark: #A8841C;
  --gold: #C9A227;
  --gold-light: #F5D77A;
  --on-gold: #14110A;
  --success: #4CC38A;
  --warning: #F5B544;
  --danger: #EF6461;
  --gradient: linear-gradient(135deg, var(--gold-dark), var(--gold) 50%, var(--gold-light));
  --heading: "Playfair Display", "New York", ui-serif, Georgia, serif;
  --body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body { min-height: 100dvh; }
#app { min-height: 100dvh; }
[hidden] { display: none !important; }

button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 2px; }

.icon { flex: none; display: block; }

/* ------------------------------------------------------------------ gate screens */

.gate {
  min-height: 100dvh;
  max-width: 420px;
  margin: 0 auto;
  padding: calc(28px + var(--safe-top)) 22px calc(28px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
}

.crest { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 6px; }
.crest-name { font-family: var(--heading); font-weight: 700; font-size: 26px; line-height: 1.2; letter-spacing: 5px; padding-left: 5px; }
.crest-tag { color: var(--gold); font-size: 12px; font-weight: 500; letter-spacing: 3px; margin-top: -8px; }

.gate-title { font-family: var(--heading); font-weight: 700; font-size: 24px; line-height: 1.25; margin: 4px 0 0; }
.gate-text { margin: 0; font-size: 15px; max-width: 340px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); font-size: 13px; }
.notice { color: var(--warning); }
.gate-wait { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 6px 0; }
.gate-foot { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 4px; }
.gate-badge {
  width: 64px; height: 64px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border); color: var(--warning);
}
.gate-badge.danger { color: var(--danger); }

.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; text-align: left; max-width: 340px; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; font-size: 14.5px; color: var(--text); }
.checklist .icon { color: var(--gold); margin-top: 4px; }

.secure-line { display: flex; align-items: center; gap: 8px; color: var(--faint); font-size: 12.5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); flex: none; }

.link { background: none; border: 0; padding: 6px 8px; color: var(--faint); font-size: 13px; text-decoration: underline; }
.link:hover { color: var(--muted); }

.code {
  display: flex; gap: 14px; justify-content: center;
  font-family: var(--heading); font-weight: 700; font-size: 44px; letter-spacing: 6px; line-height: 1.1;
  padding: 18px 26px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--gold-dark);
  color: var(--gold-light);
  font-variant-numeric: tabular-nums;
}

.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--gold);
  animation: spin .8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ----------------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 12px 20px; border-radius: 14px;
  border: 1px solid transparent; font-weight: 600; font-size: 16px;
  transition: transform .06s ease, opacity .12s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; }
.btn-wide { width: 100%; }
.btn-small { min-height: 40px; padding: 8px 14px; font-size: 14.5px; border-radius: 11px; }
.btn-primary { background: var(--gradient); color: var(--on-gold); border-color: var(--gold); }
.btn-secondary { background: var(--surface-alt); color: var(--text); border-color: var(--border); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-google { background: #FFFFFF; color: #1F1F1F; border-color: #DADCE0; font-weight: 500; }

.icon-btn {
  width: 38px; height: 38px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
}
.icon-btn.gold { color: var(--gold-light); }

/* ------------------------------------------------------------------ passcode pad */

.pin { display: flex; flex-direction: column; align-items: center; gap: 22px; }
.pin-dots { display: flex; gap: 16px; }
.pin-dot { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--muted); }
.pin-dot.filled { background: var(--gold); border-color: var(--gold); }
.pin-grid { display: grid; grid-template-columns: repeat(3, 76px); gap: 16px 24px; }
.pin-key {
  width: 76px; height: 76px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border);
  font-family: var(--heading); font-weight: 700; font-size: 28px;
  display: grid; place-items: center;
}
.pin-key:active { background: var(--surface-alt); border-color: var(--gold-dark); }
.pin-key-quiet { background: transparent; border-color: transparent; color: var(--muted); }
.pin-gap { width: 76px; height: 76px; }
.pin.disabled .pin-key { opacity: .35; }
.pin.shake { animation: shake .36s ease; }
@keyframes shake {
  20% { transform: translateX(-9px); } 40% { transform: translateX(9px); }
  60% { transform: translateX(-6px); } 80% { transform: translateX(6px); }
}
.pin-sheet { display: flex; flex-direction: column; align-items: center; gap: 14px; padding-bottom: 18px; }
.pin-step { font-family: var(--heading); font-size: 20px; margin: 0; }

/* Short screens (small phones, and any phone while the browser's own bars are showing):
   the logo moves beside the name and everything tightens, so the whole keypad is on
   screen without scrolling. */
@media (max-height: 740px) {
  .gate { gap: 10px; padding-top: calc(14px + var(--safe-top)); padding-bottom: calc(14px + var(--safe-bottom)); }
  .crest { display: grid; grid-template-columns: auto auto; column-gap: 12px; row-gap: 0; align-items: center; justify-content: center; text-align: left; margin-bottom: 2px; }
  .crest svg { width: 44px; height: 44px; grid-row: 1 / span 2; }
  .crest-name { font-size: 20px; letter-spacing: 3px; padding-left: 0; align-self: end; }
  .crest-tag { font-size: 10.5px; letter-spacing: 2px; margin-top: 0; align-self: start; }
  .gate-title { font-size: 21px; margin-top: 0; }
  .gate-text { font-size: 14px; }
  .pin { gap: 14px; }
  .pin-grid { grid-template-columns: repeat(3, 62px); gap: 10px 22px; }
  .pin-key, .pin-gap { width: 62px; height: 62px; }
  .pin-key { font-size: 24px; }
  .gate-foot { gap: 4px; margin-top: 0; }
}
/* A phone held sideways: the keypad goes beside the words instead of under them. */
@media (orientation: landscape) and (max-height: 520px) {
  .gate:has(> .pin) {
    max-width: 680px; display: grid; grid-template-columns: 1fr auto; column-gap: 32px; row-gap: 0;
    align-content: center; justify-items: center;
  }
  .gate:has(> .pin) > * { grid-column: 1; margin-top: 4px; margin-bottom: 4px; }
  .gate:has(> .pin) > .pin { grid-column: 2; grid-row: 1 / span 12; align-self: center; }
}

/* ------------------------------------------------------------------------- shell */

.shell {
  height: 100dvh;
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
@media (min-width: 761px) {
  .shell { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}

.bar {
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + var(--safe-top)) 14px 10px;
}
.bar-lead { width: 38px; height: 38px; display: grid; place-items: center; flex: none; }
.bar-name { flex: none; }
.bar-title { font-family: var(--heading); font-weight: 700; font-size: 17px; line-height: 21px; letter-spacing: 2px; white-space: nowrap; }
.bar-tag { color: var(--gold); font-size: 10.5px; font-weight: 500; line-height: 13px; letter-spacing: 1.6px; white-space: nowrap; }
.bar-status {
  flex: 1; min-width: 0; display: flex; align-items: center; justify-content: flex-end; gap: 5px;
  font-size: 11px; font-weight: 500; white-space: nowrap; overflow: hidden; margin-right: 2px;
}
.bar-status.success { color: var(--success); }
.bar-status.warning { color: var(--warning); }
.bar-status.danger { color: var(--danger); }
.bar-status span { overflow: hidden; text-overflow: ellipsis; }

.progress { height: 2px; background: var(--border); overflow: hidden; flex: none; }
.progress-bar { height: 2px; width: 40%; background: var(--gold-light); transform: translateX(-100%); }
.progress.active .progress-bar { animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }

/* Shown above the assistant's own sign-in page, so a second password is not a surprise. */
.door-note {
  flex: none; display: flex; gap: 12px; align-items: flex-start;
  margin: 12px 14px 4px; padding: 12px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--gold); color: var(--muted); font-size: 13.5px;
}
.door-note .icon { color: var(--gold); margin-top: 2px; flex: none; }
.door-note-title { color: var(--text); font-weight: 600; font-size: 14.5px; }

.stage { flex: 1; min-height: 0; position: relative; background: var(--bg); }
.page { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: var(--bg); }
.page.incoming { visibility: hidden; }

.problem {
  position: absolute; inset: 0; z-index: 2; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 22px; text-align: center;
}
.problem-title { font-family: var(--heading); font-size: 22px; margin: 0; }
.problem-actions { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; justify-content: center; }

.tabs {
  flex: none; display: flex;
  background: var(--bg-elevated); border-top: 1px solid var(--border);
  padding: 8px 6px calc(8px + var(--safe-bottom));
}
.tab {
  flex: 1; background: none; border: 0; padding: 2px 0 0;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--faint);
}
.tab.selected { color: var(--gold); }
.tab-icon { position: relative; display: block; }
.tab-label { font-size: 10.5px; font-weight: 500; }
.tab-count {
  position: absolute; right: -12px; top: -6px; min-width: 17px; height: 17px; border-radius: 9px;
  padding: 0 4px; background: var(--surface-alt); border: 1px solid var(--bg-elevated);
  color: var(--text); font-size: 10px; line-height: 15px; font-weight: 600; text-align: center;
}
.tab-count.gold { background: var(--gold); color: var(--on-gold); }

body.covered .stage, body.covered .tabs, body.covered #layers { visibility: hidden; }

/* --------------------------------------------------------------- sheets and cards */

.backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .78);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.backdrop-sheet { align-items: flex-end; padding: 0; }

.dialog {
  width: 100%; max-width: 380px; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: 16px; padding: 20px;
  display: flex; flex-direction: column; gap: 12px;
}
.dialog-title { font-family: var(--heading); font-size: 22px; line-height: 1.25; margin: 0; }
.dialog-text { margin: 0; color: var(--muted); font-size: 15.5px; overflow-wrap: anywhere; }
.dialog-actions { display: flex; gap: 12px; margin-top: 6px; }
.dialog-actions .btn { flex: 1; }

.sheet {
  width: 100%; max-width: 760px; max-height: 90dvh;
  background: var(--bg-elevated); border: 1px solid var(--border); border-bottom: 0;
  border-radius: 22px 22px 0 0;
  display: flex; flex-direction: column;
  padding-bottom: var(--safe-bottom);
  animation: rise .22s ease;
}
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--border); margin: 8px auto 0; flex: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 10px; flex: none; }
.sheet-title { font-family: var(--heading); font-size: 22px; margin: 0; }
.sheet-body { overflow-y: auto; min-height: 0; padding: 4px 16px 20px; display: flex; flex-direction: column; gap: 14px; -webkit-overflow-scrolling: touch; }
/* A long list scrolls. Without this, the browser squeezes the cards flat to make them fit instead. */
.sheet-body > * { flex-shrink: 0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.card.highlight { border-color: var(--gold-dark); padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.rows { overflow: hidden; }
.row {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 13px 14px; background: none; border: 0; border-bottom: 1px solid var(--border);
}
.rows .row:last-child { border-bottom: 0; }
button.row:active { background: var(--surface-alt); }
.row-icon { width: 34px; height: 34px; border-radius: 9px; background: var(--surface-alt); color: var(--gold); display: grid; place-items: center; flex: none; }
.row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-title { font-weight: 600; font-size: 15.5px; }
.row-sub { color: var(--muted); font-size: 13px; }
.row-chevron { color: var(--faint); flex: none; }

.pill { padding: 2px 9px; border-radius: 11px; background: var(--surface-alt); font-size: 12px; font-weight: 600; flex: none; }
.pill.gold { background: var(--gold); color: var(--on-gold); }

.label { color: var(--faint); font-size: 11.5px; font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase; margin: 6px 2px -6px; }
.label.gold { color: var(--gold); margin: 0; }
.caption { color: var(--faint); font-size: 12.5px; margin: -6px 2px 0; }
.foot-lines { color: var(--faint); font-size: 12.5px; display: flex; flex-direction: column; gap: 2px; padding: 0 2px; }
.stack { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }

.protect { display: flex; gap: 12px; align-items: flex-start; }
.protect .icon { color: var(--success); margin-top: 3px; }
.protect.warn .icon { color: var(--warning); }
.protect-title { font-weight: 600; font-size: 14.5px; }
.protect-body { color: var(--muted); font-size: 13.5px; }

.banner {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted); font-size: 13.5px;
}
.banner .icon { margin-top: 2px; color: var(--gold); }
.banner.warn { border-color: var(--warning); }
.banner.warn .icon { color: var(--warning); }

.segmented { display: flex; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 3px; gap: 3px; }
.segmented button { flex: 1; min-height: 38px; border: 0; border-radius: 9px; background: none; color: var(--muted); font-size: 13.5px; font-weight: 600; }
.segmented button.selected { background: var(--gradient); color: var(--on-gold); }

.toast {
  position: fixed; z-index: 60; top: calc(12px + var(--safe-top)); left: 50%; transform: translateX(-50%);
  max-width: min(440px, calc(100vw - 32px));
  display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-radius: 12px;
  background: var(--surface-alt); border: 1px solid var(--border); font-size: 14px;
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.toast-success .icon { color: var(--success); }
.toast-error .icon { color: var(--danger); }
.toast-info .icon { color: var(--gold); }

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