:root {
    color-scheme: dark;
    font-family: "BIZ UDPGothic", "Hiragino Sans", "Yu Gothic", sans-serif;
    --bg: #09111d;
    --panel: rgba(12, 20, 36, 0.92);
    --panel-soft: rgba(255, 255, 255, 0.03);
    --line: rgba(159, 183, 229, 0.14);
    --text: #ecf3ff;
    --muted: #9baecc;
    --accent: #45c3ff;
    --accent-strong: #1f8fff;
    --warm: #ffd166;
    --danger: #ff7b9c;
    --shadow: 0 28px 80px rgba(0, 0, 0, 0.34);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(31, 143, 255, 0.22), transparent 28%),
        radial-gradient(circle at top right, rgba(255, 209, 102, 0.14), transparent 22%),
        linear-gradient(180deg, #07101b 0%, #0a1322 45%, #0c1627 100%);
}

a {
    color: inherit;
}

code,
textarea,
pre {
    font-family: "JetBrains Mono", "Source Code Pro", monospace;
}

.studio-shell {
    width: min(1440px, calc(100vw - 28px));
    margin: 0 auto;
    padding: 26px 0 40px;
}

.studio-hero,
.studio-panel,
.studio-playground {
    border-radius: 28px;
    border: 1px solid var(--line);
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
}

.studio-hero {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: end;
    padding: 28px 30px;
}

.studio-kicker,
.studio-label {
    margin: 0 0 10px;
    color: var(--warm);
    font-size: 0.8rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.studio-hero h1,
.studio-panel h2 {
    margin: 0;
    line-height: 1.15;
}

.studio-hero h1 {
    font-size: clamp(2rem, 4vw, 3.2rem);
}

.studio-copy,
.studio-active-file,
.dropzone-copy,
.file-meta,
.function-playground-output,
.playground-analysis-card p,
.playground-analysis-card ul {
    color: var(--muted);
}

.studio-copy {
    margin: 16px 0 0;
    max-width: 880px;
    line-height: 1.85;
}

.studio-hero-actions,
.studio-actions,
.file-preview-actions,
.function-playground-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.studio-button,
.function-playground-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 16px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    cursor: pointer;
    font: inherit;
    text-decoration: none;
    transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.studio-button:hover,
.function-playground-button:hover {
    transform: translateY(-1px);
    border-color: rgba(79, 195, 247, 0.26);
}

.studio-button.primary,
.function-playground-button.primary {
    border-color: transparent;
    background: linear-gradient(135deg, var(--accent-strong), var(--accent));
    color: #041220;
    font-weight: 700;
}

.studio-button.secondary {
    background: rgba(255, 255, 255, 0.05);
}

.studio-button.subtle {
    min-height: 36px;
    padding: 0 14px;
}

.studio-layout {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
    margin-top: 18px;
}

.studio-sidebar {
    display: grid;
    gap: 18px;
}

.studio-panel,
.studio-playground {
    padding: 22px;
}

.studio-panel-head,
.function-playground-head {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 12px;
    margin-bottom: 16px;
}

.hidden-input {
    display: none;
}

.dropzone {
    margin-top: 14px;
    padding: 18px;
    border-radius: 20px;
    border: 1px dashed rgba(79, 195, 247, 0.28);
    background: rgba(79, 195, 247, 0.08);
    outline: none;
}

.dropzone.dragover,
.tree-row.drop-target {
    border-color: rgba(255, 209, 102, 0.42);
    background: rgba(255, 209, 102, 0.12);
}

.dropzone-title {
    margin: 0;
    font-weight: 700;
}

.dropzone-copy {
    margin: 8px 0 0;
    line-height: 1.7;
}

.file-tree {
    margin-top: 16px;
    max-height: 540px;
    overflow: auto;
    padding-right: 4px;
}

.tree-children {
    display: grid;
    gap: 6px;
    margin-top: 6px;
}

.tree-node {
    display: grid;
    gap: 6px;
}

.tree-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 8px 10px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.025);
    cursor: pointer;
}

.tree-row.active {
    border-color: rgba(79, 195, 247, 0.28);
    background: rgba(79, 195, 247, 0.1);
}

.tree-row.folder {
    font-weight: 700;
}

.tree-toggle {
    width: 22px;
    height: 22px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    font: inherit;
    cursor: pointer;
}

.tree-icon {
    width: 1.2rem;
    text-align: center;
    opacity: 0.9;
}

.tree-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-meta {
    font-size: 0.8rem;
    color: var(--muted);
}

.file-preview-panel {
    min-height: 280px;
}

.file-meta {
    line-height: 1.8;
    white-space: pre-wrap;
}

.file-preview {
    margin-top: 14px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.025);
    padding: 14px;
    min-height: 140px;
    overflow: auto;
}

