/* ================================================================ tokens */

:root {
  color-scheme: dark;
  --bg: #090c14;
  --bg2: #0d1220;
  --panel: rgba(19, 25, 40, .78);
  --panel-solid: #131928;
  --panel2: #1a2236;
  --panel3: #222c44;
  --line: rgba(148, 163, 214, .13);
  --line2: rgba(148, 163, 214, .24);
  --fg: #e3e8f4;
  --dim: #8b95ad;
  --faint: #5b6580;
  /* meanings used by the views: orange = sampled / final answer, blue = model / actual next */
  --accent: #f0a050;
  --accent2: #5fb3f0;
  /* chrome */
  --iris: #8b7dff;
  --cyan: #38c6f4;
  --brand: linear-gradient(120deg, var(--iris), var(--cyan));
  --good: #5fd39a;
  --bad: #ff6b7d;
  --heat: #7fa3cf;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 18px 50px -24px rgba(0, 0, 0, .7);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* ================================================================ base */

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--fg);
  font: 14px/1.5 var(--sans);
  padding: 0 20px 48px;
  background:
    radial-gradient(900px 520px at 8% -8%, rgba(139, 125, 255, .16), transparent 60%),
    radial-gradient(800px 480px at 96% -4%, rgba(56, 198, 244, .12), transparent 60%),
    radial-gradient(1000px 700px at 50% 120%, rgba(95, 179, 240, .06), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
body.busy { cursor: progress; }
body.busy button { opacity: .55; pointer-events: none; }
::selection { background: rgba(139, 125, 255, .4); }

h1 { font-size: 19px; margin: 0; letter-spacing: -.2px; font-weight: 700; }
h3 {
  font-size: 11px; margin: 20px 0 8px; color: var(--dim); text-transform: uppercase;
  letter-spacing: 1.1px; font-weight: 650; display: flex; align-items: center; gap: 8px;
}
h3::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line2), transparent); }
.dim { color: var(--dim); }
.mono { font-family: var(--mono); }
.grad { background: var(--brand); -webkit-background-clip: text; background-clip: text; color: transparent; }

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--panel3); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background-color: #2d3956; }
*::-webkit-scrollbar-track { background: transparent; }
* { scrollbar-color: var(--panel3) transparent; }

:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* ================================================================ busy bar */

#busybar {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 30; pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--iris), var(--cyan), transparent);
  background-size: 40% 100%; background-repeat: no-repeat;
  opacity: 0; transition: opacity .25s;
}
body.working #busybar { opacity: 1; animation: sweep 1.1s var(--ease) infinite; }
@keyframes sweep { from { background-position: -40% 0; } to { background-position: 140% 0; } }

/* ================================================================ header */

header {
  display: flex; align-items: center; gap: 18px; padding: 18px 0 14px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 11px; }
.logo { width: 34px; height: 34px; filter: drop-shadow(0 4px 14px rgba(139, 125, 255, .45)); }
.logo rect { transform-origin: 16px 16px; animation: stack 4.5s var(--ease) infinite; }
.logo rect:nth-of-type(2) { animation-delay: .15s; }
.logo rect:nth-of-type(3) { animation-delay: .3s; }
@keyframes stack { 0%, 70%, 100% { transform: none; } 80% { transform: translateX(2px); } 90% { transform: translateX(-1px); } }
.tagline { font-size: 11.5px; color: var(--dim); letter-spacing: .2px; }

#model-info { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.chip {
  display: inline-flex; align-items: baseline; gap: 5px; font-size: 11.5px; color: var(--dim);
  padding: 3px 9px; border-radius: 999px; background: rgba(26, 34, 54, .7); border: 1px solid var(--line);
  animation: rise .5s var(--ease) both;
}
.chip b { color: var(--fg); font-weight: 650; font-variant-numeric: tabular-nums; }
.chip:nth-child(2) { animation-delay: .04s; } .chip:nth-child(3) { animation-delay: .08s; }
.chip:nth-child(4) { animation-delay: .12s; } .chip:nth-child(5) { animation-delay: .16s; } .chip:nth-child(6) { animation-delay: .2s; }

