:root {
    --bg: #f4efe6;
    --surface: rgba(255, 252, 247, 0.88);
    --surface-strong: #fffaf2;
    --text: #2e2a25;
    --muted: #6e6457;
    --accent: #1d6b57;
    --accent-soft: #d8ede6;
    --line: rgba(46, 42, 37, 0.08);
    --shadow: 0 18px 60px rgba(58, 39, 23, 0.08);
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Avenir Next", "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.65), transparent 32rem),
        linear-gradient(180deg, #efe7d9 0%, #f8f3eb 48%, #f3eee4 100%);
}

button,
input,
select,
textarea {
    font: inherit;
}

.app-shell {
    width: min(1120px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1.25rem 0 3rem;
}

.page-header {
    margin-bottom: 0.5rem;
}

.page-header-main {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.page-heading {
    display: grid;
    gap: 0.2rem;
    padding-top: 0.1rem;
}

.page-heading h1 {
    margin: 0;
    font-size: 1.45rem;
    line-height: 1.1;
}

.page-heading p {
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
}

.page-header-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}

.plan-toolbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-left: auto;
}

.week-nav {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.18rem;
    border-radius: 999px;
    background: rgba(46, 42, 37, 0.045);
}

.week-nav-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    color: var(--muted);
    text-decoration: none;
}

.week-nav-button:hover {
    background: rgba(29, 107, 87, 0.08);
    color: var(--accent);
}

.week-nav-label {
    min-width: 7.4rem;
    text-align: center;
    color: var(--text);
    font-size: 0.9rem;
}

.menu-toggle {
    display: grid;
    gap: 0.3rem;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0.55rem;
    border: 0;
    border-radius: 0.85rem;
    background: var(--accent-soft);
}

.menu-toggle span {
    display: block;
    width: 100%;
    height: 2px;
    border-radius: 999px;
    background: var(--accent);
}

.drawer {
    position: fixed;
    z-index: 30;
    inset: 4.1rem auto auto 1rem;
    width: min(18rem, calc(100vw - 2rem));
    padding: 0.85rem;
    border: 1px solid var(--line);
    border-radius: 1.15rem;
    background: rgba(255, 250, 242, 0.96);
    box-shadow: var(--shadow);
    transform: translateX(-120%);
    transition: transform 180ms ease;
}

.drawer.is-open {
    transform: translateX(0);
}

.drawer nav {
    display: grid;
    gap: 0.5rem;
}

.nav-link {
    padding: 0.7rem 0.85rem;
    border-radius: 0.85rem;
    color: var(--text);
    text-decoration: none;
}

.nav-link.is-active,
.nav-link:hover {
    background: var(--accent-soft);
    color: var(--accent);
}

.drawer-logout-form {
    margin: 0;
}

.nav-button {
    width: 100%;
    border: 0;
    text-align: left;
    cursor: pointer;
}

.content {
    display: grid;
    gap: 1rem;
}

.session-strip {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.5rem;
    color: var(--muted);
    font-size: 0.86rem;
}

.session-strip strong {
    color: var(--text);
}

.auth-shell {
    min-height: calc(100vh - 4rem);
    display: grid;
    place-items: center;
    padding: 2rem 0;
}

.auth-panel {
    width: min(28rem, 100%);
}

.auth-heading {
    display: grid;
    gap: 0.45rem;
    margin-bottom: 1.2rem;
}

.auth-heading h1 {
    margin: 0;
    font-size: 1.75rem;
    line-height: 1.1;
}

.auth-form {
    display: grid;
    gap: 1rem;
}

.auth-message {
    margin-bottom: 1rem;
    padding: 0.85rem 1rem;
    border-radius: 0.9rem;
    background: rgba(143, 75, 55, 0.12);
    color: #7d3425;
}

.auth-switch {
    margin-top: 1rem !important;
}

.invite-form {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
}

.invite-link-field {
    margin-top: 1rem;
}

.invite-link-field input {
    cursor: text;
}

.member-card .badge {
    background: #efe7da;
    color: var(--muted);
}

.section-title {
    margin: 0 0 -0.25rem;
    padding-inline: 0.35rem;
    font-size: 1rem;
}

.plan-list,
.stack {
    display: grid;
    gap: 1rem;
}

.plan-list {
    position: relative;
    padding: 0.35rem;
    border-radius: 1.75rem;
    background: transparent;
}

.plan-list.is-empty-week {
    gap: 0;
}

