:root {
    --bg: #f3efe6;
    --panel: rgba(255, 250, 242, 0.92);
    --panel-strong: #fffdf8;
    --ink: #1f2a28;
    --muted: #54635f;
    --line: rgba(31, 42, 40, 0.12);
    --accent: #b45f2e;
    --accent-dark: #7f3d16;
    --success: #2f6a4a;
    --error: #8f2d2d;
    --shadow: 0 20px 50px rgba(37, 27, 17, 0.14);
    --radius: 24px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(180, 95, 46, 0.22), transparent 32%),
        radial-gradient(circle at bottom right, rgba(54, 106, 82, 0.18), transparent 28%),
        linear-gradient(135deg, #efe8da 0%, #f8f3eb 45%, #e6ddd0 100%);
    font-family: Georgia, "Times New Roman", serif;
}

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

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

.auth-shell {
    display: grid;
    place-items: center;
    padding: 32px;
}

.auth-panel {
    width: min(1040px, 100%);
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 24px;
    align-items: stretch;
}

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

.auth-panel-single {
    grid-template-columns: minmax(320px, 520px);
    justify-content: center;
}

.auth-copy,
.auth-card,
.hero-panel,
.panel-card,
.app-card,
.sidebar,
.content-header,
.flash,
.status-card {
    background: var(--panel);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.auth-copy,
.auth-card,
.hero-panel,
.panel-card,
.app-card,
.sidebar,
.content-header {
    padding: 28px;
}

.auth-copy h1,
.hero-panel h2,
.content-header h2 {
    margin: 0 0 12px;
    font-size: clamp(2rem, 4vw, 3.5rem);
    line-height: 0.95;
}

.auth-copy p,
.hero-panel p,
.app-card p,
.sidebar-copy,
.muted-link,
.muted-note,
.empty-state p,
.status-card span {
    color: var(--muted);
}

.eyebrow {
    margin: 0 0 8px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    font-size: 0.75rem;
    color: var(--accent-dark);
}

.auth-card,
.panel-card {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.stack-form {
    display: grid;
    gap: 16px;
}

.stack-form label,
.split-grid label {
    display: grid;
    gap: 8px;
}

.stack-form span,
.split-grid span {
    font-size: 0.95rem;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid rgba(31, 42, 40, 0.18);
    background: rgba(255, 255, 255, 0.82);
    border-radius: 16px;
    padding: 14px 16px;
    color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid rgba(180, 95, 46, 0.24);
    border-color: rgba(180, 95, 46, 0.5);
}

.primary-button,
.ghost-button,
.primary-link,
.tab-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0 18px;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.primary-button,
.primary-link {
    background: linear-gradient(135deg, var(--accent) 0%, #c8834e 100%);
    color: #fffdf8;
    box-shadow: 0 16px 24px rgba(180, 95, 46, 0.24);
}

.ghost-button,
.tab-chip {
    background: rgba(255, 255, 255, 0.66);
    color: var(--ink);
    border: 1px solid rgba(31, 42, 40, 0.12);
}

.primary-button:hover,
.ghost-button:hover,
.primary-link:hover,
.tab-chip:hover {
    transform: translateY(-1px);
}

.setup-callout {
    padding: 18px;
    border-radius: 20px;
    background: rgba(180, 95, 46, 0.08);
    border: 1px solid rgba(180, 95, 46, 0.16);
}

.status-grid,
.app-grid,
.two-column-layout,
.split-grid,
.triple-grid {
    display: grid;
    gap: 18px;
}

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

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

.site-shell {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 24px;
    padding: 24px;
}

.sidebar {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: calc(100vh - 48px);
    background:
        linear-gradient(180deg, rgba(255, 252, 247, 0.94) 0%, rgba(248, 242, 233, 0.92) 100%),
        linear-gradient(135deg, rgba(180, 95, 46, 0.08), rgba(54, 106, 82, 0.08));
}

.sidebar h1 {
    margin: 0;
    font-size: 2rem;
}

.sidebar-nav {
    display: grid;
    gap: 10px;
    margin: 24px 0;
}

.sidebar-nav a {
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid transparent;
}

.sidebar-nav a.is-active,
.sidebar-nav a:hover {
    background: rgba(180, 95, 46, 0.08);
    border-color: rgba(180, 95, 46, 0.14);
}

.content-shell {
    display: grid;
    gap: 18px;
    align-content: start;
}

.content-header h2 {
    font-size: 1.7rem;
}

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

.tab-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.inline-action-form {
    margin-top: 8px;
}

.mini-btn {
    min-height: 36px;
    padding: 0 12px;
    font-size: 0.85rem;
}

.danger-btn {
    border-color: rgba(143, 45, 45, 0.24);
    color: var(--error);
}

.token-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.token-pill {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 12px;
    border-radius: 999px;
    background: rgba(31, 42, 40, 0.08);
    border: 1px solid rgba(31, 42, 40, 0.12);
    font-size: 0.9rem;
}

.app-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.app-card-live {
    background: var(--panel-strong);
}

.card-status-row,
.history-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    background: rgba(54, 106, 82, 0.12);
    color: var(--success);
    font-size: 0.85rem;
}

.two-column-layout {
    grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
}

.history-list {
    display: grid;
    gap: 14px;
}

.report-list {
    margin: 0;
    padding-left: 18px;
    display: grid;
    gap: 6px;
}

.report-controls {
    margin-bottom: 12px;
}

.report-table {
    min-width: 860px;
}

.report-table tfoot th {
    background: rgba(180, 95, 46, 0.12);
}

.table-shell {
    overflow-x: auto;
}

.tracker-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 520px;
    background: rgba(255, 255, 255, 0.74);
    border-radius: 18px;
    overflow: hidden;
}

.tracker-table th,
.tracker-table td {
    padding: 12px 14px;
    border: 1px solid rgba(31, 42, 40, 0.1);
    text-align: left;
    vertical-align: top;
}

.tracker-table thead th {
    background: rgba(31, 42, 40, 0.08);
    font-weight: 700;
}

.history-card {
    padding: 18px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.74);
    border: 1px solid rgba(31, 42, 40, 0.08);
}

