:root{
  --bg:#0f1115; --panel:#161a24; --muted:#8c95a9; --text:#e7eaf1; --accent:#5bd0ff; --accent-2:#a88cff; --good:#5bd39a; --bad:#ff7d73; --border:#283041;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --code-size: 14px;
}
*{box-sizing:border-box}
html,body{height:100%}
body{margin:0; background:var(--bg); color:var(--text); font:14px/1.55 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial; -webkit-font-smoothing:antialiased; text-rendering:optimizeLegibility}

.topbar{display:grid; grid-template-columns:auto 1fr auto; align-items:center; gap:12px; padding:10px 12px; background:linear-gradient(90deg,#131826,#111523); border-bottom:1px solid var(--border); position:sticky; top:0; z-index:10; box-shadow:0 2px 10px rgba(0,0,0,.35)}
.topbar .left,.topbar .center,.topbar .right{display:flex; align-items:center; gap:10px}
.topbar select,.topbar input,.topbar button{background:#0b0f18; color:var(--text); border:1px solid var(--border); padding:8px 10px; border-radius:8px}
.topbar select,.topbar input,.topbar button{background:var(--panel)}
.topbar input{min-width:220px}
.icon-btn{display:inline-flex; align-items:center; justify-content:center; width:36px; height:36px; padding:0}
.topbar .primary{background:var(--accent); color:#08222e; border-color:transparent}
.topbar .primary{box-shadow:0 4px 12px rgba(91,208,255,.25)}
.topbar .accent{background:linear-gradient(180deg,#5bd0ff,#3dbef4); color:#071119; border:0}
.topbar .ghost{background:#0b0f18}
.topbar .sep{width:1px; height:22px; background:var(--border)}
.timer-chip{background:var(--panel); border:1px solid var(--border); padding:6px 10px; border-radius:999px}

.layout{display:grid; grid-template-columns: 1fr; gap:12px; padding:12px; height:calc(100vh - 56px)}
.right-pane{min-height:0; display:flex; flex-direction:column; gap:12px}

.io{background:var(--panel); border:1px solid var(--border); border-radius:10px; padding:12px; display:flex; flex-direction:column; gap:8px}
.io label{color:var(--muted)}
.mono{font-family:var(--mono)}
.note{color:var(--muted); font-size:12px}
.output{border:1px solid var(--border); border-radius:8px; overflow:hidden}
.output .toolbar{display:flex; justify-content:space-between; align-items:center; padding:6px 8px; background:var(--panel); border-bottom:1px solid var(--border)}
#output{margin:0; padding:12px; max-height:260px; overflow:auto; line-height:1.5; font-size:var(--code-size)}

.editor-wrap{position:relative; display:grid; grid-template-columns:60px 1fr; background:var(--panel); border:1px solid var(--border); border-radius:10px; overflow:hidden; min-height:0; flex:1; box-shadow:0 6px 18px rgba(0,0,0,.3)}
.gutter{background:var(--panel); color:#9aa0ae; padding:10px 8px; text-align:right; user-select:none; overflow:auto; white-space:pre; font-size:var(--code-size); line-height:1.65}
.editor{background:transparent; border:0; color:var(--text); padding:12px; resize:none; outline:none; overflow:auto; font-family:var(--mono); font-size:var(--code-size); line-height:1.65}
.hints{display:flex; align-items:center; justify-content:space-between; color:var(--muted); font-size:12px}
.status{color:#cfd6e6; font-weight:500}

.panel{position:fixed; right:12px; top:64px; bottom:12px; width:380px; background:var(--panel); border:1px solid var(--border); border-radius:10px; display:flex; flex-direction:column}
.panel.hidden{display:none}
.panel-header{display:flex; justify-content:space-between; align-items:center; padding:10px; border-bottom:1px solid var(--border)}
.panel-actions{display:flex; align-items:center; gap:8px}
.panel-body{padding:10px; display:flex; flex-direction:column; gap:10px; overflow:auto}
.snippets{list-style:none; padding:0; margin:0; display:flex; flex-direction:column; gap:8px}
.snippet-item{display:flex; justify-content:space-between; align-items:center; padding:8px; border:1px solid var(--border); border-radius:8px; background:#0b0f18}
.snippet-item .title{font-weight:600}
.snippet-item .sub{color:var(--muted); font-size:12px}
.import-label{display:inline-flex; gap:8px; align-items:center; border:1px dashed var(--border); border-radius:8px; padding:4px 8px}
.import-label input{display:none}

@media (max-width: 1024px){
  .layout{grid-template-columns:1fr; height:auto}
}

/* Analysis charts */
.analysis{margin-top:10px; border:1px solid var(--border); border-radius:8px; overflow:hidden; background:#0b0f18}
.analysis-header{padding:10px 12px; border-bottom:1px solid var(--border); color:#cfd6e6; letter-spacing:.2px}
.analysis-header{display:flex; align-items:center; justify-content:space-between}
.analysis-header .tools{display:flex; align-items:center; gap:6px}
.metrics{display:grid; grid-template-columns:1fr 1fr; gap:10px; padding:10px}
.metric{background:#0c1018; border:1px solid var(--border); border-radius:8px; padding:12px}
.metric-head{display:flex; align-items:center; gap:8px; color:#9aa0ae; font-size:12px}
.metric-icon{font-size:14px}
.metric-value{margin-top:6px; font-size:32px; font-weight:800; background:linear-gradient(180deg, var(--text), var(--accent)); -webkit-background-clip:text; background-clip:text; color:transparent}
.metric-sub{margin-top:4px; color:#9aa0ae; font-size:13px}
.history{padding:10px}
.history-title{margin:8px 0 6px; color:#cfd6e6; font-weight:600}
.history-chart{display:grid; grid-template-columns:40px 1fr; gap:8px; border:1px dashed var(--border); border-radius:8px; padding:10px}
.y-axis{display:flex; flex-direction:column; justify-content:space-between; color:#9aa0ae; font-size:12px}
.bars{display:flex; align-items:flex-end; gap:16px; height:160px}
.bar{width:48px; background:linear-gradient(180deg, #5b84ff, #3d6df4); border:1px solid #2a3e8d; border-radius:6px 6px 0 0; position:relative}
.bar-label{position:absolute; bottom:-18px; left:50%; transform:translateX(-50%); font-size:12px; color:#9aa0ae}
.hidden{display:none}
.plain{padding:10px; white-space:pre-wrap; color:#d8e2ff}
.theme-light{ --bg:#f7f8fb; --panel:#ffffff; --muted:#5b647a; --text:#0b0d12; --accent:#3b82f6; --accent-2:#06b6d4; --good:#16a34a; --bad:#ef4444; --border:#e5e7eb; }