.panel {
    padding: 1.25rem;
    border: 1px solid var(--line);
    border-radius: 1.5rem;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.list-head,
.actions,
.meta-row {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 1rem;
}

.form-panel form,
.form-panel form {
    display: grid;
    gap: 1rem;
}

.rule-form {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    align-items: end;
}

.day-card h4,
.panel h2,
.panel h3 {
    margin: 0 0 0.35rem;
}

.day-label,
.day-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.panel p {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.button,
.chip,
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    padding: 0.7rem 1rem;
    border-radius: 999px;
    border: 1px solid transparent;
    background: #ece4d8;
    color: var(--text);
    text-decoration: none;
}

.button.primary {
    background: var(--accent);
    color: #fff;
}

.button.subtle {
    background: #efe7da;
    color: var(--text);
}

.button.is-active {
    background: var(--accent);
    color: #fff;
}

.button.small {
    padding: 0.5rem 0.85rem;
    font-size: 0.84rem;
}

.chip,
.badge {
    padding: 0.45rem 0.8rem;
    background: var(--accent-soft);
    color: var(--accent);
}

.chip {
    padding: 0.35rem 0.7rem;
    font-size: 0.82rem;
}

.card-actions {
    display: flex;
    gap: 0.6rem;
    margin-top: 0.15rem;
}

.dish-list-card {
    display: grid;
    gap: 0.85rem;
    color: inherit;
    text-decoration: none;
    transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.dish-list-card:hover {
    border-color: rgba(29, 107, 87, 0.18);
    box-shadow: 0 22px 70px rgba(58, 39, 23, 0.1);
    transform: translateY(-1px);
}

.dish-list-card h3,
.dish-list-card p {
    text-decoration: none;
}

.dish-list-card h3 {
    color: var(--text);
}

.dish-name {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 500;
    line-height: 1.15;
}

.recipe-preview {
    font-size: 0.94rem;
}

.plan-row .recipe-preview {
    display: none;
}

.dish-meta-line {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.52rem;
    width: fit-content;
    max-width: 100%;
}

.meta-group,
.info-control {
    display: inline-flex;
    align-items: center;
    min-height: 1.62rem;
    padding: 0.2rem 0.42rem;
    border: 1px solid rgba(46, 42, 37, 0.12);
    border-radius: 999px;
    background: rgba(255, 252, 246, 0.56);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.info-control {
    position: relative;
    justify-content: center;
    padding-inline: 0.36rem;
}

.diet-icons {
    gap: 0.28rem;
}

.season-symbol,
.diet-symbol {
    position: relative;
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border-radius: 999px;
    border: 1px solid rgba(46, 42, 37, 0.12);
    background: rgba(46, 42, 37, 0.055);
}

.season-symbol::after,
.diet-symbol::after {
    content: "";
    position: absolute;
    inset: 0.32rem;
    border-radius: 999px;
    background: rgba(46, 42, 37, 0.34);
}

.season-symbol.is-active {
    border-color: rgba(29, 107, 87, 0.24);
    background: rgba(216, 237, 230, 0.86);
}

.season-symbol.is-active::after {
    background: var(--accent);
}

.diet-symbol.diet-vegetarian::after {
    inset: 0.3rem;
    border-radius: 0.16rem;
}

.diet-symbol.diet-meat::after {
    inset: auto 0.24rem;
    top: 50%;
    height: 0.22rem;
    transform: translateY(-50%);
}

.diet-symbol.diet-vegan.is-active {
    border-color: rgba(47, 138, 95, 0.28);
    background: rgba(216, 237, 230, 0.9);
}

.diet-symbol.diet-vegan.is-active::after {
    background: #2f8a5f;
}

.diet-symbol.diet-vegetarian.is-active {
    border-color: rgba(122, 168, 79, 0.3);
    background: rgba(231, 240, 217, 0.9);
}

.diet-symbol.diet-vegetarian.is-active::after {
    background: #7aa84f;
}

.diet-symbol.diet-meat.is-active {
    border-color: rgba(143, 75, 55, 0.28);
    background: rgba(241, 224, 217, 0.92);
}

.diet-symbol.diet-meat.is-active::after {
    background: #8f4b37;
}

.rating-icons {
    display: inline-flex;
    align-items: end;
    gap: 0.14rem;
}

.spoon-icon {
    position: relative;
    display: inline-block;
    width: 0.34rem;
    height: 0.92rem;
    color: rgba(46, 42, 37, 0.24);
    transform: rotate(32deg);
}

.spoon-icon::before {
    content: "";
    position: absolute;
    left: 0.06rem;
    top: 0.02rem;
    width: 0.22rem;
    height: 0.32rem;
    border: 1.5px solid currentColor;
    border-radius: 999px;
    background: rgba(255, 252, 246, 0.75);
}

.spoon-icon::after {
    content: "";
    position: absolute;
    left: 0.145rem;
    top: 0.32rem;
    width: 0.06rem;
    height: 0.56rem;
    border-radius: 999px;
    background: currentColor;
}

.spoon-icon.is-active {
    color: #b17b1f;
}

.planning-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.52rem;
    width: fit-content;
    margin-left: 0;
    vertical-align: middle;
}

.season-icons,
.effort-bars {
    gap: 0.28rem;
}

.effort-bars {
    gap: 0.18rem;
}

.effort-bar {
    width: 0.78rem;
    height: 0.28rem;
    border-radius: 999px;
    background: rgba(46, 42, 37, 0.14);
}

.effort-bar.is-active {
    background: #b7792f;
}

.plan-row {
    position: relative;
    overflow: visible;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 0.7rem 0.9rem;
    transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
    cursor: pointer;
}

.slot-date {
    display: grid;
    justify-items: start;
    gap: 0.1rem;
    grid-column: 1 / -1;
}

.slot-weekday,
.slot-date-value {
    margin: 0;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.slot-weekday {
    font-size: 1.22rem;
    font-weight: 500;
    line-height: 1;
}

.slot-date-value {
    font-size: 0.68rem;
}

.slot-body {
    position: relative;
    z-index: 1;
    display: grid;
    gap: 0.52rem;
    min-width: 0;
}

.plan-row .slot-body,
.plan-row .slot-body * {
    color: inherit !important;
    text-decoration: none !important;
}

.plan-row .slot-body .spoon-icon.is-active {
    color: #b17b1f !important;
}

.plan-row .slot-body .spoon-icon:not(.is-active) {
    color: rgba(46, 42, 37, 0.24) !important;
}

.plan-row .slot-body .info-button {
    color: rgba(46, 42, 37, 0.72) !important;
}

.plan-row .slot-body .info-button:hover,
.plan-row .slot-body .info-button[aria-expanded="true"] {
    color: var(--accent) !important;
}

.plan-row .slot-body .info-popover-label,
.plan-row .slot-body .info-popover p {
    color: var(--muted) !important;
}

.plan-row .slot-body .swap-select {
    color: var(--text) !important;
}

.slot-body.is-clickable {
    cursor: pointer;
}

.slot-body[aria-disabled="true"] {
    pointer-events: none;
}

.slot-actions {
    display: flex;
    align-self: stretch;
    margin-block: -1.25rem;
    align-items: center;
    justify-content: flex-end;
    gap: 0.45rem;
}

.plan-row.is-past {
    padding-block: 0.9rem;
    opacity: 0.54;
}

.plan-row:has(.order-controls) {
    padding-right: 0;
}

.plan-row.is-past .dish-name {
    font-size: 1.05rem;
}

.plan-row.is-past .recipe-preview,
.plan-row.is-past .slot-actions,
.plan-row.is-past .info-control {
    display: none;
}

.info-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.05rem;
    height: 1.05rem;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: rgba(46, 42, 37, 0.72);
    font: inherit;
    cursor: pointer;
}

.info-mark {
    font-size: 0.76rem;
    font-weight: 700;
    font-style: normal;
    line-height: 1;
}

.info-button:hover,
.info-button[aria-expanded="true"] {
    background: rgba(29, 107, 87, 0.08);
    color: var(--accent);
}

.info-popover {
    position: absolute;
    z-index: 8;
    top: calc(100% + 0.45rem);
    right: 0;
    display: grid;
    gap: 0.8rem;
    width: min(20rem, calc(100vw - 2rem));
    padding: 0.85rem;
    border: 1px solid rgba(46, 42, 37, 0.12);
    border-radius: 1rem;
    background: var(--surface-strong);
    box-shadow: var(--shadow);
    cursor: default;
}

.info-popover[hidden] {
    display: none;
}

.info-popover-section {
    display: grid;
    gap: 0.42rem;
}

.info-popover .planning-meta {
    flex-wrap: wrap;
    gap: 0.45rem;
}

.info-popover-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.info-popover p {
    color: var(--muted);
    font-size: 0.84rem;
    line-height: 1.45;
}

.swap-select {
    width: 100%;
    padding: 0.7rem 0.8rem;
    border: 1px solid rgba(46, 42, 37, 0.12);
    border-radius: 0.8rem;
    background: rgba(255, 252, 246, 0.82);
    color: var(--text);
}

.order-controls {
    display: none;
    flex-direction: column;
    align-self: stretch;
    width: 2.35rem;
    min-height: 100%;
    overflow: hidden;
    border-left: 1px solid rgba(46, 42, 37, 0.07);
    border-radius: 0 1.05rem 1.05rem 0;
    background: rgba(46, 42, 37, 0.035);
}

.plan-list.is-sorting .order-controls {
    display: flex;
}

.order-button {
    width: 100%;
    min-height: 0;
    flex: 1 1 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    appearance: none;
    -webkit-appearance: none;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: rgba(46, 42, 37, 0.58);
    line-height: 1;
    cursor: pointer;
    transition: background 140ms ease, color 140ms ease, transform 140ms ease;
}

.order-button:not(:disabled):hover {
    color: var(--accent);
    background: rgba(29, 107, 87, 0.09);
}

.order-button + .order-button {
    border-top: 1px solid rgba(46, 42, 37, 0.07);
}

.order-button:not(:disabled):active {
    transform: scale(0.94);
}

.order-symbol {
    display: block;
    width: 0.7rem;
    text-align: center;
    font-size: 0.58rem;
    line-height: 1;
    letter-spacing: 0;
}

.order-button:disabled {
    opacity: 0.18;
    cursor: default;
}

.empty-week-panel {
    display: grid;
    gap: 0.35rem;
    min-height: 8rem;
    align-content: center;
}

.empty-week-panel h3 {
    margin: 0;
}

.dish-detail-panel,
.dish-detail-content {
    display: grid;
    gap: 1rem;
}

.dish-detail-header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.dish-detail-header h2 {
    margin: 0.2rem 0 0;
}

.dish-detail-section {
    display: grid;
    gap: 0.45rem;
    padding-top: 0.25rem;
}

.dish-detail-text {
    white-space: pre-wrap;
}

.compact-stack {
    gap: 0.75rem;
}

.history-entry {
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 1rem;
    background: rgba(255, 250, 242, 0.72);
}

.save-status {
    min-height: 1rem;
    margin: -0.35rem 0 0;
    font-size: 0.92rem;
    color: var(--muted);
}

.save-status[data-state="success"] {
    color: var(--accent);
}

.save-status[data-state="error"] {
    color: #a33f32;
}

.eyebrow {
    margin: 0 0 0.25rem;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.field {
    display: grid;
    gap: 0.45rem;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 0.9rem 1rem;
    border: 1px solid var(--line);
    border-radius: 1rem;
    background: var(--surface-strong);
}

.field textarea {
    resize: vertical;
    line-height: 1.45;
}

.checkbox-field {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding-top: 1.8rem;
}

.checkbox-field input {
    width: auto;
}

.dish-edit-panel form {
    display: grid;
    gap: 1rem;
}

.category-toggle-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.category-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.48rem 0.78rem;
    border: 1px solid rgba(46, 42, 37, 0.08);
    border-radius: 999px;
    background: #ece4d8;
    color: var(--muted);
    cursor: pointer;
    transition: background 140ms ease, color 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.category-toggle input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.category-toggle:hover {
    border-color: rgba(29, 107, 87, 0.14);
    transform: translateY(-1px);
}

.category-toggle:has(input:checked),
.category-toggle.is-selected {
    border-color: rgba(29, 107, 87, 0.16);
    background: var(--accent-soft);
    color: var(--accent);
}

.import-status {
    display: grid;
    gap: 0.75rem;
}

.import-status.is-error {
    border-color: rgba(163, 63, 50, 0.22);
    background: rgba(255, 242, 239, 0.9);
}

.import-status.is-success {
    border-color: rgba(29, 107, 87, 0.22);
    background: rgba(241, 249, 246, 0.9);
}

.error-list {
    margin: 0;
    padding-left: 1.1rem;
    color: #a33f32;
}

.import-summary,
.preview-grid {
    display: grid;
    gap: 1rem;
}

.summary-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.summary-card,
.preview-card {
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 1.1rem;
    background: rgba(255, 250, 242, 0.78);
}

.summary-card {
    display: grid;
    gap: 0.35rem;
}

.summary-label {
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

@media (min-width: 900px) {
    .app-shell {
        width: min(1240px, calc(100% - 3rem));
    }

    .is-authenticated .app-shell {
        padding-left: 20rem;
    }

    .drawer {
        position: fixed;
        inset: 1rem auto auto max(1.5rem, calc((100vw - 1240px) / 2));
        transform: translateX(0);
    }

    .menu-toggle {
        display: none;
    }

    .plan-row {
        grid-template-columns: 84px minmax(0, 1fr) auto;
        align-items: center;
    }

    .slot-date {
        grid-column: auto;
        justify-items: center;
    }

    .slot-actions {
        display: flex;
    }

    .order-controls {
        display: flex;
    }

    .sort-toggle {
        display: none;
    }

}

@media (max-width: 720px) {
    .invite-form {
        grid-template-columns: 1fr;
    }
}