.file-preview pre {
    margin: 0;
    white-space: pre-wrap;
    line-height: 1.7;
}

.file-preview img,
.media-preview-stage img {
    max-width: 100%;
    border-radius: 12px;
    display: block;
}

.file-preview audio,
.file-preview video,
.media-preview-stage audio,
.media-preview-stage video {
    width: 100%;
    display: block;
}

.file-preview-actions {
    margin-top: 12px;
}

.function-playground-title {
    margin: 0;
    font-size: 1rem;
    letter-spacing: 0.04em;
}

.studio-active-file {
    margin: 8px 0 0;
    font-size: 0.94rem;
}

.studio-playground {
    min-height: 920px;
}

.studio-playground:fullscreen {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    padding: 18px;
}

.studio-playground-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.06fr) minmax(320px, 0.94fr);
    gap: 16px;
    align-items: start;
}

.studio-editor-shell {
    position: relative;
    min-height: 760px;
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: #07101c;
}

.function-playground-highlight,
.studio-editor {
    margin: 0;
    padding: 18px;
    font: 13.5px/1.75 "JetBrains Mono", "Source Code Pro", monospace;
    tab-size: 4;
}

.function-playground-highlight {
    min-height: 760px;
    color: #d8e8ff;
    white-space: pre-wrap;
    word-break: break-word;
    pointer-events: none;
    overflow: auto;
}

.function-playground-highlight code {
    display: block;
    min-height: 724px;
}

.studio-editor {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    resize: none;
    border: 0;
    outline: none;
    background: transparent;
    color: transparent;
    caret-color: #f2f7ff;
    overflow: auto;
}

.studio-editor[readonly] {
    cursor: not-allowed;
}

.studio-side {
    display: grid;
    gap: 14px;
}

.studio-stage {
    padding: 10px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background:
        radial-gradient(circle at top left, rgba(79, 195, 247, 0.14), transparent 28%),
        #08101d;
}

.preview-stage {
    position: relative;
    min-height: 360px;
    border-radius: 14px;
    overflow: hidden;
    background: #0b1424;
}

.function-playground-canvas {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 3 / 2;
    background: transparent;
}

.media-preview-stage {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 18px;
    background:
        radial-gradient(circle at top left, rgba(79, 195, 247, 0.16), transparent 25%),
        #0b1424;
    overflow: auto;
}

.function-playground-analysis,
.function-playground-output {
    padding: 14px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
}

.function-playground-output {
    min-height: 80px;
    white-space: pre-wrap;
    line-height: 1.75;
}

.playground-analysis-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 700;
}

.playground-analysis-status.ok {
    color: #c8ffe4;
    background: rgba(56, 214, 142, 0.14);
    border: 1px solid rgba(56, 214, 142, 0.18);
}

.playground-analysis-status.error {
    color: #ffd7df;
    background: rgba(255, 99, 132, 0.14);
    border: 1px solid rgba(255, 99, 132, 0.2);
}

.playground-analysis-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.playground-analysis-card {
    padding: 12px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.025);
}

.playground-analysis-card.span-2 {
    grid-column: span 2;
}

.playground-analysis-card strong {
    display: block;
    margin-bottom: 6px;
    color: var(--text);
    font-size: 0.86rem;
}

.playground-analysis-card ul {
    margin: 0;
    padding-left: 1.1rem;
    line-height: 1.7;
}

.playground-analysis-card li + li {
    margin-top: 5px;
}

.playground-error {
    display: inline-block;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(255, 99, 132, 0.2);
    background: rgba(255, 99, 132, 0.1);
    color: #ffd7df;
    line-height: 1.7;
    white-space: pre-wrap;
}

.token-comment { color: #6f87aa; }
.token-string { color: #ffd48d; }
.token-number { color: #7ee3ff; }
.token-class { color: #99c3ff; }
.token-base { color: #66ddc5; }
.token-property { color: #c7a6ff; }
.token-keyword { color: #ff8fa8; }
.token-punct { color: #8ea7cb; }

@media (max-width: 1120px) {
    .studio-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .studio-playground-layout,
    .playground-analysis-grid {
        grid-template-columns: 1fr;
    }

    .playground-analysis-card.span-2 {
        grid-column: auto;
    }

    .studio-editor-shell,
    .function-playground-highlight {
        min-height: 460px;
    }
}

@media (max-width: 720px) {
    .studio-shell {
        width: min(100vw - 18px, 1440px);
        padding: 18px 0 28px;
    }

    .studio-hero,
    .studio-panel,
    .studio-playground {
        border-radius: 22px;
        padding: 20px;
    }

    .studio-hero {
        flex-direction: column;
        align-items: start;
    }
}
