:root {
  --bg: #FAF6EE;
  --surface: #FFFFFF;
  --surface-soft: #F1F0E8;
  --text-primary: #1F2A1F;
  --text-secondary: #5F6B5C;
  --text-muted: #8B9187;
  --border: #E4E0D4;
  --border-strong: #CFCABB;
  --green-deep: #2F5233;
  --green-mid: #5C8A5F;
  --green-soft: #E6EFE2;
  --green-soft-text: #2F5233;
  --accent-amber: #E8A33D;
  --accent-amber-soft: #FBEBD3;
  --accent-amber-text: #8A5A16;
  --danger: #C0503F;
  --danger-soft: #F7E5E1;
  --radius: 12px;
  --radius-pill: 999px;
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", -apple-system, sans-serif;
  padding-bottom: 76px;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 20px 20px 4px;
}
.date { font-size: 13px; color: var(--text-muted); margin: 0; }
h1 { font-size: 20px; font-weight: 700; margin: 2px 0 0; color: var(--green-deep); }

.icon-btn {
  border: none;
  background: transparent;
  font-size: 18px;
  color: var(--text-secondary);
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-pill);
}
.icon-btn:hover { background: var(--surface-soft); }

.arc-wrap { padding: 4px 24px 0; }
.arc-svg { display: block; }
.arc-times {
  display: flex;
  justify-content: space-between;
  margin-top: -8px;
  padding: 0 4px;
}
.arc-times span { font-size: 12px; color: var(--text-muted); }

.meal-tabs {
  display: flex;
  gap: 8px;
  padding: 8px 20px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.mtab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 4px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}
.mtab-icon { font-size: 18px; }
.mtab.active {
  background: var(--green-soft);
  border-color: var(--green-mid);
  color: var(--green-soft-text);
}

.panel { padding: 0 20px 20px; }
.label { font-size: 13px; color: var(--text-secondary); margin: 0 0 8px; font-weight: 500; }

.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.tag {
  font-size: 13px;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
}
.tag.on {
  background: var(--green-soft);
  border-color: var(--green-mid);
  color: var(--green-soft-text);
  font-weight: 500;
}

.input-row { display: flex; gap: 8px; margin-bottom: 20px; }
input[type="text"], input[type="password"] {
  flex: 1;
  height: 44px;
  padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 15px;
  color: var(--text-primary);
  width: 100%;
}
input:focus { outline: 2px solid var(--green-mid); outline-offset: 1px; }
.input-row .icon-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}

.primary-btn {
  width: 100%;
  height: 46px;
  border-radius: var(--radius);
  border: none;
  background: var(--green-deep);
  color: #FFFFFF;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.primary-btn:disabled { opacity: 0.6; cursor: default; }
.primary-btn:active:not(:disabled) { transform: scale(0.98); }

.results-list { display: flex; flex-direction: column; gap: 10px; }
.recipe-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.recipe-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
}
.recipe-name { font-size: 15px; font-weight: 700; margin: 0; }
.time-badge {
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--surface-soft);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  flex-shrink: 0;
}
.recipe-ingredients {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 12px;
  line-height: 1.6;
}
.link-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.link-chip {
  flex: 1;
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--surface-soft);
  border-radius: var(--radius-pill);
  padding: 7px 10px;
  text-decoration: none;
}
.link-chip:hover { background: var(--border); }

.card-actions { display: flex; gap: 8px; }
.secondary-btn {
  flex: 1;
  height: 36px;
  font-size: 13px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-primary);
  cursor: pointer;
}
.pick-btn {
  flex: 1;
  height: 36px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid var(--green-mid);
  background: var(--green-soft);
  color: var(--green-soft-text);
  cursor: pointer;
}

.error-text {
  font-size: 13px;
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 0;
}

.history-list { display: flex; flex-direction: column; gap: 8px; }
.empty-hint { font-size: 13px; color: var(--text-muted); margin: 0; }
.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
}
.history-item .h-meal { color: var(--text-muted); margin-right: 8px; }

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  justify-content: space-around;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
}
.nav-item span:first-child { font-size: 20px; }
.nav-item.active { color: var(--green-deep); font-weight: 500; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(31, 42, 31, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.modal-overlay[hidden] { display: none; }
.modal-sheet {
  background: var(--surface);
  width: 100%;
  max-width: 480px;
  border-radius: 20px 20px 0 0;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 16px; margin: 0; }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.modal-body ul, .modal-body ol { margin: 0 0 16px; padding-left: 20px; }
.modal-body li { font-size: 14px; line-height: 1.9; color: var(--text-primary); }
.hint-text { font-size: 12px; color: var(--text-muted); margin-top: 8px; }
.version-text {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 20px;
  text-align: center;
}
.modal-footer { padding: 12px 20px 20px; }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14170F;
    --surface: #1D2117;
    --surface-soft: #262B1F;
    --text-primary: #EDEFE7;
    --text-secondary: #ABB2A2;
    --text-muted: #7D8474;
    --border: #2E3327;
    --border-strong: #3C4232;
    --green-soft: #253425;
    --green-soft-text: #8FCB92;
    --green-mid: #6FA173;
    --accent-amber-soft: #3A2D14;
  }
}
