/* Holly's Planner: all the styling.
   Colors are set once here as variables; dark mode swaps them below.
   Layout is phone-first; the @media sections at the bottom adjust it for
   iPad and laptop widths. */

:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #efece5;
  --text: #22252a;
  --muted: #6b6f76;
  --line: #e2ddd3;
  --accent: #2f6f6a;
  --accent-text: #ffffff;
  --accent-soft: #dcebe8;
  --danger: #b3261e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 2px 8px rgba(0, 0, 0, 0.04);

  /* Event colors */
  --c-blue: #3b6fd4;
  --c-green: #2e8b57;
  --c-orange: #d9822b;
  --c-red: #cc4b4b;
  --c-purple: #8559c7;
  --c-gray: #7d8590;

  --tabbar-h: 64px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1d21;
    --surface: #24272c;
    --surface-2: #2d3036;
    --text: #e9e7e3;
    --muted: #a0a3a9;
    --line: #363a41;
    --accent: #6cbfb6;
    --accent-text: #10201e;
    --accent-soft: #24403d;
    --danger: #f08a80;
    --shadow: none;
    --c-blue: #6f9bf0;
    --c-green: #5cc08a;
    --c-orange: #f0a35e;
    --c-red: #ee7d7d;
    --c-purple: #b18ef0;
    --c-gray: #9aa3ad;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 0.95rem; color: var(--muted); font-weight: 600; }
p { margin: 0.4rem 0; }
[hidden] { display: none !important; }

/* Inputs are at least 16px so iPhone doesn't zoom in when you tap them. */
input, select, textarea, button { font: inherit; color: inherit; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"],
input[type="date"], input[type="time"], select, textarea {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: 16px;
}
input[type="date"], input[type="time"] { -webkit-appearance: none; appearance: none; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--accent); flex: none; margin: 0; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); cursor: pointer; white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.danger { color: var(--danger); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.6; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; padding: 0;
  border: none; border-radius: 10px; background: transparent; cursor: pointer; color: var(--muted);
}
.icon-btn:hover, .btn:hover { filter: brightness(0.97); }
.icon-btn.on { color: var(--accent); }
.icon-btn.danger { color: var(--danger); }
.link-btn { border: none; background: none; padding: 8px 0; color: var(--accent); cursor: pointer; }
.link-btn.danger { color: var(--danger); }
.spacer { flex: 1; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.empty { color: var(--muted); }

/* ---------- App frame: tab bar at the bottom on phones ---------- */

.shell { min-height: 100dvh; }
main {
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
           calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 84px) max(16px, env(safe-area-inset-left));
}
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.brand { display: none; }
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 0.72rem;
}
.tab.active { color: var(--accent); font-weight: 600; }
/* Phones: only the main screens plus "More" fit in the bottom bar. */
.tab:not(.primary):not(.phone-only) { display: none; }

.demo-banner {
  padding: 6px 16px; padding-top: max(6px, env(safe-area-inset-top));
  background: var(--accent-soft); color: var(--text); font-size: 0.85rem; text-align: center;
}
.demo-banner + .shell main { padding-top: 12px; }

.view-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.head-actions { display: flex; align-items: center; gap: 4px; }
.narrow-column { max-width: 680px; }

/* ---------- Sign-in and messages ---------- */

.center-screen {
  min-height: 100dvh; display: grid; place-items: center; align-content: center; gap: 12px;
  padding: 24px; text-align: center;
}
.signin { width: min(380px, 100%); padding: 24px; display: grid; gap: 14px; text-align: left; }
.signin h1 { text-align: center; margin-bottom: 4px; }

/* ---------- Dialogs (forms that pop up) ---------- */

dialog.sheet {
  width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  padding: 0; border: none; border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}
