:root {
    color-scheme: light;
    --bg: #f6f7f9;
    --panel: #ffffff;
    --text: #14171f;
    --muted: #687083;
    --line: #dfe3ea;
    --accent: #1769e0;
    --accent-dark: #0f4faa;
    --danger: #b3261e;
    --ok: #137333;
    --shadow: 0 18px 50px rgba(27, 39, 68, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
    font: inherit;
}

.app-shell {
    width: min(1440px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0;
}

.topbar,
.preview-toolbar,
.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.topbar {
    margin-bottom: 22px;
}

.eyebrow {
    margin: 0 0 5px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: clamp(28px, 4vw, 48px);
    line-height: 1.02;
}

h2 {
    margin-bottom: 0;
    font-size: 19px;
}

.upload-panel {
    display: grid;
    place-items: center;
    min-height: 62vh;
}

.upload-box {
    width: min(680px, 100%);
    min-height: 260px;
    display: grid;
    place-items: center;
    gap: 18px;
    padding: 34px;
    border: 2px dashed #b9c2d2;
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
    text-align: center;
}

.upload-box input {
    width: min(420px, 100%);
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fafbfc;
}

.upload-copy {
    display: grid;
    gap: 6px;
    color: var(--muted);
}

.upload-copy strong {
    color: var(--text);
    font-size: 24px;
}

button,
.primary-button,
.ghost-button {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 8px;
    padding: 0 16px;
    background: var(--accent);
    color: #fff;
    font-weight: 750;
    text-decoration: none;
    cursor: pointer;
}

button:hover,
.primary-button:hover {
    background: var(--accent-dark);
}

button:disabled,
.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.ghost-button {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
}

.editor-layout {
    display: grid;
    grid-template-columns: minmax(320px, 430px) 1fr;
    gap: 18px;
    align-items: start;
}

.text-panel,
.preview-panel {
    min-height: 74vh;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.text-panel {
    overflow: hidden;
}

.panel-heading,
.preview-toolbar {
    padding: 18px;
    border-bottom: 1px solid var(--line);
}

.pill {
    flex: none;
    padding: 7px 10px;
    border-radius: 999px;
    background: #eaf2ff;
    color: var(--accent-dark);
    font-size: 13px;
    font-weight: 800;
}

.text-list {
    display: grid;
    gap: 12px;
    max-height: calc(74vh - 80px);
    overflow: auto;
    padding: 16px;
}

.text-item {
    display: grid;
    gap: 8px;
}

.item-meta {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

textarea {
    width: 100%;
    resize: vertical;
    min-height: 74px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    background: #fbfcfe;
}

textarea:focus {
    outline: 3px solid rgba(23, 105, 224, 0.16);
    border-color: var(--accent);
}

.preview-panel {
    display: grid;
    grid-template-rows: auto auto 1fr;
}

.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.status-line {
    min-height: 44px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
}

.status-line.ok {
    color: var(--ok);
}

.status-line.error {
    color: var(--danger);
}

.preview-frame {
    min-height: 520px;
    display: grid;
    place-items: center;
    overflow: auto;
    padding: 18px;
    background:
        linear-gradient(45deg, #eef1f5 25%, transparent 25%),
        linear-gradient(-45deg, #eef1f5 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #eef1f5 75%),
        linear-gradient(-45deg, transparent 75%, #eef1f5 75%);
    background-color: #fff;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0;
    background-size: 20px 20px;
}

.preview-frame img {
    max-width: 100%;
    max-height: 76vh;
    display: block;
    border: 1px solid var(--line);
    background: #fff;
    box-shadow: 0 12px 32px rgba(27, 39, 68, 0.18);
}

.preview-placeholder,
.empty-state {
    max-width: 520px;
    padding: 24px;
    color: var(--muted);
    text-align: center;
}

.message {
    margin-top: 14px;
    color: var(--danger);
    font-weight: 700;
}

@media (max-width: 920px) {
    .app-shell {
        width: min(100% - 20px, 720px);
        padding: 18px 0;
    }

    .topbar,
    .preview-toolbar,
    .panel-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .editor-layout {
        grid-template-columns: 1fr;
    }

    .text-panel,
    .preview-panel {
        min-height: auto;
    }

    .text-list {
        max-height: none;
    }

    .actions {
        width: 100%;
        justify-content: stretch;
    }

    .actions > * {
        flex: 1;
    }
}
