:root {
    --bg: #0f1720;
    --panel: #172331;
    --panel-alt: #223245;
    --line: #33485f;
    --text: #ecf3f9;
    --muted: #9eb1c2;
    --accent: #7dd3fc;
    --accent-strong: #38bdf8;
    --danger: #f87171;
    --success: #34d399;
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.25);
    --radius: 16px;
    --transition-ms: 450ms;
    --font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
}

body {
    line-height: 1.4;
}

a {
    color: var(--accent);
}

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

.shell-display {
    overflow: hidden;
}

.display-root {
    position: relative;
    width: 100vw;
    height: 100vh;
    background: #050a0f;
}

.display-stage {
    position: absolute;
    inset: 0;
    overflow: hidden;
    background: #050a0f;
}

.display-frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    background: transparent;
    opacity: 0;
    transform: translateX(0);
    pointer-events: none;
}

.display-frame.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.display-frame.is-loading {
    opacity: 0;
}

.display-stage.transition-none .display-frame {
    transition: none;
}

.display-stage.transition-fade .display-frame {
    transition: opacity var(--transition-ms) ease;
}

.display-stage.transition-slide .display-frame {
    transition: opacity var(--transition-ms) ease, transform var(--transition-ms) ease;
}

.display-stage.transition-slide .display-frame.is-entering {
    transform: translateX(12%);
}

.display-stage.transition-slide .display-frame.is-leaving {
    transform: translateX(-12%);
}

.debug-overlay,
.display-status {
    position: absolute;
    z-index: 10;
}

.debug-overlay strong,
.display-status strong {
    display: block;
}

.debug-overlay {
    top: 20px;
    right: 20px;
    width: min(420px, calc(100vw - 32px));
    padding: 14px 16px;
    border-radius: 18px;
    background: rgba(10, 18, 28, 0.82);
    border: 1px solid rgba(125, 211, 252, 0.28);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
    color: var(--text);
}

.debug-overlay.is-hidden {
    display: none;
}

.debug-overlay.is-compact {
    width: min(280px, calc(100vw - 32px));
    padding: 12px 14px;
}

.debug-overlay.is-compact .debug-grid-full,
.debug-overlay.is-full .debug-grid-compact {
    display: none;
}

.debug-overlay-header {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

.debug-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 62px;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(125, 211, 252, 0.14);
    border: 1px solid rgba(125, 211, 252, 0.24);
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 700;
}

.debug-grid {
    display: grid;
    gap: 6px;
}

.debug-row {
    display: grid;
    grid-template-columns: 126px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    font-size: 0.88rem;
}

.debug-overlay.is-compact .debug-row {
    grid-template-columns: 74px minmax(0, 1fr);
    font-size: 0.82rem;
}

.debug-row span {
    color: var(--muted);
}

.debug-row strong {
    word-break: break-word;
    font-weight: 600;
}

.display-status {
    left: 24px;
    right: 24px;
    bottom: 24px;
    max-width: 440px;
    padding: 16px 18px;
    border-radius: var(--radius);
    background: rgba(10, 18, 28, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(8px);
}

.display-status.is-hidden,
.debug-overlay.is-hidden {
    display: none;
}

.display-empty {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 32px;
}

.empty-card {
    width: min(640px, 100%);
    padding: 32px;
    border-radius: 24px;
    background: linear-gradient(180deg, rgba(23, 35, 49, 0.96), rgba(12, 20, 29, 0.98));
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: var(--shadow);
}

.empty-card h1 {
    margin-top: 0;
}

.empty-card p {
    color: var(--muted);
}

.app-shell {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

.app-header {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: flex-start;
    margin-bottom: 24px;
}

.app-header h1,
.panel h2,
.panel h3 {
    margin-top: 0;
}

.app-subtitle {
    margin: 8px 0 0;
    color: var(--muted);
}

.panel-grid {
    display: grid;
    grid-template-columns: 1.1fr 1.4fr;
    gap: 20px;
}

.panel {
    background: linear-gradient(180deg, rgba(23, 35, 49, 0.96), rgba(15, 23, 32, 0.96));
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}

.stack {
    display: grid;
    gap: 20px;
}

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

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

.field.field-full {
    grid-column: 1 / -1;
}

.field label,
.legend {
    font-size: 0.95rem;
    font-weight: 600;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
}

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

.actions,
.toolbar,
.mode-row,
.screen-meta,
.header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.btn,
.btn-secondary,
.btn-danger,
.chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 999px;
    border: 1px solid transparent;
    padding: 10px 14px;
    cursor: pointer;
    text-decoration: none;
}

.btn {
    background: var(--accent-strong);
    color: #072033;
    font-weight: 700;
}

.btn-secondary {
    background: transparent;
    color: var(--text);
    border-color: var(--line);
}

.btn-danger {
    background: transparent;
    color: #ffd2d2;
    border-color: rgba(248, 113, 113, 0.5);
}

.chip {
    background: rgba(255, 255, 255, 0.05);
    color: var(--muted);
    padding: 7px 10px;
    cursor: default;
}

.chip.is-success {
    color: #bbf7d0;
    border-color: rgba(52, 211, 153, 0.35);
}

.chip.is-warning {
    color: #fde68a;
    border-color: rgba(251, 191, 36, 0.35);
}

.screen-list {
    display: grid;
    gap: 12px;
}

.screen-card {
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    padding: 14px;
}

.screen-card.is-disabled {
    opacity: 0.7;
}

.screen-card header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.screen-card h3 {
    margin: 0;
}

.screen-card p {
    margin: 6px 0 0;
    color: var(--muted);
    word-break: break-word;
}

.screen-meta {
    margin-top: 10px;
}

.cache-bust-panel {
    display: grid;
    gap: 12px;
    padding: 16px;
    border-radius: 14px;
    border: 1px solid rgba(125, 211, 252, 0.22);
    background: rgba(125, 211, 252, 0.06);
}

.cache-bust-copy h3 {
    margin: 0 0 6px;
}

.cache-bust-copy p {
    margin: 0;
}

.cache-bust-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.help-text,
.status-text {
    color: var(--muted);
    margin: 0;
}

.status-text.is-error {
    color: #fecaca;
}

.status-text.is-success {
    color: #bbf7d0;
}

.hidden {
    display: none !important;
}

@media (max-width: 900px) {
    .panel-grid {
        grid-template-columns: 1fr;
    }

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

    .app-header {
        flex-direction: column;
    }
}
