:root {
    --bg: #f4efe7;
    --bg-strong: #ede6db;
    --surface: rgba(255, 251, 246, 0.88);
    --surface-strong: #fffdf8;
    --surface-alt: #f7f1e7;
    --stroke: rgba(37, 34, 29, 0.12);
    --stroke-strong: rgba(37, 34, 29, 0.2);
    --text: #171612;
    --muted: #6e675f;
    --accent: #b9894c;
    --accent-strong: #7c5530;
    --success: #2f7a4b;
    --danger: #a33b33;
    --shadow: 0 24px 80px rgba(29, 26, 21, 0.08);
    --shadow-soft: 0 18px 45px rgba(29, 26, 21, 0.06);
    --radius-xl: 32px;
    --radius-lg: 24px;
    --radius-md: 18px;
    --radius-sm: 14px;
    --container: 1320px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: "Aptos", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.88), transparent 28%),
        radial-gradient(circle at 90% 0%, rgba(185, 137, 76, 0.14), transparent 22%),
        linear-gradient(135deg, #f7f3ec 0%, #f1e9dd 46%, #ebe2d4 100%);
}

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

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

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

.page-shell {
    width: min(var(--container), calc(100% - 28px));
    margin: 0 auto;
    padding: 22px 0 72px;
}

.noscript-banner {
    padding: 12px 18px;
    text-align: center;
    background: #fff4dd;
    color: #5d441f;
    border-bottom: 1px solid rgba(93, 68, 31, 0.16);
}

.topbar,
.hero-card,
.tool-nav,
.gallery-card,
.stage-shell,
.controls-panel .card,
.feature-card,
.faq-card,
.footer {
    background: var(--surface);
    backdrop-filter: blur(18px);
    border: 1px solid var(--stroke);
    box-shadow: var(--shadow-soft);
}

.topbar {
    position: sticky;
    top: 18px;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 14px 18px;
    border-radius: 999px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
}

