:root {
    --font-display: "Fraunces", Georgia, serif;
    --font-body: "Work Sans", -apple-system, "Segoe UI", sans-serif;
    --font-mono: "IBM Plex Mono", monospace;

    --line: color-mix(in srgb, var(--ink) 14%, transparent);
    --line-strong: color-mix(in srgb, var(--ink) 29%, transparent);
    --accent-line: color-mix(in srgb, var(--accent) 34%, transparent);
    --focus-ring: color-mix(in srgb, var(--accent) 25%, transparent);
    --shadow-sm: 0 1px 2px #15172115;
    --shadow-md: 0 8px 24px #1517211c;
    --shadow-lg: 0 20px 50px #15172126;
    --radius: 18px;
    --hero-ink: #fffdf7;
    --on-danger: #fff;
    --success-ink: #2c5b34;
    --info: #2c5b8a;
    --info-soft: #e8f0f7;
}

:root,
[data-palette="sage"] {
    --cream: #f6f4eb;
    --cream-deep: #ecebdf;
    --paper: #fffdf7;
    --ink: #263129;
    --ink-soft: #515e52;
    --ink-faint: #657165;

    --accent: #496752;
    --accent-deep: #304d3b;
    --accent-soft: #e4ede2;
    --on-accent: #fff;
    --background-glow: #e1ebda;
    --background-wash: #eedbcc;
    --hero-shade: #213a2b;
    --gold: #a26d2e;
    --green: #4a7c59;
    --green-soft: #e2efe4;
    --danger: #a33;
    --danger-soft: #f9e5e5;
    --native-scheme: light;
}

[data-palette="ocean"] {
    --cream: #edf5fa;
    --cream-deep: #e0edf5;
    --paper: #f8fcff;
    --ink: #142d42;
    --ink-soft: #35546d;
    --ink-faint: #49667b;
    --accent: #265f94;
    --accent-deep: #194774;
    --accent-soft: #dcecf9;
    --background-glow: #cfe7f8;
    --background-wash: #d8ede9;
    --hero-shade: #132f4a;
}

[data-palette="lavender"] {
    --cream: #f5f0fa;
    --cream-deep: #ece3f5;
    --paper: #fdfaff;
    --ink: #30253e;
    --ink-soft: #51415f;
    --ink-faint: #645372;
    --accent: #6b4b91;
    --accent-deep: #513371;
    --accent-soft: #eee0f8;
    --background-glow: #e4d6f4;
    --background-wash: #f4e1e9;
    --hero-shade: #352347;
}

[data-palette="terracotta"] {
    --cream: #faf0e6;
    --cream-deep: #f2e2d4;
    --paper: #fffaf4;
    --ink: #392920;
    --ink-soft: #61483b;
    --ink-faint: #745849;
    --accent: #9b4b32;
    --accent-deep: #783720;
    --accent-soft: #f6dfd2;
    --background-glow: #f2d9c7;
    --background-wash: #f8e6ce;
    --hero-shade: #4b261d;
}

[data-palette="midnight"] {
    --cream: #171c2b;
    --cream-deep: #20263a;
    --paper: #252c40;
    --ink: #eef1fb;
    --ink-soft: #c5cce0;
    --ink-faint: #abb5cd;
    --accent: #aebfff;
    --accent-deep: #c9d4ff;
    --accent-soft: #333f5f;
    --on-accent: #17223e;
    --background-glow: #293655;
    --background-wash: #332b4b;
    --hero-shade: #171d33;
    --gold: #f2bf71;
    --green: #a3dcb4;
    --green-soft: #233b36;
    --success-ink: #b6e6c2;
    --info: #b9d6ff;
    --info-soft: #273a54;
    --danger: #ffb4bb;
    --danger-soft: #492d39;
    --on-danger: #331d26;
    --native-scheme: dark;
}

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

html {
    scroll-behavior: smooth;
    color-scheme: var(--native-scheme);
    background:
        radial-gradient(ellipse at 5% 12%, var(--background-glow) 0%, transparent 43%),
        radial-gradient(ellipse at 96% 47%, var(--background-wash) 0%, transparent 37%),
        repeating-linear-gradient(115deg, transparent 0 7px, color-mix(in srgb, var(--ink) 2%, transparent) 7px 8px),
        var(--cream);
}

