:root {
    --bg-app: #ece7e1;
    --bg-list: #f2ece4;
    --bg-detail: #f8f6f3;
    --panel: #fff9f3;
    --panel-soft: #f4ede3;
    --line: #dfd0bf;
    --line-strong: #d4c2ad;
    --text: #2f2219;
    --muted: #7f6a57;
    --accent: #c86739;
    --accent-dark: #a9522d;
    --accent-soft: #f3ddcf;
    --danger: #b44b30;
    --danger-dark: #943820;
    --ok-bg: #e9f5e8;
    --ok-text: #24563f;
    --warn-bg: #fff4e3;
    --warn-text: #7b4f26;
    --sidebar-bg: #30170b;
    --sidebar-bg-soft: #3b1e0f;
    --sidebar-line: rgba(248, 219, 194, 0.18);
    --radius-xl: 18px;
    --radius-lg: 14px;
    --radius-md: 12px;
    --radius-sm: 10px;
    --shadow-sm: 0 4px 12px rgba(44, 21, 10, 0.08);
    --shadow-md: 0 14px 32px rgba(44, 21, 10, 0.12);
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: 'Manrope', sans-serif;
    line-height: 1.45;
    color: var(--text);
    background: var(--bg-app);
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    display: block;
    max-width: 100%;
}

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

button:disabled,
input:disabled,
textarea:disabled,
select:disabled {
    cursor: not-allowed;
    opacity: 0.58;
}

.eyebrow {
    margin: 0 0 0.45rem;
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    clip: rect(0, 0, 0, 0);
    overflow: hidden;
}

