:root {
  --paper: #faf7f1;
  --paper-deep: #f1ebdf;
  --white: #ffffff;
  --ink: #121e18;
  --pine: #16382a;
  --brand-deep: #1a5c3e;
  --green: #2e8757;
  --green-soft: #7bcfa1;
  --green-pale: #e9f3ec;
  --soil: #a98c79;
  --line: #e2daca;
  --line-strong: #d8d0be;
  --text: #28302b;
  --text-light: #6b7268;
  --text-xlight: #6d7368;
  --shadow: 0 18px 38px rgba(18, 30, 24, 0.08);
  /* 朝昼夜間食の識別色（カレンダーのドット・タブ・スロット共通） */
  --meal-asa: #d98a1f;
  --meal-hiru: #2e8757;
  --meal-yoru: #46568f;
  --meal-kan: #b0488a;
  --font: "Noto Sans JP", sans-serif;
  --font-display: "Shippori Mincho", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --font-serif-en: "Cormorant Garamond", "Times New Roman", serif;
  --radius: 2px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(620px 280px at 50% -120px, rgba(123, 207, 161, 0.16), transparent 68%),
    linear-gradient(180deg, var(--paper) 0%, var(--paper-deep) 100%);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.8;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

::selection {
  color: #ffffff;
  background: var(--brand-deep);
}

.app-shell {
  width: min(560px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 56px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
}

.brand-block {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}

.account-button {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink);
  background: var(--paper);
}

.account-button svg {
  display: block;
}

.app-footer {
  margin: 22px 0 4px;
  text-align: center;
  color: var(--text-light);
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.brand-block .hero-label {
  margin: 0;
  line-height: 1.1;
}

.brand-block h1 {
  margin: 0;
  line-height: 1.12;
  font-family: var(--font);
  font-weight: 900;
  letter-spacing: 0.005em;
}

.hero-label,
.eyebrow {
  margin: 0;
  color: var(--brand-deep);
  font-family: var(--font-serif-en);
  font-size: 1.18rem;
  font-style: italic;
  font-weight: 400;
}

h1,
h2 {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: 0;
}

h1 {
  margin-top: 4px;
  font-size: 1.74rem;
}

h2 {
  font-size: 1.3rem;
}

.hero-label,
.eyebrow {
  font-size: 1.02rem;
}

.hero-sub {
  margin: 12px 0 0;
  color: var(--text-light);
  font-size: 0.94rem;
  font-weight: 300;
}

.header-media {
  position: relative;
  min-height: 220px;
  background: var(--paper-deep);
}

.header-media::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(250, 247, 241, 0.28), transparent 38%),
    linear-gradient(180deg, transparent 62%, rgba(18, 30, 24, 0.12));
  pointer-events: none;
}

.header-media img {
  width: 100%;
  height: 100%;
  min-height: 220px;
  display: block;
  object-fit: cover;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.92fr) minmax(0, 1.08fr);
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 14px 32px rgba(18, 30, 24, 0.05);
  padding: 24px;
}

.record-panel {
  grid-row: span 2;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.month-heading {
  align-items: center;
}

.today-count,
.menu-total {
  min-width: 52px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(26, 92, 62, 0.25);
  border-radius: 999px;
  color: var(--brand-deep);
  background: var(--green-pale);
  font-size: 0.86rem;
  font-weight: 700;
  white-space: nowrap;
}

.record-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field span,
.field legend,
.section-title {
  color: var(--text-light);
  font-size: 0.84rem;
  font-weight: 700;
}

.field legend {
  margin: 0 0 7px;
  padding: 0;
}

.meal-field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.full-field {
  grid-column: 1 / -1;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 11px 13px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.92);
  outline: none;
}

input::placeholder {
  color: var(--text-xlight);
}

/* iOS等のネイティブ月/日付入力は固有の最小幅でコンテナをはみ出すことがある。見た目を通常の入力に揃え、はみ出しを防ぐ。 */
input[type="month"],
input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  min-width: 0;
  max-width: 100%;
  text-align: left;
}

input:focus-visible,
select:focus-visible {
  border-color: var(--brand-deep);
  box-shadow: 0 0 0 3px rgba(46, 135, 87, 0.14);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='10' viewBox='0 0 15 10'%3E%3Cpath d='M1.5 1.5l6 6 6-6' fill='none' stroke='%231A5C3E' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 15px center;
  background-size: 15px 10px;
  padding-right: 40px;
}

