/* ══════════════════════════════════════════
   ミラログ — warm ivory × terracotta rose
   ══════════════════════════════════════════ */
:root {
  --cream: #FAF4EC;
  --cream-deep: #F3EADD;
  --card: #FFFDF9;
  --ink: #453A31;
  --muted: #A08F80;
  --rose: #C97C6A;
  --rose-deep: #B05E4C;
  --rose-soft: #F2DAD2;
  --sage: #93A588;
  --sage-soft: #E4EADF;
  --line: #EDE1D3;
  --shadow: 0 6px 24px rgba(140, 110, 85, 0.10);
  --radius: 20px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

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

body {
  font-family: "Zen Maru Gothic", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(201, 124, 106, 0.08), transparent),
    radial-gradient(ellipse 70% 40% at 90% 10%, rgba(147, 165, 136, 0.08), transparent),
    var(--cream);
  min-height: 100dvh;
  line-height: 1.7;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
}

/* ── header ── */
.app-header {
  max-width: 480px;
  margin: 0 auto;
  padding: 22px 22px 6px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.logo {
  font-family: "Shippori Mincho", serif;
  font-weight: 600;
  font-size: 1.5rem;
  letter-spacing: 0.14em;
}
.tagline {
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.08em;
}
.icon-btn {
  border: none;
  background: none;
  font-size: 1.25rem;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
}

/* ── layout ── */
main { max-width: 480px; margin: 0 auto; padding: 10px 22px 30px; }
.view { animation: fadeUp 0.35s ease both; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.today-date {
  font-family: "Shippori Mincho", serif;
  font-size: 0.95rem;
  letter-spacing: 0.12em;
  color: var(--rose-deep);
  margin-top: 8px;
}
.greeting { font-size: 1.05rem; font-weight: 500; margin: 2px 0 18px; }

/* ── cards ── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 18px;
  border: 1px solid rgba(255, 255, 255, 0.6);
}
.card-label {
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  color: var(--rose);
  font-weight: 700;
  margin-bottom: 10px;
}

/* ── habit ── */
.habit-body { display: flex; gap: 14px; align-items: center; }
.habit-icon { font-size: 2.1rem; }
.habit-name { font-weight: 700; font-size: 1.05rem; }
.habit-why { font-size: 0.8rem; color: var(--muted); }
.habit-actions { display: flex; gap: 10px; margin-top: 16px; }
.habit-done-msg {
  margin-top: 14px;
  text-align: center;
  font-weight: 700;
  color: var(--rose-deep);
  animation: pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes pop {
  from { opacity: 0; transform: scale(0.7); }
  to   { opacity: 1; transform: scale(1); }
}
.habit-card.done .habit-actions { display: none; }

/* ── habit checklist ── */
.habit-item {
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
  border: none;
  background: none;
  font-family: inherit;
  text-align: left;
  padding: 10px 2px;
  border-bottom: 1px dashed var(--line);
  cursor: pointer;
}
.habit-item:last-child { border-bottom: none; }
.habit-item .h-icon { font-size: 1.4rem; }
.habit-item .h-text { display: flex; flex-direction: column; }
.habit-item .h-name { font-weight: 700; font-size: 0.9rem; color: var(--ink); }
.habit-item .h-why { font-size: 0.7rem; color: var(--muted); }
.habit-item .habit-q {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--cream-deep);
  border-radius: 999px;
  padding: 5px 10px;
}
.habit-item .check {
  flex-shrink: 0;
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid var(--line);
  color: transparent;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 700;
  transition: all 0.2s ease;
}
.habit-item.done .check {
  background: var(--sage);
  border-color: var(--sage);
  color: #fff;
  transform: scale(1.08);
}
.habit-item.done .h-name { color: var(--muted); }

.pool-cat {
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  color: var(--rose);
  font-weight: 700;
  margin: 16px 0 2px;
}
.pool-cat:first-child { margin-top: 4px; }

/* ── howto ── */
.howto-head {
  font-weight: 700;
  font-size: 1.05rem;
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 4px;
}
.howto-head span:first-child { font-size: 1.6rem; }
.howto-steps {
  margin: 12px 0 4px;
  padding-left: 1.4em;
  font-size: 0.88rem;
  display: grid;
  gap: 8px;
}
.howto-steps li::marker { color: var(--rose); font-weight: 700; }

/* ── review card ── */
.review-card {
  border: 1.5px solid var(--rose-soft);
  background: linear-gradient(150deg, #fff, var(--rose-soft) 160%);
}
.review-copy { font-size: 0.85rem; margin-bottom: 4px; }

/* ── meal insight ── */
.insight-row {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 0.85rem;
  padding: 7px 2px;
  border-bottom: 1px dashed var(--line);
}
.insight-row:last-child { border-bottom: none; }
.insight-row .cnt {
  font-family: "Shippori Mincho", serif;
  font-weight: 600;
}
.insight-row .cnt small {
  font-family: "Zen Maru Gothic";
  font-size: 0.68rem;
  font-weight: 400;
  color: var(--muted);
  margin-left: 6px;
}

/* ── week dots ── */
.week-dots { display: flex; justify-content: space-between; padding: 4px 6px; }
.week-dot { text-align: center; font-size: 0.68rem; color: var(--muted); }
.week-dot .dot {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 4px auto 0;
  background: var(--cream-deep);
  font-size: 0.85rem;
}
.week-dot.active .dot { background: var(--rose-soft); }
.week-dot.today .dot { outline: 2px solid var(--rose); outline-offset: 2px; }
.week-note { font-size: 0.8rem; color: var(--muted); margin-top: 10px; text-align: center; }

/* ── quick buttons ── */
.quick-label { margin: 22px 0 10px; }
.quick-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.quick-btn {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 6px;
  font-family: inherit;
  font-size: 1.4rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease;
}
.quick-btn:active { transform: scale(0.95); }
.quick-btn span {
  display: block;
  font-size: 0.72rem;
  color: var(--ink);
  font-weight: 500;
  margin-top: 4px;
}

/* ── buttons ── */
.btn {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  border: none;
  border-radius: 999px;
  padding: 11px 22px;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.96); }
.btn.primary {
  background: linear-gradient(135deg, var(--rose), var(--rose-deep));
  color: #fff;
  box-shadow: 0 4px 14px rgba(176, 94, 76, 0.35);
}
.btn.ghost {
  background: none;
  border: 1.5px solid var(--line);
  color: var(--muted);
}
.btn.danger { background: none; border: 1.5px solid #d9a49a; color: var(--rose-deep); }
.btn.small { padding: 7px 16px; font-size: 0.8rem; }
.btn.wide { width: 100%; }

/* ── section head ── */
.section-head { margin: 10px 0 18px; }
.section-head h2 {
  font-family: "Shippori Mincho", serif;
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.1em;
}
.section-sub { font-size: 0.76rem; color: var(--muted); margin-top: 4px; }

/* ── measures ── */
.measure-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.measure-head .card-label { margin-bottom: 0; }
.measure-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 9px 2px;
  border-bottom: 1px dashed var(--line);
}
.measure-row:last-child { border-bottom: none; }
.measure-row .m-name { font-size: 0.85rem; }
.measure-row .m-val {
  font-family: "Shippori Mincho", serif;
  font-size: 1.15rem;
  font-weight: 600;
}
.measure-row .m-val small { font-size: 0.7rem; color: var(--muted); font-family: "Zen Maru Gothic"; }
.m-delta { font-size: 0.75rem; font-weight: 700; margin-left: 8px; }
.m-delta.down { color: var(--sage); }
.m-delta.flat { color: var(--muted); }
.measure-empty { font-size: 0.8rem; color: var(--muted); padding: 6px 0; }

/* ── photos ── */
.photo-toolbar { display: flex; gap: 10px; margin-bottom: 12px; }
.photo-toolbar .primary { flex: 1; }
.compare-hint {
  font-size: 0.8rem; color: var(--rose-deep); font-weight: 700;
  text-align: center; margin-bottom: 10px;
}
.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.photo-cell {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 14px;
  overflow: hidden;
  border: none;
  padding: 0;
  cursor: pointer;
  background: var(--cream-deep);
}
.photo-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-cell .p-date {
  position: absolute; left: 0; right: 0; bottom: 0;
  font-size: 0.62rem;
  color: #fff;
  background: linear-gradient(transparent, rgba(60, 40, 30, 0.65));
  padding: 14px 6px 4px;
  text-align: left;
  font-family: "Shippori Mincho", serif;
  letter-spacing: 0.05em;
}
.photo-cell.selected { outline: 3px solid var(--rose); outline-offset: 2px; }
.photo-cell.selected::after {
  content: "✓";
  position: absolute; top: 6px; right: 6px;
  width: 22px; height: 22px;
  background: var(--rose);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 40px 20px;
  line-height: 2;
}
.empty-state .big { font-size: 2rem; display: block; margin-bottom: 6px; }

/* ── meals ── */
.preset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.preset-btn {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.12s ease;
  text-align: left;
}
.preset-btn:active { transform: scale(0.95); }
.preset-btn .pr-icon { font-size: 1.15rem; }
.preset-btn.just-added { animation: presetPop 0.5s ease; }
@keyframes presetPop {
  0%   { background: var(--rose-soft); transform: scale(0.95); }
  100% { background: var(--cream); transform: scale(1); }
}

.meal-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  padding: 8px 2px;
  border-bottom: 1px dashed var(--line);
}
.meal-row:last-child { border-bottom: none; }
.meal-row .time {
  font-family: "Shippori Mincho", serif;
  font-size: 0.72rem;
  color: var(--muted);
  min-width: 38px;
}
.meal-x {
  margin-left: auto;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 8px;
}

/* ── settings ── */
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  padding: 10px 0 14px;
}
.setting-row select {
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--ink);
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 10px;
}

