/* ── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a0f;
  --surface: #12121a;
  --surface-2: #1a1a26;
  --border: #2a2a3a;
  --text: #e8e8f0;
  --text-dim: #8888a0;
  --accent: #6c5ce7;
  --accent-hover: #7d6ff0;
  --danger: #e74c3c;
  --success: #2ecc71;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body { display: flex; flex-direction: column; }

/* ── Screens ──────────────────────────────────────────── */
.screen { display: none; flex: 1; flex-direction: column; }
.screen.active { display: flex; }

/* ── Lock Screen ──────────────────────────────────────── */
.lock-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
}

.lock-icon { font-size: 4rem; margin-bottom: 1rem; }
.lock-container h1 { font-size: 2rem; font-weight: 700; margin-bottom: 0.5rem; }
.subtitle { color: var(--text-dim); margin-bottom: 2rem; }

.lock-actions { display: flex; flex-direction: column; gap: 0.75rem; width: 100%; max-width: 280px; }

/* ── Buttons ──────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  font-family: inherit;
}
.btn:active { transform: scale(0.97); }

.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: var(--border); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.full-width { width: 100%; }

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.25rem;
  padding: 0.5rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ── Vault Screen ─────────────────────────────────────── */
.vault-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}
.vault-header h1 { font-size: 1.25rem; font-weight: 700; }
.header-actions { display: flex; gap: 0.25rem; }

#search-bar { padding: 0.75rem 1.25rem; }
#search-input {
  width: 100%;
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
}
#search-input:focus { border-color: var(--accent); }

/* ── Token List ───────────────────────────────────────── */
.token-list { flex: 1; padding: 0 1rem 1rem; overflow-y: auto; }

.token-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
  overflow: hidden;
}
.token-card:hover { background: var(--surface-2); }

.token-info { flex: 1; min-width: 0; }
.token-service { font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.token-account { font-size: 0.8rem; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.token-code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--accent);
  cursor: pointer;
  transition: color 0.2s;
}
.token-code:hover { color: var(--accent-hover); }

.token-ring {
  width: 36px;
  height: 36px;
  position: relative;
  flex-shrink: 0;
}
.token-ring svg { transform: rotate(-90deg); }
.token-ring .bg { fill: none; stroke: var(--border); stroke-width: 3; }
.token-ring .progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear;
}
.token-ring .progress.warning { stroke: var(--danger); }

/* ── Empty State ──────────────────────────────────────── */
.empty-state {
  display: none;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: var(--text-dim);
  padding: 2rem;
}
.empty-state.visible { display: flex; }

/* ── Modals ───────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}
.modal.hidden { display: none; }

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.modal-header h2 { font-size: 1.15rem; }

.modal-content label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
}
.modal-content input, .modal-content textarea {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
}
.modal-content input:focus, .modal-content textarea:focus { border-color: var(--accent); }
.modal-content button[type="submit"] { margin-top: 0.5rem; width: 100%; }

#qr-reader { width: 100%; border-radius: 8px; overflow: hidden; margin-bottom: 0.5rem; }
#qr-reader video { border-radius: 8px; }

.hint { font-size: 0.8rem; color: var(--text-dim); text-align: center; margin-top: 0.5rem; }
.warning { font-size: 0.8rem; color: #f39c12; margin-top: 0.75rem; }
.error-text { color: var(--danger); font-size: 0.85rem; margin-top: 0.75rem; text-align: center; }
.hidden { display: none !important; }

.settings-list { display: flex; flex-direction: column; gap: 0.5rem; }
.version-text { font-size: 0.75rem; color: var(--text-dim); text-align: center; margin-top: 1.5rem; }

#export-qr { display: flex; justify-content: center; margin: 1rem 0; }
#export-qr img { border-radius: 8px; }
#export-blob { font-size: 0.75rem; font-family: monospace; resize: vertical; margin-bottom: 0.75rem; }

/* ── Toast ────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  border-radius: 999px;
  font-size: 0.85rem;
  z-index: 200;
  animation: toast-in 0.3s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Responsive ───────────────────────────────────────── */
@media (min-width: 600px) {
  .lock-actions { flex-direction: row; }
  .token-list { max-width: 600px; margin: 0 auto; width: 100%; }
  #search-bar { max-width: 600px; margin: 0 auto; width: 100%; }
}
