:root {
    --bg: #f1eee8;
    --bg-accent: #d9eee2;
    --card: #fffefb;
    --text: #20201d;
    --muted: #58584f;
    --line: #d8d6cf;
    --primary: #0e6b4f;
    --primary-strong: #084937;
    --danger: #9f2f2f;
    --warning: #8b5a00;
    --success: #1b6b28;
    --shadow: 0 12px 34px rgba(32, 32, 29, 0.08);
    --radius: 14px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Avenir Next", "Futura", "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--bg);
}

.page-bg {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(1200px 600px at 20% -10%, var(--bg-accent), transparent 60%),
        linear-gradient(180deg, #fdfcf9 0%, var(--bg) 80%);
    z-index: -1;
}

.app-shell {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 18px 48px;
}

.topbar h1 {
    margin: 0;
    font-size: clamp(1.8rem, 3vw, 2.6rem);
}

.topbar p {
    margin-top: 8px;
    color: var(--muted);
}

.stack {
    display: grid;
    gap: 16px;
}

.stack-sm {
    display: grid;
    gap: 12px;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
}

.card h2 {
    margin-top: 0;
}

.card-error {
    border-color: #efb7b7;
    background: #fff4f4;
}

.card-warning {
    border-color: #f0dca8;
    background: #fff8e7;
}

.grid-2,
.grid-3 {
    display: grid;
    gap: 12px;
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

label {
    display: grid;
    gap: 6px;
    font-size: 0.95rem;
}

input,
select,
button {
    font: inherit;
}

input[type="text"],
input[type="number"],
select,
input[type="file"] {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #ffffff;
    padding: 9px 10px;
}

input[type="range"] {
    width: 100%;
}

.inline-options,
.inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}

.inline-actions button {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 12px;
    background: #f7f7f3;
    cursor: pointer;
}

.layout-head {
    margin: 14px 0 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.layout-head h3 {
    margin: 0;
    font-size: 1.04rem;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.inline-copy {
    white-space: nowrap;
}

.preview-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.preview-canvas {
    position: relative;
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}

.preview-canvas.square {
    aspect-ratio: 1 / 1;
}

.preview-canvas.wide {
    aspect-ratio: 2 / 1;
}

.preview-control {
    margin-top: 10px;
}

.preview-control-title {
    display: inline-block;
    margin-bottom: 6px;
    white-space: nowrap;
}

.preview-bg,
.preview-overlay,
.preview-safe,
.preview-center-x,
.preview-center-y,
.preview-logo,
.preview-logo-box {
    position: absolute;
    inset: 0;
}

.preview-bg {
    background-size: cover;
    background-position: center;
}

.preview-overlay {
    pointer-events: none;
}

.preview-safe {
    border: 1px dashed rgba(14, 107, 79, 0.5);
    pointer-events: none;
}

.preview-center-x,
.preview-center-y {
    pointer-events: none;
}

.preview-center-x {
    left: 50%;
    top: 0;
    bottom: 0;
    width: 0;
    border-left: 1px dotted rgba(18, 50, 40, 0.55);
}

.preview-center-y {
    top: 50%;
    left: 0;
    right: 0;
    height: 0;
    border-top: 1px dotted rgba(18, 50, 40, 0.55);
}

.preview-logo {
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
    object-fit: contain;
    inset: auto;
}

.preview-logo-box {
    border: 1px solid rgba(23, 36, 82, 0.55);
    background: rgba(42, 78, 138, 0.08);
    pointer-events: none;
}

.asset-group {
    margin-top: 16px;
}

.asset-list {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.asset-item {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px;
    display: grid;
    gap: 4px;
    background: #fff;
}

.asset-item input {
    justify-self: start;
}

.asset-title {
    font-weight: 700;
}

.asset-meta,
.asset-description,
.hint,
.mono {
    color: var(--muted);
}

#preview-status {
    min-height: 1.2em;
}

.hidden-until-logo[hidden] {
    display: none !important;
}

.toggle-button {
    margin: 4px 0 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 12px;
    background: #f7f7f3;
    cursor: pointer;
}

.primary,
.primary-link {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 999px;
    padding: 12px 18px;
    text-decoration: none;
    cursor: pointer;
}

.primary:hover,
.primary-link:hover {
    background: var(--primary-strong);
}

.primary:disabled {
    opacity: 0.65;
    cursor: wait;
}

.success {
    color: var(--success);
    font-weight: 700;
}

.warn {
    color: var(--warning);
    font-weight: 700;
}

.result-list {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.result-item {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px;
}

.back-link {
    margin-top: 18px;
}

.hidden {
    display: none !important;
}

@media (max-width: 700px) {
    .app-shell {
        padding: 14px 12px 34px;
    }

    .card {
        padding: 14px;
    }
}