dialog.sheet::backdrop { background: rgba(0, 0, 0, 0.35); }
.sheet-inner { padding: 16px 18px 18px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.form { display: grid; gap: 12px; }
.field { display: grid; gap: 4px; min-width: 0; }
.field > span { font-size: 0.85rem; color: var(--muted); }
.check { display: flex; align-items: center; gap: 10px; min-height: 32px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-actions { display: flex; gap: 8px; align-items: center; margin-top: 4px; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 100;
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 12px;
  background: var(--text); color: var(--bg); transition: opacity 0.2s, transform 0.2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--danger); color: #fff; }

/* ---------- Event colors ---------- */

.c-blue { --c: var(--c-blue); }
.c-green { --c: var(--c-green); }
.c-orange { --c: var(--c-orange); }
.c-red { --c: var(--c-red); }
.c-purple { --c: var(--c-purple); }
.c-gray { --c: var(--c-gray); }

/* ---------- Calendar ---------- */

.calendar-layout { display: grid; gap: 14px; }
.month { padding: 6px; overflow: hidden; }
.weekdays, .days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.weekday { text-align: center; font-size: 0.75rem; color: var(--muted); padding: 4px 0 6px; }
.day {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-height: 52px; padding: 4px 2px; border: none; border-radius: 10px; background: none; cursor: pointer;
}
.day-num {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; font-size: 0.95rem;
}
.day.other-month .day-num { color: var(--muted); opacity: 0.6; }
.day.today .day-num { color: var(--accent); font-weight: 700; }
.day.selected .day-num { background: var(--accent); color: var(--accent-text); font-weight: 700; }
.chips { display: none; }
.dots { display: flex; gap: 3px; height: 6px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--c); }

.day-panel { padding: 14px; display: grid; gap: 10px; align-content: start; }
.event-list, .todo-list, .note-list { list-style: none; margin: 0; padding: 0; }
.event-list { display: grid; gap: 6px; }
.event-row {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 8px; border: none; border-radius: 10px; background: var(--surface-2); cursor: pointer;
}
.bar { width: 4px; align-self: stretch; border-radius: 2px; background: var(--c); }
.event-time { min-width: 88px; font-size: 0.85rem; color: var(--muted); }
.event-text { display: grid; }
.event-text small { color: var(--muted); }
.due-todos { display: grid; gap: 6px; border-top: 1px solid var(--line); padding-top: 10px; }

/* ---------- Pages made of cards (Holly's column layout) ---------- */

.board {
  display: grid; gap: 14px; align-items: start;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
}
.board-stack { display: grid; gap: 14px; }
.board-card { padding: 14px; display: grid; gap: 10px; min-width: 0; }
.board-card.wide { grid-column: 1 / -1; max-width: 760px; }
.card-head { display: flex; align-items: center; gap: 6px; min-height: 32px; }
.card-head h2 { font-size: 1.05rem; }
.card h3 { margin-top: 4px; }
.card-link { color: var(--accent); text-decoration: none; font-size: 0.9rem; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 0; }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 0.9rem; }
.icon-btn.small { width: 34px; height: 34px; font-size: 1.2rem; }
.icon-btn.small svg { width: 20px; height: 20px; }

.list-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; max-width: 100%; }
.pill {
  flex: none; min-height: 36px; padding: 6px 14px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); cursor: pointer;
}
.pill.small { min-height: 30px; padding: 3px 11px; font-size: 0.85rem; }
.pill.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.add-row { display: flex; gap: 8px; }
.add-row .btn { width: 48px; padding: 0; flex: none; }
.add-row.small input { min-height: 40px; padding: 8px 10px; }
.add-row.small .btn { width: 40px; min-height: 40px; font-size: 1.3rem; }

/* Section tags reuse the event colors */
.tag { padding: 0 6px; border-radius: 6px; background: color-mix(in srgb, var(--c) 16%, transparent); color: var(--text); }

/* ---------- Tasks ---------- */

