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

:root {
  --bg: #F7F7F2;
  --surface: #FFFFFF;
  --border: #E2E2DC;
  --text: #1C1C1C;
  --muted: #6B6B6B;
  --accent: #2A7A3B;
  --accent-light: #EEF6F0;
  --danger: #C0392B;
  --radius: 10px;
  --shadow: 0 1px 4px rgba(0,0,0,0.08), 0 4px 16px rgba(0,0,0,0.06);
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ── */
.container { max-width: 860px; margin: 0 auto; padding: 0 20px; }

/* ── Header ── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.site-header h1 {
  font-family: Georgia, serif;
  font-size: 1.4rem;
  font-weight: normal;
  color: var(--accent);
  letter-spacing: -0.02em;
}
.site-header h1 span { color: var(--muted); font-size: 0.9rem; font-weight: normal; }
.header-link { font-size: 0.875rem; color: var(--muted); }
.header-link:hover { color: var(--accent); }

/* ── Parse Form ── */
.parse-section { padding: 40px 0 24px; }
.parse-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.parse-row { display: flex; gap: 10px; }
.parse-input {
  flex: 1;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.parse-input:focus { border-color: var(--accent); }
.parse-input::placeholder { color: #B0B0A8; }

.btn {
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { opacity: 0.88; }
.btn-ghost { background: transparent; color: var(--muted); border: 1.5px solid var(--border); }
.btn-ghost:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { opacity: 0.88; }
.btn-sm { padding: 8px 16px; font-size: 0.85rem; }

/* ── Status / Error ── */
.status-msg {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
}
.status-msg.loading { background: var(--accent-light); color: var(--accent); }
.status-msg.error { background: #FDF0EF; color: var(--danger); }
.hidden { display: none !important; }

/* ── Paste Toggle ── */
.paste-toggle { margin-top: 10px; font-size: 0.8rem; }
.paste-toggle a { color: var(--muted); }
.paste-toggle a:hover { color: var(--accent); }

/* ── Paste Panel ── */
.paste-panel {
  margin-top: 16px;
  padding: 20px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
}
.paste-label {
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 12px;
  line-height: 1.5;
}
.paste-input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
  line-height: 1.5;
}
.paste-input:focus { border-color: var(--accent); }
.paste-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 12px; }

/* ── Preview Card ── */
.preview-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-top: 24px;
  overflow: hidden;
}
.preview-card-header {
  padding: 24px 28px 16px;
  border-bottom: 1px solid var(--border);
}
.preview-title {
  font-family: Georgia, serif;
  font-size: 1.7rem;
  font-weight: normal;
  line-height: 1.25;
  margin-bottom: 10px;
}
.preview-desc { color: var(--muted); font-size: 0.95rem; margin-bottom: 14px; }
.meta-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.meta-chip {
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 600;
}
.preview-body { display: grid; grid-template-columns: 1fr 1.5fr; gap: 0; }
.preview-col { padding: 24px 28px; }
.preview-col + .preview-col { border-left: 1px solid var(--border); }
.col-heading {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
}
.ingredients-list { list-style: none; }
.ingredients-list li {
  padding: 6px 0;
  border-bottom: 1px solid var(--bg);
  font-size: 0.93rem;
  line-height: 1.4;
}
.ingredients-list li:last-child { border-bottom: none; }
.ingredients-list li.ingredient-group-heading {
  border-bottom: none;
  padding: 14px 0 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}
.ingredients-list li.ingredient-group-heading:first-child { padding-top: 2px; }
.instructions-list { list-style: none; counter-reset: step; }
.instructions-list li {
  counter-increment: step;
  display: flex;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--bg);
  font-size: 0.93rem;
  line-height: 1.5;
}
.instructions-list li:last-child { border-bottom: none; }
.instructions-list li::before {
  content: counter(step);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}
.preview-actions {
  padding: 16px 28px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
}
.preview-source { flex: 1; font-size: 0.8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-source a { color: var(--accent); }

/* ── Saved Recipes ── */
.recipes-section { padding: 32px 0 60px; }
.section-heading {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 16px;
}
.recipes-empty { color: var(--muted); font-size: 0.95rem; padding: 20px 0; }
.recipes-grid { display: flex; flex-direction: column; gap: 2px; }
.recipe-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid var(--border);
  transition: border-color 0.15s;
}
.recipe-row:hover { border-color: var(--accent); }
.recipe-row-title { flex: 1; font-size: 0.95rem; font-weight: 500; }
.recipe-row-title a { color: var(--text); }
.recipe-row-title a:hover { color: var(--accent); text-decoration: none; }
.recipe-row-date { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.recipe-row-del {
  background: none;
  border: none;
  cursor: pointer;
  color: #C0C0B8;
  font-size: 1.1rem;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 4px;
  transition: color 0.15s;
}
.recipe-row-del:hover { color: var(--danger); }

/* ── Recipe Page ── */
.recipe-page { padding: 40px 0 80px; }
.recipe-back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 0.875rem; margin-bottom: 28px; }
.recipe-back:hover { color: var(--accent); text-decoration: none; }
.recipe-title {
  font-family: Georgia, serif;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: normal;
  line-height: 1.2;
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}
.recipe-description { color: var(--muted); font-size: 1rem; line-height: 1.6; margin-bottom: 20px; max-width: 640px; }
.recipe-meta { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 28px; }
.recipe-meta-item {
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 0.82rem;
  font-weight: 600;
}
.recipe-source { font-size: 0.82rem; color: var(--muted); margin-bottom: 36px; }
.recipe-source a { color: var(--accent); }
.recipe-body { display: grid; grid-template-columns: 280px 1fr; gap: 40px; align-items: start; }
.recipe-ingredients-col { position: sticky; top: 24px; }
.recipe-col-heading {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--accent);
}
.recipe-ingredients { list-style: none; }
.recipe-ingredients li {
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
  line-height: 1.4;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.recipe-ingredients li::before { content: '·'; color: var(--accent); font-size: 1.2rem; flex-shrink: 0; }
.recipe-ingredients li:last-child { border-bottom: none; }
.recipe-ingredients li.ingredient-group-heading {
  display: block;
  border-bottom: none;
  padding: 18px 0 4px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.recipe-ingredients li.ingredient-group-heading:first-child { padding-top: 2px; }
.recipe-ingredients li.ingredient-group-heading::before { display: none; }
.recipe-instructions { list-style: none; counter-reset: step; }
.recipe-instructions li {
  counter-increment: step;
  display: flex;
  gap: 18px;
  margin-bottom: 24px;
  font-size: 0.97rem;
  line-height: 1.65;
}
.recipe-instructions li::before {
  content: counter(step);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 4px;
}
.recipe-actions { display: flex; gap: 10px; margin-bottom: 40px; }

/* ── Print ── */
@media print {
  .recipe-back, .recipe-actions, .site-header { display: none; }
  body { background: #fff; }
  .recipe-body { display: grid; grid-template-columns: 260px 1fr; }
  .recipe-ingredients-col { position: static; }
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .parse-row { flex-direction: column; }
  .preview-body { grid-template-columns: 1fr; }
  .preview-col + .preview-col { border-left: none; border-top: 1px solid var(--border); }
  .recipe-body { grid-template-columns: 1fr; }
  .recipe-ingredients-col { position: static; }
  .preview-title { font-size: 1.35rem; }
  .preview-card-header, .preview-col, .preview-actions { padding-left: 18px; padding-right: 18px; }
}
