:root {
    color-scheme: light;
    --ink: #292b28;
    --muted: #777a72;
    --paper: #faf9f6;
    --white: #fff;
    --line: #e9e7e0;
    --primary: #606554;
    --primary-dark: #484B3F;
    --primary-pale: #EEF0E8;
    --primary-ink: #303329;
    --rose: #a2554a;
    font-family: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
    position: relative;
    isolation: isolate;
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-size: 18px;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background: url("fond_kitchen.png") repeat;
    background-size: 500px;
    opacity: 0.11;
    pointer-events: none;
}

button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }

.page {
    width: 90%;
    max-width: none;
    margin: 0 auto;
    padding: 58px 0 80px;
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 32px;
    margin-bottom: 42px;
}

.site-brand { display: inline-flex; align-items: center; gap: 14px; color: var(--ink); text-decoration: none; }
.site-brand img { display: block; width: 46px; height: 52px; border-radius: 8px; object-fit: contain; }
.site-brand span { font-family: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif; font-size: clamp(30px, 4vw, 42px); font-weight: 600; letter-spacing: -.035em; }

.eyebrow {
    margin: 0 0 8px;
    color: var(--primary-dark);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1, .modal-heading h2 {
    margin-bottom: 8px;
    font-family: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
    font-weight: 600;
}

h1 { font-size: clamp(36px, 5vw, 52px); letter-spacing: -.035em; color: var(--primary-dark);}
.subtitle { margin-bottom: 0; color: var(--muted); font-size: 17px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

.button {
    min-height: 42px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 7px;
    font-size: 15px;
    font-weight: 600;
    transition: background .15s ease, border-color .15s ease;
}

.button-primary { background: var(--primary); color: var(--white); }
.button-primary:hover { background: var(--primary-dark); color: var(--white); }
.button-secondary { border-color: var(--line); background: var(--white); color: var(--ink); }
.button-secondary:hover { border-color: #c9c7bf; background: #fcfcfa; }
.action-menu { position: relative; }
.action-menu summary { display: inline-flex; align-items: center; list-style: none; cursor: pointer; }
.action-menu summary::-webkit-details-marker { display: none; }
.action-menu summary::after { content: " ▾"; margin-left: 5px; }
.action-menu[open] summary::after { content: " ▴"; }
.action-menu-list { position: absolute; top: calc(100% + 8px); right: 0; z-index: 20; display: grid; width: 220px; gap: 6px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); box-shadow: 0 10px 28px rgb(34 35 31 / 16%); }
.action-menu-list .button { width: 100%; justify-content: flex-start; text-align: left; }

.library {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--white);
    box-shadow: 0 8px 26px rgb(46 48 39 / 3%);
}

.section-heading { padding: 26px 28px 20px; }
.section-heading h2 { margin-bottom: 4px; font-size: 19px; }
.section-heading p { margin-bottom: 0; color: var(--muted); font-size: 12px; }

.filters {
    display: grid;
    grid-template-columns: minmax(210px, 1fr) repeat(3, minmax(130px, .55fr)) auto;
    align-items: end;
    gap: 14px;
    padding: 18px 28px 22px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    background: #fdfcf9;
}

label { display: grid; gap: 7px; color: #55584f; font-size: 12px; font-weight: 600; }
input, select, textarea {
    width: 100%;
    min-height: 41px;
    padding: 10px 12px;
    border: 1px solid #e3e1da;
    border-radius: 6px;
    outline: none;
    background: var(--white);
    color: var(--ink);
    font-size: 13px;
    font-weight: 400;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgb(96 101 84 / 16%); }
input::placeholder { color: #aaa99f; }
.filter-actions { display: flex; align-items: center; gap: 12px; }
.filter-actions .button { min-height: 41px; }
.reset-link { color: var(--muted); font-size: 12px; text-decoration: none; }
.reset-link:hover { color: var(--ink); text-decoration: underline; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th {
    padding: 14px 16px;
    color: #8a8b83;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    white-space: nowrap;
}
th:first-child, td:first-child { padding-left: 28px; }
th:last-child, td:last-child { padding-right: 28px; }
td { padding: 5px 0px; border-top: 1px solid #f0efe9; color: #62645d; font-size: 18px; vertical-align: top; }
tbody tr:hover { background: #fdfcf9; }
.model-title { min-width: 180px; font-weight: 600; }
.model-title a { color: var(--primary-dark); text-decoration: none; }
.model-title a:hover { text-decoration: underline; }
.model-title a:focus-visible { border-radius: 2px; outline: 2px solid var(--primary-dark); outline-offset: 3px; }
.tag { display: inline-block; padding: 5px 9px; border-radius: 20px; background: var(--primary-pale); color: var(--primary-ink); font-size: 11px; white-space: nowrap; }
.long-text { min-width: 150px; max-width: 240px; white-space: pre-line; }

.detail-page { width: 90%; max-width: none; }
.detail-topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.detail-back { display: inline-block; color: var(--primary-dark); font-size: 13px; font-weight: 600; text-decoration: none; }
.detail-back:hover { text-decoration: underline; }
.detail-panel { padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.detail-header { padding-bottom: 24px; border-bottom: 0; }
.detail-header { text-align: center; }
.detail-header h1 { margin-bottom: 0; overflow-wrap: anywhere; }
.detail-actions { margin-top: 20px; }
.detail-edit { padding: 24px 0; border-bottom: 1px solid var(--line); background-color: var(--paper);}
.detail-edit h2 { margin-bottom: 18px; font-family: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif; font-size: 20px; }
.detail-edit-form { display: grid; gap: 16px; }
.detail-edit[hidden] { display: none; }
.detail-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 20px; margin: 0; padding: 24px 0; border-bottom: 1px solid var(--line); }
.detail-meta dt { margin-bottom: 9px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.detail-meta dd { margin: 0; color: var(--ink); font-size: 14px; }
.detail-section { padding-top: 24px; }
.detail-section h2 { margin-bottom: 10px; font-family: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif; font-size: 20px; }
.detail-section p { margin-bottom: 0; color: #55584f; font-size: 14px; line-height: 1.7; overflow-wrap: anywhere; }
.instruction-steps { display: grid; gap: 0; }
.instruction-step { margin: 16px 0 0 !important; }
.instruction-step strong { font-weight: 700; }
.recipe-box { display: flex; flex-direction: column; min-width: 0; padding: 16px; border-radius: 12px; background: var(--white); box-shadow: 0 6px 20px rgb(34 35 31 / 20%); }
.recipe-box h2 { margin-bottom: 8px; font-size: 20px; }
.recipe-box p { margin: 8px 0; }
.recipe-box a { color: var(--primary-dark); }
.full-width-recipe { margin-top: 16px; }
.ingredients-section { padding-top: 16px; }
.preparation-section { padding-top: 16px; }
.recipe-edit-button { display: block; margin: 32px auto 0; min-height: 48px; padding: 12px 24px; border: 0; border-radius: 8px; background: var(--primary-pale); color: var(--primary-ink); font-size: 16px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; cursor: pointer; }
.recipe-edit-button:hover { background: var(--primary); color: var(--white); }
.recipe-details h2 { margin-bottom: 8px; font-family: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif; font-size: 20px; }
.recipe-details { padding-top: 16px; }
.recipe-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
.recipe-details .detail-meta { grid-template-columns: 1fr 1fr; padding: 0 0 24px; border-bottom: 1px solid var(--line); }
.preparation-meta { grid-template-columns: 1fr !important; }
.preparation-full { grid-column: 1 / -1; }
.preparation-section { border-left: 0; padding-left: 16px; }
.ingredients-heading { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.ingredients-heading h2 { margin-bottom: 0; }
h1 { font-size: clamp(42px, 5vw, 64px); }
h2 { font-size: 24px; }
h3 { font-size: 22px; }
.detail-section p,
.recipe-box p,
.detail-meta dd,
.people-label,
.ingredient-table,
.instruction-step { font-size: 17px; }
.detail-meta dt,
.ingredient-table th,
.eyebrow { font-size: 13px; }
.detail-meta dd,
#people-count { font-size: 18px; }
.people-adjuster { display: inline-flex; align-items: center; gap: 10px; }
.people-label { color: var(--muted); font-size: 18px; }
.people-button { width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 50%; background: var(--primary-dark); color: var(--white); font-size: 18px; line-height: 1; }
.people-button:hover { border-color: var(--primary); background: var(--primary-pale); color: var(--primary-dark);}
#people-count { min-width: 24px; text-align: center; font-weight: 700; }
.ingredient-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.ingredient-table { width: 100%; }
.ingredient-table th { border-bottom: 1px solid var(--line); background: #fdfcf9; }
.ingredient-table td { border-top: 1px solid #f0efe9; }
.ingredient-table tbody tr:nth-child(odd) { background: #f8f8f8; }
.ingredient-table th, .ingredient-table td { text-align: center; }
.ingredient-table th:first-child, .ingredient-table td:first-child { width: 110px; }
.ingredient-table th:nth-child(2), .ingredient-table td:nth-child(2) { width: 140px; }

.empty-state { padding: 68px 24px 76px; text-align: center; }
.empty-icon { display: inline-grid; width: 46px; height: 46px; margin-bottom: 16px; place-items: center; border-radius: 50%; background: var(--primary-pale); color: var(--primary-dark); font-size: 22px; }
.empty-state h3 { margin-bottom: 7px; font-family: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif; font-size: 20px; }
.empty-state p { margin-bottom: 0; color: var(--muted); font-size: 13px; }

.notice-stack { position: fixed; top: 20px; right: 20px; z-index: 1200; display: grid; width: min(420px, calc(100vw - 40px)); gap: 10px; }
.notice { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 14px 14px 14px 16px; border: 1px solid; border-radius: 9px; box-shadow: 0 12px 32px rgb(34 35 31 / 14%); font-size: 13px; line-height: 1.5; transition: opacity .2s ease, transform .2s ease; }
.notice-error { border-color: #efd3cf; background: #fff5f3; color: var(--rose); }
.notice-success { border-color: #dfe2d6; background: var(--primary-pale); color: var(--primary-ink); }
.notice-dismiss { flex: 0 0 auto; width: 26px; height: 26px; margin: -3px -3px 0 0; border: 0; border-radius: 50%; background: transparent; color: currentColor; font-size: 20px; line-height: 1; }
.notice-dismiss:hover { background: rgb(0 0 0 / 6%); }
.notice.is-dismissing { opacity: 0; transform: translateY(-8px); pointer-events: none; }

.modal {
    width: min(560px, calc(100% - 32px));
    max-height: min(90vh, 850px);
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: var(--white);
    box-shadow: 0 24px 80px rgb(24 26 21 / 24%);
}
#model-dialog {
    width: min(760px, calc(100% - 32px));
    /* height: min(94vh, 920px); */
    max-height: min(98vh, 980px);
}
#model-dialog .modal-content {
    height: 100%;
    overflow-y: auto;
}
.modal::backdrop { background: rgb(30 32 27 / 42%); backdrop-filter: blur(2px); }
.modal-content { display: grid; gap: 16px; padding: 28px; }
.compact-modal { gap: 20px; }
.modal-heading { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 2px; }
.modal-heading h2 { margin-bottom: 0; font-size: 27px; }
.close-button { width: 32px; height: 32px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 25px; line-height: 1; }
.close-button:hover { background: #f2f1ec; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.fabric-fieldset { display: grid; min-width: 0; gap: 10px; margin: 0; padding: 14px; border: 1px solid #e3e1da; border-radius: 6px; }
.fabric-fieldset legend { padding: 0 6px; color: #55584f; font-size: 12px; font-weight: 600; }
.fabric-options { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.fabric-option { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); font-size: 13px; font-weight: 400; cursor: pointer; }
.ingredient-editor-rows { display: grid; gap: 10px; }
.ingredient-editor-row { display: grid; grid-template-columns: 1.4fr .6fr .7fr; gap: 10px; }
.fabric-option input[type="checkbox"] { width: 16px; height: 16px; min-height: 16px; margin: 0; accent-color: var(--primary-dark); }
.form-help { margin: 0; color: var(--muted); font-size: 12px; font-weight: 400; }
label b { color: var(--rose); }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; padding-top: 2px; }

@media (max-width: 850px) {
    .page { width: 90%; max-width: none; padding-top: 36px; }
    .page-header { align-items: flex-start; flex-direction: column; margin-bottom: 28px; }
    .detail-topbar { align-items: flex-start; flex-direction: column; }
    .recipe-columns { grid-template-columns: 1fr; gap: 12px; }
    .preparation-section { border-left: 0; border-top: 0; padding-left: 16px; }
    .recipe-details .detail-meta { grid-template-columns: 1fr 1fr; }
    .filters { grid-template-columns: 1fr 1fr; }
    .search-field { grid-column: 1 / -1; }
    .filter-actions { grid-column: 1 / -1; }
}

@media (max-width: 520px) {
    .page { width: 90%; max-width: none; padding-top: 26px; }
    .detail-page { width: 90%; }
    body { font-size: 12px; }
    h1 { font-size: 28px; }
    h2, .detail-edit h2, .recipe-details h2, .recipe-box h2 { font-size: 17px; }
    h3, .empty-state h3 { font-size: 16px; }
    .subtitle,
    .detail-section p,
    .recipe-box p,
    .detail-meta dd,
    .people-label,
    .ingredient-table,
    .instruction-step,
    input,
    select,
    textarea,
    label,
    td,
    th { font-size: 12px; }
    .detail-meta dt,
    .eyebrow,
    .section-heading p,
    .empty-state p,
    .form-help,
    .button,
    .recipe-edit-button { font-size: 12px; }
    .detail-meta { grid-template-columns: 1fr; gap: 16px; }
    .notice-stack { top: 12px; right: 12px; width: calc(100vw - 24px); }
    .actions { display: grid; width: 100%; grid-template-columns: 1fr; }
    .actions .button { width: 100%; }
    .section-heading { padding: 22px 18px 16px; }
    .filters { gap: 12px; padding: 16px 18px; }
    .filters > label:not(.search-field) { grid-column: 1 / -1; }
    .filter-actions { grid-column: 1 / -1; }
    th:first-child, td:first-child { padding-left: 18px; }
    th:last-child, td:last-child { padding-right: 18px; }
    .form-row { grid-template-columns: 1fr; }
    .ingredient-editor-row { grid-template-columns: 1fr; }
    .modal-content { padding: 22px; }
    .modal-actions { flex-wrap: wrap; }
}