/* datalist の入力欄に出るブラウザ標準の矢印は隠す（候補は下のリストから選ぶ） */
input[list]::-webkit-calendar-picker-indicator {
  display: none !important;
}

/* 記録方法のまとまり（「登録から選ぶ」と「新しく入力」を別ブロックに） */
.add-method {
  display: grid;
  gap: 10px;
}

.method-hint {
  margin: -4px 0 0;
  color: var(--text-xlight);
  font-size: 0.78rem;
}

/* 2つの記録方法を視覚的に分ける「または」区切り */
.add-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0;
  color: var(--text-xlight);
  font-size: 0.76rem;
  font-weight: 700;
}

.add-divider::before,
.add-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* 「新しい献立を入力して記録」の見出し・入力・量・記録ボタンを一つの枠に */
.new-entry {
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand-deep);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.55);
}

.new-entry > .sheet-subtitle {
  margin-top: 0;
  color: var(--brand-deep);
}

/* 入力中のサジェスト（登録済みの食品・食材から選ばせる導線） */
.suggest-wrap {
  position: relative;
}

.sheet-suggest {
  margin-top: 6px;
  display: grid;
  gap: 2px;
  max-height: 240px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.97);
}

.sheet-suggest[hidden] {
  display: none;
}

.suggest-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 40px;
  padding: 8px 11px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  text-align: left;
  font: inherit;
}

.suggest-item:hover,
.suggest-item:focus-visible {
  background: var(--green-pale);
}

.suggest-name {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--ink);
  font-weight: 700;
  font-size: 0.92rem;
}

.suggest-sub {
  flex: 0 0 auto;
  color: var(--text-light);
  font-size: 0.76rem;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  overflow: hidden;
  min-height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
}

.segment {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 0;
  border: 0;
  border-right: 1px solid var(--line);
  color: var(--text-light);
  background: transparent;
  font-weight: 700;
}

.segment:last-child {
  border-right: 0;
}

/* 各時間帯の識別ドット（カレンダーと同じ色） */
.seg-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.seg-asa .seg-dot { background: var(--meal-asa); }
.seg-hiru .seg-dot { background: var(--meal-hiru); }
.seg-yoru .seg-dot { background: var(--meal-yoru); }
.seg-kan .seg-dot { background: var(--meal-kan); }

/* 選択中はその時間帯の色で塗る */
.segment.is-active { color: #ffffff; }
.segment.is-active .seg-dot { background: rgba(255, 255, 255, 0.9); }
.segment.is-active.seg-asa { background: var(--meal-asa); }
.segment.is-active.seg-hiru { background: var(--meal-hiru); }
.segment.is-active.seg-yoru { background: var(--meal-yoru); }
.segment.is-active.seg-kan { background: var(--meal-kan); }

.input-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 102px;
  gap: 10px;
}

.form-secondary-actions {
  display: flex;
  justify-content: flex-end;
}

.save-menu-button {
  min-width: 160px;
}

.primary-button,
.secondary-button,
.icon-button,
.mini-button {
  min-height: 46px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  font-weight: 700;
  white-space: nowrap;
}

.primary-button {
  color: #ffffff;
  background: var(--brand-deep);
}

.secondary-button {
  min-width: 144px;
  color: var(--brand-deep);
  background: var(--paper);
  border-color: var(--brand-deep);
}

.mini-button {
  min-height: 34px;
  padding: 0 10px;
  color: var(--brand-deep);
  background: var(--green-pale);
  border-color: rgba(26, 92, 62, 0.16);
}

.icon-button {
  width: 36px;
  height: 36px;
  min-height: 36px;
  color: var(--brand-deep);
  background: #fbf6f2;
  border-color: rgba(169, 140, 121, 0.28);
}

.ingredient-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 12px 0 10px;
}

.ingredient-tools span {
  color: var(--text-light);
  font-size: 0.78rem;
  font-weight: 700;
}

.ingredient-rows {
  display: grid;
  gap: 8px;
}

.ingredient-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 90px 94px 36px;
  gap: 8px;
  align-items: center;
}

.ingredient-row input,
.ingredient-row select {
  min-height: 40px;
}

.primary-button:hover,
.secondary-button:hover,
.mini-button:hover,
.icon-button:hover,
.chip-button:hover {
  transform: translateY(-1px);
}

