/* Mimi Dashboard: warm, big, flat. 4:3 landscape first, portrait stacks. */
:root {
  --bg: #F7F4EE;
  --card: #FFFFFF;
  --card-sub: #F0EAD8;
  --text: #1F1D18;
  --text-mid: #4A4538;
  --text-low: #6E695A;
  --accent: #2F8F6C;
  --accent-ink: #0F6E56;
  --accent-soft: #E1F5EE;
  --danger: #A32D2D;
  --danger-soft: #FCEBEB;
  --line: #DAD4C4;
  --shadow: none;
  --radius: 16px;
  --row-h: 64px;
  --font: -apple-system, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --fs-body: 22px;
  --fs-title: 26px;
  --fs-clock: 56px;
  --fs-small: 18px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #15120E;
  --card: #1F1B14;
  --card-sub: #28231A;
  --text: #F7F4EE;
  --text-mid: #D3CDB8;
  --text-low: #A9A28F;
  --accent: #5DCAA5;
  --accent-ink: #9FE1CB;
  --accent-soft: #0F3D30;
  --danger: #F09595;
  --danger-soft: #4A1B1B;
  --line: #3A332A;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.3;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h2 { margin: 0; font-weight: 600; }
[hidden] { display: none !important; }

#dimmer {
  position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; z-index: 1000;
  transition: opacity .4s ease;
}

/* ---------- top bar ---------- */
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 14px 24px 10px;
  border-bottom: 1px solid var(--line);
}
.weekday { font-size: var(--fs-small); color: var(--text-low); }
.date { font-size: var(--fs-title); font-weight: 600; line-height: 1.1; }
.clock { font-size: var(--fs-clock); font-weight: 600; letter-spacing: -1px; line-height: 1; font-variant-numeric: tabular-nums; }
.clock small { font-size: 24px; font-weight: 500; color: var(--text-low); margin-left: 4px; }
.weather-chip {
  justify-self: end;
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 16px; min-height: var(--row-h); text-align: left;
}
.weather-chip:active { background: var(--card-sub); }
.w-icon { font-size: 36px; line-height: 1; }
.w-text { display: flex; flex-direction: column; }
.w-temp { font-size: 28px; font-weight: 600; line-height: 1.1; }
.w-desc { font-size: var(--fs-small); color: var(--text-low); }
.topbar-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 56px; height: 56px; border-radius: 50%; border: 1px solid var(--line); background: var(--card);
  display: inline-flex; align-items: center; justify-content: center; color: var(--text-mid);
}
.icon-btn svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:active { background: var(--card-sub); }
.icon-btn.close { font-size: 34px; line-height: 1; }

/* ---------- main grid ---------- */
.grid {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: var(--split-cols, 53fr auto 47fr); gap: 0;
}
.col { display: flex; flex-direction: column; min-height: 0; padding: 14px 24px; gap: 10px; }
.col-today { border-right: 1px solid var(--line); }
.col-title { font-size: var(--fs-small); font-weight: 600; color: var(--text-low); letter-spacing: .4px; text-transform: uppercase; }
.col-title .count { font-weight: 400; margin-left: 6px; }

