/* ── Variables ───────────────────────────────────────────────────────────── */
:root {
  --font: "JetBrains Mono", "Fira Code", "SF Mono", "Cascadia Code", monospace;

  /* dark (default) */
  --bg:        #0d1117;
  --surface:   #161b22;
  --border:    #30363d;
  --text:      #e6edf3;
  --muted:     #8b949e;
  --accent:    #58a6ff;
  --success:   #3fb950;
  --warning:   #d29922;
  --error:     #f85149;
  --tag-bg:    #388bfd26;
  --tag-text:  #58a6ff;
  --input-bg:  #0d1117;
  --btn-hover: #1f2937;
}

[data-theme="light"] {
  --bg:        #ffffff;
  --surface:   #f6f8fa;
  --border:    #d0d7de;
  --text:      #1f2328;
  --muted:     #656d76;
  --accent:    #0969da;
  --success:   #1a7f37;
  --warning:   #9a6700;
  --error:     #d1242f;
  --tag-bg:    #dbeafe;
  --tag-text:  #0969da;
  --input-bg:  #ffffff;
  --btn-hover: #f0f0f0;
}

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

body {
  font-family: var(--font);
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */
.app { max-width: 480px; margin: 0 auto; padding: 0 0 env(safe-area-inset-bottom); }

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky; top: 0; z-index: 10;
}

header h1 { font-size: 14px; font-weight: 600; color: var(--accent); }
header .subtitle { font-size: 11px; color: var(--muted); }

.page { padding: 16px; display: none; }
.page.active { display: block; }

/* ── Section headers ──────────────────────────────────────────────────────── */
.section-title {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 20px 0 8px;
}
.section-title::before { content: "> "; color: var(--accent); }

/* ── Cards / Surfaces ────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 8px;
}

/* ── Status badges ───────────────────────────────────────────────────────── */
.status { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; }
.status.ok      { color: var(--success); }
.status.error   { color: var(--error); }
.status.paused  { color: var(--muted); }
.status.checking { color: var(--accent); }
.status::before { font-size: 10px; }
.status.ok::before      { content: "✓"; }
.status.error::before   { content: "⚠"; }
.status.paused::before  { content: "⏸"; }
.status.checking::before { content: "●"; animation: blink 1s step-start infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ── Account list item ───────────────────────────────────────────────────── */
.account-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.account-item .meta { flex: 1; min-width: 0; }
.account-item .label { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-item .detail { font-size: 11px; color: var(--muted); margin-top: 2px; }
.account-item .actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ── Inputs ──────────────────────────────────────────────────────────────── */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.field label::before { content: "> "; color: var(--accent); }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
select, textarea {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  padding: 8px 10px;
  outline: none;
  transition: border-color 150ms ease;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 20%, transparent);
}
input::placeholder { color: var(--muted); }

select { appearance: none; cursor: pointer; }
select option { background: var(--surface); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease;
  white-space: nowrap;
}
.btn:hover { background: var(--btn-hover); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { opacity: 0.88; }
.btn-danger { color: var(--error); border-color: var(--error); }
.btn-danger:hover { background: color-mix(in srgb, var(--error) 10%, transparent); }
.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Tag / badge ─────────────────────────────────────────────────────────── */
.tag {
  display: inline-block;
  background: var(--tag-bg);
  color: var(--tag-text);
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.tag.experimental { color: var(--warning); background: color-mix(in srgb, var(--warning) 15%, transparent); }

/* ── Progress / status lines ─────────────────────────────────────────────── */
.status-line { font-size: 12px; color: var(--muted); margin-top: 6px; min-height: 18px; }
.status-line.ok      { color: var(--success); }
.status-line.error   { color: var(--error); }

/* ── Toggle ──────────────────────────────────────────────────────────────── */
.toggle { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; }
.toggle-label { font-size: 13px; }
.toggle-desc  { font-size: 11px; color: var(--muted); margin-top: 2px; }
.toggle input[type="checkbox"] { display: none; }
.toggle .switch {
  width: 36px; height: 20px;
  background: var(--border);
  border-radius: 10px;
  position: relative;
  cursor: pointer;
  transition: background 150ms;
  flex-shrink: 0;
}
.toggle .switch::after {
  content: "";
  position: absolute;
  width: 14px; height: 14px;
  background: #fff;
  border-radius: 50%;
  top: 3px; left: 3px;
  transition: transform 150ms;
}
.toggle input:checked ~ .switch { background: var(--accent); }
.toggle input:checked ~ .switch::after { transform: translateX(16px); }

/* ── Health summary ──────────────────────────────────────────────────────── */
.health-banner {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 4px; font-size: 12px; margin-bottom: 12px;
}
.health-banner.ok     { background: color-mix(in srgb, var(--success) 10%, transparent); color: var(--success); }
.health-banner.warn   { background: color-mix(in srgb, var(--warning) 10%, transparent); color: var(--warning); }
.health-banner.error  { background: color-mix(in srgb, var(--error) 10%, transparent); color: var(--error); }

/* ── Blocklist ────────────────────────────────────────────────────────────── */
.blocklist-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 0; border-bottom: 1px solid var(--border);
}
.blocklist-item:last-child { border-bottom: none; }
.blocklist-remove { background: none; border: none; color: var(--error); cursor: pointer; font-size: 14px; }

/* ── Usage table ─────────────────────────────────────────────────────────── */
.usage-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 12px; border-bottom: 1px solid var(--border); }
.usage-row:last-child { border-bottom: none; }
.usage-bar { height: 3px; background: var(--accent); border-radius: 2px; margin-top: 3px; transition: width 300ms; }
.usage-bar-bg { height: 3px; background: var(--border); border-radius: 2px; margin-top: 3px; }

/* ── Log viewer ──────────────────────────────────────────────────────────── */
.log-entry { padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 11px; }
.log-entry:last-child { border-bottom: none; }
.log-entry .log-time { color: var(--muted); margin-right: 6px; }
.log-entry.info  .log-level { color: var(--accent); }
.log-entry.warn  .log-level { color: var(--warning); }
.log-entry.error .log-level { color: var(--error); }

/* ── Expandable hint ─────────────────────────────────────────────────────── */
details summary { cursor: pointer; color: var(--accent); font-size: 12px; padding: 6px 0; list-style: none; }
details summary::before { content: "▶ "; font-size: 10px; }
details[open] summary::before { content: "▼ "; }
details .hint-body { color: var(--muted); font-size: 12px; padding: 6px 0 6px 14px; line-height: 1.7; }

/* ── Nav tabs ────────────────────────────────────────────────────────────── */
.bottom-nav {
  display: flex;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav .nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 8px 4px; cursor: pointer; color: var(--muted); font-size: 10px; gap: 2px;
  border: none; background: none; font-family: var(--font);
  transition: color 150ms;
}
.bottom-nav .nav-item.active { color: var(--accent); }
.bottom-nav .nav-item .icon { font-size: 18px; }

main { padding-bottom: 60px; }

/* ── Misc ────────────────────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.empty { color: var(--muted); text-align: center; padding: 32px 16px; font-size: 12px; }
.empty .emoji { font-size: 32px; display: block; margin-bottom: 8px; }
.row { display: flex; gap: 8px; align-items: flex-start; }
.row .field { flex: 1; }
