:root {
  --bg: #0a0a0a;
  --surface: #131313;
  --surface-2: #1a1a1a;
  --border: #262626;
  --text: #f2f2f0;
  --muted: #8f8f8f;
  --accent: #7c6cff;
  --accent-text: #0a0a0a;
  --danger: #ff5c5c;
  --success: #4ade80;
  --radius: 14px;
  --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;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-weight: 600; margin: 0; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(16px + var(--safe-top)) 20px 16px;
  background: rgba(10, 10, 10, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.content {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 20px calc(100px + var(--safe-bottom));
}

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: rgba(19, 19, 19, 0.9);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  padding: 8px 8px calc(8px + var(--safe-bottom));
  z-index: 10;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0;
  color: var(--muted);
  font-size: 11px;
  border-radius: 10px;
}

.tab.active { color: var(--text); }
.tab-icon { font-size: 18px; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 28px 0 14px;
}

.section-head:first-child { margin-top: 4px; }
.section-head h2 { font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.list-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.list-item-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.list-item-title { font-weight: 600; font-size: 15px; }
.list-item-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item-actions { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }

.empty { color: var(--muted); font-size: 14px; padding: 20px 0; text-align: center; }

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 100px;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.badge.success { color: var(--success); }
.badge.danger { color: var(--danger); }
.badge.accent { color: var(--accent); }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  transition: opacity 0.15s ease, transform 0.1s ease;
}
button:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  padding: 10px 16px;
}
.btn-primary:disabled { opacity: 0.5; }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 16px;
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--border);
  padding: 8px 12px;
}

.btn-sm { padding: 7px 12px; font-size: 13px; }
.icon-btn {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 6px 10px;
  font-size: 13px;
}

label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: -4px;
}

input, select, textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* iOS Safari renders the native time/date picker wider than its CSS box
   in some versions, spilling it past the input's border. */
input[type="time"],
input[type="date"],
input[type="datetime-local"] {
  max-width: 100%;
  min-width: 0;
  display: block;
  -webkit-appearance: none;
  appearance: none;
}

.inline { display: inline; }

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 24px;
  font-size: 14px;
}
.hidden { display: none !important; }

.hint {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  margin: -6px 0 14px;
}
code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 12px;
}

.error { color: var(--danger); font-size: 14px; margin: -8px 0 4px; }

.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.auth-card h1 { text-align: center; margin-bottom: 8px; }
.auth-card form { display: flex; flex-direction: column; gap: 10px; }
.auth-card button { margin-top: 8px; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}
@media (min-width: 560px) {
  .modal-overlay { align-items: center; }
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 24px 20px calc(24px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}
@media (min-width: 560px) {
  .modal { border-radius: 20px; }
}

.modal-title { font-size: 18px; font-weight: 700; }
.modal-actions { display: flex; gap: 10px; margin-top: 6px; }
.modal-actions button { flex: 1; }

.key-reveal {
  background: var(--surface-2);
  border: 1px dashed var(--accent);
  border-radius: 10px;
  padding: 12px;
  font-family: ui-monospace, monospace;
  font-size: 13px;
  word-break: break-all;
}

.toast {
  position: fixed;
  bottom: calc(90px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 100px;
  font-size: 13px;
  z-index: 200;
  animation: toast-in 0.2s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