.primary-button:focus-visible,
.secondary-button:focus-visible,
.mini-button:focus-visible,
.icon-button:focus-visible,
.chip-button:focus-visible,
.segment:focus-visible {
  outline: 3px solid rgba(46, 135, 87, 0.2);
  outline-offset: 2px;
}

.quick-area {
  margin-top: 22px;
}

.section-title {
  margin-bottom: 9px;
}

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-grid .empty-state {
  width: 100%;
}

.chip-button {
  min-height: 38px;
  max-width: 100%;
  border: 1px solid rgba(26, 92, 62, 0.16);
  border-radius: 999px;
  padding: 0 13px;
  color: var(--brand-deep);
  background: var(--green-pale);
  font-weight: 700;
}

.month-picker input {
  min-width: 148px;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.summary-strip > div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: rgba(250, 247, 241, 0.76);
}

.summary-label {
  display: block;
  color: var(--text-light);
  font-size: 0.78rem;
  font-weight: 700;
}

.summary-strip strong {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nutrition-date {
  min-width: 72px;
  color: var(--text-light);
  font-size: 0.84rem;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}

.advice-box {
  border-left: 3px solid var(--brand-deep);
  padding: 12px 14px;
  margin-bottom: 16px;
  color: var(--ink);
  background: rgba(233, 243, 236, 0.62);
  font-size: 0.92rem;
  line-height: 1.8;
}

.macro-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.macro-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: rgba(250, 247, 241, 0.64);
}

.macro-top,
.nutrient-main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.macro-top span,
.nutrient-main span {
  color: var(--text-light);
  font-size: 0.82rem;
  font-weight: 700;
}

.macro-top strong {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.18rem;
  font-weight: 600;
  white-space: nowrap;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  margin: 10px 0 8px;
  border-radius: 999px;
  background: rgba(226, 218, 202, 0.74);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  max-width: 100%;
  border-radius: inherit;
  background: var(--brand-deep);
}

.progress-track.small {
  height: 6px;
  margin: 8px 0 5px;
}

.macro-card.is-low .progress-track span,
.nutrient-row.is-low .progress-track span {
  background: #a98c79;
}

.macro-card.is-high .progress-track span,
.nutrient-row.is-high .progress-track span {
  background: #9f4f3f;
}

.macro-meta,
.nutrient-meta,
.record-sub,
.data-note {
  color: var(--text-light);
  font-size: 0.76rem;
  line-height: 1.6;
}

.subnutrient-area {
  margin-top: 4px;
}

.nutrient-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 9px;
}

.nutrient-row {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: rgba(255, 255, 255, 0.72);
}

.nutrient-main strong {
  color: var(--ink);
  font-size: 0.9rem;
  white-space: nowrap;
}

.data-note {
  margin: 14px 0 0;
}

.profile-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.profile-save {
  justify-self: start;
}

.toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 14px;
}

.records-list,
.menu-list {
  display: grid;
  gap: 8px;
}

.date-group {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.date-group:first-child {
  border-top: 0;
  padding-top: 0;
}

.date-title {
  margin: 0 0 8px;
  color: var(--brand-deep);
  font-size: 0.88rem;
  font-weight: 700;
}

.record-row,
.menu-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  background: rgba(255, 255, 255, 0.88);
}

.record-meta {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
}

