html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    overflow: hidden;
    background:
        radial-gradient(circle at top left, rgba(211, 122, 68, 0.16), transparent 32%),
        radial-gradient(circle at bottom right, rgba(22, 111, 125, 0.18), transparent 30%),
        linear-gradient(135deg, #f2eadc 0%, #e7ddd0 40%, #d7cdbf 100%);
    color: #1f2a2e;
    font-family: Georgia, 'Palatino Linotype', 'Book Antiqua', serif;
}

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

.studio-skip-link {
    position: absolute;
    left: 0.8rem;
    top: 0.5rem;
    transform: translateY(-140%);
    padding: 0.55rem 0.8rem;
    background: #0b4d45;
    color: #fff;
    border-radius: 8px;
    z-index: 1000;
    text-decoration: none;
}

.studio-skip-link:focus {
    transform: translateY(0);
}

#studio-app {
    --studio-ink: #1f2a2e;
    --studio-muted: #5f6a68;
    --studio-line: rgba(31, 42, 46, 0.14);
    --studio-panel: rgba(255, 250, 242, 0.9);
    --studio-panel-strong: rgba(252, 247, 239, 0.96);
    --studio-panel-tint: rgba(226, 240, 236, 0.92);
    --studio-accent: #136f63;
    --studio-accent-strong: #0f5a51;
    --studio-accent-warm: #bb5d35;
    --studio-shadow: 0 18px 40px rgba(62, 48, 32, 0.12);
    --studio-gap: 1.25rem;
    --studio-focus: #0b4d45;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-height: 100vh;
    padding: var(--studio-gap);
    gap: var(--studio-gap);
    box-sizing: border-box;
}

.studio-header,
.pane-card {
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: var(--studio-shadow);
    backdrop-filter: blur(14px);
}

.studio-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.25rem;
    padding: 1rem 1.25rem;
    border-radius: 22px;
    background:
        linear-gradient(135deg, rgba(20, 79, 70, 0.94), rgba(18, 58, 73, 0.92)),
        linear-gradient(0deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.08));
    color: #f7f3ea;
    flex-shrink: 0;
}

.studio-brand {
    min-width: 0;
    flex: 1 1 360px;
}

.studio-eyebrow {
    margin: 0 0 0.3rem;
    font-size: 0.75rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    opacity: 0.74;
}

.studio-title-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.studio-title-row h1 {
    margin: 0;
    font-size: clamp(1.6rem, 2.6vw, 2.2rem);
    line-height: 1.05;
    font-weight: 700;
}

.studio-title-input {
    flex: 1 1 280px;
    min-width: 220px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 999px;
    padding: 0.7rem 1rem;
    background: rgba(255, 255, 255, 0.12);
    color: #fffaf0;
}

.studio-title-input::placeholder {
    color: rgba(255, 250, 240, 0.62);
}

.studio-header-controls {
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.85rem 1.1rem;
    flex: 1 1 340px;
    max-width: min(100%, 52rem);
}

.studio-header-cluster {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.4rem 0.55rem 0.55rem;
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.14);
    min-width: 0;
}

.studio-cluster-eyebrow {
    font-size: 0.62rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    opacity: 0.72;
    padding: 0 0.15rem;
}

.studio-cluster-buttons {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}

.studio-header-controls .studio-button-secondary {
    padding: 0.42rem 0.72rem;
    font-size: 0.8rem;
    border-radius: 999px;
    min-height: 2.35rem;
}

.studio-header-controls .studio-button-primary {
    padding: 0.48rem 0.95rem;
    font-size: 0.88rem;
    min-height: 2.45rem;
}

.studio-provider {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.8rem;
}

.studio-provider select {
    min-width: 138px;
    padding: 0.55rem 0.8rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.24);
    background: rgba(255, 255, 255, 0.12);
    color: #fffaf0;
}

.studio-main {
    display: grid;
    grid-template-columns: minmax(248px, 0.92fr) minmax(400px, 1.55fr) minmax(300px, 1fr);
    gap: var(--studio-gap);
    min-height: 0;
    flex: 1;
}