.task-block { display: grid; gap: 8px; }
.task-list, .check-list, .tracker-list, .mini-notes, .meal-list, .timeline, .place-results {
  list-style: none; margin: 0; padding: 0;
}
.task-list { display: grid; gap: 4px; }
.task { display: flex; align-items: center; gap: 10px; padding: 2px 4px; border-radius: 10px; }
.task:hover { background: var(--surface-2); }
.task-text {
  flex: 1; min-width: 0; display: grid; gap: 1px; padding: 7px 0; border: none; background: none;
  text-align: left; cursor: pointer;
}
.task.done .task-title { text-decoration: line-through; color: var(--muted); }
.prio-mark { color: var(--danger); font-weight: 800; margin-right: 4px; }
.task.prio-low .task-title { color: var(--muted); }
.task-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.task-meta small { font-size: 0.76rem; color: var(--muted); }
.task-meta .overdue { color: var(--danger); font-weight: 600; }
.task-meta .doing { color: var(--accent); font-weight: 600; }
.done-group summary { color: var(--accent); cursor: pointer; padding: 4px 0; font-size: 0.9rem; }

/* ---------- Checklists, trackers, notes cards ---------- */

.check-list { display: grid; gap: 2px; }
.check-row, .inventory-row { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.check-text {
  flex: 1; min-width: 0; padding: 6px 0; border: none; background: none; text-align: left; cursor: pointer;
}
.check-row.done .check-text { text-decoration: line-through; color: var(--muted); }
.inventory-row.low .check-text { color: var(--danger); font-weight: 600; }
.counter { display: flex; align-items: center; gap: 2px; }
.count { min-width: 28px; text-align: center; font-variant-numeric: tabular-nums; }

.tracker-group h3 { margin: 6px 0 4px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
.tracker-list { display: grid; gap: 6px; }
.tracker-row, .mini-note, .group-head {
  width: 100%; display: grid; gap: 1px; padding: 8px 10px; text-align: left; cursor: pointer;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2);
}
.tracker-row small, .mini-note small, .group-head small { color: var(--muted); font-size: 0.8rem; }
.tracker-row.active { border-color: var(--accent); background: var(--accent-soft); }
.tracker-row.past { opacity: 0.6; }
.mini-notes { display: grid; gap: 6px; }
.mini-note small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-note .when { font-size: 0.72rem; }
.group { display: grid; gap: 6px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.group:last-child { border-bottom: none; }
.menu { display: grid; gap: 8px; }

/* ---------- Dashboard ---------- */

.cover {
  position: relative; display: flex; align-items: flex-end; min-height: 140px; margin-bottom: 14px;
  padding: 16px; border-radius: var(--radius); overflow: hidden;
  background: linear-gradient(135deg, #2f6f6a, #7d7550); /* fixed, so the white title reads in dark mode too */
  background-size: cover; background-position: center; color: #fff;
}
.cover.has-photo::before {
  content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0) 65%);
}
.cover-text { position: relative; }
.cover h1 { font-size: 1.7rem; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.35); }
.cover p { margin: 2px 0 0; opacity: 0.95; }
.cover-edit {
  position: absolute; top: 10px; right: 10px; padding: 4px 10px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.35); color: #fff; font-size: 0.78rem; text-decoration: none;
}
.weather-now { display: flex; align-items: center; gap: 12px; }
.weather-icon { font-size: 2.4rem; line-height: 1; }
.weather-now div { display: grid; }
.weather-now .temp { font-size: 1.6rem; }
.weather-now small { color: var(--muted); }
.quote-btn { border: none; background: none; padding: 0; text-align: left; cursor: pointer; display: grid; gap: 4px; }
.quote blockquote { margin: 0; font-size: 1.02rem; font-style: italic; line-height: 1.4; }
.quote small { color: var(--muted); }

.timeline { display: grid; gap: 6px; }
.timeline li { display: grid; grid-template-columns: 64px 1fr; gap: 8px; align-items: start; }
.timeline li.past { opacity: 0.55; }
.timeline-time { font-size: 0.8rem; color: var(--muted); padding-top: 9px; text-align: right; }
.timeline-event, .timeline-allday {
  display: grid; gap: 1px; width: 100%; padding: 7px 10px; text-align: left; cursor: pointer;
  border: none; border-left: 4px solid var(--c); border-radius: 8px;
  background: color-mix(in srgb, var(--c) 12%, var(--surface));
}
.timeline-event small { color: var(--muted); font-size: 0.78rem; }
.timeline-allday { font-weight: 600; }