/* segmented switch with a sliding pill (modes) */
.seg-switch {
  position: relative; display: inline-flex; padding: 3px; border-radius: 12px;
  background: rgba(13, 18, 32, .8); border: 1px solid var(--line);
}
.seg-switch button {
  position: relative; z-index: 1; border: none; background: transparent; color: var(--dim);
  padding: 6px 16px; border-radius: 9px; font-weight: 550; box-shadow: none;
}
.seg-switch button:hover { color: var(--fg); background: transparent; transform: none; }
.seg-switch button.active { color: #fff; }
.seg-switch .ink {
  position: absolute; top: 3px; bottom: 3px; left: 0; width: 0; border-radius: 9px;
  background: linear-gradient(120deg, rgba(139, 125, 255, .9), rgba(56, 198, 244, .85));
  box-shadow: 0 6px 18px -6px rgba(139, 125, 255, .8);
  transition: transform .45s var(--spring), width .45s var(--spring);
}

/* ================================================================ controls */

button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--panel2); color: var(--fg); border: 1px solid var(--line2);
  border-radius: 10px; padding: 7px 14px; cursor: pointer; font: inherit; font-weight: 550;
  transition: background .2s, border-color .2s, transform .15s var(--ease), box-shadow .2s, color .2s;
}
button:hover { background: var(--panel3); border-color: rgba(148, 163, 214, .38); transform: translateY(-1px); }
button:active { transform: translateY(0) scale(.97); }
button svg { width: 14px; height: 14px; fill: currentColor; flex: none; }
button.primary {
  background: var(--brand); border-color: transparent; color: #fff;
  box-shadow: 0 8px 22px -10px rgba(139, 125, 255, .9), 0 1px 0 rgba(255, 255, 255, .25) inset;
}
button.primary:hover { filter: brightness(1.1); box-shadow: 0 10px 26px -8px rgba(56, 198, 244, .8), 0 1px 0 rgba(255, 255, 255, .3) inset; }
button.on { background: rgba(240, 160, 80, .16); border-color: var(--accent); color: #ffd3a6; }
.kbd { font: 11px var(--mono); padding: 1px 6px; border-radius: 6px; background: rgba(255, 255, 255, .07); color: var(--dim); }

label { color: var(--dim); display: inline-flex; align-items: center; gap: 8px; }
input[type=number] {
  width: 70px; background: var(--bg2); color: var(--fg); border: 1px solid var(--line2);
  border-radius: 8px; padding: 4px 7px; font: inherit;
}

/* sliders: gradient fill up to the thumb (--fill is set from JS) */
input[type=range] {
  --fill: 50%;
  -webkit-appearance: none; appearance: none; width: 180px; height: 18px; background: transparent; cursor: pointer; margin: 0;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 5px; border-radius: 99px;
  background: linear-gradient(90deg, var(--iris), var(--cyan)) 0 / var(--fill) 100% no-repeat, var(--panel3);
}
input[type=range]::-moz-range-track { height: 5px; border-radius: 99px; background: var(--panel3); }
input[type=range]::-moz-range-progress { height: 5px; border-radius: 99px; background: linear-gradient(90deg, var(--iris), var(--cyan)); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; margin-top: -5.5px; border-radius: 50%;
  background: #fff; border: 3px solid #6f8cff; box-shadow: 0 2px 10px rgba(56, 198, 244, .5);
  transition: transform .2s var(--spring), box-shadow .2s;
}
input[type=range]::-moz-range-thumb {
  width: 11px; height: 11px; border-radius: 50%; background: #fff; border: 3px solid #6f8cff;
  box-shadow: 0 2px 10px rgba(56, 198, 244, .5); transition: transform .2s var(--spring);
}
input[type=range]:hover::-webkit-slider-thumb { transform: scale(1.15); box-shadow: 0 0 0 6px rgba(111, 140, 255, .18); }
input[type=range]:active::-webkit-slider-thumb { transform: scale(1.3); box-shadow: 0 0 0 8px rgba(111, 140, 255, .22); }
input[type=range]:hover::-moz-range-thumb { transform: scale(1.15); }
input[type=range]:focus-visible { outline: none; }
input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(56, 198, 244, .45); }