.brand-badge {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: linear-gradient(145deg, #181612 0%, #3c342c 100%);
    color: #fefaf3;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.brand-copy {
    display: grid;
    gap: 2px;
}

.brand-copy strong,
.hero h1,
.hero-card h2,
.section-heading h2,
.stage-toolbar h3,
.panel-header h3,
.feature-card h3,
.faq-card h3,
.gallery-header h3,
.footer strong {
    font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", "Times New Roman", serif;
    letter-spacing: -0.03em;
}

.brand-copy span {
    color: var(--muted);
    font-size: 0.9rem;
}

.topnav {
    display: inline-flex;
    align-items: center;
    gap: 20px;
}

.topbar-right,
.topbar-support {
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar-right {
    margin-left: auto;
}

.topbar-support {
    padding-left: 14px;
    border-left: 1px solid rgba(37, 34, 29, 0.1);
}

.support-copy {
    margin: 0;
    max-width: 26ch;
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.45;
}

.support-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid rgba(37, 34, 29, 0.12);
    font-size: 0.9rem;
    font-weight: 700;
    white-space: nowrap;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

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

.coffee-link {
    background: var(--surface-alt);
    color: var(--text);
}

.linktree-link {
    background: linear-gradient(145deg, #1b1714 0%, #43382e 100%);
    color: #fffaf3;
}

.topnav a {
    color: var(--muted);
    font-size: 0.95rem;
    transition: color 0.2s ease;
}

.topnav a:hover {
    color: var(--text);
}

.hero {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 22px;
    align-items: stretch;
    padding: 34px 0 18px;
}

.hero-copy,
.hero-card {
    border-radius: var(--radius-xl);
    padding: 34px;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--accent-strong);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.hero h1 {
    margin: 0;
    max-width: 12ch;
    font-size: clamp(3rem, 6vw, 5.1rem);
    line-height: 0.94;
}

.lead,
.section-heading p,
.hero-card p,
.feature-card p,
.faq-card p,
.footer p,
.stage-meta,
.field-note,
.action-note {
    color: var(--muted);
    line-height: 1.65;
}

.lead {
    max-width: 62ch;
    margin: 22px 0 0;
    font-size: 1.02rem;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 28px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0 18px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-weight: 600;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

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

.button.primary {
    background: linear-gradient(145deg, #1b1714 0%, #43382e 100%);
    color: #fffaf3;
}

.button.dark {
    background: linear-gradient(145deg, #2d2823 0%, #4b4239 100%);
    color: #fffaf3;
}

.button.ghost,
.button.subtle,
.chip-button {
    background: var(--surface-alt);
    color: var(--text);
    border-color: var(--stroke);
}

.button.full-width {
    width: 100%;
}

.trust-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 0;
    margin: 26px 0 0;
    list-style: none;
}

.trust-row li {
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid var(--stroke);
    color: var(--muted);
    font-size: 0.92rem;
}

.hero-card {
    display: grid;
    gap: 22px;
}

.hero-card-header h2 {
    margin: 0;
    font-size: clamp(1.9rem, 3vw, 2.8rem);
}

.hero-feature-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.hero-feature-grid article,
.stat-card,
.selection-info {
    padding: 16px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(37, 34, 29, 0.08);
}

.hero-feature-grid span,
.stat-card span,
.selection-info span {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
    margin-bottom: 6px;
}

.hero-feature-grid strong,
.stat-card strong,
.selection-info strong,
.gallery-thumb strong {
    font-size: 0.98rem;
    line-height: 1.4;
}

.studio-section,
.feature-section,
.faq-section {
    padding-top: 22px;
}

.section-heading {
    max-width: 60ch;
    margin-bottom: 20px;
}

.section-heading h2 {
    margin: 0;
    font-size: clamp(2rem, 3vw, 3rem);
}

.studio-shell {
    display: grid;
    grid-template-columns: 270px 1fr;
    gap: 18px;
}

.tool-nav,
.studio-content {
    border-radius: var(--radius-xl);
}

.tool-nav {
    padding: 16px;
    display: grid;
    gap: 10px;
    align-self: start;
}

.tool-button {
    width: 100%;
    text-align: left;
    padding: 15px 16px;
    border-radius: 20px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text);
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.tool-button span {
    display: block;
    font-weight: 700;
    margin-bottom: 4px;
}

.tool-button small {
    display: block;
    color: var(--muted);
    line-height: 1.45;
}

.tool-button.active {
    background: linear-gradient(145deg, #1b1714 0%, #45392d 100%);
    border-color: rgba(255, 255, 255, 0.12);
    color: #fffaf3;
}

.tool-button.active small {
    color: rgba(255, 250, 243, 0.72);
}

.studio-content {
    display: grid;
    gap: 18px;
}

.upload-area,
.gallery-card,
.stage-shell,
.controls-panel {
    border-radius: var(--radius-xl);
}

.upload-area {
    position: relative;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 28px;
    background: rgba(255, 255, 255, 0.72);
    border: 1.5px dashed rgba(53, 46, 37, 0.18);
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.upload-area:hover,
.upload-area:focus-visible,
.upload-area.dragover {
    background: rgba(255, 255, 255, 0.9);
    border-color: var(--accent);
    transform: translateY(-1px);
    outline: none;
}

.upload-icon {
    flex: 0 0 auto;
    width: 62px;
    height: 62px;
    display: grid;
    place-items: center;
    border-radius: 20px;
    background: linear-gradient(145deg, rgba(185, 137, 76, 0.18), rgba(255, 255, 255, 0.84));
    font-size: 2rem;
    color: var(--accent-strong);
}

.upload-copy {
    display: grid;
    gap: 4px;
}

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

.upload-area input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
}

.gallery-card,
.stage-shell,
.controls-panel {
    padding: 18px;
}

.gallery-header,
.stage-toolbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.gallery-actions,
.chip-row,
.action-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.gallery-strip {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 2px;
}

.gallery-thumb {
    position: relative;
    min-width: 150px;
    max-width: 150px;
    padding: 10px;
    border-radius: 20px;
    border: 1px solid rgba(37, 34, 29, 0.1);
    background: rgba(255, 255, 255, 0.86);
    transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.gallery-thumb.active {
    border-color: rgba(185, 137, 76, 0.6);
    box-shadow: 0 12px 24px rgba(72, 52, 28, 0.08);
}

.gallery-thumb button.thumb-select {
    display: block;
    width: 100%;
    border: 0;
    padding: 0;
    background: transparent;
    text-align: left;
}

.gallery-thumb button.thumb-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 999px;
    background: rgba(23, 22, 18, 0.82);
    color: #fffaf3;
}

.gallery-thumb img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 14px;
}

.gallery-thumb strong {
    display: block;
    margin-top: 10px;
}

.gallery-thumb span {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.82rem;
}

.workspace-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.28fr) minmax(330px, 390px);
    gap: 18px;
}

.stage-shell {
    background: var(--surface);
}

.stage {
    position: relative;
    min-height: 580px;
    padding: 18px;
    display: grid;
    place-items: center;
    border-radius: 28px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.8), rgba(244, 238, 228, 0.8)),
        repeating-linear-gradient(45deg, rgba(37, 34, 29, 0.018) 0, rgba(37, 34, 29, 0.018) 10px, transparent 10px, transparent 20px);
    border: 1px solid rgba(37, 34, 29, 0.08);
    overflow: hidden;
}

.stage.selection-mode canvas {
    cursor: crosshair;
}

#previewCanvas {
    display: none;
    max-width: 100%;
    max-height: 540px;
    width: auto;
    height: auto;
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(26, 22, 16, 0.14);
    background: #fff;
}

