:root {
    --pico-font-size: 16px;
    --pico-line-height: 1.6;
    --notice-success-bg: color-mix(in srgb, var(--pico-primary) 12%, transparent);
    --notice-success-border: color-mix(in srgb, var(--pico-primary) 35%, transparent);
    --notice-success-color: var(--pico-primary);
    --notice-error-bg: color-mix(in srgb, #c0392b 12%, transparent);
    --notice-error-border: color-mix(in srgb, #c0392b 35%, transparent);
    --notice-error-color: #c0392b;
}

[data-theme="dark"] {
    --notice-error-color: #ff8a80;
}

body {
    min-height: 100vh;
}

/* Grid rather than a centered flex row with absolutely positioned corners: the
   side columns reserve real space, so the controls can't overlap the title at
   narrow widths. */
.site-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.5rem;
    margin: 1.5rem 0 2rem;
}

.site-header h1 {
    margin: 0;
    text-align: center;
    min-width: 0;
    font-size: clamp(1.35rem, 4vw, 2.75rem);
    line-height: 1.2;
}

.site-header h1 a {
    text-decoration: none;
    color: inherit;
}

.site-header h1 a:hover {
    color: var(--pico-primary);
}

.header-account {
    display: flex;
    align-items: center;
    justify-self: end;
}

.header-account [role="button"]:not(.avatar) {
    margin: 0;
    padding: 0.4rem 0.75rem;
    font-size: 0.875rem;
    white-space: nowrap;
}

/* Both header menus are Pico <details class="dropdown">; these only adjust the
   trigger, since Pico already styles the panel. */
.site-header details.dropdown {
    margin: 0;
}

.site-header details.dropdown > summary::after {
    display: none;  /* Pico's disclosure triangle: unwanted on an icon trigger */
}

.site-header details.dropdown > summary {
    margin: 0;
}

/* Both triggers are <summary>. Pico styles a summary without role="button" via
   `details.dropdown>summary:not([role=button])` — specificity (0,2,2) — so the
   selector below has to include `details.dropdown` to outrank it, otherwise the
   avatar keeps Pico's padding and 4px radius. */
.site-header details.dropdown > summary.icon-btn,
.site-header details.dropdown > summary.avatar {
    box-sizing: border-box;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    list-style: none;
    cursor: pointer;
    user-select: none;
}

.site-header details.dropdown > summary.icon-btn::-webkit-details-marker,
.site-header details.dropdown > summary.avatar::-webkit-details-marker {
    display: none;
}

.site-header details.dropdown > summary.avatar {
    background: var(--pico-primary);
    color: var(--pico-primary-inverse);
    border: none;
    font-weight: 700;
    line-height: 1;
}

/* Pico gives <hr> 16px margins top and bottom — 32px of dead space inside a
   menu. Tighten it so the separator reads as a divider, not a gap. */
.site-header details.dropdown hr {
    margin: 0.35rem 0;
    border: none;
    border-top: 1px solid var(--pico-muted-border-color);
}

/* A button that should read as a menu row, not a button. Padding matches the
   sibling <a> rows so the items line up. */
.menu-action {
    width: 100%;
    margin: 0;
    padding: 0.375rem 0;
    background: none;
    border: none;
    box-shadow: none;
    color: inherit;
    text-align: left;
    font-size: inherit;
    cursor: pointer;
}

.menu-action:hover {
    background: none;
    color: var(--pico-primary);
}

.menu-static {
    display: flex;
    flex-direction: column;
    padding: 0.125rem 0;
    line-height: 1.3;
}

.menu-email {
    font-size: 0.8rem;
    color: var(--pico-muted-color);
    overflow: hidden;
    text-overflow: ellipsis;
}

.site-header details.dropdown .inline-form {
    margin: 0;
}

/* Saved-recipe grid, shared by the home teaser and /library. auto-fill keeps it
   responsive without extra breakpoints. */
.recipe-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.recipe-card-item {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--pico-muted-border-color);
    border-radius: 0.6rem;
    text-decoration: none;
    color: inherit;
    background: color-mix(in srgb, var(--pico-primary) 4%, transparent);
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.recipe-card-item:hover {
    border-color: var(--pico-primary);
    transform: translateY(-2px);
}

.recipe-card-title {
    font-weight: 600;
    line-height: 1.3;
}

.recipe-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.85rem;
    font-size: 0.8rem;
    color: var(--pico-muted-color);
}

.recipe-card-meta i {
    color: var(--pico-primary);
}

.section-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.section-heading h2 {
    margin: 0;
}

.section-link {
    font-size: 0.875rem;
    white-space: nowrap;
}

.section-count {
    font-size: 0.875rem;
    color: var(--pico-muted-color);
}

.library-section {
    margin-top: 1rem;
}

.inline-form {
    margin: 0;
}

.input-section {
    max-width: 800px;
    margin: 0 auto 2.5rem;
}

.url-form {
    display: grid;
    gap: 0.75rem;
}

.url-form .field {
    margin-bottom: 0;
}

.url-form label {
    margin-bottom: 0;
}

.url-form input {
    margin-bottom: 0;
}

