/* Hedges Home
   Palette pulled from the house itself: greige brick, cream trim, timber
   posts, sage shrubs. Warm on purpose — this should feel like somewhere
   you want to go, not a task manager.
*/

:root {
  --bg:            #faf7f2;
  --bg-sunk:       #f2ece3;
  --card:          #ffffff;
  --ink:           #33302c;
  --ink-soft:      #6d665d;
  --ink-faint:     #9b9287;
  --line:          #e7e0d5;
  --line-soft:     #f0ebe3;

  --accent:        #b0623a;   /* timber / terracotta */
  --accent-deep:   #8f4c2b;
  --accent-wash:   #fbeee6;
  --sage:          #7f9a5c;
  --sage-wash:     #eef3e6;
  --gold:          #d99f3c;
  --gold-wash:     #fdf3e0;
  --sky:           #6d9dbd;
  --sky-wash:      #eaf2f7;

  /* house illustration */
  --sky-top:       #cadff0;
  --sky-bottom:    #eef5fa;
  --brick:         #cec3b5;
  --mortar:        #bdb1a0;
  --roof:          #8a7e74;
  --roof-dark:     #71675e;
  --trim:          #f0e8dc;
  --timber:        #9a6238;
  --timber-light:  #b87c4c;
  --shutter:       #6b4a32;
  --shutter-dark:  #4e3524;
  --door:          #a89478;
  --door-dark:     #8a7860;
  --garage:        #cdbfa7;
  --garage-line:   #a8987e;
  --lawn:          #a6be7c;
  --lawn-dark:     #8fa768;
  --drive:         #d8d4cc;
  --drive-dark:    #c2bdb3;
  --foliage:       #7fa05e;
  --foliage-dark:  #648347;
  --bloom:         #c9b558;
  --trunk:         #8a6a4a;
  --fence:         #c0a37c;
  --fence-line:    #9a7f5c;
  --brick-step:    #c4b6a4;
  --brick-step-dark: #ab9d8b;
  --lamp:          #ffcf7a;
  --porch-shade:   #b6aa9a;
  --win-fill:      #aab9c4;

  --radius:        18px;
  --radius-sm:     12px;
  --shadow:        0 1px 2px rgba(60,50,38,.05), 0 6px 20px rgba(60,50,38,.06);
  --shadow-lift:   0 2px 6px rgba(60,50,38,.08), 0 14px 34px rgba(60,50,38,.10);

  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:          #1c1a18;
    --bg-sunk:     #151312;
    --card:        #262320;
    --ink:         #f0eae1;
    --ink-soft:    #b3a99c;
    --ink-faint:   #837a6e;
    --line:        #3a3530;
    --line-soft:   #322e2a;
    --accent:      #d3835a;
    --accent-deep: #e09a72;
    --accent-wash: #38271f;
    --sage:        #9cb877;
    --sage-wash:   #262d1f;
    --gold:        #e6b662;
    --gold-wash:   #352b19;
    --sky:         #8ab6d3;
    --sky-wash:    #1f2a32;
    --sky-top:     #2b3a47;
    --sky-bottom:  #22292f;
    --shadow:      0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.28);
    --shadow-lift: 0 2px 6px rgba(0,0,0,.35), 0 14px 34px rgba(0,0,0,.4);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.32rem; }
h3 { font-size: 1.06rem; }
p  { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ============================================================== layout */
.app { max-width: 900px; margin: 0 auto; padding: 0 16px 130px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 22px 0 14px;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand h1 { font-size: 1.55rem; }
.brand .sub { color: var(--ink-faint); font-size: .82rem; }

.sync-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .74rem; color: var(--ink-soft);
  background: var(--bg-sunk); border: 1px solid var(--line);
  padding: 5px 11px; border-radius: 999px; cursor: pointer;
  white-space: nowrap;
}
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-faint); }
.sync-pill[data-status="ok"]      .sync-dot { background: var(--sage); }
.sync-pill[data-status="pending"] .sync-dot { background: var(--gold); animation: pulse 1.2s infinite; }
.sync-pill[data-status="error"]   .sync-dot { background: #c9553f; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

/* ================================================================ nav */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; justify-content: center; gap: 2px;
  background: var(--card);
  background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--line);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
}
.nav button {
  flex: 1 1 0; max-width: 130px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: 0; cursor: pointer;
  padding: 7px 4px; border-radius: 12px;
  color: var(--ink-faint); font-size: .68rem; font-weight: 600;
  letter-spacing: .02em; transition: color .15s, background .15s;
}
.nav button .ico { font-size: 1.22rem; line-height: 1; }
.nav button.active { color: var(--accent); background: var(--accent-wash); }
.nav button:hover:not(.active) { color: var(--ink-soft); }

