:root {
  --bg: #090d18;
  --bg-glow-1: rgba(124, 92, 255, 0.16);
  --bg-glow-2: rgba(45, 211, 181, 0.10);
  --surface: rgba(23, 30, 49, 0.86);
  --surface-solid: #171e31;
  --surface-hover: #1e2740;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #edf1fb;
  --muted: #95a0bb;
  --accent: #8a70ff;
  --accent-contrast: #ffffff;
  --mint: #3ddbb6;
  --danger: #ff7089;
  --radius: 18px;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { min-height: 100%; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(900px 600px at 12% -10%, var(--bg-glow-1), transparent 65%),
    radial-gradient(800px 600px at 90% 0%, var(--bg-glow-2), transparent 60%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
code, .code, .clock-time { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.app-shell {
  width: min(1120px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 24px 28px;
  display: flex;
  flex-direction: column;
}

/* ---------- Top bar ---------- */

.topbar {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.brand-name strong { color: var(--accent); }

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(140deg, #8a70ff, #5e4ce0);
  box-shadow: 0 8px 22px rgba(124, 92, 255, 0.35);
}

.brand-mark svg { width: 22px; height: 22px; }

.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 15px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}

.button:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.button:active { transform: translateY(1px); }
.button svg { width: 16px; height: 16px; }

.button.primary {
  border-color: transparent;
  color: var(--accent-contrast);
  background: linear-gradient(135deg, #8a70ff, #6852e8);
  box-shadow: 0 8px 22px rgba(124, 92, 255, 0.28);
}

.button.primary:hover { filter: brightness(1.08); background: linear-gradient(135deg, #987fff, #725cf0); }
.button.ghost { background: transparent; }
.button.wide { width: 100%; min-height: 46px; }
.button.compact { width: 40px; padding: 0; }
.button.danger { border-color: rgba(255, 112, 137, 0.4); background: rgba(255, 112, 137, 0.06); color: #ff9bad; }
.button.danger:hover { border-color: rgba(255, 112, 137, 0.65); background: rgba(255, 112, 137, 0.14); color: #ffb1c0; }
.button:disabled { opacity: 0.45; cursor: not-allowed; }

.link-button {
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link-button:hover { color: #a894ff; }

/* ---------- Intro ---------- */

.main { flex: 1; padding-top: 42px; }

.intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 32px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--mint);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.intro h1 {
  margin: 0 0 10px;
  font-size: clamp(28px, 4.5vw, 44px);
  line-height: 1.1;
  letter-spacing: -0.035em;
}

.intro-copy { margin: 0; max-width: 52ch; color: var(--muted); font-size: 14px; line-height: 1.6; }

.clock-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  white-space: nowrap;
}

.clock-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; }
.clock-time { font-size: 20px; font-variant-numeric: tabular-nums; }

/* ---------- Toolbar ---------- */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(360px, 100%);
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  color: var(--muted);
}

.search-field:focus-within { border-color: var(--accent); }
.search-field svg { width: 16px; height: 16px; }

.search-field input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
}

.search-field input::placeholder { color: #6d7893; }

.privacy-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

.privacy-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }

.switch {
  position: relative;
  width: 38px;
  height: 22px;
  border-radius: 99px;
  background: #35405d;
  transition: background 0.2s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
}

.privacy-toggle input:checked + .switch { background: var(--accent); }
.privacy-toggle input:checked + .switch::after { transform: translateX(16px); }
.privacy-toggle input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---------- Account cards ---------- */

.accounts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(285px, 1fr));
  gap: 16px;
}

.account-card {
  --progress: 1;
  position: relative;
  overflow: hidden;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.account-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--mint));
  opacity: 0.65;
}

.account-card:hover { transform: translateY(-2px); border-color: var(--border-strong); }

.card-head { display: flex; align-items: flex-start; gap: 12px; }

.avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(138, 112, 255, 0.28), rgba(61, 219, 182, 0.16));
  color: #c8bcff;
  font-size: 16px;
  font-weight: 700;
  text-transform: uppercase;
}

.card-identity { min-width: 0; flex: 1; }
.card-issuer { margin: 0; font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-label { margin: 3px 0 0; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.card-menu { display: flex; gap: 2px; }

.icon-button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
}

.icon-button:hover { background: rgba(255, 255, 255, 0.08); color: var(--text); }
.icon-button svg { width: 15px; height: 15px; }
.icon-button.danger:hover { color: var(--danger); }

.code-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 22px 0 16px;
}

.code {
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  font-size: clamp(28px, 3.4vw, 36px);
  font-weight: 600;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.code:hover { color: #c4b8ff; }
.code.is-hidden { letter-spacing: 0.15em; color: var(--muted); }

.timer {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--progress) * 360deg), rgba(255, 255, 255, 0.10) 0);
}

.timer::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: var(--surface-solid);
}