.record-copy,
.menu-copy {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.meal-badge {
  flex: 0 0 auto;
  min-width: 42px;
  border-radius: 999px;
  padding: 4px 8px;
  color: #ffffff;
  background: var(--brand-deep);
  font-size: 0.76rem;
  font-weight: 700;
  text-align: center;
}

.record-name,
.menu-name {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-weight: 700;
}

.menu-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.empty-state {
  min-height: 96px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--text-light);
  background: rgba(250, 247, 241, 0.48);
  text-align: center;
  font-weight: 700;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 10;
  max-width: calc(100% - 32px);
  min-height: 42px;
  transform: translate(-50%, 20px);
  border-radius: 999px;
  padding: 10px 16px;
  color: #ffffff;
  background: rgba(18, 30, 24, 0.94);
  box-shadow: 0 12px 28px rgba(18, 30, 24, 0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  font-weight: 700;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

.toast:not(.is-visible) {
  pointer-events: none;
}

.toast .toast-text {
  display: inline-block;
  vertical-align: middle;
}

.toast .toast-action {
  margin-left: 12px;
  padding: 4px 10px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 999px;
  background: transparent;
  color: var(--green-soft);
  font: inherit;
  font-weight: 700;
  vertical-align: middle;
}

/* ===== Home primary action + first-run guidance ===== */
.today-cta {
  width: 100%;
  margin: 0;
  min-height: 52px;
  font-size: 1.02rem;
}

.home-intro {
  margin: 0;
  padding: 14px 16px;
  border: 0;
  background: rgba(233, 243, 236, 0.5);
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.8;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===== Calendar ===== */
.calendar-panel {
  grid-column: 1 / -1;
}

.calendar-heading {
  align-items: center;
}

.calendar-nav {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.calendar-label {
  min-width: 132px;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.06rem;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
}

.cal-step {
  font-size: 1.2rem;
  line-height: 1;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 6px;
}

.calendar-weekdays span {
  padding: 4px 0;
  color: var(--text-light);
  font-size: 0.74rem;
  font-weight: 700;
  text-align: center;
}

.calendar-weekdays span.is-sat {
  color: #3f6f9f;
}

.calendar-weekdays span.is-sun {
  color: #9f4f3f;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.calendar-day {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 74px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.78);
  text-align: left;
  overflow: hidden;
}

.calendar-day.is-empty {
  border-color: transparent;
  background: transparent;
  cursor: default;
}

.calendar-day.has-records {
  background: rgba(233, 243, 236, 0.5);
}

.calendar-day.is-today {
  border-color: var(--brand-deep);
  box-shadow: inset 0 0 0 1.5px var(--brand-deep);
  background: rgba(233, 243, 236, 0.4);
}

.calendar-day.is-selected {
  border-color: var(--brand-deep);
  box-shadow: inset 0 0 0 2px var(--brand-deep);
  background: rgba(233, 243, 236, 0.85);
}

.calendar-day .day-num {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-light);
}

.calendar-day.is-today .day-num {
  color: var(--brand-deep);
}

.calendar-day.is-sat .day-num {
  color: #3f6f9f;
}

.calendar-day.is-sun .day-num {
  color: #9f4f3f;
}

.day-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.day-thumbs img {
  width: 22px;
  height: 22px;
  border-radius: 3px;
  object-fit: cover;
  background: var(--paper-deep);
}

/* 朝昼夜間食の4スロットを色ドットで。点灯＝記録あり、淡色＝未記録。4つ揃えば漏れなし */
.day-dots {
  display: flex;
  gap: 3px;
  margin-top: auto;
  justify-content: center;
}

.day-dots .md {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(18, 30, 24, 0.1);
  transition: background 120ms ease;
}

.day-dots .md.is-on.md-asa { background: var(--meal-asa); }
.day-dots .md.is-on.md-hiru { background: var(--meal-hiru); }
.day-dots .md.is-on.md-yoru { background: var(--meal-yoru); }
.day-dots .md.is-on.md-kan { background: var(--meal-kan); }

/* 時間帯ドットの凡例 */
.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 12px 0 0;
}

.cal-legend .lg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-light);
  font-size: 0.78rem;
  font-weight: 700;
}

.cal-legend .lg::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
}

.cal-legend .lg-asa::before { background: var(--meal-asa); }
.cal-legend .lg-hiru::before { background: var(--meal-hiru); }
.cal-legend .lg-yoru::before { background: var(--meal-yoru); }
.cal-legend .lg-kan::before { background: var(--meal-kan); }

.calendar-hint {
  margin: 10px 0 0;
  color: var(--text-light);
  font-size: 0.78rem;
}

/* ===== Photo picker (form) ===== */
.photo-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.photo-add-button,
.backup-import-label {
  cursor: pointer;
}

.photo-add-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  border: 1px dashed var(--brand-deep);
  border-radius: var(--radius);
  color: var(--brand-deep);
  background: var(--green-pale);
  font-weight: 700;
}

.photo-pending,
.photo-card-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.photo-thumb {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--paper-deep);
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}

.photo-thumb .thumb-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  min-height: 20px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: rgba(18, 30, 24, 0.72);
  font-size: 0.8rem;
  line-height: 1;
}

.memo-input {
  width: 100%;
  min-height: 56px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.92);
  outline: none;
  resize: vertical;
  line-height: 1.7;
  font-family: var(--font);
}

.memo-input:focus-visible {
  border-color: var(--brand-deep);
  box-shadow: 0 0 0 3px rgba(46, 135, 87, 0.14);
}

