:root {
  --ink: #070b10;
  --ink-soft: #0e1720;
  --ink-deep: #0a1f24;
  --mist: #e8eff2;
  --surface: #f8fbfc;
  --aqua: #0c7c7a;
  --aqua-bright: #1cb8af;
  --aqua-glow: rgba(28, 184, 175, 0.35);
  --muted: #5a6b78;
  --text: #0f1b24;
  --gold: #c4a35a;
  --err: #b3261e;
  --ok: #1a7f5a;
  --hairline: rgba(12, 24, 32, 0.1);
  --shadow-sm: 0 1px 2px rgba(7, 11, 16, 0.06), 0 4px 16px rgba(7, 11, 16, 0.04);
  --shadow-md: 0 2px 8px rgba(7, 11, 16, 0.08), 0 12px 32px rgba(7, 11, 16, 0.06);
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  --tab-h: calc(56px + var(--safe-bot));
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--ink);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; font-size: 16px; }
[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Splash & lock ── */
.screen {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.splash, .lock {
  display: grid;
  place-content: center;
  gap: 0.65rem;
  text-align: center;
  background: radial-gradient(ellipse 120% 80% at 50% 0%, #122028 0%, var(--ink) 55%, #040608 100%);
  color: #f2f7f9;
  padding: 2rem;
  padding-top: calc(2rem + var(--safe-top));
}

.splash img, .lock img {
  margin: 0 auto;
  filter: drop-shadow(0 8px 24px var(--aqua-glow));
  animation: splashPulse 2.4s var(--ease-out) infinite;
}

@keyframes splashPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.03); opacity: 0.92; }
}

.splash p:first-of-type {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0.4rem 0 0;
}

.lock h1 {
  margin: 0.2rem 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.lock .muted, .splash .muted { color: #9eb4be; font-size: 0.88rem; }

.stack { display: grid; gap: 0.85rem; text-align: left; width: min(22rem, 100%); }
label { display: grid; gap: 0.35rem; font-weight: 600; font-size: 0.82rem; color: var(--muted); }

input, textarea, select {
  width: 100%;
  padding: 0.82rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(197, 212, 218, 0.9);
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--aqua-bright);
  box-shadow: 0 0 0 3px rgba(28, 184, 175, 0.18);
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.82rem 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s var(--ease-out), box-shadow 0.2s, background 0.2s;
  touch-action: manipulation;
}

.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn.primary {
  background: linear-gradient(180deg, var(--aqua-bright) 0%, var(--aqua) 100%);
  color: #fff;
  box-shadow: 0 2px 12px rgba(12, 124, 122, 0.35);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(197, 212, 218, 0.9);
  color: var(--text);
}

.btn.compact { padding: 0.42rem 0.78rem; font-size: 0.82rem; border-radius: 10px; }
.btn.danger { background: #fff5f4; color: var(--err); border-color: #f0c0bc; }
.btn.block { width: 100%; display: flex; align-items: center; justify-content: center; gap: 0.5rem; }

.btn.icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: rgba(28, 184, 175, 0.12);
  border-radius: 12px;
  color: var(--aqua-bright);
  display: grid;
  place-items: center;
  box-shadow: none;
}

.btn.icon:active { background: rgba(28, 184, 175, 0.22); }

.error { color: #ffb4ab; }
#app .error { color: var(--err); }

/* ── App shell ── */
.app-shell {
  display: grid;
  grid-template-rows: auto 1fr var(--tab-h);
  background:
    radial-gradient(ellipse 100% 60% at 50% -10%, rgba(28, 184, 175, 0.08) 0%, transparent 55%),
    linear-gradient(165deg, var(--mist) 0%, var(--surface) 38%, #dce9ec 100%);
  color: var(--text);
}

.app-shell.sub-screen { grid-template-rows: auto 1fr; }

.brand-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px 14px;
  padding-top: calc(10px + var(--safe-top));
  background: linear-gradient(180deg, var(--ink) 0%, var(--ink-soft) 72%, #0a1e24 100%);
  color: #fff;
  position: relative;
  z-index: 2;
}

.brand-bar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, rgba(28, 184, 175, 0.55), rgba(28, 184, 175, 0.08) 60%, transparent);
}

.brand-bar img {
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.brand-copy { min-width: 0; flex: 1; }

.brand-name {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--aqua-bright);
  letter-spacing: 0.03em;
}

.brand-bar strong {
  display: block;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.brand-actions { display: flex; align-items: center; gap: 6px; }

#main {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 14px 16px 24px;
  animation: fadeUp 0.35s var(--ease-out);
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Search ── */
.ios-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.94);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  margin-bottom: 12px;
  color: var(--muted);
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(255, 255, 255, 0.8);
}

.ios-search input {
  border: 0;
  background: transparent;
  padding: 0;
  outline: none;
  box-shadow: none;
}