/* ---------- Check-in ---------- */

.metric { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 40px; }
.metric-label { font-size: 0.92rem; }
.scale { display: flex; gap: 3px; }
.scale-btn {
  width: 34px; height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 50%;
  background: var(--surface); cursor: pointer; font-size: 0.95rem;
}
.scale-btn.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.number-input { display: flex; align-items: center; gap: 6px; }
.number-input input { width: 92px; min-height: 36px; padding: 6px 8px; text-align: right; }
.number-input small, .count small { color: var(--muted); }
.meds { display: flex; gap: 18px; padding-top: 4px; border-top: 1px solid var(--line); }

/* ---------- Home: meal plan ---------- */

.meal-list { display: grid; max-height: 460px; overflow-y: auto; }
.meal-row button {
  width: 100%; display: grid; grid-template-columns: 62px 1fr; gap: 8px; align-items: center;
  padding: 6px 4px; border: none; border-bottom: 1px solid var(--line); background: none; text-align: left; cursor: pointer;
}
.meal-row.today button { background: var(--accent-soft); border-radius: 8px; }
.meal-row.past { opacity: 0.55; }
.meal-day { font-size: 0.8rem; color: var(--muted); }
.meal-day strong { color: var(--text); }
.meal-text { display: grid; }
.meal-text small { color: var(--muted); font-size: 0.8rem; }

/* ---------- Health ---------- */

.table-scroll { overflow-x: auto; }
.week-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.week-table th, .week-table td { padding: 5px 3px; text-align: center; border-bottom: 1px solid var(--line); }
.week-table tbody th { text-align: left; font-weight: 500; color: var(--muted); white-space: nowrap; }
.week-table thead th.today { color: var(--accent); }
.spark { display: grid; gap: 4px; }
.spark-head { display: flex; justify-content: space-between; font-size: 0.9rem; }
.spark-head small { color: var(--muted); }
.spark-bars { display: flex; align-items: flex-end; gap: 2px; height: 36px; }
.spark-bars span { flex: 1; background: var(--accent); border-radius: 2px 2px 0 0; opacity: 0.8; }
.spark-bars span.none { background: var(--line); min-height: 2px; }
.stat-row { display: flex; gap: 10px; }
.stat { flex: 1; display: grid; padding: 8px; border-radius: 10px; background: var(--surface-2); text-align: center; }
.stat strong { font-size: 1.25rem; }
.stat small { color: var(--muted); font-size: 0.75rem; }

/* ---------- Travel ---------- */

.trip-details dl { margin: 0; display: grid; gap: 6px; }
.detail { display: grid; grid-template-columns: 70px 1fr; gap: 8px; }
.detail dt { color: var(--muted); font-size: 0.85rem; }
.detail dd { margin: 0; white-space: pre-wrap; }

/* ---------- Settings, More ---------- */

.cover-preview { width: 100%; max-height: 160px; object-fit: cover; border-radius: 10px; }
.place-results { display: grid; gap: 6px; }
.more-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.more-link {
  display: flex; align-items: center; gap: 10px; padding: 16px; color: var(--text); text-decoration: none; font-weight: 600;
}
.more-link svg { color: var(--accent); }

/* ---------- Notes ---------- */