/* ===== Settings ===== */
.week-field {
  margin: 0 0 16px;
  padding: 0;
  border: 0;
}

.week-start {
  grid-template-columns: repeat(2, 1fr);
  max-width: 240px;
}

.backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.backup-import-label {
  display: inline-flex;
}

/* ===== Day sheet ===== */
.sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(18, 30, 24, 0.42);
  backdrop-filter: blur(2px);
}

.sheet-overlay[hidden] {
  display: none;
}

.sheet-panel {
  width: min(560px, 100%);
  max-height: min(86vh, 760px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 28px 64px rgba(18, 30, 24, 0.28);
  overflow: hidden;
}

.sheet-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
}

.sheet-header h2 {
  font-size: 1.3rem;
}

.sheet-body {
  padding: 18px 22px 24px;
  overflow-y: auto;
}

.sheet-section-title {
  margin: 18px 0 9px;
  color: var(--brand-deep);
  font-size: 0.84rem;
  font-weight: 700;
}

.sheet-section-title:first-child {
  margin-top: 0;
}

.sheet-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}

.sheet-summary .chip-stat {
  flex: 1 1 0;
  min-width: 64px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  background: rgba(250, 247, 241, 0.7);
  text-align: center;
}

.sheet-summary .chip-stat span {
  display: block;
  color: var(--text-light);
  font-size: 0.72rem;
  font-weight: 700;
}

.sheet-summary .chip-stat strong {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 600;
}

.sheet-quick {
  display: grid;
  gap: 10px;
  margin-bottom: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.74);
}

.sheet-quick .input-action {
  grid-template-columns: minmax(0, 1fr) 92px;
}

.sheet-record {
  display: grid;
  gap: 8px;
  padding: 12px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
}

.sheet-record-top {
  display: flex;
  align-items: center;
  gap: 9px;
}

.sheet-record-top .record-copy {
  flex: 1 1 auto;
}

.sheet-record .record-memo {
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.mini-button.is-soft {
  color: var(--text-light);
  background: rgba(250, 247, 241, 0.8);
  border-color: var(--line);
}

.memo-edit {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 8px 10px;
  background: #fff;
  outline: none;
  resize: vertical;
  font-family: var(--font);
}

.sheet-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-light);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(250, 247, 241, 0.48);
}

/* ===== Lightbox ===== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: rgba(12, 18, 14, 0.9);
}

.lightbox[hidden] {
  display: none;
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  font-size: 1.3rem;
  line-height: 1;
}

@media (max-width: 860px) {
  .calendar-day {
    min-height: 60px;
  }

  .day-thumbs img {
    width: 18px;
    height: 18px;
  }
}

/* ===== Home ===== */
.home {
  margin-top: 0;
}

.account-button:focus-visible {
  outline: 3px solid rgba(46, 135, 87, 0.2);
  outline-offset: 2px;
}

/* ===== Account overlay ===== */
.account-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(18, 30, 24, 0.42);
  backdrop-filter: blur(2px);
}

.account-overlay[hidden] {
  display: none;
}

.account-panel {
  width: min(560px, 100%);
  max-height: min(90vh, 820px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 28px 64px rgba(18, 30, 24, 0.28);
  overflow: hidden;
}

.account-body {
  padding: 18px 22px 24px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  overflow-y: auto;
}

.account-section {
  margin-bottom: 16px;
  padding: 18px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.62);
}

.account-h {
  margin: 0 0 6px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 600;
  color: var(--ink);
}

.account-note {
  margin: 0 0 12px;
  color: var(--text-light);
  font-size: 0.82rem;
  line-height: 1.75;
}

.account-disclaimer {
  margin: 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--text-light);
  font-size: 0.78rem;
  line-height: 1.75;
}

.profile-basics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.choice-group {
  margin-bottom: 18px;
}

.choice-legend {
  margin: 0 0 8px;
  color: var(--text-light);
  font-size: 0.84rem;
  font-weight: 700;
}

.choice-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.8);
  cursor: pointer;
}

.choice-card input {
  width: auto;
  min-height: 0;
  margin-top: 3px;
  accent-color: var(--brand-deep);
}

.choice-text {
  display: grid;
  gap: 1px;
}

.choice-main {
  color: var(--ink);
  font-weight: 700;
}

.choice-reason {
  color: var(--text-light);
  font-size: 0.8rem;
}

