:root {
  --bg: #05070d; --bg2: #0a0f1c;
  --glass: rgba(16, 22, 38, .62); --glass-2: rgba(255,255,255,.035);
  --line: rgba(148, 163, 255, .12); --line-2: rgba(148, 163, 255, .2);
  --text: #e8ecf6; --muted: #8a93ab; --dim: #5b647c;
  --cyan: #22d3ee; --violet: #8b5cf6; --emerald: #34d399; --amber: #fbbf24; --rose: #fb7185;
  --grad: linear-gradient(135deg, #22d3ee 0%, #6366f1 55%, #8b5cf6 100%);
  --r: 14px; --mono: 'JetBrains Mono', ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: Inter, system-ui, sans-serif; font-size: 14px; color: var(--text);
  background: radial-gradient(1200px 600px at 80% -10%, #1a1240 0%, transparent 60%),
              radial-gradient(900px 500px at -10% 110%, #052a36 0%, transparent 55%), var(--bg);
  display: flex; flex-direction: column; overflow: hidden; -webkit-font-smoothing: antialiased;
}
.bg-glow { position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 44px 44px; opacity: .25;
  mask-image: radial-gradient(ellipse at center, #000 20%, transparent 75%); }
.glass { background: var(--glass); border: 1px solid var(--line); border-radius: var(--r);
  backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 10px 40px -12px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.04); }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 4px 0 12px; }

/* top bar */
.topbar { position: relative; z-index: 2; display: flex; align-items: center; gap: 14px; padding: 12px 18px; }
.brand { display: flex; align-items: center; gap: 10px; }
.logo { width: 30px; height: 30px; filter: drop-shadow(0 0 10px rgba(34,211,238,.35)); }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text b { font-size: 15px; letter-spacing: .2px; }
.brand-text span { font-size: 10.5px; letter-spacing: 2.6px; text-transform: uppercase; color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--glass-2); font-size: 12px; color: var(--muted);
  max-width: 46vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill span { overflow: hidden; text-overflow: ellipsis; }
.pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); flex: none; }
.pill.running i { background: var(--cyan); box-shadow: 0 0 0 0 rgba(34,211,238,.6); animation: ping 1.4s infinite; }
.pill.running { color: var(--text); }
.pill.done i { background: var(--emerald); box-shadow: 0 0 10px var(--emerald); }
.pill.error i { background: var(--rose); } .pill.error { color: var(--rose); }
@keyframes ping { 70% { box-shadow: 0 0 0 8px rgba(34,211,238,0); } 100% { box-shadow: 0 0 0 0 rgba(34,211,238,0); } }
.top-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.progress { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; overflow: hidden; opacity: 0; transition: opacity .3s; }
.progress.on { opacity: 1; }
.progress::after { content: ""; position: absolute; inset: 0; width: 40%; background: var(--grad);
  animation: slide 1.3s ease-in-out infinite; box-shadow: 0 0 12px var(--cyan); }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

/* controls */
button { font: inherit; cursor: pointer; color: var(--text); border-radius: 10px; transition: all .18s ease; }
button.primary { display: inline-flex; align-items: center; gap: 8px; border: 0; padding: 10px 18px; font-weight: 600;
  background: var(--grad); color: #fff; box-shadow: 0 6px 24px -8px rgba(99,102,241,.8), inset 0 1px 0 rgba(255,255,255,.25); }
button.primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
button.primary:disabled { opacity: .55; transform: none; cursor: default; }
button.primary svg { width: 16px; height: 16px; }
button.ghost { background: var(--glass-2); border: 1px solid var(--line-2); padding: 9px 14px; }
button.ghost:hover { border-color: rgba(34,211,238,.45); background: rgba(34,211,238,.06); }
button.sm { padding: 7px 12px; font-size: 12.5px; border-radius: 9px; }
button.full { width: 100%; margin-top: 10px; justify-content: center; }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; padding: 0;
  background: var(--glass-2); border: 1px solid var(--line); }
.icon-btn:hover { border-color: rgba(34,211,238,.45); }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn svg { width: 16px; height: 16px; }
.ghost-select, input, textarea { font: inherit; color: var(--text); background: rgba(5,8,16,.55);
  border: 1px solid var(--line); border-radius: 10px; outline: none; transition: border-color .2s, box-shadow .2s; }
input:focus, textarea:focus, .ghost-select:focus { border-color: rgba(34,211,238,.55); box-shadow: 0 0 0 3px rgba(34,211,238,.12); }
.ghost-select { height: 34px; padding: 0 10px; font-size: 12.5px; max-width: 180px; color: var(--muted); }

/* composer */
.composer { position: relative; z-index: 1; margin: 0 18px 12px; padding: 12px; }
#context { width: 100%; resize: none; border: 0; background: transparent; padding: 6px 8px; font-size: 15px; line-height: 1.5; box-shadow: none !important; }
#context::placeholder { color: var(--dim); }
.composer-row { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-top: 6px; }
.examples { display: flex; gap: 6px; flex-wrap: wrap; min-width: 0; }
.examples button { font-size: 12px; padding: 5px 10px; border-radius: 999px; background: transparent;
  border: 1px solid var(--line); color: var(--muted); }
.examples button:hover { color: var(--text); border-color: var(--line-2); }
.knobs { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.knob { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1px; padding-left: 10px; border: 1px solid var(--line); border-radius: 10px; height: 38px; }
.knob input { width: 46px; height: 36px; border: 0; background: transparent; font-family: var(--mono); font-size: 13px; text-align: center; box-shadow: none !important; }
.composer-mini { display: flex; align-items: center; gap: 10px; }
.composer-mini span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); padding-left: 6px; }

