:root {
    --bg:      #f7f5f0;
    --surface: #ffffff;
    --text:    #1a1614;
    --muted:   #7c756e;
    --accent:  #a0341e;
    --border:  #e2ddd7;
    --radius:  14px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

nav { background: white; padding: 1rem 2rem; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.nav-logo { font-weight: 800; font-size: 1.2rem; text-decoration: none; color: var(--text); }
.nav-links a { text-decoration: none; color: var(--text); margin-left: 15px; font-size: 0.95rem; }
.nav-links a:hover { color: var(--accent); }

.page-header { text-align: center; padding: 56px 20px 30px; }
.page-header h1 { font-family: 'Cormorant Garamond', serif; font-size: clamp(2.8rem, 8vw, 5rem); font-weight: 700; letter-spacing: -0.01em; line-height: 1; }
.page-header .tagline { margin-top: 10px; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.15em; text-transform: uppercase; color: var(--muted); }
.header-rule { display: flex; align-items: center; gap: 14px; max-width: 280px; margin: 18px auto 0; }
.header-rule span { flex: 1; height: 1px; background: var(--border); }
.header-rule em { font-family: 'Cormorant Garamond', serif; font-style: italic; color: var(--muted); font-size: 1.1rem; }

.wrap { max-width: 720px; margin: 0 auto; padding: 0 20px 80px; }

.input-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 22px; display: flex; gap: 10px; box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.input-card input[type=text] {
    flex: 1; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px;
    font-size: 0.95rem; font-family: 'Inter', sans-serif; color: var(--text); background: var(--bg);
}
.input-card input[type=text]:focus { outline: none; border-color: var(--accent); }
.input-card button {
    border: none; border-radius: 10px; padding: 12px 22px; font-size: 0.9rem; font-weight: 600;
    background: var(--accent); color: white; cursor: pointer; white-space: nowrap;
}
.input-card button:disabled { opacity: 0.55; cursor: default; }
.input-card button:not(:disabled):hover { filter: brightness(1.08); }

.hint { text-align: center; color: var(--muted); font-size: 0.82rem; margin-top: 12px; }
.error-msg { text-align: center; color: var(--accent); font-size: 0.88rem; margin-top: 14px; display: none; }

.status-area { text-align: center; margin-top: 30px; display: none; }
.spinner {
    width: 26px; height: 26px; margin: 0 auto 14px; border-radius: 50%;
    border: 3px solid var(--border); border-top-color: var(--accent);
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.status-text { color: var(--muted); font-style: italic; font-family: 'Cormorant Garamond', serif; font-size: 1.15rem; }

.recipe-card {
    margin-top: 36px; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.recipe-card.js-managed { display: none; }
.recipe-thumb { width: 100%; max-height: 360px; object-fit: cover; display: block; background: var(--border); }
.recipe-body { padding: 26px 28px 30px; }
.recipe-title { font-family: 'Cormorant Garamond', serif; font-size: 2.1rem; font-weight: 700; line-height: 1.15; }
.recipe-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: center; }
.pill { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; padding: 4px 10px; border-radius: 999px; }
.pill-servings { background: #f0ede7; color: var(--muted); }
.pill-confidence-high { background: #e7f3ea; color: #2f7a43; }
.pill-confidence-medium { background: #fbf1de; color: #a06a1e; }
.pill-confidence-low { background: #f8e7e5; color: var(--accent); }
.source-link { font-size: 0.82rem; color: var(--muted); text-decoration: none; margin-left: auto; }
.source-link:hover { color: var(--accent); }

.section-label {
    font-size: 0.72rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
    color: var(--muted); margin: 26px 0 10px;
}
ul.ingredient-list, ol.step-list { padding-left: 0; list-style: none; }
ul.ingredient-list li {
    display: flex; gap: 8px; padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: 0.95rem;
}
ul.ingredient-list li:last-child { border-bottom: none; }
.ing-qty { color: var(--accent); font-weight: 600; min-width: 90px; flex-shrink: 0; }
ol.step-list { counter-reset: step; }
ol.step-list li {
    counter-increment: step; padding: 10px 0 10px 34px; position: relative; font-size: 0.95rem; line-height: 1.5;
    border-bottom: 1px dashed var(--border);
}
ol.step-list li:last-child { border-bottom: none; }
ol.step-list li::before {
    content: counter(step); position: absolute; left: 0; top: 9px;
    width: 24px; height: 24px; border-radius: 50%; background: var(--bg); border: 1px solid var(--border);
    font-size: 0.75rem; font-weight: 700; color: var(--accent); display: flex; align-items: center; justify-content: center;
}
.inferred-tag {
    font-size: 0.65rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
    color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 1px 7px; margin-left: 8px;
}
.notes-box { margin-top: 20px; padding: 14px 16px; background: var(--bg); border-radius: 10px; font-size: 0.88rem; color: var(--muted); }

.card-actions { margin-top: 26px; text-align: center; }
.copy-btn {
    border: 1px solid var(--border); background: var(--bg); color: var(--text);
    border-radius: 10px; padding: 10px 20px; font-size: 0.85rem; font-weight: 600;
    cursor: pointer; font-family: 'Inter', sans-serif;
}
.copy-btn:hover { border-color: var(--accent); color: var(--accent); }
.copy-btn.copied { border-color: #2f7a43; color: #2f7a43; background: #e7f3ea; }

.history-section { margin-top: 60px; }
.history-section .section-label { margin-bottom: 16px; text-align: center; }
.history-section .browse-all { display: block; text-align: center; margin-top: -6px; margin-bottom: 20px; font-size: 0.82rem; color: var(--muted); text-decoration: none; }
.history-section .browse-all:hover { color: var(--accent); }
.history-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.history-item { cursor: pointer; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); background: var(--surface); }
.history-item img { width: 100%; height: 100px; object-fit: cover; display: block; background: var(--bg); }
.history-item .h-title { font-size: 0.78rem; padding: 8px 10px; line-height: 1.3; }
.history-item:hover { border-color: var(--accent); }

/* Library list page */
.back-link { display: inline-block; color: var(--muted); text-decoration: none; font-size: 0.85rem; margin-bottom: 20px; }
.back-link:hover { color: var(--accent); }
.library-list { display: flex; flex-direction: column; gap: 2px; }
.library-item {
    display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--surface);
    border: 1px solid var(--border); text-decoration: none; color: var(--text);
    border-radius: 10px; margin-bottom: 8px;
}
.library-item:hover { border-color: var(--accent); }
.library-item img { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; background: var(--bg); flex-shrink: 0; }
.library-item .l-thumb-placeholder { width: 52px; height: 52px; border-radius: 8px; background: var(--bg); flex-shrink: 0; }
.library-item .l-info { min-width: 0; flex: 1; }
.library-item .l-title { font-family: 'Cormorant Garamond', serif; font-size: 1.25rem; font-weight: 700; line-height: 1.2; }
.library-item .l-meta { font-size: 0.78rem; color: var(--muted); margin-top: 3px; }
.library-empty { text-align: center; color: var(--muted); padding: 40px 0; }