body {
    font-family: var(--font-body);
    font-weight: 400;
    max-width: 1060px;
    margin: 0 auto;
    padding: 0 24px 60px;
    color: var(--ink);
    line-height: 1.65;
    min-height: 100vh;
}

[hidden] {
    display: none !important;
}

:focus-visible {
    outline: 2px solid var(--accent-deep);
    outline-offset: 3px;
}

.collection-hero {
    display: flex;
    align-items: end;
    min-height: clamp(230px, 34vw, 355px);
    margin-bottom: 25px;
    padding: clamp(20px, 5vw, 56px);
    border-radius: 26px;
    background:
        linear-gradient(90deg, var(--hero-shade) 8%, color-mix(in srgb, var(--hero-shade) 93%, transparent) 38%, transparent),
        radial-gradient(ellipse at 87% 20%, var(--accent) 0%, var(--hero-shade) 72%);
    box-shadow: var(--shadow-lg);
    color: var(--hero-ink);
}

.collection-intro {
    width: min(100%, 490px);
}

.collection-hero h1 {
    margin-bottom: 18px;
    font: 650 clamp(2.4rem, 6.2vw, 4.75rem) / 1.02 var(--font-display);
    letter-spacing: -0.045em;
}

.collection-hero .search-bar form {
    margin: 0;
    padding: 5px;
    gap: 5px;
    flex-wrap: nowrap;
    border-radius: 14px;
    background: var(--paper);
}

.collection-hero input[type="search"] {
    width: 100%;
    min-width: 0;
    padding: 8px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--ink);
    font: 1rem var(--font-body);
}

.collection-hero button {
    padding: 9px 14px;
    border-radius: 9px;
    background: var(--accent-deep);
}

.empty-collection {
    padding: 32px 20px;
    border: 1px solid var(--accent-line);
    border-radius: var(--radius);
    background: linear-gradient(120deg, var(--paper), var(--accent-soft));
    text-align: center;
}

.empty-collection a {
    color: var(--accent-deep);
    font-weight: 600;
}

.recipe-instructions {
    white-space: pre-line;
    overflow-wrap: anywhere;
}

header {
    padding: 22px 0;
    margin-bottom: 28px;
    border-bottom: 1px solid var(--line);
}

.site-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.logo {
    font-family: var(--font-display);
    font-size: 1.7rem;
    font-weight: 700;
    font-variation-settings: "opsz" 144;
    text-decoration: none;
    color: var(--accent);
    letter-spacing: -0.02em;
    transition: color 0.2s ease;
}

.logo:hover {
    color: var(--accent-deep);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.nav-link {
    text-decoration: none;
    color: var(--ink-soft);
    font-weight: 600;
    font-size: 0.95rem;
    padding: 8px 14px;
    border-radius: 999px;
    background: transparent;
    border: 1px solid transparent;
    transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.nav-link:hover {
    color: var(--accent-deep);
    background: var(--accent-soft);
    border-color: var(--accent-line);
}

.theme-picker {
    position: relative;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 8px 13px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--paper);
    color: var(--ink);
    font: 600 0.95rem var(--font-body);
    cursor: pointer;
}

.theme-toggle::after {
    width: 6px;
    height: 6px;
    margin-top: -3px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg);
    content: "";
}

.theme-toggle:hover,
.theme-toggle[aria-expanded="true"] {
    border-color: var(--accent-line);
    background: var(--accent-soft);
}

.theme-palettes {
    position: absolute;
    z-index: 5;
    inset-block-start: calc(100% + 8px);
    inset-inline-end: 0;
    display: grid;
    gap: 2px;
    width: 188px;
    max-width: calc(100vw - 32px);
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--paper);
    box-shadow: var(--shadow-lg);
}

