:root {
  --bg: #f6f7f9; --card: #fff; --ink: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --accent: #2F6B79; --accent-ink: #fff; --brand: #2F6B79; --orange: #DA6A26; --now: #dc2626; --week: #2563eb; --waiting: #a16207; --done: #16a34a;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b1120; --card: #111827; --ink: #e5e7eb; --muted: #94a3b8; --line: #1f2937; --accent: #5fa7b8; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--brand); color: #fff; }
.brand { display: flex; gap: 10px; align-items: flex-end; }
.wordmark { font-weight: 800; font-size: 24px; letter-spacing: -1px; line-height: 1; color: #fff; }
.wordmark i { display: inline-block; width: .17em; height: .17em; border-radius: 50%; background: var(--orange); margin-left: .03em; }
.byline { display: inline-flex; align-items: flex-end; gap: 4px; font-size: 11px; line-height: 1; font-weight: 600; color: rgba(255,255,255,.85); padding-bottom: 1px; }
.byline img { height: 15px; width: auto; display: block; }
.when { color: rgba(255,255,255,.85); font-size: 13px; }

main { max-width: 960px; margin: 0 auto; padding: 16px 16px 96px; }
.view[hidden] { display: none; }
.grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .grid { grid-template-columns: 1fr 1fr; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin-bottom: 16px; }
.grid .card { margin-bottom: 0; }
.grid + .card { margin-top: 16px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 10px; display: flex; justify-content: space-between; }
h2 .more { text-transform: none; letter-spacing: 0; font-size: 13px; }
.muted { color: var(--muted); }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 9px 0; border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: flex-start; }
.list li:first-child { border-top: 0; }
.list .time { min-width: 64px; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; padding-top: 1px; }
.list .main { flex: 1; min-width: 0; }
.list .sub { color: var(--muted); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.list .conflict { color: var(--now); font-size: 12px; font-weight: 600; }

.pill { font-size: 11px; font-weight: 700; text-transform: uppercase; border-radius: 99px; padding: 2px 8px; color: #fff; }
.pill.now { background: var(--now); } .pill.week { background: var(--week); } .pill.waiting { background: var(--waiting); } .pill.done { background: var(--done); }

.btn { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 8px 14px; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

.add { display: flex; gap: 8px; margin-bottom: 16px; }
.add input { flex: 1; min-width: 0; }
input, select, textarea { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 8px 10px; }
.check { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--muted); background: transparent; cursor: pointer; flex: none; margin-top: 1px; }
.check.on { background: var(--done); border-color: var(--done); }
.task-title.done { text-decoration: line-through; color: var(--muted); }
details.task-notes summary { cursor: pointer; color: var(--muted); font-size: 13px; }

.md h1, .md h2, .md h3 { text-transform: none; letter-spacing: 0; color: var(--ink); font-size: 15px; margin: 14px 0 6px; display: block; }
.md p { margin: 6px 0; } .md ul { margin: 4px 0; padding-left: 20px; } .md li { margin: 3px 0; }
.md code { background: var(--bg); padding: 1px 4px; border-radius: 4px; }

.chat-head { margin-bottom: 10px; } .chat-head select { width: 100%; }
.thread { display: flex; flex-direction: column; gap: 10px; }
.msg { padding: 10px 14px; border-radius: 14px; max-width: 92%; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); white-space: pre-wrap; }
.msg.assistant { align-self: flex-start; background: var(--card); border: 1px solid var(--line); }
.msg .tools { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.hint { color: var(--muted); text-align: center; padding: 24px 8px; }
.ask { position: fixed; left: 0; right: 0; bottom: calc(56px + env(safe-area-inset-bottom)); display: flex; gap: 8px; padding: 10px 16px;
  background: var(--bg); border-top: 1px solid var(--line); max-width: 960px; margin: 0 auto; }
.ask textarea { flex: 1; resize: none; max-height: 160px; }
#view-chat { padding-bottom: 70px; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.tabs a { flex: 1; text-align: center; padding: 16px 0; color: var(--muted); font-size: 13px; font-weight: 600; }
.tabs a.on { color: var(--accent); }
.badge { background: var(--now); color: #fff; border-radius: 99px; padding: 0 6px; font-size: 11px; }

.banner { background: #fef3c7; color: #78350f; padding: 10px 16px; font-size: 14px; }
.banner a { color: inherit; text-decoration: underline; }

.signin { background: var(--brand); color: #fff; }
.signin main { min-height: 100vh; display: grid; place-content: center; justify-items: center; text-align: center; gap: 6px; }
.wordmark.xl { font-size: 96px; letter-spacing: -4px; }
.byline.xl { font-size: 20px; gap: 8px; } .byline.xl img { height: 34px; margin-bottom: -2px; }
.signin p { color: rgba(255,255,255,.85); margin: 18px 0 0; }
.btn.light { background: #fff; color: var(--brand); border-color: #fff; font-weight: 600; margin-top: 18px; display: inline-block; }

/* Calendar month view */
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.cal-head h2 { flex: 1; margin: 0; font-size: 18px; text-transform: none; letter-spacing: 0; color: var(--ink); justify-content: flex-start; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin-bottom: 16px; }
.cal-grid.loading { opacity: .5; }
.cal-dow { font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--muted); text-align: center; padding: 2px 0; }
.cal-day { min-height: 92px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 4px; text-align: left;
  display: flex; flex-direction: column; gap: 2px; cursor: pointer; overflow: hidden; font: inherit; color: inherit; }
.cal-day.out { opacity: .45; }
.cal-day.sel { outline: 2px solid var(--accent); outline-offset: -1px; }
.cal-day .num { font-size: 12px; font-weight: 600; color: var(--muted); align-self: flex-start; padding: 1px 5px; border-radius: 99px; }
.cal-day.today .num { background: var(--orange); color: #fff; }
.chip { font-size: 11px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-radius: 4px; padding: 1px 4px;
  background: #E3EFF1; color: #1f4f5a; }
.chip b { font-weight: 600; }
.chip.allday { background: var(--accent); color: #fff; }
.chip.task { background: #FAEEE7; color: #8a3f12; }
.chip.task.done { text-decoration: line-through; opacity: .6; }
.cal-day .more { font-size: 11px; color: var(--muted); padding-left: 4px; }
.cal-day .dots { display: none; gap: 3px; flex-wrap: wrap; margin-top: auto; padding: 0 2px 2px; }
.cal-day .dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.cal-day .dots span.task { background: var(--orange); }
@media (prefers-color-scheme: dark) {
  .chip { background: #16333A; color: #cfe6eb; } .chip.task { background: #3a2316; color: #f5c9ab; }
}
/* Phones: dots instead of chips */
@media (max-width: 640px) {
  .cal-day { min-height: 52px; align-items: center; }
  .cal-day .num { align-self: center; }
  .cal-day .chip, .cal-day .more { display: none; }
  .cal-day .dots { display: flex; justify-content: center; }
}