/* ── Empty states ── */
.empty {
  text-align: center;
  padding: 2.8rem 1rem;
  animation: fadeUp 0.4s var(--ease-out);
}

.empty h3 {
  margin: 0.85rem 0 0.4rem;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.empty .glyph {
  width: 72px;
  height: 72px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(12, 124, 122, 0.14), rgba(28, 184, 175, 0.08));
  color: var(--aqua);
}

.empty .glyph svg { width: 36px; height: 36px; }

/* ── OTP cards ── */
.otp-card {
  display: flex;
  gap: 14px;
  align-items: center;
  background: rgba(255, 255, 255, 0.92);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(255, 255, 255, 0.95);
  width: 100%;
  text-align: left;
  color: inherit;
  cursor: pointer;
  transition: transform 0.2s var(--ease-out), box-shadow 0.2s, border-color 0.2s;
  animation: cardIn 0.4s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 0.04s);
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.otp-card:active { transform: scale(0.985); }
.otp-card.urgent-card { border-color: rgba(196, 163, 90, 0.35); box-shadow: 0 0 0 1px rgba(196, 163, 90, 0.15), var(--shadow-sm); }

.mono {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  flex: none;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--aqua-bright), var(--aqua));
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  box-shadow: 0 4px 12px rgba(12, 124, 122, 0.28);
}

.otp-meta { min-width: 0; flex: 1; }
.otp-top { display: flex; align-items: baseline; gap: 8px; }
.otp-issuer { font-weight: 600; font-size: 0.96rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.otp-account { color: var(--muted); font-size: 0.76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; margin-top: 1px; }

.pill {
  margin-left: auto;
  flex: none;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--aqua);
  background: rgba(12, 124, 122, 0.12);
  border-radius: 999px;
  padding: 3px 8px;
}

.code {
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  line-height: 1.2;
  margin-top: 6px;
  transition: color 0.3s;
}

.code.urgent { color: var(--gold); }
.copy-hint { font-size: 0.68rem; color: var(--muted); margin-top: 2px; transition: color 0.2s; }
.copy-hint.copied { color: var(--ok); font-weight: 600; }

.otp-side { display: grid; place-items: center; gap: 6px; }
.ring { width: 30px; height: 30px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 3; }
.ring .track { stroke: #d5e0e4; }
.ring .value { stroke: var(--aqua); stroke-linecap: round; transition: stroke 0.3s; }
.ring.urgent .value { stroke: var(--gold); }

/* ── Tab bar ── */
.tab-bar {
  display: flex;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: saturate(190%) blur(24px);
  -webkit-backdrop-filter: saturate(190%) blur(24px);
  border-top: 0.5px solid var(--hairline);
  padding-bottom: var(--safe-bot);
  padding-top: 4px;
  box-shadow: 0 -4px 24px rgba(7, 11, 16, 0.04);
}

.tab-bar button {
  flex: 1;
  border: 0;
  background: none;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 2px 2px 6px;
  min-width: 0;
  transition: color 0.2s;
}

.tab-bar .ico {
  width: 44px;
  height: 32px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  transition: background 0.25s var(--ease-out), transform 0.2s var(--ease-spring);
}

.tab-bar svg { width: 24px; height: 24px; display: block; }
.tab-bar span { font-size: 10px; font-weight: 500; line-height: 11px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab-bar button.is-on { color: var(--aqua); font-weight: 600; }
.tab-bar button.is-on .ico { background: rgba(12, 124, 122, 0.16); transform: scale(1.04); }

/* ── Groups (settings-style) ── */
.group {
  background: rgba(255, 255, 255, 0.94);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(255, 255, 255, 0.9);
}

.group h3 {
  margin: 0;
  padding: 12px 16px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.group .row-item, .group label.field {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-top: 0.5px solid var(--hairline);
}

.group label.field { display: grid; gap: 6px; align-items: stretch; }
.group p { margin: 0; padding: 10px 16px 14px; font-size: 0.84rem; line-height: 1.45; }
.group .footnote { padding: 8px 16px 12px; font-size: 0.8rem; color: var(--muted); border-top: 0.5px solid var(--hairline); }

.switch { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.switch input { width: auto; accent-color: var(--aqua); transform: scale(1.18); }

.labeled { display: grid; gap: 4px; }
.labeled .label { font-size: 0.78rem; color: var(--muted); font-weight: 500; }
.labeled .value { font-weight: 600; font-size: 0.95rem; }
.labeled .value.mono-sm { font-family: ui-monospace, monospace; font-size: 0.78rem; font-weight: 500; word-break: break-all; }

/* ── Cards & identity rows ── */
.card {
  background: rgba(255, 255, 255, 0.94);
  border-radius: var(--radius-md);
  padding: 1rem 1.05rem;
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(255, 255, 255, 0.9);
  animation: fadeUp 0.35s var(--ease-out);
}

.identity-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  padding: 14px 16px;
  border-top: 0.5px solid var(--hairline);
  animation: fadeUp 0.35s var(--ease-out);
}

.identity-row:first-of-type { border-top: 0; }

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 6px;
  background: #c5d0d6;
  box-shadow: 0 0 0 3px rgba(197, 208, 214, 0.35);
}

.status-dot.on {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(26, 127, 90, 0.25);
  animation: pulseDot 2s ease infinite;
}

@keyframes pulseDot {
  0%, 100% { box-shadow: 0 0 0 3px rgba(26, 127, 90, 0.25); }
  50% { box-shadow: 0 0 0 6px rgba(26, 127, 90, 0.12); }
}

.identity-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.identity-top strong { font-size: 1rem; }
.identity-user { display: block; font-size: 0.84rem; color: var(--text); margin-top: 2px; }
.identity-url { display: block; font-family: ui-monospace, monospace; font-size: 0.72rem; color: var(--muted); margin-top: 2px; word-break: break-all; }

.badge-active {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--aqua);
  background: rgba(12, 124, 122, 0.12);
  padding: 2px 8px;
  border-radius: 999px;
}

.identity-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; grid-column: 1 / -1; }