.choice-card:has(input:checked) {
  border-color: var(--brand-deep);
  background: var(--green-pale);
}

.profile-basics + .choice-group #profile-form button,
#profile-form .primary-button {
  width: 100%;
  margin-top: 4px;
}

.data-actions {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

/* ===== Sheet accordions ===== */
.sheet-acc {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.74);
  margin-bottom: 12px;
  overflow: hidden;
}

.sheet-acc > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 14px;
  font-weight: 700;
  color: var(--brand-deep);
}

.sheet-acc > summary::-webkit-details-marker {
  display: none;
}

.sheet-acc > summary::after {
  content: "";
  flex: 0 0 auto;
  width: 15px;
  height: 10px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='10' viewBox='0 0 15 10'%3E%3Cpath d='M1.5 1.5l6 6 6-6' fill='none' stroke='%231A5C3E' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center;
  background-size: 15px 10px;
  transition: transform 150ms ease;
}

.sheet-acc[open] > summary::after {
  transform: rotate(180deg);
}

.acc-title {
  font-family: var(--font-display);
  font-size: 1.02rem;
}

.summary-flex {
  display: flex;
  align-items: center;
  gap: 8px;
}

.acc-sub {
  margin-left: auto;
  color: var(--text-light);
  font-weight: 700;
  font-size: 0.86rem;
}

/* 未計上（DBに無い食品）の警告バッジ。総量が実際より少なく見える事故を防ぐ */
.acc-warn {
  margin-left: auto;
  flex: 0 0 auto;
  padding: 2px 8px;
  border-radius: 999px;
  color: #9a4a2f;
  background: rgba(154, 74, 47, 0.12);
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.acc-warn + .acc-sub {
  margin-left: 8px;
}

.nutrition-warn {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(154, 74, 47, 0.28);
  border-left: 3px solid #9a4a2f;
  border-radius: var(--radius);
  background: rgba(154, 74, 47, 0.07);
  color: #7e3c25;
  font-size: 0.82rem;
  line-height: 1.6;
}

/* カテゴリ平均でおおよそ計算した食品のお知らせ（未計上より穏やかな情報トーン） */
.nutrition-est {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--meal-asa);
  border-radius: var(--radius);
  background: rgba(211, 149, 36, 0.06);
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.6;
}

.nutrition-list-names {
  display: inline-block;
  margin: 4px 0;
  font-weight: 700;
}

.acc-body {
  padding: 2px 14px 16px;
  display: grid;
  gap: 12px;
}

.sheet-acc.sub {
  background: rgba(250, 247, 241, 0.72);
}

.sheet-subtitle {
  color: var(--text-light);
  font-size: 0.82rem;
  font-weight: 700;
  margin-top: 2px;
}

/* ===== Slot blocks ===== */
/* ===== Day records as compact chips ===== */
.record-chips {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.chip-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 時間帯ラベルは色付きの丸バッジ（カレンダーのドット・タブと同じ色体系） */
.chip-slot {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.8rem;
}

.chip-slot.slot-asa { background: var(--meal-asa); }
.chip-slot.slot-hiru { background: var(--meal-hiru); }
.chip-slot.slot-yoru { background: var(--meal-yoru); }
.chip-slot.slot-kan { background: var(--meal-kan); }
.chip-slot.slot-other { background: var(--text-light); }

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.record-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 5px 5px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
}

.record-chip-name {
  color: var(--ink);
  font-weight: 700;
  font-size: 0.9rem;
}

.record-chip-amt {
  color: var(--text-light);
  font-size: 0.76rem;
}

.chip-x {
  width: 24px;
  height: 24px;
  min-height: 24px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--radius);
  color: var(--text-light);
  background: rgba(250, 247, 241, 0.9);
  font-size: 0.95rem;
  line-height: 1;
}

.record-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

/* ===== Ingredient palette (tap to add) ===== */
.ingredient-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 140px;
  overflow-y: auto;
  margin: 4px 0 10px;
  padding: 2px;
}

/* ===== Day-sheet menu selection list ===== */
.sheet-menu-search {
  width: 100%;
  margin-bottom: 8px;
}

/* 登録した献立はパネル（チップ）式で折り返し、小さい画面でも一覧しやすく */
.sheet-menu-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
  padding: 2px;
}

.sheet-menu-item {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  width: auto;
  max-width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  text-align: left;
  font: inherit;
  line-height: 1.3;
}