.theme-option {
    display: grid;
    grid-template-columns: 18px 1fr 12px;
    align-items: center;
    gap: 9px;
    padding: 8px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--ink);
    font: 500 0.875rem var(--font-body);
    text-align: start;
    cursor: pointer;
}

.theme-option:hover,
.theme-option[aria-pressed="true"] {
    background: var(--accent-soft);
}

.theme-option[aria-pressed="true"]::after {
    width: 6px;
    height: 10px;
    border-right: 2px solid var(--accent-deep);
    border-bottom: 2px solid var(--accent-deep);
    transform: rotate(45deg) translateY(-2px);
    content: "";
}

.theme-swatch {
    display: block;
    width: 18px;
    height: 18px;
    border: 1px solid var(--line-strong);
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent) 50%, var(--cream) 50%);
}

.btn {
    background: linear-gradient(135deg, var(--accent), var(--accent-deep));
    color: var(--on-accent);
    padding: 11px 20px;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    filter: brightness(1.05);
}

.flash-container {
    margin-bottom: 24px;
}

.flash {
    padding: 14px 18px;
    border-radius: 12px;
    margin-bottom: 10px;
    font-weight: 500;
    font-size: 0.95rem;
    border-left: 4px solid transparent;
    box-shadow: var(--shadow-sm);
}

.flash-success {
    background: var(--green-soft);
    color: var(--success-ink);
    border-left-color: var(--green);
}

.flash-info {
    background: var(--info-soft);
    color: var(--info);
    border-left-color: var(--info);
}

.flash-error {
    background: var(--danger-soft);
    color: var(--danger);
    border-left-color: var(--danger);
}

main > p:first-child {
    color: var(--ink-soft);
    margin-bottom: 20px;
}

/* ------- Search ------- */
form input[type="text"] {
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    width: 100%;
    max-width: 480px;
    font-family: var(--font-body);
    font-size: 0.98rem;
    background: var(--paper);
    color: var(--ink);
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

form input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

form button {
    padding: 12px 22px;
    border: none;
    background: linear-gradient(135deg, var(--accent), var(--accent-deep));
    color: var(--on-accent);
    border-radius: 12px;
    cursor: pointer;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.95rem;
    transition: transform 0.15s ease, filter 0.15s ease;
}

form button:hover {
    transform: translateY(-1px);
    filter: brightness(1.1);
}

main > form,
.search-bar form {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

main > form input[type="text"],
.search-bar form input[type="text"] {
    flex: 1;
    min-width: 200px;
}

/* ------- Filter bar ------- */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 22px;
    padding: 12px 16px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
}

.filter-pill {
    text-decoration: none;
    padding: 7px 14px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.9rem;
    background: var(--cream-deep);
    color: var(--ink-soft);
    border: 1px solid transparent;
    transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.filter-pill:hover {
    background: var(--accent-soft);
    color: var(--accent-deep);
    transform: translateY(-1px);
}

.filter-pill.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-deep));
    color: var(--on-accent);
    box-shadow: var(--shadow-sm);
}

.filter-tag {
    text-decoration: none;
    background: var(--accent-soft);
    color: var(--accent-deep);
    padding: 7px 12px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: background 0.2s ease, color 0.2s ease;
}

.filter-tag:hover {
    background: var(--accent);
    color: var(--on-accent);
}

.filter-clear {
    text-decoration: none;
    color: var(--ink-faint);
    font-size: 0.9rem;
    font-weight: 500;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px dashed var(--line-strong);
    transition: color 0.2s ease, border-color 0.2s ease;
}

.filter-clear:hover {
    color: var(--danger);
    border-color: var(--danger);
}

.filter-count {
    margin-left: auto;
    color: var(--ink-faint);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    white-space: nowrap;
}

/* ------- Recipe list ------- */
ul#recipe-list {
    list-style: none;
    display: grid;
    gap: 14px;
    margin-top: 8px;
}

#recipe-list li {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px;
    position: relative;
    box-shadow: var(--shadow-sm);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

#recipe-list li:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent-line);
}

#recipe-list li a:first-of-type {
    text-decoration: none;
    color: var(--ink);
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    transition: color 0.2s ease;
}