.agenda, .upcoming { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; -webkit-overflow-scrolling: touch; }
.ev {
  display: grid; grid-template-columns: 6px 1fr; gap: 14px; align-items: stretch;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  min-height: var(--row-h); padding: 0 16px 0 0; text-align: left; width: 100%; overflow: hidden;
}
.ev:active { background: var(--card-sub); }
.ev .stripe { background: var(--accent); }
.ev .body { padding: 10px 0; min-width: 0; }
.ev .time { font-size: var(--fs-small); color: var(--accent-ink); font-weight: 600; }
.ev .title { font-size: 24px; font-weight: 600; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev .sub { font-size: var(--fs-small); color: var(--text-low); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.now { border-color: var(--accent); background: var(--accent-soft); }
.ev.past { opacity: .55; }
.empty { color: var(--text-low); padding: 18px 4px; font-size: var(--fs-body); }

.up {
  display: grid; grid-template-columns: 76px 1fr; gap: 12px; align-items: center;
  min-height: 58px; padding: 6px 4px; border-bottom: 1px solid var(--line); width: 100%; text-align: left;
  background: none; border-left: 0; border-right: 0; border-top: 0;
}
.up:active { background: var(--card-sub); }
.up .day { font-size: var(--fs-small); font-weight: 600; color: var(--text-low); line-height: 1.1; }
.up .day small { display: block; font-weight: 400; font-size: 15px; }
.up .title { font-size: 21px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up .sub { font-size: 17px; color: var(--text-low); }

.big-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--accent); color: #fff; border: 0; border-radius: var(--radius);
  min-height: 72px; font-size: 26px; font-weight: 600;
}
:root[data-theme="dark"] .big-btn { color: #0B2A20; }
.big-btn:active { filter: brightness(.9); }
.big-btn .plus { font-size: 34px; line-height: 1; }

.list-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 16px; text-align: left; min-height: 96px; width: 100%;
}
.list-card:active { background: var(--card-sub); }
.list-card-head { display: flex; justify-content: space-between; align-items: baseline; }
.list-card-title { font-size: var(--fs-small); font-weight: 600; color: var(--text-low); text-transform: uppercase; letter-spacing: .4px; }
.list-card-count { font-size: var(--fs-small); color: var(--text-low); }
.list-card-preview { font-size: 21px; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.statusbar {
  display: flex; justify-content: center; padding: 6px 24px 8px;
  border-top: 1px solid var(--line); font-size: 18px; background: var(--danger-soft);
}
.statusbar .warn { color: var(--danger); font-weight: 600; }

/* ---------- sheets ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 500; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.sheet-card {
  background: var(--bg); border-radius: 24px; width: min(720px, 100%); max-height: 100%;
  display: flex; flex-direction: column; gap: 14px; padding: 20px 24px 22px; overflow: hidden;
}
.sheet-card.tall { height: min(900px, 100%); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-head h2 { font-size: 30px; }
form { display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: var(--fs-small); color: var(--text-low); font-weight: 600; }
.field input, .field textarea, .add-row input {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  min-height: var(--row-h); padding: 10px 16px; font-size: 24px; width: 100%;
}
.field textarea { min-height: 72px; resize: none; }
.field input:focus, .add-row input:focus, .field textarea:focus { outline: 3px solid var(--accent); outline-offset: 0; }
.row { display: flex; gap: 14px; align-items: flex-end; }
.grow { flex: 1; }
.toggle { display: flex; align-items: center; gap: 12px; min-height: var(--row-h); font-size: var(--fs-body); }
.toggle input { width: 32px; height: 32px; accent-color: var(--accent); }
.btn {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  min-height: var(--row-h); padding: 0 24px; font-size: 22px; font-weight: 600;
}
.btn:active { background: var(--card-sub); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
:root[data-theme="dark"] .btn.primary { color: #0B2A20; }
.btn.danger { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.btn[disabled] { opacity: .5; }
.sheet-actions { display: flex; gap: 12px; align-items: center; margin-top: 4px; }
.spacer { flex: 1; }
.form-error { color: var(--danger); font-size: var(--fs-small); margin: 0; min-height: 1.3em; }
.form-error:empty { display: none; }
.hint { color: var(--text-low); font-size: var(--fs-small); margin: 0; }

/* shopping */
.add-row { flex-direction: row; gap: 12px; }
.shop-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.shop-item {
  display: grid; grid-template-columns: 44px 1fr 56px; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; min-height: var(--row-h); padding: 0 8px 0 14px;
}
.shop-item .check {
  width: 36px; height: 36px; border-radius: 10px; border: 2px solid var(--text-low); display: flex; align-items: center; justify-content: center; font-size: 26px; color: #fff; background: transparent;
}
.shop-item.done .check { background: var(--accent); border-color: var(--accent); }
.shop-item .text { font-size: 24px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shop-item.done .text { text-decoration: line-through; color: var(--text-low); }
.shop-item .remove { background: none; border: 0; font-size: 30px; color: var(--text-low); width: 56px; height: 56px; }

/* weather */
.weather-card { gap: 16px; }
.place-row { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.pill {
  background: var(--card); border: 1px solid var(--line); border-radius: 999px; min-height: 48px; padding: 0 18px; font-size: 19px; font-weight: 600;
}
.pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }
:root[data-theme="dark"] .pill.active { color: #0B2A20; }
.wx-now { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; align-items: center; }
.wx-main { display: flex; align-items: center; gap: 18px; }
.wx-big-icon { font-size: 88px; line-height: 1; }
.wx-big-temp { font-size: 72px; font-weight: 600; line-height: 1; }
.wx-big-desc { font-size: 24px; color: var(--text-mid); }
.wx-place { font-size: 20px; color: var(--text-low); font-weight: 600; }
.wx-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; margin: 0; }
.wx-facts div { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }
.wx-facts dt { font-size: 15px; color: var(--text-low); }
.wx-facts dd { margin: 0; font-size: 22px; font-weight: 600; }
.wx-hourly { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
.wx-hour { flex: 0 0 84px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 4px; text-align: center; }
.wx-hour .h { font-size: 16px; color: var(--text-low); }
.wx-hour .i { font-size: 30px; line-height: 1.2; }
.wx-hour .t { font-size: 20px; font-weight: 600; }
.wx-hour .p { font-size: 14px; color: var(--accent-ink); }
.wx-daily { flex: 1; min-height: 0; overflow-y: auto; }
.wx-day { display: grid; grid-template-columns: 110px 48px 1fr 150px; align-items: center; gap: 10px; min-height: 52px; border-bottom: 1px solid var(--line); font-size: 21px; }
.wx-day .d { font-weight: 600; }
.wx-day .i { font-size: 28px; }
.wx-day .desc { color: var(--text-mid); font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wx-day .hl { text-align: right; font-variant-numeric: tabular-nums; }
.wx-day .hl small { color: var(--text-low); font-size: 18px; }
.place-results { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow-y: auto; }
.place-results button { text-align: left; }

/* settings */
.setting { display: flex; flex-direction: column; gap: 8px; }
.setting-label { font-size: var(--fs-small); color: var(--text-low); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.seg button { flex: 1; min-height: 56px; background: var(--card); border: 0; font-size: 21px; font-weight: 600; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-checked="true"] { background: var(--accent); color: #fff; }
:root[data-theme="dark"] .seg button[aria-checked="true"] { color: #0B2A20; }
.place-list { display: flex; flex-direction: column; gap: 8px; }
.place-item { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; min-height: 56px; padding: 0 8px 0 16px; font-size: 21px; }
.place-item .name { flex: 1; }
.place-item .remove { background: none; border: 0; font-size: 28px; color: var(--text-low); width: 52px; height: 52px; }

/* brightness popover */
.popover {
  position: fixed; top: 92px; right: 24px; z-index: 600; width: 420px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 20px; padding: 16px 20px;
  display: flex; flex-direction: column; gap: 10px;
}
.popover label { font-size: var(--fs-small); color: var(--text-low); font-weight: 600; }
.dim-row { display: flex; align-items: center; gap: 14px; font-size: 28px; }
.dim-row input { flex: 1; height: 44px; accent-color: var(--accent); }

.toast {
  position: fixed; left: 50%; bottom: 60px; transform: translateX(-50%); z-index: 900;
  background: var(--text); color: var(--bg); padding: 14px 24px; border-radius: 14px; font-size: 20px; max-width: 80%;
}

/* ---------- portrait / phone ---------- */
@media (orientation: portrait), (max-width: 820px) {
  :root { --fs-clock: 44px; --fs-title: 22px; }
  .topbar { grid-template-columns: 1fr auto; grid-template-areas: "date clock" "weather actions"; gap: 10px 12px; padding: 12px 16px 8px; }
  .date-block { grid-area: date; }
  .clock { grid-area: clock; justify-self: end; }
  .weather-chip { grid-area: weather; justify-self: start; }
  .topbar-actions { grid-area: actions; justify-self: end; }
  .grid { grid-template-columns: 1fr; grid-template-rows: 1.2fr 1fr; }
  .col { padding: 12px 16px; }
  .col-today { border-right: 0; border-bottom: 1px solid var(--line); }
  .sheet { padding: 10px; }
  .sheet-card { padding: 16px; border-radius: 18px; }
  .wx-now { grid-template-columns: 1fr; }
  .wx-day { grid-template-columns: 80px 40px 1fr 120px; }
  .popover { right: 10px; left: 10px; width: auto; }
  .list-card-preview { white-space: normal; }
}

/* ---------- weather tabs, radar, alerts ---------- */
.wx-tabs { width: 320px; }
.wx-pane { display: flex; flex-direction: column; gap: 16px; flex: 1; min-height: 0; }
.radar-pane { gap: 10px; }
.radar-map { flex: 1; min-height: 360px; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); background: var(--card-sub); }
.radar-bar { display: flex; align-items: center; gap: 12px; }
.radar-bar input[type=range] { flex: 1; height: 44px; accent-color: var(--accent); }
.radar-time { min-width: 150px; font-size: 19px; font-weight: 600; text-align: center; }
.wx-alerts { display: flex; flex-direction: column; gap: 8px; }
.wx-alert { background: var(--danger-soft); border: 2px solid var(--danger); color: var(--danger); border-radius: 14px; padding: 10px 14px; font-size: 20px; font-weight: 600; }
.wx-alert small { display: block; font-weight: 400; font-size: 16px; color: var(--text-mid); margin-top: 2px; }
.weather-chip { position: relative; }
.w-alert { position: absolute; top: -8px; right: -8px; width: 32px; height: 32px; border-radius: 50%; background: var(--danger); color: #fff; font-weight: 700; font-size: 22px; display: flex; align-items: center; justify-content: center; }
.leaflet-container { font-family: var(--font); font-size: 14px; }
.leaflet-bar a { width: 44px !important; height: 44px !important; line-height: 44px !important; font-size: 24px !important; }

/* ---------- size presets (Settings → Size of everything) ---------- */
:root[data-size="small"] { --fs-body: 19px; --fs-title: 23px; --fs-clock: 48px; --fs-small: 16px; --row-h: 56px; }
:root[data-size="large"] { --fs-body: 25px; --fs-title: 30px; --fs-clock: 64px; --fs-small: 20px; --row-h: 72px; }
:root[data-size="huge"]  { --fs-body: 28px; --fs-title: 34px; --fs-clock: 72px; --fs-small: 22px; --row-h: 80px; }
:root[data-size="small"] .ev .title { font-size: 21px; }
:root[data-size="large"] .ev .title { font-size: 27px; }
:root[data-size="huge"] .ev .title { font-size: 30px; }
:root[data-size="large"] .up .title, :root[data-size="large"] .list-card-preview { font-size: 23px; }
:root[data-size="huge"] .up .title, :root[data-size="huge"] .list-card-preview { font-size: 26px; }
.seg.small button { min-height: 48px; font-size: 19px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent-ink); text-decoration: underline; font-size: inherit; }

/* ---------- view bar + divider ---------- */
.view-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.view-bar .seg { flex: 0 0 auto; width: 300px; }
.view-bar .col-title { margin-left: auto; }
.nav { display: flex; gap: 6px; }
.nav-btn { min-height: 48px; padding: 0 16px; font-size: 22px; }
.grid { position: relative; }
.divider { width: 14px; margin: 0 -7px; cursor: col-resize; position: relative; z-index: 2; touch-action: none; }
.divider::after { content: ''; position: absolute; left: 6px; top: 40%; width: 4px; height: 20%; border-radius: 2px; background: var(--line); }
.divider.active::after, .divider:hover::after { background: var(--accent); }
.grid.full { grid-template-columns: 1fr !important; }
.grid.full .divider, .grid.full .col-upcoming { display: none; }
.grid.full .col-today { border-right: 0; }

/* ---------- week view ---------- */
.week { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.wk-col { display: flex; flex-direction: column; min-height: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--card); overflow: hidden; }
.wk-col.today { border-color: var(--accent); }
.wk-head { display: flex; flex-direction: column; align-items: center; padding: 6px 0 4px; background: var(--card-sub); border: 0; border-bottom: 1px solid var(--line); }
.wk-col.today .wk-head { background: var(--accent); color: #fff; }
:root[data-theme="dark"] .wk-col.today .wk-head { color: #0B2A20; }
.wk-dow { font-size: 15px; text-transform: uppercase; letter-spacing: .4px; opacity: .85; }
.wk-num { font-size: 28px; font-weight: 600; line-height: 1.05; }
.wk-events { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 5px; padding: 6px; }
.wk-ev { display: flex; flex-direction: column; align-items: flex-start; text-align: left; border: 0; border-left: 4px solid var(--accent); border-radius: 8px; background: var(--card-sub); padding: 5px 8px; min-height: 48px; }
.wk-ev.allday { background: var(--accent-soft); }
.wk-ev .t { font-size: 14px; color: var(--accent-ink); font-weight: 600; }
.wk-ev .n { font-size: 17px; font-weight: 600; line-height: 1.15; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.wk-more { background: none; border: 0; color: var(--text-low); font-size: 15px; text-align: left; padding: 2px 8px; }

/* ---------- month view ---------- */
.month { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.mo-head { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; padding: 0 0 4px; }
.mo-dow { text-align: center; font-size: 15px; color: var(--text-low); text-transform: uppercase; letter-spacing: .4px; }
.mo-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); gap: 4px; }
.mo-cell { display: flex; flex-direction: column; align-items: stretch; text-align: left; border: 1px solid var(--line); border-radius: 10px; background: var(--card); padding: 4px 6px; min-height: 0; overflow: hidden; }
.mo-cell.other { opacity: .45; }
.mo-cell.today { border-color: var(--accent); border-width: 2px; }
.mo-cell.today .mo-num { background: var(--accent); color: #fff; }
:root[data-theme="dark"] .mo-cell.today .mo-num { color: #0B2A20; }
.mo-num { align-self: flex-start; font-size: 17px; font-weight: 600; border-radius: 999px; padding: 1px 7px; }
.mo-chips { display: flex; flex-direction: column; gap: 2px; margin-top: 2px; min-height: 0; overflow: hidden; }
.mo-chip { font-size: 13px; line-height: 1.2; border-left: 3px solid var(--accent); padding-left: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mo-chip.allday { background: var(--accent-soft); border-radius: 4px; }
.mo-more { font-size: 12px; color: var(--text-low); }
:root[data-size="large"] .mo-chip, :root[data-size="huge"] .mo-chip { font-size: 15px; }
.day-list { max-height: 55vh; }

@media (orientation: portrait), (max-width: 820px) {
  .divider { display: none; }
  .view-bar .seg { width: 100%; }
  .week { grid-template-columns: 1fr; overflow-y: auto; }
  .wk-col { flex-direction: row; min-height: 64px; }
  .wk-head { flex: 0 0 70px; border-bottom: 0; border-right: 1px solid var(--line); }
  .wk-events { overflow: visible; }
  .mo-chip { display: none; }
  .mo-cell.has::after { content: '•'; color: var(--accent); font-size: 22px; line-height: .6; }
}
