:root {
  font-family: Inter, ui-rounded, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172133;
  background: #e9eef3;
  --ink: #172133;
  --muted: #66758a;
  --line: #dfe6ed;
  --surface: #fbfcfd;
  --surface-2: #f3f7fa;
  --accent: #3c7aa9;
  --accent-soft: #dbeaf5;
  --today: #e4f1fb;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: #e9eef3; }
body { min-height: 100vh; padding: 14px; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.dashboard {
  min-height: calc(100vh - 28px);
  background: var(--surface);
  border-radius: 26px;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1.9fr) minmax(300px, 1fr);
  box-shadow: 0 18px 48px rgba(36, 51, 67, .16);
}
.week-panel { padding: 28px 30px 26px; overflow: auto; }
.dinners-panel {
  padding: 28px 24px 26px;
  border-left: 1px solid var(--line);
  background: var(--surface-2);
  overflow: auto;
}
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.eyebrow { margin: 0 0 6px; color: #8291a3; font-size: 12px; font-weight: 850; letter-spacing: .16em; }
h1, h2 { margin: 0; color: var(--ink); letter-spacing: -.035em; }
h1 { font-size: clamp(32px, 3.2vw, 48px); line-height: 1.02; }
h2 { font-size: clamp(28px, 2.5vw, 38px); line-height: 1.06; }
.range { margin: 8px 0 0; color: var(--muted); font-size: 18px; }
.week-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.icon-button, .text-button, .primary-button {
  border: 0;
  border-radius: 13px;
  min-height: 44px;
  cursor: pointer;
  font-weight: 760;
}
.icon-button { width: 44px; display: inline-grid; place-items: center; background: #e8eef3; color: #314156; font-size: 24px; text-decoration: none; }
.text-button { padding: 0 14px; background: #e8eef3; color: #314156; }
.primary-button { padding: 0 18px; background: #315f82; color: white; }
.settings-link { font-size: 18px; }
.week-list { margin-top: 18px; }
.day-row {
  min-height: 92px;
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 16px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}
.day-label {
  align-self: stretch;
  border-radius: 16px;
  padding: 12px 13px;
  background: #eef2f6;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.day-label.today { background: var(--today); box-shadow: inset 3px 0 0 #4f94c6; }
.day-name { font-size: 20px; font-weight: 850; letter-spacing: -.02em; }
.day-date { margin-top: 3px; color: var(--muted); font-size: 14px; }
.events { align-content: center; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.event {
  min-width: 0;
  border-radius: 12px;
  padding: 9px 11px 9px 14px;
  background: #e8f0f6;
  position: relative;
  overflow: hidden;
}
.event::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--event-color, #7b98af); }
.event-main { display: flex; min-width: 0; gap: 8px; align-items: baseline; }
.event-time { flex: 0 0 auto; font-size: 13px; font-weight: 820; color: #33465c; }
.event-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; font-weight: 690; }
.event-meta { margin-top: 2px; color: #6f7e90; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-day { color: #96a1af; align-self: center; font-size: 14px; }
.dinner-header { align-items: center; }
.save-state { min-width: 55px; color: #6d7c8c; font-size: 13px; text-align: right; }
.dinner-list { margin-top: 20px; display: grid; gap: 10px; }
.dinner-row {
  width: 100%;
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) 34px;
  gap: 12px;
  align-items: center;
  border: 0;
  border-radius: 17px;
  background: white;
  padding: 11px;
  text-align: left;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(44, 63, 82, .06);
}
.dinner-day { border-radius: 13px; background: #e3eff8; padding: 10px 8px; text-align: center; font-weight: 850; }
.dinner-row:nth-child(3n + 2) .dinner-day { background: #f6e6ed; }
.dinner-row:nth-child(3n) .dinner-day { background: #e5f1e8; }
.dinner-date { display: block; color: #697889; font-weight: 600; font-size: 11px; margin-top: 2px; }
.dinner-meal { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 18px; font-weight: 720; }
.dinner-meal.empty { color: #9aa5b2; font-weight: 600; }
.edit-mark { color: #8493a3; font-size: 19px; }
.phone-hint { color: #8090a1; font-size: 12px; line-height: 1.45; margin: 16px 3px 0; }
.status-banner { margin-top: 17px; border-radius: 14px; padding: 12px 14px; background: #fff0cd; color: #6d551e; font-size: 14px; }
.status-banner a { color: inherit; font-weight: 800; }
.hidden { display: none !important; }
.overlay { position: fixed; inset: 0; z-index: 20; background: rgba(25, 34, 45, .48); display: grid; place-items: center; padding: 18px; backdrop-filter: blur(7px); }
.login-card, .meal-card { width: min(450px, 94vw); padding: 26px; border-radius: 24px; background: white; box-shadow: 0 22px 70px rgba(26, 39, 52, .28); }
.login-card h2, .meal-card h2 { margin-bottom: 8px; }
.login-card p:not(.eyebrow), .meal-card p:not(.eyebrow) { color: var(--muted); }
.login-card input, .meal-card input {
  width: 100%;
  height: 52px;
  border-radius: 13px;
  border: 1px solid #cfd8e1;
  padding: 0 14px;
  outline: none;
  font-size: 18px;
  margin: 10px 0 14px;
}
.login-card input:focus, .meal-card input:focus { border-color: #6b9bbb; box-shadow: 0 0 0 3px #dcebf4; }
.login-card .primary-button { width: 100%; }
.form-error { min-height: 19px; margin: 10px 0 0; color: #b44747 !important; font-size: 13px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 900px) {
  body { padding: 0; }
  .dashboard { min-height: 100vh; border-radius: 0; grid-template-columns: minmax(0, 1.65fr) minmax(270px, 1fr); }
  .week-panel { padding: 20px; }
  .dinners-panel { padding: 20px 15px; }
  .day-row { grid-template-columns: 92px minmax(0, 1fr); }
  .events { grid-template-columns: 1fr; }
  .event-title { font-size: 15px; }
  .dinner-row { grid-template-columns: 70px minmax(0, 1fr) 28px; padding: 9px; }
  .dinner-meal { font-size: 16px; }
}

@media (max-width: 720px) {
  body { background: var(--surface); }
  .dashboard { display: flex; flex-direction: column; }
  .dinners-panel { order: -1; border-left: 0; border-bottom: 1px solid var(--line); padding: 20px 16px; max-height: none; }
  .week-panel { padding: 22px 16px; }
  .week-header { flex-direction: column; }
  .week-actions { justify-content: flex-start; }
  .dinner-list { grid-template-columns: 1fr; gap: 8px; }
  .dinner-row { grid-template-columns: 76px minmax(0, 1fr) 28px; }
  .phone-hint { display: block; }
  .day-row { grid-template-columns: 82px minmax(0, 1fr); min-height: 80px; }
  .day-label { padding: 9px; }
  .day-name { font-size: 17px; }
}

/* Compact wall-display layout for landscape iPads/tablets.
   Seven days and seven dinners always fit in a single viewport. */
@media (min-width: 721px) and (max-width: 1180px) and (max-height: 900px) {
  html, body { height: 100%; min-height: 0; overflow: hidden; }
  body { height: 100vh; height: 100dvh; padding: 0; }

  .dashboard {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    border-radius: 0;
    grid-template-columns: minmax(0, 1.72fr) minmax(270px, .9fr);
    overflow: hidden;
  }

  .week-panel,
  .dinners-panel {
    min-height: 0;
    overflow: hidden;
    display: grid;
  }

  .week-panel {
    grid-template-rows: auto auto minmax(0, 1fr);
    padding: 14px 16px 10px;
  }

  .dinners-panel {
    grid-template-rows: auto minmax(0, 1fr) auto;
    padding: 14px 12px 9px;
  }

  .panel-header { gap: 10px; }
  .eyebrow { margin-bottom: 3px; font-size: 9px; }
  h1 { font-size: 30px; }
  h2 { font-size: 27px; }
  .range { margin-top: 4px; font-size: 15px; }

  .week-actions { gap: 5px; }
  .icon-button, .text-button, .primary-button { min-height: 36px; border-radius: 10px; }
  .icon-button { width: 36px; font-size: 20px; }
  .text-button { padding: 0 11px; font-size: 14px; }
  .settings-link { font-size: 16px; }

  .status-banner { margin-top: 7px; padding: 7px 10px; font-size: 12px; }

  .week-list {
    min-height: 0;
    margin-top: 7px;
    display: grid;
    grid-template-rows: repeat(7, minmax(0, 1fr));
  }

  .day-row {
    min-height: 0;
    height: 100%;
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 8px;
    padding: 3px 0;
    overflow: hidden;
  }

  .day-label { border-radius: 11px; padding: 5px 8px; }
  .day-name { font-size: 16px; }
  .day-date { margin-top: 1px; font-size: 11px; }

  .events {
    min-height: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    overflow: hidden;
  }

  .event { border-radius: 9px; padding: 5px 7px 5px 10px; }
  .event::before { width: 4px; }
  .event-main { gap: 5px; }
  .event-time { font-size: 11px; }
  .event-title { font-size: 13px; }
  .event-meta { margin-top: 0; font-size: 9px; }
  .empty-day { font-size: 12px; }

  .dinner-list {
    min-height: 0;
    margin-top: 8px;
    display: grid;
    grid-template-rows: repeat(7, minmax(0, 1fr));
    gap: 5px;
  }

  .dinner-row {
    min-height: 0;
    height: 100%;
    grid-template-columns: 58px minmax(0, 1fr) 20px;
    gap: 7px;
    border-radius: 12px;
    padding: 5px 7px;
    box-shadow: 0 2px 8px rgba(44, 63, 82, .05);
  }

  .dinner-day { border-radius: 9px; padding: 5px 4px; font-size: 13px; }
  .dinner-date { margin-top: 0; font-size: 9px; }
  .dinner-meal { font-size: 15px; }
  .edit-mark { font-size: 14px; }
  .phone-hint { margin: 5px 2px 0; font-size: 9px; line-height: 1.25; }
  .save-state { font-size: 11px; }
}

/* Interactive day and event detail views */
.day-label {
  border: 0;
  width: 100%;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.day-label:active { transform: scale(.985); }
.day-label:focus-visible,
.event-card:focus-visible,
.dinner-row:focus-visible {
  outline: 3px solid rgba(79, 148, 198, .35);
  outline-offset: 2px;
}
.event-card {
  width: 100%;
  border: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.event-card:active { transform: scale(.992); }
.event-detail-overlay { z-index: 30; }
.detail-card {
  width: min(720px, 94vw);
  max-height: min(82vh, 760px);
  overflow: auto;
  padding: 26px;
  border-radius: 26px;
  background: white;
  box-shadow: 0 24px 80px rgba(26, 39, 52, .32);
}
.day-card { width: min(760px, 94vw); }
.detail-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}
.detail-subtitle { margin: 7px 0 0; color: var(--muted); font-size: 16px; }
.close-button { flex: 0 0 auto; font-size: 27px; line-height: 1; }
.day-event-list { display: grid; gap: 10px; }
.day-detail-event {
  position: relative;
  overflow: hidden;
  border-radius: 15px;
  padding: 13px 14px 13px 18px;
  background: #edf3f7;
}
.day-detail-event::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
  background: var(--event-color, #7b98af);
}
.day-detail-event .event-time { font-size: 14px; }
.day-detail-event .event-title { font-size: 18px; white-space: normal; }
.day-detail-event .event-meta { margin-top: 4px; font-size: 13px; white-space: normal; }
.day-empty {
  display: grid;
  gap: 4px;
  padding: 24px;
  border-radius: 16px;
  background: var(--surface-2);
  color: var(--muted);
}
.day-empty strong { color: var(--ink); font-size: 18px; }
.event-detail-heading { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
.event-color-dot { width: 12px; height: 42px; flex: 0 0 12px; border-radius: 10px; background: #7b98af; }
.event-detail-heading h2 { overflow-wrap: anywhere; }
.event-detail-list { margin: 0; display: grid; gap: 0; }
.detail-row {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 14px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.detail-row dt { color: #8291a3; font-size: 12px; font-weight: 850; letter-spacing: .09em; text-transform: uppercase; }
.detail-row dd { margin: 0; color: var(--ink); line-height: 1.45; }
.event-description { white-space: pre-wrap; overflow-wrap: anywhere; }
.event-detail-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 22px; }
.event-link { display: inline-flex; align-items: center; text-decoration: none; }

@media (max-width: 720px) {
  .detail-card { width: min(96vw, 720px); max-height: 88vh; padding: 21px 18px; border-radius: 22px; }
  .detail-row { grid-template-columns: 68px minmax(0, 1fr); gap: 10px; }
  .event-detail-actions { align-items: stretch; flex-direction: column; }
  .event-detail-actions .text-button,
  .event-detail-actions .primary-button { width: 100%; justify-content: center; text-align: center; }
}

/* v4: Dinners/Notes side panel + dinner notes */
.side-toggle {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: #e3eaf0;
}
.side-toggle-button {
  min-height: 38px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: #657587;
  font-weight: 800;
  cursor: pointer;
}
.side-toggle-button.active {
  background: white;
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(44, 63, 82, .10);
}
.side-view { min-height: 0; }
#dinnerView { display: grid; grid-template-rows: minmax(0, 1fr) auto; }
.dinner-content {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
}
.dinner-meal { display: block; }
.dinner-note {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #728092;
  font-size: 13px;
  font-style: italic;
  line-height: 1.25;
}
.field-label {
  display: block;
  margin: 12px 0 -5px;
  color: #647386;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.field-label span { font-weight: 650; text-transform: none; letter-spacing: 0; }
.field-help { margin: -6px 0 16px !important; font-size: 12px; }
.notes-view { padding-top: 16px; }
.notes-label {
  display: block;
  margin-bottom: 8px;
  color: #66758a;
  font-size: 13px;
  font-weight: 800;
}
.week-notes {
  width: 100%;
  min-height: 360px;
  resize: vertical;
  border: 1px solid #ccd7e0;
  border-radius: 17px;
  background: white;
  color: var(--ink);
  padding: 16px;
  outline: none;
  font: inherit;
  font-size: 17px;
  line-height: 1.5;
  box-shadow: 0 4px 16px rgba(44, 63, 82, .05);
}
.week-notes:focus { border-color: #6b9bbb; box-shadow: 0 0 0 3px #dcebf4; }
.notes-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}
.notes-help { color: #8290a0; font-size: 11px; line-height: 1.35; }

@media (max-width: 720px) {
  .side-toggle { margin-top: 13px; }
  .week-notes { min-height: 220px; }
  .notes-actions { align-items: stretch; flex-direction: column; }
  .notes-actions .primary-button { width: 100%; }
}

@media (min-width: 721px) and (max-width: 1180px) and (max-height: 900px) {
  .dinners-panel { grid-template-rows: auto auto minmax(0, 1fr); }
  .side-toggle { margin-top: 7px; padding: 3px; border-radius: 10px; }
  .side-toggle-button { min-height: 29px; border-radius: 8px; font-size: 12px; }
  #dinnerView { min-height: 0; overflow: hidden; }
  .dinner-list { min-height: 0; }
  .dinner-content { gap: 1px; }
  .dinner-note { font-size: 9px; line-height: 1.1; }
  .notes-view { min-height: 0; padding-top: 8px; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
  .notes-label { margin-bottom: 5px; font-size: 10px; }
  .week-notes { min-height: 0; height: 100%; resize: none; border-radius: 12px; padding: 10px; font-size: 14px; line-height: 1.35; }
  .notes-actions { margin-top: 6px; gap: 6px; }
  .notes-help { font-size: 8px; }
  .notes-actions .primary-button { min-height: 30px; padding: 0 10px; font-size: 11px; }
}

/* v5 note cards */
.note-list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.add-note-button { min-height: 36px; padding: 0 12px; font-size: 13px; }
.note-card-list {
  display: grid;
  gap: 8px;
  min-height: 0;
  overflow: auto;
  padding: 1px 2px 2px;
  align-content: start;
}
.note-card {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 22px;
  gap: 10px;
  align-items: center;
  border: 0;
  border-radius: 17px;
  background: white;
  padding: 13px 14px;
  text-align: left;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(44, 63, 82, .06);
}
.note-card:nth-child(3n + 2) { background: #fff8fb; }
.note-card:nth-child(3n) { background: #f7fbf8; }
.note-card-copy { min-width: 0; display: grid; gap: 4px; }
.note-card-title { font-size: 17px; font-weight: 780; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-card-description {
  color: #748395;
  font-size: 12px;
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.note-card-arrow { color: #8c9aaa; font-size: 24px; line-height: 1; }
.notes-empty {
  display: grid;
  gap: 5px;
  padding: 18px;
  border-radius: 16px;
  background: rgba(255,255,255,.68);
  color: var(--muted);
  line-height: 1.4;
}
.notes-empty strong { color: var(--ink); font-size: 17px; }
.note-detail-description {
  min-height: 90px;
  padding: 18px;
  border-radius: 16px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 17px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.note-description-input {
  width: 100%;
  min-height: 170px;
  resize: vertical;
  border-radius: 13px;
  border: 1px solid #cfd8e1;
  padding: 13px 14px;
  outline: none;
  font: inherit;
  font-size: 16px;
  line-height: 1.45;
  margin: 10px 0 4px;
}
.note-description-input:focus { border-color: #6b9bbb; box-shadow: 0 0 0 3px #dcebf4; }
.note-editor-actions { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.dialog-spacer { flex: 1; }
.danger-button {
  min-height: 42px;
  border: 1px solid #e7b7b7;
  border-radius: 12px;
  background: #fff2f2;
  color: #a23c3c;
  padding: 0 13px;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}
.note-card:focus-visible { outline: 3px solid rgba(79, 148, 198, .35); outline-offset: 2px; }

@media (max-width: 720px) {
  .note-card-list { max-height: none; }
  .note-card { padding: 12px; }
  .note-list-toolbar { position: sticky; top: 0; z-index: 1; padding-top: 2px; }
}

@media (min-width: 721px) and (max-width: 1180px) and (max-height: 900px) {
  .notes-view { grid-template-rows: auto minmax(0, 1fr) auto; }
  .note-list-toolbar { margin-bottom: 6px; }
  .notes-label { margin-bottom: 0; }
  .add-note-button { min-height: 30px; padding: 0 9px; font-size: 11px; }
  .note-card-list { gap: 5px; }
  .note-card { border-radius: 12px; padding: 8px 9px; gap: 6px; box-shadow: 0 2px 8px rgba(44, 63, 82, .05); }
  .note-card-title { font-size: 14px; }
  .note-card-description { font-size: 10px; line-height: 1.2; -webkit-line-clamp: 1; }
  .note-card-arrow { font-size: 18px; }
  .notes-empty { padding: 12px; font-size: 11px; }
  .notes-empty strong { font-size: 14px; }
}