.studio-pane {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 0;
    min-width: 0;
}

.pane-card {
    position: relative;
    overflow: hidden;
    border-radius: 22px;
    background: var(--studio-panel);
}

.pane-card::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.26), transparent 18%),
        linear-gradient(90deg, rgba(255, 255, 255, 0.12), transparent 24%);
}

.pane-card > * {
    position: relative;
    z-index: 1;
}

.pane-card-accent {
    background:
        linear-gradient(135deg, rgba(19, 111, 99, 0.92), rgba(187, 93, 53, 0.88)),
        rgba(255, 250, 242, 0.96);
    color: #fff7ed;
}

.pane-scroll {
    overflow: auto;
}

.pane-chat {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.pane-preview {
    display: flex;
    flex-direction: column;
    min-height: 280px;
}

.section-shell {
    padding: 1rem 1.1rem;
}

.section-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}

.section-title-row h2,
.section-title-row h3,
.section-title-row h4 {
    margin: 0;
    font-size: 0.98rem;
    letter-spacing: 0.02em;
}

.section-meta {
    color: inherit;
    opacity: 0.78;
    font-size: 0.84rem;
}

.studio-button {
    border: 0;
    border-radius: 999px;
    padding: 0.7rem 1rem;
    cursor: pointer;
    min-height: 2.4rem;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

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

.studio-button-primary {
    background: linear-gradient(135deg, var(--studio-accent), var(--studio-accent-warm));
    color: #fff8f1;
    box-shadow: 0 10px 22px rgba(19, 111, 99, 0.24);
}

.studio-button-secondary {
    background: rgba(255, 255, 255, 0.68);
    color: var(--studio-ink);
    border: 1px solid var(--studio-line);
}

.studio-button-subtle {
    background: rgba(19, 111, 99, 0.08);
    color: var(--studio-accent-strong);
    border: 1px solid rgba(19, 111, 99, 0.14);
}

.studio-button-ghost {
    background: transparent;
    color: var(--studio-muted);
    border: 1px dashed rgba(31, 42, 46, 0.22);
}

.studio-button-danger {
    background: rgba(187, 93, 53, 0.12);
    color: #8d4122;
    border: 1px solid rgba(187, 93, 53, 0.18);
}

.studio-button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.overview-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.7rem;
}

.overview-stat {
    padding: 0.75rem;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.12);
}

.overview-stat strong {
    display: block;
    font-size: 1.5rem;
    line-height: 1;
    margin-bottom: 0.2rem;
}

.navigator-section {
    padding: 1rem 1.1rem;
    border-top: 1px solid var(--studio-line);
}

.navigator-section:first-child {
    border-top: 0;
}

.navigator-list {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.navigator-item,
.scene-pill,
.choice-card,
.scope-hint,
.timeline-card,
.preview-choice {
    border-radius: 16px;
    border: 1px solid var(--studio-line);
    background: rgba(255, 255, 255, 0.62);
}

.navigator-item {
    padding: 0.7rem 0.8rem;
    cursor: pointer;
}

.navigator-item:hover,
.scene-pill:hover {
    border-color: rgba(19, 111, 99, 0.28);
    background: rgba(226, 240, 236, 0.74);
}

.navigator-item.is-selected,
.scene-pill.is-selected {
    background: rgba(19, 111, 99, 0.14);
    border-color: rgba(19, 111, 99, 0.44);
}

.navigator-item strong,
.scene-pill strong {
    display: block;
    margin-bottom: 0.18rem;
}

.navigator-item span,
.scene-pill span,
.muted-copy,
.field-help {
    color: var(--studio-muted);
    font-size: 0.84rem;
}

.navigator-inline-actions,
.stack-row,
.inspector-actions,
.preview-toolbar,
.preview-choice-bar,
.choice-inline-actions,
.proposal-actions,
.composer-row,
.composer-footer-row,
.quick-intents {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.proposal-actions {
    align-items: center;
}

#studio-app .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;
}

#studio-app :focus {
    outline: none;
}

