/* MORDAS LAB – interface. Near-black surface, restrained violet accent, compact data density. */
:root {
  --bg: #060608; --panel: #0d0d12; --panel-2: #121219; --raise: #171720; --line: #1f1f2a; --line-2: #2c2c3a;
  --text: #ececf2; --soft: #b9b9c8; --muted: #85859a; --dim: #5a5a6e;
  --violet: #8f7df7; --violet-2: #b8adff; --violet-bg: #17142b; --violet-line: #3a3270;
  --good: #46d39a; --warn: #e9b44c; --bad: #f2777a; --info: #74c7ec;
  --r: 10px; --r-s: 6px;
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
body { margin: 0; background: var(--bg); color: var(--text); font: 13px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--violet-2); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--mono); font-size: 12px; }
pre { margin: 0; white-space: pre-wrap; word-break: break-word; }
[hidden] { display: none !important; }
::selection { background: #3d3480; color: #fff; }
:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; border-radius: 4px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #262633; border-radius: 6px; border: 2px solid var(--bg); }

.muted { color: var(--muted); } .dim { color: var(--dim); } .small { font-size: 11.5px; } .right { text-align: right; }
.good { color: var(--good); } .warn { color: var(--warn); } .bad { color: var(--bad); } .violet { color: var(--violet-2); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; } .spread { justify-content: space-between; }
.stack { display: grid; gap: 14px; } .grow { flex: 1; min-width: 0; } .nowrap { white-space: nowrap; }

/* layout */
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--panel);
  border-right: 1px solid var(--line); z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px 14px; }