.knobs { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.knobs.stack { flex-direction: column; gap: 10px; }
.knob { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; gap: 1px 8px; min-width: 150px; }
.knob > span { font-size: 11.5px; color: var(--dim); align-self: end; }
.knob > input { grid-column: 1 / -1; grid-row: 2; width: 100%; }
.knob > output, .pill {
  grid-column: 2; grid-row: 1; justify-self: end; font: 600 11.5px var(--mono); color: var(--fg);
  padding: 0 7px; border-radius: 99px; background: rgba(139, 125, 255, .16); border: 1px solid rgba(139, 125, 255, .3);
  min-width: 34px; text-align: center; font-variant-numeric: tabular-nums;
}
.knob > output.neutral { background: transparent; border-color: var(--line2); color: var(--dim); font-family: var(--sans); font-weight: 500; }
label.slider { gap: 10px; }

/* toggle switches */
input[type=checkbox] {
  -webkit-appearance: none; appearance: none; flex: none; position: relative; margin: 0; cursor: pointer;
  width: 30px; height: 17px; border-radius: 99px; background: var(--panel3); border: 1px solid var(--line2);
  transition: background .25s, border-color .25s;
}
input[type=checkbox]::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 11px; height: 11px; border-radius: 50%;
  background: var(--dim); transition: transform .3s var(--spring), background .25s;
}
input[type=checkbox]:checked { background: linear-gradient(120deg, var(--iris), var(--cyan)); border-color: transparent; }
input[type=checkbox]:checked::after { transform: translateX(13px); background: #fff; }
.head input[type=checkbox]:checked { background: var(--bad); }

/* option groups (.pick) as segmented controls */
.pick { color: var(--dim); display: inline-flex; gap: 0; align-items: center; font-size: 12px; }
.pick button {
  padding: 4px 11px; font-size: 12px; border-radius: 0; background: rgba(13, 18, 32, .8); border-color: var(--line2);
  margin-left: -1px; font-weight: 500; color: var(--dim);
}
.pick button:hover { transform: none; color: var(--fg); }
.pick button:first-of-type { border-radius: 8px 0 0 8px; margin-left: 8px; }
.pick button:last-of-type { border-radius: 0 8px 8px 0; }
.pick button.on { background: rgba(139, 125, 255, .22); border-color: rgba(139, 125, 255, .6); color: #fff; position: relative; z-index: 1; }

/* ================================================================ completion view */

.glass {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
#controls, #tokens, #panel, .chat-main, .chat-side, .loadbox {
  background: var(--panel); border: 1px solid var(--line);
  box-shadow: var(--shadow); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}

#controls { border-radius: var(--radius); padding: 12px; }
#prompt {
  width: 100%; resize: vertical; background: rgba(9, 12, 20, .7); color: var(--fg);
  border: 1px solid var(--line2); border-radius: 10px; padding: 10px 12px; font: 14px/1.5 var(--mono);
  transition: border-color .2s, box-shadow .2s;
}
#prompt:focus, #chat-input:focus, .chat-side textarea:focus {
  outline: none; border-color: rgba(139, 125, 255, .6); box-shadow: 0 0 0 4px rgba(139, 125, 255, .14);
}
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 10px; }
.grow { flex: 1; }
.sep { width: 1px; height: 22px; background: var(--line2); }

#tokens {
  margin-top: 12px; padding: 12px; border-radius: var(--radius);
  display: flex; flex-wrap: wrap; gap: 4px; max-height: 200px; overflow: auto;
}
.tok {
  --w: 0;
  font: 13px var(--mono); padding: 2px 6px; border-radius: 6px; cursor: pointer; white-space: pre;
  border: 1px solid var(--line2);
  background: color-mix(in srgb, var(--heat) calc(var(--w) * 100%), var(--panel2));
  transition: background .3s, border-color .2s, transform .15s var(--ease), box-shadow .2s;
}
.tok:hover { border-color: rgba(255, 255, 255, .6); transform: translateY(-1px); }
.tok.gen { border-color: rgba(95, 179, 240, .55); color: #cfe8ff; background: color-mix(in srgb, var(--heat) calc(var(--w) * 100%), rgba(95, 179, 240, .12)); }
.tok.special { color: var(--accent); font-style: italic; }
.tok.sel { border-color: #fff; box-shadow: 0 0 0 2px rgba(139, 125, 255, .7), 0 4px 14px -4px rgba(139, 125, 255, .8); }
.tok.pop { animation: pop .42s var(--spring) both; }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.7); } }

