:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #fff8df;
  --panel: #ffffff;
  --ink: #222033;
  --muted: #6b6475;
  --line: #eadfca;
  --blue: #0f766e;
  --blue-dark: #0b5f59;
  --green: #138a56;
  --orange: #f97316;
  --yellow: #ffdd57;
  --pink: #e85d75;
  --red: #c2410c;
  --shadow: 0 16px 36px rgba(79, 45, 20, 0.11);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

.is-hidden {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(255, 221, 87, 0.58), transparent 34rem),
    linear-gradient(180deg, #fff8df 0%, #fffdf7 48%, #fff5ed 100%);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: white;
  font-weight: 700;
  padding: 0 16px;
}

button:hover {
  filter: brightness(1.02);
}

button:active {
  transform: translateY(1px);
}

.shell {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 14px max(24px, env(safe-area-inset-bottom));
}

.login-view {
  display: grid;
  gap: 22px;
  min-height: 90vh;
  align-content: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand img {
  border-radius: 18px;
  box-shadow: 0 12px 24px rgba(249, 115, 22, 0.22);
}

.brand h1,
.topbar h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.05;
}

.brand p,
.status-line {
  margin: 6px 0 0;
  color: var(--muted);
}

.panel,
.meal-form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  border-top: 5px solid var(--yellow);
}

.panel {
  display: grid;
  gap: 16px;
  padding: 18px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  min-height: 46px;
  padding: 0 12px;
  font-size: 16px;
}

input:focus,
select:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.16);
  outline: 0;
}

.error {
  margin: 0;
  color: var(--red);
  font-weight: 700;
}

.app-view {
  display: grid;
  gap: 14px;
}

.topbar {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.icon-button {
  width: 44px;
  min-width: 44px;
  padding: 0;
  background: white;
  color: var(--blue-dark);
  border: 1px solid var(--line);
}

.notice {
  border-radius: 8px;
  padding: 12px 14px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  font-weight: 700;
}

.readonly-notice {
  background: #ecfdf5;
  border-color: #99f6e4;
  color: #0f766e;
}

.week-nav {
  display: grid;
  grid-template-columns: 54px 1fr 54px;
  gap: 10px;
}

.week-nav button {
  background: white;
  color: var(--blue-dark);
  border: 1px solid var(--line);
}

#todayButton {
  color: #a33a00;
  background: #fff4c2;
  border-color: #ffd166;
}

.week-grid {
  display: grid;
  gap: 12px;
}

.day-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 8px 22px rgba(79, 45, 20, 0.07);
  scroll-margin-top: 14px;
}

.day-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, #fff4c2, #fffaf0);
}

.day-name {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
}

