/* Shared dark theme for sub-pages (saved.html, settings.html, alerts.html). */
:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1c2128;
  --border: #30363d;
  --text: #e6edf3;
  --text-2: #9ba2b0;
  --muted: #6e7681;
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.15);
  --green: #4ade80;
  --warn: #fbbf24;
  --severe: #fb923c;
  --extreme: #f43f5e;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(13, 17, 23, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: calc(12px + var(--safe-top)) 16px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ===========================================================
   Mobile bottom navigation — drops in on every page.
   Replaces the cramped top nav on phones; hidden on desktop.
=========================================================== */
.bottom-nav {
  display: none;
}
@media (max-width: 700px) {
  .bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(13, 17, 23, 0.96);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
    z-index: 60;
    padding: 4px 4px calc(4px + var(--safe-bottom));
    display: flex;
    justify-content: space-around;
    align-items: stretch;
  }
  .bn-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    color: var(--text-2);
    text-decoration: none;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.3px;
    border-radius: 8px;
    min-height: 48px;
  }
  .bn-item .icon { font-size: 19px; margin-bottom: 2px; line-height: 1; }
  .bn-item.active { color: var(--accent); }
  .bn-item:active { background: var(--surface-2); }
  /* Hide the top-of-page nav on mobile; bottom nav replaces it */
  .app-header nav { display: none; }
  /* Sub-pages need to leave room for bottom nav */
  .container { padding-bottom: calc(80px + var(--safe-bottom)); }
}
.app-header .logo {
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  flex-shrink: 0;
}
.app-header .logo .bolt { color: var(--accent); font-size: 18px; }
.app-header nav {
  display: flex;
  gap: 4px;
  flex: 1;
  overflow-x: auto;
}
.app-header nav a {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
  white-space: nowrap;
}
.app-header nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.app-header nav a.active { background: var(--accent-soft); color: var(--accent); }
.app-header .user-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
  flex-shrink: 0;
}

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px calc(40px + var(--safe-bottom));
}
h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.6px; margin: 0 0 6px; }
h2 { font-size: 18px; font-weight: 800; letter-spacing: -0.3px; margin: 28px 0 12px; color: var(--text); }
h3 { font-size: 11px; color: var(--text-2); text-transform: uppercase; letter-spacing: 1.5px; font-weight: 800; margin: 0 0 12px; }
.lede { color: var(--text-2); font-size: 14px; margin-bottom: 24px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 10px;
}

.btn {
  background: var(--accent);
  color: var(--bg);
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.2px;
}
.btn:hover { transform: translateY(-1px); }
.btn.secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn.danger { background: var(--extreme); color: white; }
.btn.small { padding: 6px 12px; font-size: 12px; }
/* Min-44px tap targets on touch screens */
@media (hover: none) and (pointer: coarse) {
  .btn { min-height: 44px; padding: 10px 18px; }
  .btn.small { min-height: 36px; padding: 8px 14px; font-size: 12px; }
}

label {
  display: block;
  font-size: 11px;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: 700;
  margin: 14px 0 6px;
}
input[type="text"], input[type="number"], input[type="password"], select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }

.empty {
  padding: 30px 20px;
  text-align: center;
  color: var(--text-2);
  font-style: italic;
  font-size: 13px;
}
.loading { padding: 30px 20px; text-align: center; color: var(--text-2); font-size: 13px; }

/* Toggle switch */
.toggle { position: relative; display: inline-block; width: 44px; height: 24px; vertical-align: middle; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--border);
  border-radius: 999px;
  transition: 0.2s;
}
.toggle .slider::before {
  position: absolute; content: ""; height: 18px; width: 18px;
  left: 3px; top: 3px;
  background: var(--text);
  border-radius: 50%;
  transition: 0.2s;
}
.toggle input:checked + .slider { background: var(--accent); }
.toggle input:checked + .slider::before { transform: translateX(20px); background: var(--bg); }

/* Modal */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.modal.show { display: flex; }
.modal-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-bottom: none;
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  max-width: 560px;
  width: 100%;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}
.modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-head .title { font-size: 18px; font-weight: 800; }
.modal-close {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  width: 32px; height: 32px; border-radius: 8px; cursor: pointer; font-weight: 700;
}
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot {
  padding: 14px 20px calc(20px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
}
