:root {
  color-scheme: dark;
  --bg: #0b0e12;
  --panel: #11161c;
  --panel-alt: #161d25;
  --surface: #1b232d;
  --surface-hover: #222d3a;
  --border: rgba(220, 234, 244, 0.11);
  --border-strong: rgba(220, 234, 244, 0.22);
  --text: #eef4f7;
  --muted: #98a8b5;
  --faint: #6f8090;
  --accent: #3ee0a8;
  --accent-hover: #64ebb9;
  --accent-dim: rgba(62, 224, 168, 0.13);
  --accent-border: rgba(62, 224, 168, 0.42);
  --warn: #f5b856;
  --warn-dim: rgba(245, 184, 86, 0.14);
  --warn-border: rgba(245, 184, 86, 0.38);
  --danger: #ff6e63;
  --danger-dim: rgba(255, 110, 99, 0.14);
  --danger-border: rgba(255, 110, 99, 0.4);
  --radius-card: 12px;
  --radius-control: 8px;
  --radius-pill: 999px;
  --sans: "Plus Jakarta Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { overflow-x: clip; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
h1, h2, h3, p, ul { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }
code {
  font-family: var(--mono);
  font-size: 12.5px;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--surface);
  color: #cfece0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Shared Top Navigation */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 64px;
  background: rgba(11, 14, 18, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: 1200px;
  height: 100%;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.nav-brand {
  display: inline-flex;
  align-items: center;
  flex: none;
}
.nav-logo {
  height: 28px;
  width: auto;
  object-fit: contain;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
}
.nav-links a {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  transition: color 0.15s;
}
.nav-links a:hover,
.nav-links a.active {
  color: var(--accent);
}
.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-danger,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-control);
  font-size: 13.5px;
  font-weight: 700;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
}
.btn-primary {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #051610;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-secondary {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
}
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--accent-border); }
.btn-danger {
  background: var(--danger-dim);
  border: 1px solid var(--danger-border);
  color: #ffd5d1;
}
.btn-danger:hover { background: rgba(255, 110, 99, 0.24); border-color: var(--danger); }
.btn-ghost {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  min-height: 34px;
  padding: 0 10px;
}
.btn-ghost:hover { color: var(--text); background: var(--surface); }
.btn-sm {
  min-height: 32px;
  padding: 0 12px;
  font-size: 12.5px;
}
.btn-full {
  width: 100%;
  min-height: 44px;
}

/* Google Official-Style Button */
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  width: 100%;
  min-height: 46px;
  padding: 0 18px;
  border-radius: var(--radius-control);
  background: #ffffff;
  border: 1px solid #dadce0;
  color: #1f1f1f;
  font-size: 14.5px;
  font-weight: 600;
  transition: background 0.15s, box-shadow 0.15s;
}
.btn-google:hover {
  background: #f5f7f9;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
}
.btn-google svg {
  width: 18px;
  height: 18px;
  flex: none;
}

/* Alerts & Banners */
.alert-box {
  padding: 12px 14px;
  border-radius: var(--radius-control);
  font-size: 13.5px;
  line-height: 1.5;
  border: 1px solid var(--border-strong);
  background: var(--panel-alt);
  color: var(--text);
}
.alert-box.is-error {
  background: var(--danger-dim);
  border-color: var(--danger-border);
  color: #ffd8d4;
}
.alert-box.is-success {
  background: var(--accent-dim);
  border-color: var(--accent-border);
  color: #d6fff0;
}
.alert-box.is-warn {
  background: var(--warn-dim);
  border-color: var(--warn-border);
  color: #ffe7bf;
}

/* Form Fields */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.field label {
  font-size: 13px;
  font-weight: 600;
  color: #dce7ef;
}
.field-link {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
  padding: 0;
  min-height: 24px;
}
.field-link:hover { text-decoration: underline; background: transparent; color: var(--accent-hover); }
.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.text-input {
  width: 100%;
  min-height: 44px;
  padding: 0 13px;
  border-radius: var(--radius-control);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 14.5px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.text-input.has-toggle {
  padding-right: 68px;
}
.text-input::placeholder { color: var(--faint); }
.text-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(62, 224, 168, 0.16);
}
.pw-toggle {
  position: absolute;
  right: 8px;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.pw-toggle:hover { color: var(--text); border-color: var(--border-strong); }
.field-hint {
  font-size: 12.5px;
  color: var(--muted);
}
.field-hint.ok { color: var(--accent); }

/* Badges / Pills */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.status-pill.good {
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  color: var(--accent);
}
.status-pill.warn {
  background: var(--warn-dim);
  border: 1px solid var(--warn-border);
  color: var(--warn);
}
.status-pill.neutral {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--muted);
}

/* =========================================================================
   AUTH PAGE LAYOUT (/auth, /login, /signup, /reset-password)
   ========================================================================= */
.auth-main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 40px 24px 64px;
  display: grid;
  grid-template-columns: minmax(0, 450px) minmax(0, 1fr);
  gap: 40px;
  align-items: stretch;
}

