:root {
  --bg: #f6f6f3;
  --panel: #ffffff;
  --ink: #16181d;
  --ink-2: #545862;
  --ink-3: #8b8f98;
  --line: #e3e3de;
  --line-2: #eeeeea;
  --accent: #d9481f;          /* the "now" colour: a struck match */
  --accent-ink: #ffffff;
  --accent-soft: #fbe6df;
  --event: #1f3a5f;
  --event-soft: #e4ebf4;
  --plan: #2f6b4f;
  --plan-soft: #e2f0e8;
  --danger: #b42318;
  --radius: 12px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121418;
    --panel: #1a1d22;
    --ink: #eceae6;
    --ink-2: #a9adb5;
    --ink-3: #737882;
    --line: #2a2e35;
    --line-2: #22252b;
    --accent: #ff6a3d;
    --accent-ink: #1a0d08;
    --accent-soft: #3a1f17;
    --event: #a9c4e8;
    --event-soft: #1d2a3b;
    --plan: #8fd1ad;
    --plan-soft: #1a3026;
    --danger: #ff7b6e;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent;
  background: var(--panel); cursor: pointer; text-decoration: none; font-weight: 600; white-space: nowrap;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { background: var(--line-2); }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn {
  width: 36px; height: 36px; display: inline-grid; place-items: center;
  border: 0; background: transparent; border-radius: 9px; cursor: pointer; color: var(--ink-2);
}
.icon-btn:hover { background: var(--line-2); color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- mark ---------- */
.mark { width: 56px; height: 56px; border-radius: 15px; background: var(--ink); position: relative; margin-bottom: 18px; }
.mark span { position: absolute; left: 12px; right: 12px; top: 50%; height: 3px; background: var(--accent); border-radius: 2px; }
.mark span::before { content: ""; position: absolute; left: -4px; top: -4.5px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }
.mark.small { width: 28px; height: 28px; border-radius: 8px; margin: 0; }
.mark.small span { left: 6px; right: 6px; height: 2px; }
.mark.small span::before { width: 7px; height: 7px; left: -2px; top: -2.5px; }

/* ---------- sign-in ---------- */
.signin { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.signin-card { width: 100%; max-width: 360px; }
.signin h1 { font-size: 30px; margin: 0 0 6px; letter-spacing: -.02em; }
.signin p { color: var(--ink-2); margin: 0 0 24px; }
.signin .fine { font-size: 13px; color: var(--ink-3); margin-top: 14px; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100%; }
.rail {
  position: fixed; z-index: 20; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.rail-brand { display: none; }
.tab {
  flex: 1; max-width: 90px; border: 0; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0;
  color: var(--ink-3); font-size: 11px; font-weight: 600; border-radius: 10px;
}
.tab[aria-current="page"] { color: var(--ink); }
.tab[aria-current="page"] svg { color: var(--accent); }
.main {
  flex: 1; min-width: 0; max-width: 980px; margin: 0 auto;
  padding: calc(10px + env(safe-area-inset-top)) 16px calc(86px + env(safe-area-inset-bottom));
}

@media (min-width: 860px) {
  .rail {
    position: sticky; top: 0; bottom: auto; right: auto; height: 100vh; width: 208px;
    flex-direction: column; justify-content: flex-start; gap: 2px; padding: 18px 12px;
    border-top: 0; border-right: 1px solid var(--line); background: var(--panel);
  }
  .rail-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; padding: 4px 10px 18px; }
  .tab { flex: none; max-width: none; flex-direction: row; gap: 12px; padding: 9px 12px; font-size: 14px; }
  .tab:hover { background: var(--line-2); color: var(--ink); }
  .tab[aria-current="page"] { background: var(--line-2); }
  .main { padding: 20px 32px 40px; }
}

/* ---------- top bar ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.top-date { display: flex; align-items: center; gap: 2px; min-width: 0; }
.title-btn {
  border: 0; background: transparent; cursor: pointer; padding: 4px 6px; border-radius: 8px;
  font-size: 21px; font-weight: 700; letter-spacing: -.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.title-btn small { font-size: 14px; font-weight: 500; color: var(--ink-3); margin-left: 6px; }

/* ---------- ask bar ---------- */
.ask {
  display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 14px;
}
.ask:focus-within { border-color: var(--ink-3); }
.ask #ask-input { flex: 1; padding: 0; border-radius: 0; min-width: 0; border: 0; background: transparent; outline: none; height: 38px; font-size: 16px; }
.ask input::placeholder { color: var(--ink-3); }
.mic.listening { color: var(--accent); background: var(--accent-soft); }

/* ---------- proposal + summary ---------- */
.proposal, .summary {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 14px;
}
.proposal h3, .summary h3 { margin: 0 0 8px; font-size: 12px; font-weight: 700; color: var(--ink-3); letter-spacing: .02em; }
.prop-item { display: flex; gap: 12px; align-items: baseline; padding: 8px 0; border-top: 1px solid var(--line-2); }
.prop-item:first-of-type { border-top: 0; }
.prop-when { font-family: var(--mono); font-size: 13px; color: var(--ink-2); min-width: 128px; }
.prop-what { font-weight: 600; }
.prop-q { color: var(--ink-2); font-size: 14px; margin: 6px 0 0; }
.prop-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; flex-wrap: wrap; }
.summary p { margin: 0; }
.summary .meta { display: flex; justify-content: space-between; align-items: center; }

/* ---------- day timeline ---------- */
.allday { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip {
  border: 0; cursor: pointer; text-align: left;
  background: var(--event-soft); color: var(--event); border-radius: 8px; padding: 5px 10px; font-weight: 600; font-size: 13px;
}
.timeline { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.hour { position: relative; height: 56px; border-top: 1px solid var(--line-2); }
.hour:first-child { border-top: 0; }
.hour.off { background: color-mix(in srgb, var(--line-2) 45%, transparent); }
.hour label { position: absolute; left: 10px; top: 4px; font: 12px var(--mono); color: var(--ink-3); }
.slot-layer { position: absolute; inset: 0 8px 0 62px; }
.ev {
  position: absolute; left: 0; right: 0; border: 0; cursor: pointer; text-align: left; overflow: hidden;
  background: var(--event-soft); color: var(--event); border-left: 3px solid var(--event);
  border-radius: 7px; padding: 4px 8px; font-size: 13px; line-height: 1.25;
}
.ev b { display: block; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev span { font-family: var(--mono); font-size: 11.5px; opacity: .85; }
.ev.short { display: flex; align-items: center; gap: 8px; padding-top: 0; padding-bottom: 0; }
.ev.short b { flex: 0 1 auto; min-width: 0; }
.ev.short span { flex: none; }
.ev.planned { background: var(--plan-soft); color: var(--plan); border-left-color: var(--plan); }
.ev.draft { background: transparent; border: 1.5px dashed var(--plan); color: var(--plan); }
.ev.past { opacity: .55; }
.now-line { position: absolute; left: 54px; right: 0; height: 2px; background: var(--accent); z-index: 3; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.empty { color: var(--ink-3); padding: 28px 4px; text-align: center; }

/* ---------- week ---------- */
.week { display: grid; gap: 10px; }
@media (min-width: 860px) { .week { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; } }
.wday { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; min-height: 64px; }
.wday h4 { margin: 0 0 6px; font-size: 13px; display: flex; gap: 6px; align-items: baseline; cursor: pointer; }
.wday h4 .n { font-size: 18px; font-weight: 700; }
.wday h4 .d { color: var(--ink-3); font-weight: 600; }
.wday.today h4 .n { color: var(--accent); }
.witem { display: block; width: 100%; border: 0; background: transparent; text-align: left; cursor: pointer; padding: 3px 0; font-size: 13px; color: var(--ink); }
.witem time { font: 12px var(--mono); color: var(--ink-3); margin-right: 6px; }
.witem.planned::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--plan); margin-right: 6px; vertical-align: 1px; }
.wday .none { color: var(--ink-3); font-size: 13px; }

/* ---------- month ---------- */
.month { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.mhead, .mgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.mhead div { font-size: 11px; font-weight: 700; color: var(--ink-3); padding: 8px 6px; text-align: center; }
.mcell {
  border: 0; border-top: 1px solid var(--line-2); border-left: 1px solid var(--line-2); background: transparent;
  min-height: 64px; padding: 5px; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 2px; overflow: hidden;
}
.mcell:nth-child(7n+1) { border-left: 0; }
.mcell .n { font-size: 13px; font-weight: 600; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; }
.mcell.out .n { color: var(--ink-3); }
.mcell.today .n { background: var(--accent); color: var(--accent-ink); }
.mcell .t { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--event); }
.mcell .more { font-size: 11px; color: var(--ink-3); }
.mcell .dots { display: none; }
@media (max-width: 520px) { .mcell .t, .mcell .more { display: none; } .mcell .dots { display: flex; gap: 3px; flex-wrap: wrap; padding-left: 4px; } }
.mcell .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--event); }

/* ---------- tasks / plan ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
.card h3 { margin: 0 0 10px; font-size: 15px; }
.task-add { display: grid; grid-template-columns: 1fr 88px 104px auto; gap: 8px; }
@media (max-width: 560px) { .task-add { grid-template-columns: 1fr 1fr; } .task-add input[name=title] { grid-column: 1 / -1; } }
input:not([type=checkbox]), select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 9px; padding: 8px 10px; min-height: 40px; font-size: 16px;
}
textarea { resize: vertical; }
.task { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line-2); }
.task:first-child { border-top: 0; }
.task input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--plan); flex: none; }
.task .tt { flex: 1; min-width: 0; }
.task .tt b { display: block; font-weight: 600; }
.task.done .tt b { text-decoration: line-through; color: var(--ink-3); }
.task .tm { font: 12px var(--mono); color: var(--ink-3); }
.pri { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--line-2); color: var(--ink-2); }
.pri.high { background: var(--accent-soft); color: var(--accent); }
.plan-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.plan-row input[type=date] { width: auto; }
.plan-list { margin-top: 12px; }
.plan-note { color: var(--ink-2); font-size: 14px; margin: 8px 0 0; }

/* ---------- settings ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
label.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); align-self: end; min-height: 40px; }
label.check input { width: 18px; height: 18px; }
.status-list { display: grid; gap: 6px; font-size: 14px; }
.status-list .ok { color: var(--plan); }
.status-list .no { color: var(--danger); }
.help { color: var(--ink-2); font-size: 14px; }
.help ol { padding-left: 20px; margin: 6px 0; }

/* ---------- editor sheet ---------- */
.sheet {
  border: 0; padding: 0; width: min(520px, 100%); max-width: 100%; max-height: 92vh;
  background: var(--panel); color: var(--ink); border-radius: 16px;
}
.sheet::backdrop { background: rgba(10, 12, 16, .45); }
.sheet form { display: grid; gap: 12px; padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); }
.sheet h2 { margin: 0; font-size: 18px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sheet-actions { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.spacer { flex: 1; }
@media (max-width: 560px) {
  .sheet { margin: auto 0 0; border-radius: 16px 16px 0 0; width: 100%; }
}

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 50;
  bottom: calc(84px + env(safe-area-inset-bottom));
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px;
  max-width: calc(100% - 32px); box-shadow: 0 6px 24px rgba(0,0,0,.18);
}
@media (min-width: 860px) { .toast { bottom: 24px; } }

.loading { color: var(--ink-3); padding: 24px 4px; }
@media (prefers-reduced-motion: no-preference) {
  .proposal, .summary { animation: rise .18s ease-out; }
  @keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
}