.muted-copy {
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.flash-banner,
.mode-banner {
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 0.78rem 1rem;
    font-weight: 600;
}

.flash-banner.success {
    background: var(--ok-bg);
    color: var(--ok-text);
}

.flash-banner.error {
    background: #fdece7;
    color: #7e2f1f;
}

.mode-banner {
    background: var(--warn-bg);
    color: var(--warn-text);
}

.brand-logo-wrap {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 0.8rem;
}

.brand-logo {
    width: 56px;
    height: 56px;
    border-radius: 14px;
}

.auth-page {
    display: grid;
    align-items: center;
    min-height: 100vh;
    padding: 1.2rem;
}

.auth-shell {
    width: min(1080px, 100%);
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1.15fr minmax(340px, 440px);
    gap: 1rem;
}

.auth-brand,
.auth-panel {
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    background: var(--panel);
}

.auth-brand {
    padding: clamp(1.3rem, 3vw, 2.2rem);
    display: grid;
    align-content: center;
    gap: 1rem;
}

.auth-brand h1,
.sidebar h1,
.column-header h2,
.detail-hero h2 {
    margin: 0;
    font-family: 'Fraunces', serif;
    line-height: 1.08;
}

.auth-brand p {
    margin: 0;
    color: var(--muted);
    max-width: 62ch;
}

.auth-panel {
    padding: clamp(1.1rem, 2vw, 1.5rem);
    display: grid;
    align-content: start;
    gap: 0.85rem;
}

.auth-switch {
    padding: 0.25rem;
    border-radius: 999px;
    background: var(--panel-soft);
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem;
}

.auth-switch a {
    border-radius: 999px;
    text-align: center;
    font-weight: 700;
    color: var(--muted);
    padding: 0.62rem 0.7rem;
}

.auth-switch a.active {
    background: var(--accent);
    color: #fff8f2;
}

.auth-inline-link {
    color: #8a5537;
    font-weight: 700;
    font-size: 0.9rem;
}

.auth-inline-link:hover {
    text-decoration: underline;
}

.auth-help-copy {
    margin-top: 0.2rem;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    background: var(--bg-app);
}

.sidebar {
    height: 100vh;
    position: sticky;
    top: 0;
    overflow: auto;
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, #261106 100%);
    border-right: 1px solid var(--sidebar-line);
    color: #f6ecdf;
    display: grid;
    align-content: start;
    gap: 0.95rem;
    padding: 0.92rem 0.68rem 1rem;
}

.brand-block .sidebar-copy {
    margin-top: 0.7rem;
    color: #d5b9a2;
    font-size: 0.82rem;
}

.main-nav,
.family-list,
.inline-form,
.recipe-form,
.stack-form,
.form-grid,
.chip-grid,
.detail-grid,
.gallery-grid,
.admin-stats-grid,
.admin-member-list,
.dynamic-list {
    display: grid;
    gap: 0.7rem;
}

.main-nav a {
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    display: grid;
    grid-template-columns: 20px 1fr;
    align-items: center;
    gap: 0.62rem;
    padding: 0.6rem 0.7rem;
    color: #f8ebdf;
    transition: 150ms ease;
}

.main-nav a:hover {
    border-color: rgba(255, 221, 194, 0.35);
    background: rgba(200, 103, 57, 0.2);
}

.main-nav a.active {
    border-color: rgba(255, 213, 185, 0.48);
    background: var(--accent);
    color: #fff9f2;
    font-weight: 700;
}

.nav-icon {
    display: inline-flex;
}

.nav-icon svg {
    width: 18px;
    height: 18px;
}

.nav-icon path {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.family-switcher,
.invite-box {
    border: 1px solid rgba(250, 228, 210, 0.2);
    border-radius: var(--radius-lg);
    background: rgba(255, 247, 239, 0.06);
    padding: 0.75rem;
}

.section-heading {
    margin-bottom: 0.72rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.7rem;
}

.section-heading h2,
.section-heading h3 {
    margin: 0;
}

.section-heading span {
    color: var(--muted);
    font-size: 0.87rem;
}

.sidebar .section-heading h2,
.sidebar .section-heading h3,
.sidebar .family-title {
    color: #fff4e8;
}

.sidebar .section-heading span,
.sidebar .family-meta,
.sidebar .muted-copy,
.sidebar .field span {
    color: #d8bfa9;
}

.family-card {
    border: 1px solid rgba(241, 210, 186, 0.22);
    border-radius: var(--radius-sm);
    background: rgba(255, 245, 236, 0.05);
    padding: 0.62rem;
    display: block;
    transition: 150ms ease;
}

.family-card:hover {
    border-color: rgba(241, 208, 181, 0.5);
    transform: translateY(-1px);
}

.family-card.selected {
    border-color: rgba(255, 226, 203, 0.62);
    background: rgba(200, 103, 57, 0.28);
}

.family-title {
    display: block;
    font-weight: 700;
}

.family-meta {
    display: block;
    margin-top: 0.2rem;
    color: var(--muted);
    font-size: 0.83rem;
}

.ghost-button,
.secondary-button,
.primary-button,
.filter-chip,
.ghost-chip,
.jump-button,
.danger-button {
    border: 1px solid transparent;
    border-radius: 999px;
    cursor: pointer;
    transition: 150ms ease;
}

.primary-button,
.jump-button {
    background: var(--accent);
    border-color: transparent;
    color: #fff9f2;
    font-weight: 700;
    padding: 0.72rem 0.98rem;
}

.primary-button:hover,
.jump-button:hover {
    background: var(--accent-dark);
}

.secondary-button {
    background: #f1e6da;
    border-color: #e7d3c0;
    color: #734730;
    font-weight: 700;
    padding: 0.7rem 0.95rem;
}

.secondary-button:hover {
    background: #ebdccd;
}

.danger-button {
    background: var(--danger);
    border-color: transparent;
    color: #fff;
    font-weight: 700;
    padding: 0.62rem 0.9rem;
}

.danger-button:hover {
    background: var(--danger-dark);
}

.ghost-chip {
    background: #f7efe5;
    border-color: #ddc9b5;
    color: #7d5b46;
    padding: 0.44rem 0.76rem;
    font-weight: 600;
}

.ghost-chip:hover {
    background: #f2e6d8;
}

.sidebar .primary-button {
    background: #d77845;
}

.sidebar .primary-button:hover {
    background: #be6435;
}

.sidebar .secondary-button {
    background: rgba(255, 246, 236, 0.15);
    border-color: rgba(248, 219, 194, 0.26);
    color: #ffefe0;
}

.sidebar .secondary-button:hover {
    background: rgba(255, 246, 236, 0.24);
}

.sidebar .ghost-chip {
    background: rgba(255, 246, 236, 0.1);
    border-color: rgba(248, 219, 194, 0.38);
    color: #ffe6d3;
}

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

.field span {
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 700;
}

.field input,
.field textarea,
.field select,
.code-line input,
.inline-admin-form select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fffdfa;
    padding: 0.64rem 0.78rem;
}

.field textarea {
    resize: vertical;
}

.sidebar .field input,
.sidebar .field textarea,
.sidebar .field select,
.sidebar .code-line input {
    background: rgba(255, 246, 236, 0.1);
    border-color: rgba(248, 219, 194, 0.25);
    color: #fff5eb;
}

.code-line {
    margin-bottom: 0.7rem;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.45rem;
}

.inline-form {
    margin-top: 0.78rem;
}

.logout-form {
    margin-top: -0.2rem;
}

.workspace {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(330px, 420px) minmax(0, 1fr);
    gap: 0;
    align-items: stretch;
    background: var(--bg-detail);
}

.workspace > * {
    min-width: 0;
}

.workspace > .flash-banner,
.workspace > .mode-banner {
    grid-column: 1 / -1;
    margin: 0.9rem 1rem 0;
}

.list-column,
.detail-column,
.admin-main-column,
.admin-side-column {
    max-height: 100vh;
    overflow: auto;
    display: grid;
    align-content: start;
    gap: 0.95rem;
}

.list-column,
.admin-main-column {
    background: var(--bg-list);
    border-right: 1px solid var(--line-strong);
    padding: 1rem;
}

.detail-column,
.admin-side-column {
    background: var(--bg-detail);
    padding: 1rem 1.15rem 1.2rem;
}

.column-header,
.search-panel,
.recipe-card,
.detail-panel,
.gallery-panel,
.empty-state,
.detail-hero,
.form-panel,
.admin-panel {
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--panel);
    box-shadow: var(--shadow-sm);
    padding: 0.95rem;
}

