:root {
  color-scheme: dark;
  --bg: #0b1020;
  --panel: #11182a;
  --panel-2: #151e33;
  --panel-3: #1a2540;
  --border: #26324d;
  --muted: #8793ad;
  --text: #e8edf8;
  --text-soft: #bbc5d9;
  --accent: #7993ff;
  --accent-2: #9c83ff;
  --green: #51d7a0;
  --red: #ff788b;
  --yellow: #f5c86e;
  --editor-font: 13px;
  --editor-line: 22px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { background: var(--bg); color: var(--text); }
button, input, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app-shell { display: flex; flex-direction: column; width: 100%; height: 100dvh; min-height: 0; background: var(--bg); }
.topbar { height: 62px; flex: 0 0 62px; display: flex; align-items: center; gap: 24px; padding: 0 17px; border-bottom: 1px solid var(--border); background: #0e1526; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 190px; }
.brand-mark { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; gap: 2px; border: 1px solid #536fe566; border-radius: 10px; background: linear-gradient(145deg, #1d2b50, #282045); }
.brand-mark span { width: 3px; height: 15px; border-radius: 5px; background: #94a8ff; transform: skew(-24deg); }
.brand-mark span:nth-child(2) { height: 20px; background: #a68cff; }
.brand-mark span:nth-child(3) { height: 13px; background: #6ec8f6; }
.brand-copy { display: flex; flex-direction: column; line-height: 1.05; }
.brand-copy strong { font-size: 14px; letter-spacing: .015em; }
.brand-copy small { margin-top: 4px; color: #7f8ba7; font-size: 9px; letter-spacing: .17em; text-transform: uppercase; }
.project-name { display: flex; align-items: center; gap: 9px; padding: 7px 11px; border: 1px solid transparent; border-radius: 8px; min-width: 170px; max-width: 300px; }
.project-name:focus-within { background: var(--panel); border-color: var(--border); }
.project-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px #7993ff88; }
.project-name input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--text); background: transparent; font-size: 12px; font-weight: 600; }
.top-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.save-state { display: inline-flex; align-items: center; gap: 7px; margin-right: 7px; color: #8693ad; font-size: 10px; white-space: nowrap; }
.save-state i { width: 6px; height: 6px; display: inline-block; border-radius: 50%; background: var(--green); }
.save-state.saving i { background: var(--yellow); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.button, .icon-button { height: 32px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); cursor: pointer; transition: .15s ease; }
.button { padding: 0 12px; font-size: 11px; font-weight: 650; }
.button:hover, .icon-button:hover { border-color: #566b9d; background: var(--panel-3); }
.icon-button { width: 33px; font-size: 16px; }
.button-quiet { color: var(--text-soft); }
.button-run { display: inline-flex; align-items: center; gap: 7px; padding: 0 15px; border-color: #627df0; color: white; background: linear-gradient(135deg, #5976ee, #8066e9); box-shadow: 0 4px 18px #5b70e833; }
.button-run:hover { border-color: #9daeff; background: linear-gradient(135deg, #6d87ff, #9178f6); }
.button-run span { font-size: 10px; }
.button-stop { color: #ff9cab; border-color: #743747; background: #2b1925; }
.button:disabled { opacity: .4; cursor: not-allowed; }

.workspace { display: grid; grid-template-columns: 218px minmax(350px, 1fr) minmax(340px, 43%); flex: 1; min-height: 0; overflow: hidden; }
.sidebar { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--border); background: #0f1728; }
.side-section-heading { height: 44px; display: flex; align-items: center; justify-content: space-between; padding: 0 15px; color: #7785a1; font-size: 9px; font-weight: 800; letter-spacing: .16em; }
.side-tools { display: flex; gap: 4px; }
.side-tools button { width: 23px; height: 23px; border: 0; border-radius: 5px; color: #9ca9c4; background: transparent; cursor: pointer; font-size: 15px; }
.side-tools button:hover { color: white; background: #202d49; }
.project-tree-title { display: flex; align-items: center; gap: 8px; padding: 8px 14px 7px; color: #aab6ce; font-size: 10px; letter-spacing: .04em; }
.project-tree-title span { color: #7583a1; }
.project-tree-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-tree { display: flex; flex-direction: column; gap: 1px; padding: 3px 8px; }
.file-row { height: 31px; display: flex; align-items: center; border-radius: 6px; }
.file-row:hover { background: #17233b; }
.file-row.active { background: #1d2c4d; }
.file-open { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; height: 100%; padding: 0 8px; border: 0; border-radius: 6px; color: #b8c3d9; background: transparent; cursor: pointer; text-align: left; font-size: 11px; }
.file-row.active .file-open { color: #f1f4ff; }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-type-icon { width: 18px; flex: 0 0 18px; color: #91a9ff; font-size: 9px; font-weight: 850; text-align: center; }
.icon-python { color: #f4c66f; }
.icon-css { color: #8ba5ff; }
.icon-javascript { color: #e9cf71; }
.icon-html { color: #ee9a74; }
.icon-json { color: #9ec88b; }
.file-row-actions { display: flex; gap: 1px; padding-right: 4px; opacity: 0; transition: opacity .12s; }
.file-row:hover .file-row-actions { opacity: 1; }
.file-row-actions button { width: 21px; height: 21px; border: 0; border-radius: 5px; color: #8290ac; background: transparent; cursor: pointer; }
.file-row-actions button:hover { color: white; background: #314466; }
.sidebar-spacer { flex: 1; }
.runtime-card { margin: 12px 10px; padding: 12px; border: 1px solid #2b3855; border-radius: 10px; background: linear-gradient(145deg, #151f35, #121a2b); }
.runtime-card-head { display: flex; align-items: center; gap: 8px; font-size: 10px; }
.runtime-indicator { width: 7px; height: 7px; border-radius: 50%; background: #6b7894; }
.runtime-indicator.ready { background: var(--green); box-shadow: 0 0 9px #51d7a088; }
.runtime-indicator.loading { background: var(--yellow); animation: pulse 1s infinite; }
.runtime-state { margin: 8px 0 10px 15px; color: #8f9bb4; font-size: 10px; }
.runtime-load { width: 100%; height: 27px; border: 1px solid #465d9a; border-radius: 6px; color: #cbd6ff; background: #25365f; cursor: pointer; font-size: 10px; font-weight: 700; }
.runtime-load:disabled { opacity: .55; cursor: default; }
.runtime-version { margin-top: 8px; color: #6c7a98; font-size: 9px; text-align: center; }
.sidebar-footer { display: flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px; border-top: 1px solid var(--border); color: #6c7892; font-size: 9px; }
.online-dot { width: 6px; height: 6px; display: inline-block; border-radius: 50%; background: var(--green); }
.footer-lock { margin-left: auto; font-size: 13px; }

.editor-column { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--border); background: #0c1322; }
.tabs-bar { height: 39px; display: flex; align-items: stretch; flex: 0 0 39px; overflow-x: auto; border-bottom: 1px solid var(--border); background: #0e1627; scrollbar-width: thin; }
.editor-tab { display: flex; align-items: center; gap: 4px; min-width: 112px; max-width: 175px; border-right: 1px solid #202b43; border-top: 2px solid transparent; }
.editor-tab.active { border-top-color: var(--accent); background: #121c30; }
.tab-select { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; height: 100%; padding: 0 9px; border: 0; color: #8996b0; background: transparent; cursor: pointer; text-align: left; font-size: 10px; }
.editor-tab.active .tab-select { color: #e5eaff; }
.tab-file-icon { color: #9caef9; font-size: 9px; font-weight: 800; }
.tab-close { width: 21px; height: 21px; margin-right: 5px; border: 0; border-radius: 4px; color: #7b89a5; background: transparent; cursor: pointer; }
.tab-close:hover { color: white; background: #283653; }
.editor-toolbar { height: 35px; display: flex; align-items: center; justify-content: space-between; padding: 0 14px; border-bottom: 1px solid #202a40; background: #101829; }
.breadcrumb { color: #8290aa; font-size: 10px; }
.breadcrumb span { padding: 0 7px; color: #4d5c7b; }
.editor-tools { display: flex; align-items: center; gap: 10px; }
.language-badge { color: #8fa7ff; font-size: 9px; font-weight: 800; letter-spacing: .08em; }
.tool-button { padding: 3px 6px; border: 0; border-radius: 4px; color: #8794ac; background: transparent; cursor: pointer; font-size: 9px; }
.tool-button:hover { color: white; background: #202c45; }
.editor-host { position: relative; display: flex; flex: 1; min-height: 120px; overflow: hidden; background: #0c1322; }
.line-numbers { width: 46px; flex: 0 0 46px; padding: 17px 10px 30px 0; overflow: hidden; color: #4a5873; background: #0c1322; font: var(--editor-font)/var(--editor-line) ui-monospace, SFMono-Regular, Consolas, monospace; text-align: right; white-space: pre; user-select: none; }
.code-area { position: relative; flex: 1; min-width: 0; min-height: 0; overflow: hidden; }
.highlight-layer, .code-editor { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 17px 20px 40px 9px; border: 0; outline: 0; overflow: auto; tab-size: 2; white-space: pre; overflow-wrap: normal; font: var(--editor-font)/var(--editor-line) ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; letter-spacing: 0; }
.highlight-layer { pointer-events: none; color: #d2daf0; }
.code-editor { resize: none; color: transparent; caret-color: #f2f5ff; background: transparent; -webkit-text-fill-color: transparent; selection-background-color: #647fc955; }
.code-editor::selection { background: #637fe055; color: transparent; }
.code-editor:focus { outline: none; }
.tok-comment { color: #71809d; font-style: italic; }
.tok-string { color: #d8b77d; }
.tok-keyword { color: #c19bff; }
.tok-number { color: #8bcde1; }
.tok-tag { color: #83b7fa; }
.tok-selector { color: #92d5b5; }
.editor-statusbar { height: 23px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 12px; border-top: 1px solid var(--border); color: #75829d; background: #121b2e; font-size: 9px; }
.status-left, .status-right { display: flex; gap: 13px; }
.bottom-panel { height: 185px; flex: 0 0 185px; display: flex; flex-direction: column; border-top: 1px solid var(--border); background: #0e1626; transition: height .18s; }
.bottom-panel.collapsed { height: 34px; flex-basis: 34px; }
.bottom-panel.collapsed .console-output { display: none; }
.bottom-panel-header { height: 34px; flex: 0 0 34px; display: flex; align-items: center; justify-content: space-between; padding: 0 10px; border-bottom: 1px solid #202b43; }
.panel-tabs { display: flex; align-items: stretch; height: 100%; gap: 13px; }
.panel-tab { position: relative; padding: 0 3px; border: 0; color: #77849e; background: transparent; cursor: pointer; font-size: 10px; }
.panel-tab.active { color: #dbe3f8; }
.panel-tab.active::after { position: absolute; right: 0; bottom: -1px; left: 0; height: 2px; background: var(--accent); content: ''; }
.console-actions { display: flex; align-items: center; gap: 9px; color: #77849e; font-size: 9px; }
.console-actions button { padding: 3px 5px; border: 0; border-radius: 4px; color: #8794ad; background: transparent; cursor: pointer; font-size: 9px; }
.console-actions button:hover { color: white; background: #202b43; }
.console-output { flex: 1; min-height: 0; overflow: auto; padding: 9px 12px 15px; color: #bac5d8; font: 10px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; }
.console-welcome { color: #74819c; }
.console-welcome span { color: #a5b5ff; }
.console-line { display: flex; align-items: flex-start; gap: 8px; min-height: 18px; white-space: pre-wrap; overflow-wrap: anywhere; }
.console-marker { width: 11px; flex: 0 0 11px; color: #8197f7; text-align: center; }
.console-line pre { margin: 0; font: inherit; white-space: pre-wrap; overflow-wrap: anywhere; }
.console-error { color: #ff9ba7; }
.console-error .console-marker { color: #ff7188; }
.console-warn { color: #e6c77d; }
.console-info { color: #8595b9; }
.hidden { display: none !important; }

.preview-column { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #111a2c; }
.preview-header { height: 43px; flex: 0 0 43px; display: flex; align-items: center; justify-content: space-between; padding: 0 14px; border-bottom: 1px solid var(--border); background: #101829; }
.preview-heading { display: flex; align-items: center; gap: 8px; font-size: 11px; }
.preview-icon { color: #a0b3ff; font-size: 15px; }
.preview-live { display: inline-flex; align-items: center; gap: 5px; margin-left: 4px; color: #60cfa0; font-size: 8px; font-weight: 800; letter-spacing: .1em; }
.preview-live i { width: 5px; height: 5px; border-radius: 50%; background: #51d7a0; box-shadow: 0 0 8px #51d7a077; }
.preview-actions { display: flex; gap: 5px; }
.preview-actions button { width: 26px; height: 26px; border: 0; border-radius: 5px; color: #8997b1; background: transparent; cursor: pointer; font-size: 15px; }
.preview-actions button:hover { color: white; background: #263552; }
.preview-frame-wrap { position: relative; flex: 1; min-height: 0; overflow: hidden; padding: 12px; background: #171f31; }
#previewFrame { width: 100%; height: 100%; border: 0; border-radius: 8px; background: white; box-shadow: 0 7px 24px #0003; }
.preview-empty { position: absolute; inset: 0; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; padding: 30px; color: #aab5cc; text-align: center; }
.preview-empty strong { color: #e6ebf7; font-size: 12px; }
.preview-empty span { max-width: 260px; color: #8592ad; font-size: 10px; line-height: 1.7; }
.empty-icon { width: 50px; height: 50px; display: grid; place-items: center; border: 1px solid #3c4f79; border-radius: 15px; color: #9eb0ff; background: #1c2b4b; font-size: 22px; }
.preview-footer { height: 26px; display: flex; align-items: center; justify-content: space-between; padding: 0 13px; border-top: 1px solid var(--border); color: #74819c; background: #111a2c; font-size: 9px; }
.preview-footer span:first-child { display: flex; align-items: center; gap: 6px; }
.mobile-nav { display: none; }
.toast-region { position: fixed; right: 16px; bottom: 18px; z-index: 20; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { max-width: min(360px, calc(100vw - 32px)); padding: 10px 14px; border: 1px solid #384767; border-radius: 9px; color: #eaf0ff; background: #1a2741; box-shadow: 0 10px 35px #0006; font-size: 11px; animation: toast-in .16s ease-out; }
.toast-success { border-color: #2c785f; }
.toast-warn { border-color: #846d39; }
.toast-error { border-color: #894354; }
@keyframes toast-in { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f5fb;
  --panel: #fff;
  --panel-2: #f0f3fb;
  --panel-3: #e4eaff;
  --border: #d7deec;
  --muted: #67738c;
  --text: #202a40;
  --text-soft: #51607b;
}
:root[data-theme="light"] .topbar { background: #fff; }
:root[data-theme="light"] .brand-copy small { color: #7d8aa3; }
:root[data-theme="light"] .project-name input { color: var(--text); }
:root[data-theme="light"] .sidebar { background: #f8f9fd; }
:root[data-theme="light"] .file-open { color: #52617d; }
:root[data-theme="light"] .file-row.active { background: #e5ebff; }
:root[data-theme="light"] .file-row.active .file-open { color: #263a75; }
:root[data-theme="light"] .runtime-card { background: #eef2fc; }
:root[data-theme="light"] .editor-column, :root[data-theme="light"] .editor-host, :root[data-theme="light"] .line-numbers { background: #fbfcff; }
:root[data-theme="light"] .tabs-bar, :root[data-theme="light"] .editor-toolbar { background: #f3f5fb; }
:root[data-theme="light"] .editor-tab.active { background: #fff; }
:root[data-theme="light"] .tab-select { color: #64718b; }
:root[data-theme="light"] .editor-tab.active .tab-select { color: #233052; }
:root[data-theme="light"] .highlight-layer { color: #25304a; }
:root[data-theme="light"] .code-editor { caret-color: #28385e; }
:root[data-theme="light"] .editor-statusbar, :root[data-theme="light"] .bottom-panel, :root[data-theme="light"] .bottom-panel-header { background: #f5f7fc; }
:root[data-theme="light"] .preview-column, :root[data-theme="light"] .preview-header, :root[data-theme="light"] .preview-footer { background: #f0f3fa; }
:root[data-theme="light"] .preview-frame-wrap { background: #e8edf6; }
:root[data-theme="light"] .tok-comment { color: #8794a9; }
:root[data-theme="light"] .tok-string { color: #98631c; }
:root[data-theme="light"] .tok-keyword { color: #8352c6; }
:root[data-theme="light"] .tok-number { color: #167d98; }
:root[data-theme="light"] .tok-tag { color: #266ab7; }
:root[data-theme="light"] .tok-selector { color: #218052; }
:root[data-theme="light"] .console-output { color: #38455f; }
:root[data-theme="light"] .console-welcome { color: #79869e; }

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 190px minmax(320px, 1fr) minmax(290px, 38%); }
  .brand { min-width: 160px; }
  .topbar { gap: 12px; }
  .save-state { display: none; }
}
@media (max-width: 900px) {
  .file-row-actions { opacity: 1; }
  html, body { overflow: hidden; }
  .topbar { height: 54px; flex-basis: 54px; gap: 8px; padding: 0 10px; }
  .brand { min-width: auto; }
  .brand-copy small { display: none; }
  .brand-copy strong { font-size: 12px; }
  .brand-mark { width: 28px; height: 28px; }
  .project-name { min-width: 0; max-width: 170px; padding: 5px 7px; }
  .top-actions { gap: 5px; }
  .top-actions .button-quiet { padding: 0 7px; font-size: 9px; }
  .button { height: 30px; padding: 0 9px; font-size: 10px; }
  .icon-button { width: 29px; height: 29px; }
  .workspace { position: relative; display: block; min-height: 0; }
  .sidebar, .editor-column, .preview-column { position: absolute; inset: 0; display: none; width: 100%; height: 100%; border: 0; }
  .editor-column { display: flex; }
  .sidebar.mobile-active { display: flex; z-index: 3; }
  .preview-column.mobile-active { display: flex; z-index: 2; }
  .editor-host.mobile-hidden, .tabs-bar.mobile-hidden { display: none; }
  .editor-column:has(.editor-host.mobile-hidden) { display: none; }
  .editor-statusbar { height: 22px; }
  .bottom-panel { height: 150px; flex-basis: 150px; }
  .mobile-nav { height: 47px; flex: 0 0 47px; display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--border); background: #101829; }
  .mobile-nav button { border: 0; color: #8592ac; background: transparent; font-size: 11px; }
  .mobile-nav button.active { color: #dce5ff; background: #1a2743; box-shadow: inset 0 2px #8198ff; }
  .preview-frame-wrap { padding: 8px; }
}
@media (max-width: 520px) {
  .top-actions .button-quiet { display: none; }
  .project-name { display: none; }
  .topbar { justify-content: space-between; }
  .button-stop { display: none; }
  .line-numbers { width: 35px; flex-basis: 35px; padding-right: 7px; }
  .highlight-layer, .code-editor { padding-left: 7px; padding-right: 12px; font-size: 12px; }
  .editor-toolbar { padding: 0 9px; }
  .editor-tools { gap: 4px; }
  .status-right span:first-child { display: none; }
  .bottom-panel { height: 132px; flex-basis: 132px; }
}