.stage-placeholder {
    display: grid;
    gap: 6px;
    text-align: center;
    color: var(--muted);
}

.stage-placeholder strong {
    color: var(--text);
    font-size: 1.1rem;
}

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

.controls-panel {
    display: grid;
    align-content: start;
    gap: 14px;
    background: var(--surface);
}

.card {
    border-radius: 24px;
    padding: 18px;
}

.tool-panel {
    display: none;
}

.tool-panel.active {
    display: block;
}

.field,
.split-fields {
    display: grid;
    gap: 10px;
}

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

.split-fields-balanced {
    align-items: end;
}

.split-fields-balanced .field {
    grid-template-rows: auto minmax(56px, auto);
}

.split-fields-balanced select {
    min-height: 56px;
    height: 56px;
}

.split-fields > .field + .field {
    margin-top: 0;
}

.field + .field,
.chip-row + .field,
.field + .chip-row,
.selection-info + .button,
.selection-info + .chip-row {
    margin-top: 14px;
}

.controls-panel label {
    font-weight: 600;
    font-size: 0.95rem;
}

.range-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.controls-panel input[type="number"],
.controls-panel input[type="text"],
.controls-panel input[type="color"],
.controls-panel input[type="file"],
.controls-panel select {
    width: 100%;
    min-height: 48px;
    padding: 0 14px;
    border-radius: 14px;
    border: 1px solid rgba(37, 34, 29, 0.12);
    background: rgba(255, 255, 255, 0.82);
    color: var(--text);
}

.controls-panel input[type="file"] {
    padding: 12px 14px;
}

.controls-panel input[type="color"] {
    display: block;
    min-height: 56px;
    height: 56px;
    padding: 6px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}

.controls-panel input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.controls-panel input[type="color"]::-webkit-color-swatch {
    border: 1px solid rgba(37, 34, 29, 0.12);
    border-radius: 10px;
}

.controls-panel input[type="color"]::-moz-color-swatch {
    border: 1px solid rgba(37, 34, 29, 0.12);
    border-radius: 10px;
}