.column-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.85rem;
}

.column-header h2 {
    font-size: clamp(1.25rem, 1.4vw, 1.5rem);
}

.column-subtitle {
    margin: 0.3rem 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.family-switch-form {
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--panel);
    box-shadow: var(--shadow-sm);
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: end;
    gap: 0.7rem;
    padding: 0.72rem 0.82rem;
}

.search-panel {
    position: sticky;
    top: 1rem;
    z-index: 5;
}

.search-field input {
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    padding: 0.76rem 0.92rem;
}

.advanced-filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.62rem;
    margin-top: 0.2rem;
}

.advanced-filters .field input,
.advanced-filters .field select {
    width: 100%;
}

.advanced-filters .field:last-child {
    grid-column: 1 / -1;
}

.filter-actions {
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
}

.filter-actions p {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.chip-grid {
    margin-top: -0.1rem;
    grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
}

.filter-chip {
    background: #f5ece2;
    border-color: #dfccb8;
    color: #745442;
    font-size: 0.84rem;
    padding: 0.5rem 0.62rem;
}

.filter-chip:hover,
.filter-chip.active {
    background: var(--accent-soft);
    border-color: #dca784;
    color: #7f4324;
}

.recipe-list {
    display: grid;
    gap: 0.72rem;
    margin-top: -0.1rem;
}

.recipe-card {
    padding: 0;
    overflow: hidden;
    transition: border-color 150ms ease, background-color 150ms ease, transform 150ms ease;
    opacity: 0;
    transform: translateY(5px);
    animation: card-fade 320ms ease forwards;
    animation-delay: calc(var(--card-index, 0) * 26ms);
}

.recipe-card a {
    display: grid;
    gap: 0.64rem;
    padding: 0.78rem;
}

.recipe-card:hover {
    border-color: #d7b79e;
    transform: translateY(-1px);
}

.recipe-card.selected {
    border-color: #d59c7a;
    background: #fff3e8;
}

.recipe-card[hidden] {
    display: none !important;
}

.empty-card {
    opacity: 1;
    transform: none;
    animation: none;
}

.recipe-card-top {
    display: grid;
    grid-template-columns: 68px minmax(0, 1fr);
    align-items: center;
    gap: 0.72rem;
}

.recipe-card-top img {
    width: 68px;
    height: 68px;
    border-radius: 12px;
    object-fit: cover;
    border: 1px solid #e6d4c2;
}

.recipe-tag {
    margin: 0 0 0.26rem;
    display: inline-flex;
    width: fit-content;
    border: 1px solid #e0c4ad;
    border-radius: 999px;
    background: #f8ebe0;
    color: #7d4e35;
    padding: 0.18rem 0.5rem;
    font-size: 0.76rem;
    font-weight: 700;
}

.recipe-card h3 {
    margin: 0;
    font-size: 1rem;
}

.recipe-author {
    margin: 0.22rem 0 0;
    color: var(--muted);
    font-size: 0.82rem;
}

.recipe-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.recipe-stats span {
    border: 1px solid #e3d3c3;
    border-radius: 999px;
    background: #fcf5ed;
    color: #745b48;
    font-size: 0.78rem;
    padding: 0.2rem 0.55rem;
}

.detail-hero {
    display: grid;
    grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
    gap: 0.95rem;
}

.detail-hero img {
    width: 100%;
    min-height: 240px;
    max-height: 330px;
    object-fit: cover;
    border-radius: 16px;
    border: 1px solid #e1cdb9;
}

.detail-hero-copy {
    display: grid;
    align-content: start;
    gap: 0.7rem;
}

.detail-hero-copy p {
    margin: 0;
    color: var(--muted);
}

.detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.46rem;
}

