/* DarkDefender — dark-first, single theme. The app is a security tool, so the
   palette stays fixed rather than following the OS. */

:root {
  --bg: #07080c;
  --surface: #0f1117;
  --surface-2: #161a25;
  --surface-3: #1d2231;
  --line: #262c3c;
  --line-soft: #1b2030;
  --text: #e9edf6;
  --muted: #8b93a7;
  --muted-2: #626a7d;
  --accent: #00e5a0;
  --accent-dim: #0b6f52;
  --violet: #7c5cff;
  --danger: #ff5c6e;
  --warn: #ffb020;

  --radius: 14px;
  --radius-lg: 20px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, monospace;
  --sans: -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);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body {
  /* A faint aurora keeps the near-black background from reading as an error page. */
  background-image:
    radial-gradient(60rem 40rem at 78% -12%, rgba(124, 92, 255, 0.14), transparent 62%),
    radial-gradient(48rem 34rem at 8% 4%, rgba(0, 229, 160, 0.10), transparent 60%);
  background-attachment: fixed;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
input { -webkit-user-select: text; user-select: text; }

.app {
  max-width: 30rem;
  margin: 0 auto;
  min-height: 100%;
  padding: calc(var(--safe-top) + 1rem) 1rem calc(var(--safe-bottom) + 5.5rem);
  display: flex;
  flex-direction: column;
}

/* ---------- header ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 1.25rem;
}
.topbar__logo { width: 2.1rem; height: 2.1rem; flex: none; }
.topbar__name {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}
.topbar__name span { color: var(--accent); }
.topbar__spacer { flex: 1; }

.iconbtn {
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  transition: color .15s, border-color .15s, background .15s;
}
.iconbtn:hover, .iconbtn:focus-visible { color: var(--text); border-color: var(--line); }
.iconbtn svg { width: 1.15rem; height: 1.15rem; }

/* ---------- generic surfaces ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  padding: 1.15rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  font-weight: 650;
  font-size: 0.95rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  transition: transform .08s, filter .15s, background .15s;
}
.btn:active { transform: scale(.985); }
.btn--primary {
  background: linear-gradient(135deg, var(--accent), #16c9a0 55%, var(--violet));
  color: #04120d;
  border-color: transparent;
}
.btn--primary:hover { filter: brightness(1.07); }
.btn--ghost { background: transparent; }
.btn--danger { color: var(--danger); border-color: rgba(255, 92, 110, .28); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 1.05rem; height: 1.05rem; }

.field { margin-bottom: 0.9rem; }
.field__label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.4rem;
  letter-spacing: 0.01em;
}
.input {
  width: 100%;
  padding: 0.8rem 0.9rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px rgba(0, 229, 160, .12);
}
.input::placeholder { color: var(--muted-2); }
textarea.input { resize: vertical; min-height: 5rem; font-family: var(--mono); font-size: .82rem; }

.hint { font-size: 0.8rem; color: var(--muted); line-height: 1.5; margin: 0.5rem 0 0; }
.hint--warn { color: var(--warn); }

/* ---------- lock screen ---------- */

.lock {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 1.1rem;
  padding-bottom: 4rem;
}
.lock__logo { width: 5.5rem; height: 5.5rem; }
.lock__title { font-size: 1.5rem; font-weight: 750; margin: 0; letter-spacing: -0.02em; }
.lock__sub { color: var(--muted); margin: -0.5rem 0 0; font-size: 0.92rem; max-width: 22rem; line-height: 1.55; }
.lock form { width: 100%; max-width: 20rem; }
.lock .input { text-align: center; letter-spacing: 0.25em; font-family: var(--mono); }

/* ---------- account list ---------- */

.list { display: flex; flex-direction: column; gap: 0.7rem; }

.entry {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.85rem;
  transition: border-color .15s, background .15s;
}
.entry:hover { border-color: var(--line); }
.entry__meta { min-width: 0; }
.entry__issuer {
  font-weight: 650;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.entry__account {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.1rem;
}
.entry__code {
  font-family: var(--mono);
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-top: 0.35rem;
  font-variant-numeric: tabular-nums;
  transition: color .2s;
}
.entry__code--expiring { color: var(--warn); }
.entry__code button { font: inherit; color: inherit; padding: 0; letter-spacing: inherit; }

.entry__right { display: flex; align-items: center; gap: 0.55rem; }

.ring { width: 2.4rem; height: 2.4rem; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 3; }
.ring__track { stroke: var(--surface-3); }
.ring__value { stroke: var(--accent); stroke-linecap: round; transition: stroke .2s; }
.ring--expiring .ring__value { stroke: var(--warn); }
.ring__label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.ring-wrap { position: relative; width: 2.4rem; height: 2.4rem; }

.empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}
.empty svg { width: 3.5rem; height: 3.5rem; opacity: .5; margin-bottom: 1rem; }
.empty p { margin: 0 0 0.4rem; }
.empty strong { color: var(--text); display: block; margin-bottom: .35rem; font-size: 1.02rem; }

/* ---------- bottom bar ---------- */

.fab {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--safe-bottom) + 1.1rem);
  width: min(28rem, calc(100vw - 2rem));
  z-index: 20;
}