#recipe-list li a:first-of-type:hover {
    color: var(--accent);
}

.tag,
a.tag {
    display: inline-block;
    background: var(--accent-soft);
    color: var(--accent-deep);
    padding: 3px 12px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    margin-left: 6px;
    margin-top: 6px;
    text-decoration: none;
    transition: background 0.2s ease, color 0.2s ease;
}

.tag:hover,
a.tag:hover {
    background: var(--accent);
    color: var(--on-accent);
}

.star {
    color: var(--gold);
    margin-right: 4px;
}

.mini-rating {
    color: var(--gold);
    font-size: 0.85rem;
    margin-left: 8px;
    letter-spacing: 1px;
}

.favorite-btn {
    background: var(--accent-soft);
    color: var(--accent-deep);
    border: 1px solid var(--accent-line);
    padding: 10px 18px;
    border-radius: 999px;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 600;
    transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.favorite-btn:hover {
    background: var(--accent);
    color: var(--on-accent);
    transform: translateY(-1px);
}

/* ------- Recipe detail actions ------- */
.actions-bar {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--line);
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 12px 22px;
    border-radius: 999px;
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid transparent;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease, color 0.2s ease;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.edit-btn {
    background: linear-gradient(135deg, var(--accent), var(--accent-deep));
    color: var(--on-accent);
}

.delete-action-btn {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: var(--danger);
}

.delete-action-btn:hover {
    background: var(--danger);
    color: var(--on-danger);
}

.delete-btn {
    float: right;
    background: none;
    border: none;
    color: var(--ink-faint);
    cursor: pointer;
    font-size: 1.05rem;
    line-height: 1;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, color 0.2s ease;
}

.delete-btn:hover {
    background: var(--danger-soft);
    color: var(--danger);
}

/* ------- View toggle ------- */
.view-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
}

.view-btn {
    background: var(--paper);
    border: 1px solid var(--line);
    color: var(--ink-soft);
    padding: 8px 18px;
    border-radius: 999px;
    cursor: pointer;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.9rem;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.view-btn:hover {
    border-color: var(--accent);
    color: var(--accent-deep);
}

.view-btn.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-deep));
    color: var(--on-accent);
    border-color: transparent;
    box-shadow: var(--shadow-sm);
}

/* ------- Recipe deck ------- */
.recipe-deck {
    margin: 0 auto 24px;
    max-width: 610px;
}

.deck-stack {
    display: grid;
    grid-template-columns: minmax(0, 366px);
    justify-content: center;
    padding: 22px clamp(22px, 5vw, 46px) 42px;
    overflow: hidden;
    isolation: isolate;
    border: 1px solid var(--line);
    border-radius: 25px;
    background:
        radial-gradient(ellipse at 45% 35%, var(--paper), transparent 72%),
        linear-gradient(135deg, var(--accent-soft), var(--cream-deep));
    touch-action: pan-y pinch-zoom;
}

.flashcard {
    grid-area: 1 / 1;
    position: relative;
    visibility: hidden;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--paper);
    color: var(--ink);
    text-decoration: none;
    box-shadow: var(--shadow-md);
    transition: transform 180ms ease-out, box-shadow 180ms ease-out, border-color 180ms ease-out;
}

.flashcard[data-depth="0"] {
    z-index: 3;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(var(--drag-x, 0px)) rotate(var(--drag-angle, 0deg));
}

.flashcard[data-depth="0"]:hover {
    border-color: var(--accent-line);
    box-shadow: var(--shadow-lg);
}

.deck-stack.can-swipe .flashcard[data-depth="0"] {
    cursor: grab;
    user-select: none;
}

.deck-stack.can-swipe .flashcard.is-dragging {
    cursor: grabbing;
    transition: none;
}

.flashcard[data-depth="1"] {
    z-index: 2;
    visibility: visible;
    transform: translate(9px, 12px) rotate(3deg) scale(.97);
}

.flashcard[data-depth="2"] {
    z-index: 1;
    visibility: visible;
    transform: translate(-10px, 21px) rotate(-4deg) scale(.94);
}