.brand strong { display: block; letter-spacing: .14em; font-size: 13px; font-weight: 650; }
.brand small { display: block; color: var(--muted); font-size: 10.5px; letter-spacing: .02em; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; flex: none;
  background: conic-gradient(from 210deg, #2a2360, var(--violet) 40%, #e8e4ff 55%, #3a3270 75%, #2a2360);
  box-shadow: 0 0 0 1px #3a3270, 0 0 18px -4px var(--violet); }
#nav { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.nav-group { margin: 12px 8px 4px; font-size: 10px; letter-spacing: .14em; color: var(--dim); font-weight: 600; }
.nav-link { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; border-radius: var(--r-s);
  color: var(--soft); cursor: pointer; border: 1px solid transparent; }
.nav-link:hover { background: var(--raise); color: var(--text); text-decoration: none; }
.nav-link.on { background: var(--violet-bg); color: #fff; border-color: var(--violet-line); }
.nav-link .tag { font-size: 9.5px; color: var(--dim); letter-spacing: .06em; }
.side-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px;
  border-top: 1px solid var(--line); }
.side-foot span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 22px;
  background: rgba(6, 6, 8, .88); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top h1 { font-size: 16px; font-weight: 600; letter-spacing: .01em; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
#menu { display: none; }
#view { padding: 18px 22px 60px; display: grid; gap: 16px; align-content: start; outline: none; }

/* controls */
.btn { font: inherit; font-weight: 550; color: var(--text); background: var(--raise); border: 1px solid var(--line-2);
  border-radius: var(--r-s); padding: 6px 12px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #45455a; background: #1c1c27; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--violet); border-color: var(--violet); color: #0b0918; }
.btn.primary:hover { background: var(--violet-2); border-color: var(--violet-2); }
.btn.danger { color: var(--bad); border-color: #5a2a30; background: #1a0f12; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--soft); }
.btn.small { padding: 3px 9px; font-size: 11.5px; } .btn.icon { padding: 4px 9px; }
input, select, textarea { font: inherit; color: var(--text); background: #0a0a0f; border: 1px solid var(--line-2);
  border-radius: var(--r-s); padding: 6px 9px; width: 100%; }
textarea { min-height: 84px; resize: vertical; font-family: var(--font); }
textarea.code { font-family: var(--mono); font-size: 12px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px rgba(143, 125, 247, .16); }
input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--violet); }
label { display: grid; gap: 4px; color: var(--soft); font-size: 12px; }
label.check { display: flex; align-items: center; gap: 8px; }
.form { display: grid; gap: 12px; } .form .cols { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.form h4 { font-size: 10.5px; letter-spacing: .14em; color: var(--violet-2); margin-top: 6px; padding-bottom: 5px; border-bottom: 1px solid var(--line); }
.hint { color: var(--dim); font-size: 11px; }

/* cards and metrics */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 14px;
  border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--soft); font-weight: 600; }
.card-head .sub { color: var(--dim); font-size: 11px; }
.card-body { padding: 14px; display: grid; gap: 12px; }
.card-body.flush { padding: 0; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.metrics { display: grid; gap: 1px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); background: var(--line);
  border-radius: var(--r-s); overflow: hidden; border: 1px solid var(--line); }
.metric { background: var(--panel-2); padding: 10px 12px; min-width: 0; }
.metric .k { color: var(--muted); font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; }
.metric .v { font-size: 19px; font-weight: 600; letter-spacing: -.01em; margin-top: 2px; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.metric .v.text { font-size: 13.5px; font-weight: 550; }
.metric .v.na { font-size: 12.5px; font-weight: 500; color: var(--dim); font-style: italic; }
.metric .u { font-size: 11px; color: var(--muted); font-weight: 500; margin-left: 3px; }
.metric .s { color: var(--dim); font-size: 10.5px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.big { font-size: 40px; font-weight: 650; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.big small { font-size: 13px; color: var(--muted); font-weight: 500; letter-spacing: 0; }

/* pills */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 99px; font-size: 11px; font-weight: 550;
  border: 1px solid var(--line-2); color: var(--soft); background: var(--panel-2); white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--dim); }
.pill.good { color: var(--good); border-color: #1d4a3a; background: #0b1814; } .pill.good::before { background: var(--good); box-shadow: 0 0 8px var(--good); }
.pill.warn { color: var(--warn); border-color: #4d3d18; background: #17130a; } .pill.warn::before { background: var(--warn); }
.pill.bad { color: var(--bad); border-color: #55262b; background: #180d0f; } .pill.bad::before { background: var(--bad); }
.pill.violet { color: var(--violet-2); border-color: var(--violet-line); background: var(--violet-bg); } .pill.violet::before { background: var(--violet); }
.pill.plain::before { display: none; }
.count { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--violet-bg); color: var(--violet-2); font-size: 10.5px; text-align: center; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th { text-align: left; font-weight: 600; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel); position: sticky; top: 0; }
td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--panel-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 22px 14px; text-align: center; color: var(--dim); }
.kv { display: grid; grid-template-columns: minmax(130px, 34%) 1fr; gap: 6px 14px; font-size: 12.5px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }

/* bars and charts */
.bar-row { display: grid; grid-template-columns: minmax(120px, 190px) 1fr 62px; gap: 10px; align-items: center; font-size: 12px; }
.bar { height: 7px; background: #191923; border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #5d4fd1, var(--violet-2)); border-radius: 4px; }
.bar.na i { background: none; } .bar-row .val { text-align: right; font-variant-numeric: tabular-nums; }
.chart { position: relative; } .chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis { stroke: var(--line); stroke-width: 1; } .chart .gridline { stroke: #16161e; stroke-width: 1; }
.chart text { fill: var(--dim); font: 10px var(--font); }
.chart .cross { stroke: var(--violet-line); stroke-width: 1; }
.chart-tip { position: absolute; top: 0; right: 0; background: var(--raise); border: 1px solid var(--line-2); border-radius: var(--r-s);
  padding: 4px 8px; font-size: 11px; pointer-events: none; white-space: nowrap; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11px; color: var(--muted); }
.legend i { display: inline-block; width: 9px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.stages { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.stages span { height: 6px; border-radius: 3px; background: #1b1b26; } .stages span.done { background: var(--violet); }

/* notices */
.notice { padding: 10px 12px; border-radius: var(--r-s); border: 1px solid var(--line-2); background: var(--panel-2); color: var(--soft); font-size: 12.5px; }
.notice.bad { border-color: #55262b; background: #180d0f; color: #ffc9cb; }
.notice.warn { border-color: #4d3d18; background: #17130a; color: #f3dca6; }
.notice.violet { border-color: var(--violet-line); background: var(--violet-bg); color: #dcd6ff; }
.notice.good { border-color: #1d4a3a; background: #0b1814; color: #bdf0dc; }
.planned { border: 1px dashed var(--line-2); border-radius: var(--r); padding: 18px; background: repeating-linear-gradient(135deg, #0c0c11, #0c0c11 12px, #0e0e14 12px, #0e0e14 24px); }
.answer { background: #0a0a0f; border: 1px solid var(--line); border-radius: var(--r-s); padding: 12px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; }
.drop { border: 1px dashed var(--violet-line); border-radius: var(--r); padding: 22px; text-align: center; color: var(--soft); background: #0c0b16; cursor: pointer; }
.drop.over { background: var(--violet-bg); border-color: var(--violet); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding: 0 6px; }
.tab { padding: 8px 12px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; background: none; border-top: 0; border-left: 0; border-right: 0; font: inherit; }
.tab.on { color: #fff; border-bottom-color: var(--violet); }

/* overlays */
.modal-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .66); z-index: 60; display: grid; place-items: start center; padding: 6vh 16px 16px; overflow-y: auto; }
.modal { width: min(760px, 100%); background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: 0 30px 80px #000; }
.modal.wide { width: min(1080px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 14px; font-weight: 600; } .modal-body { padding: 16px; display: grid; gap: 14px; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100%); background: var(--panel); border-left: 1px solid var(--line-2);
  z-index: 50; overflow-y: auto; box-shadow: -20px 0 60px #000; }
.task { padding: 11px 14px; border-bottom: 1px solid var(--line); display: grid; gap: 6px; }
.progress { height: 4px; background: #191923; border-radius: 2px; overflow: hidden; } .progress i { display: block; height: 100%; background: var(--violet); }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 80; display: grid; gap: 8px; width: min(380px, calc(100% - 32px)); }
.toast { background: var(--violet-bg); border: 1px solid var(--violet-line); border-radius: var(--r-s); padding: 9px 12px; box-shadow: 0 10px 30px #000; }
.toast.bad { background: #180d0f; border-color: #55262b; color: #ffc9cb; } .toast.good { background: #0b1814; border-color: #1d4a3a; color: #bdf0dc; }
.toast.warn { background: #17130a; border-color: #4d3d18; color: #f3dca6; }

/* auth pages */
body.auth { display: grid; place-items: center; min-height: 100vh; padding: 20px;
  background: radial-gradient(900px 500px at 50% -10%, #17142b 0%, var(--bg) 60%); }
.auth-card { width: min(400px, 100%); background: var(--panel); border: 1px solid var(--line-2); border-radius: 14px; padding: 22px; display: grid; gap: 14px; }
.auth-card .brand { padding: 0 0 6px; } .auth-card h1 { font-size: 18px; font-weight: 600; } .auth-card form { display: grid; gap: 12px; }

@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; left: 0; top: 0; width: 250px; transform: translateX(-100%); transition: transform .18s ease; }
  .side.open { transform: none; box-shadow: 20px 0 60px #000; }
  #menu { display: inline-block; }
  #view { padding: 14px 12px 60px; } .top { padding: 9px 12px; }
  .grid, .grid.two { grid-template-columns: minmax(0, 1fr); }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bar-row { grid-template-columns: minmax(90px, 120px) 1fr 52px; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; } .kv dd { margin-bottom: 8px; }
  .big { font-size: 32px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* --- 1.1: formatted model answers (Markdown) and Control section --- */
.answer.md-on { white-space: normal; }
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 9px; line-height: 1.55; }
.md h3, .md h4, .md h5, .md h6 { margin: 14px 0 6px; font-weight: 600; color: var(--text); }
.md h3 { font-size: 15px; } .md h4 { font-size: 14px; } .md h5, .md h6 { font-size: 13px; }
.md ul, .md ol { margin: 0 0 9px; padding-left: 22px; } .md li { margin: 2px 0; line-height: 1.5; }
.md code { background: #15151d; border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; font-size: 12px; }
.md pre { background: #08080c; border: 1px solid var(--line); border-radius: var(--r-s); padding: 10px; overflow-x: auto; white-space: pre; font-size: 12px; margin: 0 0 9px; }
.md blockquote { margin: 0 0 9px; padding: 8px 12px; background: var(--violet-bg); border: 1px solid var(--violet-line); border-radius: var(--r-s); color: var(--soft); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.md table { font-size: 12px; } .md a { color: var(--violet); }
.stop-panel { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 14px; border-radius: var(--r); border: 1px solid var(--line); background: #0a0a0f; }
.stop-panel.on { background: #180d0f; border-color: #55262b; }
.stop-panel strong { font-size: 15px; }
.mode-list { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.mode { padding: 12px; border: 1px solid var(--line); border-radius: var(--r-s); background: #0a0a0f; }
.mode.on { border-color: var(--violet-line); background: var(--violet-bg); }
.mode p { margin: 6px 0 0; font-size: 12px; color: var(--soft); line-height: 1.45; }