#status {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  font-size: 12px; color: var(--dim); padding: 10px 4px 12px;
}
#status .op, #status .cache { display: inline-flex; align-items: center; gap: 8px; }
.opkind {
  font: 600 10.5px var(--mono); text-transform: uppercase; letter-spacing: .6px; padding: 1px 7px; border-radius: 6px;
  background: rgba(95, 179, 240, .14); color: var(--accent2); border: 1px solid rgba(95, 179, 240, .3);
}
.opkind.decode { background: rgba(240, 160, 80, .14); color: var(--accent); border-color: rgba(240, 160, 80, .3); }
.opkind.rewind { background: rgba(139, 125, 255, .16); color: #b9b0ff; border-color: rgba(139, 125, 255, .35); }
.cachebar { display: inline-block; width: 130px; height: 6px; background: var(--panel3); border-radius: 99px; overflow: hidden; }
.cachebar i { display: block; height: 100%; width: 0; background: var(--brand); border-radius: 99px; transition: width .6s var(--ease); }

#tabs { position: relative; display: flex; flex-wrap: wrap; gap: 2px; padding: 0 4px; }
#tabs button {
  border: none; background: transparent; color: var(--dim); border-radius: 10px 10px 0 0; padding: 9px 14px;
  font-weight: 550; box-shadow: none;
}
#tabs button svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; opacity: .8; }
#tabs button:hover { color: var(--fg); background: rgba(255, 255, 255, .03); transform: none; }
#tabs button.active { color: var(--fg); }
#tabs button.active svg { stroke: var(--cyan); opacity: 1; }
#tabs .ink {
  position: absolute; left: 0; bottom: -1px; height: 2px; width: 0; border-radius: 2px; z-index: 2;
  background: var(--brand); box-shadow: 0 0 12px rgba(56, 198, 244, .7);
  transition: transform .45s var(--spring), width .45s var(--spring);
}

#panel { border-radius: var(--radius); padding: 18px; min-height: 300px; }
.explain { color: var(--dim); max-width: 920px; margin: 0 0 14px; line-height: 1.6; }
.explain b { color: var(--fg); font-weight: 600; }
.controls { display: flex; flex-wrap: wrap; gap: 14px 20px; align-items: center; margin-bottom: 14px; }
.scroll { overflow: auto; max-width: 100%; }

/* entering a tab: sections rise in turn, bars grow */
#panel.enter > * { animation: rise .5s var(--ease) both; }
#panel.enter > :nth-child(2) { animation-delay: .05s; }
#panel.enter > :nth-child(3) { animation-delay: .1s; }
#panel.enter > :nth-child(4) { animation-delay: .15s; }
#panel.enter > :nth-child(n+5) { animation-delay: .2s; }
#panel.enter .bar { animation: grow .7s var(--ease) both .15s; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes grow { from { transform: scaleX(0); } }
.appear { animation: fadein .35s var(--ease) both; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } }

/* ================================================================ logit lens */

