:root {
  --bg: #0d0d0d;
  --surface: #171717;
  --surface-2: #1f1f1f;
  --text: #ededed;
  --muted: #8b8b8b;
  --accent: #4ade80;
  --accent-dim: #1c3a28;
  --danger: #f87171;
  --border: #272727;
  --radius: 16px;
  --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; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC",
        "HarmonyOS Sans SC", "Microsoft YaHei UI", sans-serif;
  overscroll-behavior-y: contain;
}

[hidden] { display: none !important; }

/* ---------- auth ---------- */
.auth {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: var(--bg); padding: 24px;
}
.auth-box { width: 100%; max-width: 340px; }
.auth-box h1 { font-size: 20px; margin: 0 0 6px; font-weight: 600; }
.auth-box p { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.auth-box input {
  width: 100%; padding: 14px 15px; font-size: 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; color: var(--text); outline: none;
  font-family: inherit;
}
.auth-box input:focus { border-color: #3d3d3d; }
.auth-box button {
  width: 100%; margin-top: 12px; padding: 14px;
  background: var(--accent); color: #08130c; border: 0;
  border-radius: 12px; font-size: 16px; font-weight: 600;
  font-family: inherit;
}
.err { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ---------- app ---------- */
#app {
  padding-bottom: calc(84px + var(--safe-bottom));
  min-height: 100vh;
}

header {
  position: sticky; top: 0; z-index: 10;
  background: rgba(13, 13, 13, .92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: calc(14px + var(--safe-top)) 18px 10px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
header h1 { font-size: 18px; margin: 0; font-weight: 600; letter-spacing: .01em; }

.tabs { display: flex; gap: 4px; background: var(--surface); padding: 3px; border-radius: 10px; }
.tab {
  border: 0; background: transparent; color: var(--muted);
  font-size: 13px; padding: 6px 12px; border-radius: 8px;
  font-family: inherit; transition: .15s;
}
.tab.active { background: var(--surface-2); color: var(--text); }

main { padding: 10px 12px; }

.item {
  display: flex; gap: 13px; align-items: flex-start;
  background: var(--surface); border-radius: var(--radius);
  padding: 15px 15px; margin: 8px 0;
  transition: opacity .22s ease, transform .22s ease;
}
.item:active { background: var(--surface-2); }
.item.leaving { opacity: 0; transform: translateX(24px); }

.check {
  flex: 0 0 24px; width: 24px; height: 24px; margin-top: 1px;
  border-radius: 50%; border: 2px solid #3a3a3a;
  display: grid; place-items: center;
  color: transparent; font-size: 12px; transition: .15s;
}
.item:active .check { border-color: var(--accent); color: var(--accent); }
.item.is-done .check {
  background: var(--accent-dim); border-color: var(--accent); color: var(--accent);
}

.body { flex: 1; min-width: 0; }
.text { word-break: break-word; font-size: 15.5px; }
.item.is-done .text { color: var(--muted); text-decoration: line-through; text-decoration-color: #4a4a4a; }

.meta {
  margin-top: 6px; font-size: 12px; color: var(--muted);
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}
.tag {
  background: var(--surface-2); border-radius: 6px;
  padding: 1px 7px; font-size: 11px; color: #9a9a9a;
}
.old { color: #d08b5b; }

.empty {
  text-align: center; color: var(--muted);
  padding: 72px 24px; font-size: 14px; line-height: 2;
}
.empty b { display: block; font-size: 15px; color: #b8b8b8; font-weight: 500; margin-bottom: 4px; }

/* ---------- composer ---------- */
#composer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; gap: 8px;
  padding: 10px 12px calc(10px + var(--safe-bottom));
  background: rgba(17, 17, 17, .95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}
#q {
  flex: 1; min-width: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 13px; color: var(--text);
  padding: 13px 15px; font-size: 16px; outline: none;
  font-family: inherit;
}
#q:focus { border-color: #3d3d3d; }
#q::placeholder { color: #5e5e5e; }
#send {
  flex: 0 0 auto; width: 52px;
  background: var(--accent); color: #08130c;
  border: 0; border-radius: 13px;
  font-size: 22px; font-weight: 700; line-height: 1;
  font-family: inherit;
}
#send:disabled { opacity: .35; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