/* ============================================================== cards */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 14px;
}
.card.flush { padding: 0; overflow: hidden; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.card-head .hint { color: var(--ink-faint); font-size: .78rem; }

.section-label {
  font-size: .7rem; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--ink-faint);
  margin: 26px 0 10px;
}

/* ============================================================ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--accent); color: #fff; border: 0;
  padding: 11px 17px; border-radius: 12px; cursor: pointer;
  font-size: .88rem; font-weight: 600; min-height: 44px;
  transition: transform .1s, background .15s;
}
.btn:hover { background: var(--accent-deep); }
.btn:active { transform: scale(.97); }
.btn.ghost {
  background: var(--bg-sunk); color: var(--ink-soft);
  border: 1px solid var(--line);
}
.btn.ghost:hover { background: var(--line-soft); color: var(--ink); }
.btn.sm { padding: 7px 13px; min-height: 36px; font-size: .8rem; border-radius: 10px; }
.btn.wide { width: 100%; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--bg-sunk); border: 1px solid var(--line);
  color: var(--ink-soft); border-radius: 999px;
  padding: 6px 13px; font-size: .78rem; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  transition: background .14s, color .14s, border-color .14s;
}
.chip:hover { border-color: var(--ink-faint); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip-row { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 3px; -webkit-overflow-scrolling: touch; }
.chip-row::-webkit-scrollbar { display: none; }

/* ============================================================== house */
.house-wrap {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); margin-bottom: 14px;
}
.house-svg { display: block; width: 100%; height: auto; }
.is-hotspot { cursor: pointer; outline: none; }
.is-hotspot ellipse, .is-hotspot rect, .is-hotspot polygon, .is-hotspot circle {
  transition: filter .18s, transform .18s;
}
.is-hotspot:hover, .is-hotspot:focus-visible { filter: brightness(1.09); }
.is-hotspot:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 8px; }
.svg-tag {
  font-family: var(--sans); font-size: 15px; font-weight: 700;
  fill: #fff; paint-order: stroke; stroke: rgba(51,48,44,.42);
  stroke-width: 4px; stroke-linejoin: round; opacity: 0;
  transition: opacity .18s; pointer-events: none;
}
.is-hotspot:hover .svg-tag, .is-hotspot:focus-visible .svg-tag { opacity: 1; }

.house-caption {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 13px 17px; border-top: 1px solid var(--line);
  background: var(--card);
}
.house-caption .big { font-family: var(--serif); font-size: 1.16rem; }
.house-caption .sub { color: var(--ink-faint); font-size: .78rem; }

/* =========================================================== progress */
.bar { height: 8px; background: var(--bg-sunk); border-radius: 99px; overflow: hidden; }
.bar > span {
  display: block; height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--gold), var(--accent));
  transition: width .5s cubic-bezier(.22,.9,.3,1);
}
.bar.sage > span { background: linear-gradient(90deg, #a8c47e, var(--sage)); }

.ring { transform: rotate(-90deg); }
.ring circle { fill: none; stroke-linecap: round; }
.ring .track { stroke: var(--bg-sunk); }
.ring .fill { stroke: var(--accent); transition: stroke-dashoffset .6s cubic-bezier(.22,.9,.3,1); }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 14px 12px; text-align: center;
}
.stat .n { font-family: var(--serif); font-size: 1.7rem; line-height: 1.1; }
.stat .l { font-size: .68rem; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .06em; margin-top: 3px; }
.stat.gold .n { color: var(--gold); }
.stat.sage .n { color: var(--sage); }
.stat.accent .n { color: var(--accent); }

/* ============================================================== tasks */
.task {
  display: flex; align-items: flex-start; gap: 13px;
  padding: 13px 4px; border-bottom: 1px solid var(--line-soft);
  cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
}
.task:last-child { border-bottom: 0; }
.task:active { background: var(--line-soft); }

.box {
  flex: none; width: 25px; height: 25px; margin-top: 1px;
  border: 2px solid var(--line); border-radius: 8px;
  background: var(--card); position: relative;
  transition: background .18s, border-color .18s, transform .12s;
}
.box svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.box svg path {
  stroke: #fff; stroke-width: 2.6; fill: none;
  stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 22; stroke-dashoffset: 22;
  transition: stroke-dashoffset .28s cubic-bezier(.6,0,.3,1.4);
}
.task.done .box { background: var(--sage); border-color: var(--sage); }
.task.done .box svg path { stroke-dashoffset: 0; }
.task:active .box { transform: scale(.88); }

.task .txt { flex: 1; min-width: 0; font-size: .95rem; transition: color .22s; }
.task.done .txt { color: var(--ink-faint); text-decoration: line-through; text-decoration-thickness: 1.5px; }
.task .del {
  flex: none; background: none; border: 0; cursor: pointer;
  color: var(--ink-faint); opacity: 0; padding: 2px 5px;
  font-size: 1.05rem; line-height: 1; transition: opacity .15s, color .15s;
}
.task:hover .del { opacity: .6; }
.task .del:hover { color: #c9553f; opacity: 1; }
@media (hover: none) { .task .del { opacity: .45; } }

/* =========================================================== add row */
.add-row { display: flex; gap: 9px; margin-top: 12px; }
.add-row input, .field {
  flex: 1; min-width: 0; background: var(--bg-sunk);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; min-height: 44px; outline: none;
  transition: border-color .15s, background .15s;
}
.add-row input:focus, .field:focus {
  border-color: var(--accent); background: var(--card);
}
.field { width: 100%; display: block; }
label.lab { display: block; font-size: .78rem; font-weight: 600; color: var(--ink-soft); margin: 12px 0 5px; }

/* ============================================================= rooms */
.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 11px; }
.room-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 15px; cursor: pointer;
  text-align: left; box-shadow: var(--shadow);
  transition: transform .16s, box-shadow .16s, border-color .16s;
  display: flex; flex-direction: column; gap: 9px;
}
.room-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); border-color: var(--ink-faint); }
.room-card:active { transform: translateY(0) scale(.99); }
.room-card .ico { font-size: 1.5rem; line-height: 1; }
.room-card .nm { font-family: var(--serif); font-size: 1rem; }
.room-card .ct { font-size: .74rem; color: var(--ink-faint); }
.room-card.complete { border-color: var(--sage); background: var(--sage-wash); }