table.lens { border-collapse: separate; border-spacing: 2px; font: 12px var(--mono); }
table.lens th { color: var(--dim); font-weight: normal; padding: 0 8px 0 4px; white-space: pre; text-align: right; position: sticky; left: 0; background: var(--panel-solid); z-index: 1; }
table.lens thead th { position: sticky; text-align: center; z-index: 2; max-width: 74px; overflow: hidden; text-overflow: ellipsis; color: var(--fg); }
table.lens thead tr:first-child th { top: 0; height: 20px; }
table.lens thead tr.nextrow th { top: 22px; color: var(--accent2); font-size: 11px; height: 18px; }
table.lens thead th:first-child { left: 0; z-index: 3; color: var(--dim); font-size: 11px; }
table.lens thead th.sel { background: var(--panel3); border-radius: 5px; }
table.lens td { min-width: 66px; max-width: 74px; height: 21px; padding: 0 4px; white-space: pre; overflow: hidden; text-overflow: ellipsis; text-align: center; border-radius: 4px; cursor: pointer; transition: filter .15s; }
table.lens td:hover { filter: brightness(1.35); }
table.lens td.agree { font-weight: 700; }
table.lens td.lock { box-shadow: inset 0 -3px 0 var(--accent); }
table.lens td.selcol { outline: 1px solid rgba(255, 255, 255, .55); outline-offset: -1px; }
table.lens td.lock.selcol { box-shadow: inset 0 -3px 0 var(--accent); }
table.lens tr.final th { color: var(--accent); }
table.lens tr.final td { border-top: 1px solid var(--line); }
.lensdetail { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 6px; }
.lensdetail p { max-width: 920px; margin: 6px 0; }
.story { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 3px; font-size: 13px; }
.seg { background: var(--panel2); border: 1px solid var(--line2); border-radius: 7px; padding: 2px 8px; white-space: pre; }
.seg.ans { border-color: var(--accent); background: rgba(240, 160, 80, .08); }
.seg.ans b { color: var(--accent); }

/* ================================================================ attention */

.groups { display: flex; flex-wrap: wrap; gap: 14px; }
.group { border: 1px solid var(--line); background: rgba(9, 12, 20, .35); border-radius: 12px; padding: 10px; }
.group > .dim { font-size: 12px; margin-bottom: 8px; }
.heads { display: flex; gap: 10px; }
.head { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; cursor: pointer; }
.head canvas {
  width: 130px; height: 130px; image-rendering: pixelated; border: 2px solid transparent; border-radius: 8px; background: #000;
  transition: transform .25s var(--ease), border-color .2s, box-shadow .25s, opacity .3s;
}
.head:hover canvas { transform: translateY(-2px); box-shadow: 0 10px 24px -10px rgba(56, 198, 244, .5); }
.head.sel canvas { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(240, 160, 80, .2), 0 10px 26px -10px rgba(240, 160, 80, .6); }
.head.ablated canvas { opacity: .22; filter: grayscale(1); }
.head label { font-size: 11px; gap: 6px; }

/* ================================================================ bars and numbers */