.day-date {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.today-badge {
  align-self: center;
  border-radius: 999px;
  padding: 4px 9px;
  background: #f97316;
  color: white;
  font-size: 12px;
  font-weight: 800;
}

.meal-row {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  padding: 10px 14px;
  background: white;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  text-align: left;
  font-weight: 500;
}

.meal-block {
  border-bottom: 1px solid var(--line);
}

.meal-block:last-child {
  border-bottom: 0;
}

.meal-block .meal-row {
  border-bottom: 0;
}

.meal-row:not([disabled]):hover {
  background: #fffaf0;
}

.meal-row:last-child {
  border-bottom: 0;
}

.meal-row[disabled] {
  opacity: 0.7;
}

.slot-name {
  color: #9a3412;
  font-size: 13px;
  font-weight: 800;
}

.meal-name {
  min-width: 0;
  overflow-wrap: anywhere;
}

.empty-meal {
  color: var(--muted);
}

.meal-row[disabled] .empty-meal {
  color: #a8a29e;
}

.plan-rating {
  display: grid;
  gap: 4px;
  padding: 0 14px 10px 112px;
  background: white;
}

.plan-rating p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.empty-rating {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.mini-stars {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.mini-star,
.clear-mini-rating {
  min-height: 32px;
  width: 32px;
  min-width: 32px;
  padding: 0;
  border: 1px solid #e4e4e7;
  background: #f4f4f5;
  color: #a1a1aa;
  font-size: 16px;
}

.mini-star.selected {
  background: #ffdd57;
  border-color: #fbbf24;
  color: #9a3412;
}

.clear-mini-rating {
  background: white;
  color: var(--muted);
  font-size: 14px;
}

.meal-dialog {
  width: min(520px, calc(100% - 24px));
  border: 0;
  padding: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.meal-dialog::backdrop {
  background: rgba(23, 32, 51, 0.35);
}

.meal-form {
  display: grid;
  gap: 16px;
  padding: 16px;
}

.meal-form header,
.meal-form menu {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 0;
}

.meal-form h2,
.meal-form p {
  margin: 0;
}

.meal-form p {
  color: var(--muted);
  font-weight: 800;
}

.secondary {
  background: white;
  border: 1px solid var(--line);
  color: var(--red);
}

@media (min-width: 680px) {
  .week-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .day-card:first-child {
    grid-column: 1 / -1;
  }
}

.view-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.view-tabs button {
  background: white;
  color: var(--blue-dark);
  border: 1px solid var(--line);
}

.view-tabs button.active {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}

.plan-view,
.meals-view {
  display: grid;
  gap: 12px;
}

.meal-tools {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.new-meal-form {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(79, 45, 20, 0.07);
}

.meals-list {
  display: grid;
  gap: 12px;
}

.meal-card {
  display: grid;
  gap: 12px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 8px 22px rgba(79, 45, 20, 0.07);
}

.meal-card-head {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.meal-card h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.meal-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.rating-summary {
  justify-self: start;
  display: grid;
  gap: 2px;
  min-width: 116px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fff4c2;
  color: #8a3600;
}

.rating-toggle {
  min-height: auto;
  border: 1px solid #ffd166;
  text-align: left;
}

.rating-toggle:hover {
  background: #ffed9f;
}

.rating-summary strong {
  font-size: 16px;
}

.rating-summary span {
  font-size: 12px;
  font-weight: 800;
}

.rating-details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
  padding: 10px 12px;
}

.rating-breakdown-list {
  display: grid;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.rating-breakdown-list li {
  display: grid;
  grid-template-columns: 12px minmax(72px, auto) 1fr;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 13px;
}

.member-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.member-rating-name {
  font-weight: 800;
}

.member-rating-values,
.empty-rating-detail {
  color: var(--muted);
  font-weight: 700;
}

.empty-rating-detail {
  margin: 0;
  font-size: 13px;
}

.star-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.star-button {
  width: 40px;
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  background: #f4f4f5;
  color: #a1a1aa;
  border: 1px solid #e4e4e7;
  font-size: 20px;
}

.star-button.selected {
  background: #ffdd57;
  color: #9a3412;
  border-color: #fbbf24;
}

.clear-rating {
  min-height: 40px;
  background: white;
  color: var(--muted);
  border: 1px solid var(--line);
  font-size: 14px;
}

.note-field textarea {
  width: 100%;
  resize: vertical;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
}

.note-field textarea:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.16);
  outline: 0;
}

.save-note {
  justify-self: start;
  color: var(--blue-dark);
}

.has-unsaved-note .save-note {
  border-color: var(--orange);
  color: #a33a00;
}

.note-readonly {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.cook-again {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.cook-again button {
  grid-column: 1 / -1;
}

.empty-state {
  margin: 0;
  padding: 16px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-weight: 700;
}

@media (min-width: 680px) {
  .meal-tools {
    grid-template-columns: 2fr 1fr 1fr;
  }

  .new-meal-form {
    grid-template-columns: 2fr 1fr auto;
    align-items: end;
  }

  .new-meal-form .error {
    grid-column: 1 / -1;
  }

  .meal-card-head {
    grid-template-columns: 1fr auto;
    align-items: start;
  }

  .rating-summary {
    justify-self: end;
  }

  .cook-again {
    grid-template-columns: 150px 150px 1fr;
  }

  .cook-again button {
    grid-column: auto;
  }
}