/* ── Approval challenge ── */
.approve-num {
  font-size: 2.75rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--aqua);
  line-height: 1;
  margin: 8px 0 12px;
  font-variant-numeric: tabular-nums;
}

.challenge-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.challenge-head strong { font-size: 1rem; }

/* ── Hero (add account) ── */
.hero {
  text-align: center;
  padding: 1.2rem 0.5rem 1.6rem;
  animation: fadeUp 0.45s var(--ease-out);
}

.hero-icon {
  width: 96px;
  height: 96px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, rgba(12, 124, 122, 0.16), rgba(28, 184, 175, 0.06));
  color: var(--aqua);
}

.hero-icon svg { width: 48px; height: 48px; }
.hero h2 { margin: 0 0 0.5rem; font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em; }
.hero p { margin: 0; color: var(--muted); font-size: 0.88rem; line-height: 1.5; max-width: 22rem; margin-inline: auto; }

.hero-actions { display: grid; gap: 10px; padding: 0 0.5rem; margin-top: 1.2rem; }

.panel {
  background: rgba(255, 255, 255, 0.94);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-top: 1rem;
  box-shadow: var(--shadow-sm);
  animation: fadeUp 0.35s var(--ease-out);
}

.panel summary {
  font-weight: 600;
  cursor: pointer;
  color: var(--aqua);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel summary::-webkit-details-marker { display: none; }
.panel[open] summary { margin-bottom: 0.85rem; }

/* ── Segmented control ── */
.segmented {
  display: flex;
  background: rgba(12, 124, 122, 0.1);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 12px;
}

.segmented button {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 0.55rem 0.5rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}

.segmented button.is-on {
  background: #fff;
  color: var(--aqua);
  box-shadow: 0 1px 4px rgba(7, 11, 16, 0.08);
}

.row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.6rem; align-items: center; }
.fp { font-family: ui-monospace, monospace; font-size: 0.75rem; word-break: break-all; color: var(--muted); }

video#qrVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  display: block;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

.qr-stage {
  position: relative;
  margin: 0.75rem 0 1rem;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
  aspect-ratio: 3 / 4;
  max-height: min(68dvh, 28rem);
  box-shadow: var(--shadow-md);
}

.qr-frame {
  position: absolute;
  inset: 18% 14%;
  border: 2px solid rgba(28, 184, 175, 0.95);
  border-radius: 14px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.38);
  pointer-events: none;
}

.qr-status {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 3.2rem;
  margin: 0;
  padding: 0 12px;
  text-align: center;
  color: #f2f7f9;
  font-size: 0.86rem;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

.qr-cancel {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.92) !important;
}

.ios-hint {
  background: linear-gradient(135deg, rgba(12, 124, 122, 0.12), rgba(28, 184, 175, 0.06));
  color: var(--ink-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.84rem;
  line-height: 1.45;
  margin-bottom: 14px;
  border: 1px solid rgba(12, 124, 122, 0.12);
}

.gate-msg {
  text-align: center;
  padding: 2.5rem 1.2rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.status-line {
  font-size: 0.82rem;
  color: var(--muted);
  padding: 8px 0;
  min-height: 1.4em;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab-h) + 14px);
  transform: translateX(-50%) translateY(0);
  background: rgba(7, 11, 16, 0.92);
  color: #fff;
  padding: 0.58rem 1.1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 30;
  max-width: 90vw;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(12px);
  animation: toastIn 0.35s var(--ease-spring);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(12px) scale(0.92); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

.busy-overlay {
  opacity: 0.55;
  filter: saturate(0.85);
}