.url-form small {
    display: block;
    margin: 0.35rem 0 0;
}

.url-form button {
    margin: 0;
    width: 100%;
}

.notice {
    padding: 1rem 1.25rem;
    border-radius: var(--pico-border-radius);
    margin-bottom: 1.25rem;
    text-align: center;
    font-weight: 600;
    animation: fadeIn 0.35s ease;
}

.notice.success {
    background: var(--notice-success-bg);
    border: 1px solid var(--notice-success-border);
    color: var(--notice-success-color);
}

.notice.error {
    background: var(--notice-error-bg);
    border: 1px solid var(--notice-error-border);
    color: var(--notice-error-color);
}

.notice .muted {
    display: block;
    margin-top: 0.35rem;
    font-weight: 400;
    opacity: 0.85;
    word-break: break-all;
}

.notice a {
    color: inherit;
    text-decoration: underline;
    font-weight: 600;
}

.notice a:hover {
    opacity: 0.8;
}

.loading {
    display: none;
    text-align: center;
    padding: 2.5rem 1.5rem;
    margin: 0 auto 2rem;
}

.cooking-animation {
    display: inline-block;
    animation: cook 2s infinite;
}

.cooking-animation-img {
    display: block;
    width: 4rem;
    height: 4rem;
}

.loading-text {
    margin-top: 0.75rem;
    color: var(--pico-muted-color);
    animation: pulse 1.5s infinite;
}

@keyframes cook {
    0%, 100% { transform: rotate(0deg) scale(1); }
    25% { transform: rotate(-5deg) scale(1.1); }
    50% { transform: rotate(5deg) scale(1.15); }
    75% { transform: rotate(-3deg) scale(1.1); }
}

@keyframes pulse {
    0%, 100% { opacity: 0.65; }
    50% { opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.recipe-card {
    background: var(--pico-card-background-color);
    border: 1px solid var(--pico-muted-border-color);
    border-radius: calc(var(--pico-border-radius) + 0.25rem);
    padding: 1.5rem;
    margin-bottom: 2.5rem;
    box-shadow: var(--pico-card-box-shadow);
    animation: fadeIn 0.4s ease;
}

.recipe-card > header {
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--pico-muted-border-color);
    padding-bottom: 1rem;
}

.recipe-card > header h2 {
    margin: 0 0 0.5rem;
    font-size: clamp(1.4rem, 3vw, 1.9rem);
    line-height: 1.25;
}

.source-link {
    display: inline-flex;
    align-items: center;
    font-size: 0.6em;
    color: var(--pico-muted-color);
    text-decoration: none;
    vertical-align: middle;
    margin-left: 0.4rem;
}

.source-link:hover {
    color: var(--pico-primary);
}

.recipe-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1rem;
    margin: 0 0 0.75rem;
    padding: 0;
    list-style: none;
    font-size: 0.875rem;
    color: var(--pico-muted-color);
}

.recipe-meta li {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0;
    padding: 0;
}

.recipe-meta i {
    color: var(--pico-primary);
}

.ingredient-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.ingredient-heading h3 {
    margin: 0;
}

.portion-control {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.4rem 0.75rem;
    border-radius: 2rem;
    background: color-mix(in srgb, var(--pico-primary) 8%, transparent);
    font-size: 0.95rem;
}

.portion-label {
    color: var(--pico-muted-color);
    font-weight: 500;
}

.portion-btn {
    width: 2rem;
    height: 2rem;
    padding: 0;
    margin: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--pico-card-background-color);
    border: 1px solid var(--pico-muted-border-color);
    /* Pico redefines --pico-color to its white button-inverse on <button>, so
       referencing it here would render white-on-white in light mode. Inherit
       the surrounding text color instead, which tracks the theme. */
    color: inherit;
    box-shadow: none;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}

.portion-btn:hover {
    border-color: var(--pico-primary);
    color: var(--pico-primary);
}

#portion-count {
    min-width: 1.5rem;
    text-align: center;
    font-weight: 700;
    color: var(--pico-primary);
}

.recipe-grid {
    display: grid;
    gap: 1.75rem;
}

@media (min-width: 768px) {
    .recipe-grid {
        grid-template-columns: minmax(240px, 0.9fr) 1.1fr;
        gap: 2rem;
    }
}

.recipe-section h3 {
    margin: 0 0 1rem;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ingredient-group-header {
    display: block;
    margin: 1rem 0 0.5rem;
    font-weight: 700;
    font-size: 0.95rem;
}

.ingredient-group-header:first-child {
    margin-top: 0;
}

.ingredient-list,
.instruction-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 0.65rem;
}

.ingredient-list li {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    border-radius: var(--pico-border-radius);
    background: var(--pico-code-background-color);
    transition: background-color 0.2s ease, opacity 0.2s ease;
}

.ingredient-list input[type="checkbox"] {
    width: 1.15rem;
    height: 1.15rem;
    margin: 0.15rem 0 0;
    flex-shrink: 0;
    accent-color: var(--pico-primary);
    cursor: pointer;
}