/* workspace */
.workspace { position: relative; z-index: 1; flex: 1; min-height: 0; display: flex; gap: 12px; padding: 0 18px 18px; }
.canvas { position: relative; flex: 1; min-width: 0; overflow: hidden; }
#cy { position: absolute; inset: 0; }
.empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px; pointer-events: none; }
.empty h2 { margin: 22px 0 8px; font-size: 20px; font-weight: 600; letter-spacing: -.2px; }
.empty p { margin: 0; max-width: 420px; color: var(--muted); line-height: 1.6; }
.orb { width: 92px; height: 92px; border-radius: 50%; background: var(--grad); filter: blur(.5px);
  box-shadow: 0 0 60px rgba(99,102,241,.55), inset 0 0 30px rgba(255,255,255,.25); animation: breathe 4s ease-in-out infinite; opacity: .9; }
@keyframes breathe { 50% { transform: scale(1.06); box-shadow: 0 0 90px rgba(34,211,238,.5), inset 0 0 30px rgba(255,255,255,.3); } }
.legend { position: absolute; left: 12px; bottom: 12px; display: flex; gap: 12px; flex-wrap: wrap; font-size: 11px; color: var(--muted);
  padding: 7px 12px; border-radius: 10px; background: rgba(5,8,16,.6); border: 1px solid var(--line); }
.legend:empty { display: none; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 8px; height: 8px; border-radius: 3px; }
.zoom { position: absolute; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 6px; }

/* panel */
.panel { width: 380px; flex: none; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.sheet-handle { display: none; }
.tabs { display: flex; gap: 4px; padding: 8px; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; background: transparent; border: 0; padding: 8px 0; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.tabs button.active { color: var(--text); background: rgba(255,255,255,.06); box-shadow: inset 0 -2px 0 var(--cyan); }
.tab-body { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 16px; }
.pane { display: none; } .pane.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }
h3.section { font-size: 11px; letter-spacing: 1.6px; text-transform: uppercase; color: var(--muted); margin: 18px 0 6px; font-weight: 600; }
h3.section:first-child { margin-top: 0; }
.type-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 10.5px; letter-spacing: 1.4px; text-transform: uppercase;
  padding: 4px 9px; border-radius: 999px; border: 1px solid currentColor; }
