/* Recipe Scaler styles. Light/dark via prefers-color-scheme. */
:root {
    --bg: #faf5ee;
    --bg-dots: #efe5d6;
    --surface: #ffffff;
    --surface-2: #f6efe5;
    --ink: #2d2620;
    --ink-soft: #6f6358;
    --line: #ebe1d3;
    --accent: #d8613c;
    --accent-ink: #ffffff;
    --accent-soft: #fbe6dc;
    --sage: #5f8a6b;
    --sage-soft: #e3efe5;
    --butter: #fff4cf;
    --butter-line: #f1dc94;
    --butter-ink: #6b5413;
    --danger-soft: #fde8e5;
    --danger-line: #f3c1b9;
    --danger-ink: #8f2d1f;
    --shadow: 0 1px 2px rgba(61, 41, 20, .06), 0 8px 24px rgba(61, 41, 20, .07);
    --radius: 22px;
    --radius-sm: 14px;
    --font-body: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1d1916;
        --bg-dots: #2a2420;
        --surface: #27221e;
        --surface-2: #312a25;
        --ink: #f4ece3;
        --ink-soft: #b6a99c;
        --line: #3b332d;
        --accent: #ee7a52;
        --accent-ink: #1d1916;
        --accent-soft: #4a2c21;
        --sage: #8fbb99;
        --sage-soft: #263329;
        --butter: #3a311a;
        --butter-line: #5c4c22;
        --butter-ink: #f3dc93;
        --danger-soft: #3f211c;
        --danger-line: #6b3329;
        --danger-ink: #f6b4a8;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
        color-scheme: dark;
    }
}

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

body {
    font-family: var(--font-body);
    font-size: 17px;
    line-height: 1.55;
    color: var(--ink);
    background-color: var(--bg);
    background-image: radial-gradient(var(--bg-dots) 1.2px, transparent 1.2px);
    background-size: 22px 22px;
    padding: 40px 20px 64px;
    -webkit-font-smoothing: antialiased;
}

.container { max-width: 960px; margin: 0 auto; }
.narrow { max-width: 640px; margin: 0 auto; }

/* ---------- header ---------- */
.site-header { text-align: center; margin-bottom: 28px; }

.logo {
    display: inline-grid;
    place-items: center;
    width: 56px;
    height: 56px;
    border-radius: 18px;
    background: var(--accent);
    color: var(--accent-ink);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 22px;
    transform: rotate(-6deg);
    box-shadow: var(--shadow);
    margin-bottom: 14px;
}

h1 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 2.7rem);
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.subtitle { color: var(--ink-soft); margin-top: 8px; }

/* ---------- cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px;
}

.form-card { margin-bottom: 24px; }

/* ---------- form ---------- */
fieldset { border: none; min-width: 0; }

.form-group { margin-bottom: 22px; }

.field-label, legend {
    display: block;
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 8px;
}

input[type="text"],
input[type="number"] {
    width: 100%;
    font: inherit;
    color: var(--ink);
    background: var(--surface-2);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    padding: 13px 16px;
    transition: border-color .15s, background .15s;
}

input[type="text"]:focus,
input[type="number"]:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--surface);
}

input::placeholder { color: var(--ink-soft); opacity: .7; }

.url-input { font-size: 1rem; }

textarea {
    width: 100%;
    font: inherit;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--ink);
    background: var(--surface-2);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    resize: vertical;
}

textarea:focus { outline: none; border-color: var(--accent); background: var(--surface); }

.field-hint { margin-top: 8px; }
.field-hint a, .bookmark-card a:not(.bookmarklet) { color: var(--accent); font-weight: 500; }


.imported {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--sage-soft);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
}

.imported-badge { font-weight: 700; color: var(--sage); }
.start-over { color: var(--ink-soft); font-size: 0.9rem; }

.bookmark-card { margin-top: 8px; }
.bookmark-card p { margin-bottom: 12px; }
.bookmark-steps { padding-left: 22px; margin-bottom: 12px; }
.bookmark-steps li { margin-bottom: 10px; }