.room-hero {
  display: flex; align-items: center; gap: 15px; margin-bottom: 4px;
}
.room-hero .ico { font-size: 2.3rem; }
.room-hero .blurb { color: var(--ink-soft); font-size: .85rem; }

.proj-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin: 20px 0 2px;
}
.proj-head h3 { font-size: .98rem; }
.proj-head .n { font-size: .74rem; color: var(--ink-faint); }

/* =========================================================== grocery */
.aisle-head {
  display: flex; align-items: center; gap: 8px;
  font-size: .72rem; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-faint);
  margin: 18px 0 2px; padding-top: 12px; border-top: 1px solid var(--line-soft);
}
.aisle-head:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.task .qty { color: var(--ink-faint); font-size: .82rem; margin-left: 6px; }
.task .src { display: block; color: var(--ink-faint); font-size: .72rem; margin-top: 2px; }

.list-toggle { display: flex; gap: 6px; background: var(--bg-sunk); padding: 4px; border-radius: 13px; margin-bottom: 14px; }
.list-toggle button {
  flex: 1; background: none; border: 0; cursor: pointer;
  padding: 10px 8px; border-radius: 10px; min-height: 42px;
  font-size: .85rem; font-weight: 600; color: var(--ink-soft);
  transition: background .16s, color .16s, box-shadow .16s;
}
.list-toggle button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