/* ---------- sheet ---------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 4, 7, .72);
  backdrop-filter: blur(3px);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.sheet-backdrop[data-open="true"] { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 100%);
  width: min(30rem, 100vw);
  max-height: 92vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 22px 22px 0 0;
  padding: 0.75rem 1.15rem calc(var(--safe-bottom) + 1.5rem);
  z-index: 50;
  transition: transform .26s cubic-bezier(.32, .72, 0, 1);
}
.sheet[data-open="true"] { transform: translate(-50%, 0); }
.sheet__grip {
  width: 2.4rem;
  height: 0.25rem;
  border-radius: 99px;
  background: var(--line);
  margin: 0.35rem auto 1rem;
}
.sheet__title { font-size: 1.12rem; font-weight: 700; margin: 0 0 1rem; letter-spacing: -0.01em; }

.tabs { display: flex; gap: 0.3rem; background: var(--surface-2); padding: 0.25rem; border-radius: 11px; margin-bottom: 1.1rem; }
.tabs button {
  flex: 1;
  padding: 0.55rem 0.4rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  transition: background .15s, color .15s;
}
.tabs button[aria-selected="true"] { background: var(--surface-3); color: var(--text); }

#scanner { display: none; }
#scanner[data-active="true"] { display: block; }
.scanner__frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--line);
}
.scanner__frame video { width: 100%; height: 100%; object-fit: cover; }
.scanner__reticle {
  position: absolute;
  inset: 18%;
  border: 2px solid rgba(0, 229, 160, .85);
  border-radius: 12px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35);
}

/* ---------- misc ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 5rem);
  transform: translate(-50%, 1rem);
  background: var(--surface-3);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 0.7rem 1.1rem;
  border-radius: 11px;
  font-size: 0.88rem;
  font-weight: 550;
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  max-width: calc(100vw - 2rem);
  text-align: center;
}
.toast[data-show="true"] { opacity: 1; transform: translate(-50%, 0); }
.toast[data-kind="error"] { border-color: rgba(255, 92, 110, .45); color: #ffd6db; }

.clock-warning {
  background: rgba(255, 176, 32, .1);
  border: 1px solid rgba(255, 176, 32, .3);
  color: var(--warn);
  border-radius: 11px;
  padding: 0.7rem 0.9rem;
  font-size: 0.82rem;
  line-height: 1.5;
  margin-bottom: 0.9rem;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line-soft);
}
.settings-row:last-of-type { border-bottom: none; }
.settings-row__label { font-size: 0.9rem; font-weight: 550; }
.settings-row__desc { font-size: 0.78rem; color: var(--muted); margin-top: 0.15rem; line-height: 1.45; }
.settings-row button { flex: none; width: auto; padding: 0.55rem 0.9rem; font-size: 0.85rem; }

.hidden { display: none !important; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

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

/* ---------- transfer QR ---------- */

.qr-holder {
  background: #fff;
  border-radius: var(--radius);
  padding: 0.9rem;
  display: grid;
  place-items: center;
}
.qr-holder svg { width: 100%; max-width: 17rem; height: auto; display: block; }
