/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green:        #2e7d32;
  --green-mid:    #388e3c;
  --green-light:  #e8f5e9;
  --green-border: #a5d6a7;
  --amber:        #e65100;
  --amber-mid:    #f57c00;
  --amber-light:  #fff3e0;
  --amber-border: #ffcc80;
  --red:          #b71c1c;
  --red-mid:      #c62828;
  --red-light:    #ffebee;
  --red-border:   #ef9a9a;
  --blue:         #1565c0;
  --blue-light:   #e3f2fd;
  --blue-border:  #90caf9;
  --gray:         #546e7a;
  --gray-light:   #f5f7f8;
  --border:       #dde3e7;
  --radius:       12px;
  --shadow:       0 2px 14px rgba(0,0,0,.08);
  --font:         'Noto Sans JP', 'Hiragino Sans', 'Yu Gothic', sans-serif;
  /* Phase 3 追加カラー */
  --color-primary:   #2D7A3A;
  --color-accent:    #F4A336;
  --color-bg-hero:   #FDFAF4;
  --color-bg-card:   #FFFFFF;
  --color-text-main: #1A1A1A;
  --color-text-sub:  #666666;
}

body {
  font-family: var(--font);
  background: #f0f4f2;
  color: #263238;
  min-height: 100vh;
}

/* ===== Header ===== */
header {
  background: var(--green);
  color: #fff;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
}
.logo { font-size: 1.5rem; font-weight: 700; letter-spacing: .04em; }
.tagline { font-size: .78rem; opacity: .85; margin-top: 2px; }
.header-left { display: flex; flex-direction: column; }
.header-nav {
  display: flex; align-items: center; gap: 1.2rem;
  margin-left: auto; margin-right: 1rem;
}
.header-nav-link {
  color: rgba(255,255,255,0.9); text-decoration: none;
  font-size: 0.9rem; font-weight: bold;
  transition: color 0.15s;
}
.header-nav-link:hover { color: #fff; text-decoration: underline; }
@media (max-width: 600px) {
  header {
    flex-wrap: wrap;
    align-items: center;
    padding: 0.5rem 0.8rem;
    gap: 0;
  }
  .tagline { display: none !important; }
  .header-left { flex: 1; min-width: 0; }
  .logo { font-size: 1.1rem; }
  .btn-hamburger { display: flex; margin-left: auto; }
  .header-nav { display: none !important; }
  .auth-area {
    order: 10;
    width: 100%;
    display: flex !important;
    flex-direction: row;
    justify-content: flex-end;
    align-items: center;
    gap: 0.4rem;
    padding-top: 0.4rem;
    margin-top: 0.3rem;
    border-top: 1px solid rgba(255,255,255,0.2);
    flex-wrap: nowrap;
    overflow: hidden;
  }
  .auth-email {
    font-size: 0.75rem;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .scan-badge,
  .scan-badge-unlimited {
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    white-space: nowrap;
  }
  .btn-auth-outline {
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
    white-space: nowrap;
  }
}

/* ハンバーガーボタン */
.btn-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.4rem;
  margin-left: 0.5rem;
}
.btn-hamburger span {
  display: block;
  width: 24px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: transform 0.3s, opacity 0.3s;
}
.btn-hamburger.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.btn-hamburger.is-open span:nth-child(2) { opacity: 0; }
.btn-hamburger.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ドロワーメニュー */
.drawer-menu {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
}
.drawer-menu.is-open { display: block; }
.drawer-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
}
.drawer-content {
  position: absolute;
  top: 0; right: 0;
  width: 75%; max-width: 280px; height: 100%;
  background: #fff;
  padding: 1.5rem;
  box-shadow: -4px 0 16px rgba(0,0,0,0.15);
  transform: translateX(100%);
  transition: transform 0.3s ease;
}
.drawer-menu.is-open .drawer-content { transform: translateX(0); }
.drawer-close {
  display: block;
  margin-left: auto;
  background: none; border: none;
  font-size: 1.2rem; cursor: pointer;
  color: #666; margin-bottom: 1.5rem;
}
.drawer-nav { display: flex; flex-direction: column; gap: 0; }
.drawer-nav-link {
  display: block;
  padding: 1rem 0;
  border-bottom: 1px solid #f0f0f0;
  color: #1a1a1a; text-decoration: none;
  font-size: 1rem; font-weight: bold;
}
.drawer-nav-link:hover { color: #2D7A3A; }

/* ===== Layout ===== */
main {
  max-width: 760px;
  margin: 28px auto;
  padding: 0 16px 64px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ===== Card ===== */
.card {
  background: #fff;
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
}
.card-title {
  font-size: .95rem;
  font-weight: 700;
  color: var(--green);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== API Key ===== */
.api-key-row {
  display: flex;
  gap: 8px;
}
.api-key-row input {
  flex: 1;
  font-family: monospace;
  font-size: .85rem;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  transition: border-color .2s;
}
.api-key-row input:focus { border-color: var(--green); }
.btn-icon {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
  font-size: .8rem;
  white-space: nowrap;
  transition: background .15s;
}
.btn-icon:hover { background: var(--gray-light); }
.hint { font-size: .76rem; color: var(--gray); margin-top: 8px; line-height: 1.5; }
.hint a { color: var(--green); }

/* ===== Hero ===== */
.hero {
  background: var(--color-bg-hero);
  border-radius: var(--radius);
  padding: 36px 24px 30px;
  text-align: center;
  box-shadow: var(--shadow);
}
.hero-emoji {
  font-size: 1.7rem;
  letter-spacing: .2em;
  margin-bottom: 16px;
}
.hero-copy {
  font-size: 1.9rem;
  font-weight: 900;
  color: var(--green);
  letter-spacing: -.01em;
  line-height: 1.2;
  margin-bottom: 12px;
}
.hero-sub {
  font-size: .9rem;
  color: var(--color-text-sub);
  line-height: 1.7;
  max-width: 500px;
  margin: 0 auto;
}

/* ===== Mode Card ===== */
.mode-card { padding: 24px 26px; }
.mode-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--green);
  margin-bottom: 16px;
}
.mode-rules {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mode-rule-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .88rem;
  font-weight: 500;
  padding: 9px 14px;
  border-radius: 8px;
}
.mode-rule-row.ng { background: var(--red-light);   color: var(--red); }
.mode-rule-row.ok { background: var(--green-light); color: var(--green); }

/* ===== Mode Badge ===== */
.mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--green-light);
  border: 2px solid var(--green-border);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: .88rem;
}
.mode-badge .mode-icon { font-size: 1.2rem; }
.mode-badge .mode-info .mode-name { font-weight: 700; color: var(--green); }
.mode-badge .mode-info .mode-rule { font-size: .76rem; color: var(--gray); margin-top: 2px; }
.phase-note { font-size: .76rem; color: var(--gray); margin-top: 10px; }

