:root {
  --bg: #f6f3ec;
  --surface: #ffffff;
  --ink: #1b1a17;
  --muted: #6b665c;
  --line: #e2ddd1;
  --accent: #b4441f;
  --accent-ink: #ffffff;
  --pending: #a86b00;
  --danger: #b3261e;
  --head-bg: rgba(246, 243, 236, 0.94);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161512;
    --surface: #211f1b;
    --ink: #eeeae0;
    --muted: #a39d90;
    --line: #34312b;
    --accent: #e0703f;
    --accent-ink: #161512;
    --pending: #e0a63a;
    --danger: #f28b82;
    --head-bg: rgba(22, 21, 18, 0.94);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }

/* ---------- sign in ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 24px;
}
.login-card img { align-self: center; }
.login-card h1 { margin: 4px 0 12px; text-align: center; font-size: 1.4rem; }
.login-msg { min-height: 1.4em; margin: 4px 0 0; color: var(--danger); font-size: .9rem; }

/* ---------- inputs & buttons ---------- */
input {
  width: 100%; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface);
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button {
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; min-height: 44px;
}
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--danger); }
label { font-size: .85rem; color: var(--muted); margin-top: 6px; }
.hint { font-size: .8rem; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  background: var(--head-bg); backdrop-filter: blur(8px);
  padding: calc(10px + env(safe-area-inset-top)) 16px 6px;
  border-bottom: 1px solid var(--line);
}
.search-wrap { position: relative; }
.search-wrap input { padding-right: 44px; font-size: 1.05rem; -webkit-appearance: none; appearance: none; }
.search-wrap input::-webkit-search-cancel-button { display: none; }
.clear {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  border: 0; background: none; font-size: 1.5rem; color: var(--muted); min-height: 40px; width: 40px; padding: 0;
}
.status-row { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; font-size: .82rem; color: var(--muted); }
.status { border: 0; background: none; padding: 4px 0 4px 8px; min-height: 32px; color: var(--muted); font-size: .82rem; }
.status.pending { color: var(--pending); }
.status.offline { color: var(--pending); }

/* ---------- list ---------- */
.list { padding: 0 16px calc(96px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }
.group { margin-top: 14px; }
.group-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  padding: 6px 0; border-bottom: 1px solid var(--line);
}
.group-head h2 { margin: 0; font-size: 1rem; font-weight: 700; }
.group-head .n { color: var(--muted); font-size: .8rem; font-weight: 400; margin-left: 6px; }
.add-to { border: 0; background: none; color: var(--accent); min-height: 36px; padding: 4px 0 4px 12px; font-size: .9rem; white-space: nowrap; }
.item {
  display: flex; width: 100%; text-align: left; align-items: baseline; gap: 8px;
  padding: 10px 2px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: none; min-height: 44px;
}
.item .t { flex: 1; }
.item .no-title { color: var(--muted); font-style: italic; }
.item .notes { color: var(--muted); font-size: .85rem; }
.item .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--pending); flex: none; align-self: center; }
mark { background: color-mix(in srgb, var(--accent) 28%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.empty { text-align: center; color: var(--muted); padding: 48px 8px; }
.empty button { margin-top: 12px; }

/* ---------- add button ---------- */
.fab {
  position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom));
  width: 60px; height: 60px; border-radius: 50%; padding: 0;
  background: var(--accent); color: var(--accent-ink); border: 0;
  font-size: 2rem; line-height: 1; box-shadow: 0 4px 14px rgba(0,0,0,.25);
}

/* ---------- add/edit dialog ---------- */
dialog {
  width: min(480px, calc(100vw - 24px)); border: 1px solid var(--line); border-radius: 16px;
  background: var(--surface); color: var(--ink); padding: 20px;
}
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog form { display: flex; flex-direction: column; gap: 6px; }
dialog h2 { margin: 0 0 6px; font-size: 1.15rem; }
.dialog-actions { display: flex; gap: 8px; margin-top: 14px; align-items: center; }
.spacer { flex: 1; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(92px + env(safe-area-inset-bottom));
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  font-size: .9rem; max-width: calc(100vw - 32px); z-index: 20;
}