.notes-layout { display: grid; gap: 12px; }
.search { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; color: var(--muted); }
.search span { display: grid; }
.note-list { display: grid; gap: 6px; }
.note-item {
  width: 100%; display: grid; gap: 2px; padding: 10px 12px; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
}
.note-item.active { border-color: var(--accent); background: var(--accent-soft); }
.note-item strong { display: flex; align-items: center; gap: 4px; }
.note-item small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pin-mark svg { width: 14px; height: 14px; color: var(--accent); }
.note-tag { margin-right: 6px; padding: 0 5px; border-radius: 5px; background: var(--surface-2); }
.section-filter { margin-bottom: 8px; }
.note-editor { padding: 10px 14px 14px; display: flex; flex-direction: column; min-height: 60dvh; }
.note-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.save-status { color: var(--muted); }
.note-title {
  border: none !important; outline: none !important; padding: 6px 0 !important;
  font-size: 1.35rem !important; font-weight: 700; background: transparent !important;
}
.note-body {
  flex: 1; min-height: 50dvh; border: none !important; outline: none !important; padding: 6px 0 !important;
  background: transparent !important; resize: none; line-height: 1.55;
}

/* Phone: show the note list OR the open note, not both. */
.note-editor { display: none; }
.note-open .note-sidebar { display: none; }
.note-open .note-editor { display: flex; }

/* ---------- Settings ---------- */

.settings { display: grid; gap: 12px; }
.settings .card { padding: 16px; display: grid; gap: 8px; justify-items: start; }
.settings .card .field { justify-self: stretch; max-width: 320px; }
.button-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Quick add button (every page) ---------- */

.fab {
  position: fixed; z-index: 11; right: max(16px, env(safe-area-inset-right));
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px);
  width: 54px; height: 54px; border-radius: 50%; border: none; cursor: pointer;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-text);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2), 0 6px 16px rgba(0, 0, 0, 0.12);
}
.fab svg { width: 26px; height: 26px; }
.list-tabs.wrap { flex-wrap: wrap; overflow: visible; }
.menu.two { grid-template-columns: 1fr 1fr; }

/* ---------- Top 3 priorities ---------- */