.flashcard-media {
    height: clamp(215px, 62vw, 325px);
    position: relative;
    background: var(--cream-deep);
    overflow: hidden;
}

.flashcard-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.flashcard-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
}

.photo-unavailable {
    padding: 12px;
    background: var(--cream-deep);
    color: var(--ink-faint);
    font-size: 0.875rem;
    text-align: center;
}

.flashcard-fav {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--paper);
    color: var(--gold);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    box-shadow: var(--shadow-sm);
}

.flashcard-body {
    padding: 18px 16px 22px;
}

.flashcard-title {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin-bottom: 6px;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.flashcard-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.82rem;
    color: var(--ink-faint);
    margin-bottom: 8px;
}

.flashcard-rating {
    color: var(--gold);
    font-size: 0.85rem;
    letter-spacing: 1px;
}

.flashcard-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.flashcard-tags .tag {
    margin: 0;
    overflow-wrap: anywhere;
    max-width: 100%;
}

.deck-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    margin-top: 12px;
}

.deck-arrow {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--paper);
    color: var(--ink-soft);
    box-shadow: var(--shadow-sm);
    font-size: 1.2rem;
    cursor: pointer;
}

.deck-arrow:hover {
    background: var(--accent);
    color: var(--on-accent);
}

.deck-progress {
    min-width: 6ch;
    color: var(--ink-faint);
    font: 0.85rem var(--font-mono);
    text-align: center;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.rating-form {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.rating-form label {
    color: var(--ink-soft);
    font-weight: 600;
    font-size: 0.95rem;
}

.rating-form select {
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-family: var(--font-body);
    font-size: 0.95rem;
    background: var(--paper);
    color: var(--ink);
    cursor: pointer;
}

.rating-form select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.rate-btn {
    background: linear-gradient(135deg, var(--accent), var(--accent-deep));
    color: var(--on-accent);
    border: none;
    padding: 9px 18px;
    border-radius: 999px;
    cursor: pointer;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.rate-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ------- Recipe detail ------- */
.back-link {
    display: inline-block;
    margin-bottom: 20px;
    text-decoration: none;
    color: var(--ink-soft);
    font-weight: 500;
    font-size: 0.95rem;
    transition: color 0.2s ease, transform 0.15s ease;
}

.back-link:hover {
    color: var(--accent);
    transform: translateX(-2px);
}

.recipe-photo {
    display: block;
    width: auto;
    max-width: 100%;
    max-height: 480px;
    object-fit: contain;
    border-radius: var(--radius);
    margin: 0 auto 20px;
    box-shadow: var(--shadow-md);
}

.recipe-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: 32px 34px;
    box-shadow: var(--shadow-lg);
}

.recipe-card h1 {
    font-family: var(--font-display);
    font-size: 2.3rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin-bottom: 12px;
}

.recipe-card h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
    margin: 30px 0 12px;
    color: var(--ink);
    letter-spacing: -0.01em;
    position: relative;
    padding-bottom: 8px;
}

.recipe-card h2::after {
    content: "";
    display: block;
    width: 44px;
    height: 3px;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--accent), var(--gold));
    margin-top: 8px;
}

.recipe-card p {
    line-height: 1.75;
}

.recipe-card .tags {
    margin-bottom: 14px;
}

.recipe-card .tags .tag {
    margin-left: 0;
    margin-right: 6px;
}

.rating-display {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.single-star {
    color: var(--gold);
    font-size: 1.6rem;
    line-height: 1;
    text-shadow: 0 1px 0 var(--accent-line);
}

.rating-value {
    color: var(--ink-soft);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.05rem;
}

#origin-btn {
    background: linear-gradient(135deg, var(--accent), var(--accent-deep));
    color: var(--on-accent);
    border: none;
    padding: 12px 20px;
    border-radius: 999px;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

#origin-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

#origin-btn:disabled {
    opacity: 0.6;
    cursor: default;
    transform: none;
}

