:root {
    --bg: #f4efe6;
    --bg-strong: #e6dccd;
    --surface: rgba(255, 248, 240, 0.88);
    --surface-strong: #fffaf4;
    --text: #201815;
    --muted: #67574f;
    --accent: #b84c2b;
    --accent-dark: #8c3318;
    --success: #256d4a;
    --warning: #a86b07;
    --danger: #8f2435;
    --line: rgba(32, 24, 21, 0.1);
    --shadow: 0 18px 40px rgba(63, 42, 32, 0.14);
    --radius: 24px;
    --font-display: "Avenir Next", "Segoe UI", sans-serif;
    --font-body: "IBM Plex Sans", "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-body);
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(184, 76, 43, 0.2), transparent 32%),
        radial-gradient(circle at bottom right, rgba(111, 94, 73, 0.22), transparent 25%),
        linear-gradient(180deg, #f8f1e7 0%, #efe6d8 100%);
    min-height: 100vh;
}

img,
canvas {
    max-width: 100%;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
}

.page-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 24px 0 48px;
}

.site-header,
.section-header,
.actions,
.hero-actions,
.site-nav,
.detail-grid,
.grid,
.meta-list {
    display: flex;
    gap: 16px;
}

.site-header,
.section-header {
    justify-content: space-between;
    align-items: center;
}

.site-header {
    margin-bottom: 24px;
    padding: 18px 24px;
    border: 1px solid var(--line);
    background: rgba(255, 250, 244, 0.76);
    box-shadow: var(--shadow);
    border-radius: 999px;
    backdrop-filter: blur(18px);
}

.brand,
.site-nav a,
.link-button {
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
}

.brand {
    font-family: var(--font-display);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.site-nav {
    align-items: center;
    flex-wrap: wrap;
}

.content {
    display: grid;
    gap: 24px;
}

.hero,
.detail-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 24px;
}

.hero-copy,
.hero-card,
.panel,
.card,
.viewer-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(20px);
}

.hero-copy,
.hero-card,
.panel,
.viewer-panel {
    padding: 28px;
}

.hero-copy h1,
h1,
h2,
h3 {
    font-family: var(--font-display);
    line-height: 1.05;
    margin-top: 0;
}

.hero-copy h1 {
    font-size: clamp(2.8rem, 5vw, 4.7rem);
    margin-bottom: 16px;
}

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

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--accent-dark);
}

.button,
.link-button {
    border: 0;
    cursor: pointer;
    border-radius: 999px;
    padding: 12px 18px;
    font: inherit;
    font-weight: 700;
    transition: transform 0.18s ease, opacity 0.18s ease, background 0.18s ease;
}

.button {
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

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

.button-secondary {
    background: var(--surface-strong);
    color: var(--text);
    border: 1px solid var(--line);
}

.button-tertiary,
.link-button {
    background: transparent;
    color: var(--accent-dark);
}

.danger {
    background: var(--danger);
    color: #fff;
}

.full {
    width: 100%;
}

.input,
.textarea {
    width: 100%;
    margin-top: 8px;
    margin-bottom: 14px;
    padding: 14px 16px;
    border-radius: 18px;
    border: 1px solid rgba(32, 24, 21, 0.14);
    background: rgba(255, 255, 255, 0.72);
    font: inherit;
}

.quick-field {
    display: flex;
    align-items: center;
    gap: 12px;
}

.quick-field .input {
    margin-bottom: 14px;
}

.quick-field .button {
    white-space: nowrap;
}

.small {
    max-width: 100px;
}

.textarea {
    min-height: 140px;
    resize: vertical;
}

.narrow {
    max-width: 540px;
    margin: 0 auto;
}

.cards,
.stats {
    flex-wrap: wrap;
}

.card,
.stat {
    flex: 1 1 280px;
}

.card {
    overflow: hidden;
}

.card-body {
    padding: 20px;
}

.thumb,
.detail-image,
.viewer-preview,
#protected-canvas {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    background: linear-gradient(135deg, #d2c1ae, #f7eee3);
}

.preview-toggle {
    cursor: pointer;
}

.preview-hint {
    color: var(--muted);
    font-size: 0.92rem;
}

.detail-image,
.viewer-preview,
#protected-canvas {
    border-radius: 20px;
}

.flash-stack {
    display: grid;
    gap: 10px;
}

.flash {
    padding: 14px 18px;
    border-radius: 18px;
    border: 1px solid var(--line);
}

.flash-success {
    background: rgba(37, 109, 74, 0.14);
}

.flash-danger {
    background: rgba(143, 36, 53, 0.12);
}

.flash-warning {
    background: rgba(168, 107, 7, 0.12);
}

.flash-info {
    background: rgba(184, 76, 43, 0.1);
}

.field-error {
    margin: -8px 0 12px;
    color: var(--danger);
}

.meta-list {
    flex-direction: column;
    gap: 4px;
}

.code {
    font-family: "IBM Plex Mono", monospace;
    word-break: break-all;
}

.generated-codes {
    margin: 24px 0;
    padding: 20px;
    border-radius: 20px;
    background: rgba(184, 76, 43, 0.08);
}

.code-list {
    padding-left: 18px;
}

.code-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.viewer-shell {
    display: grid;
    place-items: center;
}

.viewer-panel {
    width: min(980px, 100%);
}

.viewer-stage {
    position: relative;
    overflow: hidden;
    border-radius: 24px;
    margin: 24px 0;
    border: 1px solid var(--line);
    background: #1f1714;
}

.viewer-stage.compact {
    margin: 0;
    border-radius: 0;
}

.viewer-stage[data-fullscreen-ready="true"],
.viewer-stage canvas[data-fullscreen-trigger] {
    cursor: zoom-in;
}

.viewer-stage:fullscreen {
    display: grid;
    place-items: center;
    width: 100vw;
    height: 100vh;
    margin: 0;
    padding: 24px;
    border-radius: 0;
    background: rgba(16, 10, 8, 0.98);
}

.viewer-stage:fullscreen canvas {
    max-width: 100%;
    max-height: calc(100vh - 96px);
    width: auto;
    height: auto;
    aspect-ratio: auto;
    object-fit: contain;
}

.viewer-stage:fullscreen .viewer-overlay {
    position: absolute;
    left: 24px;
    right: 24px;
    bottom: 24px;
}

.viewer-stage.locked::after {
    content: "";
    position: absolute;
    inset: 0;
    backdrop-filter: blur(6px);
    pointer-events: none;
}

.viewer-overlay {
    position: absolute;
    inset: auto 18px 18px 18px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(32, 24, 21, 0.7);
    color: #fff;
    font-size: 0.9rem;
}

.unlock-form {
    max-width: 420px;
}

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

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    text-align: left;
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
}

.inline-form {
    display: inline;
}

.site-footer {
    padding-top: 20px;
    color: var(--muted);
    font-size: 0.9rem;
}

@media (max-width: 860px) {
    .hero,
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .site-header,
    .section-header,
    .actions,
    .hero-actions,
    .quick-field {
        flex-direction: column;
        align-items: stretch;
    }

    .site-header {
        border-radius: 28px;
    }

    .viewer-overlay {
        position: static;
        border-radius: 0;
    }
}
