:root {
    --bg: #f7f7f4;
    --panel: #ffffff;
    --text: #171717;
    --muted: #6b6b63;
    --line: #deded7;
    --accent: #2f6f73;
    --accent-strong: #204f52;
    --danger: #9f2d20;
    --success: #287348;
    --shadow: 0 16px 50px rgba(31, 37, 35, 0.1);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

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

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

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 18px clamp(18px, 4vw, 56px);
    border-bottom: 1px solid rgba(222, 222, 215, 0.8);
    background: rgba(247, 247, 244, 0.92);
    backdrop-filter: blur(14px);
}

.brand {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0;
}

.nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.nav a {
    border-radius: 999px;
    padding: 8px 12px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

.nav a.active,
.nav a:hover {
    background: #e7eeeb;
    color: var(--accent-strong);
}

.page {
    width: min(1180px, calc(100vw - 32px));
    margin: 0 auto;
    padding: 34px 0 70px;
}

.hero,
.admin-hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 28px;
    padding: clamp(28px, 5vw, 64px) 0 34px;
}

.hero.compact {
    align-items: flex-start;
    padding-bottom: 12px;
}

.homepage-hero {
    position: relative;
    display: flex;
    align-items: center;
    min-height: var(--hero-height);
    overflow: hidden;
    border-radius: 8px;
    margin: 0 0 34px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.homepage-hero.with-image {
    background: #161616;
    color: #fff;
}

.homepage-hero.with-image::after {
    position: absolute;
    inset: 0;
    content: "";
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.62), rgba(0, 0, 0, 0.22) 52%, rgba(0, 0, 0, 0.08));
}

.homepage-hero > img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.homepage-hero.text-only {
    justify-content: center;
    border: 1px solid var(--line);
    background:
        linear-gradient(135deg, rgba(47, 111, 115, 0.11), rgba(255, 255, 255, 0.74)),
        var(--panel);
}

.homepage-hero-content {
    position: relative;
    z-index: 1;
    width: min(760px, calc(100% - 44px));
    padding: clamp(28px, 6vw, 70px);
}

.homepage-hero.text-only .homepage-hero-content {
    text-align: center;
}

.homepage-hero h1 {
    max-width: 720px;
    margin-bottom: 14px;
    font-size: clamp(36px, 6vw, 74px);
    line-height: 1;
}

.homepage-hero.text-only h1 {
    margin-left: auto;
    margin-right: auto;
}

.homepage-hero p {
    max-width: 650px;
    margin-bottom: 0;
    color: inherit;
    font-size: clamp(17px, 2vw, 22px);
}

.homepage-hero.text-only p {
    margin-left: auto;
    margin-right: auto;
    color: var(--muted);
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    max-width: 780px;
    margin-bottom: 12px;
    font-size: clamp(38px, 7vw, 88px);
    line-height: 0.95;
    letter-spacing: 0;
}

.compact h1,
.admin-hero h1,
.edit-panel h1,
.auth-panel h1,
.setup-panel h1 {
    font-size: clamp(32px, 5vw, 58px);
    line-height: 1;
}

.hero p,
.admin-hero p {
    max-width: 620px;
    margin-bottom: 0;
    color: var(--muted);
    font-size: clamp(17px, 2vw, 22px);
}

.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

.breadcrumbs a:hover {
    color: var(--accent);
}

.stats {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.admin-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.stats span {
    min-width: 132px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    padding: 14px 16px;
    color: var(--muted);
    box-shadow: 0 8px 28px rgba(31, 37, 35, 0.06);
}

.stats strong {
    display: block;
    color: var(--text);
    font-size: 28px;
    line-height: 1;
}

.grid {
    display: grid;
    gap: 18px;
}

.category-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}

