/* Routine Builder — calm command center.
   Palette and the 19px/48px accessibility contract follow the Mission Unstoppable house style. */

:root {
  --cream:#F6F1E8; --cream-2:#EDE8DF; --card:#FFFDF9;
  --forest:#355C4A; --forest-dark:#27442F; --gold:#D4A24C; --sage:#A9B7A0; --clay:#C76D4F;
  --ink:#323232; --ink-soft:#5A5A5A; --line:#DED7CA;
  --ok:#3F7A52; --warn:#A8453F;
  --r:14px; --shadow:0 1px 2px rgba(50,50,50,.06), 0 4px 16px rgba(50,50,50,.05);
  --nav-h:68px;
}

* { box-sizing:border-box; }
html { -webkit-text-size-adjust:100%; }
body {
  margin:0; background:var(--cream); color:var(--ink);
  font-family:'Atkinson Hyperlegible','Segoe UI',system-ui,-apple-system,sans-serif;
  font-size:19px; line-height:1.6;
  padding-bottom:calc(var(--nav-h) + env(safe-area-inset-bottom,0px));
}
h1,h2,h3 { font-family:Nunito,'Atkinson Hyperlegible',system-ui,sans-serif; font-weight:900;
  line-height:1.2; margin:0 0 .4em; color:var(--forest-dark); }
h1 { font-size:1.65rem; } h2 { font-size:1.25rem; } h3 { font-size:1.05rem; }
p { margin:0 0 1em; max-width:65ch; }
a { color:var(--forest); }

.skip { position:absolute; left:-9999px; }
.skip:focus { left:8px; top:8px; z-index:200; background:var(--forest); color:#fff;
  padding:12px 18px; border-radius:8px; }
:focus-visible { outline:3px solid var(--gold); outline-offset:2px; border-radius:6px; }

.wrap { max-width:760px; margin:0 auto; padding:16px 16px 32px; }

/* ---- header ---- */
.topbar { background:var(--cream-2); border-bottom:1px solid var(--line);
  padding:14px 16px calc(14px + env(safe-area-inset-top,0px)); }
.topbar .inner { max-width:760px; margin:0 auto; display:flex; align-items:baseline;
  justify-content:space-between; gap:12px; flex-wrap:wrap; }
.topbar .eyebrow { font-size:.8rem; letter-spacing:.08em; text-transform:uppercase;
  color:var(--forest); font-weight:700; }
.topbar h1 { margin:0; }

/* ---- cards ---- */
.card { background:var(--card); border:1px solid var(--line); border-radius:var(--r);
  padding:18px; box-shadow:var(--shadow); margin-bottom:16px; }
.card.tight { padding:14px; }
.muted { color:var(--ink-soft); }
.small { font-size:.85rem; }

/* ---- buttons ---- */
.btn { display:inline-flex; align-items:center; justify-content:center; gap:8px;
  min-height:48px; padding:12px 20px; border-radius:10px; border:2px solid transparent;
  font:inherit; font-weight:700; cursor:pointer; text-decoration:none; }