#studio-app :focus-visible {
    outline: 2px solid var(--studio-focus);
    outline-offset: 2px;
}

.chat-shell {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.chat-header {
    flex: 0 0 auto;
    padding: 0.85rem 1.15rem 0.75rem;
    border-bottom: 1px solid var(--studio-line);
}

.chat-header-title-row {
    align-items: flex-start;
}

.chat-title {
    margin: 0 0 0.25rem;
    font-size: clamp(1.15rem, 2vw, 1.45rem);
    line-height: 1.2;
}

.chat-subtitle {
    margin: 0;
    max-width: 42rem;
    line-height: 1.45;
}

.chat-history {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 0.85rem 1.15rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chat-empty {
    display: grid;
    gap: 0.85rem;
    align-content: start;
    min-height: 8rem;
    padding: 0.5rem 0 0.75rem;
}

.chat-empty-card {
    padding: 0.85rem 1rem;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.74);
    border: 1px solid rgba(31, 42, 46, 0.12);
}

.chat-empty-card h3 {
    margin: 0 0 0.4rem;
    font-size: 1rem;
}

.chat-empty-card .muted-copy {
    margin: 0;
    line-height: 1.45;
}

.chat-empty-card .muted-copy + .muted-copy {
    margin-top: 0.55rem;
}

.chat-message {
    display: flex;
    gap: 0.65rem;
    align-items: flex-start;
}

.chat-role {
    width: 3.1rem;
    flex-shrink: 0;
    padding-top: 0.28rem;
    font-size: 0.68rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--studio-muted);
}

.chat-bubble {
    flex: 1;
    min-width: 0;
    padding: 0.75rem 0.9rem;
    border-radius: 18px;
    border: 1px solid var(--studio-line);
    background: rgba(255, 255, 255, 0.74);
}

.chat-message.is-assistant .chat-bubble {
    background: rgba(226, 240, 236, 0.82);
}

.quick-intents-wrap {
    flex: 0 0 auto;
    border-top: 1px solid var(--studio-line);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.45), rgba(255, 250, 242, 0.25));
    padding: 0.5rem 0 0.55rem;
}

.intent-rail-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0 1rem 0.35rem;
}

.intent-rail-label {
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--studio-muted);
    font-weight: 600;
}

.intent-rail-hint {
    font-size: 0.68rem;
    color: var(--studio-muted);
    opacity: 0.85;
    white-space: nowrap;
}

.quick-intents {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.45rem;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.15rem 1rem 0.35rem;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(19, 111, 99, 0.35) transparent;
}

.quick-intents::-webkit-scrollbar {
    height: 6px;
}

.quick-intents::-webkit-scrollbar-thumb {
    background: rgba(19, 111, 99, 0.35);
    border-radius: 999px;
}

.intent-chip {
    flex: 0 0 auto;
    scroll-snap-align: start;
    white-space: nowrap;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    border: 1px solid rgba(19, 111, 99, 0.14);
    background: rgba(19, 111, 99, 0.08);
    color: var(--studio-accent-strong);
    cursor: pointer;
    font-size: 0.82rem;
}

.intent-chip.is-active {
    background: linear-gradient(135deg, rgba(19, 111, 99, 0.2), rgba(187, 93, 53, 0.14));
    border-color: rgba(19, 111, 99, 0.38);
    box-shadow: 0 0 0 1px rgba(19, 111, 99, 0.12);
}

.proposal-shell {
    flex: 0 1 auto;
    min-height: 0;
    max-height: min(34vh, 265px);
    overflow: auto;
    border-top: 1px solid var(--studio-line);
    padding: 0 1rem 0.75rem;
    scrollbar-width: thin;
}

.proposal-card {
    margin-top: 0.75rem;
    padding: 0.85rem 1rem;
    border-radius: 16px;
    background: rgba(255, 250, 242, 0.82);
    border: 1px solid rgba(187, 93, 53, 0.18);
}

.proposal-list {
    display: grid;
    gap: 0.65rem;
    margin-top: 0.65rem;
}