.meal-day { margin-top: 20px; }
.meal-day-label {
  font-family: "Shippori Mincho", serif;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  color: var(--rose-deep);
  margin-bottom: 8px;
}
.meal-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.meal-strip .photo-cell { aspect-ratio: 1; }

/* ── modals ── */
.ml-overlay[hidden] { display: none; }
.ml-overlay {
  position: fixed; inset: 0;
  background: rgba(70, 50, 40, 0.45);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 50;
}
.ml-modal {
  background: var(--card);
  border-radius: 24px;
  padding: 24px;
  width: 100%;
  max-width: 420px;
  max-height: 86dvh;
  overflow-y: auto;
  animation: fadeUp 0.3s ease both;
}
.ml-modal h3 {
  font-family: "Shippori Mincho", serif;
  font-size: 1.1rem;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}
.ml-note { font-size: 0.78rem; color: var(--muted); margin-bottom: 14px; }
.ml-note.small { font-size: 0.7rem; margin-top: 12px; }
.ml-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

.measure-inputs label, .weight-details label {
  display: flex; align-items: center; gap: 10px;
  font-size: 0.85rem;
  padding: 8px 0;
}
.measure-inputs input, .weight-details input {
  margin-left: auto;
  width: 90px;
  font-family: "Shippori Mincho", serif;
  font-size: 1.05rem;
  text-align: right;
  border: none;
  border-bottom: 2px solid var(--line);
  background: none;
  padding: 4px 6px;
  color: var(--ink);
  outline: none;
}
.measure-inputs input:focus, .weight-details input:focus { border-color: var(--rose); }
.measure-inputs span, .weight-details span { font-size: 0.75rem; color: var(--muted); }
.weight-details { margin-top: 10px; }
.weight-details summary {
  font-size: 0.78rem; color: var(--muted); cursor: pointer;
  list-style-position: inside;
}