/* ===== Ingredient Input ===== */
#ingredients-textarea {
  width: 100%;
  min-height: 150px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .88rem;
  line-height: 1.75;
  resize: vertical;
  font-family: var(--font);
  outline: none;
  transition: border-color .2s;
}
#ingredients-textarea:focus { border-color: var(--green); }

.input-hint { font-size: .76rem; color: var(--gray); margin-top: 6px; }

/* ===== Tab badge（おすすめ） ===== */
.tab-badge {
  display: inline-block;
  background: var(--color-accent);
  color: #fff;
  font-size: .62rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 4px;
  vertical-align: middle;
  letter-spacing: .02em;
}

/* ===== Input Tabs ===== */
.input-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
}
.input-tab {
  padding: 8px 18px;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  background: none;
  cursor: pointer;
  font-size: .88rem;
  font-weight: 600;
  color: var(--gray);
  font-family: var(--font);
  transition: color .15s, border-color .15s;
}
.input-tab:hover { color: var(--green); }
.input-tab.active { color: var(--green); border-bottom-color: var(--green); }

/* ===== Drop Zone ===== */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 32px 16px;
  text-align: center;
  cursor: pointer;
  background: var(--gray-light);
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .2s, background .2s;
}
.drop-zone:hover,
.drop-zone.dragover { border-color: var(--green); background: var(--green-light); }
.drop-zone.dragover { border-style: solid; }
.drop-zone.has-image { padding: 12px; background: #fff; border-style: solid; border-color: var(--green-border); }

.drop-icon { font-size: 2.5rem; margin-bottom: 8px; }
.drop-main { font-size: .92rem; font-weight: 600; color: #455a64; margin-bottom: 4px; }
.drop-hint-text { font-size: .75rem; color: var(--gray); margin-top: 4px; }

.btn-clear-image {
  display: inline-block;
  margin-top: 8px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 14px;
  font-size: .78rem;
  color: var(--gray);
  cursor: pointer;
  font-family: var(--font);
  transition: background .15s;
}
.btn-clear-image:hover { background: var(--gray-light); }

/* ===== Image toolbar & crop (原材料の部分切り出し) ===== */
.image-toolbar {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--blue-light);
  border: 1px solid var(--blue-border);
  border-radius: 8px;
}
.image-toolbar-hint {
  font-size: .78rem;
  line-height: 1.55;
  color: #37474f;
  margin-bottom: 10px;
}
.image-toolbar-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.btn-crop {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
}
.btn-crop:hover { background: #1b5e20; }
.btn-crop:disabled {
  background: #a5d6a7;
  cursor: not-allowed;
}
.btn-crop-secondary {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-size: .82rem;
  cursor: pointer;
  font-family: var(--font);
  color: var(--gray);
}
.btn-crop-secondary:hover { background: var(--gray-light); }

.btn-toolbar-clear {
  padding: 8px 16px;
  border: 1px solid var(--red-border);
  border-radius: 8px;
  background: var(--red-light);
  color: var(--red);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
}
.btn-toolbar-clear:hover { background: #ffcdd2; }

.crop-panel {
  margin-top: 14px;
  padding: 14px;
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.crop-instruction {
  font-size: .82rem;
  color: var(--gray);
  margin-bottom: 10px;
}
.crop-canvas-wrap {
  width: 100%;
  overflow: auto;
  max-height: 70vh;
  border-radius: 8px;
  background: #263238;
}
#crop-canvas {
  display: block;
  max-width: 100%;
  height: auto;
  cursor: crosshair;
  touch-action: none;
}
.crop-panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

/* ===== Compare photo (result vs extracted text) ===== */
.result-compare-photo-wrap {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
}
.result-compare-photo-title {
  font-size: .88rem;
  font-weight: 700;
  color: var(--gray);
  margin-bottom: 10px;
}
.result-compare-photo-inner {
  border-radius: 8px;
  overflow: hidden;
  background: #eceff1;
  max-height: min(50vh, 420px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.result-compare-photo {
  display: block;
  max-width: 100%;
  max-height: min(50vh, 420px);
  width: auto;
  height: auto;
  object-fit: contain;
}
.result-compare-photo-hint {
  margin: 10px 0 0;
  font-size: .78rem;
  color: #607d8b;
  line-height: 1.5;
}

/* ===== Extracted Text Accordion ===== */
.extracted-accordion {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.extracted-accordion summary {
  padding: 12px 16px;
  font-size: .88rem;
  font-weight: 700;
  color: var(--gray);
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.extracted-accordion summary::-webkit-details-marker { display: none; }
.extracted-accordion summary::after { content: "▼"; font-size: .65rem; opacity: .6; }
.extracted-accordion[open] summary::after { content: "▲"; }
.extracted-text {
  padding: 12px 16px;
  font-size: .84rem;
  line-height: 1.75;
  color: #37474f;
  border-top: 1px solid var(--border);
  white-space: pre-wrap;
  word-break: break-all;
}

/* ===== Analyze Button ===== */
.btn-analyze {
  width: 100%;
  padding: 18px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 16px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: .05em;
  transition: background .2s, transform .15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 4px 14px rgba(46,125,50,.3);
}
.btn-analyze:hover:not(:disabled) { background: #1b5e20; transform: scale(1.02); }
.btn-analyze:active:not(:disabled) { transform: scale(.98); }
.btn-analyze:disabled { background: #a5d6a7; cursor: not-allowed; box-shadow: none; }

.spinner {
  display: none;
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.btn-analyze.loading .spinner { display: block; }
.btn-analyze.loading .btn-label { opacity: .75; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Error ===== */
.error-box {
  background: var(--red-light);
  border: 1px solid var(--red-border);
  border-radius: 8px;
  padding: 14px 16px;
  color: var(--red);
  font-size: .88rem;
  display: none;
}
.error-box.visible { display: block; }

/* ===== Result Section ===== */
#result-section { display: none; flex-direction: column; gap: 16px; }
#result-section.visible { display: flex; }

/* Overall Banner */
.overall-banner {
  border-radius: 10px;
  padding: 18px 22px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.overall-banner.ok     { background: var(--green-light); border: 2px solid var(--green-border); }
.overall-banner.gray   { background: var(--amber-light); border: 2px solid var(--amber-border); }
.overall-banner.ng     { background: var(--red-light);   border: 2px solid var(--red-border); }
.overall-banner.extract-only {
  background: var(--blue-light);
  border: 2px solid var(--blue-border);
}

.image-flow-note {
  margin-top: 14px;
  padding: 10px 12px;
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .78rem;
  line-height: 1.55;
  color: #37474f;
}
.image-flow-note strong { color: var(--blue); font-weight: 700; }

.extract-only-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 18px;
  background: #fff;
  border: 2px solid var(--green-border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
/* .extract-only-actions { display:flex } が [hidden] より後勝ちし、非表示にならないのを防ぐ */
.extract-only-actions[hidden] {
  display: none !important;
}
.extract-only-actions-hint {
  font-size: .8rem;
  line-height: 1.55;
  color: var(--gray);
  margin: 0;
}
.btn-extract-classify {
  align-self: flex-start;
  padding: 12px 20px;
  border: none;
  border-radius: 10px;
  background: var(--green);
  color: #fff;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font);
}
.btn-extract-classify:hover { background: #1b5e20; }
.btn-extract-classify:disabled {
  background: #a5d6a7;
  cursor: not-allowed;
}

.overall-icon { font-size: 2.4rem; line-height: 1; flex-shrink: 0; }
.overall-text .verdict {
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1.2;
}
.overall-text .verdict.ok   { color: var(--green); }
.overall-text .verdict.gray { color: var(--amber); }
.overall-text .verdict.ng   { color: var(--red); }
.overall-text .summary {
  font-size: .86rem;
  margin-top: 6px;
  line-height: 1.65;
  color: #37474f;
}

/* Result List Cards */
.result-list-card {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.result-list-header {
  padding: 10px 16px;
  font-weight: 700;
  font-size: .88rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.result-list-header .count {
  margin-left: auto;
  font-size: .78rem;
  font-weight: 500;
  opacity: .8;
}
.result-list-header.ok   { background: var(--green-light); color: var(--green); }
.result-list-header.gray { background: var(--amber-light); color: var(--amber); }
.result-list-header.ng   { background: var(--red-light);   color: var(--red-mid); }
.result-list-header.unknown { background: var(--blue-light); color: var(--blue); }

.result-list { list-style: none; background: #fff; }
.result-list li {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: .86rem;
}
.result-list li:first-child { border-top: none; }

.ing-name { font-weight: 600; display: block; margin-bottom: 2px; }
.ing-reason { color: var(--gray); font-size: .78rem; }

/* Gray detail block */
.ing-detail {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--amber-light);
  border-left: 3px solid var(--amber-border);
  border-radius: 4px;
  font-size: .78rem;
  line-height: 1.65;
  white-space: pre-line;
  color: #4a3000;
}

/* Unknown inferred badge */
.inferred-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .72rem;
  padding: 2px 7px;
  border-radius: 10px;
  margin-left: 6px;
  font-weight: 600;
}
.inferred-badge.low    { background: #fff3e0; color: #bf360c; }
.inferred-badge.medium { background: #fff8e1; color: #e65100; }
.inferred-badge.high   { background: #e8f5e9; color: var(--green); }

.ing-inferred-reason {
  font-size: .76rem;
  color: var(--gray);
  margin-top: 4px;
  display: block;
}

.empty-list {
  padding: 12px 16px;
  font-size: .84rem;
  color: var(--gray);
  background: #fff;
  font-style: italic;
}

/* ===== Feedback UI（推測成分の正解入力） ===== */
.feedback-row {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--blue-light);
  border: 1px solid var(--blue-border);
  border-radius: 8px;
  font-size: .8rem;
}
.feedback-label { color: var(--blue); font-weight: 600; display: block; margin-bottom: 8px; }

.feedback-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.fb-btn {
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: .8rem;
  transition: background .15s, border-color .15s;
}
.fb-btn:hover { background: var(--gray-light); }
.fb-btn.selected.fb-ok   { background: var(--green-light); border-color: var(--green); color: var(--green); font-weight: 700; }
.fb-btn.selected.fb-gray { background: var(--amber-light); border-color: var(--amber-border); color: var(--amber); font-weight: 700; }
.fb-btn.selected.fb-ng   { background: var(--red-light); border-color: var(--red-border); color: var(--red); font-weight: 700; }
.fb-btn:disabled { opacity: .5; cursor: not-allowed; }

.feedback-reason-row {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  align-items: center;
}
.fb-reason-input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .8rem;
  outline: none;
}
.fb-reason-input:focus { border-color: var(--blue); }
.fb-save-btn {
  padding: 6px 14px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: .8rem;
  cursor: pointer;
  white-space: nowrap;
}
.fb-save-btn:hover { background: #0d47a1; }

.feedback-saved {
  margin-top: 6px;
  color: var(--green);
  font-weight: 600;
  font-size: .8rem;
}

/* ===== User DB badge ===== */
.user-db-note {
  text-align: center;
  font-size: .76rem;
  color: var(--gray);
}
#user-db-count {
  background: var(--green-light);
  color: var(--green);
  border-radius: 10px;
  padding: 2px 10px;
  font-weight: 700;
  margin-right: 6px;
}
.user-db-hint { color: var(--gray); }

/* ===== Detailed Result (Gemini 詳細モード) ===== */
.detailed-header { background: #3f51b5; color: #fff; }

.detailed-item {
  padding: 10px 12px;
  border-bottom: 1px solid #eee;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.detailed-item:last-child { border-bottom: none; }

.detailed-item-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

/* 確信度バッジ */
.conf-badge {
  font-size: .72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  white-space: nowrap;
}
.conf-high { background: #e8f5e9; color: #2e7d32; }
.conf-mid  { background: #fff8e1; color: #f57f17; }
.conf-low  { background: #fce4ec; color: #c62828; }

/* ベジステータスバッジ */
.vege-badge {
  font-size: .75rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}
.vege-badge.ok   { background: #e8f5e9; color: #2e7d32; }
.vege-badge.gray { background: #fff8e1; color: #e65100; }
.vege-badge.ng   { background: #fce4ec; color: #c62828; }

/* 要確認フラグ */
.check-flag {
  font-size: .72rem;
  background: #ff8f00;
  color: #fff;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 700;
}

/* ユーザーへの確認文 */
.user-prompt-text {
  font-size: .82rem;
  color: #1565c0;
  background: #e3f2fd;
  padding: 5px 10px;
  border-radius: 6px;
}

/* ズームボタン */
.btn-zoom-bbox {
  align-self: flex-start;
  font-size: .78rem;
  padding: 4px 10px;
  background: #f3e5f5;
  color: #6a1b9a;
  border: 1px solid #ce93d8;
  border-radius: 6px;
  cursor: pointer;
}
.btn-zoom-bbox:hover { background: #e1bee7; }

/* ズームエリア */
.ingredient-zoom-area {
  background: #1a1a2e;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 14px;
}
.zoom-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.zoom-title { color: #fff; font-size: .85rem; font-weight: 600; }
.zoom-close-btn {
  background: none;
  border: none;
  color: #aaa;
  font-size: 1rem;
  cursor: pointer;
  padding: 2px 6px;
}
.zoom-canvas {
  display: block;
  max-width: 100%;
  border-radius: 6px;
  image-rendering: crisp-edges;
}
.zoom-caption {
  color: #ccc;
  font-size: .78rem;
  margin-top: 6px;
  text-align: center;
}

/* ===== Engine Selector ===== */
.engine-selector {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 10px 14px;
  margin-bottom: 14px;
  background: #f8f9fa;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: .85rem;
}
.engine-label {
  font-weight: 600;
  color: #555;
  white-space: nowrap;
}
.engine-option {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}
.engine-option input[type="radio"] { accent-color: #2d7a4e; }

/* ===== Footer ===== */
footer {
  background: var(--green);
  color: rgba(255,255,255,0.8);
  padding: 1.2rem 1rem;
  display: flex; flex-direction: column;
  align-items: center; gap: 0.5rem;
}
.footer-links {
  display: flex; gap: 1.2rem; flex-wrap: wrap;
  justify-content: center;
}
.footer-link {
  color: rgba(255,255,255,0.8); text-decoration: none;
  font-size: 0.85rem;
}
.footer-link:hover { color: #fff; text-decoration: underline; }
.footer-copy { color: rgba(255,255,255,0.6); font-size: 0.8rem; }

/* ===== 新しい食品を解析するボタン（結果下） ===== */
.result-reset-wrap {
  text-align: center;
  margin: 8px 0 4px;
}
.btn-result-reset {
  padding: 12px 28px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 24px;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font);
  letter-spacing: .02em;
  transition: background .15s, transform .1s;
}
.btn-result-reset:hover  { background: var(--green-mid); }
.btn-result-reset:active { transform: scale(.96); }

/* ===== Camera direct-capture button (drop-zone内) ===== */
.btn-open-camera {
  margin-top: 14px;
  padding: 10px 22px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 22px;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  letter-spacing: .02em;
  transition: background .15s, transform .1s;
  pointer-events: all;
}
.btn-open-camera:hover { background: var(--green-mid); }
.btn-open-camera:active { transform: scale(.96); }

/* ===== Camera overlay ===== */
.camera-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.camera-overlay[hidden] { display: none; }

.camera-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-ui {
  position: relative;
  z-index: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 12px;
  gap: 0;
}

.camera-hint-text {
  color: #fff;
  font-size: .88rem;
  font-weight: 700;
  text-shadow: 0 1px 4px rgba(0,0,0,.9);
  margin-bottom: 14px;
  text-align: center;
  pointer-events: none;
}
.camera-sub-hint {
  color: rgba(255,255,255,.8);
  font-size: .75rem;
  text-shadow: 0 1px 3px rgba(0,0,0,.8);
  margin-top: 14px;
  text-align: center;
  pointer-events: none;
}

/* ガイドフレーム（原材料ラベルに合わせた比率） */
.camera-guide-box {
  position: relative;
  width: 88%;
  max-width: 520px;
  aspect-ratio: 1 / 1;
  /* box-shadow でフレーム外を暗くする */
  box-shadow: 0 0 0 200vmax rgba(0,0,0,.62);
  border-radius: 6px;
}

/* コーナーマーカー（L字）*/
.cgc {
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: #fff;
  border-style: solid;
}
.cgc.tl { top: -2px; left: -2px;  border-width: 3px 0 0 3px; border-radius: 3px 0 0 0; }
.cgc.tr { top: -2px; right: -2px; border-width: 3px 3px 0 0; border-radius: 0 3px 0 0; }
.cgc.bl { bottom: -2px; left: -2px;  border-width: 0 0 3px 3px; border-radius: 0 0 0 3px; }
.cgc.br { bottom: -2px; right: -2px; border-width: 0 3px 3px 0; border-radius: 0 0 3px 0; }

/* 撮影ボタン周辺 */
.camera-buttons {
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.btn-camera-capture {
  position: relative;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: #fff;
  border: 4px solid rgba(255,255,255,.45);
  cursor: pointer;
  transition: transform .12s, background .12s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-camera-capture:active { transform: scale(.88); background: #ddd; }

/* 外側のリング装飾 */
.camera-capture-ring {
  display: block;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255,255,255,.35);
}

.btn-camera-cancel {
  background: rgba(0,0,0,.35);
  border: 1px solid rgba(255,255,255,.55);
  border-radius: 20px;
  color: #fff;
  padding: 7px 22px;
  font-size: .8rem;
  cursor: pointer;
  font-family: var(--font);
  transition: background .15s;
}
.btn-camera-cancel:hover { background: rgba(0,0,0,.55); }

/* ===== Responsive ===== */
@media (max-width: 480px) {
  main { padding: 0 10px 48px; gap: 14px; }
  .card { padding: 16px; }
  header { padding: 14px 16px; }
  .logo { font-size: 1.3rem; }
  .camera-guide-box { width: 94%; aspect-ratio: 1 / 1; }
  .hero { padding: 26px 16px 22px; }
  .hero-copy { font-size: 1.5rem; }
  .hero-emoji { font-size: 1.4rem; letter-spacing: .15em; }
}

/* ===== Auth Header ===== */
header { justify-content: space-between; }

.auth-area {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.auth-email {
  font-size: .76rem;
  opacity: .9;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.scan-badge {
  background: rgba(255,255,255,.22);
  color: #fff;
  border-radius: 12px;
  padding: 3px 10px;
  font-size: .76rem;
  font-weight: 700;
  white-space: nowrap;
}
.scan-badge.exhausted { background: var(--red-mid); }

.btn-auth {
  background: rgba(255,255,255,.22);
  color: #fff;
  border: 1px solid rgba(255,255,255,.5);
  border-radius: 20px;
  padding: 5px 13px;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}
.btn-auth:hover { background: rgba(255,255,255,.38); }

.btn-auth-outline {
  background: transparent;
  color: rgba(255,255,255,.9);
  border: 1px solid rgba(255,255,255,.45);
  border-radius: 20px;
  padding: 5px 13px;
  font-size: .8rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}
.btn-auth-outline:hover { background: rgba(255,255,255,.18); }

/* ===== Auth Modal ===== */
.auth-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.auth-modal[hidden] { display: none; }

.auth-modal-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 32px 28px 24px;
  width: 100%;
  max-width: 400px;
  position: relative;
  box-shadow: 0 8px 40px rgba(0,0,0,.22);
}
.auth-modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--gray);
  line-height: 1;
  padding: 4px 6px;
}
.auth-modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--green);
  margin-bottom: 20px;
}
.auth-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
}
.auth-field label {
  font-size: .82rem;
  font-weight: 600;
  color: #546e7a;
}
.auth-field input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: .95rem;
  outline: none;
  transition: border-color .15s;
}
.auth-field input:focus {
  border-color: var(--green-mid);
  box-shadow: 0 0 0 3px var(--green-light);
}
.auth-error {
  font-size: .84rem;
  min-height: 18px;
  margin-bottom: 8px;
  color: var(--red-mid);
}
.auth-error.success { color: var(--green); }
.btn-auth-submit {
  width: 100%;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background .15s;
}
.btn-auth-submit:hover:not(:disabled) { background: var(--green-mid); }
.btn-auth-submit:disabled { opacity: .6; cursor: not-allowed; }
.auth-modal-footer {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.btn-auth-link {
  background: none;
  border: none;
  color: var(--blue);
  font-size: .84rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px;
}
.btn-auth-link:hover { color: var(--green); }
.scan-badge-unlimited {
  background: #fff3cd;
  color: #856404;
  border-radius: 1rem;
  padding: 0.3rem 0.8rem;
  font-size: 0.85rem;
  font-weight: bold;
}
.logo-link { text-decoration: none; color: inherit; cursor: pointer; }
.logo-link:hover { opacity: 0.85; }
.btn-settings-admin {
  display: block; text-align: center;
  background: #2D7A3A; color: #fff;
  border-radius: 2rem; padding: 0.8rem;
  text-decoration: none; font-weight: bold;
  transition: transform 0.15s;
}
.btn-settings-admin:hover { transform: scale(1.02); }

/* ===== ランディングページ ===== */
#landing-page { background: var(--gray-light); }

.btn-hero-cta {
  display: inline-block; margin-top: 1.2rem;
  background: #2D7A3A; color: #fff;
  border: none; border-radius: 2rem; padding: 0.9rem 2.5rem;
  font-size: 1.1rem; font-weight: bold; cursor: pointer;
  transition: transform 0.15s;
}
.btn-hero-cta:hover { transform: scale(1.03); }
.hero-note { font-size: 0.85rem; color: #888; margin-top: 0.5rem; }

/* LPセクション共通 */
.lp-section { padding: 2.5rem 1rem; max-width: 900px; margin: 0 auto; }
.lp-section-title {
  text-align: center; font-size: 1.4rem;
  font-weight: bold; margin-bottom: 1.5rem; color: #2D7A3A;
}

/* 食事スタイルカード */
.mode-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}
.mode-lp-card {
  background: #fff; border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  padding: 1.2rem; text-align: center;
}
.mode-lp-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.mode-lp-name { font-weight: bold; margin-bottom: 0.4rem; font-size: 0.95rem; }
.mode-lp-desc { font-size: 0.82rem; color: #666; line-height: 1.5; }

/* 使い方ステップ */
.howto-steps {
  display: flex; align-items: center;
  justify-content: center; gap: 0.5rem;
  flex-wrap: wrap; margin-bottom: 1.5rem;
}
.howto-step {
  text-align: center; background: #fff;
  border-radius: 12px; padding: 1.2rem 1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07); min-width: 130px;
}
.howto-num { font-size: 1.5rem; font-weight: bold; color: #2D7A3A; }
.howto-title { font-weight: bold; margin: 0.3rem 0; }
.howto-desc { font-size: 0.82rem; color: #888; }
.howto-arrow { font-size: 1.5rem; color: #2D7A3A; }

/* 動画プレースホルダー */
.video-placeholder {
  border: 2px dashed #ccc; border-radius: 12px;
  padding: 2.5rem; text-align: center;
  color: #aaa; font-size: 1rem; margin-top: 1rem;
}

/* 料金カード */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem; max-width: 600px; margin: 0 auto;
}
.pricing-card {
  background: #fff; border-radius: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  padding: 1.8rem; text-align: center;
}
.pricing-card-coming { opacity: 0.6; }
.pricing-badge {
  display: inline-block; background: #888;
  color: #fff; border-radius: 1rem;
  padding: 0.2rem 0.8rem; font-size: 0.8rem; margin-bottom: 0.5rem;
}
.pricing-plan { font-weight: bold; font-size: 1.1rem; margin-bottom: 0.3rem; }
.pricing-price { font-size: 2rem; font-weight: bold; color: #2D7A3A; margin-bottom: 1rem; }
.pricing-features { list-style: none; padding: 0; margin-bottom: 1.2rem; text-align: left; }
.pricing-features li { padding: 0.3rem 0; font-size: 0.9rem; }
.btn-coming-soon {
  background: #ccc; color: #fff; border: none;
  border-radius: 2rem; padding: 0.7rem 2rem;
  font-size: 1rem; cursor: not-allowed;
}

/* ===== モードバー（スキャンページ上部） ===== */
.scanner-modebar {
  display: flex; align-items: center; gap: 0.8rem;
  padding: 0.8rem 1rem; background: #fff;
  border-bottom: 1px solid #eee; position: relative;
  margin-bottom: 16px; border-radius: 12px;
  box-shadow: var(--shadow);
}
.btn-modebar {
  background: #f0f7f1; border: 1px solid #2D7A3A;
  border-radius: 2rem; padding: 0.4rem 1rem;
  color: #2D7A3A; font-weight: bold; cursor: pointer;
}
.modebar-dropdown {
  position: absolute; top: 3rem; left: 1rem;
  background: #fff; border: 1px solid #ddd;
  border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 100; min-width: 200px;
}
.modebar-option {
  display: block; width: 100%; text-align: left;
  padding: 0.7rem 1rem; border: none; background: none;
  cursor: pointer; font-size: 0.95rem;
}
.modebar-option:hover { background: #f0f7f1; }
.btn-user-page {
  margin-left: auto; color: #2D7A3A;
  text-decoration: none; font-size: 0.9rem;
}

/* ===== スマホ対応（LP） ===== */
@media (max-width: 600px) {
  .howto-arrow { display: none; }
  .howto-steps { flex-direction: column; }
  .mode-cards-grid { grid-template-columns: 1fr 1fr; }
}

/* ===== モード選択画面 ===== */
.mode-select-wrap {
  max-width: 860px; margin: 0 auto; padding: 2rem 1rem;
}
.mode-select-header { text-align: center; margin-bottom: 2rem; }
.mode-select-emoji { font-size: 3rem; margin-bottom: 0.5rem; }
.mode-select-title { font-size: 1.6rem; font-weight: bold; color: #2D7A3A; margin-bottom: 0.5rem; }
.mode-select-sub { color: #666; line-height: 1.7; }

.mode-select-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.2rem;
}
.mode-select-card {
  background: #fff; border: 2px solid #e0e0e0;
  border-radius: 16px; padding: 1.5rem;
  text-align: center; cursor: pointer;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  position: relative;
}
.mode-select-card:hover:not([disabled]) {
  border-color: #2D7A3A;
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(45,122,58,0.15);
}
.mode-select-card-disabled { opacity: 0.5; cursor: not-allowed; }
.msc-badge {
  position: absolute; top: 0.8rem; right: 0.8rem;
  background: #888; color: #fff; border-radius: 1rem;
  padding: 0.15rem 0.6rem; font-size: 0.75rem;
}
.msc-icon { font-size: 2.5rem; margin-bottom: 0.6rem; }
.msc-name { font-weight: bold; font-size: 1rem; margin-bottom: 0.5rem; color: #1a1a1a; }
.msc-desc { font-size: 0.82rem; color: #666; line-height: 1.6; margin-bottom: 0.8rem; }
.msc-rules { display: flex; flex-direction: column; gap: 0.3rem; }
.msc-rule {
  display: inline-block; border-radius: 1rem;
  padding: 0.25rem 0.7rem; font-size: 0.78rem; font-weight: bold;
}
.msc-rule.ng { background: #fff0f0; color: #c0392b; }
.msc-rule.ok { background: #f0fff4; color: #2D7A3A; }

@media (max-width: 600px) {
  .mode-select-grid { grid-template-columns: 1fr; }
}

/* ===== ユーザー設定ページ ===== */
.user-settings-wrap {
  max-width: 600px; margin: 0 auto; padding: 1.5rem 1rem;
}
.user-settings-header {
  display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem;
}
.btn-back {
  background: none; border: 1px solid #ddd; border-radius: 2rem;
  padding: 0.4rem 1rem; cursor: pointer; color: #555; font-size: 0.9rem;
}
.btn-back:hover { background: #f5f5f5; }
.user-settings-title { font-size: 1.3rem; font-weight: bold; color: #2D7A3A; }

.settings-card {
  background: #fff; border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  padding: 1.4rem; margin-bottom: 1.2rem;
}
.settings-card-title {
  font-weight: bold; font-size: 1rem;
  color: #2D7A3A; margin-bottom: 1rem;
  padding-bottom: 0.5rem; border-bottom: 1px solid #eee;
}
.settings-card-desc { font-size: 0.85rem; color: #888; margin-bottom: 1rem; }
.settings-row {
  display: flex; justify-content: space-between;
  align-items: center; padding: 0.6rem 0;
  border-bottom: 1px solid #f0f0f0;
}
.settings-row:last-child { border-bottom: none; }
.settings-label { color: #666; font-size: 0.9rem; }
.settings-value { font-weight: bold; font-size: 0.9rem; }

.settings-mode-list { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1.2rem; }
.settings-mode-item {
  display: flex; align-items: center; gap: 0.8rem;
  border: 2px solid #eee; border-radius: 10px;
  padding: 0.9rem; cursor: pointer; transition: border-color 0.2s;
}
.settings-mode-item:hover:not(.settings-mode-item-disabled) { border-color: #2D7A3A; }
.settings-mode-item input[type="radio"] { accent-color: #2D7A3A; width: 18px; height: 18px; flex-shrink: 0; }
.settings-mode-item-disabled { opacity: 0.5; cursor: not-allowed; }
.settings-mode-content { display: flex; align-items: center; gap: 0.8rem; }
.settings-mode-icon { font-size: 1.6rem; }
.settings-mode-name { font-weight: bold; font-size: 0.95rem; }
.settings-mode-desc { font-size: 0.8rem; color: #888; margin-top: 0.2rem; }
.settings-coming-badge {
  background: #888; color: #fff; border-radius: 1rem;
  padding: 0.1rem 0.5rem; font-size: 0.72rem; margin-left: 0.4rem;
}

.btn-settings-save {
  width: 100%; background: #2D7A3A; color: #fff;
  border: none; border-radius: 2rem; padding: 0.9rem;
  font-size: 1rem; font-weight: bold; cursor: pointer;
  transition: transform 0.15s;
}
.btn-settings-save:hover { transform: scale(1.02); }
.btn-settings-save:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.settings-save-msg {
  text-align: center; margin-top: 0.7rem; font-size: 0.9rem; min-height: 1.2rem;
}
.settings-save-msg.success { color: #2D7A3A; }
.settings-save-msg.error   { color: #c0392b; }

.settings-card-danger .settings-card-title { color: #c0392b; }
.btn-settings-logout {
  width: 100%; background: #fff; color: #c0392b;
  border: 2px solid #c0392b; border-radius: 2rem;
  padding: 0.8rem; font-size: 1rem; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-settings-logout:hover { background: #c0392b; color: #fff; }