.flash {
    padding: 14px 18px;
}

.flash-error {
    color: var(--error);
    border-color: rgba(143, 45, 45, 0.14);
    background: rgba(255, 245, 244, 0.95);
}

.flash-success {
    color: var(--success);
    border-color: rgba(47, 106, 74, 0.14);
    background: rgba(243, 251, 246, 0.95);
}

.status-card {
    display: grid;
    gap: 6px;
    padding: 18px;
}

.status-good {
    border-color: rgba(47, 106, 74, 0.16);
}

.status-warn {
    border-color: rgba(180, 95, 46, 0.16);
}

.empty-state {
    padding: 18px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.68);
}

.public-gallery-shell {
    width: min(1200px, 100%);
    margin: 0 auto;
    padding: 32px;
}

.public-gallery-title {
    margin: 0;
    font-size: clamp(2rem, 4vw, 3rem);
    line-height: 1;
}

.public-gallery-intro {
    margin-top: 10px;
}

.public-gallery-form {
    margin-top: 20px;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
}

.gallery-card {
    display: grid;
    gap: 10px;
    align-content: start;
    border: 1px solid rgba(31, 42, 40, 0.1);
    background: rgba(255, 255, 255, 0.78);
    border-radius: 18px;
    padding: 10px;
}

.gallery-card input {
    width: auto;
    margin: 0;
}

.gallery-preview-trigger {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    border-radius: 12px;
    cursor: zoom-in;
    background: transparent;
}

.gallery-preview-trigger:focus-visible {
    outline: 3px solid rgba(180, 95, 46, 0.35);
    outline-offset: 3px;
}

.gallery-card img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid rgba(31, 42, 40, 0.12);
}

.gallery-meta {
    font-size: 0.92rem;
    color: var(--muted);
}

.gallery-lightbox {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: grid;
    place-items: center;
    padding: 24px;
}

.gallery-lightbox[hidden] {
    display: none !important;
}

.gallery-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(22, 18, 14, 0.74);
}

.gallery-lightbox-panel {
    position: relative;
    z-index: 1;
    width: min(1100px, 100%);
    max-height: calc(100vh - 48px);
    overflow: auto;
    background: rgba(255, 250, 243, 0.97);
    border: 1px solid rgba(31, 42, 40, 0.14);
    border-radius: 20px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.35);
    padding: 14px;
}

.gallery-lightbox-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.gallery-lightbox-media {
    position: relative;
    margin-top: 10px;
}

.gallery-lightbox-count {
    margin: 0;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid rgba(31, 42, 40, 0.16);
    background: rgba(255, 255, 255, 0.76);
    color: var(--muted);
    font-size: 0.9rem;
    white-space: nowrap;
}

.gallery-lightbox-close,
.gallery-lightbox-nav {
    min-height: 40px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid rgba(31, 42, 40, 0.16);
    background: rgba(255, 255, 255, 0.86);
    cursor: pointer;
}

.gallery-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    display: grid;
    place-items: center;
    font-size: 1.2rem;
    line-height: 1;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.gallery-lightbox-nav-prev {
    left: 12px;
}

.gallery-lightbox-nav-next {
    right: 12px;
}

.gallery-lightbox-close:hover,
.gallery-lightbox-nav:hover {
    background: #ffffff;
}

.gallery-lightbox-close:focus-visible,
.gallery-lightbox-nav:focus-visible {
    outline: 3px solid rgba(180, 95, 46, 0.35);
    outline-offset: 2px;
}

.gallery-lightbox-panel img {
    width: 100%;
    max-height: calc(100vh - 180px);
    object-fit: contain;
    border-radius: 14px;
    cursor: zoom-out;
}

.gallery-lightbox-title {
    margin: 10px 0 4px;
    color: var(--muted);
}

.gallery-lightbox-select {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.95rem;
}

.gallery-lightbox-select input {
    width: auto;
    margin: 0;
}

@media (max-width: 980px) {

    .auth-panel,
    .auth-panel-wide,
    .site-shell,
    .two-column-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        min-height: 0;
    }

    .compact-panel {
        align-items: start;
        flex-direction: column;
    }
}

@media (max-width: 640px) {

    .auth-shell,
    .site-shell {
        padding: 16px;
    }

    .public-gallery-shell {
        padding: 16px;
    }

    .auth-copy,
    .auth-card,
    .hero-panel,
    .panel-card,
    .app-card,
    .sidebar,
    .content-header {
        padding: 22px;
    }

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

    .gallery-lightbox {
        padding: 10px;
    }

    .gallery-lightbox-panel {
        padding: 10px;
    }

    .gallery-lightbox-controls {
        gap: 8px;
    }

    .gallery-lightbox-nav-prev {
        left: 8px;
    }

    .gallery-lightbox-nav-next {
        right: 8px;
    }
}