/* Same look as the Android app (android/.../ui/Theme.kt and Screens.kt). */
:root {
  --teal: #1F6F6B;
  --teal-soft: #CFE6E3;
  --teal-line: #A9C9C6;
  --teal-text: var(--teal); /* the main colour as text on cards; lighter on Night */
  --orange: #D9692A;
  --orange-soft: #FBE3D3;
  --orange-ink: #8A3E12;
  --ground: #F4F5F1;
  --card: #FFFFFF;
  --ink: #1C2321;
  --muted: #5A6461;
  --line: #A9B3AF;
  --track: #E6E9E3;
  --memo-bg: #FFF4EA;
  --memo-ink: #B4531C;
  --done-ink: #7A8480;
  --dialog: #F0F2EE;
  --nav-h: 80px;
  color-scheme: light;
}

/* Themes, picked under the settings cog. Same colours as the Android app's
   Palette in Theme.kt; "teal" (above) is the approved mockup. */
:root[data-theme="ocean"] {
  --teal: #1F5A86; --teal-soft: #D3E3F0; --teal-line: #A8C2D8;
  --orange: #E0703A; --orange-soft: #FCE4D6; --orange-ink: #8A3E12;
  --ground: #F2F5F8; --card: #FFFFFF; --ink: #1A2330; --muted: #56616E;
  --line: #A7B2BE; --track: #E3E8EE; --memo-bg: #FFF4EA; --memo-ink: #B4531C; --done-ink: #7A8490;
  --dialog: #EDF1F5;
}
:root[data-theme="berry"] {
  --teal: #7A3B72; --teal-soft: #F0DCEC; --teal-line: #CFAAC8;
  --orange: #D2553F; --orange-soft: #FADDD6; --orange-ink: #86301F;
  --ground: #F7F3F5; --card: #FFFFFF; --ink: #261C24; --muted: #665A63;
  --line: #B8AAB4; --track: #EDE5EA; --memo-bg: #FDF0F0; --memo-ink: #A8402E; --done-ink: #85798A;
  --dialog: #F3EDF1;
}
:root[data-theme="forest"] {
  --teal: #2E6337; --teal-soft: #D5E8D3; --teal-line: #AAC8A9;
  --orange: #C07F12; --orange-soft: #F6E6C4; --orange-ink: #6E4A08;
  --ground: #F3F5EF; --card: #FFFFFF; --ink: #1C231D; --muted: #5A645A;
  --line: #AAB3A8; --track: #E5E9E1; --memo-bg: #FBF3E2; --memo-ink: #8F5E0A; --done-ink: #7D867B;
  --dialog: #EEF2EA;
}
:root[data-theme="night"] {
  --teal: #2B7F79; --teal-soft: #CDEAE6; --teal-line: #3F6E6A;
  --orange: #E07A3F; --orange-soft: #4A2B1A; --orange-ink: #F6C7A8;
  --ground: #121816; --card: #1D2522; --ink: #E5ECE9; --muted: #9BA7A3;
  --line: #4B5854; --track: #2C3733; --memo-bg: #33261C; --memo-ink: #F0A574; --done-ink: #6F7B77;
  --dialog: #232C29; --teal-text: #6CC4BC;
  color-scheme: dark;
}
:root[data-theme="night"] .btn:disabled { background: rgba(229, 236, 233, 0.12); color: rgba(229, 236, 233, 0.38); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: Roboto, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.35;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
.boot { padding: 48px 24px; color: var(--muted); }

/* ---------- Layout ---------- */

.main {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 18px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom));
  padding-top: env(safe-area-inset-top);
}
.header { padding: 24px 4px 16px; display: flex; align-items: flex-start; gap: 8px; }
.header .titles { flex: 1; min-width: 0; }
.cog {
  width: 48px; height: 48px;
  margin: -4px -8px 0 0;
  border-radius: 24px;
  display: grid; place-items: center;
  color: var(--muted);
}
.cog svg { width: 24px; height: 24px; fill: currentColor; }
.header .date { color: var(--muted); font-size: 13px; font-weight: 500; }
.header h1 { margin: 0; font-size: 30px; font-weight: 700; letter-spacing: -0.2px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack.tight { gap: 10px; }

.nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--card);
  display: flex;
  justify-content: center;
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
  box-shadow: 0 -1px 3px rgba(28, 35, 33, 0.08);
  z-index: 5;
}
.nav button {
  flex: 1;
  max-width: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.nav .pill-ind {
  width: 64px; height: 32px;
  border-radius: 16px;
  display: grid; place-items: center;
  transition: background-color 0.15s;
}
.nav button[aria-current="page"] { color: var(--teal-text); }
.nav button[aria-current="page"] .pill-ind { background: var(--teal-soft); color: var(--teal); }
.nav svg { width: 24px; height: 24px; fill: currentColor; }

/* ---------- Cards ---------- */

.card {
  background: var(--card);
  border-radius: 20px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.card-head { display: flex; justify-content: space-between; align-items: baseline; }
.card-title { font-size: 16px; font-weight: 700; }
.small-muted { font-size: 13px; color: var(--muted); }
.empty { color: var(--muted); font-size: 14px; }
.empty.padded { margin: 0; padding: 4px; }

.dinner-hero {
  background: var(--teal);
  border-radius: 20px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  width: 100%;
}
.dinner-hero .label { display: flex; align-items: center; gap: 8px; color: var(--teal-soft); font-size: 13px; font-weight: 500; }
.dinner-hero .label svg { width: 16px; height: 16px; fill: var(--teal-soft); }
.dinner-hero .meal { color: #fff; font-size: 24px; font-weight: 600; }
.dinner-hero .sub { color: var(--teal-soft); font-size: 14px; }

.progress { height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; }
.progress > div { height: 100%; background: var(--orange); border-radius: 4px; transition: width 0.25s; }

.upcoming { display: flex; gap: 14px; align-items: center; }
.upcoming .when { width: 60px; flex: none; color: var(--teal-text); font-size: 13px; font-weight: 700; }

.memo-banner {
  background: var(--memo-bg);
  border-radius: 20px;
  padding: 16px;
  display: flex;
  gap: 12px;
}
.memo-banner svg { width: 24px; height: 24px; flex: none; fill: var(--memo-ink); }
.memo-banner .meta { color: var(--memo-ink); font-size: 12px; font-weight: 700; }
.memo-banner .body { display: flex; flex-direction: column; gap: 2px; }
.memo-banner .actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

.weather { flex-direction: row; align-items: center; gap: 14px; flex-wrap: wrap; }
.weather .icon { font-size: 34px; line-height: 1; }
.weather .now { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.weather .temp { font-size: 20px; font-weight: 700; }
.weather .range { display: flex; flex-direction: column; align-items: flex-end; font-size: 14px; font-weight: 700; }
.weather .rain { color: var(--teal-text); font-size: 13px; font-weight: 500; }
.weather .updated { flex-basis: 100%; font-size: 11px; color: var(--muted); }

/* ---------- Chores ---------- */

.chore {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  width: 100%;
  text-align: left;
}
.box {
  width: 30px; height: 30px;
  flex: none;
  border-radius: 9px;
  border: 2px solid var(--line);
  background: var(--card);
  display: grid; place-items: center;
  transition: background-color 0.15s, border-color 0.15s;
}
.box svg { width: 20px; height: 20px; fill: #fff; }
.chore.done .box { background: var(--orange); border-color: var(--orange); }
.chore .name, .chore .sub, .day-row .meal, .day-row .detail { display: block; }
.chore .name { font-size: 15px; }
.chore.done .name { color: var(--done-ink); text-decoration: line-through; }
.chore .sub { font-size: 12px; color: var(--muted); }
.chore .sub.overdue { color: var(--memo-ink); }

.week { display: flex; gap: 6px; }
.week > div {
  flex: 1;
  height: 40px;
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
  background: var(--track); color: var(--muted);
}
.week > .all { background: var(--orange); color: #fff; }
.week > .some { background: var(--orange-soft); color: var(--orange-ink); }

/* ---------- Dinner ---------- */

.day-row {
  background: var(--card);
  border-radius: 16px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  border: 2px solid transparent;
}
.day-row.today { border-color: var(--teal); }
.day-row .dcol { width: 44px; flex: none; display: flex; flex-direction: column; align-items: center; }
.day-row .dow { font-size: 12px; font-weight: 700; color: var(--muted); }
.day-row .dnum { font-size: 20px; font-weight: 700; }
.day-row .meal { font-size: 15px; font-weight: 500; }
.day-row .meal.none { color: var(--muted); }
.day-row .detail { font-size: 12px; color: var(--muted); }

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

.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  height: 40px;
  padding: 0 18px;
  border-radius: 18px;
  font-size: 13px;
  font-weight: 700;
  color: var(--teal-text);
  border: 2px solid var(--teal-line);
}
.pill[aria-pressed="true"] { background: var(--teal); border-color: var(--teal); color: #fff; }

.btn {
  min-height: 46px;
  padding: 0 24px;
  border-radius: 14px;
  background: var(--teal);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
}
.btn.block { width: 100%; }
.btn:disabled { background: rgba(28, 35, 33, 0.12); color: rgba(28, 35, 33, 0.38); cursor: default; }
.btn.round { border-radius: 20px; min-height: 40px; font-size: 14px; }
.btn-text { color: var(--teal-text); font-weight: 700; font-size: 14px; padding: 10px 12px; border-radius: 20px; }
.btn-outline {
  width: 100%;
  min-height: 48px;
  border-radius: 14px;
  border: 2px solid var(--line);
  color: var(--teal-text);
  font-size: 15px;
  font-weight: 700;
}
.link { color: var(--teal-text); font-weight: 700; text-decoration: underline; }

/* ---------- Text fields (Material outlined) ---------- */

.field { position: relative; }
.field input, .field textarea {
  width: 100%;
  border: 1px solid #727976;
  border-radius: 4px;
  background: transparent;
  padding: 16px 14px;
  font-size: 16px; /* 16px stops iPhone zooming in */
  outline: none;
  resize: none;
}
.field textarea { min-height: 96px; }
.field input:focus, .field textarea:focus { border: 2px solid var(--teal); padding: 15px 13px; }
.field label {
  position: absolute;
  left: 10px; top: 16px;
  padding: 0 4px;
  color: var(--muted);
  font-size: 16px;
  pointer-events: none;
  transition: all 0.12s;
  background: var(--card);
}
.dialog .field label { background: var(--dialog); }
.field input:focus + label, .field input:not(:placeholder-shown) + label,
.field textarea:focus + label, .field textarea:not(:placeholder-shown) + label {
  top: -8px; font-size: 12px;
}
.field input:focus + label, .field textarea:focus + label { color: var(--teal-text); }

.field-label { font-weight: 700; font-size: 13px; color: var(--muted); }

/* ---------- Dialog (Material AlertDialog) ---------- */

.scrim {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.32);
  display: grid; place-items: center;
  padding: 24px;
  z-index: 10;
}
.dialog {
  background: var(--dialog);
  border-radius: 28px;
  padding: 24px;
  width: 100%;
  max-width: 400px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.dialog h2 { margin: 0; font-size: 24px; font-weight: 400; }
.dialog .body { display: flex; flex-direction: column; gap: 12px; }
.dialog .actions { display: flex; justify-content: flex-end; gap: 8px; align-items: center; }

.theme-row {
  display: flex; align-items: center; gap: 14px;
  min-height: 48px; width: 100%; text-align: left;
  font-size: 16px; font-weight: 500;
}
.theme-row .name { flex: 1; }
.theme-row svg { width: 24px; height: 24px; fill: var(--teal-text); }
.swatch {
  width: 36px; height: 36px; flex: none;
  border-radius: 18px; border: 1px solid var(--sw-line);
  background: var(--sw-ground);
  display: flex; align-items: center; justify-content: center; gap: 3px;
}
.swatch i { width: 11px; height: 11px; border-radius: 6px; }
.swatch i:first-child { background: var(--sw-main); }
.swatch i:last-child { background: var(--sw-tick); }
.swatch.teal { --sw-ground: #F4F5F1; --sw-line: #A9B3AF; --sw-main: #1F6F6B; --sw-tick: #D9692A; }
.swatch.ocean { --sw-ground: #F2F5F8; --sw-line: #A7B2BE; --sw-main: #1F5A86; --sw-tick: #E0703A; }
.swatch.berry { --sw-ground: #F7F3F5; --sw-line: #B8AAB4; --sw-main: #7A3B72; --sw-tick: #D2553F; }
.swatch.forest { --sw-ground: #F3F5EF; --sw-line: #AAB3A8; --sw-main: #2E6337; --sw-tick: #C07F12; }
.swatch.night { --sw-ground: #121816; --sw-line: #4B5854; --sw-main: #2B7F79; --sw-tick: #E07A3F; }

/* ---------- Setup screens ---------- */

.setup {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(72px + env(safe-area-inset-top)) 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.setup h1 { margin: 0; font-size: 28px; font-weight: 700; }
.setup p { margin: 0; font-size: 15px; color: var(--muted); }
.setup .rows { display: flex; flex-direction: column; gap: 10px; }
.setup .field label { background: var(--ground); }
.pick {
  background: var(--card);
  border-radius: 16px;
  padding: 18px;
  font-size: 16px;
  font-weight: 500;
  text-align: left;
  width: 100%;
}
.error-text { color: #B3261E; font-size: 14px; }

/* ---------- Memos ---------- */

.memo-card {
  background: var(--card);
  border-radius: 16px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.memo-card .meta { font-size: 12px; font-weight: 700; color: var(--muted); }
.memo-card .text, .memo-banner .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.footnote { text-align: center; font-size: 13px; color: var(--muted); padding: 8px; }

/* ---------- Snackbar ---------- */

#snackbar {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  width: calc(100% - 32px);
  max-width: 520px;
  background: #313033;
  color: #F4EFF4;
  border-radius: 4px;
  padding: 14px 16px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 20;
}
#snackbar.show { opacity: 1; transform: translate(-50%, 0); }
