:root {
  color-scheme: dark;
  --bg: #07101c;
  --panel: rgba(10, 22, 37, .91);
  --panel-solid: #0c1929;
  --surface: #0e1d2f;
  --surface-2: #12243a;
  --line: rgba(138, 173, 209, .16);
  --line-strong: rgba(138, 173, 209, .3);
  --text: #eef7ff;
  --muted: #8296aa;
  --muted-2: #536a7e;
  --cyan: #4bd6ff;
  --blue: #4c79ff;
  --green: #43e0a0;
  --amber: #ffbf69;
  --red: #ff667d;
  --shadow: 0 22px 80px rgba(0, 0, 0, .28);
  --mono: "Cascadia Code", "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #edf3f8;
  --panel: rgba(252, 254, 255, .94);
  --panel-solid: #f9fcff;
  --surface: #f2f7fb;
  --surface-2: #e8f0f7;
  --line: rgba(38, 65, 89, .13);
  --line-strong: rgba(38, 65, 89, .24);
  --text: #12263a;
  --muted: #667c90;
  --muted-2: #8da0b1;
  --cyan: #008ab4;
  --blue: #3159d9;
  --green: #008e62;
  --amber: #b96900;
  --red: #d83d58;
  --shadow: 0 22px 70px rgba(47, 71, 94, .14);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  min-height: 100vh;
  overflow-x: hidden;
  background:
    linear-gradient(rgba(74, 123, 163, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(74, 123, 163, .035) 1px, transparent 1px),
    var(--bg);
  background-size: 32px 32px;
  color: var(--text);
  font-family: var(--sans);
}
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.ambient { position: fixed; z-index: -1; width: 38vw; height: 38vw; border-radius: 50%; filter: blur(90px); opacity: .12; pointer-events: none; }
.ambient-a { top: -18vw; left: 18vw; background: var(--cyan); }
.ambient-b { right: -18vw; bottom: -20vw; background: var(--blue); }

.topbar {
  height: 76px; padding: 0 26px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(18px); position: sticky; top: 0; z-index: 10;
}
.brand { color: var(--text); text-decoration: none; display: flex; align-items: center; gap: 13px; }
.brand-mark { width: 40px; height: 40px; border: 1px solid color-mix(in srgb, var(--cyan) 60%, transparent); display: grid; place-content: center; gap: 3px; border-radius: 12px; box-shadow: inset 0 0 24px color-mix(in srgb, var(--cyan) 10%, transparent); }
.brand-mark i { display: block; height: 3px; border-radius: 4px; background: var(--cyan); }
.brand-mark i:nth-child(1) { width: 17px; }.brand-mark i:nth-child(2) { width: 11px; }.brand-mark i:nth-child(3) { width: 15px; }
.brand b { display: block; font-size: 15px; letter-spacing: .13em; }
.brand small { display: block; margin-top: 3px; color: var(--muted); font: 10px var(--mono); letter-spacing: .08em; }
.top-meta { display: flex; gap: 9px; align-items: center; }
.status-chip { height: 34px; padding: 0 13px; display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font: 11px var(--mono); }
.status-chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px var(--green); }
.icon-button { height: 34px; min-width: 38px; padding: 0 11px; border: 1px solid var(--line); background: var(--surface); border-radius: 9px; cursor: pointer; font: 11px var(--mono); }
.icon-button:hover { border-color: var(--line-strong); color: var(--cyan); }

.shell { display: grid; grid-template-columns: 270px minmax(440px, 1fr) 350px; gap: 14px; padding: 14px; min-height: calc(100vh - 76px); }
.panel { border: 1px solid var(--line); border-radius: 17px; background: var(--panel); box-shadow: var(--shadow); overflow: hidden; backdrop-filter: blur(18px); }

