:root {
    color-scheme: light;
    --shell-bg: #f5efe6;
    --shell-bg-strong: #efe4d3;
    --shell-panel: rgba(255, 252, 247, 0.82);
    --shell-panel-strong: #fffaf3;
    --shell-line: rgba(103, 75, 37, 0.14);
    --shell-ink: #24180b;
    --shell-muted: #6e5b43;
    --shell-accent: #b46a2d;
    --shell-accent-soft: rgba(180, 106, 45, 0.12);
    --shell-shadow: 0 24px 60px rgba(72, 48, 18, 0.14);
    --radius-xl: 24px;
    --radius-2xl: 32px;
    --topbar-height: 86px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background:
        radial-gradient(circle at top left, rgba(255, 224, 191, 0.8), transparent 26%),
        radial-gradient(circle at top right, rgba(197, 227, 255, 0.55), transparent 28%),
        linear-gradient(180deg, #fcf8f1 0%, #f5efe6 45%, #f0e7db 100%);
    color: var(--shell-ink);
    font-family: "Space Grotesk", sans-serif;
}

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

button {
    cursor: pointer;
}

a {
    color: inherit;
}

.app-shell {
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 2fr) auto;
    gap: 18px;
    align-items: center;
    padding: 18px 24px;
    min-height: var(--topbar-height);
    background: rgba(250, 244, 236, 0.84);
    backdrop-filter: blur(18px);
    border-bottom: 1px solid rgba(103, 75, 37, 0.12);
}

.brand-lockup {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-badge {
    width: 48px;
    height: 48px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: linear-gradient(145deg, #1e3a5f, #c57236);
    color: white;
    font-size: 20px;
    font-weight: 700;
    box-shadow: var(--shell-shadow);
}

.brand-copy h1 {
    margin: 0;
    font-family: "Fraunces", serif;
    font-size: 1.3rem;
    letter-spacing: -0.03em;
}

.brand-copy p {
    margin: 4px 0 0;
    color: var(--shell-muted);
    font-size: 0.92rem;
}

.topbar-cluster {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.template-strip {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 6px;
    scrollbar-width: none;
}

.template-strip::-webkit-scrollbar {
    display: none;
}

.template-pill {
    min-width: 156px;
    padding: 12px 14px;
    border-radius: 20px;
    border: 1px solid var(--shell-line);
    background: rgba(255, 252, 247, 0.72);
    box-shadow: 0 14px 30px rgba(53, 33, 10, 0.06);
    text-align: left;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.template-pill:hover {
    transform: translateY(-1px);
    border-color: rgba(180, 106, 45, 0.34);
}

.template-pill.is-active {
    background: linear-gradient(180deg, rgba(255, 248, 239, 0.98), rgba(255, 237, 214, 0.98));
    border-color: rgba(180, 106, 45, 0.45);
}

.template-pill strong {
    display: block;
    margin-bottom: 5px;
    font-size: 0.95rem;
}

.template-pill span {
    color: var(--shell-muted);
    font-size: 0.78rem;
}

.template-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    margin-right: 8px;
    vertical-align: middle;
}

.device-toggle,
.action-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.segmented {
    display: inline-flex;
    padding: 4px;
    gap: 4px;
    border-radius: 999px;
    background: rgba(255, 252, 247, 0.75);
    border: 1px solid var(--shell-line);
}

.segmented button,
.shell-btn,
.ghost-btn {
    border: 0;
    border-radius: 999px;
    transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.segmented button {
    padding: 10px 14px;
    color: var(--shell-muted);
    background: transparent;
}

.segmented button.is-active {
    background: var(--shell-ink);
    color: white;
}

.segmented button:hover,
.shell-btn:hover,
.ghost-btn:hover {
    transform: translateY(-1px);
}

.shell-btn,
.ghost-btn {
    padding: 11px 16px;
}

.shell-btn {
    background: var(--shell-ink);
    color: white;
}

.ghost-btn {
    background: rgba(255, 252, 247, 0.78);
    color: var(--shell-ink);
    border: 1px solid var(--shell-line);
}

.workspace {
    display: grid;
    grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
    gap: 20px;
    padding: 20px 24px 28px;
}

.inspector {
    min-width: 0;
}

.panel-stack {
    display: grid;
    gap: 18px;
}

.panel {
    background: var(--shell-panel);
    border: 1px solid var(--shell-line);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shell-shadow);
    backdrop-filter: blur(18px);
    overflow: hidden;
}

.panel-head {
    padding: 18px 20px 0;
}

.panel-head h2,
.panel-head h3 {
    margin: 0;
    font-family: "Fraunces", serif;
    font-size: 1.08rem;
    letter-spacing: -0.02em;
}

.panel-head p {
    margin: 6px 0 0;
    color: var(--shell-muted);
    font-size: 0.88rem;
    line-height: 1.45;
}

.panel-body {
    padding: 18px 20px 20px;
}

.grid-fields {
    display: grid;
    gap: 14px;
}

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

.field {
    display: grid;
    gap: 8px;
}

.field label {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--shell-muted);
    letter-spacing: 0.01em;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid rgba(103, 75, 37, 0.16);
    background: rgba(255, 252, 247, 0.94);
    color: var(--shell-ink);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: 2px solid rgba(180, 106, 45, 0.22);
    border-color: rgba(180, 106, 45, 0.42);
}

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

.field small {
    color: var(--shell-muted);
    font-size: 0.75rem;
    line-height: 1.45;
}

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

.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 999px;
    border: 1px solid rgba(103, 75, 37, 0.13);
    background: rgba(255, 252, 247, 0.84);
    font-size: 0.8rem;
    color: var(--shell-muted);
}

.switch-row {
    display: grid;
    gap: 10px;
}

.switch {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    padding: 14px 16px;
    border-radius: 18px;
    background: rgba(255, 252, 247, 0.88);
    border: 1px solid rgba(103, 75, 37, 0.1);
}

.switch strong {
    display: block;
    font-size: 0.9rem;
}

.switch span {
    display: block;
    color: var(--shell-muted);
    font-size: 0.77rem;
    margin-top: 2px;
}

.switch input {
    width: 18px;
    height: 18px;
}

.repeater {
    display: grid;
    gap: 14px;
}

.repeater-card {
    padding: 16px;
    border-radius: 24px;
    background: rgba(255, 252, 247, 0.88);
    border: 1px solid rgba(103, 75, 37, 0.12);
    display: grid;
    gap: 14px;
}

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

.repeater-card__head strong {
    font-size: 0.94rem;
}

.mini-actions {
    display: inline-flex;
    gap: 8px;
}

.mini-btn {
    border: 1px solid rgba(103, 75, 37, 0.13);
    background: white;
    color: var(--shell-muted);
    padding: 8px 10px;
    border-radius: 999px;
}

.mini-btn:hover {
    color: var(--shell-ink);
    border-color: rgba(180, 106, 45, 0.34);
}

.section-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(103, 75, 37, 0.16), transparent);
    margin: 4px 0;
}