.detail-meta span {
    border: 1px solid #e0ccba;
    border-radius: 999px;
    background: #f8eee3;
    padding: 0.3rem 0.62rem;
    font-size: 0.82rem;
    color: #6f5442;
}

.recipe-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.delete-recipe-form {
    margin: 0;
}

.detail-grid {
    grid-template-columns: 1fr;
}

.ingredient-list,
.step-list {
    margin: 0;
    padding: 0;
}

.ingredient-list {
    list-style: none;
    display: grid;
    gap: 0.52rem;
}

.ingredient-list li {
    display: grid;
    grid-template-columns: minmax(110px, 130px) minmax(0, 1fr);
    gap: 0.6rem;
    border: 1px solid #e4d6c8;
    border-radius: 12px;
    background: var(--panel-soft);
    padding: 0.56rem 0.65rem;
}

.ingredient-list li span {
    font-weight: 700;
    color: #8a5537;
}

.ingredient-list li strong {
    font-weight: 700;
}

.step-list {
    list-style: none;
    counter-reset: step;
    display: grid;
    gap: 0.56rem;
}

.step-list li {
    position: relative;
    border: 1px solid #e4d6c8;
    border-radius: 12px;
    background: var(--panel-soft);
    padding: 0.62rem 0.7rem 0.62rem 2.4rem;
}

.step-list li::before {
    content: counter(step);
    counter-increment: step;
    position: absolute;
    left: 0.58rem;
    top: 0.55rem;
    width: 1.34rem;
    height: 1.34rem;
    border-radius: 999px;
    background: var(--accent);
    color: #fff9f2;
    font-size: 0.74rem;
    font-weight: 800;
    display: grid;
    place-items: center;
}

.gallery-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.gallery-grid img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid #e2d1bf;
}

.empty-state {
    border-style: dashed;
    background: transparent;
    box-shadow: none;
    min-height: 54vh;
    display: grid;
    align-content: center;
    justify-items: center;
    text-align: center;
    gap: 0.4rem;
    padding: 1.8rem 1rem;
}

.empty-state h2 {
    margin: 0;
    font-family: 'Fraunces', serif;
}

.empty-state p {
    margin: 0;
    color: var(--muted);
    max-width: 36ch;
}

.empty-state-emoji {
    margin: 0 0 0.2rem;
    font-size: 2rem;
}

.form-panel {
    margin-top: 0.15rem;
}

.form-grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.recipe-form,
.stack-form {
    gap: 0.72rem;
}

.compact-form {
    margin-top: 0.75rem;
}

.structured-block {
    border: 1px solid #e2d4c6;
    border-radius: var(--radius-md);
    background: var(--panel-soft);
    padding: 0.78rem;
    display: grid;
    gap: 0.58rem;
}