#origin-text {
    margin-top: 14px;
    line-height: 1.7;
    padding: 16px 18px;
    background: var(--cream-deep);
    border-radius: 12px;
    border-left: 4px solid var(--accent);
    color: var(--ink-soft);
    font-family: var(--font-display);
    font-style: italic;
}

#servings-input {
    width: 70px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-family: var(--font-mono);
    font-size: 1rem;
    background: var(--paper);
    color: var(--ink);
}

#servings-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

#servings-note {
    color: var(--ink-faint);
    font-size: 0.85rem;
}

#ingredient-list {
    list-style: none;
    padding: 0;
    margin-top: 4px;
}

#ingredient-list li {
    padding: 9px 12px;
    margin-bottom: 4px;
    background: var(--cream);
    border: 1px solid var(--line);
    border-radius: 10px;
    transition: background 0.2s ease;
}

#ingredient-list li:hover {
    background: var(--cream-deep);
}

.ing-amount {
    font-family: var(--font-mono);
    font-weight: 500;
    display: inline-block;
    min-width: 44px;
    color: var(--accent-deep);
}

.ing-unit {
    font-family: var(--font-mono);
    color: var(--ink-faint);
    margin-right: 6px;
}

.ing-name {
    font-weight: 500;
}

.nutrition-facts {
    background: linear-gradient(135deg, var(--green-soft), var(--paper));
    border-radius: 14px;
    padding: 18px 20px;
    margin: 16px 0;
    border: 1px solid var(--line);
}

.nutrition-facts strong {
    font-family: var(--font-display);
    font-size: 1.1rem;
    color: var(--success-ink);
}

.nutrition-facts ul {
    list-style: none;
    padding: 0;
    margin: 10px 0 0;
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.nutrition-facts li {
    background: var(--paper);
    padding: 7px 14px;
    border-radius: 999px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--success-ink);
    border: 1px solid var(--line);
}

#nutrition-btn {
    background: linear-gradient(135deg, var(--accent), var(--accent-deep));
    color: var(--on-accent);
    border: none;
    padding: 12px 20px;
    border-radius: 999px;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

#nutrition-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

#nutrition-error {
    color: var(--danger);
    margin-top: 8px;
    font-weight: 500;
}

/* ------- Add / Edit form ------- */
.form-page {
    max-width: 780px;
    margin: 0 auto;
}

.form-title {
    font-family: var(--font-display);
    font-size: 2.3rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 22px;
}

.recipe-form {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.form-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 26px 28px;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.form-section {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.form-heading {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--ink);
    position: relative;
    padding-bottom: 8px;
    margin-bottom: 2px;
}

.form-heading::after {
    content: "";
    display: block;
    width: 42px;
    height: 3px;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--accent), var(--gold));
    margin-top: 8px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 7px;
    flex: 1;
}

.field-row {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
}

.field label {
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--ink);
}

.field-hint {
    color: var(--ink-faint);
    font-weight: 400;
    font-size: 0.8rem;
    margin-left: 4px;
}

.form-card input[type="text"],
.form-card input[type="number"],
.form-card textarea {
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    font-family: var(--font-body);
    font-size: 0.98rem;
    background: var(--cream);
    color: var(--ink);
    width: 100%;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.form-card input[type="text"]:focus,
.form-card input[type="number"]:focus,
.form-card textarea:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--paper);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.form-card textarea {
    resize: vertical;
    min-height: 140px;
    line-height: 1.6;
}