.sheet-menu-item .menu-name {
  color: var(--ink);
  font-weight: 700;
  font-size: 0.92rem;
  line-height: 1.3;
}

.sheet-menu-item .menu-amt {
  flex: 0 0 auto;
  color: var(--text-light);
  font-size: 0.76rem;
  line-height: 1.3;
}

.sheet-menu-item:hover {
  border-color: var(--brand-deep);
}

.amount-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 116px;
  gap: 8px;
}

.field-hint {
  color: var(--text-light);
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.5;
}

.add-record-button {
  width: 100%;
}

.memo-editor {
  display: grid;
  gap: 8px;
}

/* ===== Safe area for the bottom sheet ===== */
.sheet-body {
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}

/* ===== Focus rings for added controls ===== */
.photo-add-button:focus-visible,
.js-file-label:focus-visible,
.sheet-menu-item:focus-visible,
.calendar-day:focus-visible {
  outline: 3px solid rgba(46, 135, 87, 0.2);
  outline-offset: 2px;
}

/* ===== Touch targets (>= 44px on touch devices) ===== */
@media (pointer: coarse) {
  .mini-button {
    min-height: 44px;
  }

  .icon-button {
    width: 44px;
    height: 44px;
    min-height: 44px;
  }

  .photo-add-button {
    min-height: 44px;
  }

  .thumb-remove {
    width: 28px;
    height: 28px;
    min-height: 28px;
  }
}

@media (max-width: 520px) {
  .sheet-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .sheet-panel {
    width: 100%;
    max-height: 92vh;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    border-radius: 14px 14px 0 0;
  }

  .calendar-grid {
    gap: 4px;
  }

  .calendar-weekdays {
    gap: 4px;
  }

  .calendar-day {
    min-height: 52px;
    padding: 4px;
  }

  .calendar-day .day-num {
    font-size: 0.76rem;
  }

  .day-thumbs img {
    width: 15px;
    height: 15px;
  }

  .calendar-heading {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .calendar-nav {
    justify-content: space-between;
  }

  .calendar-label {
    flex: 1;
    min-width: 0;
    font-size: 0.98rem;
  }

  .week-start {
    max-width: none;
  }

  .backup-actions .secondary-button,
  .backup-import-label {
    flex: 1 1 100%;
    width: 100%;
  }
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 20px, 680px);
    padding-top: 10px;
  }

  h1 {
    font-size: 1.7rem;
  }
}

@media (max-width: 520px) {
  .app-shell {
    width: 100%;
    padding: 0 0 24px;
  }

  .app-header,
  .panel {
    border-left: 0;
    border-right: 0;
  }

  .app-header {
    min-height: 0;
    padding: 16px 18px;
  }

  h1 {
    margin-top: 4px;
    font-size: 1.6rem;
  }

  h2 {
    font-size: 1.2rem;
  }

  .hero-label,
  .eyebrow {
    font-size: 0.96rem;
  }

  .home {
    margin-top: 0;
  }

  .panel {
    padding: 20px 18px;
  }

  .account-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .account-panel {
    width: 100%;
    max-height: 92vh;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    border-radius: 14px 14px 0 0;
  }

  .panel-heading {
    margin-bottom: 14px;
  }

  .record-form {
    gap: 12px;
  }

  input,
  select,
  .segmented,
  .primary-button,
  .secondary-button {
    min-height: 44px;
  }

  .record-form {
    grid-template-columns: 1fr;
  }

  .ingredient-tools {
    align-items: flex-start;
    flex-direction: column;
  }

  .ingredient-row {
    grid-template-columns: minmax(0, 1fr) 86px 38px;
  }

  .ingredient-row .ingredient-name {
    grid-column: 1 / -1;
  }

  .ingredient-row .ingredient-unit {
    grid-column: 2 / 3;
  }

  .input-action {
    grid-template-columns: 1fr;
  }

  .form-secondary-actions,
  .save-menu-button {
    width: 100%;
  }

  .primary-button {
    width: 100%;
  }

  .summary-strip {
    grid-template-columns: 1fr;
  }

  .macro-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nutrient-list,
  .profile-form {
    grid-template-columns: 1fr;
  }

  .profile-save {
    width: 100%;
  }

  .panel-heading {
    align-items: flex-start;
  }

  .month-heading {
    display: grid;
  }

  .month-picker input {
    min-width: 0;
  }
}