.bookmarklet {
    display: inline-block;
    margin: 6px 0 2px;
    padding: 8px 18px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 700;
    text-decoration: none;
    cursor: grab;
    box-shadow: var(--shadow);
}

/* segmented Servings / Multiplier switch */
.segmented {
    display: inline-flex;
    background: var(--surface-2);
    border-radius: 999px;
    padding: 4px;
    gap: 4px;
}

.segmented label {
    position: relative;
    cursor: pointer;
}

.segmented input {
    position: absolute;
    opacity: 0;
    inset: 0;
    cursor: pointer;
}

.segmented span {
    display: block;
    padding: 8px 20px;
    border-radius: 999px;
    font-weight: 500;
    color: var(--ink-soft);
    transition: background .15s, color .15s;
}

.segmented input:checked + span {
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .12);
}

.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* servings stepper */
.stepper {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.stepper input[type="number"] {
    width: 88px;
    text-align: center;
    font-weight: 700;
    font-size: 1.15rem;
    -moz-appearance: textfield;
}

.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.round-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
    transition: border-color .15s, transform .1s;
}

.round-btn:hover { border-color: var(--accent); }
.round-btn:active { transform: scale(.94); }

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

.chip {
    font: inherit;
    font-weight: 500;
    padding: 7px 16px;
    border-radius: 999px;
    border: 2px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    transition: all .15s;
}

.chip:hover { border-color: var(--accent); }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

[hidden] { display: none !important; }

details.form-group {
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
}

details summary {
    cursor: pointer;
    font-weight: 500;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

details summary::-webkit-details-marker { display: none; }

details summary::before {
    content: '+';
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--surface);
    font-weight: 700;
    transition: transform .2s;
}

details[open] summary::before { content: '–'; }

details.form-group[open] summary { margin-bottom: 8px; }
details.form-group input { max-width: 160px; background: var(--surface); }

.hint { color: var(--ink-soft); font-size: 0.9rem; }
details .hint { margin-bottom: 10px; }

/* toggle switch for unit conversion */
.switch {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    cursor: pointer;
}

.switch input {
    appearance: none;
    -webkit-appearance: none;
    flex: none;
    width: 46px;
    height: 28px;
    border-radius: 999px;
    background: var(--line);
    position: relative;
    cursor: pointer;
    transition: background .2s;
    margin-top: 1px;
}

.switch input::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
    transition: transform .2s;
}

.switch input:checked { background: var(--sage); }
.switch input:checked::after { transform: translateX(18px); }
.switch input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch strong { display: block; font-weight: 500; }

.submit-btn {
    width: 100%;
    font: inherit;
    font-weight: 700;
    font-size: 1.05rem;
    padding: 15px 24px;
    border: none;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-ink);
    cursor: pointer;
    box-shadow: 0 6px 16px -6px var(--accent);
    transition: transform .1s, filter .15s;
}

.submit-btn:hover { filter: brightness(1.06); }
.submit-btn:active { transform: translateY(1px); }

/* ---------- messages ---------- */
.error {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    background: var(--danger-soft);
    border: 1px solid var(--danger-line);
    color: var(--danger-ink);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    margin-bottom: 24px;
}

.error::before { content: '😬'; }

.error[hidden] { display: none; }

/* ---------- recipe ---------- */
.recipe-card { padding: 36px; }

.recipe-head { margin-bottom: 24px; }

.eyebrow {
    display: inline-block;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 6px;
}

.recipe-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.8rem, 4.5vw, 2.5rem);
    letter-spacing: -0.02em;
    line-height: 1.1;
    margin-bottom: 14px;
}

.recipe-times {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.recipe-times li {
    background: var(--surface-2);
    border-radius: 999px;
    padding: 5px 14px;
    font-size: 0.92rem;
}

.recipe-times span { font-weight: 700; margin-right: 2px; }

.times-note { margin-top: 8px; font-size: 0.85rem; }

.scale-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
    margin-bottom: 28px;
}