.photo-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.tile {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 8px 26px rgba(31, 37, 35, 0.05);
    transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.tile:hover {
    border-color: rgba(47, 111, 115, 0.45);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.tile img,
.placeholder {
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #e4e3dd;
    object-fit: cover;
}

.tile strong,
.tile small {
    display: block;
    padding: 14px 16px 0;
}

.tile strong {
    font-size: 17px;
    line-height: 1.25;
}

.tile small {
    padding-top: 6px;
    padding-bottom: 16px;
    color: var(--muted);
}

.section-heading {
    margin: 34px 0 14px;
    border-top: 1px solid var(--line);
    padding-top: 22px;
}

.section-heading h2 {
    margin-bottom: 0;
    font-size: 22px;
}

.empty,
.setup-panel,
.auth-panel,
.edit-panel,
.admin-list {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    padding: clamp(22px, 4vw, 38px);
    box-shadow: 0 8px 28px rgba(31, 37, 35, 0.06);
}

.setup-panel,
.auth-panel,
.edit-panel {
    width: min(760px, 100%);
    margin: 32px auto;
}

.edit-panel.wide {
    width: 100%;
}

.split {
    display: grid;
    grid-template-columns: minmax(0, 0.85fr) minmax(280px, 1.15fr);
    gap: 32px;
}

.photo-view {
    padding-top: 10px;
}

.photo-view figure,
.edit-preview {
    margin: 0;
    overflow: hidden;
    border-radius: 8px;
    background: #111;
}

.photo-view figure img {
    width: 100%;
    max-height: 76vh;
    object-fit: contain;
    background: #111;
}

.photo-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 18px;
}

.photo-meta div {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    padding: 18px;
}

.photo-meta span,
.form span {
    display: block;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.photo-meta strong {
    font-size: 18px;
}

.photo-meta p {
    margin-bottom: 0;
}

.form {
    display: grid;
    gap: 18px;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font: inherit;
    padding: 12px 13px;
}

input:focus,
textarea:focus,
select:focus {
    outline: 3px solid rgba(47, 111, 115, 0.16);
    border-color: var(--accent);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    cursor: pointer;
    font: inherit;
    font-size: 14px;
    font-weight: 800;
    padding: 10px 15px;
}

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

.button.primary:hover {
    background: var(--accent-strong);
}

.button.danger {
    border-color: #efd0cc;
    color: var(--danger);
}

.button.small {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 13px;
}

.alert {
    border-radius: 8px;
    padding: 12px 14px;
    font-weight: 700;
}

.alert.success {
    background: #e7f3ec;
    color: var(--success);
}

.alert.error {
    background: #f9e9e6;
    color: var(--danger);
}

.admin-stats {
    margin-bottom: 18px;
}

.list-header,
.row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.list-header {
    margin-bottom: 14px;
}

.list-header h2 {
    margin-bottom: 0;
}

.list-header span,
.row small {
    color: var(--muted);
}

.row {
    border-top: 1px solid var(--line);
    padding: 15px 0;
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.photo-edit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}

.photo-edit-card {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 14px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
}

.photo-edit-card img {
    width: 96px;
    height: 72px;
    border-radius: 6px;
    object-fit: cover;
}

.photo-edit-card strong {
    display: block;
    overflow-wrap: anywhere;
    margin-bottom: 8px;
}

.edit-preview img {
    width: 100%;
    max-height: 760px;
    object-fit: contain;
}

.settings-block {
    margin-top: 26px;
    border-top: 1px solid var(--line);
    padding-top: 24px;
}

.settings-block:first-of-type {
    margin-top: 0;
    border-top: 0;
    padding-top: 0;
}

.settings-subsection {
    display: grid;
    gap: 18px;
    border-top: 1px solid var(--line);
    padding-top: 24px;
}

.settings-subsection h2 {
    margin-bottom: 0;
}

.hero-admin-preview {
    display: grid;
    gap: 12px;
}

.hero-admin-preview img {
    width: min(420px, 100%);
    max-height: 180px;
    border-radius: 8px;
    object-fit: cover;
}

.debug-list {
    display: grid;
    gap: 10px;
    margin-top: 22px;
}

.debug-list div {
    display: grid;
    grid-template-columns: minmax(160px, 0.35fr) minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    border-bottom: 1px solid var(--line);
    padding-bottom: 10px;
}

.debug-list code {
    overflow-wrap: anywhere;
}

.settings-table {
    display: grid;
    gap: 10px;
}

.settings-row {
    display: grid;
    grid-template-columns: minmax(120px, 0.8fr) minmax(220px, 1.4fr) 90px 82px 92px 76px;
    gap: 10px;
    align-items: center;
}

.settings-head {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.check {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.check input {
    width: auto;
}

.check span {
    margin: 0;
}

.standalone {
    justify-content: flex-start;
}

pre,
code {
    border-radius: 6px;
    background: #edede8;
    padding: 2px 5px;
}

pre {
    overflow: auto;
    padding: 14px;
}

@media (max-width: 760px) {
    .site-header,
    .hero,
    .admin-hero,
    .list-header,
    .row {
        align-items: flex-start;
        flex-direction: column;
    }

    .site-header {
        gap: 12px;
    }

    .nav {
        justify-content: flex-start;
    }

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

    .homepage-hero {
        min-height: max(260px, calc(var(--hero-height) * 0.75));
    }

    .settings-row {
        grid-template-columns: 1fr;
        border: 1px solid var(--line);
        border-radius: 8px;
        padding: 12px;
    }

    .settings-head {
        display: none;
    }

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

    .stats span {
        min-width: calc(50% - 6px);
    }
}