.rail { min-height: 720px; display: flex; flex-direction: column; }
.rail-tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 10px; gap: 6px; border-bottom: 1px solid var(--line); }
.rail-tab { height: 36px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; font-size: 11px; letter-spacing: .08em; }
.rail-tab.active { color: var(--text); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.rail-section { display: none; padding: 17px 14px; min-height: 0; flex: 1; flex-direction: column; }
.rail-section.active { display: flex; }
.rail-heading, .output-head, .modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.rail-heading span, .output-head span, .modal-head span { color: var(--cyan); font: 9px var(--mono); letter-spacing: .16em; }
.rail-heading h2, .output-head h2, .modal-head h2 { margin: 4px 0 0; font-size: 15px; }
.mini-button { border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 8px; height: 30px; padding: 0 10px; cursor: pointer; font-size: 11px; }
.mini-button:hover { color: var(--text); border-color: var(--cyan); }
.upload-button { display: inline-flex; align-items: center; }
.search-box { display: flex; align-items: center; gap: 8px; height: 36px; margin: 15px 0 10px; padding: 0 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--muted); }
.search-box input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 12px; }
.project-list, .include-groups { min-height: 0; overflow: auto; padding-right: 3px; }
.project-card { width: 100%; display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 9px; padding: 10px 7px; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.project-card:hover, .project-card.active { background: var(--surface); border-color: var(--line); }
.project-card.active { box-shadow: inset 2px 0 var(--cyan); }
.project-card .project-icon { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; background: color-mix(in srgb, var(--blue) 16%, var(--surface)); color: var(--cyan); font: 10px var(--mono); }
.project-card b { display: block; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.project-card small { display: block; margin-top: 3px; color: var(--muted); font: 9px var(--mono); }
.project-delete { border: 0; background: transparent; color: var(--muted-2); cursor: pointer; font-size: 16px; }
.project-delete:hover { color: var(--red); }
.rail-empty { padding: 25px 12px; color: var(--muted); text-align: center; font-size: 11px; line-height: 1.7; }
.include-stats { display: flex; gap: 14px; margin: 1px 2px 11px; color: var(--muted); font: 10px var(--mono); }
.include-stats b { color: var(--text); }
.include-group-title { margin: 13px 4px 6px; color: var(--muted); font: 9px var(--mono); letter-spacing: .12em; }
.include-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 7px; font: 10px var(--mono); cursor: pointer; }
.include-row:hover { background: var(--surface); color: var(--cyan); }
.include-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.include-row button { border: 0; background: transparent; color: var(--muted-2); cursor: pointer; }
.include-row button:hover { color: var(--red); }
.rail-footer { height: 48px; padding: 0 14px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.rail-footer code { color: var(--cyan); }

.workspace { min-width: 0; display: flex; flex-direction: column; min-height: 720px; }
.editor-head { min-height: 78px; padding: 13px 16px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.file-identity { display: flex; align-items: center; gap: 12px; min-width: 0; }
.file-badge { flex: 0 0 auto; width: 39px; height: 39px; display: grid; place-items: center; border-radius: 11px; background: linear-gradient(145deg, var(--blue), #703dff); color: white; font: 11px var(--mono); box-shadow: 0 9px 25px rgba(76,121,255,.25); }
.file-identity label > span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 9px; }
.file-identity label div { display: flex; align-items: center; }
.file-identity input { width: min(32vw, 330px); border: 0; border-bottom: 1px solid var(--line); outline: 0; padding: 3px 0 6px; background: transparent; color: var(--text); font: 15px var(--mono); }
.file-identity input:focus { border-color: var(--cyan); }
.file-identity em { padding-bottom: 4px; color: var(--muted); font: normal 13px var(--mono); }
.editor-actions { display: flex; gap: 8px; }
.ghost-button, .primary-button, .download-button { min-height: 40px; border-radius: 10px; padding: 0 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; text-decoration: none; }
.ghost-button { border: 1px solid var(--line); background: var(--surface); color: var(--muted); }
.ghost-button:hover { color: var(--text); border-color: var(--line-strong); }
.primary-button { border: 1px solid color-mix(in srgb, var(--cyan) 45%, transparent); background: linear-gradient(135deg, color-mix(in srgb, var(--blue) 72%, #17253a), color-mix(in srgb, var(--cyan) 55%, #17253a)); color: white; font-weight: 700; }
.primary-button:hover { filter: brightness(1.1); transform: translateY(-1px); }
.primary-button:disabled { opacity: .55; cursor: wait; transform: none; }
kbd { padding: 2px 5px; border: 1px solid rgba(255,255,255,.22); border-radius: 5px; font: 9px var(--mono); color: rgba(255,255,255,.72); }
.editor-toolbar { height: 43px; display: flex; align-items: flex-end; justify-content: space-between; padding: 0 11px; background: color-mix(in srgb, var(--surface) 70%, transparent); border-bottom: 1px solid var(--line); }
.file-tab { height: 34px; min-width: 150px; padding: 0 11px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-bottom-color: var(--panel-solid); border-radius: 8px 8px 0 0; background: var(--panel-solid); font: 10px var(--mono); }
.file-tab i { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }.file-tab b { margin-left: auto; color: var(--muted); }
.editor-tools { height: 34px; display: flex; align-items: center; gap: 12px; color: var(--muted); font: 9px var(--mono); }
.editor-tools button { border: 0; background: transparent; color: var(--muted); cursor: pointer; font: inherit; }.editor-tools button:hover { color: var(--cyan); }
.code-stage { flex: 1; min-height: 540px; display: grid; grid-template-columns: 55px 1fr; background: color-mix(in srgb, var(--panel-solid) 92%, black); overflow: hidden; }
#lineNumbers { margin: 0; padding: 18px 13px 18px 0; overflow: hidden; border-right: 1px solid var(--line); color: var(--muted-2); text-align: right; user-select: none; font: 13px/1.65 var(--mono); }
#sourceEditor { width: 100%; height: 100%; resize: none; border: 0; outline: 0; padding: 18px 19px 80px; overflow: auto; tab-size: 4; background: transparent; color: var(--text); caret-color: var(--cyan); font: 13px/1.65 var(--mono); white-space: pre; }
#sourceEditor::selection { background: color-mix(in srgb, var(--blue) 38%, transparent); }
.editor-foot { height: 32px; display: flex; align-items: center; gap: 14px; padding: 0 13px; border-top: 1px solid var(--line); color: var(--muted); font: 9px var(--mono); }.editor-foot .grow { flex: 1; }

.output { padding: 17px; min-height: 720px; display: flex; flex-direction: column; }
.build-summary { display: flex; align-items: center; gap: 13px; min-height: 82px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.build-orb { width: 51px; height: 51px; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; font: 10px var(--mono); color: var(--muted); box-shadow: inset 0 0 20px var(--surface-2); }
.build-orb.running { color: var(--cyan); border-color: var(--cyan); animation: pulse 1.1s infinite; }.build-orb.success { color: var(--green); border-color: var(--green); }.build-orb.error { color: var(--red); border-color: var(--red); }
@keyframes pulse { 50% { box-shadow: 0 0 22px color-mix(in srgb, var(--cyan) 35%, transparent), inset 0 0 20px var(--surface-2); } }
.build-summary b { display: block; font-size: 13px; }.build-summary span { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; }
.metric-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin: 13px 0; }
.metric-row div { min-width: 0; padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.metric-row span { display: block; color: var(--muted); font-size: 9px; }.metric-row b { display: block; margin-top: 4px; font: 12px var(--mono); }
.console { flex: 1; min-height: 330px; max-height: 49vh; margin: 0; padding: 14px; overflow: auto; border: 1px solid var(--line); border-radius: 11px; background: #050b13; color: #cde6f6; white-space: pre-wrap; word-break: break-word; font: 10px/1.65 var(--mono); }
[data-theme="light"] .console { background: #132232; color: #d9edfa; }
.console-dim { color: #5d788c; }.console .error { color: #ff8da0; }.console .warning { color: #ffd18f; }.console .success { color: #74edbc; }
.artifact-card { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 10px; margin-top: 12px; padding: 10px; border: 1px solid color-mix(in srgb, var(--green) 30%, var(--line)); border-radius: 11px; background: color-mix(in srgb, var(--green) 6%, var(--surface)); }
.artifact-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; background: color-mix(in srgb, var(--green) 15%, var(--surface)); color: var(--green); }
.artifact-card span { display: block; color: var(--green); font: 8px var(--mono); letter-spacing: .12em; }.artifact-card b { display: block; margin-top: 3px; font: 11px var(--mono); }.artifact-card small { display: block; margin-top: 3px; color: var(--muted); font: 8px var(--mono); }
.download-button { min-height: 32px; padding: 0 11px; background: var(--green); color: #03271b; font-size: 10px; font-weight: 800; }
.quick-notes { margin-top: 13px; padding: 11px 2px 0; border-top: 1px solid var(--line); }.quick-notes b { font-size: 10px; }.quick-notes p { margin: 7px 0 0; color: var(--muted); font-size: 10px; line-height: 1.7; }

.modal { width: min(850px, calc(100vw - 30px)); padding: 0; border: 0; border-radius: 16px; background: transparent; color: var(--text); }
.modal::backdrop { background: rgba(2, 8, 14, .73); backdrop-filter: blur(8px); }
.modal-card { margin: 0; padding: 20px; border: 1px solid var(--line-strong); border-radius: 16px; background: var(--panel-solid); box-shadow: var(--shadow); }
.modal-head button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--muted); cursor: pointer; font-size: 20px; }
.modal-code pre { max-height: 70vh; overflow: auto; padding: 15px; border: 1px solid var(--line); border-radius: 11px; background: #050b13; color: #cde6f6; white-space: pre; font: 11px/1.65 var(--mono); }
.api-intro { color: var(--muted); line-height: 1.7; font-size: 12px; }.api-intro code { color: var(--cyan); }
.endpoint { display: flex; align-items: center; gap: 10px; margin: 15px 0 9px; }.endpoint b { padding: 5px 7px; border-radius: 6px; background: color-mix(in srgb, var(--green) 16%, var(--surface)); color: var(--green); font: 9px var(--mono); }.endpoint code { font: 12px var(--mono); }
.api-code { padding: 15px; overflow: auto; border-radius: 11px; background: #050b13; color: #cde6f6; font: 10px/1.65 var(--mono); }
.api-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }.api-grid div { padding: 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }.api-grid span { display: block; color: var(--muted); font-size: 9px; }.api-grid code { display: block; margin-top: 5px; color: var(--cyan); font-size: 10px; }
.toast-stack { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: grid; gap: 8px; }
.toast { min-width: 230px; max-width: 390px; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--panel-solid); box-shadow: var(--shadow); font-size: 11px; animation: toast-in .22s ease-out; }.toast.success { border-color: color-mix(in srgb, var(--green) 45%, var(--line)); }.toast.error { border-color: color-mix(in srgb, var(--red) 45%, var(--line)); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { border: 2px solid transparent; border-radius: 9px; background: color-mix(in srgb, var(--muted) 38%, transparent); background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--muted) 60%, transparent); background-clip: padding-box; }

@media (max-width: 1180px) {
  .shell { grid-template-columns: 240px minmax(440px, 1fr); }
  .output { grid-column: 1 / -1; min-height: 520px; }
  .console { max-height: 330px; }
}
@media (max-width: 800px) {
  .topbar { height: 64px; padding: 0 13px; }.status-chip { display: none; }
  .brand { min-width: 0; }.brand small { display: none; }.brand b { font-size: 13px; }.brand-mark { width: 36px; height: 36px; }
  .top-meta { flex: 0 0 auto; }.icon-button { min-width: 34px; padding: 0 8px; }
  .shell { grid-template-columns: 1fr; padding: 8px; min-height: calc(100vh - 64px); }
  .rail { min-height: 430px; }.workspace, .output { min-height: 650px; }
  .editor-head { align-items: flex-start; flex-direction: column; }.editor-actions { width: 100%; min-width: 0; }.editor-actions button { flex: 1 1 0; min-width: 0; padding-inline: 8px; font-size: 13px; }.editor-actions kbd { display: none; }
  .file-identity input { width: min(68vw, 330px); }
  .editor-toolbar { align-items: center; }.editor-tools span, .editor-tools button:first-of-type { display: none; }
  .code-stage { min-height: 520px; grid-template-columns: 43px 1fr; }#lineNumbers { padding-right: 8px; }#sourceEditor { padding-left: 12px; }
  .api-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; } }