.ingredient-list label {
    margin: 0;
    font-weight: 400;
    cursor: pointer;
    transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

.ingredient-list input[type="checkbox"]:checked + label {
    text-decoration: line-through;
    color: var(--pico-muted-color);
    text-decoration-thickness: 2px;
}

.ingredient-list li:has(input:checked) {
    opacity: 0.7;
}

.instruction-list {
    counter-reset: step;
    gap: 0.85rem;
}

.instruction-list li {
    counter-increment: step;
    display: grid;
    grid-template-columns: 2rem 1fr;
    gap: 0.85rem;
    padding: 0.85rem 1rem;
    border-radius: var(--pico-border-radius);
    border: 1px solid var(--pico-muted-border-color);
    background: transparent;
}

.instruction-list li::before {
    content: counter(step);
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--pico-primary);
    color: var(--pico-primary-inverse);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.action-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--pico-muted-border-color);
}

.action-bar a,
.action-bar button {
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: 2.75rem;
}

.action-bar .secondary,
.action-bar .outline {
    background: transparent;
    border: 1px solid var(--pico-primary);
    color: var(--pico-primary);
    box-shadow: none;
}

.action-bar .secondary:hover,
.action-bar .outline:hover {
    background: color-mix(in srgb, var(--pico-primary) 12%, transparent);
}

.action-bar .copied {
    border-color: var(--pico-ins-color, var(--pico-primary));
    color: var(--pico-ins-color, var(--pico-primary));
}

.cached-section {
    margin-top: 1rem;
    margin-bottom: 3rem;
}

.cached-section h2 {
    margin-bottom: 1rem;
    font-size: 1.35rem;
}

.recipe-grid-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    list-style: none;
    padding: 0;
    margin: 0;
}

.recipe-grid-cards li {
    list-style: none;
    padding: 0;
}

.recipe-grid-cards a {
    display: inline-block;
    text-decoration: none;
    color: var(--pico-primary);
    background: color-mix(in srgb, var(--pico-primary) 8%, transparent);
    padding: 0.4rem 0.85rem;
    border-radius: 2rem;
    font-size: 0.9rem;
    transition: background 0.2s ease;
}

.recipe-grid-cards a:hover {
    background: color-mix(in srgb, var(--pico-primary) 18%, transparent);
    text-decoration: none;
}

.print-recipe {
    display: none;
}

/* Cooking mode overlay */
.cooking-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: var(--pico-background-color);
    color: var(--pico-color);
    flex-direction: column;
    padding: 1.25rem 1.5rem 1.5rem;
    overflow: auto;
}

.cooking-overlay.active {
    display: flex;
}

.cooking-overlay-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.cooking-overlay-header h2 {
    margin: 0;
    font-size: clamp(1.2rem, 3vw, 1.6rem);
    line-height: 1.3;
}

.cooking-exit {
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    margin: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--pico-card-background-color);
    border: 1px solid var(--pico-muted-border-color);
    /* See .portion-btn: --pico-color is the white button-inverse here. */
    color: inherit;
    box-shadow: none;
    flex-shrink: 0;
}

.cooking-exit:hover {
    border-color: var(--pico-primary);
    color: var(--pico-primary);
}

.cooking-progress {
    text-align: center;
    color: var(--pico-muted-color);
    font-weight: 600;
    margin-bottom: 1rem;
    letter-spacing: 0.02em;
}

.cooking-step {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.cooking-step p {
    margin: 0;
    font-size: clamp(1.5rem, 5vw, 2.4rem);
    line-height: 1.4;
    max-width: 42rem;
    font-weight: 500;
}

#cooking-step-text {
    white-space: pre-line;
}

.cooking-mic {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    margin-bottom: 1.25rem;
    color: var(--pico-muted-color);
    font-size: 0.95rem;
    min-height: 1.5rem;
}

.cooking-mic .mic-dot {
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 50%;
    background: var(--pico-muted-color);
    flex-shrink: 0;
}

.cooking-mic.listening .mic-dot {
    background: var(--pico-primary);
    animation: micPulse 1.2s ease-in-out infinite;
}

.cooking-mic.paused .mic-dot {
    background: #e67e22;
    animation: none;
}

.cooking-mic.unavailable {
    opacity: 0.85;
}

@keyframes micPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.45); opacity: 0.55; }
}

.cooking-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    margin-top: auto;
}

.cooking-controls button {
    margin: 0;
    min-width: 7rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
}

.cooking-controls .secondary {
    background: transparent;
    border: 1px solid var(--pico-primary);
    color: var(--pico-primary);
    box-shadow: none;
}

.cooking-controls .secondary:hover {
    background: color-mix(in srgb, var(--pico-primary) 12%, transparent);
}

.cooking-hint {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.85rem;
    color: var(--pico-muted-color);
}

@media print {
    .site-header,
    .input-section,
    .loading,
    .action-bar,
    .cached-section,
    .library-section,
    .notice,
    .screen-recipe,
    .cooking-overlay {
        display: none !important;
    }

    .recipe-card {
        border: none;
        box-shadow: none;
        padding: 0;
        animation: none;
    }

    .print-recipe {
        display: block;
        white-space: pre-wrap;
        font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
        font-size: 12pt;
        line-height: 1.45;
        margin: 0;
        color: #000;
    }
}
