:root {
    --pico-form-element-spacing-vertical: 0.75rem;
}

body {
    min-height: 100vh;
}

.container.login {
    max-width: 420px;
    margin: 4rem auto;
    padding: 0 1rem;
}

.error {
    color: #842029;
    background: #f8d7da;
    border: 1px solid #f5c2c7;
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
}

header.app-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--pico-muted-border-color, #e0e0e0);
    background: var(--pico-card-background-color, #fff);
}

header.app-header h1 {
    margin: 0;
    font-size: 1.2rem;
}

header.app-header .logo-link {
    color: inherit;
    text-decoration: none;
}

header.app-header form {
    margin: 0;
}

header.app-header button {
    margin: 0;
    padding: 0.4rem 0.85rem;
    font-size: 0.9rem;
    width: auto;
}

.header-nav {
    display: flex;
    gap: 0.5rem;
    flex: 1 1 auto;
    margin-left: 0.5rem;
}

.header-nav a {
    text-decoration: none;
    padding: 0.35rem 0.65rem;
    border-radius: 0.25rem;
    font-size: 0.95rem;
    color: inherit;
}

.header-nav a:hover {
    background: var(--pico-secondary-background, #f0f2f5);
}

header.app-header .header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.muted {
    color: var(--pico-muted-color, #777);
}

/* Page header inside main */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.page-header h2 {
    margin: 0;
}

.page-header a[role="button"] {
    width: auto;
    margin: 0;
    padding: 0.5rem 1rem;
}

/* Recipe list */
.recipe-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.recipe-list > li {
    margin-bottom: 0.75rem;
}

.recipe-list a {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--pico-card-background-color, #fff);
    border: 1px solid var(--pico-muted-border-color, #e0e0e0);
    border-radius: 0.5rem;
    text-decoration: none;
    color: inherit;
}

.recipe-list .thumb {
    flex: 0 0 80px;
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 0.375rem;
    background: var(--pico-secondary-background, #f0f2f5);
}

.recipe-list .thumb-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    color: var(--pico-muted-color, #aaa);
}

.recipe-list .recipe-info {
    flex: 1 1 auto;
    min-width: 0;
}

.recipe-list h3 {
    margin: 0 0 0.25rem;
    font-size: 1.05rem;
}

.recipe-list p {
    margin: 0.25rem 0 0;
}

.meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    align-items: center;
}

.meta .tag {
    background: var(--pico-secondary-background, #e9eef3);
    color: var(--pico-secondary-color, #2d3848);
    padding: 0.1rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    text-transform: lowercase;
}

.meta .time, .meta .servings, .meta .on-hand {
    color: var(--pico-muted-color, #777);
    font-size: 0.8rem;
}

.meta .on-hand.full {
    background: #d4f5dc;
    color: #1f5c3a;
    padding: 0.1rem 0.55rem;
    border-radius: 999px;
    font-weight: 500;
}

.meta .on-hand.partial {
    color: #2a7a4f;
}

/* Filters */
.filters {
    margin-bottom: 1rem;
    background: var(--pico-card-background-color, #fff);
    border: 1px solid var(--pico-muted-border-color, #e0e0e0);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
}

.filters summary {
    cursor: pointer;
    font-weight: 500;
    padding: 0.25rem 0;
}

.filters[open] summary {
    margin-bottom: 0.5rem;
}

.filter-controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.tag-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.tag-chip {
    width: auto;
    margin: 0;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    font-size: 0.85rem;
    background: var(--pico-secondary-background, #e9eef3);
    color: var(--pico-secondary-color, #2d3848);
    border: 1px solid transparent;
    cursor: pointer;
}

.tag-chip.active {
    background: #1f2937;
    color: #fff;
}

.filter-controls .filter-row {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.filter-controls input[type="number"] {
    margin: 0;
    width: 8rem;
}

.filter-controls label {
    margin: 0;
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Recipe view */
.back-link {
    text-decoration: none;
    font-size: 0.9rem;
    display: inline-block;
    margin-bottom: 0.5rem;
}

.recipe-view header h2 {
    margin: 0 0 0.25rem;
}

.recipe-view .description {
    color: var(--pico-muted-color, #555);
    margin: 0.25rem 0 0;
}

.recipe-view .hero {
    width: 100%;
    max-height: 50vh;
    object-fit: cover;
    border-radius: 0.5rem;
    margin: 0.5rem 0 1rem;
}

.ingredient-list {
    padding-left: 1.25rem;
    margin: 0;
}

.ingredient-list li {
    margin-bottom: 0.25rem;
}

.ingredient-list li.in-pantry::after {
    content: " ✓";
    color: #2a7a4f;
}

.step-list li {
    margin-bottom: 1rem;
}

.step-list li img {
    display: block;
    max-width: 100%;
    border-radius: 0.375rem;
    margin: 0.5rem 0 0;
}

.recipe-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--pico-muted-border-color, #e0e0e0);
}

.recipe-actions a, .recipe-actions button {
    width: auto;
    margin: 0;
}

/* Form */
.ingredient-row, .step-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    align-items: flex-start;
}

.ingredient-row input.qty { flex: 0 0 4.5rem; }
.ingredient-row input.unit { flex: 0 0 5rem; }
.ingredient-row input.ingredient { flex: 1 1 auto; min-width: 0; }

.step-row .step-text {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.step-row textarea {
    margin: 0;
}

.ingredient-row button.remove,
.step-row button.remove {
    width: auto;
    flex: 0 0 auto;
    margin: 0;
    padding: 0.4rem 0.7rem;
    line-height: 1;
}

#ingredient-rows input,
#step-rows textarea {
    margin-bottom: 0;
}

#add-ingredient, #add-step {
    width: auto;
    margin: 0.5rem 0 0;
    padding: 0.5rem 1rem;
}

/* Image uploader */
.image-uploader {
    border: 1px dashed var(--pico-muted-border-color, #ccc);
    border-radius: 0.5rem;
    padding: 0.6rem;
    margin: 0;
    text-align: center;
    background: var(--pico-card-background-color, #fff);
}

.image-uploader .preview {
    max-width: 100%;
    max-height: 200px;
    border-radius: 0.375rem;
    margin-bottom: 0.5rem;
}

.image-uploader .image-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.image-uploader .image-actions button {
    width: auto;
    margin: 0;
    padding: 0.4rem 0.85rem;
    font-size: 0.9rem;
}

/* Pantry */
.pantry-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.pantry-list > li {
    border-bottom: 1px solid var(--pico-muted-border-color, #eee);
}

.pantry-list label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0;
    margin: 0;
    cursor: pointer;
}

.pantry-list input[type="checkbox"] {
    margin: 0;
    flex: 0 0 auto;
}

.pantry-name {
    flex: 1 1 auto;
    text-transform: capitalize;
}

.pantry-count {
    font-size: 0.8rem;
    flex: 0 0 auto;
}

/* Tonight's plan card on home */
.tonight-plan {
    background: var(--pico-card-background-color, #fff);
    border: 1px solid var(--pico-muted-border-color, #e0e0e0);
    border-radius: 0.5rem;
    padding: 0.75rem;
    margin-bottom: 1.5rem;
    border-left: 4px solid #1f2937;
}

.tonight-plan.logged.cooked { border-left-color: #2a7a4f; }
.tonight-plan.logged.ordered_out { border-left-color: #c1272d; }
.tonight-plan.logged.skipped { border-left-color: #888; }

.tonight-label {
    margin: 0 0 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--pico-muted-color, #666);
}

.tonight-content {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    text-decoration: none;
    color: inherit;
}

.tonight-content h3 {
    margin: 0;
    font-size: 1.15rem;
}

.tonight-content p {
    margin: 0.15rem 0 0;
    font-size: 0.9rem;
}

.tonight-thumb {
    flex: 0 0 70px;
    width: 70px;
    height: 70px;
    object-fit: cover;
    border-radius: 0.375rem;
}

.tonight-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.tonight-actions button {
    flex: 1 1 auto;
    margin: 0;
    padding: 0.5rem;
}

/* Last cooked label on recipe view */
.last-cooked {
    margin: 0.25rem 0 0;
    font-size: 0.85rem;
}

/* Schedule dialog */
dialog#schedule-dialog {
    max-width: 90vw;
    width: 320px;
    border: 1px solid var(--pico-muted-border-color, #e0e0e0);
    border-radius: 0.5rem;
    padding: 1.25rem;
}

dialog#schedule-dialog::backdrop {
    background: rgba(0, 0, 0, 0.4);
}

dialog#schedule-dialog h3 {
    margin: 0 0 0.75rem;
    font-size: 1.1rem;
}

dialog#schedule-dialog input[type="date"] {
    margin: 0;
}

.dialog-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

.dialog-actions button {
    width: auto;
    margin: 0;
    padding: 0.45rem 1rem;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(2rem);
    background: #1f2937;
    color: #fff;
    padding: 0.65rem 1.15rem;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    opacity: 0;
    transition: opacity 0.25s, transform 0.25s;
    z-index: 1000;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Picker CTA on home */
.picker-cta {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    padding: 1rem;
    background: linear-gradient(135deg, #1f2937, #374151);
    color: #fff;
    border-radius: 0.5rem;
    text-decoration: none;
    margin-bottom: 1.5rem;
    transition: transform 0.1s;
}

.picker-cta:active { transform: scale(0.99); }

.picker-cta-content { flex: 1 1 auto; }

.picker-cta-content h3 {
    margin: 0;
    color: #fff;
    font-size: 1.1rem;
}

.picker-cta-content p {
    margin: 0.15rem 0 0;
    font-size: 0.85rem;
    color: #cbd5e1;
}

.picker-cta-arrow {
    font-size: 1.5rem;
    flex: 0 0 auto;
}

/* Picker page cards */
.picker-cards {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 1rem 0;
}

.picker-card {
    width: 100%;
    margin: 0;
    padding: 0;
    border: 2px solid var(--pico-muted-border-color, #e0e0e0);
    border-radius: 0.75rem;
    background: var(--pico-card-background-color, #fff);
    color: inherit;
    overflow: hidden;
    cursor: pointer;
    text-align: left;
    transition: transform 0.1s, border-color 0.1s;
    font-family: inherit;
    font-size: 1rem;
}

.picker-card:active {
    transform: scale(0.98);
    border-color: #1f2937;
}

.picker-card img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
}

.picker-card-info {
    padding: 0.75rem 1rem;
}

.picker-card-info h3 {
    margin: 0;
    font-size: 1.15rem;
}

.picker-card-info .meta {
    margin-top: 0.4rem;
}

.picker-regen {
    width: 100%;
    margin: 1rem 0 0;
}

.picker-no-regen {
    text-align: center;
    margin: 1rem 0;
}

@media (min-width: 700px) {
    .picker-cards:not(.picker-cards-single) {
        flex-direction: row;
    }
    .picker-cards:not(.picker-cards-single) .picker-card {
        flex: 1 1 0;
        min-width: 0;
    }
}

/* Multi-CTA on home */
.picker-ctas {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.picker-ctas .picker-cta {
    margin-bottom: 0;
}

@media (min-width: 700px) {
    .picker-ctas {
        flex-direction: row;
    }
    .picker-ctas .picker-cta {
        flex: 1 1 0;
    }
}

/* Duo picker states */
.duo-choose {
    margin-top: 1rem;
}

.duo-choose .start-btn {
    width: 100%;
    padding: 1rem;
    margin-bottom: 1rem;
}

.duo-join {
    border: 1px solid var(--pico-muted-border-color, #e0e0e0);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--pico-card-background-color, #fff);
}

.duo-join summary {
    cursor: pointer;
    font-weight: 500;
    padding: 0.25rem 0;
}

.duo-join[open] summary {
    margin-bottom: 0.75rem;
}

.duo-join-form {
    display: flex;
    gap: 0.5rem;
    margin: 0;
}

.duo-join-form input {
    flex: 1 1 auto;
    margin: 0;
    text-align: center;
    letter-spacing: 0.5rem;
    font-size: 1.5rem;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

.duo-join-form button {
    flex: 0 0 auto;
    margin: 0;
    width: auto;
    padding: 0.5rem 1.25rem;
}

.big-code {
    font-size: 4rem;
    font-weight: 700;
    text-align: center;
    letter-spacing: 0.5rem;
    margin: 1.5rem 0;
    color: #1f2937;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    user-select: all;
}

.duo-status {
    text-align: center;
    margin: 0.5rem 0 1rem;
    font-style: italic;
    color: var(--pico-muted-color, #666);
}

.picker-card.dimmed {
    opacity: 0.55;
}

.picker-card.my-pick {
    opacity: 1;
    border-color: #2a7a4f;
}

.picker-pick-label {
    color: #2a7a4f;
    font-weight: 500;
    margin: 0.4rem 0 0;
    font-size: 0.9rem;
}

.duo-result-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.duo-result-actions a[role="button"] {
    margin: 0;
    width: auto;
    padding: 0.5rem 1rem;
    flex: 1 1 0;
    text-align: center;
}

/* Search input on recipe list */
.recipes-search {
    margin: 0 0 1rem;
    width: 100%;
}

/* Insights */
.insight-block {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--pico-card-background-color, #fff);
    border: 1px solid var(--pico-muted-border-color, #e0e0e0);
    border-radius: 0.5rem;
}

.insight-block h3 {
    margin: 0 0 0.5rem;
    font-size: 1.05rem;
}

.big-stat {
    font-size: 3rem;
    font-weight: 700;
    margin: 0.5rem 0;
    color: #1f2937;
    line-height: 1.1;
}

.insight-recipe-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.insight-recipe-list > li {
    margin-bottom: 0.5rem;
}

.insight-recipe-list a {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    text-decoration: none;
    color: inherit;
    padding: 0.5rem;
    border-radius: 0.375rem;
}

.insight-recipe-list a:hover {
    background: var(--pico-secondary-background, #f0f2f5);
}

.insight-recipe-list .thumb {
    flex: 0 0 60px;
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 0.375rem;
    background: var(--pico-secondary-background, #f0f2f5);
}

.insight-recipe-list .thumb-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--pico-muted-color, #aaa);
}

.insight-recipe-list strong {
    display: block;
}

.insight-recipe-list p {
    margin: 0.15rem 0 0;
    font-size: 0.85rem;
}

.insight-by-user {
    width: 100%;
    margin: 0;
}

.insight-by-user th, .insight-by-user td {
    padding: 0.4rem 0.6rem;
    text-align: left;
}

.insight-by-user td:nth-child(2),
.insight-by-user td:nth-child(3),
.insight-by-user th:nth-child(2),
.insight-by-user th:nth-child(3) {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Cook CTA on recipe view */
.cook-cta {
    margin: 1rem 0 1.5rem;
}

.cook-cta a[role="button"] {
    width: 100%;
    margin: 0;
    padding: 0.85rem;
    font-size: 1.05rem;
    text-align: center;
}

/* Step-by-step cook view */
body.cooking header.app-header {
    display: none;
}

body.cooking {
    padding-top: 0;
}

.cook-view {
    margin-top: 0.5rem;
}

.cook-header {
    margin-bottom: 1rem;
}

.cook-header h2 {
    margin: 0 0 0.5rem;
    font-size: 1.2rem;
}

.cook-progress-bar {
    height: 8px;
    background: var(--pico-muted-border-color, #e0e0e0);
    border-radius: 999px;
    overflow: hidden;
}

.cook-progress-fill {
    height: 100%;
    background: #1f2937;
    transition: width 0.3s ease;
}

.cook-progress-label {
    margin: 0.4rem 0 0;
    font-size: 0.85rem;
    color: var(--pico-muted-color, #777);
}

.cook-step-image {
    display: block;
    width: 100%;
    max-height: 55vh;
    object-fit: cover;
    border-radius: 0.5rem;
    margin: 0 0 1rem;
}

.cook-step-text {
    font-size: 1.15rem;
    line-height: 1.55;
    margin: 0 0 1.5rem;
}

.cook-nav {
    display: flex;
    gap: 0.75rem;
}

.cook-nav button {
    flex: 1 1 0;
    margin: 0;
    padding: 0.9rem;
    font-size: 1rem;
}

/* Users page */
.user-block {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--pico-card-background-color, #fff);
    border: 1px solid var(--pico-muted-border-color, #e0e0e0);
    border-radius: 0.5rem;
}

.user-block h3 {
    margin: 0 0 0.5rem;
    font-size: 1.05rem;
}

.add-user-form {
    margin: 0;
}

.add-user-form button {
    width: auto;
    padding: 0.5rem 1rem;
    margin: 0.5rem 0 0;
}

#change-pw-btn {
    width: auto;
    padding: 0.5rem 1rem;
    margin: 0.5rem 0 0;
}

.users-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.users-list > li {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--pico-muted-border-color, #eee);
}

.users-list > li:last-child {
    border-bottom: none;
}

.user-info {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: baseline;
}

.user-info strong {
    font-size: 1rem;
}

.user-status {
    font-size: 0.8rem;
    padding: 0.1rem 0.55rem;
    border-radius: 999px;
    flex: 0 0 auto;
}

.status-ok      { background: #d4f5dc; color: #1f5c3a; }
.status-pending { background: #fde9c2; color: #6e4c0a; }
.status-locked  { background: #f8d7da; color: #842029; }

.users-list .reset-btn {
    width: auto;
    margin: 0;
    padding: 0.4rem 0.85rem;
    font-size: 0.85rem;
    flex: 0 0 auto;
}

#change-pw-dialog {
    max-width: 90vw;
    width: 360px;
    border: 1px solid var(--pico-muted-border-color, #e0e0e0);
    border-radius: 0.5rem;
    padding: 1.25rem;
}

#change-pw-dialog::backdrop {
    background: rgba(0, 0, 0, 0.4);
}

#change-pw-dialog h3 {
    margin: 0 0 0.75rem;
    font-size: 1.1rem;
}

#change-pw-dialog input {
    margin: 0;
}

@media (max-width: 600px) {
    header.app-header h1 { font-size: 1.05rem; }
    .header-nav { order: 3; flex: 1 0 100%; margin: 0; }
    .ingredient-row {
        flex-wrap: wrap;
    }
    .ingredient-row input.qty { flex: 1 1 30%; }
    .ingredient-row input.unit { flex: 1 1 30%; }
    .ingredient-row input.ingredient { flex: 1 0 100%; order: 3; }
    .ingredient-row button.remove { flex: 0 0 auto; }
}
