/* Faccende di Casa — big text, big buttons, high contrast. */

:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --card: #ffffff;
  --text: #1a1a1a;
  --muted: #4a4a4a;
  --line: #d6d2c8;
  --primary: #1f3a5f;
  --primary-text: #ffffff;
  --danger: #b3261e;
  --danger-bg: #fde8e6;
  --ok: #1d7a3a;

  /* One clear colour per person */
  --papa: #1d5fbf;   --papa-bg: #e4eeff;
  --mamma: #b8460b;  --mamma-bg: #ffeadc;
  --luca: #18783a;   --luca-bg: #e0f4e6;

  --radius: 18px;
  --tap: 64px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { font-size: 20px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.35;
  -webkit-tap-highlight-color: transparent;
}

h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.35rem; margin: 0; }

.screen {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
  min-height: 100vh;
}
.screen.center {
  display: flex; flex-direction: column; justify-content: center; align-items: stretch;
  text-align: center; gap: 20px;
}
.logo { align-self: center; border-radius: 22px; }
.big-text { font-size: 1.4rem; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.hint { color: var(--muted); margin: 0; font-size: 1rem; }
.error { color: var(--danger); font-weight: 700; margin: 0; min-height: 1em; }
.error:empty { display: none; }

/* ---------- Buttons ---------- */
.btn {
  font: inherit;
  font-weight: 700;
  min-height: var(--tap);
  padding: 12px 18px;
  border-radius: var(--radius);
  border: 3px solid transparent;
  cursor: pointer;
  background: #e9e6df;
  color: var(--text);
  touch-action: manipulation;
}
.btn:active { transform: scale(0.98); }
.btn:focus-visible, input:focus-visible, textarea:focus-visible { outline: 4px solid #f2b705; outline-offset: 2px; }
.btn-primary { background: var(--primary); color: var(--primary-text); }
.btn-secondary { background: #fff; border-color: var(--line); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.btn-xl { font-size: 1.3rem; min-height: 72px; width: 100%; }
.btn-link { background: none; color: var(--muted); text-decoration: underline; width: 100%; font-weight: 400; }
.btn-chip { min-height: 48px; padding: 6px 14px; font-size: 0.9rem; font-weight: 400; background: #fff; border-color: var(--line); }

/* ---------- Inputs ---------- */
input[type="password"], input[type="text"], input[type="date"], textarea {
  font: inherit;
  font-size: 1.2rem;
  width: 100%;
  padding: 14px;
  border: 3px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
}
textarea { resize: vertical; min-height: 96px; }
.field-label { font-weight: 700; font-size: 1.15rem; margin: 6px 0 0; text-align: left; }
.check-line { display: flex; align-items: center; gap: 10px; justify-content: center; font-size: 1rem; }
.check-line input { width: 28px; height: 28px; }

/* ---------- "Chi sei?" ---------- */
.who-buttons { display: flex; flex-direction: column; gap: 16px; }
.btn-person { min-height: 96px; font-size: 1.7rem; color: #fff; }
.btn-person.person-papa { background: var(--papa); }
.btn-person.person-mamma { background: var(--mamma); }
.btn-person.person-luca { background: var(--luca); }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-wrap: wrap; padding: 4px 0 6px;
}
.banner { background: #fff4cc; border: 2px solid #e0b400; padding: 12px; border-radius: 12px; font-weight: 700; }

/* ---------- Task lists ---------- */
.person-section { margin: 0 0 16px; }
.person-title {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; border-radius: var(--radius) var(--radius) 0 0;
  color: #fff;
}
.person-title .count { margin-left: auto; font-size: 1rem; font-weight: 400; }
.person-section.person-papa .person-title { background: var(--papa); }
.person-section.person-mamma .person-title { background: var(--mamma); }
.person-section.person-luca .person-title { background: var(--luca); }

/* ---------- Tabs: Umberta / Claudio / Luca ---------- */
.tabs-wrap {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg); padding: 6px 0 8px;
  display: flex; flex-direction: column; gap: 6px;
}
/* 4 tabs in one row: Attività ×3 + Dov'è Umberta */
.tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
.tab-where { border-style: dashed; }
.tab-where.active { border-style: solid; }
.tab-place {
  max-width: 100%; padding: 0 2px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tab {
  font: inherit; cursor: pointer; min-height: 64px; padding: 4px 2px; min-width: 0;
  border-radius: 12px; border: 3px solid currentColor; background: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  touch-action: manipulation;
}
.tab-label { font-size: 0.7rem; font-weight: 600; line-height: 1.1; }
.tab-name { font-size: 0.9rem; font-weight: 800; line-height: 1.2; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.tab-count { font-size: 0.8rem; font-weight: 700; }
.tab.person-papa { color: var(--papa); }
.tab.person-mamma { color: var(--mamma); }
.tab.person-luca { color: var(--luca); }
.tab.active { color: #fff; }
.tab.active.person-papa { background: var(--papa); border-color: var(--papa); }
.tab.active.person-mamma { background: var(--mamma); border-color: var(--mamma); }
.tab.active.person-luca { background: var(--luca); border-color: var(--luca); }

.task-list {
  list-style: none; margin: 0; padding: 5px;
  border-radius: var(--radius);
  display: flex; flex-direction: column; gap: 5px;
}
.person-papa .task-list { background: var(--papa-bg); }
.person-mamma .task-list { background: var(--mamma-bg); }
.person-luca .task-list { background: var(--luca-bg); }
.empty { padding: 14px; margin: 0; color: var(--muted); }

/* Compact row: text, date and notes on the left, "Fatto" button on the right */
.task {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border-radius: 12px;
  border: 2px solid transparent;
  padding: 6px 8px 6px 0;
}
.task.overdue { border-color: var(--danger); background: #fff6f5; }
.task.is-done { opacity: 0.6; }

.task-body {
  flex: 1; min-width: 0; text-align: left; background: none; border: 0; cursor: pointer;
  font: inherit; color: inherit; padding: 4px 4px 4px 12px;
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
}
.task-text { font-size: 1.15rem; font-weight: 700; overflow-wrap: anywhere; line-height: 1.25; }
.task-meta { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 0.95rem; color: var(--muted); }
.task-notes {
  font-size: 0.95rem; color: var(--muted); white-space: pre-line; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.done-item .task-notes { margin-top: 2px; }

.task-body { min-height: 64px; }
.chevron { flex: 0 0 auto; font-size: 2rem; color: var(--muted); padding: 0 6px; line-height: 1; }

/* ---------- "Dov'è...?" card ---------- */
.where-card {
  background: var(--card); border-radius: var(--radius); margin: 4px 0 14px;
  border-left: 12px solid var(--primary); padding: 16px 18px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}
.where-card.person-papa { border-left-color: var(--papa); }
.where-card.person-mamma { border-left-color: var(--mamma); }
.where-card.person-luca { border-left-color: var(--luca); }
.where-card p { margin: 0; }
.where-title { font-weight: 700; color: var(--muted); font-size: 1.05rem; }
.where-place { font-size: 1.8rem; font-weight: 800; line-height: 1.2; margin: 6px 0 10px !important; overflow-wrap: anywhere; }
.where-return { font-size: 1.3rem; font-weight: 700; }
.where-return.late { color: var(--danger); }
.where-meal {
  font-size: 1.2rem; font-weight: 800; margin: 10px 0 0 !important;
  padding: 10px 12px; border-radius: 12px;
}
.where-meal.meal-ready { background: #e4eeff; color: #163f80; }
.where-meal.meal-cook { background: #fff4cc; color: #6b4a00; }
/* Meal choices: two groups, each with two buttons side by side */
.meal-groups { display: flex; flex-direction: column; gap: 6px; }
.meal-group-title { margin: 6px 0 0; font-weight: 700; color: var(--muted); }
.meal-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.meal-groups .btn-choice { padding: 10px 8px; font-size: 1rem; line-height: 1.25; }
.where-notes { font-size: 1.1rem; margin-top: 8px !important; white-space: pre-line; overflow-wrap: anywhere; }
.where-updated { font-size: 0.95rem; color: var(--muted); margin-top: 12px !important; }
.where-updated.stale { color: #8a5a00; font-weight: 700; }
.where-actions { margin-bottom: 16px; }
.btn-home { background: var(--ok); color: #fff; }

/* ---------- Summary card ---------- */
.detail-card {
  background: var(--card); border-radius: var(--radius); margin: 8px 0 18px;
  border-top: 14px solid var(--primary); padding: 16px 18px 18px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}
.detail-card.person-papa { border-top-color: var(--papa); }
.detail-card.person-mamma { border-top-color: var(--mamma); }
.detail-card.person-luca { border-top-color: var(--luca); }
.detail-person { margin: 0 0 4px; font-weight: 800; font-size: 1.1rem; }
.person-papa .detail-person { color: var(--papa); }
.person-mamma .detail-person { color: var(--mamma); }
.person-luca .detail-person { color: var(--luca); }
.detail-text { font-size: 1.6rem; line-height: 1.25; overflow-wrap: anywhere; }
.detail-rows { margin: 16px 0 0; }
.detail-rows dt { font-weight: 700; color: var(--muted); font-size: 1rem; margin-top: 12px; }
.detail-rows dd { margin: 2px 0 0; font-size: 1.2rem; }
.detail-rows dd.late { color: var(--danger); font-weight: 700; }
.detail-notes { white-space: pre-line; overflow-wrap: anywhere; }
.btn-done-xl { background: var(--ok); color: #fff; min-height: 84px; font-size: 1.5rem; }
.btn-done-xl:disabled { opacity: 0.6; }
.optional { font-weight: 400; color: var(--muted); }
.due { font-weight: 700; color: var(--text); }
.due.today { color: var(--primary); }
.overdue .due { color: var(--danger); }

/* ---------- Done section ---------- */
.done-section {
  background: #fff; border: 2px solid var(--line); border-radius: var(--radius);
  margin: 8px 0 12px;
}
.done-section summary {
  font-size: 1.2rem; font-weight: 700; padding: 18px; cursor: pointer; min-height: var(--tap);
}
.done-list { list-style: none; margin: 0; padding: 0 10px 10px; display: flex; flex-direction: column; gap: 10px; }
.done-item { border-top: 1px solid var(--line); padding-top: 10px; }
.done-item .task-text { text-decoration: line-through; color: var(--muted); }
.done-item .task-meta { margin: 4px 0 8px; }
.done-actions { display: flex; gap: 8px; }
.done-actions .btn { flex: 1; min-height: 56px; font-size: 1rem; }

/* ---------- Floating "+ Nuova attività" ---------- */
.fab-space { height: 100px; }
.btn-fab {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom));
  width: min(608px, calc(100% - 32px));
  min-height: 76px; font-size: 1.4rem;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}
.btn-fab:active { transform: translateX(-50%) scale(0.98); }

/* ---------- Form ---------- */
.mic-area { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 6px 0 10px; }
.btn-mic {
  width: 150px; height: 150px; border-radius: 50%;
  border: 0; cursor: pointer; font: inherit; font-weight: 700; font-size: 1.2rem;
  background: var(--primary); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}
.mic-icon { font-size: 3.4rem; line-height: 1; }
.btn-mic.listening { background: var(--danger); animation: pulse 1.2s infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(179, 38, 30, 0.5); }
  50% { box-shadow: 0 0 0 18px rgba(179, 38, 30, 0); }
}
.mic-status { text-align: center; margin: 0; font-size: 1.1rem; min-height: 1.4em; }

.choice-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-choice { background: #fff; border-color: var(--line); padding: 10px 6px; font-size: 1.1rem; }
.btn-choice.selected { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-choice.person-papa.selected { background: var(--papa); border-color: var(--papa); }
.btn-choice.person-mamma.selected { background: var(--mamma); border-color: var(--mamma); }
.btn-choice.person-luca.selected { background: var(--luca); border-color: var(--luca); }
.btn-choice.selected::before { content: "✓ "; }

.date-line { display: flex; align-items: center; gap: 10px; font-size: 1rem; }
.date-line span { flex: 0 0 auto; }

.weekday-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin-top: 8px; }
.btn-day { padding: 0; min-height: 58px; font-size: 1.25rem; background: #fff; border-color: var(--line); }
.btn-day.selected { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- Dialog ---------- */
.dialog-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 20;
}
.dialog {
  background: #fff; border-radius: 22px; padding: 22px; width: min(520px, 100%);
  max-height: 90vh; overflow: auto;
}
.dialog p { font-size: 1.15rem; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(110px + env(safe-area-inset-bottom));
  width: min(608px, calc(100% - 32px));
  background: #222; color: #fff; border-radius: 16px;
  padding: 12px 12px 12px 18px; font-size: 1.15rem; font-weight: 700;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  z-index: 30; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}
.btn-toast { min-height: 52px; background: #fff; color: #222; font-size: 1.05rem; }
