/* Today — warm, phone-first design system.
   Light is the primary theme; dark follows the system setting. */

:root {
  --paper: #fbf7f1;
  --paper-2: #f3ece1;
  --surface: #ffffff;
  --surface-2: #fdfaf5;
  --ink: #241e1a;
  --ink-2: #4a3f38;
  --muted: #7d6f66;
  --faint: #a99c92;
  --line: #e8ded1;
  --line-strong: #d9ccbb;
  --terracotta: #b8542f;
  --terracotta-soft: #f6e3d9;
  --amber: #b5761a;
  --amber-soft: #fbeed4;
  --green: #4a7357;
  --green-soft: #e4eee5;
  --blue: #37627f;
  --blue-soft: #e2ecf2;
  --plum: #7a4a6b;
  --plum-soft: #f0e3ec;
  --danger: #a63a2c;
  --shadow-sm: 0 1px 2px rgba(58, 42, 31, .05), 0 1px 1px rgba(58, 42, 31, .04);
  --shadow-md: 0 6px 24px -12px rgba(58, 42, 31, .28), 0 2px 6px -2px rgba(58, 42, 31, .08);
  --radius: 20px;
  --radius-sm: 14px;
  --pad: 18px;
  --serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #17130f;
    --paper-2: #1d1813;
    --surface: #211b16;
    --surface-2: #261f19;
    --ink: #f4ece2;
    --ink-2: #ded2c6;
    --muted: #b0a196;
    --faint: #8a7c71;
    --line: #372e26;
    --line-strong: #453a30;
    --terracotta: #e08861;
    --terracotta-soft: #3a241b;
    --amber: #e2ab5a;
    --amber-soft: #3a2c17;
    --green: #8dbb99;
    --green-soft: #1f2c22;
    --blue: #8fb4cc;
    --blue-soft: #1b2830;
    --plum: #c795b6;
    --plum-soft: #2e2029;
    --danger: #e08a7d;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow-md: 0 10px 30px -16px rgba(0, 0, 0, .8);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
  min-height: 100dvh;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
button { font: inherit; color: inherit; }
a { color: inherit; }

.skip {
  position: absolute; left: -999px; top: 0; background: var(--surface);
  padding: 10px 14px; border-radius: 0 0 12px 0; z-index: 100;
}
.skip:focus { left: 0; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s ease;
}
.topbar.is-scrolled { border-bottom-color: var(--line); }
.topbar__inner {
  max-width: 720px; margin: 0 auto; padding: 12px 20px 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.topbar__left { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.wordmark {
  font-family: var(--serif); font-size: 21px; font-weight: 600; letter-spacing: .01em;
}
.topbar__sub {
  font-size: 13px; color: var(--muted); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.topbar__actions { display: flex; gap: 4px; }
.iconbtn {
  width: 40px; height: 40px; display: grid; place-items: center;
  background: transparent; border: 0; border-radius: 50%; cursor: pointer;
  color: var(--ink-2); transition: background .18s ease, transform .18s ease;
}
.iconbtn:hover { background: var(--paper-2); }
.iconbtn:active { transform: scale(.94); }
.iconbtn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.iconbtn.is-spinning svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- layout ---------- */
.main { max-width: 720px; margin: 0 auto; padding: 0 16px 40px; }
.view { display: flex; flex-direction: column; gap: 14px; }

.hero { padding: 6px 4px 2px; }
.hero__day {
  font-family: var(--serif); font-size: clamp(28px, 8vw, 36px); line-height: 1.1;
  letter-spacing: -.015em;
}
.hero__sub { margin-top: 6px; color: var(--muted); font-size: 14px; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.dot { width: 4px; height: 4px; border-radius: 50%; background: var(--faint); display: inline-block; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: var(--pad);
  overflow: hidden;
}
.card--flat { box-shadow: none; background: var(--surface-2); }
.card__head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
}
.card__title {
  font-size: 12px; font-weight: 650; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted);
}
.card__badge {
  margin-left: auto; font-size: 12px; font-weight: 600; color: var(--muted);
  background: var(--paper-2); border-radius: 999px; padding: 2px 9px;
}
.badge-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.badge-dot--terracotta { background: var(--terracotta); }
.badge-dot--green { background: var(--green); }
.badge-dot--amber { background: var(--amber); }
.badge-dot--blue { background: var(--blue); }
.badge-dot--plum { background: var(--plum); }

/* ---------- catch-up ---------- */
.catchup {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--plum-soft); border: 1px solid color-mix(in srgb, var(--plum) 22%, transparent);
  border-radius: var(--radius-sm); padding: 12px 14px;
}
.catchup__text { font-size: 14.5px; color: var(--ink-2); }
.catchup__list { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.catchup__list li { font-size: 13.5px; color: var(--ink-2); display: flex; gap: 8px; }
.catchup__list .k { color: var(--plum); font-weight: 600; }
.catchup__close { margin-left: auto; }

/* ---------- summary strip ---------- */
.strip { display: grid; grid-template-columns: 1.15fr 1fr; gap: 12px; }
@media (max-width: 380px) { .strip { grid-template-columns: 1fr; } }
.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px; display: flex; flex-direction: column; gap: 4px; min-height: 92px;
}
.tile__label { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 600; }
.tile__value { font-size: 20px; font-weight: 600; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.tile__meta { font-size: 13px; color: var(--muted); }
.tile--work { background: var(--blue-soft); border-color: color-mix(in srgb, var(--blue) 20%, transparent); }
.tile--off { background: var(--surface-2); }
.tile--unknown { background: var(--amber-soft); border-color: color-mix(in srgb, var(--amber) 25%, transparent); }
.tile--weather { background: linear-gradient(160deg, var(--surface), var(--surface-2)); }

/* ---------- briefing ---------- */
.brief__summary {
  font-family: var(--serif); font-size: 18.5px; line-height: 1.45; color: var(--ink);
  letter-spacing: -.005em;
}
.brief__meta { margin-top: 10px; font-size: 12.5px; color: var(--faint); display: flex; gap: 8px; align-items: center; }
.focus { margin: 16px 0 0; padding: 0; list-style: none; counter-reset: focus; display: grid; gap: 10px; }
.focus li {
  counter-increment: focus; display: grid; grid-template-columns: 26px 1fr; gap: 10px;
  padding-top: 10px; border-top: 1px dashed var(--line);
}
.focus li:first-child { border-top: 0; padding-top: 0; }
.focus li::before {
  content: counter(focus); font-size: 12px; font-weight: 700; color: var(--terracotta);
  background: var(--terracotta-soft); border-radius: 50%; width: 22px; height: 22px;
  display: grid; place-items: center;
}
.focus__title { font-weight: 600; font-size: 15.5px; }
.focus__why { font-size: 13.5px; color: var(--muted); margin-top: 1px; }
.lookout {
  margin-top: 14px; padding: 10px 12px; border-radius: 12px; background: var(--amber-soft);
  font-size: 13.5px; color: var(--ink-2); display: flex; gap: 8px;
}
.brief__empty { color: var(--muted); font-size: 14.5px; }

/* ---------- task rows ---------- */
.rows { display: grid; gap: 2px; margin: -4px; }
.row {
  display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; align-items: start;
  padding: 11px 4px; border-radius: 12px; text-align: left; background: none; border: 0;
  cursor: pointer; width: 100%; transition: background .15s ease;
}
.row:hover { background: var(--surface-2); }
.row:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.check {
  width: 26px; height: 26px; border-radius: 50%; border: 1.7px solid var(--line-strong);
  display: grid; place-items: center; background: var(--surface); color: transparent;
  transition: border-color .15s, background .15s, color .15s; flex: none; cursor: pointer;
  position: relative;
}
/* The circle stays small; the touch target does not. */
.check::after {
  content: ""; position: absolute; inset: -10px; border-radius: 50%;
}
.check:hover { border-color: var(--green); color: var(--green); }
.check svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.row__body { min-width: 0; }
.row__title { font-size: 15.5px; line-height: 1.35; overflow-wrap: anywhere; }
.row__meta { margin-top: 3px; font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.row__chev { color: var(--faint); align-self: center; transition: transform .2s ease; }
.row__chev svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }
.row[aria-expanded="true"] .row__chev { transform: rotate(90deg); }

.task-group + .task-group { margin-top: 14px; }
.task-group__name {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--faint);
  font-weight: 650; margin-bottom: 4px;
}
.overdue-text { color: var(--danger); }
.tag {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600;
  padding: 1px 7px; border-radius: 999px; background: var(--paper-2); color: var(--ink-2);
}
.tag--due { background: var(--blue-soft); color: var(--blue); }
.tag--late { background: var(--terracotta-soft); color: var(--danger); }
.tag--rec { background: var(--green-soft); color: var(--green); }

.detail {
  padding: 4px 0 10px 40px; display: grid; gap: 10px;
}
.mail__row + .detail { padding-left: 26px; }
.detail__facts { display: grid; gap: 4px; font-size: 13.5px; color: var(--ink-2); }
.detail__facts div { display: flex; gap: 8px; }
.detail__facts dt { color: var(--muted); min-width: 84px; }
.detail__facts dd { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 42px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--surface); font-size: 14px; font-weight: 600; cursor: pointer;
  transition: transform .12s ease, background .15s ease, border-color .15s;
  text-decoration: none;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn--primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn--primary:hover { background: var(--ink-2); }
.btn--ghost { border-color: transparent; background: var(--paper-2); }
.btn--danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); background: var(--terracotta-soft); }
.btn--sm { min-height: 44px; padding: 0 14px; font-size: 13.5px; }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- mail ---------- */
.mail { display: grid; gap: 2px; }
.mail__row { grid-template-columns: 10px 1fr auto; }
.mail__pip { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); margin-top: 9px; }
.mail__from { font-size: 13px; color: var(--muted); }
.mail__subject { font-size: 15.5px; line-height: 1.35; font-weight: 550; }
.mail__reason { margin-top: 3px; font-size: 13px; color: var(--ink-2); }
.mail__snippet { margin-top: 6px; font-size: 13.5px; color: var(--muted); }
.state-pill { font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.state-pill--archived { color: var(--green); }
.state-pill--unknown { color: var(--amber); }
.state-pill--failed { color: var(--danger); }

/* ---------- completed ---------- */
.collapsible__head {
  display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: 0;
  padding: 10px 0; cursor: pointer; text-align: left; min-height: 44px;
}
.collapsible__chev { margin-left: auto; color: var(--faint); transition: transform .2s; }
.collapsible__chev svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }
.collapsible[data-open="true"] .collapsible__chev { transform: rotate(180deg); }
.done-item { display: flex; gap: 10px; padding: 8px 0; font-size: 14px; color: var(--muted); align-items: baseline; }
.done-item + .done-item { border-top: 1px solid var(--line); }
.done-item__time { font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--faint); min-width: 42px; }
.done-item__text { color: var(--ink-2); text-decoration: line-through; text-decoration-color: var(--line-strong); }

