:root {
  --bg: #0b0b0a;
  --surface: #141413;
  --raised: #1c1c1a;
  --fg: #f3f1ea;
  --muted: #9a978c;
  --subtle: #6e6c64;
  --accent: #ebe6d8;
  --accent-fg: #0b0b0a;
  --border: color-mix(in oklab, #f3f1ea 12%, transparent);
  --sage: #7a9a7c;
  --clay: #c45c4a;
  --sky: #8aa0ad;
  --sand: #c4b8a1;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f3f0e8;
  --surface: #fffcf5;
  --raised: #ffffff;
  --fg: #1c1b18;
  --muted: #6f6c63;
  --subtle: #8e8a80;
  --accent: #1c1b18;
  --accent-fg: #f3f0e8;
  --border: color-mix(in oklab, #1c1b18 12%, transparent);
  --sage: #3f6a48;
  --clay: #b24738;
  --sky: #4d6572;
  --sand: #8a7b62;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); }
body {
  font-family: Figtree, ui-sans-serif, system-ui, -apple-system, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
h1, h2 { font-family: Fraunces, ui-serif, Georgia, serif; font-weight: 500; letter-spacing: -0.03em; text-wrap: balance; }

.app {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.header {
  padding: calc(var(--safe-t) + 16px) 20px 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.kicker { font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); margin: 0 0 4px; }
h1 { font-size: 32px; margin: 0; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.header-actions { display: flex; align-items: center; gap: 4px; padding-top: 4px; }

.icon-btn {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center; color: var(--fg);
}
.icon-btn:active { transform: scale(0.96); }

.ring { width: 44px; height: 44px; position: relative; }
.ring svg { width: 44px; height: 44px; transform: rotate(-90deg); }
.ring span {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 12px; font-variant-numeric: tabular-nums; font-weight: 500;
}

.banner {
  margin: 0 20px 8px;
  background: var(--surface);
  border-radius: 16px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 0 0 1px var(--border);
}
.banner button { text-align: left; font-size: 14px; font-weight: 500; }
.banner .dismiss { color: var(--muted); font-size: 12px; flex-shrink: 0; }

.search {
  margin: 0 20px 8px;
  height: 44px;
  border-radius: 12px;
  background: var(--raised);
  border: 0;
  padding: 0 14px;
  width: calc(100% - 40px);
  outline: none;
}

.main { flex: 1; overflow-y: auto; padding: 8px 12px 16px; min-height: 0; }
.section { margin-bottom: 20px; }
.section h2 {
  font-family: Figtree, sans-serif;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 12px 6px;
  font-weight: 500;
}
.section.overdue h2 { color: var(--clay); }

.row {
  display: flex;
  align-items: stretch;
  gap: 4px;
  border-radius: 12px;
}
.check, .flag {
  width: 44px; height: 44px; display: grid; place-items: center; flex-shrink: 0;
}
.circle {
  width: 24px; height: 24px; border-radius: 50%;
  border: 1.5px solid var(--muted);
  display: grid; place-items: center;
}
.row.done .circle { background: var(--sage); border-color: var(--sage); }
.row.overdue:not(.done) .circle { border-color: var(--clay); }
.row.done { opacity: 0.5; }
.row.done .title { text-decoration: line-through; color: var(--muted); }
.body { flex: 1; min-width: 0; padding: 10px 0; text-align: left; }
.title { font-size: 16px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta { margin-top: 2px; font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.dot.sand { background: var(--sand); }
.dot.sage { background: var(--sage); }
.dot.sky { background: var(--sky); }
.dot.clay { background: var(--clay); }
.dot.paper { background: var(--accent); }
.meta .due.late { color: var(--clay); }
.flag svg { color: var(--subtle); }
.flag.on svg { color: var(--clay); fill: var(--clay); }

.composer-wrap { padding: 8px 12px calc(var(--safe-b) + 4px); }
.composer {
  background: var(--surface);
  border-radius: 16px;
  padding: 6px;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  box-shadow: 0 0 0 1px var(--border);
}
.composer input {
  flex: 1; height: 44px; border: 0; background: transparent; padding: 0 12px; outline: none;
}
.composer input::placeholder { color: var(--subtle); }
.send {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--raised); color: var(--subtle);
  display: grid; place-items: center; margin: 4px;
}
.send.on { background: var(--accent); color: var(--accent-fg); }
.hint { padding: 0 12px 8px; font-size: 12px; color: var(--muted); display: none; }
.hint.show { display: block; }

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  padding: 4px 16px calc(var(--safe-b) + 8px);
}
.tabs button {
  height: 56px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 11px; font-weight: 500; color: var(--subtle);
}
.tabs button.on { color: var(--fg); }

.empty { text-align: center; padding: 64px 32px; color: var(--muted); }
.empty h2 { font-size: 24px; color: var(--fg); margin: 0 0 8px; }
.empty p { margin: 0; font-size: 14px; line-height: 1.5; }

.sheet {
  position: fixed; inset: 0; z-index: 40;
  display: none;
}
.sheet.open { display: block; }
.backdrop { position: absolute; inset: 0; background: color-mix(in oklab, var(--bg) 70%, transparent); }
.panel {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 100%; max-width: 430px; max-height: 92dvh;
  background: var(--surface); border-radius: 24px 24px 0 0;
  overflow: auto; padding: 0 20px calc(var(--safe-b) + 28px);
}
.handle { width: 40px; height: 4px; border-radius: 99px; background: var(--border); margin: 12px auto 8px; }
.panel h3 { font-size: 22px; margin: 8px 0 16px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 500; }
.field input, .field textarea {
  height: 44px; border-radius: 12px; background: var(--raised);
  border: 0; padding: 0 12px; outline: none;
  box-shadow: 0 0 0 1px var(--border);
}
.field textarea { height: auto; min-height: 88px; padding: 12px; resize: vertical; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  height: 40px; padding: 0 14px; border-radius: 999px;
  background: var(--raised); color: var(--muted); font-size: 14px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 8px;
}
.pill.on { background: var(--accent); color: var(--accent-fg); }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.btn {
  height: 44px; border-radius: 12px; background: var(--raised);
  font-size: 14px; font-weight: 500;
}
.btn.primary { background: var(--accent); color: var(--accent-fg); width: 100%; }
.btn.danger { color: var(--clay); background: transparent; width: 100%; }
.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--raised); border-radius: 16px; padding: 12px 16px; margin-bottom: 10px; gap: 12px;
}
.setting-row p { margin: 0; font-size: 14px; font-weight: 500; }
.setting-row span { display: block; font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.switch {
  width: 48px; height: 28px; border-radius: 999px; background: var(--surface);
  position: relative; flex-shrink: 0;
}
.switch i {
  position: absolute; top: 2px; left: 2px; width: 24px; height: 24px;
  border-radius: 50%; background: var(--accent); transition: transform 150ms ease;
}
.switch.on { background: var(--sage); }
.switch.on i { transform: translateX(20px); background: var(--fg); }
.list-card {
  display: flex; align-items: center; gap: 12px;
  height: 64px; background: var(--surface); border-radius: 16px;
  padding: 0 16px; margin-bottom: 8px; text-align: left; width: 100%;
  box-shadow: 0 0 0 1px var(--border);
}
.list-card b { flex: 1; font-weight: 500; }
.list-card em { font-style: normal; color: var(--muted); font-variant-numeric: tabular-nums; }

@media (min-width: 860px) {
  body { overflow: auto; }
  .shell { max-width: 960px; margin: 0 auto; display: grid; grid-template-columns: 260px 1fr; min-height: 100dvh; }
  .rail {
    display: flex !important; flex-direction: column; padding: 28px 16px;
    border-right: 1px solid var(--border);
  }
  .app { max-width: none; }
  .tabs { display: none; }
  .banner { display: none; }
}
.rail { display: none; }
.rail-btn {
  height: 44px; display: flex; align-items: center; gap: 10px;
  padding: 0 12px; border-radius: 12px; color: var(--muted); font-size: 14px; font-weight: 500; text-align: left;
}
.rail-btn.on { background: var(--raised); color: var(--fg); }
.rail-btn em { margin-left: auto; font-style: normal; font-variant-numeric: tabular-nums; font-size: 12px; color: var(--subtle); }