/* ============================================================= meals */
.meal-card {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); padding: 16px; margin-bottom: 11px;
  box-shadow: var(--shadow);
}
.meal-card .nm { font-family: var(--serif); font-size: 1.1rem; margin-bottom: 4px; }
.meal-card .blurb { color: var(--ink-soft); font-size: .86rem; margin-bottom: 11px; }
.meal-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tag {
  font-size: .7rem; font-weight: 600; padding: 4px 9px; border-radius: 999px;
  background: var(--bg-sunk); color: var(--ink-soft);
}
.tag.time { background: var(--gold-wash); color: #8a6415; }
.tag.kid  { background: var(--sage-wash); color: #4d6630; }
.tag.new  { background: var(--sky-wash); color: #3d6a89; }
.meal-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.meal-detail { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.meal-detail h4 { font-size: .72rem; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 7px; }
.meal-detail ul, .meal-detail ol { margin: 0 0 14px; padding-left: 19px; }
.meal-detail li { font-size: .88rem; margin-bottom: 5px; color: var(--ink-soft); }
.meal-detail .note {
  background: var(--gold-wash); border-radius: var(--radius-sm);
  padding: 11px 13px; font-size: .84rem; color: #7a5a15;
}

.day-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 4px; border-bottom: 1px solid var(--line-soft);
}
.day-row:last-child { border-bottom: 0; }
.day-badge {
  flex: none; width: 46px; text-align: center;
  font-size: .68rem; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--ink-faint);
}
.day-row.today .day-badge { color: var(--accent); }
.day-row.today { background: var(--accent-wash); border-radius: 10px; }
.day-pick { flex: 1; min-width: 0; }
.day-pick .set { font-size: .92rem; }
.day-pick .empty { font-size: .88rem; color: var(--ink-faint); font-style: italic; }

.discover {
  background: var(--sky-wash); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
}
.discover .k { font-size: .68rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--sky); margin-bottom: 6px; }
.discover .t { font-family: var(--serif); font-size: 1.04rem; margin-bottom: 4px; }
.discover .d { font-size: .86rem; color: var(--ink-soft); }

/* ============================================================= goals */
.goal { padding: 14px 0; border-bottom: 1px solid var(--line-soft); }
.goal:last-child { border-bottom: 0; }
.goal-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 9px; }
.goal-top .t { font-size: .95rem; font-weight: 600; }
.goal-top .n { font-size: .8rem; color: var(--ink-faint); white-space: nowrap; }
.goal-ctl { display: flex; gap: 7px; margin-top: 9px; }
.goal-ctl button {
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer;
  background: var(--bg-sunk); border: 1px solid var(--line);
  font-size: 1.05rem; color: var(--ink-soft);
}
.goal-ctl button:hover { background: var(--line-soft); color: var(--ink); }

/* ============================================================ misc */
.empty-state { text-align: center; padding: 34px 20px; color: var(--ink-faint); }
.empty-state .ico { font-size: 2.1rem; margin-bottom: 9px; }
.empty-state p { font-size: .89rem; }

.encourage {
  font-family: var(--serif); font-size: 1.02rem; font-style: italic;
  color: var(--ink-soft); text-align: center; padding: 6px 12px 16px;
}

.toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%) translateY(14px);
  background: var(--ink); color: var(--bg); padding: 11px 19px;
  border-radius: 999px; font-size: .85rem; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .22s, transform .22s;
  z-index: 100; box-shadow: var(--shadow-lift); max-width: 88vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.sheet-back {
  position: fixed; inset: 0; background: rgba(30,26,22,.42);
  z-index: 90; opacity: 0; pointer-events: none; transition: opacity .22s;
  backdrop-filter: blur(2px);
}
.sheet-back.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%) translateY(100%);
  width: min(560px, 100%); max-height: 88vh; overflow-y: auto; z-index: 91;
  background: var(--card); border-radius: 22px 22px 0 0;
  padding: 22px 20px calc(28px + env(safe-area-inset-bottom));
  transition: transform .3s cubic-bezier(.22,.9,.3,1);
  box-shadow: var(--shadow-lift);
}
.sheet.open { transform: translateX(-50%) translateY(0); }
.sheet h2 { margin-bottom: 6px; }
.sheet .muted { color: var(--ink-soft); font-size: .87rem; margin-bottom: 16px; }
.sheet-grip { width: 38px; height: 4px; background: var(--line); border-radius: 99px; margin: -8px auto 16px; }

.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 0; cursor: pointer; padding: 8px 0;
  color: var(--ink-soft); font-size: .85rem; font-weight: 600;
}
.back-link:hover { color: var(--accent); }

.view { animation: fade .3s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.split { display: flex; gap: 9px; flex-wrap: wrap; }
.muted-note { font-size: .8rem; color: var(--ink-faint); margin-top: 10px; line-height: 1.5; }
code {
  background: var(--bg-sunk); padding: 2px 6px; border-radius: 5px;
  font-size: .84em; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
pre {
  background: var(--bg-sunk); padding: 13px; border-radius: var(--radius-sm);
  overflow-x: auto; font-size: .76rem; line-height: 1.45;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  border: 1px solid var(--line); margin: 8px 0;
}

@media (max-width: 460px) {
  .topbar { padding: 16px 0 10px; }
  .brand h1 { font-size: 1.36rem; }
  .brand .sub { display: none; }
  .stat .n { font-size: 1.45rem; }
  .stat .l { font-size: .62rem; }
}

@media (min-width: 720px) {
  .app { padding-bottom: 40px; }
  .nav {
    position: sticky; top: 0; bottom: auto; margin-bottom: 18px;
    border-top: 0; border-bottom: 1px solid var(--line);
    border-radius: 0 0 var(--radius) var(--radius); padding: 8px;
  }
  .nav button { flex-direction: row; gap: 7px; font-size: .82rem; padding: 9px 14px; }
  .nav button .ico { font-size: 1rem; }
  .toast { bottom: 30px; }
}

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