.preview-stage {
    min-width: 0;
}

.preview-shell {
    position: sticky;
    top: calc(var(--topbar-height) + 18px);
    background: linear-gradient(180deg, rgba(44, 29, 10, 0.95), rgba(15, 13, 14, 0.92));
    border-radius: 34px;
    padding: 18px;
    border: 1px solid rgba(31, 20, 7, 0.32);
    box-shadow: 0 36px 90px rgba(26, 17, 10, 0.28);
}

.preview-meta {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    margin-bottom: 16px;
    color: rgba(255, 246, 233, 0.9);
}

.preview-meta strong {
    display: block;
    font-size: 0.98rem;
}

.preview-meta span {
    display: block;
    margin-top: 4px;
    color: rgba(255, 246, 233, 0.62);
    font-size: 0.82rem;
}

.preview-window {
    border-radius: 28px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: #f7f2ea;
}

.preview-frame-wrap {
    margin: 0 auto;
    width: 100%;
    transition: width 0.24s ease;
}

.preview-frame-wrap[data-device="desktop"] {
    width: 100%;
}

.preview-frame-wrap[data-device="tablet"] {
    width: 860px;
    max-width: 100%;
}

.preview-frame-wrap[data-device="mobile"] {
    width: 410px;
    max-width: 100%;
}

.preview-frame {
    width: 100%;
    height: calc(100vh - 190px);
    border: 0;
    background: white;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    font-size: 0.78rem;
    color: rgba(255, 246, 233, 0.74);
}

.status-pill::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #7dd3a9;
    box-shadow: 0 0 0 6px rgba(125, 211, 169, 0.12);
}

.muted-note {
    color: var(--shell-muted);
    font-size: 0.8rem;
    line-height: 1.5;
}

.empty-inline {
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(255, 252, 247, 0.78);
    border: 1px dashed rgba(103, 75, 37, 0.16);
    color: var(--shell-muted);
    font-size: 0.8rem;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 1180px) {
    .topbar {
        grid-template-columns: 1fr;
        justify-items: stretch;
    }

    .action-row,
    .device-toggle {
        justify-content: flex-start;
    }

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

    .preview-shell {
        position: relative;
        top: 0;
    }
}

@media (max-width: 760px) {
    .topbar,
    .workspace {
        padding-left: 14px;
        padding-right: 14px;
    }

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

    .template-pill {
        min-width: 138px;
    }

    .preview-frame {
        height: 72vh;
    }
}