.title-input-group {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.title-input-group input {
    flex: 1;
}

.suggest-btn {
    background: linear-gradient(135deg, var(--accent), var(--accent-deep));
    color: var(--on-accent);
    border: none;
    padding: 12px 18px;
    border-radius: 999px;
    cursor: pointer;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.suggest-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    filter: brightness(1.05);
}

.suggest-btn:disabled {
    opacity: 0.7;
    cursor: default;
}

.suggest-status {
    font-size: 0.88rem;
    font-weight: 500;
    margin-top: 6px;
}

.suggest-status.error { color: var(--danger); }
.suggest-status.warn  { color: var(--gold); }
.suggest-status.ok    { color: var(--green); }

/* File upload */
.file-label {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
}

.file-label input[type="file"] {
    display: none;
}

.file-drop {
    display: inline-block;
    background: var(--cream-deep);
    border: 1.5px dashed var(--line-strong);
    color: var(--ink-soft);
    padding: 12px 20px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.file-label:hover .file-drop {
    background: var(--accent-soft);
    color: var(--accent-deep);
    border-color: var(--accent-line);
}

.file-name {
    color: var(--ink-faint);
    font-size: 0.85rem;
}

.form-photo-preview {
    margin-top: 8px;
    max-width: 200px;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--line);
}

/* Ingredients */
.ingredient-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.ingredient-row input {
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-family: var(--font-body);
    font-size: 0.95rem;
    background: var(--cream);
    color: var(--ink);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    flex: 1;
    min-width: 90px;
}

.ingredient-row input[type="number"] {
    flex: 0 0 90px;
}

.ingredient-row input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--paper);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.remove-row-btn {
    background: none;
    border: none;
    color: var(--ink-faint);
    cursor: pointer;
    font-size: 1rem;
    padding: 0 6px;
    align-self: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease, background 0.2s ease;
}

.remove-row-btn:hover {
    color: var(--danger);
    background: var(--danger-soft);
}

.add-row-wrap {
    display: flex;
    margin-top: 2px;
}

#add-row-btn {
    background: var(--cream-deep);
    border: 1px dashed var(--line-strong);
    color: var(--ink-soft);
    padding: 9px 18px;
    border-radius: 999px;
    cursor: pointer;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.9rem;
    line-height: 1.2;
    white-space: nowrap;
    width: fit-content;
    flex: 0 0 auto;
    transition: background 0.2s ease, color 0.2s ease;
}

#add-row-btn:hover {
    background: var(--accent-soft);
    color: var(--accent-deep);
}

/* Form actions */
.form-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: 4px;
}

.save-btn {
    background: linear-gradient(135deg, var(--accent), var(--accent-deep));
    color: var(--on-accent);
    border: none;
    padding: 14px 34px;
    border-radius: 999px;
    cursor: pointer;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 1rem;
    box-shadow: var(--shadow-md);
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.save-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    filter: brightness(1.05);
}

.thumb {
    width: 100%;
    height: 140px;
    object-fit: cover;
    border-radius: 12px;
    margin-bottom: 8px;
    box-shadow: var(--shadow-sm);
}

.hint {
    color: var(--ink-faint);
    font-size: 0.85rem;
    font-style: italic;
}

/* ------- Pagination ------- */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    margin-top: 30px;
    padding: 18px 0;
}

.pagination a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 10px;
    background: var(--paper);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.pagination a:hover {
    background: var(--accent);
    color: var(--on-accent);
    transform: translateY(-1px);
}

.page-info {
    color: var(--ink-soft);
    font-size: 0.9rem;
}

/* ------- Responsive ------- */
@media (max-width: 640px) {
    body {
        padding: 0 16px 40px;
    }

    header {
        flex-wrap: wrap;
        gap: 10px;
    }

    .recipe-card {
        padding: 22px 18px;
    }

    .recipe-card h1 {
        font-size: 1.8rem;
    }

    .collection-hero {
        border-radius: 19px;
        background-position: center, 67% center;
    }

    .nav-links {
        gap: 5px;
    }

    .nav-link {
        padding-inline: 7px;
    }

    .theme-palettes {
        inset-inline: 0 auto;
    }
}

@media (max-width: 360px) {
    .theme-palettes {
        inset-inline: auto 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
.account-page {
    max-width: 455px;
    margin-inline: auto;
}

.account-form {
    display: grid;
    gap: 15px;
    margin-block: 15px;
}

.account-form input,
.account-form select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--cream);
    color: var(--ink);
    font: 1rem var(--font-body);
}

.mfa-setup-key {
    overflow-wrap: anywhere;
    padding: 8px;
    background: var(--cream-deep);
}

.nav-signout button.nav-link {
    background: transparent;
    color: var(--ink-soft);
    box-shadow: none;
}
