:root {
  --bg: #f7fbf4;
  --surface: #ffffff;
  --surface-soft: #eef6e9;
  --text: #1d2820;
  --muted: #69766c;
  --border: #dce7d7;
  --green: #27754f;
  --green-dark: #155f3a;
  --amber: #b86b16;
  --red: #b84242;
  --shadow: 0 18px 42px rgba(36, 64, 42, 0.12);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
}

button,
textarea {
  font: inherit;
}

a {
  color: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px clamp(18px, 4vw, 56px);
  background: rgba(247, 251, 244, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: var(--green);
  color: white;
  font-size: 15px;
}

.nav-links {
  display: flex;
  gap: 18px;
  color: var(--muted);
  font-size: 14px;
}

.nav-links a {
  text-decoration: none;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 34px auto 0;
}

.hero-copy {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(260px, 0.55fr);
  gap: 32px;
  align-items: end;
  margin-bottom: 22px;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 14px;
  font-size: clamp(36px, 5.4vw, 68px);
  line-height: 1.08;
  letter-spacing: 0;
}

.lead {
  max-width: 560px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 18px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(340px, 0.95fr);
  gap: 18px;
  align-items: start;
}

.panel,
.history-section,
.content-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  min-height: 620px;
  padding: 22px;
}

.panel-heading,
.focus-header,
.input-actions,
.result-row-header,
.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel h2,
.history-section h2,
.content-section h2 {
  margin-bottom: 0;
  font-size: 24px;
  line-height: 1.25;
}

textarea {
  width: 100%;
  min-height: 170px;
  margin-top: 18px;
  padding: 16px;
  resize: vertical;
  color: var(--text);
  background: #fbfdf9;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
}

textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(39, 117, 79, 0.14);
}

.camera-box {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding: 18px;
  background: #fbfdf9;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.camera-box p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
}

.camera-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 58px;
  padding: 0 18px;
  border-radius: 8px;
  background: var(--green);
  color: white;
  cursor: pointer;
  font-weight: 850;
}

.camera-glyph {
  position: relative;
  width: 18px;
  height: 14px;
  border: 2px solid currentColor;
  border-radius: 4px;
}

.camera-glyph::before {
  position: absolute;
  top: -6px;
  left: 3px;
  width: 8px;
  height: 4px;
  border-radius: 3px 3px 0 0;
  background: currentColor;
  content: "";
}

.camera-glyph::after {
  position: absolute;
  top: 3px;
  left: 5px;
  width: 4px;
  height: 4px;
  border: 1px solid currentColor;
  border-radius: 50%;
  content: "";
}

.preview-frame {
  margin: 16px 0 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #111;
}

.preview-frame img {
  display: block;
  width: 100%;
  max-height: 280px;
  object-fit: contain;
}

.ocr-status {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding: 12px;
  background: var(--surface-soft);
  border-radius: 8px;
  color: var(--green-dark);
  font-weight: 800;
}

.ocr-status progress {
  width: 100%;
  height: 12px;
  accent-color: var(--green);
}

.ocr-text-box {
  margin-top: 16px;
}

.ocr-text-box h3 {
  margin-bottom: 0;
  font-size: 16px;
}

.ocr-text-box textarea {
  min-height: 150px;
  margin-top: 10px;
}

.primary-button,
.secondary-button,
.ghost-button,
.text-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.primary-button {
  padding: 0 22px;
  background: var(--green);
  color: white;
}

.primary-button:hover {
  background: var(--green-dark);
}

.secondary-button,
.ghost-button {
  padding: 0 16px;
  background: var(--surface-soft);
  color: var(--green-dark);
}

.text-button {
  min-height: auto;
  padding: 0;
  background: transparent;
  color: var(--green);
}

.input-actions {
  justify-content: flex-start;
  margin-top: 14px;
}

.upload-note {
  display: grid;
  gap: 4px;
  margin-top: 18px;
  padding: 14px;
  color: var(--muted);
  background: var(--surface-soft);
  border-radius: 8px;
  font-size: 14px;
}

.status-pill,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.status-pill {
  background: var(--surface-soft);
  color: var(--green-dark);
}

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

.summary-grid div {
  padding: 14px;
  background: #fbfdf9;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.summary-value,
.summary-label {
  display: block;
}

.summary-value {
  font-size: 30px;
  font-weight: 850;
  line-height: 1;
}

.summary-label {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.focus-box {
  padding: 14px;
  background: #fbfdf9;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.focus-box h3 {
  margin-bottom: 0;
  font-size: 16px;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chip {
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: white;
  color: var(--text);
  cursor: pointer;
}

.chip[aria-pressed="true"] {
  border-color: var(--green);
  background: var(--green);
  color: white;
}

.result-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.result-row {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
}

.result-row.focused {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(39, 117, 79, 0.1);
}

.result-row h3 {
  margin-bottom: 0;
  font-size: 17px;
}

.result-meta {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.match-text {
  margin: 10px 0 0;
  padding: 10px;
  white-space: pre-wrap;
  background: #fff9ed;
  border-left: 3px solid var(--amber);
  border-radius: 6px;
  color: #604112;
  font-size: 13px;
}

.badge.ingredient {
  background: #fdebea;
  color: var(--red);
}

.badge.caution {
  background: #fff1dc;
  color: var(--amber);
}

.badge.unknown {
  background: #eef1f4;
  color: #4f5c62;
}

.ad-slot {
  display: grid;
  place-items: center;
  min-height: 92px;
  margin-top: 18px;
  color: var(--muted);
  background: #f0f4ee;
  border: 1px dashed #bdcabb;
  border-radius: 8px;
  text-align: center;
}

.ad-slot span {
  font-size: 12px;
  font-weight: 800;
}

.ad-slot p {
  margin-bottom: 0;
  font-size: 13px;
}

.history-section,
.content-section {
  width: min(1180px, calc(100% - 32px));
  margin: 18px auto 0;
  padding: 24px;
}

.history-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.history-row {
  padding: 12px 14px;
  background: #fbfdf9;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.history-row button {
  white-space: nowrap;
}

.content-section {
  display: grid;
  grid-template-columns: 0.7fr 1fr;
  gap: 28px;
}

.content-copy p:last-child {
  color: var(--muted);
}

.info-grid {
  display: grid;
  gap: 12px;
}

.info-grid article,
details {
  padding: 16px;
  background: #fbfdf9;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.info-grid h3,
details p {
  margin-bottom: 0;
}

details + details {
  margin-top: 12px;
}

summary {
  cursor: pointer;
  font-weight: 800;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  width: min(1180px, calc(100% - 32px));
  margin: 22px auto 32px;
  color: var(--muted);
  font-size: 13px;
}

.empty-state {
  margin-bottom: 0;
  color: var(--muted);
}

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

@media (max-width: 820px) {
  .site-header,
  .site-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav-links {
    width: 100%;
    justify-content: space-between;
  }

  .hero-copy,
  .workspace,
  .content-section {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 38px;
  }

  .panel {
    min-height: auto;
    padding: 18px;
  }

  textarea {
    min-height: 160px;
  }
}

@media (max-width: 520px) {
  .app-shell,
  .history-section,
  .content-section,
  .site-footer {
    width: min(100% - 20px, 1180px);
  }

  h1 {
    font-size: 32px;
  }

  .lead {
    font-size: 16px;
  }

  .panel-heading,
  .input-actions,
  .history-row {
    align-items: stretch;
    flex-direction: column;
  }

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