:root {
  --paper: #f7f3ed;
  --card: #fffdf9;
  --ink: #2b2926;
  --muted: #766f67;
  --line: #e6ddd2;
  --accent: #a45b3f;
  --accent-soft: #f2dfd4;
  --sage: #58725f;
  --sage-soft: #e4ece4;
  --empty: #ddd6cd;
  --gold: #b88731;
  --gold-soft: #f5ecd5;
  --shadow: 0 12px 30px rgba(77, 61, 45, .07);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 90% 0%, rgba(244, 221, 202, .58), transparent 30rem),
    var(--paper);
}

.shell {
  width: min(100% - 32px, 1080px);
  margin: 0 auto;
  padding: 28px 0 42px;
}

.page-header { padding: 12px 2px 26px; }
.eyebrow, .section-kicker, .summary-label {
  margin: 0;
  color: var(--accent);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .13em;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(2rem, 8vw, 3.7rem); letter-spacing: -.055em; line-height: 1; }
h2 { margin: 2px 0 0; font-size: 1.35rem; letter-spacing: -.03em; }
.intro { max-width: 34rem; margin-bottom: 10px; color: var(--muted); font-size: .98rem; line-height: 1.7; }
.sync { margin: 0; color: var(--muted); font-size: .78rem; }

.summary-block { min-height: 74px; padding: 15px 17px; border: 1px solid #e8c8b7; border-radius: 18px; background: linear-gradient(145deg, #fff8f0, #f8e9df); box-shadow: var(--shadow); }
.summary-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; margin: 9px 0 0; color: var(--muted); font-size: .86rem; line-height: 1.55; }
.summary-line strong { color: var(--ink); font-size: 1.02rem; letter-spacing: -.02em; }
.summary-line strong span { font-size: 1.25rem; }
.summary-separator { color: var(--accent); font-weight: 800; }

.section-block { margin-top: 38px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 15px; }
.section-kicker { margin-bottom: 7px; color: var(--muted); font-size: .66rem; }
.section-hint { margin: 0 0 2px; color: var(--muted); font-size: .78rem; }

