:root {
  --paper:      #FAF8F5;   /* warm off-white — easier on the eyes at night than pure white */
  --surface:    #FFFFFF;
  --line:       #E9E4DC;
  --line-soft:  #F2EEE8;
  --ink:        #1E1C19;
  --ink-2:      #6E675F;
  --ink-3:      #A49C92;
  --now:        #E0453F;
  --accent:     #2F6BE0;
  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --body: 'Inter', system-ui, sans-serif;
}

* { margin: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }

/* ───────── app shell ───────── */
#app { display: grid; grid-template-columns: 78px 1fr; height: 100%; }

.rail {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center;
  padding: 14px 0; gap: 6px;
}
.rail button {
  width: 58px; height: 58px; border-radius: 17px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--ink-3);
}
.rail button svg { width: 22px; height: 22px; }
.rail button span { font-size: 9.5px; font-weight: 600; letter-spacing: .02em; }
.rail button.on { background: #EEF3FD; color: var(--accent); }
.rail .spacer { flex: 1; }

.pane { display: flex; flex-direction: column; min-width: 0; height: 100%; }

/* ───────── header ───────── */
.head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 20px; padding: 16px 22px 12px;
}
.fam { font-family: var(--display); font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.head-meta { display: flex; align-items: baseline; gap: 16px; color: var(--ink-2); font-size: 17px; }
.head-meta .clock { font-family: var(--display); font-size: 26px; font-weight: 700; color: var(--ink); }
.head-meta .wx { font-weight: 600; }
.head-meta .wx i { font-style: normal; margin-right: 5px; }

/* ───────── toolbar ───────── */
.bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 0 22px 12px; border-bottom: 1px solid var(--line);
}
.who { display: flex; gap: 7px; flex-wrap: wrap; min-width: 0; }
.who button {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 13px 6px 7px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  font-size: 14.5px; font-weight: 600; color: var(--ink-2);
}
.who button .dot {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  background: var(--c); color: #fff;
  font-size: 10px; font-weight: 700; letter-spacing: .01em;
  display: flex; align-items: center; justify-content: center;
}
.who button.on { color: var(--ink); border-color: var(--c); background: color-mix(in srgb, var(--c) 11%, #fff); }
.who button.all { padding-left: 13px; }

.nav { display: flex; align-items: center; gap: 6px; flex: none; }
.seg { display: flex; background: #F0ECE5; border-radius: 11px; padding: 3px; }
.seg button { padding: 6px 15px; border-radius: 8px; font-size: 14.5px; font-weight: 600; color: var(--ink-2); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.09); }
.nav .step {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; color: var(--ink-2);
}
.nav .today-btn { padding: 8px 15px; border-radius: 10px; border: 1px solid var(--line); font-size: 14.5px; font-weight: 600; }

/* ───────── view frame ───────── */
.view { flex: 1; min-height: 0; display: flex; }
.view[hidden] { display: none; }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ───────── calendar grid ───────── */
.days, .allday, .slots { display: grid; }
.days {
  border-bottom: 1px solid var(--line);
  padding-right: 4px;
}
.days .gutter-head { border-right: 1px solid var(--line-soft); }
.dayhead { padding: 9px 10px; text-align: left; border-right: 1px solid var(--line-soft); }
.dayhead:last-child { border-right: none; }
.dayhead .dow { font-size: 12.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--ink-3); }
.dayhead .dnum { font-family: var(--display); font-size: 27px; font-weight: 700; line-height: 1.05; }
.dayhead.is-today .dow { color: var(--now); }
.dayhead.is-today .dnum {
  color: #fff; background: var(--now); border-radius: 11px;
  display: inline-block; padding: 0 10px;
}
.dayhead.is-weekend, .daycol.is-weekend { background: #F6F2EB; }
.dayhead.is-focus, .daycol.is-focus { background: #F4F7FD; }
.dayhead.is-focus.is-weekend, .daycol.is-focus.is-weekend { background: #F1F4FA; }

.allday { border-bottom: 1px solid var(--line); min-height: 34px; padding-right: 4px; }
.allday .gutter {
  border-right: 1px solid var(--line-soft); font-size: 10.5px; font-weight: 700;
  color: var(--ink-3); text-transform: uppercase; letter-spacing: .07em;
  display: flex; align-items: center; justify-content: flex-end; padding-right: 8px;
}
.allday .cell { border-right: 1px solid var(--line-soft); padding: 4px 5px; display: flex; flex-direction: column; gap: 3px; }
.allday .cell:last-child { border-right: none; }

.pill {
  border-radius: 7px; padding: 4px 8px; font-size: 14px; font-weight: 600;
  background: color-mix(in srgb, var(--c) 15%, #fff);
  color: color-mix(in srgb, var(--c) 72%, #000);
  border-left: 3px solid var(--c);
  /* block, not flex: text-overflow only clips an inline text run */
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  cursor: pointer;
}
.pill.done { opacity: .45; text-decoration: line-through; }

.grid-wrap { flex: 1; min-height: 0; position: relative; overflow: hidden; padding-right: 4px; }
.slots { position: absolute; inset: 0; }
.hour-gutter { border-right: 1px solid var(--line-soft); position: relative; }
.hour-gutter .hr {
  position: absolute; right: 8px; transform: translateY(-50%);
  font-size: 12px; font-weight: 600; color: var(--ink-3); white-space: nowrap;
}
.daycol { border-right: 1px solid var(--line-soft); position: relative; }
.daycol:last-child { border-right: none; }
.hline { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line-soft); }

.block {
  position: absolute; left: 3px; right: 3px;
  border-radius: 9px; padding: 5px 8px; overflow: hidden;
  background: color-mix(in srgb, var(--c) 16%, #fff);
  border-left: 3px solid var(--c);
  cursor: pointer;
}
.block .t {
  font-size: 14.5px; font-weight: 700; line-height: 1.2;
  color: color-mix(in srgb, var(--c) 74%, #000);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.block.no-sub .t { -webkit-line-clamp: 1; }
.block .s {
  font-size: 12.5px; font-weight: 500; margin-top: 1px;
  color: color-mix(in srgb, var(--c) 58%, #000);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.block.tiny { padding: 2px 8px; }
.block.tiny .t { font-size: 13px; -webkit-line-clamp: 1; white-space: nowrap; text-overflow: ellipsis; }
.block.done { opacity: .45; }
.block.done .t { text-decoration: line-through; }

.nowline { position: absolute; left: 0; right: 0; height: 0; border-top: 2px solid var(--now); z-index: 3; pointer-events: none; }
.nowline::before {
  content: ''; position: absolute; left: -5px; top: -5px;
  width: 9px; height: 9px; border-radius: 50%; background: var(--now);
}

/* ───────── right rail ───────── */
.side {
  width: 274px; flex: none; border-left: 1px solid var(--line);
  padding: 14px 16px; overflow: hidden;
  display: flex; flex-direction: column; gap: 16px;
}
.side h3 {
  font-size: 11px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 9px;
}
.pay {
  display: flex; align-items: center; gap: 9px; padding: 7px 0;
  border-bottom: 1px solid var(--line-soft); cursor: pointer;
}
.pay:last-child { border-bottom: none; }
.pay .txt { flex: 1; min-width: 0; }
.pay .n { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pay .d { font-size: 12.5px; color: var(--ink-3); }
.pay .amt { font-family: var(--display); font-size: 17px; font-weight: 700; }
.pay .tag { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: #F0ECE5; color: var(--ink-2); }
.pay .tag.soon { background: #FDF0DC; color: #9A6612; }
.pay .tag.due { background: #FBE4E3; color: #A5322D; }
.pay .tag.paid { background: #E4F3E9; color: #2C6B43; }
.pay.is-paid { opacity: .45; }

.cd { display: flex; align-items: baseline; gap: 11px; padding: 7px 0; border-bottom: 1px solid var(--line-soft); }
.cd:last-child { border-bottom: none; }
.cd .num { font-family: var(--display); font-size: 30px; font-weight: 800; line-height: 1; color: var(--c); min-width: 46px; }
.cd .num small { font-family: var(--body); font-size: 11px; font-weight: 600; color: var(--ink-3); display: block; }
.cd .n { font-size: 15px; font-weight: 600; }
.cd .d { font-size: 12.5px; color: var(--ink-3); }

.empty { color: var(--ink-3); font-size: 14.5px; padding: 6px 0; }

/* ───────── chores ───────── */
.chore-wrap { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 22px; }
.chore-cols { display: grid; gap: 14px; align-items: start; }
.chore-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 14px; }
.chore-card .who-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.chore-card .av {
  width: 40px; height: 40px; border-radius: 50%; background: var(--c); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px;
}
.chore-card .nm { font-size: 18px; font-weight: 700; flex: 1; }
.chore-card .stars { font-size: 15px; font-weight: 700; color: #B8860B; white-space: nowrap; }
.task {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  padding: 11px 10px; border-radius: 13px; background: #FBF9F6; margin-bottom: 7px;
}
.task .box {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  border: 2px solid var(--c); display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 15px; font-weight: 700;
}
.task.done .box { background: var(--c); }
.task .lbl { flex: 1; font-size: 16px; font-weight: 600; }
.task.done .lbl { text-decoration: line-through; color: var(--ink-3); }
.task .pts { font-size: 13px; font-weight: 700; color: #B8860B; }

/* ───────── meals ───────── */
.meal-wrap { flex: 1; min-height: 0; overflow: auto; padding: 18px 22px; }
.meal-grid { display: grid; gap: 8px; min-width: 100%; }
.meal-grid .rowlab {
  font-size: 11.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-3); display: flex; align-items: center;
}
.meal-grid .dh { text-align: center; padding-bottom: 4px; }
.meal-grid .dh .dow { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.meal-grid .dh .dnum { font-family: var(--display); font-size: 21px; font-weight: 700; }
.meal-grid .dh.is-today .dnum { color: var(--now); }
.meal {
  background: var(--surface); border: 1px solid var(--line); border-radius: 13px;
  padding: 10px; min-height: 62px; font-size: 15px; font-weight: 600; line-height: 1.35;
}
.meal:empty::after { content: '—'; color: var(--ink-3); font-weight: 500; }

/* ───────── lists ───────── */
.list-wrap { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 22px; }
.list-cols { display: grid; gap: 14px; align-items: start; }
.list-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 15px 16px; }
.list-card h4 { font-family: var(--display); font-size: 20px; font-weight: 700; margin-bottom: 10px; }
.li { display: flex; align-items: center; gap: 11px; width: 100%; text-align: left; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.li:last-child { border-bottom: none; }
.li .box { width: 23px; height: 23px; border-radius: 7px; border: 2px solid var(--ink-3); flex: none; display: flex; align-items: center; justify-content: center; font-size: 14px; color: #fff; }
.li.done .box { background: #4FB58C; border-color: #4FB58C; }
.li .lbl { flex: 1; font-size: 16px; font-weight: 500; }
.li.done .lbl { text-decoration: line-through; color: var(--ink-3); }

/* ───────── notes strip ───────── */
.notes-strip { border-top: 1px solid var(--line); padding: 9px 22px; display: flex; gap: 22px; align-items: baseline; overflow: hidden; }
.notes-strip .nlab { font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); flex: none; }
.notes-strip .nitem { font-size: 15px; white-space: nowrap; }
.notes-strip .nitem b { font-weight: 700; }

/* ───────── photos ───────── */
.photo-wrap { flex: 1; min-height: 0; position: relative; background: #14110F; overflow: hidden; }
.photo-wrap img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; transition: opacity 1s; }
.photo-wrap img.on { opacity: 1; }
.photo-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: #8A8078; font-size: 17px; line-height: 1.8; padding: 40px; }
.photo-empty b { color: #B5ABA1; }
.photo-clock { position: absolute; left: 30px; bottom: 26px; color: #fff; text-shadow: 0 2px 14px rgba(0,0,0,.65); }
.photo-clock .t { font-family: var(--display); font-size: 52px; font-weight: 800; line-height: 1; }
.photo-clock .d { font-size: 16px; font-weight: 600; opacity: .88; margin-top: 5px; }

/* ───────── sleep ───────── */
#sleep {
  position: fixed; inset: 0; z-index: 40; background: #06070A; color: #3A4152;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
}
#sleep .t { font-family: var(--display); font-size: 88px; font-weight: 800; line-height: 1; }
#sleep .d { font-size: 17px; font-weight: 500; }
#sleep .hint { position: absolute; bottom: 26px; font-size: 12.5px; color: #262B36; }

/* ───────── PIN ───────── */
#pin-screen {
  position: fixed; inset: 0; background: var(--paper); z-index: 50;
  display: flex; align-items: center; justify-content: center;
}
.pin-box { text-align: center; }
.pin-title { font-family: var(--display); font-size: 34px; font-weight: 800; }
.pin-sub { color: var(--ink-2); margin: 8px 0 18px; }
.pin-dots { font-size: 26px; letter-spacing: 8px; min-height: 40px; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 84px); gap: 12px; justify-content: center; }
.pin-pad button {
  height: 74px; font-size: 28px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
}
.pin-pad button:active { background: #F0ECE5; }
.pin-err { color: var(--now); margin-top: 14px; min-height: 22px; font-weight: 600; }

.stamp { position: fixed; right: 10px; bottom: 6px; font-size: 10.5px; color: var(--ink-3); }

@media (max-width: 1099px) { .side { display: none; } }
@media (prefers-reduced-motion: reduce) { .photo-wrap img { transition: none; } }