.btn-primary { background:var(--forest); color:#fff; }
.btn-primary:hover { background:var(--forest-dark); }
.btn-secondary { background:var(--card); color:var(--forest-dark); border-color:var(--forest); }
.btn-secondary:hover { background:var(--cream-2); }
.btn-ghost { background:transparent; color:var(--forest); border-color:var(--line); }
.btn-danger { background:var(--card); color:var(--warn); border-color:var(--warn); }
.btn-block { width:100%; }
.btn-sm { min-height:40px; padding:8px 14px; font-size:.9rem; }
.btn:disabled { opacity:.5; cursor:not-allowed; }
.btn-row { display:flex; gap:10px; flex-wrap:wrap; }

/* ---- forms ---- */
label { display:block; font-weight:700; margin-bottom:6px; font-size:.95rem; }
input,select,textarea { width:100%; min-height:48px; padding:11px 13px; font:inherit;
  color:var(--ink); background:var(--card); border:2px solid var(--line); border-radius:10px; }
textarea { min-height:96px; resize:vertical; line-height:1.5; }
input:focus,select:focus,textarea:focus { border-color:var(--forest); }
.field { margin-bottom:16px; }
.grid2 { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
@media (max-width:560px) { .grid2 { grid-template-columns:1fr; } }
.hint { font-size:.85rem; color:var(--ink-soft); margin-top:4px; }

/* ---- flash ---- */
.flash { border-radius:10px; padding:12px 16px; margin-bottom:16px; border:2px solid; }
.flash.error { border-color:var(--warn); background:#FBF0EF; color:#7A2F2A; }
.flash.ok { border-color:var(--ok); background:#F0F6F1; color:#24502F; }

/* ---- progress ---- */
.progress { height:14px; border-radius:7px; background:var(--cream-2);
  border:1px solid var(--line); overflow:hidden; }
.progress > i { display:block; height:100%; background:var(--forest); border-radius:7px; }
.statline { display:flex; gap:18px; flex-wrap:wrap; align-items:baseline; margin:10px 0 6px; }
.statline b { font-family:Nunito,sans-serif; font-size:1.5rem; color:var(--forest-dark); }

/* ---- now / next ---- */
.nownext { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.nownext .slot { border:1px solid var(--line); border-radius:12px; padding:14px;
  background:var(--cream-2); border-left:6px solid var(--sage); }
.nownext .slot.now { border-left-color:var(--forest); background:#EFF3EE; }
.nownext .slot .k { font-size:.78rem; letter-spacing:.08em; text-transform:uppercase;
  font-weight:700; color:var(--forest); }
.nownext .slot .t { font-family:Nunito,sans-serif; font-weight:900; font-size:1.05rem;
  color:var(--forest-dark); }

/* ---- timeline ---- */
.tl { list-style:none; margin:0; padding:0; }
.tl > li { display:grid; grid-template-columns:78px 1fr; gap:12px; margin-bottom:12px; }
.tl .time { font-variant-numeric:tabular-nums; font-size:.88rem; color:var(--ink-soft);
  padding-top:14px; line-height:1.35; }
.tl .body { background:var(--card); border:1px solid var(--line); border-left:6px solid var(--cat,#767676);
  border-radius:12px; padding:13px 15px; }
.tl .body.is-now { box-shadow:0 0 0 3px rgba(53,92,74,.18); }
.tl .body h3 { margin:0 0 2px; }
.tl .cat { display:inline-block; font-size:.74rem; letter-spacing:.06em; text-transform:uppercase;
  font-weight:700; color:#fff; background:var(--cat,#767676); border-radius:999px; padding:2px 10px; }

/* ---- tasks ---- */
.tasks { list-style:none; margin:10px 0 0; padding:0; }
.tasks li { display:flex; align-items:flex-start; gap:10px; padding:9px 0;
  border-top:1px solid var(--line); flex-wrap:wrap; }
.tasks li:first-child { border-top:0; }
.tasks input[type=checkbox] { width:28px; height:28px; min-height:28px; margin:2px 0 0;
  accent-color:var(--forest); flex:0 0 auto; cursor:pointer; }
.tasks .t-title { flex:1 1 55%; min-width:0; overflow-wrap:anywhere; }
.tasks li.done .t-title { color:var(--ink-soft); text-decoration:line-through; }
.pill { font-size:.72rem; font-weight:700; border-radius:999px; padding:2px 9px;
  border:1px solid var(--line); color:var(--ink-soft); white-space:nowrap; }
.pill.p-High { color:#8A5A12; border-color:var(--gold); background:#FBF4E6; }
.pill.p-Urgent { color:#7A2F2A; border-color:var(--warn); background:#FBF0EF; }

/* ---- bottom nav ---- */
.nav { position:fixed; left:0; right:0; bottom:0; z-index:50; display:flex;
  background:var(--card); border-top:1px solid var(--line);
  padding-bottom:env(safe-area-inset-bottom,0px); }
.nav a { flex:1; min-height:var(--nav-h); display:flex; flex-direction:column;
  align-items:center; justify-content:center; gap:3px; text-decoration:none;
  color:var(--ink-soft); font-size:.72rem; font-weight:700; padding:6px 2px; }
.nav a svg { width:24px; height:24px; stroke:currentColor; fill:none; stroke-width:2;
  stroke-linecap:round; stroke-linejoin:round; }
.nav a[aria-current=page] { color:var(--forest); background:var(--cream-2); }

/* ---- chat ---- */
.chat-log { display:flex; flex-direction:column; gap:14px; margin-bottom:16px; }
.msg { max-width:88%; padding:13px 16px; border-radius:16px; white-space:pre-wrap;
  overflow-wrap:anywhere; }
.msg.user { align-self:flex-end; background:var(--forest); color:#fff; border-bottom-right-radius:5px; }
.msg.bot { align-self:flex-start; background:var(--card); border:1px solid var(--line);
  border-bottom-left-radius:5px; }
.msg.sys { align-self:center; background:transparent; color:var(--ink-soft);
  font-size:.85rem; text-align:center; max-width:100%; }
.composer { display:flex; gap:10px; align-items:flex-end;
  position:sticky; bottom:calc(var(--nav-h) + env(safe-area-inset-bottom,0px));
  background:var(--cream); padding:10px 0; }
.composer textarea { min-height:52px; max-height:160px; }
.dots i { display:inline-block; width:7px; height:7px; margin-right:4px; border-radius:50%;
  background:var(--sage); animation:b 1.2s infinite; }
.dots i:nth-child(2){animation-delay:.2s} .dots i:nth-child(3){animation-delay:.4s}
@keyframes b { 0%,60%,100%{opacity:.3} 30%{opacity:1} }

/* ---- builder ---- */
.blk { border:1px solid var(--line); border-left:6px solid var(--cat,#767676);
  border-radius:12px; background:var(--card); padding:14px; margin-bottom:12px; }
.blk .head { display:flex; gap:10px; align-items:center; margin-bottom:10px; flex-wrap:wrap; }
.blk .head .times { display:flex; gap:6px; align-items:center; }
.blk .head input[type=time] { min-width:118px; }
.blk .tools { display:flex; gap:6px; margin-left:auto; }
.iconbtn { min-height:44px; min-width:44px; display:inline-flex; align-items:center;
  justify-content:center; border:1px solid var(--line); background:var(--card);
  border-radius:9px; cursor:pointer; font-size:.8rem; font-weight:700; color:var(--forest);
  padding:0 10px; }
.iconbtn:hover { background:var(--cream-2); }
.iconbtn.danger { color:var(--warn); }
.overlap { border:2px solid var(--warn); background:#FBF0EF; border-radius:10px;
  padding:10px 14px; margin-bottom:12px; color:#7A2F2A; font-size:.9rem; }

/* ---- misc ---- */
.empty { text-align:center; padding:28px 16px; }
.empty .big { font-size:2.4rem; line-height:1; margin-bottom:10px; }
.list-row { display:flex; gap:12px; align-items:center; padding:14px 0;
  border-top:1px solid var(--line); flex-wrap:wrap; }
.list-row:first-child { border-top:0; }
.list-row .grow { flex:1; min-width:180px; }
details.acc > summary { cursor:pointer; font-weight:700; color:var(--forest-dark);
  padding:12px 0; min-height:48px; display:flex; align-items:center; }
hr.sep { border:0; border-top:1px solid var(--line); margin:22px 0; }

@media (min-width:860px) {
  body { padding-bottom:0; }
  .wrap { max-width:960px; padding-top:24px; }
  .nav { position:static; border-top:0; border-bottom:1px solid var(--line);
    max-width:960px; margin:0 auto; background:transparent; }
  .nav a { flex-direction:row; gap:8px; font-size:.9rem; min-height:56px; border-radius:10px; }
  .composer { bottom:0; }
  .dash { display:grid; grid-template-columns:1fr 320px; gap:20px; align-items:start; }
  .dash .side { position:sticky; top:20px; }
}

@media (prefers-reduced-motion:reduce) {
  *,*::before,*::after { animation-duration:.001ms !important; animation-iteration-count:1 !important;
    transition-duration:.001ms !important; scroll-behavior:auto !important; }
}