.priority-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.priority { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.priority-num {
  flex: none; width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
  border: 1.5px solid var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 700;
}
.priority-num.on { background: var(--accent); color: var(--accent-text); }
.priority.done .check-text { text-decoration: line-through; color: var(--muted); }

/* ---------- Habits ---------- */

.streak { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.meter { display: block; height: 6px; margin-top: 4px; border-radius: 3px; background: var(--surface); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.board-card.wide.habit-grid-card { max-width: none; }
.habit-grid { border-collapse: collapse; font-size: 0.8rem; }
.habit-grid th { font-weight: 500; color: var(--muted); padding: 2px 1px; }
.habit-grid thead th { text-align: center; min-width: 26px; }
.habit-grid thead th small, .habit-grid thead th span { display: block; line-height: 1.2; }
.habit-grid thead th.today { color: var(--accent); font-weight: 700; }
.habit-grid tbody th {
  position: sticky; left: 0; z-index: 1; background: var(--surface); text-align: left; color: var(--text);
  max-width: 130px; padding-right: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.habit-grid td { padding: 1px; }
.habit-cell {
  width: 24px; height: 24px; border-radius: 6px; padding: 0; cursor: pointer; font-size: 0.75rem;
  border: 1px solid var(--line); background: var(--surface); color: var(--accent-text);
}
.habit-cell.off { background: var(--surface-2); }
.habit-cell.on { background: var(--accent); border-color: var(--accent); }
.habit-cell:disabled { opacity: 0.35; cursor: default; }

/* ---------- Week ---------- */

.week-day.is-today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.week-day.is-today h2 { color: var(--accent); }
.week-mood { font-size: 1.2rem; }
.week-events { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.week-events .timeline-event { display: flex; gap: 8px; align-items: baseline; width: 100%; }
.week-events .timeline-event small { min-width: 58px; }
.week-priorities { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; font-weight: 600; }
.week-priorities .done { text-decoration: line-through; color: var(--muted); font-weight: 400; }
.task.ghost { color: var(--muted); min-height: 32px; }
.ghost-tick { width: 22px; text-align: center; flex: none; }
.week-meal { display: flex; gap: 8px; color: var(--text); text-decoration: none; font-size: 0.9rem; }
.week-meal small { color: var(--muted); }
.week-habits { color: var(--muted); text-decoration: none; font-size: 0.9rem; }

/* ---------- Search ---------- */

.search-head { align-items: stretch; flex-direction: column; }
.search-box {
  display: flex; align-items: center; gap: 8px; padding: 0 12px; max-width: 560px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; color: var(--muted);
}
.search-box span { display: grid; }
.search-box input { border: none !important; outline: none !important; background: transparent; padding: 12px 0; flex: 1; min-width: 0; }
a.tracker-row { color: var(--text); text-decoration: none; }

/* ---------- Help ---------- */

.help-group { gap: 4px; }
.help-topic { border-top: 1px solid var(--line); padding: 2px 0; }
.help-topic:first-of-type { border-top: none; }
.help-topic summary { cursor: pointer; padding: 9px 0; font-weight: 600; }
.help-topic[open] { padding-bottom: 12px; }
.help-steps { margin: 0 0 8px; padding-left: 1.4em; display: grid; gap: 4px; }
.help-tips { margin: 0 0 10px; padding-left: 1.2em; color: var(--muted); font-size: 0.92rem; display: grid; gap: 3px; }
.help-topic .btn { text-decoration: none; display: inline-flex; color: var(--text); }

/* ---------- Collections ---------- */

.collection-row { display: flex; align-items: center; gap: 8px; }
.collection-row .tracker-row { flex: 1; min-width: 0; }
.collection-row .pill { flex: none; white-space: nowrap; }

/* ===================================================================
   iPad and laptop: sidebar instead of bottom tabs, more room.
   =================================================================== */

@media (min-width: 768px) {
  .shell { display: grid; grid-template-columns: 172px 1fr; }
  .tabs {
    position: sticky; top: 0; bottom: auto; height: 100dvh;
    flex-direction: column; justify-content: flex-start; gap: 4px;
    padding: max(20px, env(safe-area-inset-top)) 12px 20px max(12px, env(safe-area-inset-left));
    border-top: none; border-right: 1px solid var(--line); background: var(--surface);
  }
  .brand { display: block; font-weight: 700; padding: 0 10px 14px; }
  .tabs { overflow-y: auto; }
  .tab:not(.primary):not(.phone-only) { display: flex; }
  .tab.phone-only { display: none; }
  .cover { min-height: 190px; }
  .tab {
    flex: none; flex-direction: row; justify-content: flex-start; gap: 10px;
    padding: 10px; border-radius: 10px; font-size: 0.95rem;
  }
  .tab.active { background: var(--accent-soft); }
  main { padding: max(20px, env(safe-area-inset-top)) 24px 96px; min-width: 0; }
  .fab { bottom: max(24px, env(safe-area-inset-bottom)); right: 28px; }
  #toast { bottom: 24px; }

  .day { min-height: 92px; align-items: stretch; padding: 4px; border-radius: 8px; }
  .day-num { width: 28px; height: 28px; font-size: 0.9rem; }
  .day.selected { background: var(--accent-soft); }
  .day.selected .day-num { background: var(--accent); }
  .dots { display: none; }
  .chips { display: grid; gap: 2px; }
  .chip {
    display: block; padding: 1px 5px; border-radius: 5px; font-size: 0.72rem; text-align: left;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    background: color-mix(in srgb, var(--c) 18%, transparent); color: var(--text);
    border-left: 3px solid var(--c);
  }
  .more { font-size: 0.7rem; color: var(--muted); text-align: left; padding-left: 4px; }

  .notes-layout { grid-template-columns: minmax(200px, 34%) 1fr; align-items: start; }
  .note-sidebar, .note-open .note-sidebar { display: block; }
  .note-editor { display: flex; min-height: calc(100dvh - 120px); }
  .back-btn { display: none; }
}

@media (min-width: 1100px) {
  .calendar-layout { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
  .shell { grid-template-columns: 210px 1fr; }
  .notes-layout { grid-template-columns: 300px 1fr; }
  .day-panel { position: sticky; top: 20px; }
  .day { min-height: 110px; }
}