.photo-modal img {
  width: 100%;
  border-radius: 16px;
  max-height: 60dvh;
  object-fit: contain;
  background: var(--cream-deep);
}
.photo-date {
  font-family: "Shippori Mincho", serif;
  text-align: center;
  margin-top: 10px;
  letter-spacing: 0.1em;
  font-size: 0.9rem;
}

.compare-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.compare-pair figure { margin: 0; }
.compare-pair img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 14px;
  background: var(--cream-deep);
}
.compare-pair figcaption {
  font-family: "Shippori Mincho", serif;
  font-size: 0.75rem;
  text-align: center;
  margin-top: 6px;
  color: var(--muted);
  letter-spacing: 0.08em;
}
.compare-cheer {
  text-align: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--rose-deep);
  margin-top: 14px;
}

.settings-list { display: grid; gap: 10px; }

/* ── bottom nav ── */
.bottom-nav {
  position: fixed;
  left: 50%; bottom: calc(12px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  background: rgba(255, 253, 249, 0.92);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px;
  box-shadow: var(--shadow);
  z-index: 40;
}
.nav-btn {
  border: none;
  background: none;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  padding: 8px 20px;
  border-radius: 999px;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
}
.nav-btn .nav-icon { font-size: 1.15rem; }
.nav-btn.active { background: var(--rose-soft); color: var(--rose-deep); }