.controls-panel input[type="range"] {
    width: 100%;
    height: 18px;
    margin: 0;
    padding: 0;
    border-radius: 999px;
    background: transparent;
    appearance: none;
    -webkit-appearance: none;
    outline: none;
}

.controls-panel input[type="range"]::-webkit-slider-runnable-track {
    height: 5px;
    border-radius: 999px;
    background: rgba(37, 34, 29, 0.12);
}

.controls-panel input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 0;
    background: linear-gradient(145deg, #1b1714 0%, #513f32 100%);
    margin-top: -6.5px;
}

.controls-panel input[type="range"]::-moz-range-track {
    height: 5px;
    border-radius: 999px;
    background: rgba(37, 34, 29, 0.12);
}

.controls-panel input[type="range"]::-moz-range-progress {
    height: 5px;
    border-radius: 999px;
    background: rgba(37, 34, 29, 0.12);
}

.controls-panel input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 0;
    background: linear-gradient(145deg, #1b1714 0%, #513f32 100%);
}

.checkbox-row {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
}

.checkbox-row input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-strong);
}

.chip-button {
    min-height: 42px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid rgba(37, 34, 29, 0.12);
}

.chip-button.is-active {
    background: linear-gradient(145deg, #1b1714 0%, #45392d 100%);
    color: #fffaf3;
}

.field-note,
.action-note {
    margin: 0;
    font-size: 0.92rem;
}

.export-card {
    display: grid;
    gap: 12px;
}

.action-stack {
    display: grid;
}

.message {
    display: none;
    padding: 14px 16px;
    border-radius: 18px;
    font-weight: 600;
}

.message.is-visible {
    display: block;
}

.message.success {
    background: rgba(47, 122, 75, 0.12);
    color: var(--success);
    border: 1px solid rgba(47, 122, 75, 0.18);
}

.message.error {
    background: rgba(163, 59, 51, 0.12);
    color: var(--danger);
    border: 1px solid rgba(163, 59, 51, 0.18);
}

.feature-grid,
.faq-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.feature-card,
.faq-card {
    border-radius: var(--radius-xl);
    padding: 24px;
}

.feature-card h3,
.faq-card h3 {
    margin: 0 0 10px;
    font-size: 1.35rem;
}

.footer {
    margin-top: 22px;
    padding: 20px 24px;
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.footer a {
    color: var(--accent-strong);
    font-weight: 700;
}

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

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

    .tool-nav {
        grid-auto-flow: column;
        grid-auto-columns: minmax(210px, 1fr);
        overflow-x: auto;
    }
}

@media (max-width: 860px) {
    .page-shell {
        width: min(var(--container), calc(100% - 18px));
        padding-top: 14px;
    }

    .topbar,
    .gallery-header,
    .stage-toolbar,
    .footer,
    .hero-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .topnav {
        justify-content: space-between;
    }

    .topbar-right,
    .topbar-support {
        width: 100%;
        flex-wrap: wrap;
    }

    .topbar-support {
        padding-left: 0;
        border-left: 0;
        padding-top: 2px;
    }

    .support-copy {
        max-width: none;
    }

    .hero-copy,
    .hero-card,
    .tool-nav,
    .gallery-card,
    .stage-shell,
    .controls-panel,
    .feature-card,
    .faq-card,
    .footer {
        padding: 20px;
    }

    .hero-feature-grid,
    .stats-grid,
    .split-fields {
        grid-template-columns: 1fr;
    }

    .stage {
        min-height: 360px;
    }
}

@media (max-width: 560px) {
    .topbar {
        border-radius: 28px;
    }

    .topnav {
        gap: 12px;
        font-size: 0.92rem;
    }

    .support-link {
        width: 100%;
    }

    .upload-area {
        flex-direction: column;
        align-items: flex-start;
    }

    .gallery-thumb {
        min-width: 130px;
        max-width: 130px;
    }
}
