:root {
  --bg: #0f172a;
  --bg2: #1e293b;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #5b5bd6;
  --brand-d: #4744c4;
  --ok: #16a34a;
  --warn: #dc2626;
  --amber: #d97706;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  background: #f1f5f9; color: var(--ink);
  padding-bottom: env(safe-area-inset-bottom);
}
#app { max-width: 640px; margin: 0 auto; }
button { font-family: inherit; cursor: pointer; }

/* ---- login ---- */
.login {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px;
  background: linear-gradient(160deg, #312e81, #5b5bd6 60%, #6d28d9);
  color: #fff; padding: 24px;
}
.login h1 { font-size: 28px; margin: 0; letter-spacing: 2px; }
.login p { margin: 0; opacity: .85; }
.login .pinbox { display: flex; gap: 10px; margin-top: 8px; }
.login .pinbox input {
  width: 200px; text-align: center; font-size: 26px; letter-spacing: 10px;
  padding: 14px; border-radius: 14px; border: none; outline: none;
}
.login button {
  background: #fff; color: var(--brand); border: none; font-weight: 700;
  padding: 14px 30px; border-radius: 14px; font-size: 17px;
}
.login .err { color: #fecaca; min-height: 20px; }

/* ---- header ---- */
header {
  position: sticky; top: 0; z-index: 10;
  background: linear-gradient(135deg, var(--brand), #7c3aed);
  color: #fff; padding: calc(env(safe-area-inset-top) + 14px) 16px 14px;
  display: flex; align-items: center; justify-content: space-between;
}
header h1 { font-size: 20px; margin: 0; letter-spacing: 1px; }
header .gear { background: rgba(255,255,255,.2); border: none; color: #fff;
  width: 38px; height: 38px; border-radius: 50%; font-size: 18px; }

/* ---- quick add ---- */
.quick { padding: 14px 16px; background: var(--bg2);
  position: sticky; top: 0; }
.quick { background: #fff; border-bottom: 1px solid var(--line); }
.quick .row { display: flex; gap: 8px; }
.quick input {
  flex: 1; padding: 13px 14px; border: 1.5px solid var(--line);
  border-radius: 12px; font-size: 16px; outline: none;
}
.quick input:focus { border-color: var(--brand); }
.quick button {
  background: var(--brand); color: #fff; border: none; border-radius: 12px;
  padding: 0 18px; font-size: 16px; font-weight: 700;
}
.quick .hint { color: var(--muted); font-size: 12px; margin: 8px 2px 0; }
.quick .preview { margin-top: 8px; font-size: 13px; color: var(--brand-d);
  background: #eef2ff; border-radius: 10px; padding: 8px 10px; display: none; }

/* ---- tabs ---- */
.tabs { display: flex; gap: 6px; padding: 12px 16px 4px; }
.tabs button {
  flex: 1; border: none; background: #e2e8f0; color: var(--muted);
  padding: 9px 0; border-radius: 999px; font-size: 14px; font-weight: 600;
}
.tabs button.on { background: var(--brand); color: #fff; }

/* ---- list ---- */
.list { padding: 8px 16px 120px; }
.empty { text-align: center; color: var(--muted); padding: 50px 0; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px; margin-bottom: 10px; display: flex; gap: 12px; align-items: flex-start;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.card.overdue { border-color: #fecaca; background: #fff5f5; }
.card .check {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid var(--brand); background: #fff; color: var(--brand);
  font-size: 16px; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.card .body { flex: 1; min-width: 0; }
.card .title { font-size: 16px; font-weight: 600; word-break: break-word; }
.card .meta { margin-top: 4px; font-size: 13px; color: var(--muted);
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.card .when.od { color: var(--warn); font-weight: 700; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 700; }
.badge.rec { background: #ecfeff; color: #0891b2; }
.badge.nag { background: #fef3c7; color: var(--amber); }
.badge.line { background: #dcfce7; color: #15803d; }
.card .note { margin-top: 6px; font-size: 13px; color: #475569; white-space: pre-wrap; }
.card .kebab { flex: none; background: none; border: none; color: var(--muted); font-size: 20px; padding: 0 4px; }
.card.done .title { text-decoration: line-through; color: var(--muted); }
.card.done .check { background: var(--ok); border-color: var(--ok); color: #fff; }

/* ---- FAB ---- */
.fab {
  position: fixed; right: 20px; bottom: calc(env(safe-area-inset-bottom) + 20px);
  width: 60px; height: 60px; border-radius: 50%; border: none;
  background: var(--brand); color: #fff; font-size: 30px; z-index: 20;
  box-shadow: 0 6px 20px rgba(91,91,214,.45);
}

/* ---- modal / sheet ---- */
.sheet-bg { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 30;
  display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: #fff; width: 100%; max-width: 640px; border-radius: 20px 20px 0 0;
  padding: 20px 18px calc(env(safe-area-inset-bottom) + 24px); max-height: 92vh; overflow: auto;
}
.sheet h2 { margin: 0 0 14px; font-size: 18px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px; border: 1.5px solid var(--line); border-radius: 10px;
  font-size: 16px; outline: none; font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); }
.field.inline { display: flex; align-items: center; justify-content: space-between; }
.field.inline label { margin: 0; }
.switch { position: relative; width: 50px; height: 28px; }
.switch input { display: none; }
.switch span { position: absolute; inset: 0; background: #cbd5e1; border-radius: 999px; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::before { transform: translateX(22px); }
.sheet .actions { display: flex; gap: 10px; margin-top: 8px; }
.btn { flex: 1; padding: 14px; border-radius: 12px; border: none; font-size: 16px; font-weight: 700; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.ghost { background: #e2e8f0; color: var(--ink); }
.btn.danger { background: #fee2e2; color: var(--warn); }
.msg { font-size: 13px; margin-top: 8px; min-height: 18px; }
.msg.ok { color: var(--ok); } .msg.err { color: var(--warn); }
hr.sep { border: none; border-top: 1px solid var(--line); margin: 18px 0; }