.bars { display: grid; grid-template-columns: max-content 1fr max-content; gap: 4px 12px; align-items: center; font: 12px var(--mono); max-width: 780px; }
.bar {
  height: 12px; border-radius: 4px; min-width: 1px; transform-origin: left;
  background: linear-gradient(90deg, #3f86c4, var(--accent2));
  box-shadow: 0 0 12px -4px rgba(95, 179, 240, .6);
}
.bar.alt { background: linear-gradient(90deg, #d17a2c, var(--accent)); box-shadow: 0 0 12px -4px rgba(240, 160, 80, .6); }
.barcell { display: flex; flex-direction: column; gap: 3px; }
.clickrow { cursor: pointer; transition: color .15s; }
.drytag { margin-left: 8px; padding: 0 6px; border-radius: 6px; font-size: 11px; color: #c9b8ff; background: rgba(139, 125, 255, .16); border: 1px solid rgba(139, 125, 255, .35); }
.clickrow:hover { color: #fff; }

.legend { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--dim); }
.legend canvas { border-radius: 3px; }
.kpi { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.kpi div {
  position: relative; overflow: hidden; min-width: 120px;
  background: linear-gradient(160deg, rgba(34, 44, 68, .9), rgba(22, 29, 46, .9));
  border: 1px solid var(--line); border-radius: 12px; padding: 9px 13px; font-size: 12px; color: var(--dim);
}
.kpi div::before { content: ''; position: absolute; inset: 0 0 auto; height: 2px; background: var(--brand); opacity: .7; }
.kpi b { display: block; font-size: 19px; color: var(--fg); font-weight: 650; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }

/* ================================================================ overlays */

#tip {
  position: fixed; display: none; pointer-events: none; z-index: 10; max-width: 380px;
  background: rgba(10, 13, 22, .94); border: 1px solid var(--line2); border-radius: 10px; padding: 9px 11px;
  font-size: 12px; box-shadow: 0 16px 40px -12px rgba(0, 0, 0, .8); backdrop-filter: blur(10px);
  animation: tipin .14s var(--ease);
}
@keyframes tipin { from { opacity: 0; transform: translateY(3px) scale(.98); } }
#tip .mono { white-space: pre; }
#flash {
  position: fixed; right: 18px; bottom: 18px; z-index: 11; max-width: 420px;
  background: rgba(58, 22, 32, .95); border: 1px solid rgba(255, 107, 125, .55); border-left: 3px solid var(--bad);
  border-radius: 10px; padding: 10px 14px; box-shadow: 0 16px 40px -12px rgba(0, 0, 0, .8);
  transform: translateY(20px); opacity: 0; pointer-events: none;
  transition: transform .4s var(--spring), opacity .25s;
}
#flash.show { transform: none; opacity: 1; pointer-events: auto; }

/* loading screen */
#loading {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center; z-index: 20; padding: 16px;
  background: radial-gradient(600px 400px at 50% 40%, rgba(139, 125, 255, .14), transparent 70%), rgba(7, 9, 15, .94);
}
.loadbox { border-radius: 18px; padding: 26px 30px; width: min(540px, 100%); animation: rise .5s var(--ease) both; }
.loadbox h2 { margin: 14px 0 8px; font-size: 18px; letter-spacing: -.2px; }
.loadlogo { display: flex; gap: 5px; align-items: flex-end; height: 34px; }
.loadlogo i { width: 7px; border-radius: 4px; background: var(--brand); animation: eq 1.1s var(--ease) infinite; }
.loadlogo i:nth-child(1) { animation-delay: 0s; } .loadlogo i:nth-child(2) { animation-delay: .12s; }
.loadlogo i:nth-child(3) { animation-delay: .24s; } .loadlogo i:nth-child(4) { animation-delay: .36s; } .loadlogo i:nth-child(5) { animation-delay: .48s; }
@keyframes eq { 0%, 100% { height: 8px; opacity: .5; } 50% { height: 34px; opacity: 1; } }
#load-stage { margin-top: 16px; font-weight: 550; }
.loadbar { position: relative; height: 8px; background: var(--panel3); border-radius: 99px; overflow: hidden; margin: 10px 0 8px; }
.loadbar i { position: relative; display: block; height: 100%; width: 0; background: var(--brand); border-radius: 99px; transition: width .2s; overflow: hidden; }
.loadbar i::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45), transparent);
  animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* ================================================================ chat */

.chat-layout { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 16px; }
@media (max-width: 860px) { .chat-layout { grid-template-columns: 1fr; } }
.chat-main { display: flex; flex-direction: column; border-radius: 18px; height: calc(100vh - 100px); min-height: 440px; overflow: hidden; }
#messages { flex: 1; overflow-y: auto; padding: 22px; display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth; }