.auth-card {
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-card);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.auth-card-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.auth-card-head h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.2;
}
.auth-card-head p {
  font-size: 14px;
  color: var(--muted);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-control);
  background: var(--bg);
  border: 1px solid var(--border);
}
.auth-tab {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 700;
  transition: background 0.15s, color 0.15s;
}
.auth-tab.active {
  background: var(--surface);
  color: var(--text);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: var(--mono);
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}
.auth-footer-note {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  margin-top: auto;
  padding-top: 12px;
}
.auth-footer-note a {
  color: var(--accent);
  font-weight: 600;
}
.auth-footer-note a:hover { text-decoration: underline; }

/* Auth Proof Side Panel */
.auth-aside {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.aside-eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
}
.auth-aside h2 {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.25;
}
.aside-art {
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg);
}
.aside-art img {
  width: 100%;
  height: auto;
  display: block;
}
.perk-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.perk-list li {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  font-size: 13.5px;
  color: #d6e2ea;
}
.perk-dot {
  width: 10px;
  height: 10px;
  margin-top: 6px;
  border-radius: 2px;
  background: var(--accent);
}
.perk-list strong { color: var(--text); }

/* =========================================================================
   SETTINGS PAGE LAYOUT (/settings)
   ========================================================================= */
.settings-shell {
  max-width: 1140px;
  margin: 0 auto;
  padding: 32px 24px 72px;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}
.settings-nav {
  position: sticky;
  top: 88px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.settings-nav-label {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--faint);
  padding: 0 12px 8px;
}
.settings-nav a {
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-control);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
.settings-nav a:hover,
.settings-nav a.active {
  background: var(--panel);
  color: var(--accent);
}

.settings-content {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
}
.settings-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.settings-header h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.025em;
}
.settings-header p {
  font-size: 14px;
  color: var(--muted);
  margin-top: 4px;
}

.settings-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scroll-margin-top: 84px;
}
.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.card-head h2 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.015em;
}
.card-head p {
  font-size: 13.5px;
  color: var(--muted);
  margin-top: 3px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.metric-tile {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.metric-label {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
}
.metric-value {
  font-size: 21px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}
.metric-value.accent { color: var(--accent); }

.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}
.inline-form .field {
  flex: 1 1 240px;
}
.inline-form .btn-primary,
.inline-form .btn-secondary {
  min-height: 44px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.info-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 9px;
  background: var(--bg);
  border: 1px solid var(--border);
}
.info-row-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.info-row-copy strong { font-size: 14px; }
.info-row-copy span { font-size: 13px; color: var(--muted); }

/* BYOK Mode Cards */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.mode-card {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 14px;
  border-radius: 9px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.mode-card.active {
  border-color: var(--accent);
  background: rgba(62, 224, 168, 0.07);
}
.mode-card input {
  margin-top: 3px;
  accent-color: var(--accent);
}
.mode-card strong {
  display: block;
  font-size: 14px;
  margin-bottom: 3px;
}
.mode-card span {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
}

/* Secret Reveal Box */
.secret-reveal {
  padding: 16px;
  border-radius: 9px;
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.secret-reveal-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.secret-reveal code {
  flex: 1 1 240px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  color: var(--accent);
  word-break: break-all;
}

/* Lists (API Keys & Sessions) */
.item-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.item-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
}
.item-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.item-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.item-sub {
  font-size: 12.5px;
  color: var(--muted);
  word-break: break-word;
}
.empty-note {
  font-size: 13.5px;
  color: var(--muted);
  padding: 12px 0 4px;
}

.guest-wall {
  width: min(520px, calc(100% - 32px));
  max-width: 520px;
  margin: 56px auto;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-card);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.guest-wall h1 { font-size: 22px; font-weight: 800; }
.guest-wall p { color: var(--muted); font-size: 14px; }

.nav-user-pill {
  font-size: 12.5px;
  color: var(--muted);
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Responsive Breakpoints (Desktop -> Tablet -> 390px Mobile) */
@media (max-width: 900px) {
  .auth-main {
    grid-template-columns: 1fr;
    max-width: 520px;
    gap: 24px;
    padding: 24px 16px 48px;
  }
  .settings-shell {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 20px 16px 56px;
  }
  .settings-nav {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    padding-bottom: 0;
    gap: 6px;
  }
  .settings-nav-label { display: none; }
  .settings-nav a {
    background: var(--panel);
    border: 1px solid var(--border);
    white-space: nowrap;
    min-height: 34px;
    padding: 0 11px;
    font-size: 12.5px;
    flex: none;
  }
}

@media (max-width: 640px) {
  .nav-inner { padding: 0 14px; gap: 10px; }
  .nav-links { display: none; }
  .nav-user-pill { display: none; }
  .auth-card,
  .auth-aside,
  .settings-card { padding: 20px 16px; }
  .guest-wall { margin: 28px auto; padding: 22px 18px; }
  .metrics-grid { grid-template-columns: 1fr; }
  .mode-grid { grid-template-columns: 1fr; }
  .action-row > a,
  .action-row > button { width: 100%; }
  .settings-header h1 { font-size: 22px; }
  .auth-card-head h1 { font-size: 21px; }
}
