:root {
  --bg: #0a0a0b; --surface: #141418; --surface2: #1c1c22; --border: #2a2a32;
  --text: #e8e8ef; --dim: #8b8b99; --accent: #6d4aff; --accent2: #9d7cff;
  --ok: #34d399; --warn: #fbbf24; --err: #f87171; --info: #60a5fa;
}
[data-theme="midnight"] { --bg: #0d1424; --surface: #16203a; --surface2: #1e2b4a; --border: #2b3a5c; --accent: #4f9cff; --accent2: #7cb8ff; }
[data-theme="light"] { --bg: #f4f4f8; --surface: #ffffff; --surface2: #f0f0f5; --border: #e0e0e8; --text: #1a1a2e; --dim: #6a6a7a; --accent: #6d4aff; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font-family: 'Bricolage Grotesque', system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
}
#root { height: 100%; }
button, input, textarea, select { font-family: inherit; color: inherit; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.app-shell {
  display: flex; flex-direction: column; height: 100dvh;
  padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
}

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .5rem .7rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .4rem; min-width: 0; flex: 1; }
.logo { font-size: 1.3rem; }
.proj-name {
  background: transparent; border: none; font-weight: 800; font-size: 1rem;
  color: var(--text); width: 100%; min-width: 0; padding: 2px 4px; border-radius: 6px;
}
.proj-name:focus { outline: none; background: var(--surface2); }
.mode-switch { display: flex; background: var(--surface2); border-radius: 8px; padding: 2px; }
.mode-btn {
  background: transparent; border: none; color: var(--dim); font-size: .6rem; font-weight: 700;
  padding: .35rem .5rem; border-radius: 6px; letter-spacing: .05em; cursor: pointer;
}
.mode-btn.active { background: var(--accent); color: #fff; }
.icon-btn {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  width: 34px; height: 34px; border-radius: 8px; font-size: .9rem; cursor: pointer; flex-shrink: 0;
}

/* Workspace */
.workspace { flex: 1; overflow: hidden; position: relative; display: flex; }
.workspace > * { flex: 1; overflow: hidden; }

/* Code pane */
.code-pane { display: flex; flex-direction: column; height: 100%; position: relative; }
.file-tabs { display: flex; overflow-x: auto; background: var(--surface); border-bottom: 1px solid var(--border); scrollbar-width: none; }
.file-tabs::-webkit-scrollbar { display: none; }
.file-tab {
  background: transparent; border: none; border-right: 1px solid var(--border);
  color: var(--dim); font-size: .72rem; padding: .5rem .8rem; white-space: nowrap;
  font-family: 'JetBrains Mono', monospace; cursor: pointer;
}
.file-tab.active { color: var(--text); background: var(--surface2); box-shadow: inset 0 -2px 0 var(--accent); }
.file-tab.add { color: var(--accent); font-weight: bold; }

.editor-body { flex: 1; display: flex; overflow: hidden; font-family: 'JetBrains Mono', monospace; line-height: 1.5; }
.gutter {
  padding: .5rem .4rem; text-align: right; color: var(--dim); user-select: none;
  background: var(--surface); border-right: 1px solid var(--border); overflow: hidden;
  min-width: 2.5em; font-size: inherit;
}
.gutter div { line-height: 1.5; }
.code-wrap { flex: 1; position: relative; overflow: hidden; }
.hl, .code-input {
  position: absolute; inset: 0; margin: 0; padding: .5rem .6rem;
  font: inherit; line-height: 1.5; white-space: pre; overflow: auto;
  border: none; tab-size: 2;
}
.hl { color: var(--text); pointer-events: none; z-index: 1; }
.code-input {
  z-index: 2; background: transparent; color: transparent; caret-color: var(--accent2);
  resize: none; outline: none; -webkit-text-fill-color: transparent;
}
.tk-tag { color: #ff7edb; } .tk-attr { color: #72d5ff; } .tk-str { color: #a5e075; }
.tk-kw { color: #c792ea; font-weight: 500; }
[data-theme="light"] .tk-tag { color: #c026d3; } [data-theme="light"] .tk-attr { color: #0369a1; }
[data-theme="light"] .tk-str { color: #16a34a; } [data-theme="light"] .tk-kw { color: #7c3aed; }

.fmt-fab {
  position: absolute; bottom: 1rem; right: 1rem; z-index: 5;
  background: var(--accent); color: #fff; border: none; width: 46px; height: 46px;
  border-radius: 50%; font-family: 'JetBrains Mono'; font-size: .8rem; font-weight: bold;
  box-shadow: 0 6px 20px rgba(109,74,255,.4); cursor: pointer;
}

/* Preview */
.preview-pane { display: flex; flex-direction: column; height: 100%; background: var(--surface2); }
.preview-label { padding: .35rem .7rem; font-size: .7rem; color: var(--dim); background: var(--surface); border-bottom: 1px solid var(--border); }
.preview-frame, .design-frame { flex: 1; width: 100%; border: none; background: #fff; }

.split-view { display: flex; flex-direction: column; height: 100%; width: 100%; }
.split-top { flex: 1; min-height: 0; border-bottom: 2px solid var(--accent); }
.split-bot { flex: 1; min-height: 0; }

/* Design */
.design-pane { display: flex; flex-direction: column; height: 100%; }
.design-toolbar { display: flex; align-items: center; justify-content: space-between; padding: .4rem .7rem; background: var(--surface); border-bottom: 1px solid var(--border); font-size: .75rem; color: var(--dim); }
.insert-palette { display: flex; flex-wrap: wrap; gap: .3rem; padding: .5rem; background: var(--surface2); border-bottom: 1px solid var(--border); }
.ins-chip { background: var(--surface); border: 1px solid var(--border); color: var(--text); padding: .3rem .6rem; border-radius: 6px; font-size: .7rem; cursor: pointer; }
.ins-chip:active { background: var(--accent); color: #fff; }

/* Statusbar */
.statusbar { display: flex; gap: 1rem; padding: .3rem .7rem; background: var(--surface); border-top: 1px solid var(--border); font-size: .65rem; color: var(--dim); font-family: 'JetBrains Mono', monospace; overflow-x: auto; white-space: nowrap; }
.statusbar .ok { color: var(--ok); } .statusbar .dirty { color: var(--warn); }

/* Tabbar */
.tabbar { display: flex; background: var(--surface); border-top: 1px solid var(--border); }
.tab { flex: 1; background: transparent; border: none; color: var(--dim); padding: .45rem 0 .5rem; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; }
.tab.active { color: var(--accent2); }
.tab-icon { font-size: 1.1rem; }
.tab-label { font-size: .58rem; }

/* Panels */
.panel { height: 100%; overflow-y: auto; padding: 1rem; -webkit-overflow-scrolling: touch; }
.panel-head { display: flex; align-items: center; gap: .6rem; margin-bottom: 1rem; }
.panel-head h2 { margin: 0; font-size: 1.3rem; font-weight: 800; flex: 1; }
.back-btn { background: var(--surface2); border: 1px solid var(--border); color: var(--text); width: 32px; height: 32px; border-radius: 8px; font-size: 1rem; cursor: pointer; }
.mini-btn { background: var(--surface2); border: 1px solid var(--border); color: var(--text); padding: .4rem .7rem; border-radius: 8px; font-size: .75rem; cursor: pointer; margin: 2px; }
.mini-btn:active { background: var(--accent); color: #fff; }
.primary-btn { background: var(--accent); border: none; color: #fff; padding: .6rem 1.2rem; border-radius: 10px; font-weight: 700; cursor: pointer; }
.primary-btn:disabled { opacity: .5; }

/* Files */
.file-list { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1rem; }
.file-row { display: flex; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; position: relative; }
.file-row.active { border-color: var(--accent); }
.file-open { flex: 1; display: flex; align-items: center; gap: .5rem; background: transparent; border: none; padding: .7rem; text-align: left; font-family: 'JetBrains Mono', monospace; font-size: .8rem; cursor: pointer; }
.file-meta { margin-left: auto; color: var(--dim); font-size: .65rem; }
.lang-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.lang-html { background: #f97316; } .lang-css { background: #38bdf8; } .lang-js { background: #eab308; } .lang-json { background: #34d399; }
.row-menu { background: transparent; border: none; color: var(--dim); padding: .7rem; cursor: pointer; }
.row-actions { position: absolute; right: 0; top: 100%; z-index: 10; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; }
.row-actions button { background: transparent; border: none; color: var(--err); padding: .6rem 1rem; width: 100%; cursor: pointer; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; }
.stat-box { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: .8rem; display: flex; flex-direction: column; }
.stat-k { color: var(--dim); font-size: .7rem; } .stat-v { font-weight: 800; font-size: 1.1rem; }

/* Tools grid */
.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.tool-card { display: flex; flex-direction: column; gap: .2rem; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1rem; text-align: left; cursor: pointer; transition: transform .1s; }
.tool-card:active { transform: scale(.97); border-color: var(--accent); }
.tool-icon { font-size: 1.6rem; } .tool-name { font-weight: 700; } .tool-desc { font-size: .65rem; color: var(--dim); }

/* Results */
.score-ring { width: 90px; height: 90px; border-radius: 50%; margin: 0 auto 1rem; display: flex; flex-direction: column; align-items: center; justify-content: center; background: conic-gradient(var(--accent) calc(var(--score)*1%), var(--surface2) 0); position: relative; }
.score-ring::after { content: ''; position: absolute; inset: 8px; border-radius: 50%; background: var(--bg); }
.score-ring span { position: relative; z-index: 1; font-size: 1.6rem; font-weight: 800; }
.score-ring small { position: relative; z-index: 1; font-size: .6rem; color: var(--dim); }
.all-good { text-align: center; padding: 2rem; color: var(--ok); font-weight: 600; }
.issue-cat { margin-bottom: 1rem; }
.issue-cat h4 { margin: .5rem 0; color: var(--dim); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.issue-card { display: flex; gap: .6rem; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: .7rem; margin-bottom: .4rem; }
.issue-card p { margin: 0; font-size: .85rem; } .issue-card small { color: var(--dim); font-size: .7rem; }
.sev-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 4px; flex-shrink: 0; }
.sev-error .sev-dot { background: var(--err); } .sev-warn .sev-dot { background: var(--warn); } .sev-info .sev-dot { background: var(--info); }

/* Perf */
.metric-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; margin-bottom: 1rem; }
.metric { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: .8rem; text-align: center; }
.metric b { display: block; font-size: 1.3rem; color: var(--accent2); } .metric span { font-size: .65rem; color: var(--dim); }
.bar-chart { display: flex; flex-direction: column; gap: .5rem; }
.bar-item { display: flex; align-items: center; gap: .5rem; }
.bar-label { width: 40px; font-size: .7rem; font-family: 'JetBrains Mono'; }
.bar-track { flex: 1; height: 14px; background: var(--surface2); border-radius: 7px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 7px; transition: width .4s; }
.bar-val { width: 60px; text-align: right; font-size: .65rem; color: var(--dim); font-family: 'JetBrains Mono'; }

/* Network */
.net-list { display: flex; flex-direction: column; gap: .5rem; }
.net-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: .7rem; }
.net-top { display: flex; justify-content: space-between; margin-bottom: .3rem; }
.net-method { font-family: 'JetBrains Mono'; font-size: .7rem; color: var(--ok); font-weight: 700; }
.net-status { font-size: .7rem; color: var(--dim); }
.net-url { font-family: 'JetBrains Mono'; font-size: .72rem; word-break: break-all; color: var(--accent2); }
.net-type { font-size: .6rem; color: var(--dim); text-transform: uppercase; }

/* API */
.api-form { display: flex; flex-direction: column; gap: .6rem; margin-bottom: 1rem; }
.api-row { display: flex; gap: .5rem; }
.api-row select { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: .5rem; font-family: 'JetBrains Mono'; font-size: .75rem; }
.api-url, .api-body, .snip-in { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .6rem; color: var(--text); font-family: 'JetBrains Mono'; font-size: .78rem; width: 100%; }
.api-body { min-height: 70px; resize: vertical; }
.api-resp { border-top: 1px solid var(--border); padding-top: 1rem; }
.resp-meta { display: flex; gap: 1rem; margin-bottom: .5rem; font-family: 'JetBrains Mono'; font-size: .8rem; }
.resp-status { font-weight: 700; padding: 2px 8px; border-radius: 6px; }
.status-ok { background: rgba(52,211,153,.2); color: var(--ok); } .status-err { background: rgba(248,113,113,.2); color: var(--err); }
.resp-body { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .7rem; font-family: 'JetBrains Mono'; font-size: .72rem; overflow-x: auto; white-space: pre-wrap; word-break: break-all; max-height: 300px; overflow-y: auto; }

/* Assets */
.upload-zone { display: block; text-align: center; padding: 1.5rem; border: 2px dashed var(--border); border-radius: 14px; color: var(--dim); margin-bottom: 1rem; cursor: pointer; }
.upload-zone:active { border-color: var(--accent); color: var(--accent2); }
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: .6rem; }
.asset-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.asset-card img { width: 100%; height: 80px; object-fit: cover; cursor: pointer; }
.asset-file { height: 80px; display: flex; align-items: center; justify-content: center; font-size: 2rem; background: var(--surface2); cursor: pointer; }
.asset-name { display: block; font-size: .6rem; padding: .3rem; color: var(--dim); word-break: break-all; }
.asset-actions { display: flex; border-top: 1px solid var(--border); }
.asset-actions button { flex: 1; background: transparent; border: none; color: var(--text); padding: .4rem; font-size: .65rem; cursor: pointer; border-right: 1px solid var(--border); }
.preview-modal { background: var(--surface); border-radius: 16px; padding: 1.5rem; max-width: 90vw; max-height: 85vh; text-align: center; }
.preview-modal img { max-width: 100%; max-height: 50vh; border-radius: 10px; }

/* Sheets & overlays */
.sheet-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 50; display: flex; align-items: flex-end; justify-content: center; backdrop-filter: blur(2px); }
.prop-sheet { background: var(--surface); width: 100%; max-width: 500px; border-radius: 20px 20px 0 0; padding: 1rem 1.2rem 1.5rem; display: flex; flex-direction: column; gap: .7rem; animation: slideUp .25s ease; }
@keyframes slideUp { from { transform: translateY(100%); } }
.sheet-handle { width: 40px; height: 4px; background: var(--border); border-radius: 2px; margin: 0 auto .5rem; }
.prop-sheet h3 { margin: 0; font-family: 'JetBrains Mono'; font-size: .9rem; }
.prop-sheet label { display: flex; flex-direction: column; gap: .3rem; font-size: .75rem; color: var(--dim); }
.prop-sheet input[type=text], .prop-sheet input:not([type]) { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: .5rem; color: var(--text); }
.prop-sheet input:not([type=color]):not([type=range]) { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: .5rem; color: var(--text); }
.prop-row { display: flex; gap: 1rem; }
.prop-row label { flex-direction: row; align-items: center; gap: .5rem; }

/* Palette */
.sheet-overlay:has(.palette) { align-items: flex-start; padding-top: 15vh; }
.palette { background: var(--surface); width: 90%; max-width: 480px; border-radius: 14px; overflow: hidden; border: 1px solid var(--border); box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.palette-input { width: 100%; background: var(--surface); border: none; border-bottom: 1px solid var(--border); padding: 1rem; font-size: 1rem; outline: none; }
.palette-list { max-height: 50vh; overflow-y: auto; }
.palette-item { display: block; width: 100%; text-align: left; background: transparent; border: none; padding: .8rem 1rem; cursor: pointer; font-size: .9rem; }
.palette-item:active { background: var(--accent); color: #fff; }
.palette-empty { padding: 1rem; text-align: center; color: var(--dim); }

/* Settings */
.settings-block { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1rem; margin-bottom: 1rem; }
.settings-block h4 { margin: 0 0 .7rem; font-size: .9rem; }
.theme-chips, .btn-row { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { background: var(--surface2); border: 1px solid var(--border); color: var(--text); padding: .5rem .9rem; border-radius: 20px; font-size: .75rem; cursor: pointer; }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.zoom-row { display: flex; align-items: center; gap: .8rem; }
.tpl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: .7rem; }
.tpl-card { background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 1rem .5rem; font-size: .8rem; font-weight: 600; cursor: pointer; }
.tpl-card:active { background: var(--accent); color: #fff; }
.snip-in { margin-bottom: .5rem; } .snip-in textarea, textarea.snip-in { min-height: 60px; resize: vertical; }
.snip-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .5rem 0; border-top: 1px solid var(--border); font-size: .8rem; }

.app-footer { text-align: center; padding: 1.5rem 0; color: var(--dim); font-size: .75rem; }
.app-footer a { color: var(--accent2); text-decoration: none; font-weight: 700; }

/* Toasts */
.toasts { position: fixed; bottom: 70px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: .4rem; width: 90%; max-width: 400px; }
.toast { padding: .7rem 1rem; border-radius: 10px; font-size: .8rem; font-weight: 600; color: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.3); animation: toastIn .25s ease; cursor: pointer; }
@keyframes toastIn { from { transform: translateY(20px); opacity: 0; } }
.toast-success { background: var(--ok); color: #052e1b; }
.toast-warn { background: var(--warn); color: #422006; }
.toast-error { background: var(--err); color: #450a0a; }
.toast-info { background: var(--info); color: #082f49; }

/* Desktop: split becomes side-by-side */
@media (min-width: 900px) {
  .split-view { flex-direction: row; }
  .split-top { border-bottom: none; border-right: 2px solid var(--accent); }
}
</styles.css>