/* ---------- states ---------- */
.state {
  display: grid; gap: 8px; padding: 26px 18px; text-align: center; color: var(--muted);
  background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: var(--radius-sm);
}
.state__title { color: var(--ink-2); font-weight: 600; font-size: 15px; }
.state__body { font-size: 13.5px; }
.state--error { background: var(--terracotta-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.gap {
  display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--ink-2);
  background: var(--amber-soft); border-radius: 12px; padding: 9px 11px;
}
.gap__icon { color: var(--amber); flex: none; margin-top: 1px; }
.gap__icon svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; }
.skeleton { border-radius: 12px; background: linear-gradient(90deg, var(--paper-2) 25%, var(--surface-2) 50%, var(--paper-2) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- journal ---------- */
.journal__toolbar { display: flex; align-items: center; gap: 8px; }
.datechip {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line);
  background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 13.5px; font-weight: 600;
  cursor: pointer;
}
.journal__editor {
  width: 100%; min-height: 46vh; border: 0; background: transparent; color: var(--ink);
  font-family: var(--serif); font-size: 17px; line-height: 1.6; resize: vertical; padding: 0;
  outline: none;
}
.journal__editor::placeholder { color: var(--faint); font-style: italic; }
.savestate { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.savestate--pending { color: var(--amber); }
.savestate--error { color: var(--danger); }
.savestate--saved { color: var(--green); }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.conflict {
  border: 1px solid color-mix(in srgb, var(--amber) 40%, transparent); background: var(--amber-soft);
  border-radius: var(--radius-sm); padding: 14px; display: grid; gap: 10px;
}
.conflict__cols { display: grid; gap: 10px; }
@media (min-width: 560px) { .conflict__cols { grid-template-columns: 1fr 1fr; } }
.conflict__col { background: var(--surface); border-radius: 10px; padding: 10px; font-size: 13px; white-space: pre-wrap; max-height: 220px; overflow: auto; }
.conflict__label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 6px; font-weight: 700; }

/* ---------- history ---------- */
.daylist { display: grid; gap: 8px; }
.dayrow {
  display: grid; gap: 4px; text-align: left; width: 100%; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 13px 14px; cursor: pointer;
}
.dayrow:hover { border-color: var(--line-strong); }
.dayrow__top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.dayrow__title { font-weight: 600; font-size: 15px; }
.dayrow__meta { font-size: 12.5px; color: var(--muted); }
.dayrow__summary { font-size: 13.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.upcoming { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(148px, 1fr); gap: 10px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: none; scroll-snap-type: x proximity; margin: 0 -6px; }
.upcoming::-webkit-scrollbar { display: none; }
.upday {
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; background: var(--surface);
  display: grid; gap: 2px; text-align: left; cursor: pointer; min-width: 148px; scroll-snap-align: start;
}
.upday__name { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 650; }
.upday__shift { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.upday__meta { font-size: 12.5px; color: var(--faint); }

/* ---------- tabbar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; justify-content: center; gap: 6px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(140%) blur(16px);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1; max-width: 220px; display: grid; justify-items: center; gap: 2px;
  background: none; border: 0; padding: 6px 4px; border-radius: 14px; cursor: pointer;
  color: var(--muted); font-size: 11.5px; font-weight: 600; letter-spacing: .01em;
  transition: color .15s ease, background .15s ease;
}
.tab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tab.is-active { color: var(--terracotta); background: var(--terracotta-soft); }

/* ---------- toasts + sheet ---------- */
.toast-wrap {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 60;
  display: grid; gap: 8px; width: min(92vw, 420px);
}
.toast {
  background: var(--ink); color: var(--paper); border-radius: 14px; padding: 11px 14px;
  font-size: 14px; box-shadow: var(--shadow-md); display: flex; gap: 10px; align-items: center;
  animation: rise .2s ease;
}
.toast--error { background: var(--danger); color: #fff; }
.toast--ok { background: var(--green); color: #fff; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(24, 16, 10, .42); z-index: 70;
  backdrop-filter: blur(2px); animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed; z-index: 71; left: 50%; transform: translateX(-50%);
  bottom: 0; width: min(100%, 560px); max-height: 88dvh; overflow: auto;
  background: var(--surface); border-radius: 24px 24px 0 0; padding: 20px 20px calc(24px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-md); animation: slideup .22s cubic-bezier(.2,.8,.2,1);
}
@media (min-width: 640px) {
  .sheet { bottom: 24px; border-radius: 24px; }
}
@keyframes slideup { from { transform: translate(-50%, 24px); opacity: .6; } }
.sheet__head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.sheet__title { font-family: var(--serif); font-size: 20px; }
.sheet__close { margin-left: auto; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 650; }
.field input, .field textarea, .field select {
  font: inherit; font-size: 15px; padding: 11px 12px; border-radius: 12px;
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--ink); width: 100%;
}
.field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid var(--blue); outline-offset: 1px; }
.chipset { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  border: 1px solid var(--line-strong); background: var(--surface); border-radius: 999px;
  padding: 6px 11px; font-size: 13px; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.sheet__actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
