/* Layout: lists sidebar beside one paper column (wide); on phones, list index and list editor are separate screens. */
:root {
  --bg: #f5f6f4;
  --side: #eceeeb;
  --paper: #ffffff;
  --ink: #1d2320;
  --muted: #6b746f;
  --line: #dde2de;
  --accent: #1f6b57;
  --accent-ink: #ffffff;
  --accent-soft: #e3efe9;
  --err: #c0352b;
  --err-soft: #fbe6e3;
  --info: #8a5a00;
  --info-soft: #fbf0d9;
  --font-display: "Schibsted Grotesk", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Atkinson Hyperlegible", -apple-system, "Segoe UI", sans-serif;
  --pad-l: max(16px, env(safe-area-inset-left, 0px));
  --pad-r: max(16px, env(safe-area-inset-right, 0px));
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141816; --side: #101311; --paper: #1c211f; --ink: #e8ece9; --muted: #95a09a; --line: #2e3532;
    --accent: #5fbf9f; --accent-ink: #0f1a16; --accent-soft: #1f3a31;
    --err: #ff7b6e; --err-soft: #3d1f1c; --info: #f0c060; --info-soft: #3a2f14;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
[hidden] { display: none !important; }
body {
  background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 17px; line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, textarea:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn {
  min-height: 40px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--paper);
  font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:hover { border-color: var(--muted); }
.btn.primary {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
  font-family: var(--font-display); font-weight: 800; letter-spacing: .02em; padding: 0 20px;
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.quiet { background: transparent; border-color: transparent; color: var(--muted); }
.btn.quiet:hover { color: var(--ink); border-color: var(--line); }
.btn.danger { color: var(--err); }
.btn:disabled { opacity: .45; cursor: default; }

.brand h1 { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: 24px; letter-spacing: -.01em; color: var(--accent); }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

/* ---------- full-screen states ---------- */
.center {
  min-height: 100dvh; display: grid; place-items: center; text-align: center;
  padding: max(24px, env(safe-area-inset-top, 0px)) var(--pad-r) max(24px, env(safe-area-inset-bottom, 0px)) var(--pad-l);
}
.center .card { max-width: 380px; display: grid; gap: 18px; justify-items: center; }
.center .brand h1 { font-size: 40px; }
.center .brand p { font-size: 16px; }
.center .note { color: var(--muted); font-size: 14px; margin: 0; }
.center .error { color: var(--err); font-size: 15px; margin: 0; }
.google-btn { min-height: 48px; padding: 0 22px; font-size: 16px; font-weight: 700; }
.google-btn svg { width: 20px; height: 20px; }
.center code { font-size: 14px; background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }

/* ---------- app layout ---------- */
.app { display: grid; grid-template-columns: 290px minmax(0, 1fr); min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100dvh; overflow-y: auto;
  background: var(--side); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 14px;
  padding: max(20px, env(safe-area-inset-top, 0px)) 14px max(14px, env(safe-area-inset-bottom, 0px)) max(14px, env(safe-area-inset-left, 0px));
}
.sidebar .brand { padding: 0 4px; }
.lists { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.list-link {
  text-align: left; border: 0; background: transparent; border-radius: 10px; padding: 9px 10px;
  display: grid; gap: 1px; width: 100%;
}
.list-link:hover { background: var(--paper); }
.list-link[aria-current="true"] { background: var(--accent-soft); }
.list-link .t { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-link .t.untitled { color: var(--muted); font-weight: 400; font-style: italic; }
.list-link .m { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.lists .none { color: var(--muted); font-size: 14px; padding: 8px 10px; }
.account { display: grid; gap: 6px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 10px; }
.account .who { display: flex; align-items: center; gap: 6px; }
.account .who span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account .btn { min-height: 32px; font-size: 13px; padding: 0 8px; }
.offline { color: var(--info); font-weight: 700; }

.editor {
  min-width: 0;
  padding: 0 var(--pad-r) max(48px, env(safe-area-inset-bottom, 0px)) max(24px, env(safe-area-inset-left, 0px));
}
.editor-inner { max-width: 700px; margin: 0 auto; }
.bar {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  padding: max(12px, env(safe-area-inset-top, 0px)) 0 12px;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.bar .spacer { flex: 1; }
#backBtn { display: none; }

.banner { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; margin-bottom: 10px; font-size: 15px; }
.banner.error { background: var(--err-soft); color: var(--err); }
.banner.info { background: var(--info-soft); color: var(--info); }
.banner.ok { background: var(--accent-soft); color: var(--accent); }
.banner ul { margin: 0; padding-left: 18px; }
.banner .msgs { flex: 1; min-width: 0; }
.banner button { background: none; border: 0; color: inherit; font-size: 20px; line-height: 1; padding: 0 4px; }
.confirm { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 12px; border-radius: 10px; background: var(--paper); border: 1px solid var(--line); margin-bottom: 10px; font-size: 15px; }
.confirm span { flex: 1; min-width: 180px; }

.paper { background: var(--paper); border-radius: 14px; border: 1px solid var(--line); padding: 20px 18px 14px; }
#title {
  width: 100%; border: 0; background: transparent; color: var(--ink);
  font-family: var(--font-display); font-weight: 800; font-size: 30px; line-height: 1.15;
  padding: 0 0 10px; outline: none;
}
#title::placeholder { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 60px 16px; display: grid; gap: 14px; justify-items: center; }

.list { display: flex; flex-direction: column; }
.group { display: flex; flex-direction: column; }
.group + .group { border-top: 1px solid var(--line); }
.children { display: flex; flex-direction: column; margin-left: 34px; }
.children .row { border-top: 1px solid var(--line); border-radius: 0; }
.row { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 6px; align-items: start; padding: 5px 6px; border-radius: 8px; }
.row.flagged { background: var(--err-soft); }
.row.flagged textarea { color: var(--err); }
.check {
  width: 24px; height: 24px; margin-top: 2px; border-radius: 50%;
  border: 2px solid var(--muted); background: transparent; padding: 0; display: grid; place-items: center;
}
.check svg { width: 14px; height: 14px; opacity: 0; }
.row.done .check { background: var(--accent); border-color: var(--accent); }
.row.done .check svg { opacity: 1; }
.row.locked .check { opacity: .55; cursor: not-allowed; }
.row textarea {
  width: 100%; min-width: 0; border: 0; resize: none; overflow: hidden; background: transparent;
  color: var(--ink); font: inherit; padding: 2px 0; outline: none; display: block;
}
.row.done textarea { color: var(--muted); }
.flag { font-size: 12px; font-weight: 700; color: var(--err); text-transform: uppercase; letter-spacing: .06em; padding-top: 6px; white-space: nowrap; }
.section-label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 16px 6px 6px; border-top: 1px solid var(--line); margin-top: 6px; }
.add { margin-top: 6px; color: var(--accent); }
.add:hover { color: var(--accent); }

.help { color: var(--muted); font-size: 14px; margin-top: 14px; display: grid; gap: 4px; }
.help kbd { font-family: inherit; font-size: 12px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; background: var(--paper); }

/* ---------- phones: one screen at a time ---------- */
@media (max-width: 759px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; min-height: 100dvh; border-right: 0; padding-left: var(--pad-l); padding-right: var(--pad-r); }
  .editor { padding-left: var(--pad-l); }
  .app[data-view="index"] .editor { display: none; }
  .app[data-view="list"] .sidebar { display: none; }
  #backBtn { display: inline-flex; }
  .hide-narrow { display: none; }
  .list-link { padding: 12px 10px; border-bottom: 1px solid var(--line); border-radius: 0; }
  #title { font-size: 26px; }
  .btn { padding: 0 10px; }
  .children { margin-left: 22px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
