:root {
    color-scheme: light;
    --ink: #29231d;
    --muted: #756c63;
    --paper: #fffaf3;
    --ground: #f4f0e8;
    --panel: #fffdf8;
    --line: #ded2c2;
    --green: #176b5b;
    --green-dark: #0f4f43;
    --gold: #9f6a24;
    --danger: #9a342c;
    --brown: #6f5846;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: var(--ground);
    font: 14px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", sans-serif;
}

h1,
h2,
h3,
p,
figure {
    margin: 0;
}

h1 {
    font-size: 22px;
}

h2 {
    font-size: 19px;
}

h3 {
    font-size: 16px;
}

.eyebrow {
    color: var(--gold);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px clamp(16px, 4vw, 40px);
    background: rgba(255, 250, 243, 0.96);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(10px);
}

.top-actions {
    display: flex;
    gap: 8px;
}

main {
    width: min(1380px, 100%);
    margin: 0 auto;
    padding: 22px clamp(12px, 3vw, 32px) 48px;
}

.login-view {
    display: grid;
    min-height: 68vh;
    place-items: center;
}

.login-box,
.metric,
.list-item,
.form-grid,
.media-item {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.login-box {
    display: grid;
    gap: 16px;
    width: min(420px, 100%);
    padding: 28px;
}

.app-shell {
    display: grid;
    grid-template-columns: 176px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.sidebar {
    position: sticky;
    top: 82px;
    display: grid;
    gap: 6px;
}

.nav-item {
    justify-content: flex-start;
    width: 100%;
    color: var(--ink);
    background: transparent;
    border: 1px solid transparent;
    text-align: left;
}

.nav-item.active {
    color: #fff;
    background: var(--brown);
}

.workspace {
    min-width: 0;
}

.panel {
    display: none;
}

.panel.active {
    display: grid;
    gap: 16px;
}

.panel-head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.metric {
    padding: 18px;
}

.metric span {
    color: var(--muted);
}

.metric strong {
    display: block;
    margin-top: 8px;
    font-size: 28px;
}

label {
    color: var(--muted);
}

input,
select,
textarea,
button {
    min-height: 40px;
    border-radius: 6px;
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    padding: 0 12px;
    color: var(--ink);
    background: var(--panel);
}

textarea {
    min-height: 76px;
    padding: 10px 12px;
    resize: vertical;
}

button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    padding: 0 16px;
    color: #fff;
    background: var(--green);
    cursor: pointer;
}

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

.ghost {
    color: var(--green);
    background: #e7efe9;
}

.ghost:hover {
    background: #d8e7dd;
}

.danger {
    background: var(--danger);
}

.danger:hover {
    background: #7d2923;
}

.form-grid,
.edit-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    padding: 14px;
}

.edit-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-top: 1px solid var(--line);
    padding: 14px 0 0;
}

.edit-grid.compact {
    border-top: 0;
    padding: 0;
}

.form-grid textarea,
.edit-grid textarea,
.form-grid .check-row,
.edit-grid .check-row,
.form-grid button,
.edit-grid .button-row,
.edit-grid .image-strip {
    grid-column: span 2;
}

.check-row,
.mini-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
}

.check-row input,
.mini-check input {
    width: auto;
}

.list {
    display: grid;
    gap: 10px;
}

.list-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
    gap: 16px;
    padding: 16px;
}

.item-main {
    min-width: 0;
}

.item-head {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
}

.thumb {
    width: 88px;
    height: 72px;
    border: 1px solid var(--line);
    border-radius: 6px;
    object-fit: cover;
    background: #eee4d6;
}

.empty-thumb {
    background: #eee4d6;
}

.meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    color: var(--muted);
}

.muted,
.empty {
    color: var(--muted);
}

.error {
    color: var(--danger);
}

.editor summary {
    margin-bottom: 12px;
    color: var(--green);
    cursor: pointer;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.image-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.image-strip figure {
    display: grid;
    gap: 4px;
    width: 84px;
}

.image-strip img {
    width: 84px;
    height: 84px;
    border: 1px solid var(--line);
    border-radius: 6px;
    object-fit: cover;
    background: #eee4d6;
}

.image-strip figcaption {
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.media-item {
    overflow: hidden;
}

.media-item img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    background: #eee4d6;
}

.media-item figcaption {
    display: grid;
    gap: 4px;
    padding: 10px;
}

.media-item span {
    color: var(--muted);
    font-size: 12px;
}

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 4;
    max-width: min(360px, calc(100vw - 36px));
    padding: 12px 14px;
    color: #fff;
    background: var(--green);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(41, 35, 29, 0.18);
}

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

    .sidebar {
        position: static;
        grid-auto-flow: column;
        grid-auto-columns: max-content;
        overflow-x: auto;
        padding-bottom: 6px;
    }

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

    .list-item {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 640px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .metrics,
    .form-grid,
    .edit-grid {
        grid-template-columns: 1fr;
    }

    .form-grid textarea,
    .edit-grid textarea,
    .form-grid .check-row,
    .edit-grid .check-row,
    .form-grid button,
    .edit-grid .button-row,
    .edit-grid .image-strip {
        grid-column: auto;
    }

    .item-head {
        grid-template-columns: 72px minmax(0, 1fr);
    }

    .thumb {
        width: 72px;
        height: 60px;
    }
}
