:root {
  --bg: #0f1b2d;
  --panel: #16263e;
  --panel-2: #1d3252;
  --ink: #eef3fa;
  --muted: #9db0c9;
  --accent: #d4a644;
  --accent-ink: #1a1305;
  --red: #ff7a7a;
  --amber: #ffcf7a;
  --green: #7ee2a8;
  --line: #2a3f5f;
  --radius: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
}
.app { max-width: 640px; margin: 0 auto; padding: 16px 14px 96px; }
.boot { padding: 40px 0; text-align: center; color: var(--muted); }
.hidden { display: none !important; }

h1 { font-size: 22px; margin: 6px 0 2px; }
h2 { font-size: 15px; margin: 22px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.sub { color: var(--muted); margin: 0 0 12px; font-size: 14px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }

button, .btn {
  font: inherit;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  padding: 9px 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}
button:active, .btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-block { display: block; width: 100%; margin-top: 10px; }
.btn-small { padding: 5px 10px; font-size: 14px; }
.btn-danger { color: var(--red); }
.btn-ghost { background: transparent; }

input, select, textarea {
  font: inherit;
  width: 100%;
  background: #0c1524;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 4px 0 10px;
}
textarea { min-height: 90px; resize: vertical; }
label { font-size: 13px; color: var(--muted); display: block; margin-top: 8px; }
.field-row { display: flex; gap: 10px; }
.field-row > div { flex: 1; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.chip {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 14px;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }

.tag { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.due-red { color: var(--red); font-weight: 600; }
.due-amber { color: var(--amber); font-weight: 600; }
.due-green { color: var(--green); }

.fu { border-left: 3px solid var(--line); }
.fu.overdue { border-left-color: var(--red); }
.fu.today { border-left-color: var(--amber); }
.fu .actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

.typeahead { position: relative; }
.hits {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 20;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  max-height: 240px; overflow: auto;
}
.hits > div { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.hits > div:last-child { border-bottom: 0; }
.hits > div:active { background: var(--panel); }

.task { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.task:last-child { border-bottom: 0; }
.task .t { flex: 1; }
.task.done .t { text-decoration: line-through; color: var(--muted); }

.fab {
  position: fixed; right: 18px; bottom: 84px; z-index: 30;
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  font-size: 30px; line-height: 1; border: none;
  box-shadow: 0 6px 18px rgba(0,0,0,.45);
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--panel); border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0; padding: 16px 16px 34px;
  max-width: 640px; margin: 0 auto;
}
.sheet .btn-block { margin-top: 8px; }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 35; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  display: flex; background: #0b1423; border-top: 1px solid var(--line);
  max-width: 640px; margin: 0 auto;
}
.nav a {
  flex: 1; text-align: center; padding: 8px 0 10px;
  color: var(--muted); text-decoration: none; font-size: 12px;
}
.nav a .ni { display: block; font-size: 18px; margin-bottom: 2px; }
.nav a.on { color: var(--accent); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 150px; z-index: 60;
  background: #23344f; border: 1px solid var(--line); color: var(--ink);
  padding: 10px 16px; border-radius: 999px; font-size: 14px;
  box-shadow: 0 6px 18px rgba(0,0,0,.4);
}
.toast.err { border-color: var(--red); color: var(--red); }

.preview-chip { margin: -4px 0 10px; font-size: 14px; }
.empty { color: var(--muted); text-align: center; padding: 18px 0 8px; font-size: 14px; }
.auth-wrap { max-width: 400px; margin: 8vh auto 0; }
.logo { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.logo img { width: 42px; height: 42px; border-radius: 10px; }
.logo .name { font-size: 20px; font-weight: 700; }
.right { text-align: right; }
.mt { margin-top: 14px; }

:focus-visible { outline:3px solid var(--accent); outline-offset:3px; }
button,.btn,.chip { min-height:44px; }
.nav a { min-height:60px; }
#connection-status { position:sticky;top:0;z-index:70;background:#702a2a;color:#fff;padding:12px;font-size:14px; }
@media(prefers-reduced-motion:reduce){*{scroll-behavior:auto!important;transition:none!important;}}