.type-tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; }
#np-title { font-size: 18px; line-height: 1.3; margin: 12px 0 6px; font-weight: 600; letter-spacing: -.2px; }
#np-desc { color: #b9c1d6; line-height: 1.6; margin: 0 0 14px; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.kpi { padding: 10px; border-radius: 11px; background: var(--glass-2); border: 1px solid var(--line); }
.kpi small { display: block; font-size: 10px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); }
.kpi b { font-family: var(--mono); font-size: 18px; font-weight: 500; }
.meters { display: grid; gap: 9px; margin-bottom: 6px; }
.meter { display: grid; grid-template-columns: 96px 1fr 36px; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.meter .track { height: 5px; border-radius: 99px; background: rgba(255,255,255,.06); overflow: hidden; }
.meter .fill { height: 100%; border-radius: 99px; background: var(--grad); }
.meter.bad .fill { background: linear-gradient(90deg, #f59e0b, #fb7185); }
.meter.text { grid-template-columns: 96px 1fr; }
.meter.text b { white-space: normal; }
.meter b { font-family: var(--mono); font-weight: 500; color: var(--text); text-align: right; }
#np-extra h4 { font-size: 11px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--muted); margin: 18px 0 6px; font-weight: 600; }
#np-extra p { color: #b9c1d6; line-height: 1.6; margin: 0; }
.list, #np-extra ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.list li, #np-extra li { position: relative; padding: 8px 10px 8px 24px; border-radius: 9px; background: var(--glass-2);
  border: 1px solid var(--line); color: #c3cadc; line-height: 1.45; font-size: 13px; }
.list li::before, #np-extra li::before { content: ""; position: absolute; left: 10px; top: 14px; width: 5px; height: 5px; border-radius: 50%; background: var(--cyan); }
.panel-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; position: sticky; bottom: -16px;
  padding: 12px 0 16px; background: #0d1222; border-top: 1px solid var(--line); margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; }
.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; min-width: 0; padding: 9px 12px; font-size: 13px; }
#weights label { display: grid; grid-template-columns: 110px 1fr 30px; gap: 10px; align-items: center; margin: 10px 0;
  font-size: 12.5px; color: #c3cadc; text-transform: capitalize; }
#weights output { font-family: var(--mono); font-size: 12px; color: var(--muted); text-align: right; }
input[type=range] { -webkit-appearance: none; appearance: none; height: 4px; padding: 0; border: 0; border-radius: 99px;
  background: rgba(255,255,255,.08); box-shadow: none !important; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 0 3px rgba(34,211,238,.35), 0 0 12px rgba(34,211,238,.6); }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px rgba(34,211,238,.35); }

/* recommendation cards */
.rec { position: relative; padding: 14px; border-radius: 12px; background: var(--glass-2); border: 1px solid var(--line);
  margin-bottom: 10px; cursor: pointer; transition: border-color .2s, transform .2s; overflow: hidden; }
.rec::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent, var(--cyan)); box-shadow: 0 0 14px var(--accent, var(--cyan)); }
.rec:hover, .rec.active { border-color: var(--line-2); transform: translateY(-1px); }
.rec.active { background: rgba(34,211,238,.05); }
.rec .kind { font-size: 10.5px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--accent, var(--cyan)); font-weight: 600; }
.rec h4 { margin: 6px 0; font-size: 14.5px; line-height: 1.35; font-weight: 600; }
.rec p { margin: 6px 0 0; color: #b9c1d6; font-size: 13px; line-height: 1.55; }
.rec .risk { color: #e7b9a8; }
.rec .next { display: flex; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--emerald); font-size: 12.5px; }
.rec .next::before { content: "→"; }

/* mobile */
@media (max-width: 860px) {
  .topbar { padding: 10px 12px; gap: 10px; }
  .brand-text { display: none; }
  .pill { max-width: 52vw; }
  .legend { font-size: 10px; padding: 6px 10px; }
  .ghost-select { max-width: 96px; }
  .composer { margin: 0 12px 10px; padding: 10px; }
  .examples { display: none; }
  .knobs { width: 100%; }
  .knobs button.primary { margin-left: auto; }
  .workspace { padding: 0 12px 12px; }
  .canvas { border-radius: 12px; }
  .legend { left: 8px; right: 8px; bottom: 8px; gap: 10px; justify-content: center; }
  .zoom { right: 8px; top: 8px; bottom: auto !important; }
  .panel { position: fixed; left: 0; right: 0; bottom: 0; width: auto; z-index: 5; border-radius: 18px 18px 0 0;
    height: 56vh; transform: translateY(calc(100% - 94px)); transition: transform .35s cubic-bezier(.2,.8,.2,1);
    background: rgba(10,14,26,.92); padding-bottom: env(safe-area-inset-bottom); }
  .panel.open { transform: none; }
  .sheet-handle { display: grid; place-items: center; height: 22px; background: transparent; border: 0; padding: 0; }
  .sheet-handle i { width: 38px; height: 4px; border-radius: 99px; background: var(--line-2); }
  .tabs { padding-top: 0; }
  .workspace { padding-bottom: 104px; }
}