.structured-block .section-heading {
    margin-bottom: 0.1rem;
}

.structured-block h3 {
    font-size: 0.98rem;
}

.dynamic-row {
    border: 1px solid #e5d7c8;
    border-radius: 11px;
    background: #fffdf9;
    padding: 0.5rem;
    display: grid;
    gap: 0.46rem;
    align-items: start;
}

.ingredient-row {
    grid-template-columns: minmax(0, 120px) minmax(0, 1fr) auto;
}

.step-row {
    grid-template-columns: minmax(0, 1fr) auto;
}

.photo-row {
    grid-template-columns: minmax(0, 1fr) auto;
}

.step-row textarea {
    min-height: 86px;
}

.row-remove-button {
    white-space: nowrap;
    align-self: center;
}

.admin-main-column,
.admin-side-column {
    gap: 0.92rem;
}

.admin-stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat-card {
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--panel-soft);
    padding: 0.78rem;
}

.stat-label {
    margin: 0;
    color: var(--muted);
    font-size: 0.8rem;
}

.stat-value {
    margin: 0.2rem 0 0;
    font-size: 1.7rem;
    font-weight: 800;
    color: #8c4f32;
}

.table-wrap {
    overflow: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.admin-table th,
.admin-table td {
    border-bottom: 1px solid var(--line);
    text-align: left;
    padding: 0.64rem 0.45rem;
    white-space: nowrap;
}

.admin-table th {
    color: var(--muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.admin-family-meta {
    border: 1px dashed #d6c3af;
    border-radius: var(--radius-sm);
    background: var(--panel-soft);
    margin: 0.32rem 0 0.6rem;
    padding: 0.62rem 0.66rem;
}

.admin-family-meta p {
    margin: 0;
    font-size: 0.88rem;
}

.admin-family-meta p + p {
    margin-top: 0.3rem;
}

.admin-member-card {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #fffdfa;
    padding: 0.68rem;
    display: grid;
    gap: 0.5rem;
}

.member-name {
    margin: 0;
    font-weight: 700;
}

.owner-pill {
    margin: 0;
    width: fit-content;
    border: 1px solid #dfc5ac;
    border-radius: 999px;
    background: #f6e6d7;
    color: #7b4f35;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.24rem 0.58rem;
}

.inline-admin-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
}

@keyframes card-fade {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 1380px) {
    .workspace {
        grid-template-columns: minmax(300px, 390px) minmax(0, 1fr);
    }
}

@media (max-width: 1180px) {
    .workspace {
        grid-template-columns: 1fr;
    }

    .search-panel {
        position: static;
    }

    .list-column,
    .detail-column,
    .admin-main-column,
    .admin-side-column {
        max-height: none;
        overflow: visible;
    }

    .list-column,
    .admin-main-column {
        border-right: 0;
        border-bottom: 1px solid var(--line-strong);
    }

    .admin-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 1040px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
        max-height: none;
        border-right: 0;
        border-bottom: 1px solid var(--sidebar-line);
    }

    .auth-shell {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 820px) {
    .detail-hero,
    .advanced-filters,
    .gallery-grid,
    .ingredient-row,
    .step-row,
    .photo-row,
    .form-grid.two,
    .form-grid.three {
        grid-template-columns: 1fr;
    }

    .detail-hero img {
        max-height: 280px;
    }

    .advanced-filters .field:last-child {
        grid-column: auto;
    }
}

@media (max-width: 640px) {
    .auth-page {
        padding: 1rem;
    }

    .workspace > .flash-banner,
    .workspace > .mode-banner {
        margin: 0.72rem 0.74rem 0;
    }

    .list-column,
    .detail-column,
    .admin-main-column,
    .admin-side-column {
        padding: 0.75rem;
    }

    .column-header {
        flex-direction: column;
        align-items: stretch;
    }

    .recipe-card-top {
        grid-template-columns: 1fr;
    }

    .recipe-stats {
        gap: 0.35rem;
    }

    .code-line,
    .family-switch-form {
        grid-template-columns: 1fr;
    }

    .admin-stats-grid {
        grid-template-columns: 1fr;
    }
}