.proposal-item {
    padding: 0.75rem 0.85rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.76);
    border: 1px solid var(--studio-line);
}

.proposal-json-details {
    margin-top: 0.45rem;
    border-radius: 12px;
    border: 1px solid rgba(31, 42, 46, 0.1);
    background: rgba(255, 255, 255, 0.55);
}

.proposal-json-summary {
    cursor: pointer;
    padding: 0.45rem 0.65rem;
    font-size: 0.78rem;
    color: var(--studio-accent-strong);
    list-style: none;
}

.proposal-json-summary::-webkit-details-marker {
    display: none;
}

.proposal-json-pre {
    margin: 0;
    padding: 0.55rem 0.65rem 0.65rem;
    max-height: 9.5rem;
    overflow: auto;
    font-family: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
    font-size: 0.72rem;
    line-height: 1.35;
    white-space: pre-wrap;
    word-break: break-word;
    border-top: 1px solid var(--studio-line);
    background: rgba(31, 42, 46, 0.04);
}

.proposal-item code,
.preview-scene-meta code,
.json-chip {
    font-family: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
    font-size: 0.82rem;
}

.chat-composer {
    flex: 0 0 auto;
    border-top: 1px solid var(--studio-line);
    padding: 0.85rem 1.1rem 1rem;
    background: var(--studio-panel-strong);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.composer-scope-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.composer-scope-block {
    flex: 1 1 220px;
    max-width: 100%;
    min-width: 0;
}

.composer-scope-block .studio-select {
    max-width: 20rem;
}

.scope-hint-inline {
    margin: 0.4rem 0 0;
    padding: 0.55rem 0.65rem;
    font-size: 0.8rem;
    line-height: 1.35;
}

.composer-prompt-block {
    min-width: 0;
}

.studio-textarea-composer {
    min-height: 5.5rem;
    max-height: 40vh;
    resize: vertical;
}

.composer-footer-row {
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.composer-intent-readout {
    font-size: 0.84rem;
    color: var(--studio-muted);
    min-width: 0;
}

.composer-intent-readout strong {
    color: var(--studio-ink);
    font-weight: 650;
}

.studio-send-btn {
    flex-shrink: 0;
}

@media (max-width: 900px) {
    .intent-rail-hint {
        display: none;
    }
}

.composer-row {
    align-items: flex-start;
}

.composer-row textarea {
    min-height: 102px;
    flex: 1;
}

.studio-field,
.studio-select,
.studio-textarea {
    width: 100%;
    box-sizing: border-box;
    border-radius: 16px;
    border: 1px solid rgba(31, 42, 46, 0.14);
    background: rgba(255, 255, 255, 0.78);
    color: var(--studio-ink);
    padding: 0.72rem 0.85rem;
}

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

.studio-form-grid {
    display: grid;
    gap: 0.85rem;
}

.studio-form-grid.two-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-block label,
.form-block legend {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.82rem;
    letter-spacing: 0.03em;
    color: var(--studio-muted);
    text-transform: uppercase;
}

.form-block fieldset {
    margin: 0;
    padding: 0;
    border: 0;
}

.scope-hint {
    padding: 0.8rem 0.9rem;
}

.inspector-shell,
.preview-shell {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.inspector-header,
.preview-header {
    padding: 1rem 1.1rem 0.8rem;
    border-bottom: 1px solid var(--studio-line);
}

.inspector-body,
.preview-body {
    min-height: 0;
    overflow: auto;
    padding: 1rem 1.1rem 1.1rem;
}

.inspector-stack,
.choice-stack,
.preview-stack,
.timeline-stack {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.scene-pill {
    padding: 0.75rem 0.85rem;
}

.choice-card,
.timeline-card {
    padding: 0.85rem;
}

.choice-card-header,
.timeline-card-header {
    display: flex;
    justify-content: space-between;
    gap: 0.6rem;
    margin-bottom: 0.55rem;
}

.pill-row,
.preview-variable-row {
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.pill,
.preview-variable,
.tag {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.34rem 0.62rem;
    border-radius: 999px;
    background: rgba(19, 111, 99, 0.1);
    color: var(--studio-accent-strong);
    font-size: 0.78rem;
}

.preview-shell {
    height: 100%;
}

.preview-toolbar {
    align-items: center;
    justify-content: space-between;
}

.preview-scene {
    padding: 1.1rem;
    border-radius: 22px;
    background:
        linear-gradient(180deg, rgba(12, 49, 62, 0.9), rgba(31, 29, 39, 0.92)),
        linear-gradient(135deg, rgba(187, 93, 53, 0.18), transparent 40%);
    color: #f7f3ea;
}

.preview-scene h3 {
    margin: 0 0 0.35rem;
    font-size: 1.4rem;
}

.preview-scene-meta {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.8rem;
    color: rgba(247, 243, 234, 0.72);
}

.preview-scene p {
    margin: 0 0 0.95rem;
    line-height: 1.7;
}

.preview-dialogue {
    display: grid;
    gap: 0.55rem;
    margin: 0 0 1rem;
}

.preview-dialogue-line {
    padding: 0.7rem 0.8rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.08);
}

.preview-dialogue-line strong {
    display: block;
    margin-bottom: 0.25rem;
    color: #ffdfcf;
}

.preview-choice {
    padding: 0.8rem 0.85rem;
}

.preview-choice button {
    width: 100%;
}

.empty-panel {
    padding: 1.2rem;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.54);
    border: 1px dashed rgba(31, 42, 46, 0.18);
    color: var(--studio-muted);
}

.status-toast {
    position: fixed;
    right: 1.5rem;
    bottom: 1.5rem;
    max-width: 340px;
    padding: 0.85rem 1rem;
    border-radius: 18px;
    color: #fff9f2;
    background: rgba(20, 79, 70, 0.94);
    box-shadow: var(--studio-shadow);
    z-index: 20;
}

.status-toast.is-error {
    background: rgba(143, 61, 33, 0.94);
}

.status-toast.is-warning {
    background: rgba(163, 116, 23, 0.94);
}

.loading-label {
    color: var(--studio-accent-warm);
    font-size: 0.84rem;
}

.inline-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.preview-blocked {
    padding: 1rem;
    border-radius: 18px;
    background: rgba(187, 93, 53, 0.1);
    color: #8d4122;
}

.mono {
    font-family: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
}

@media (prefers-reduced-motion: reduce) {
    #studio-app *,
    #studio-app *::before,
    #studio-app *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

@media (max-width: 1180px) {
    body {
        overflow: auto;
    }

    #studio-app {
        max-height: none;
    }

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

    .studio-pane-left,
    .studio-pane-right {
        min-height: 320px;
    }

    .pane-chat {
        min-height: 680px;
    }
}

@media (max-width: 1360px) {
    .studio-header {
        gap: 0.9rem;
    }

    .studio-header-controls {
        flex: 1 1 100%;
        max-width: 100%;
        justify-content: flex-start;
        align-items: stretch;
        gap: 0.65rem 0.75rem;
    }

    .studio-provider {
        width: 9.8rem;
        flex: 0 0 auto;
    }

    .studio-header-cluster {
        flex: 1 1 300px;
    }
}

@media (max-width: 780px) {
    #studio-app {
        padding: 0.8rem;
    }

    .studio-header {
        border-radius: 18px;
        padding: 0.95rem;
        gap: 0.75rem;
    }

    .studio-header-controls {
        gap: 0.55rem;
    }

    .studio-header-cluster {
        width: 100%;
        padding: 0.35rem 0.45rem 0.45rem;
    }

    .studio-cluster-eyebrow {
        font-size: 0.58rem;
    }

    .pane-card {
        border-radius: 18px;
    }

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

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

    .status-toast {
        left: 0.8rem;
        right: 0.8rem;
        max-width: none;
    }

    .studio-button,
    .intent-chip {
        min-height: 2.75rem;
    }

    .chat-role {
        display: none;
    }

    .chat-bubble {
        border-radius: 14px;
    }
}
