:root {
    color-scheme: light;
    --bg: #f7f8f4;
    --surface: #ffffff;
    --surface-soft: #edf4ef;
    --text: #1d2924;
    --muted: #607168;
    --border: #cbd8d0;
    --accent: #16736b;
    --accent-strong: #0c514c;
    --accent-warm: #d9603f;
    --code-bg: #17231f;
    --code-text: #e9f4ef;
    --shadow: 0 16px 40px rgba(27, 41, 36, 0.12);
}

* {
    box-sizing: border-box;
}

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

button,
textarea {
    font: inherit;
}

.app {
    min-height: 100vh;
    padding: 24px;
}

.shell {
    max-width: 1180px;
    margin: 0 auto;
}

.header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    padding: 0 0 18px;
    border-bottom: 1px solid var(--border);
}

h1 {
    margin: 0;
    font-size: clamp(1.55rem, 3vw, 2.55rem);
    line-height: 1.05;
}

.subtitle {
    max-width: 680px;
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 1rem;
}

.meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.pill {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    font-size: 0.82rem;
    white-space: nowrap;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px;
    margin-top: 18px;
}

.panel {
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-soft);
}

.panel-title {
    margin: 0;
    font-size: 0.92rem;
    font-weight: 700;
    letter-spacing: 0;
}

.status {
    color: var(--accent-strong);
    font-size: 0.82rem;
    font-weight: 700;
    white-space: nowrap;
}

.status.error {
    color: var(--accent-warm);
}

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

.example-button {
    min-height: 38px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 700;
}

.example-button:hover,
.example-button:focus-visible {
    border-color: var(--accent);
    outline: 2px solid rgba(22, 115, 107, 0.18);
    outline-offset: 1px;
}

.editor {
    display: block;
    width: calc(100% - 32px);
    min-height: 180px;
    margin: 14px 16px 16px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    resize: vertical;
    background: #fcfffd;
    color: var(--text);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 0.92rem;
    line-height: 1.55;
}

.editor:focus {
    border-color: var(--accent);
    outline: 3px solid rgba(22, 115, 107, 0.16);
}

.output {
    display: block;
    min-height: 258px;
    margin: 0;
    padding: 16px;
    overflow: auto;
    background: var(--code-bg);
    color: var(--code-text);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 0.88rem;
    line-height: 1.55;
    white-space: pre-wrap;
}

.preview {
    margin-top: 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-soft);
}

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

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

.preview-label {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 700;
}

.tree {
    margin: 0;
    padding: 0;
    list-style: none;
}

.tree ul {
    margin: 8px 0 0;
    padding-left: 22px;
    list-style: none;
    border-left: 2px solid var(--border);
}

.tree li {
    position: relative;
    margin: 8px 0;
}

.tree li::before {
    content: "";
    position: absolute;
    top: 17px;
    left: -22px;
    width: 14px;
    border-top: 2px solid var(--border);
}

.tree > li::before {
    display: none;
}

.text {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    font-weight: 700;
    transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.depth {
    color: var(--muted);
    font-weight: 600;
}

.note {
    margin: 0;
    color: var(--muted);
    font-size: 0.86rem;
}

@media (max-width: 860px) {
    .app {
        padding: 16px;
    }

    .header,
    .preview-header {
        align-items: start;
        flex-direction: column;
    }

    .meta {
        justify-content: flex-start;
    }

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

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

    .panel-header {
        align-items: start;
        flex-direction: column;
    }

    .status {
        white-space: normal;
    }
}