.timer span { position: relative; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
.timer.is-urgent { background: conic-gradient(var(--danger) calc(var(--progress) * 360deg), rgba(255, 255, 255, 0.10) 0); }
.timer.is-urgent span { color: var(--danger); }

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.chips { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 99px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.hint { color: #6d7893; font-size: 11px; }

/* ---------- Empty state ---------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 72px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.015);
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 18px;
  border-radius: 18px;
  background: rgba(138, 112, 255, 0.12);
  color: var(--accent);
}

.empty-icon svg { width: 30px; height: 30px; }
.empty-state h2 { margin: 0 0 8px; font-size: 20px; }
.empty-state p { max-width: 44ch; margin: 0 0 22px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.empty-state code { color: #c4b8ff; }

/* ---------- Footer ---------- */

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 40px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.footer p { margin: 0; max-width: 80ch; }
.footer-actions { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.footer .link-button { white-space: nowrap; }

/* ---------- Lock screen ---------- */

.lock-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(700px 500px at 15% 0%, rgba(124, 92, 255, 0.20), transparent 65%),
    radial-gradient(700px 500px at 85% 100%, rgba(61, 219, 182, 0.12), transparent 60%),
    #080c16;
  overflow: auto;
}

.lock-card {
  width: min(420px, 100%);
  padding: 34px 30px 30px;
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.brand-mark.large { width: 52px; height: 52px; margin: 0 auto 20px; border-radius: 15px; }
.brand-mark.large svg { width: 28px; height: 28px; }

.lock-card .eyebrow { margin-bottom: 10px; }
.lock-card h1 { margin: 0 0 10px; font-size: 25px; letter-spacing: -0.03em; }
.lock-description { margin: 0 0 24px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.lock-card .field { text-align: left; margin-bottom: 14px; }
.lock-card form { display: grid; gap: 0; }
.lock-card .button { margin-top: 8px; }
.lock-card .lock-help { display: grid; gap: 6px; margin-top: 16px; }
.lock-card .link-button { font-size: 12px; }
.lock-note { margin: 20px 0 0; color: #6d7893; font-size: 11px; line-height: 1.5; }

/* ---------- Dialogs ---------- */

dialog.modal {
  width: min(560px, calc(100% - 32px));
  max-height: calc(100vh - 40px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}

dialog.modal::backdrop { background: rgba(4, 7, 14, 0.72); backdrop-filter: blur(4px); }

.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
}

.modal-header { border-bottom: 1px solid var(--border); }
.modal-header h2 { margin: 0; font-size: 17px; }
.modal-footer { border-top: 1px solid var(--border); justify-content: flex-end; }
.modal-body { display: grid; gap: 16px; padding: 22px; }

.field { display: grid; gap: 7px; min-width: 0; }
.field > span { color: #c5cee5; font-size: 12px; font-weight: 600; }
.field small { color: var(--muted); font-size: 11px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-row.three { grid-template-columns: 1.2fr 0.8fr 0.9fr; }

.field input:not([type="file"]),
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  outline: none;
  background: #101627;
  color: var(--text);
  font-size: 14px;
}

.field textarea { resize: vertical; line-height: 1.5; }
.field input:focus,
.field select:focus,
.field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(138, 112, 255, 0.16); }
.field input::placeholder,
.field textarea::placeholder { color: #626d88; }
.field code { color: #c4b8ff; }

.form-error {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(255, 112, 137, 0.35);
  border-radius: 10px;
  background: rgba(255, 112, 137, 0.08);
  color: #ff9bad;
  font-size: 13px;
}

.warning {
  margin: 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(255, 112, 137, 0.08);
  color: #ffb1c0;
  font-size: 13px;
  line-height: 1.5;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  cursor: pointer;
}

.check-row input { margin: 2px 0 0; accent-color: var(--danger); }
.check-row + .button { margin-top: 12px; }

.backup-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.file-field input { padding: 9px 0; font-size: 12px; color: var(--muted); }
.file-field input::file-selector-button {
  margin-right: 10px;
  padding: 7px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface-hover);
  color: var(--text);
  cursor: pointer;
}

/* ---------- Settings ---------- */

.settings-section { padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.settings-section:last-child { padding-bottom: 0; border-bottom: 0; }
.settings-section h3 { margin: 0 0 7px; font-size: 13px; color: #c5cee5; }
.settings-section p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }

.spec-link {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-top: 10px;
  padding: 10px 13px;
  border: 1px solid rgba(138, 112, 255, 0.35);
  border-radius: 10px;
  background: rgba(138, 112, 255, 0.10);
  color: #c4b8ff;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.spec-link:hover { background: rgba(138, 112, 255, 0.18); color: #fff; }
.spec-link svg { width: 16px; height: 16px; }
.settings-actions { margin-top: 14px; }

.scan-modal video {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 12px;
  background: #05070d;
  object-fit: cover;
}

.scan-status { margin: 0; color: var(--muted); font-size: 13px; text-align: center; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 60;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: #222b45;
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 13px;
  opacity: 0;
  transform: translate(-50%, 16px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: rgba(255, 112, 137, 0.5); color: #ffb1c0; }

/* ---------- Responsive ---------- */

@media (max-width: 720px) {
  .app-shell { padding: 0 16px 24px; }
  .topbar { min-height: 72px; }
  .brand-name { font-size: 16px; }
  .top-actions { gap: 6px; }
  .button { min-height: 36px; padding: 0 10px; font-size: 12px; }
  .button svg { width: 15px; height: 15px; }
  .main { padding-top: 28px; }
  .intro { align-items: flex-start; flex-direction: column; gap: 18px; }
  .clock-card { align-items: flex-start; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .search-field { width: 100%; }
  .privacy-toggle { align-self: flex-end; }
  .footer { flex-direction: column; align-items: flex-start; }
  .field-row, .field-row.three { grid-template-columns: 1fr; }
}

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