:root {
  --bg: #0f1220;
  --bg-2: #171a2e;
  --panel: #1b1f38;
  --panel-2: #232847;
  --line: #2a2f4d;
  --text: #eef0fb;
  --muted: #9aa0c4;
  --accent: #6ee7d6;
  --accent-ink: #06231f;
  --danger: #ff6b81;
  --radius: 16px;
  --tap: 52px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 100% -10%, #21264a 0%, rgba(33,38,74,0) 60%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 100%);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(15, 18, 32, 0.72);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; letter-spacing: 0.2px; }
.topbar nav { display: flex; gap: 8px; }

.btn-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
}
.btn-link:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.btn-link.primary { color: var(--accent-ink); background: var(--accent); font-weight: 700; }

/* ---------- capture ---------- */
body.capture { display: flex; flex-direction: column; }
.capture-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

.type-toggle { display: inline-flex; gap: 6px; background: var(--panel); padding: 6px; border-radius: 999px; align-self: flex-start; border: 1px solid var(--line); }
.type {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
}
.type.active { background: var(--accent); color: var(--accent-ink); }

#box {
  flex: 1;
  min-height: 42vh;
  resize: none;
  width: 100%;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  font-size: 20px;
  line-height: 1.5;
  outline: none;
}
#box:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(110,231,214,0.15); }
#box::placeholder { color: var(--muted); }

.capture-actions { display: flex; gap: 12px; align-items: stretch; }
.save {
  flex: 1;
  appearance: none;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 18px;
  font-weight: 800;
  min-height: var(--tap);
  cursor: pointer;
}
.save:active { transform: translateY(1px); }
.mic {
  width: var(--tap);
  min-height: var(--tap);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.mic.recording { background: var(--danger); color: #fff; border-color: var(--danger); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,107,129,0.5);} 50% { box-shadow: 0 0 0 10px rgba(255,107,129,0);} }

.pending { margin: 0; font-size: 13px; }
.muted { color: var(--muted); }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: #0b0e1a;
  color: #fff;
  border: 1px solid var(--line);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- auth ---------- */
body.auth { display: grid; place-items: center; padding: 24px; }
.card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px 24px;
}
.brand-lg { margin: 0 0 6px; font-size: 28px; font-weight: 800; }
.card form { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.card label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.card input[type=password], .card input[type=text], .card textarea {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
  outline: none;
}
.card input:focus, .card textarea:focus { border-color: var(--accent); }
.card .check { flex-direction: row; align-items: center; gap: 8px; }
.card button {
  appearance: none; border: 0; border-radius: 12px;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 800; font-size: 16px; padding: 12px; cursor: pointer;
  min-height: var(--tap);
}
.error { background: rgba(255,107,129,0.12); border: 1px solid var(--danger); color: #ffd7de; padding: 10px 12px; border-radius: 12px; font-size: 14px; }

/* ---------- inbox ---------- */
.inbox-main { max-width: 760px; margin: 0 auto; padding: 16px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
.filters { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.filters #search { flex: 1; min-width: 160px; }
.filters input, .filters select {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; font-size: 15px; outline: none;
}
.filters input:focus, .filters select:focus { border-color: var(--accent); }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.item.done .item-content { text-decoration: line-through; color: var(--muted); }
.item-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.badge { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.badge.task { color: var(--accent); border-color: rgba(110,231,214,0.4); }
.badge.voice { color: #c7a3ff; border-color: rgba(199,163,255,0.4); }
.item-time { font-size: 12px; color: var(--muted); margin-left: auto; }
.item-content { white-space: pre-wrap; word-wrap: break-word; font-size: 16px; line-height: 1.5; }
.item-actions { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.act {
  appearance: none; cursor: pointer;
  background: var(--bg); color: var(--muted);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 7px 12px; font-size: 13px; font-weight: 600;
}
.act:hover { color: var(--text); }
.act.danger:hover { color: #fff; background: var(--danger); border-color: var(--danger); }
.act.primary { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.edit-area { width: 100%; margin-top: 10px; background: var(--bg); color: var(--text); border: 1px solid var(--accent); border-radius: 12px; padding: 12px; font-size: 16px; line-height: 1.5; resize: vertical; }

/* ---------- setup ---------- */
.setup-main { max-width: 640px; margin: 0 auto; padding: 16px; }
.section { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.section h2 { margin: 0 0 8px; font-size: 18px; }
.section p { color: var(--muted); font-size: 14px; line-height: 1.5; }
.url-row { display: flex; gap: 8px; margin: 12px 0; }
.url-row input { flex: 1; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-size: 14px; }
.btn {
  appearance: none; cursor: pointer; border: 0; border-radius: 12px;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 800; font-size: 15px; padding: 12px 18px; min-height: var(--tap);
}
.btn.secondary { background: var(--bg); color: var(--text); border: 1px solid var(--line); }
.status { margin-top: 10px; font-size: 14px; min-height: 20px; }
.status.ok { color: var(--accent); }
.status.err { color: var(--danger); }
.steps { color: var(--muted); font-size: 14px; line-height: 1.6; padding-left: 18px; }
code { background: var(--bg); padding: 2px 6px; border-radius: 6px; font-size: 13px; }