.msg { display: flex; gap: 10px; max-width: 84%; animation: msgin .4s var(--spring) both; }
@keyframes msgin { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.msg .bubble { padding: 10px 14px; border-radius: 16px; line-height: 1.6; min-width: 0; }
.msg .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; }
.msg.user .bubble {
  background: linear-gradient(135deg, #5d55d6, #2f8fd0); color: #fff; border-bottom-right-radius: 5px;
  box-shadow: 0 10px 26px -14px rgba(93, 85, 214, .9);
}
.msg.assistant { align-self: flex-start; }
.msg.assistant .bubble { background: rgba(26, 34, 54, .85); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.avatar {
  flex: none; width: 28px; height: 28px; border-radius: 9px; margin-top: 2px;
  background: var(--brand); box-shadow: 0 4px 14px -4px rgba(139, 125, 255, .8);
  position: relative;
}
.avatar::after { content: ''; position: absolute; inset: 8px; border-radius: 3px; background: rgba(9, 12, 20, .65); }
.msg.streaming .avatar { animation: glow 1.4s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 5px rgba(56, 198, 244, .18), 0 4px 18px -2px rgba(56, 198, 244, .9); } }
.msg.assistant.streaming:not(.waiting) .body::after { content: '▍'; color: var(--cyan); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.dots { display: none; gap: 4px; padding: 6px 2px; }
.msg.waiting .dots { display: flex; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--dim); animation: bounce 1s var(--ease) infinite; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: none; opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }
.msg .meta { font-size: 11px; margin-top: 5px; }
.msg .meta:empty { display: none; }
.ct { border-radius: 4px; cursor: default; transition: background .3s; animation: inkin .35s var(--ease) both; }
@keyframes inkin { from { opacity: 0; filter: blur(3px); } }
.ct:hover { outline: 1px solid var(--heat); }

.empty { margin: auto; text-align: center; max-width: 520px; animation: rise .6s var(--ease) both; }
.empty h2 { font-size: 20px; margin: 18px 0 6px; letter-spacing: -.3px; }
.empty-orb {
  width: 64px; height: 64px; margin: 0 auto; border-radius: 22px; background: var(--brand);
  box-shadow: 0 16px 50px -10px rgba(139, 125, 255, .8); animation: float 5s ease-in-out infinite; position: relative;
}
.empty-orb::after { content: ''; position: absolute; inset: 18px; border-radius: 7px; background: rgba(9, 12, 20, .6); }
@keyframes float { 50% { transform: translateY(-6px) rotate(4deg); } }
.ideas { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 18px; }
.idea { font-size: 12.5px; font-weight: 500; border-radius: 99px; padding: 6px 14px; background: rgba(26, 34, 54, .7); color: var(--fg); }
.idea:hover { border-color: rgba(139, 125, 255, .6); background: rgba(139, 125, 255, .14); }

#composer { display: flex; gap: 10px; align-items: flex-end; padding: 12px; border-top: 1px solid var(--line); background: rgba(9, 12, 20, .35); }
#chat-input {
  flex: 1; resize: none; background: rgba(9, 12, 20, .7); color: var(--fg); border: 1px solid var(--line2);
  border-radius: 14px; padding: 10px 14px; font: inherit; transition: border-color .2s, box-shadow .2s;
}
.composer-buttons { display: flex; gap: 6px; }
button.icon { width: 42px; height: 42px; padding: 0; border-radius: 13px; }
button.icon svg { width: 17px; height: 17px; }
#stop { background: rgba(255, 107, 125, .14); border-color: rgba(255, 107, 125, .5); color: var(--bad); animation: fadein .2s both; }
#stop:hover { background: rgba(255, 107, 125, .24); }

.chat-side { border-radius: 18px; padding: 4px 16px 16px; align-self: start; }
.chat-side h3 { margin-top: 16px; }
.chat-side .small, .chat-side .explain.small { font-size: 12px; }
.chat-side .turn div { margin: 3px 0; }
.chat-side .turn b { color: var(--fg); font-variant-numeric: tabular-nums; }
.chat-side label.block { display: flex; margin: 8px 0; font-size: 13px; }
.chat-side textarea {
  width: 100%; background: rgba(9, 12, 20, .7); color: var(--fg); border: 1px solid var(--line2); border-radius: 10px;
  padding: 8px; font: 12px var(--mono); resize: vertical; transition: border-color .2s, box-shadow .2s;
}
.chat-side button.wide { width: 100%; margin-top: 10px; }
.row.tight { gap: 8px; margin-top: 0; }
.ctxbar { height: 8px; background: var(--panel3); border-radius: 99px; overflow: hidden; margin-bottom: 6px; }
.ctxbar i { display: block; height: 100%; width: 0; background: var(--brand); border-radius: 99px; transition: width .6s var(--ease); }
.rawstream { display: flex; flex-wrap: wrap; gap: 3px; }

/* ================================================================ small screens, reduced motion */

@media (max-width: 720px) {
  body { padding: 0 12px 32px; }
  #model-info { margin-left: 0; }
  .knob { min-width: 130px; flex: 1; }
  .msg { max-width: 94%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
