:root {
  --bg: #02030f;
  --panel: rgba(12, 16, 48, 0.78);
  --line: rgba(120, 140, 255, 0.22);
  --blue: #4f7dff;
  --violet: #b48cff;
  --text: #e4e8ff;
  --muted: #8a93c4;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  background: radial-gradient(ellipse at 50% 42%, #0b0f3d 0%, #050824 38%, var(--bg) 75%);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
#sphere { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: pointer; }

header {
  position: fixed; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center;
  padding: max(14px, env(safe-area-inset-top)) 18px 0; pointer-events: none; z-index: 2;
}
.brand { font-weight: 600; letter-spacing: .5em; font-size: 13px; color: #c9d2ff; text-shadow: 0 0 14px rgba(110,130,255,.8); }
.pill { font-size: 11px; letter-spacing: .08em; padding: 3px 10px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); pointer-events: auto; }
.pill.on { color: #9fffd0; border-color: rgba(120,255,190,.35); }
.pill.warn { color: #ffb08a; border-color: rgba(255,150,110,.4); }

.hud {
  position: fixed; left: 0; right: 0; bottom: calc(92px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 0 16px; pointer-events: none; z-index: 2;
}
#status { font-size: 12px; letter-spacing: .32em; text-transform: uppercase; color: #aebcff; }
#hint { font-size: 13px; color: var(--muted); }
#caption {
  max-width: 640px; text-align: center; font-size: 17px; line-height: 1.45; color: #dfe4ff; min-height: 1.5em;
  max-height: 30vh; overflow: hidden; text-shadow: 0 2px 18px rgba(0,0,0,.8);
  mask-image: linear-gradient(to top, #000 70%, transparent);
  -webkit-mask-image: linear-gradient(to top, #000 70%, transparent);
}
#caption.user { color: var(--muted); font-style: italic; }

.dock {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(22px + env(safe-area-inset-bottom));
  display: flex; gap: 14px; z-index: 3;
}
.dock button, .dock a.dock-link {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(20, 26, 70, .55); border: 1px solid var(--line); color: #c7cffc; cursor: pointer; backdrop-filter: blur(8px);
}
.dock svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.dock button:hover, .dock a.dock-link:hover { border-color: var(--violet); }
@media (max-width: 440px) { .dock { gap: 7px; } .dock button, .dock a.dock-link { width: 42px; height: 42px; } }

button, select, input { font: inherit; color: var(--text); }
#textForm {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(80px + env(safe-area-inset-bottom));
  width: min(560px, calc(100% - 32px)); display: flex; gap: 8px; z-index: 4;
}
#textForm[hidden] { display: none; }
#textForm input, .card input, .panel select, #marketsBox input:not([type]), .copyrow input {
  flex: 1; background: rgba(10, 14, 44, .85); border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; outline: none;
}
#textForm input:focus, .card input:focus { border-color: var(--violet); }
#textForm button, .card button, .wide {
  background: linear-gradient(135deg, #3d5bff, #8b5cff); border: 0; border-radius: 12px; padding: 10px 16px; cursor: pointer; color: #fff;
}
body:has(#textForm:not([hidden])) .hud { bottom: calc(140px + env(safe-area-inset-bottom)); }

.panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(400px, 100%); z-index: 6;
  background: var(--panel); backdrop-filter: blur(18px); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 12px; padding: max(16px, env(safe-area-inset-top)) 16px 16px;
}
.panel[hidden] { display: none; }
.panel-head { display: flex; justify-content: space-between; align-items: center; }
.close { background: none; border: 0; font-size: 18px; cursor: pointer; color: var(--muted); }
.panel label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.panel label.row { flex-direction: row; align-items: center; gap: 10px; color: var(--text); font-size: 14px; }
.panel input[type=checkbox], .panel input[type=range] { accent-color: var(--violet); }
.wide { width: 100%; }
.wide.danger { background: rgba(255, 90, 120, .15); border: 1px solid rgba(255, 90, 120, .4); color: #ffb3c0; margin-top: auto; }
#resetBtn { background: rgba(120,140,255,.12); border: 1px solid var(--line); color: var(--text); }
.small { font-size: 12px; color: var(--muted); line-height: 1.45; }

#log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.msg { padding: 9px 13px; border-radius: 14px; max-width: 92%; white-space: pre-wrap; word-wrap: break-word; font-size: 14px; }
.msg.user { align-self: flex-end; background: rgba(90, 110, 255, .2); }
.msg.nessa { align-self: flex-start; background: rgba(255,255,255,.05); border: 1px solid var(--line); }
.msg .actions { font-size: 11px; color: var(--muted); margin-top: 5px; }
.msg .actions div::before { content: "⚙ "; }
.msg button.copy { margin-top: 6px; font-size: 11px; background: none; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); cursor: pointer; padding: 2px 8px; }

.overlay { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 16px;
  background: rgba(2, 3, 15, .72); backdrop-filter: blur(6px); }
.overlay[hidden] { display: none; }
.card { display: flex; flex-direction: column; gap: 12px; width: min(340px, 100%); padding: 28px; text-align: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px; }
.card p { margin: 0; color: var(--muted); }
.card.big { cursor: pointer; color: var(--text); font: inherit; align-items: center; }
.card.big p { font-size: 18px; color: var(--text); }
.err { color: #ff9db0; min-height: 1.2em; font-size: 13px; }

/* ---- Core interface: pure black, warm red accents ---- */
body.theme-core { background: #000; }
body.theme-face { background: radial-gradient(ellipse at 50% 45%, #050a1c 0%, #000 70%); }
body.theme-face .brand { color: #cfe9ff; text-shadow: 0 0 14px rgba(90,200,255,.7); }
body.theme-face #status { color: #8fdcff; }
body.theme-core .brand { color: #ffd9d2; text-shadow: 0 0 14px rgba(255,70,50,.7); }
body.theme-core #status { color: #ffb4a8; }
body.theme-core .dock button, body.theme-core .dock a.dock-link { background: rgba(30,20,22,.6); border-color: rgba(255,120,100,.22); color: #f3d6d0; }
body.theme-core .dock button:hover { border-color: #ff5a44; }

.pill.content { color: #ffd38a; border-color: rgba(255,200,120,.45); letter-spacing: .15em; }
.panel.wide-panel { width: min(560px, 100%); overflow-y: auto; }
.panel textarea { width: 100%; resize: vertical; background: rgba(10,14,44,.85); color: var(--text); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px; font: 13px/1.5 -apple-system, BlinkMacSystemFont, sans-serif; }

/* ---- teleprompter ---- */
.prompter { position: fixed; inset: 0; z-index: 8; background: rgba(0,0,0,.94); display: flex; flex-direction: column;
  padding: max(14px, env(safe-area-inset-top)) 20px 14px; color: #fff; }
.prompter[hidden] { display: none; }
.p-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.p-top .close { font-size: 22px; }
.p-viewport { position: relative; flex: 1; overflow: hidden; margin: 10px auto; width: min(900px, 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 12%, #000 70%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 12%, #000 70%, transparent 100%); }
.p-viewport::before { content: ""; position: absolute; left: 0; right: 0; top: 33%; height: 2px; background: rgba(255,200,120,.35); z-index: 1; }
.p-text { position: absolute; left: 0; right: 0; top: 0; font-size: 40px; line-height: 1.45; font-weight: 600; text-align: center;
  white-space: pre-wrap; padding: 30vh 4px 70vh; will-change: transform; }
.p-count { position: absolute; inset: 0; display: grid; place-items: center; font-size: 140px; font-weight: 700; color: #ffd38a; pointer-events: none; }
.p-bar { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: center; }
.p-bar button { background: rgba(255,255,255,.08); color: #fff; border: 1px solid rgba(255,255,255,.2); border-radius: 12px; padding: 9px 16px; cursor: pointer; font: inherit; }
.p-bar #pStart { background: linear-gradient(135deg, #ff8a3d, #ff3d6e); border: 0; }
.p-speed { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #ccc; }
.p-speed input { accent-color: #ff8a3d; }
.p-help { text-align: center; margin: 8px 0 0; }
.dock button.active { border-color: #ffd38a; color: #ffd38a; box-shadow: 0 0 14px rgba(255,200,120,.35); }

/* Nessa Trader box in settings */
.trade-box { border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 8px; background: rgba(10,14,44,.5); }
.trade-box b { font-size: 14px; }
.copyrow { display: flex; gap: 6px; }
.copyrow input { flex: 1; min-width: 0; font-size: 12px; }
.copy { padding: 6px 10px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.06); color: var(--text); cursor: pointer; }
.msg.trade { border-left: 2px solid #6fe3a8; }

button.pill { background: transparent; font: inherit; font-size: 11px; cursor: pointer; }
.pill[hidden] { display: none; }
.catgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; }
#marketsBox label { display: block; margin-top: 6px; } #marketsBox input:not([type]) { width: 100%; box-sizing: border-box; margin-top: 4px; }
.panel { overflow-y: auto; overscroll-behavior: contain; } .panel > * { flex-shrink: 0; }

/* Nessa's own trading chart (KLineChart) */
.panel.chart-panel { width: min(1180px, 100%); gap: 6px; padding: 10px 10px 8px; background: rgba(6, 9, 30, .98); overflow: hidden; }
.panel.chart-panel.full { width: 100%; left: 0; }
.cp-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cp-head b { font-size: 15px; letter-spacing: .04em; }
.cp-price { font-variant-numeric: tabular-nums; color: #9fffd0; font-size: 14px; min-width: 70px; }
.cp-head select { background: rgba(10,14,44,.9); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; font-size: 12px; }
#chartTfs button, #chartFull, .cp-inds button { background: transparent; border: 1px solid var(--line); color: var(--muted); border-radius: 7px; padding: 3px 8px; font-size: 12px; cursor: pointer; margin-left: 2px; }
#chartTfs button.on, .cp-inds button.on { color: #9fffd0; border-color: rgba(120,255,190,.45); }
.cp-right { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.cp-body { flex: 1; display: flex; gap: 6px; min-height: 0; }
.cp-tools { display: flex; flex-direction: column; gap: 3px; overflow-y: auto; padding-right: 2px; }
.cp-tools button { width: 32px; height: 32px; flex: 0 0 auto; border-radius: 8px; border: 1px solid transparent; background: rgba(255,255,255,.03); cursor: pointer; display: grid; place-items: center; }
.cp-tools button:hover { border-color: var(--line); }
.cp-tools button.on { border-color: rgba(120,255,190,.5); background: rgba(120,255,190,.08); }
.cp-tools svg { width: 18px; height: 18px; fill: none; stroke: #b9c3f5; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.cp-tools .sep { height: 1px; background: var(--line); margin: 4px 2px; flex: 0 0 auto; }
#chartBox { position: relative; flex: 1; min-width: 0; min-height: 300px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.cp-foot { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.cp-inds { display: flex; gap: 2px; flex-wrap: wrap; }
.cp-src { margin-left: auto; }
.cp-src a, #chartLegend a { color: var(--muted); }
@media (max-width: 640px) {
  .panel.chart-panel { width: 100%; }
  .cp-tools { flex-direction: row; overflow-x: auto; order: 2; }
  .cp-body { flex-direction: column; }
  .cp-tools button { width: 30px; height: 30px; }
}

/* conversations + projects */
.conv-panel { gap: 8px; }
.cv-row { display: flex; gap: 6px; align-items: center; }
.cv-row select { flex: 1; min-width: 0; background: rgba(10,14,44,.9); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 7px 8px; }
.cv-row button { background: rgba(255,255,255,.04); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 7px 10px; cursor: pointer; font-size: 13px; white-space: nowrap; }
.cv-row .cv-new { flex: 1; }
.cv-list { max-height: 38vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; flex-shrink: 0; }
.cv-item { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 13px; }
.cv-item:last-child { border-bottom: 0; }
.cv-item:hover, .cv-item.on { background: rgba(90,110,255,.12); }
.cv-item .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cv-item .d { color: var(--muted); font-size: 11px; }
.cv-item button { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 13px; }
.cv-title { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.cv-title span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.cv-title button { background: none; border: 0; color: var(--muted); cursor: pointer; }
#projPanel textarea, #projPanel input:not([type]) { width: 100%; box-sizing: border-box; background: rgba(10,14,44,.85); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; color: var(--text); font: inherit; outline: none; }
#projFiles div { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--line); }
#projFiles button { background: none; border: 0; color: #ff8a8a; cursor: pointer; }

/* Nessa's mind + Telegram */
.mind-times { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.mind-times input, #tgBox input:not([type=checkbox]) { width: 100%; box-sizing: border-box; background: rgba(10,14,44,.85); border: 1px solid var(--line); border-radius: 10px; padding: 7px 9px; color: var(--text); font: inherit; color-scheme: dark; }
#mindThoughts div { padding: 6px 0; border-bottom: 1px solid var(--line); }
#mindThoughts .w { color: var(--muted); font-size: 11px; display: block; }
#mindBox details summary, #tgBox details summary { cursor: pointer; margin-top: 6px; }
.msg.mind { border-left: 2px solid #9b7bff; }

/* Stop button: only while she's thinking or speaking */
#stopBtn { display: none; margin: 10px auto 0; padding: 10px 26px; border-radius: 999px; border: 1px solid rgba(255,120,120,.45);
  background: rgba(255,80,80,.16); color: #ffd6d6; font-weight: 600; font-size: 15px; letter-spacing: .04em; cursor: pointer; pointer-events: auto; }
#stopBtn:hover { background: rgba(255,80,80,.28); }
body[data-state="speaking"] #stopBtn, body[data-state="thinking"] #stopBtn { display: block; }