.recipe-meta {
    display: inline-block;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 700;
    padding: 6px 16px;
    border-radius: 999px;
}

.scale-info { color: var(--ink-soft); font-size: 0.95rem; flex: 1 1 260px; }

.scale-info.warning {
    flex-basis: 100%;
    background: var(--butter);
    border: 1px solid var(--butter-line);
    color: var(--butter-ink);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
}

.recipe-body {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    gap: 40px;
    align-items: start;
}

.section-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.4rem;
    margin-bottom: 4px;
}

.section-hint { margin-bottom: 12px; }

.ingredients-panel {
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    padding: 22px;
    position: sticky;
    top: 20px;
}

.ingredients-list { list-style: none; }

.ingredients-list li + li { border-top: 1px dashed var(--line); }

.ingredients-list label {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 10px 0;
    cursor: pointer;
}

.ingredients-list input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    flex: none;
    width: 22px;
    height: 22px;
    margin-top: 2px;
    border-radius: 7px;
    border: 2px solid var(--ink-soft);
    background: var(--surface);
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: all .15s;
}

.ingredients-list input[type="checkbox"]::after {
    content: '✓';
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    transform: scale(0);
    transition: transform .15s;
}

.ingredients-list input:checked { background: var(--sage); border-color: var(--sage); }
.ingredients-list input:checked::after { transform: scale(1); }
.ingredients-list input:checked + span { text-decoration: line-through; color: var(--ink-soft); }
.ingredients-list input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.totals-box {
    background: var(--sage-soft);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    margin-bottom: 16px;
}

.totals-box h3 { font-size: 0.95rem; margin-bottom: 6px; color: var(--sage); }
.totals-list { list-style: none; }

.instructions-list {
    list-style: none;
    counter-reset: step;
}

.instructions-list li {
    counter-increment: step;
    position: relative;
    padding: 0 0 22px 52px;
}

.instructions-list li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: 0;
    width: 34px;
    height: 34px;
    border-radius: 12px;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 700;
    display: grid;
    place-items: center;
}

.instructions-list li:not(:last-child)::after {
    content: '';
    position: absolute;
    left: 16px;
    top: 40px;
    bottom: 6px;
    width: 2px;
    background: var(--line);
    border-radius: 2px;
}

.recipe-footer {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--line);
    display: grid;
    gap: 16px;
}

.source-link a {
    color: var(--accent);
    font-weight: 700;
    text-decoration: none;
}

.source-link a:hover { text-decoration: underline; }

.original-recipe {
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
}

.original-recipe[open] summary { margin-bottom: 14px; }
.original-recipe h3 { font-size: 1rem; margin: 14px 0 6px; }
.original-recipe .ingredients-list li { padding: 6px 0; color: var(--ink-soft); }
.original-recipe ol { padding-left: 22px; color: var(--ink-soft); }
.original-recipe ol li { margin-bottom: 6px; }

.site-footer {
    text-align: center;
    color: var(--ink-soft);
    font-size: 0.85rem;
    margin-top: 32px;
}

@media (max-width: 760px) {
    body { padding: 24px 14px 48px; }
    .card, .recipe-card { padding: 22px; }
    .recipe-body { grid-template-columns: 1fr; gap: 28px; }
    .ingredients-panel { position: static; padding: 18px; }
}

@media print {
    body { background: #fff; padding: 0; }
    .form-card, .site-header, .site-footer, .original-recipe, .times-note { display: none; }
    .card { box-shadow: none; border: none; }
    .ingredients-panel { position: static; }
}

.site-footer a { color: inherit; }

.loading { opacity: .6; pointer-events: none; }

noscript p {
    max-width: 640px;
    margin: 0 auto 24px;
    text-align: center;
}

.link-button {
    background: none;
    border: none;
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
}