.timeline-legend { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-bottom: 12px; color: var(--muted); font-size: .76rem; }
.timeline-legend span { display: inline-flex; align-items: center; gap: 6px; }
.timeline-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 17px; background: rgba(255, 253, 249, .84); box-shadow: var(--shadow); -webkit-overflow-scrolling: touch; }
.food-timeline { display: grid; grid-template-columns: minmax(156px, 1fr) repeat(var(--day-count), 34px); min-width: 638px; }
.timeline-food-header, .timeline-day-header { min-height: 50px; padding: 9px 4px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .66rem; font-weight: 800; text-align: center; }
.timeline-food-header { position: sticky; left: 0; z-index: 3; padding: 17px 14px 8px; background: var(--card); text-align: left; }
.timeline-day-header { display: grid; gap: 2px; place-items: center; }
.timeline-day-header small { font-size: .62rem; font-weight: 700; }
.timeline-day-header.is-today { color: var(--accent); background: #fff5eb; }
.timeline-food, .timeline-cell { min-height: 58px; border-bottom: 1px solid var(--line); }
.timeline-food { position: sticky; left: 0; z-index: 2; display: grid; align-content: center; gap: 3px; padding: 8px 14px; background: var(--card); box-shadow: 7px 0 10px rgba(77, 61, 45, .035); }
.timeline-food__name { font-size: .88rem; font-weight: 800; }
.timeline-food__detail { color: var(--muted); font-size: .68rem; }
.timeline-food__detail.is-pending { color: var(--accent); font-weight: 800; }
.timeline-cell { display: grid; place-items: center; min-width: 0; padding: 0; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; font: inherit; }
.timeline-cell--record { cursor: pointer; }
.timeline-cell--record:hover, .timeline-cell--record:focus-visible { background: #fff5eb; outline: none; }
.timeline-cell--record:focus-visible { box-shadow: inset 0 0 0 2px #c68467; }
.timeline-dot { display: block; width: 14px; height: 14px; border-radius: 50%; }
.timeline-dot--empty { background: var(--empty); }
.timeline-dot--new { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.timeline-dot--eaten { background: var(--sage); box-shadow: 0 0 0 3px var(--sage-soft); }

.empty-state { margin: 0; padding: 22px 18px; color: var(--muted); font-size: .9rem; }

.master-summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.master-stat { padding: 8px 11px; border-radius: 10px; color: var(--muted); background: #eee8df; font-size: .78rem; }
.master-stat strong { color: var(--ink); }
.master-stat--result { color: #45604c; background: var(--sage-soft); }
.master-controls { margin-bottom: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255, 253, 249, .78); box-shadow: var(--shadow); }
.master-filter-row { display: grid; grid-template-columns: 74px minmax(0, 1fr); align-items: start; gap: 10px; }
.master-control-label { padding-top: 7px; color: var(--muted); font-size: .72rem; font-weight: 800; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.filter-chip { min-height: 34px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: #fffdf9; font: inherit; font-size: .76rem; font-weight: 700; cursor: pointer; }
.filter-chip span { margin-left: 3px; opacity: .72; font-size: .68rem; }
.filter-chip.is-active { border-color: var(--accent); color: #7c3d28; background: var(--accent-soft); }
.master-list { display: grid; gap: 10px; }
.master-group { overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: rgba(255, 253, 249, .72); }
.master-group summary { cursor: pointer; padding: 13px 15px; font-weight: 800; list-style: none; }
.master-group summary::-webkit-details-marker { display: none; }
.master-group summary::after { float: right; content: "+"; color: var(--muted); font-weight: 400; }
.master-group[open] summary::after { content: "−"; }
.master-items { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 0 12px 13px; }
.master-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 58px; padding: 9px 10px; border-radius: 10px; background: #f5f0e9; font-size: .83rem; }
.master-item__names { display: grid; min-width: 0; gap: 3px; }
.master-item__name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 750; }
.master-item__english { min-width: 0; overflow: hidden; color: var(--muted); font-size: .68rem; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.master-item__meta { display: flex; flex-shrink: 0; align-items: center; gap: 4px; }
.record-pill { display: inline-flex; align-items: center; padding: 4px 7px; border-radius: 999px; color: #45604c; background: var(--sage-soft); font-size: .62rem; font-weight: 800; white-space: nowrap; }
.flag { display: inline-flex; width: 20px; height: 20px; align-items: center; justify-content: center; border-radius: 999px; color: var(--gold); background: var(--gold-soft); font-size: .69rem; font-weight: 800; }
.flag--watch { color: #9a6332; background: #f4e7d8; }
.master-edit-button { padding: 3px 6px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: #fffdf9; font: inherit; font-size: .62rem; cursor: pointer; }
.master-edit-button:hover, .master-edit-button:focus-visible { border-color: #d9b5a3; color: #7c3d28; background: var(--accent-soft); outline: none; }

.composite-catalog {
  display: grid;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 253, 249, .84);
}
.composite-catalog__heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.composite-catalog__title { display: flex; align-items: baseline; gap: 7px; }
.composite-catalog__title strong { font-size: .92rem; }
.composite-catalog__title span { color: var(--muted); font-size: .7rem; }
.composite-catalog__create {
  min-height: 32px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #7c3d28;
  background: var(--accent-soft);
  font: inherit;
  font-size: .7rem;
  font-weight: 800;
  cursor: pointer;
}
.composite-catalog__create:hover,
.composite-catalog__create:focus-visible { border-color: #d9b5a3; background: #fbf1e9; outline: none; }
.composite-catalog__items { display: grid; gap: 7px; }
.composite-catalog-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 9px 10px;
  border-radius: 10px;
  background: #f5f0e9;
}
.composite-catalog-item__body { display: grid; min-width: 0; gap: 2px; }
.composite-catalog-item__name { overflow: hidden; font-size: .83rem; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.composite-catalog-item__english { overflow: hidden; color: var(--muted); font-size: .68rem; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.composite-catalog-item__summary { color: var(--muted); font-size: .68rem; line-height: 1.45; white-space: normal; overflow-wrap: anywhere; }
.composite-catalog__empty { margin: 0; padding: 6px 2px 2px; color: var(--muted); font-size: .78rem; }

.page-footer { margin-top: 42px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: .76rem; line-height: 1.6; }

@media (max-width: 680px) {
  .shell { width: min(100% - 24px, 1080px); padding-top: 20px; }
  .section-heading { align-items: start; }
  .food-timeline { grid-template-columns: minmax(96px, 1fr) repeat(var(--day-count), 34px); min-width: 572px; }
  .timeline-food-header { padding-right: 8px; padding-left: 8px; }
  .timeline-food { padding-right: 8px; padding-left: 8px; }
}

@media (max-width: 410px) {
  .summary-block { padding: 13px; }
  .master-items { grid-template-columns: 1fr; }
  .master-filter-row { grid-template-columns: 1fr; gap: 5px; }
  .master-control-label { padding-top: 0; }
}
