/* ============================================================================
   JARVIS — operator console design system.
   One stylesheet, served as the web app (phone PWA) and loaded by the Tauri
   desktop shell. Mobile-first responsive; collapses the 3-pane layout to a
   single column with slide-over drawers on narrow screens.
   ========================================================================== */

:root {
  /* Surfaces — layered near-black with a faint blue cast */
  --bg:            #07090e;
  --bg-grad-1:     #0a0e16;
  --bg-grad-2:     #070912;
  --surface:       #0e1118;
  --surface-2:     #12161f;
  --surface-3:     #171c27;
  --elevated:      #1a2130;
  --border:        #20262f;
  --border-soft:   #181d26;
  --border-strong: #2c3543;

  /* Text */
  --text:          #e9edf5;
  --text-dim:      #9aa6b8;
  --text-faint:    #5d6878;
  --text-ghost:    #3a434f;

  /* Accent — electric indigo → cyan */
  --accent:        #6b8cff;
  --accent-2:      #57d9ff;
  --accent-deep:   #3a5bd9;
  --accent-soft:   rgba(107,140,255,0.13);
  --accent-line:   rgba(107,140,255,0.35);
  --glow:          rgba(87,140,255,0.45);

  /* Semantic */
  --ok:            #4fd699;
  --warn:          #ffcc66;
  --err:           #ff6b7d;
  --user-bubble:   linear-gradient(135deg, #243352, #1d2a45);
  --user-border:   #34466b;

  --radius:        14px;
  --radius-sm:     10px;
  --radius-lg:     20px;
  --shadow:        0 10px 40px rgba(0,0,0,0.45);
  --shadow-soft:   0 4px 18px rgba(0,0,0,0.30);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, system-ui, sans-serif;
}

/* Light theme — overrides surfaces/text/borders; accent vars are set in JS and work
   on either theme. Code blocks stay dark (intentional, like most light editors). */
:root[data-theme="light"] {
  --bg:            #eef1f7;
  --bg-grad-1:     #f1f4fa;
  --bg-grad-2:     #e7ecf4;
  --surface:       #ffffff;
  --surface-2:     #f6f8fc;
  --surface-3:     #eceff5;
  --elevated:      #e6eaf2;
  --border:        #dce1ea;
  --border-soft:   #e9edf3;
  --border-strong: #c2cad8;
  --text:          #1b2330;
  --text-dim:      #54607a;
  --text-faint:    #8b95a7;
  --text-ghost:    #b9c1ce;
  --shadow:        0 12px 40px rgba(20,30,55,0.14);
  --shadow-soft:   0 4px 18px rgba(20,30,55,0.08);
  --user-bubble:   linear-gradient(135deg, #dde8ff, #d2e0ff);
  --user-border:   #bcd0f5;
}
:root[data-theme="light"] body {
  background:
    radial-gradient(1200px 600px at 80% -10%, #e4ecfa 0%, transparent 60%),
    radial-gradient(900px 500px at -10% 110%, #e6eefb 0%, transparent 55%),
    linear-gradient(160deg, var(--bg-grad-1), var(--bg-grad-2));
}
:root[data-theme="light"] .codeblock .cb-head { background: #11151c; border-color: #1d232d; }
:root[data-theme="light"] .codeblock .cb-lang { color: #8b93a3; }
:root[data-theme="light"] .codeblock .cb-copy { color: #c2cad8; border-color: #2a313c; }
:root[data-theme="light"] *::-webkit-scrollbar-thumb:hover { background: #aeb6c4; background-clip: content-box; }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
/* Keyboard focus rings (mouse clicks stay clean via :focus-visible). */
button:focus-visible, a:focus-visible, textarea:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px;
}
/* Smooth glide only while toggling theme — keeps normal hovers snappy. */
html.theming, html.theming * { transition: background-color .28s ease, color .24s ease, border-color .28s ease, fill .24s ease, box-shadow .28s ease !important; }
/* Subtle message entrance. */
@keyframes msgin { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: no-preference) { .msg-wrap { animation: msgin .26s ease both; } }
body {
  background:
    radial-gradient(1200px 600px at 80% -10%, #0e1626 0%, transparent 60%),
    radial-gradient(900px 500px at -10% 110%, #0c1422 0%, transparent 55%),
    linear-gradient(160deg, var(--bg-grad-1), var(--bg-grad-2));
  color: var(--text);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
::selection { background: var(--accent-soft); }
button { font-family: inherit; }

/* Scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: #38424f; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

#app { height: 100vh; height: 100dvh; overflow: hidden; }

/* ============================ App shell ================================== */
.shell {
  display: grid;
  grid-template-columns: 268px minmax(0,1fr) 320px;
  grid-template-rows: minmax(0, 1fr); /* bound the row to the viewport so .messages scrolls internally instead of overflowing */
  height: 100%;
}
.shell.panel-collapsed { grid-template-columns: 268px minmax(0,1fr) 0; }

/* ============================ Sidebar =================================== */
.sidebar {
  display: flex; flex-direction: column; min-height: 0;
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-grad-2) 100%);
  border-right: 1px solid var(--border);
}
.brand {
  display: flex; align-items: center; gap: 11px;
  padding: 16px 18px 14px;
}
.brand .mark {
  width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 18px var(--glow); position: relative;
}
.brand .mark::after {
  content: ""; position: absolute; inset: 7px; border-radius: 4px;
  background: var(--bg); opacity: .9;
}
.brand .mark::before {
  content: ""; position: absolute; inset: 12px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-2), var(--accent)); z-index: 1;
}
.brand .name { font-weight: 800; letter-spacing: 3px; font-size: 16px; }
.brand .name small { display: block; font-size: 9px; letter-spacing: 2.5px; color: var(--text-faint); font-weight: 600; margin-top: 1px; }

.new-chat {
  margin: 6px 14px 12px; padding: 11px 14px;
  background: linear-gradient(135deg, var(--accent-deep), var(--accent));
  color: #fff; border: 0; border-radius: var(--radius-sm);
  font-weight: 700; font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: 0 4px 16px rgba(58,91,217,0.35); transition: transform .12s, filter .12s;
}
.new-chat:hover { filter: brightness(1.08); transform: translateY(-1px); }
.new-chat:active { transform: translateY(0); }

.conv-search { margin: 0 12px 8px; padding: 9px 12px; background: var(--bg-input); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-sm); font: inherit; font-size: 13px; outline: none; }
.conv-search::placeholder { color: var(--text-faint); }
.conv-search:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.conv-list { flex: 1; overflow-y: auto; padding: 0 10px 10px; }
.conv-group-label { font-size: 10px; letter-spacing: 1.5px; color: var(--text-ghost); font-weight: 700; padding: 12px 10px 6px; text-transform: uppercase; }
.conv-row {
  display: block;
  padding: 9px 11px; border-radius: var(--radius-sm); cursor: pointer;
  color: var(--text-dim); margin-bottom: 2px; border: 1px solid transparent;
  transition: background .12s, color .12s, transform .12s; position: relative;
}
.conv-row:hover { transform: translateX(2px); }
.conv-row .cr-top { display: flex; align-items: center; gap: 10px; }
.conv-row .cr-preview { font-size: 11px; color: var(--text-ghost); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; padding-right: 2px; }
.conv-row:hover { background: var(--surface-2); color: var(--text); }
.conv-row.active { background: var(--surface-3); color: var(--text); border-color: var(--border); }
.conv-row.active::before {
  content: ""; position: absolute; left: -1px; top: 9px; bottom: 9px; width: 3px;
  border-radius: 3px; background: linear-gradient(var(--accent), var(--accent-2));
}
.conv-row .title { flex: 1; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-row .meta { font-size: 10.5px; color: var(--text-ghost); flex-shrink: 0; }
.conv-row .del { opacity: 0; background: none; border: 0; color: var(--text-faint); cursor: pointer; padding: 3px; border-radius: 6px; display: inline-flex; flex-shrink: 0; transition: opacity .12s, color .12s, background .12s; }
.conv-row:hover .del, .conv-row.active .del { opacity: .7; }
.conv-row .del:hover { opacity: 1; color: var(--err); background: rgba(255,107,125,.12); }
.conv-row .pin { opacity: 0; background: none; border: 0; color: var(--text-faint); cursor: pointer; padding: 3px; border-radius: 6px; display: inline-flex; flex-shrink: 0; transition: opacity .12s, color .12s; }
.conv-row:hover .pin { opacity: .5; }
.conv-row .pin:hover { opacity: 1; color: var(--warn); }
.conv-row .pin.on { opacity: 1; color: var(--warn); }

.sidebar-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; border-top: 1px solid var(--border); color: var(--text-dim); font-size: 12px;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-ghost); flex-shrink: 0; transition: background .2s, box-shadow .2s; }
.status-dot.online { background: var(--ok); box-shadow: 0 0 8px rgba(79,214,153,0.7); }
.status-dot.busy   { background: var(--warn); box-shadow: 0 0 8px rgba(255,204,102,0.7); animation: pulse 1s infinite; }
.status-dot.offline{ background: var(--err); }
.sidebar-foot .who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { background: none; border: 0; color: var(--text-faint); cursor: pointer; padding: 5px; border-radius: 7px; display: inline-flex; transition: color .12s, background .12s; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

/* ============================ Main / chat ============================== */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: transparent; position: relative; }
.scroll-bottom { position: absolute; right: 24px; bottom: 104px; width: 38px; height: 38px; border-radius: 50%; background: var(--surface-3); border: 1px solid var(--border-strong); color: var(--text); cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-soft); opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity .15s, transform .15s; z-index: 5; }
.scroll-bottom.show { opacity: 1; pointer-events: auto; transform: none; }
.scroll-bottom:hover { background: var(--elevated); }
.main.dropping::after { content: "Drop a text file to add it to your message"; position: absolute; inset: 10px; border: 2px dashed var(--accent-line); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; color: var(--accent-2); font-size: 14px; font-weight: 600; background: var(--accent-soft); pointer-events: none; z-index: 8; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 20px; border-bottom: 1px solid var(--border-soft);
  backdrop-filter: blur(6px);
}
.topbar .hamburger, .topbar .panel-toggle { display: none; }
.topbar .t { font-size: 15px; font-weight: 650; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: default; }
.title-edit { flex: 1; min-width: 0; background: var(--bg-input); color: var(--text); border: 1px solid var(--accent-line); border-radius: 8px; padding: 5px 10px; font: inherit; font-size: 15px; font-weight: 650; outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.topbar .model-chip {
  font-family: var(--mono); font-size: 11px; color: var(--accent-2);
  background: var(--accent-soft); border: 1px solid var(--accent-line);
  padding: 3px 9px; border-radius: 20px; white-space: nowrap;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--text-faint); transition: background .2s, box-shadow .2s; }
.status-dot.online { background: #4fd699; box-shadow: 0 0 7px #4fd69988; }
.status-dot.offline { background: #ff6b6b; box-shadow: 0 0 7px #ff6b6b88; }

.messages { flex: 1; overflow-y: auto; padding: 22px clamp(16px, 6vw, 64px); scroll-behavior: smooth; }
.msg-wrap { max-width: 820px; margin: 0 auto; }

.msg-row { display: flex; gap: 13px; margin-bottom: 22px; animation: rise .25s ease both; }
.msg-row.user { flex-direction: row-reverse; }
.avatar {
  width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0; margin-top: 2px;
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800;
}
.avatar.assistant { background: linear-gradient(135deg, var(--accent-deep), var(--accent-2)); color: #fff; box-shadow: 0 0 14px var(--glow); }
.avatar.user { background: var(--surface-3); color: var(--text-dim); border: 1px solid var(--border); }

.bubble { min-width: 0; max-width: 100%; }
.msg-row.user .bubble { max-width: 78%; }
.msg-row.user .body {
  background: var(--user-bubble); border: 1px solid var(--user-border);
  padding: 11px 15px; border-radius: 16px 16px 4px 16px;
}
.msg-row.assistant .body { padding-top: 3px; }
.msg-row.assistant .bubble { position: relative; }
.msg-copy { position: absolute; top: -4px; right: -4px; opacity: 0; background: var(--surface-3); border: 1px solid var(--border); color: var(--text-faint); border-radius: 7px; padding: 4px; cursor: pointer; display: inline-flex; transition: opacity .12s, color .12s; }
.msg-row.assistant:hover .msg-copy { opacity: .85; }
.msg-copy:hover { color: var(--text); border-color: var(--border-strong); }
.msg-regen { position: absolute; top: -4px; right: 26px; opacity: 0; background: var(--surface-3); border: 1px solid var(--border); color: var(--text-faint); border-radius: 7px; padding: 4px; cursor: pointer; display: inline-flex; transition: opacity .12s, color .12s; }
.msg-wrap:last-child .msg-row.assistant:hover .msg-regen { opacity: .85; }
.msg-regen:hover { color: var(--text); border-color: var(--border-strong); }
.msg-edit { position: absolute; top: -4px; left: -4px; opacity: 0; background: var(--surface-3); border: 1px solid var(--border); color: var(--text-faint); border-radius: 7px; padding: 4px; cursor: pointer; display: inline-flex; transition: opacity .12s, color .12s; }
.msg-row.user.last-user:hover .msg-edit { opacity: .85; }
.msg-edit:hover { color: var(--text); border-color: var(--border-strong); }
/* Touch devices have no hover → show the message actions so regenerate/edit/copy stay reachable on mobile. */
@media (hover: none) {
  .msg-row.assistant .msg-copy,
  .msg-wrap:last-child .msg-row.assistant .msg-regen,
  .msg-row.user.last-user .msg-edit { opacity: .6; }
  /* Comfortable ≥40px tap targets for icon buttons on touch. */
  .icon-btn { min-width: 40px; min-height: 40px; align-items: center; justify-content: center; }
}
.msg-time { font-size: 10px; color: var(--text-ghost); margin-top: 4px; opacity: 0; transition: opacity .12s; }
.msg-row:hover .msg-time { opacity: .7; }
.msg-row.user .msg-time { text-align: right; }
.body { color: var(--text); overflow-wrap: anywhere; }

/* Markdown rendering */
.body p { margin: 0 0 10px; }
.body p:last-child { margin-bottom: 0; }
.body h1, .body h2, .body h3 { margin: 16px 0 8px; line-height: 1.3; font-weight: 700; }
.body h1 { font-size: 20px; } .body h2 { font-size: 17px; } .body h3 { font-size: 15px; color: var(--text-dim); }
.body ul, .body ol { margin: 4px 0 12px; padding-left: 22px; }
.body ul ul, .body ul ol, .body ol ul, .body ol ol { margin: 2px 0; }
.body li { margin: 3px 0; }
.body a { color: var(--accent-2); text-decoration: none; border-bottom: 1px solid var(--accent-line); }
.body a:hover { border-bottom-color: var(--accent-2); }
.body strong { color: #fff; font-weight: 700; }
.body em { color: var(--text-dim); }
.body li.md-task { list-style: none; margin-left: -20px; display: flex; gap: 8px; align-items: flex-start; }
.body li.md-task .tl-box { width: 15px; height: 15px; border: 1.5px solid var(--border-strong); border-radius: 4px; flex-shrink: 0; margin-top: 3px; display: inline-flex; align-items: center; justify-content: center; }
.body li.md-task.done .tl-box { background: var(--ok); border-color: var(--ok); }
.body li.md-task.done .tl-box::after { content: "✓"; color: #06210f; font-size: 10px; font-weight: 900; }
.body li.md-task.done > span:last-child { color: var(--text-faint); text-decoration: line-through; }
.body code.inline { font-family: var(--mono); font-size: 12.5px; background: var(--surface-3); border: 1px solid var(--border); padding: 1px 6px; border-radius: 6px; color: var(--accent-2); }
.body del { color: var(--text-faint); }
.body blockquote { margin: 8px 0; padding: 4px 14px; border-left: 3px solid var(--accent-line); color: var(--text-dim); }
.body hr { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
.body table { border-collapse: collapse; margin: 12px 0; width: 100%; font-size: 13.5px; display: block; overflow-x: auto; }
.body th, .body td { border: 1px solid var(--border); padding: 7px 11px; text-align: left; }
.body thead th { background: var(--surface-2); color: var(--text); font-weight: 650; }
.body tbody tr:nth-child(even) { background: rgba(255,255,255,0.015); }

.codeblock { margin: 10px 0; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: #0a0d13; }
.codeblock .cb-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.codeblock .cb-lang { font-family: var(--mono); font-size: 11px; color: var(--text-faint); letter-spacing: .5px; }
.codeblock .cb-copy { font-size: 11px; color: var(--text-dim); background: none; border: 1px solid var(--border); border-radius: 6px; padding: 2px 9px; cursor: pointer; transition: all .12s; }
.codeblock .cb-copy:hover { color: var(--text); border-color: var(--border-strong); }
.codeblock .cb-copy.copied { color: var(--ok); border-color: var(--ok); }
.codeblock pre { margin: 0; padding: 12px 14px; overflow-x: auto; }
.codeblock code { font-family: var(--mono); font-size: 12.5px; line-height: 1.55; color: #d6deec; white-space: pre; }
.codeblock .tok-c { color: #5c6473; font-style: italic; }
.codeblock .tok-s { color: #7fd88f; }
.codeblock .tok-n { color: #d6a96b; }
.codeblock .tok-k { color: #6b8cff; }

/* thinking / cursor */
.thinking-row .body { color: var(--text-faint); display: flex; align-items: center; gap: 9px; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); display: inline-block; animation: bounce 1.2s infinite; }
.dots i:nth-child(2){ animation-delay: .15s; } .dots i:nth-child(3){ animation-delay: .3s; }
.cursor { display: inline-block; width: 7px; height: 15px; background: var(--accent); margin-left: 2px; vertical-align: text-bottom; animation: blink 1s steps(2) infinite; border-radius: 1px; }

/* Tool trace */
.trace { margin-top: 11px; display: flex; flex-direction: column; gap: 5px; }
.trace-row {
  display: flex; align-items: center; gap: 9px; font-size: 12px;
  background: var(--surface); border: 1px solid var(--border-soft);
  padding: 7px 11px; border-radius: 9px; color: var(--text-dim);
  animation: rise .2s ease both;
}
.trace-row .ic { width: 15px; height: 15px; flex-shrink: 0; display: inline-flex; }
.trace-row .ic.spin svg { animation: spin 1s linear infinite; }
.trace-row .tool { font-family: var(--mono); font-weight: 600; color: var(--accent-2); }
.trace-row .sum { color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }

/* ============================ Composer ================================= */
.composer-wrap { padding: 10px clamp(12px, 6vw, 64px) 16px; }
.composer-inner { max-width: 820px; margin: 0 auto; position: relative; }
.slash-menu { position: absolute; bottom: calc(100% + 6px); left: 0; right: 0; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: var(--shadow); padding: 5px; z-index: 20; }
.slash-item { display: flex; align-items: baseline; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.slash-item.active, .slash-item:hover { background: var(--accent-soft); }
.slash-cmd { font-weight: 700; color: var(--accent); font-size: 13px; min-width: 86px; }
.slash-desc { color: var(--text-faint); font-size: 12.5px; }
.quick-row { display: flex; gap: 8px; margin-bottom: 9px; flex-wrap: wrap; }
.quick {
  font-size: 12px; color: var(--text-dim); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 20px; padding: 5px 12px; cursor: pointer;
  transition: all .12s; white-space: nowrap;
}
.quick:hover { color: var(--text); border-color: var(--accent-line); background: var(--accent-soft); }
.composer {
  display: flex; align-items: flex-end; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 8px 8px 16px; transition: border-color .15s, box-shadow .15s;
}
.composer:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer textarea {
  flex: 1; background: none; color: var(--text); border: 0; resize: none;
  font: 15px/1.5 var(--sans); max-height: 200px; min-height: 26px; padding: 6px 0; outline: none; overflow-y: auto;
}
.composer textarea::placeholder { color: var(--text-faint); }
.send {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0; border: 0; cursor: pointer;
  background: linear-gradient(135deg, var(--accent-deep), var(--accent));
  color: #fff; display: flex; align-items: center; justify-content: center;
  transition: filter .12s, transform .12s; box-shadow: 0 3px 12px rgba(58,91,217,0.4);
}
.send:hover:not(:disabled) { filter: brightness(1.1); }
.send:disabled { opacity: .35; cursor: default; box-shadow: none; }
.attach { width: 36px; height: 38px; flex-shrink: 0; border: 0; background: none; color: var(--text-faint); cursor: pointer; display: flex; align-items: center; justify-content: center; border-radius: 9px; transition: color .12s, background .12s; }
.attach:hover { color: var(--text); background: var(--surface-3); }
.send.stop { background: var(--surface-3); box-shadow: none; color: var(--err); }
.hint { text-align: center; font-size: 11px; color: var(--text-ghost); margin-top: 8px; }

/* ============================ Operator panel =========================== */
.panel {
  display: flex; flex-direction: column; min-height: 0;
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-grad-2) 100%);
  border-left: 1px solid var(--border);
}
.shell.panel-collapsed .panel { display: none; }
.panel-head { display: flex; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border-soft); gap: 8px; }
.panel-head .ttl { font-size: 12px; font-weight: 700; letter-spacing: 1.5px; color: var(--text-dim); text-transform: uppercase; flex: 1; }
.tabs { display: flex; gap: 2px; padding: 8px 10px; border-bottom: 1px solid var(--border-soft); }
.tab {
  flex: 1; text-align: center; font-size: 10.5px; font-weight: 600; color: var(--text-faint);
  padding: 7px 2px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; transition: all .12s;
  white-space: nowrap;
}
.tab:hover { color: var(--text-dim); }
.tab.active { color: var(--text); background: var(--surface-3); border-color: var(--border); }
.tab .count { font-size: 10px; color: var(--text-ghost); margin-left: 3px; }
.panel-body { flex: 1; overflow-y: auto; padding: 12px; }

.card {
  background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
  padding: 11px 12px; margin-bottom: 9px; animation: rise .2s ease both;
}
.card .c-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.card .c-sub { font-size: 11.5px; color: var(--text-faint); }
.badge { font-size: 9.5px; font-weight: 700; letter-spacing: .5px; padding: 2px 7px; border-radius: 20px; text-transform: uppercase; }
.badge.open { background: rgba(107,140,255,.15); color: var(--accent-2); }
.badge.in_progress { background: rgba(255,204,102,.15); color: var(--warn); }
.badge.done { background: rgba(79,214,153,.15); color: var(--ok); }
.badge.blocked { background: rgba(255,107,125,.15); color: var(--err); }
.badge.tool { background: var(--accent-soft); color: var(--accent-2); font-family: var(--mono); text-transform: none; }
.badge.dyn { background: rgba(79,214,153,.12); color: var(--ok); }

.plan-steps { margin: 7px 0 0; padding: 0; list-style: none; }
.plan-steps li { display: flex; gap: 8px; font-size: 12px; color: var(--text-dim); padding: 3px 0; }
.plan-steps li .box { width: 14px; height: 14px; border: 1.5px solid var(--border-strong); border-radius: 4px; flex-shrink: 0; margin-top: 2px; }
.plan-steps li.done .box { background: var(--ok); border-color: var(--ok); }
.plan-steps li.done span { color: var(--text-faint); text-decoration: line-through; }
.plan-steps li.clickable { cursor: pointer; border-radius: 6px; padding: 3px 4px; margin: 0 -4px; transition: background .12s; }
.plan-steps li.clickable:hover { background: var(--surface-2); }
.task-check { width: 16px; height: 16px; border: 1.5px solid var(--border-strong); border-radius: 5px; flex-shrink: 0; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: all .12s; }
.task-check:hover { border-color: var(--accent); }
.task-check.checked { background: var(--ok); border-color: var(--ok); }
.task-check.checked::after { content: "✓"; color: #06210f; font-size: 11px; font-weight: 900; line-height: 1; }
.card-done .task-title { color: var(--text-faint); text-decoration: line-through; }

.empty-panel { color: var(--text-ghost); font-size: 12.5px; text-align: center; padding: 30px 16px; line-height: 1.6; white-space: pre-line; }
.empty-cta { display: block; margin: 14px auto 0; background: var(--accent-soft); border: 1px solid var(--accent-line); color: var(--accent-2); padding: 8px 14px; border-radius: 9px; cursor: pointer; font-size: 13px; font-weight: 600; transition: all .12s; }
.empty-cta:hover { background: var(--accent); color: #fff; }

/* ============================ Onboarding =============================== */
.onboard { display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100vh; height: 100dvh; padding: 28px; }
.onboard .card2 { width: 100%; max-width: 400px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 36px 32px; box-shadow: var(--shadow); animation: rise .3s ease both; }
.onboard .logo { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.onboard .logo .mark { width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 0 24px var(--glow); position: relative; }
.onboard .logo .mark::after { content:""; position:absolute; inset:9px; border-radius:5px; background: var(--surface-2); }
.onboard .logo .mark::before { content:""; position:absolute; inset:15px; border-radius:50%; background: linear-gradient(135deg, var(--accent-2), var(--accent)); z-index:1; }
.onboard .kicker { color: var(--accent-2); font-size: 11px; letter-spacing: 3px; font-weight: 700; }
.onboard h1 { margin: 0; font-size: 26px; letter-spacing: 1px; }
.onboard p { color: var(--text-dim); margin: 4px 0 22px; font-size: 14px; }
.onboard label { display: block; color: var(--text-dim); font-size: 12px; margin: 16px 0 7px; font-weight: 600; }
.onboard input {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px; font: inherit; outline: none; transition: border-color .15s, box-shadow .15s;
}
.onboard input:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.onboard button.primary {
  width: 100%; margin-top: 24px; padding: 13px; border: 0; border-radius: var(--radius-sm); cursor: pointer;
  background: linear-gradient(135deg, var(--accent-deep), var(--accent)); color: #fff; font-weight: 700; font-size: 15px;
  box-shadow: 0 4px 16px rgba(58,91,217,0.4); transition: filter .12s, transform .12s;
}
.onboard button.primary:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); }
.onboard button.primary:disabled { opacity: .5; }
.err { color: var(--err); font-size: 13px; margin-top: 14px; min-height: 18px; }
.reveal-toggle { display: block; margin: 7px 0 0 auto; background: none; border: 0; color: var(--text-faint); font-size: 12px; cursor: pointer; padding: 2px 0; }
.reveal-toggle:hover { color: var(--text); }

/* Empty chat state */
.empty-chat { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; text-align: center; padding: 30px; }
.empty-chat .big-mark { width: 56px; height: 56px; border-radius: 16px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 0 36px var(--glow); position: relative; margin-bottom: 20px; }
.empty-chat .big-mark::after { content:""; position:absolute; inset:13px; border-radius:7px; background: var(--bg); }
.empty-chat .big-mark::before { content:""; position:absolute; inset:21px; border-radius:50%; background: linear-gradient(135deg, var(--accent-2), var(--accent)); z-index:1; }
.empty-chat h2 { margin: 0 0 6px; font-size: 22px; font-weight: 700; }
.empty-chat p { color: var(--text-dim); margin: 0 0 24px; max-width: 460px; }
.empty-chat .briefing { color: var(--accent-2); font-size: 13px; margin: -12px 0 22px; opacity: 0; transition: opacity .25s; min-height: 18px; }
.empty-chat .briefing.show { opacity: 1; }
.suggest-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; max-width: 480px; }
.suggest {
  text-align: left; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; cursor: pointer; transition: all .14s; color: var(--text-dim);
}
.suggest:hover { border-color: var(--accent-line); background: var(--accent-soft); color: var(--text); transform: translateY(-2px); }
.suggest .s-t { font-weight: 650; color: var(--text); font-size: 13.5px; margin-bottom: 3px; }
.suggest .s-d { font-size: 12px; }

/* Toast */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--elevated); border: 1px solid var(--border-strong); color: var(--text); padding: 11px 18px; border-radius: 12px; box-shadow: var(--shadow); font-size: 13px; opacity: 0; transition: all .25s; z-index: 100; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Confirm modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 20px; animation: rise .15s ease both; backdrop-filter: blur(2px); }
.modal { background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 22px; max-width: 380px; width: 100%; box-shadow: var(--shadow); }
.modal.modal-wide { max-width: 560px; }
.files-list { max-height: 50vh; overflow-y: auto; margin: 12px 0; display: flex; flex-direction: column; gap: 4px; }
.file-row { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 9px; background: var(--surface-3); }
.file-row:hover { background: var(--surface-4, var(--surface-3)); }
.file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.file-meta { color: var(--text-faint); font-size: 12px; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.file-btn { flex-shrink: 0; background: none; border: 1px solid var(--border); color: var(--text-faint); border-radius: 7px; padding: 4px 6px; cursor: pointer; display: inline-flex; transition: color .12s, border-color .12s; }
.file-btn:hover { color: var(--text); border-color: var(--border-strong); }
.file-btn.danger:hover { color: var(--danger, #ff6b6b); border-color: var(--danger, #ff6b6b); }
.file-viewhead { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.file-viewhead .file-name { font-size: 12px; color: var(--text-faint); }
.file-view { max-height: 52vh; overflow: auto; margin: 0; padding: 12px 14px; background: #0a0d13; border: 1px solid var(--border); border-radius: var(--radius-sm); font-family: var(--mono); font-size: 12.5px; line-height: 1.5; color: #d6deec; white-space: pre-wrap; word-break: break-word; }
.modal-t { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.modal-b { color: var(--text-dim); font-size: 13.5px; margin-bottom: 18px; line-height: 1.5; }
.settings-rows { margin: 4px 0 18px; }
.settings-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
.settings-row .sk { color: var(--text-faint); }
.settings-row .sv { color: var(--text); font-family: var(--mono); font-size: 12px; overflow: hidden; text-overflow: ellipsis; max-width: 62%; white-space: nowrap; }
.accent-swatches { display: flex; gap: 7px; }
.swatch { width: 18px; height: 18px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; transition: transform .1s; }
.swatch:hover { transform: scale(1.18); }
.swatch.sel { border-color: var(--text); }
.theme-btn { font-size: 12px; color: var(--text-dim); background: var(--surface-3); border: 1px solid var(--border); border-radius: 8px; padding: 4px 12px; cursor: pointer; transition: all .12s; }
.theme-btn:hover { color: var(--text); border-color: var(--border-strong); }
.theme-btn.sel { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.modal-input { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px 13px; font: inherit; outline: none; margin-bottom: 18px; transition: border-color .15s, box-shadow .15s; }
.modal-input:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.btn-ghost { background: none; border: 1px solid var(--border); color: var(--text-dim); padding: 9px 16px; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: 13px; }
.btn-ghost:hover { color: var(--text); border-color: var(--border-strong); }
.btn-danger { background: var(--err); border: 0; color: #2a1115; padding: 9px 16px; border-radius: 9px; cursor: pointer; font-weight: 700; font-size: 13px; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-primary { background: linear-gradient(135deg,var(--accent-deep),var(--accent)); border: 0; color: #fff; padding: 9px 16px; border-radius: 9px; cursor: pointer; font-weight: 700; font-size: 13px; }
.btn-primary:hover { filter: brightness(1.08); }

/* Command palette (⌘/Ctrl-K) */
.cmdk { align-items: flex-start; padding-top: 12vh; }
.cmdk-box { width: 100%; max-width: 520px; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; animation: rise .14s ease both; }
.cmdk-input { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--border); color: var(--text); font: inherit; font-size: 15px; padding: 15px 18px; outline: none; }
.cmdk-input::placeholder { color: var(--text-faint); }
.cmdk-list { max-height: 52vh; overflow-y: auto; padding: 6px; }
.cmdk-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 9px; cursor: pointer; color: var(--text-dim); }
.cmdk-item.sel { background: var(--accent-soft); color: var(--text); }
.cmdk-hint { font-size: 10px; color: var(--text-ghost); text-transform: uppercase; letter-spacing: .5px; flex-shrink: 0; }
.cmdk-empty { padding: 16px; text-align: center; color: var(--text-ghost); font-size: 13px; }

/* Scrim for mobile drawers */
.scrim { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 40; opacity: 0; transition: opacity .2s; }
.scrim.show { display: block; opacity: 1; }

/* ============================ Animations =============================== */
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes bounce { 0%,60%,100% { transform: translateY(0); opacity:.6; } 30% { transform: translateY(-5px); opacity:1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .4; } }

/* ============================ Responsive ============================== */
@media (max-width: 1080px) {
  .shell, .shell.panel-collapsed { grid-template-columns: minmax(0,1fr); }
  .sidebar { position: fixed; z-index: 50; width: 280px; top: 0; bottom: 0; left: 0; transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .panel { position: fixed; z-index: 50; width: 320px; max-width: 86vw; top: 0; bottom: 0; right: 0; transform: translateX(100%); transition: transform .22s ease; box-shadow: var(--shadow); }
  .shell.panel-collapsed .panel { display: flex; }
  .panel.open { transform: none; }
  .topbar .hamburger, .topbar .panel-toggle { display: inline-flex; }
  .suggest-grid { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  body { font-size: 14.5px; }
  .messages { padding: 16px 14px; }
  .composer-wrap { padding: 8px 12px 12px; }
  .msg-row.user .bubble { max-width: 88%; }
}

/* ============================================================================
   JARVIS aesthetic — arc-reactor brand mark, glass surfaces, ambient grid.
   Premium + futuristic but calm (§8): slow motion, faint texture, no clutter.
   ========================================================================== */

/* Arc-reactor "breathing" glow on every brand mark + a slow rotating energy ring. */
@keyframes jv-arc-pulse { 0%,100% { box-shadow: 0 0 16px var(--glow); } 50% { box-shadow: 0 0 30px var(--glow); } }
@keyframes jv-arc-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: no-preference) {
  .brand .mark, .empty-chat .big-mark, .onboard .logo .mark { animation: jv-arc-pulse 3.4s ease-in-out infinite; }
  /* conic energy ring around the big mark (most prominent spot) */
  .empty-chat .big-mark { isolation: isolate; }
  .empty-chat .big-mark::after {
    content: ""; position: absolute; inset: -6px; border-radius: 20px; z-index: -1;
    background: conic-gradient(from 0deg, transparent 0deg, var(--accent) 90deg, var(--accent-2) 180deg, transparent 300deg);
    filter: blur(5px); opacity: .55; animation: jv-arc-spin 6s linear infinite;
  }
}

/* Glass surfaces — translucent panels over the ambient background. */
.sidebar, .panel {
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--surface) 86%, transparent),
      color-mix(in srgb, var(--bg-grad-2) 86%, transparent));
  backdrop-filter: blur(12px) saturate(1.15);
  -webkit-backdrop-filter: blur(12px) saturate(1.15);
}
.topbar, .composer {
  backdrop-filter: blur(10px) saturate(1.1);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
}

/* Faint ambient dot-grid for depth — behind everything, masked to fade out. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: radial-gradient(var(--accent-line) 1px, transparent 1.5px);
  background-size: 30px 30px;
  opacity: .14;
  -webkit-mask-image: radial-gradient(120% 90% at 50% 30%, #000 0%, transparent 72%);
  mask-image: radial-gradient(120% 90% at 50% 30%, #000 0%, transparent 72%);
}
#app { position: relative; z-index: 1; }

/* Subtle HUD accent line at the top of the side columns. */
.sidebar { box-shadow: inset 0 2px 0 -1px var(--accent-line); }
.panel { box-shadow: inset 0 2px 0 -1px var(--accent-line); }

/* JARVIS HUD polish — brand glow, gradient greeting, subtle top scan line. */
.brand .name { text-shadow: 0 0 14px var(--accent-line); }
.empty-chat h2 {
  background: linear-gradient(90deg, var(--text) 30%, var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.empty-chat .big-mark { width: 60px; height: 60px; }
@keyframes jv-scan { 0% { transform: translateX(-30%); opacity: 0; } 50% { opacity: .9; } 100% { transform: translateX(130%); opacity: 0; } }
@media (prefers-reduced-motion: no-preference) {
  .topbar { position: relative; overflow: hidden; }
  .topbar::after {
    content: ""; position: absolute; left: 0; top: 0; height: 1px; width: 35%;
    background: linear-gradient(90deg, transparent, var(--accent-2), transparent);
    animation: jv-scan 7s ease-in-out infinite; pointer-events: none;
  }
}
/* Send button: a touch more arc-reactor glow. */
.send { box-shadow: 0 3px 12px rgba(58,91,217,0.4), 0 0 0 1px var(--accent-line) inset; }

/* JARVIS HUD details — accent scrollbar + active-state glow. */
*::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--accent) 38%, var(--border-strong)); background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--accent) 60%, var(--border-strong)); background-clip: content-box; }
.conv-row.active { box-shadow: 0 0 0 1px var(--accent-line), 0 0 14px -4px var(--glow); }
.tab.active { text-shadow: 0 0 10px var(--accent-line); }
.quick:hover, .suggest:hover { box-shadow: 0 0 16px -6px var(--glow); }

/* ===== Reasoning ("Thinking…") panel — live chain-of-thought, collapsible ===== */
.reason {
  margin: 2px 0 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface-2) 80%, transparent); overflow: hidden;
}
.reason-head {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 7px 11px; background: transparent; border: 0; cursor: pointer;
  color: var(--text-dim); font-size: 12.5px; font-weight: 600; font-family: inherit;
}
.reason-head:hover { color: var(--text); }
.reason-ic { color: var(--accent-2); display: inline-flex; filter: drop-shadow(0 0 6px var(--glow)); }
.reason-label { flex: 1; letter-spacing: .2px; }
.reason.open .reason-label { background: linear-gradient(90deg, var(--text-dim), var(--accent-2), var(--text-dim)); background-size: 200% auto; -webkit-background-clip: text; background-clip: text; color: transparent; animation: jv-reason-shimmer 2.4s linear infinite; }
@keyframes jv-reason-shimmer { to { background-position: 200% center; } }
.reason-chev { transition: transform .2s ease; color: var(--text-faint); }
.reason.open .reason-chev { transform: rotate(180deg); }
.reason-body {
  max-height: 0; overflow: hidden; transition: max-height .25s ease;
  font-family: var(--mono); font-size: 12px; line-height: 1.5; color: var(--text-faint);
  white-space: pre-wrap; word-break: break-word; padding: 0 12px;
  border-top: 1px solid transparent;
}
.reason.open .reason-body {
  max-height: 280px; overflow-y: auto; padding: 9px 12px 11px;
  border-top-color: var(--border-soft);
}

/* ===================== Sandbox console ===================== */
.sbx-modal { max-width: 900px; width: 94vw; }
.modal-t .sbx-title-ic { display: inline-flex; vertical-align: -2px; margin-right: 7px; color: var(--accent-2); filter: drop-shadow(0 0 7px var(--glow)); }
.sbx-sub { font-size: 11.5px; font-weight: 500; color: var(--text-faint); margin-left: 8px; }
.sbx-body { display: grid; grid-template-columns: 220px minmax(0,1fr); gap: 12px; min-height: 56vh; max-height: 70vh; }
.sbx-list { overflow-y: auto; border-right: 1px solid var(--border); padding-right: 8px; display: flex; flex-direction: column; gap: 4px; }
.sbx-new { display: flex; align-items: center; justify-content: center; gap: 7px; padding: 9px; margin-bottom: 4px; background: linear-gradient(135deg, var(--accent-deep), var(--accent)); color: #fff; border: 0; border-radius: var(--radius-sm); font-weight: 700; font-size: 13px; cursor: pointer; }
.sbx-new:hover { filter: brightness(1.08); }
.sbx-item { position: relative; padding: 9px 11px; border-radius: var(--radius-sm); cursor: pointer; border: 1px solid transparent; }
.sbx-item:hover { background: var(--surface-2); }
.sbx-item.active { background: var(--accent-soft); border-color: var(--accent-line); }
.sbx-item-name { font-weight: 650; font-size: 13px; }
.sbx-item-info { font-size: 11px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.sbx-item-dot { position: absolute; top: 10px; right: 9px; width: 7px; height: 7px; border-radius: 50%; }
.sbx-item-dot.ok { background: var(--ok); box-shadow: 0 0 6px var(--ok); } .sbx-item-dot.err { background: var(--err); }
.sbx-detail { display: flex; flex-direction: column; min-height: 0; gap: 8px; }
.sbx-fields { display: flex; flex-direction: column; gap: 6px; }
.sbx-name, .sbx-info-in { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); padding: 8px 11px; font: inherit; outline: none; }
.sbx-name { font-weight: 700; } .sbx-info-in { font-size: 13px; color: var(--text-dim); }
.sbx-name:focus, .sbx-info-in:focus, .sbx-code:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.sbx-code { flex: 1; min-height: 160px; resize: vertical; background: #0a0d13; color: #d6e2f5; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px 13px; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; outline: none; tab-size: 2; white-space: pre; }
.sbx-bar { display: flex; align-items: center; gap: 8px; }
.sbx-run { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; background: linear-gradient(135deg, var(--accent-deep), var(--accent)); color: #fff; border: 0; border-radius: var(--radius-sm); font-weight: 700; font-size: 13px; cursor: pointer; box-shadow: 0 0 14px -4px var(--glow); }
.sbx-run:hover { filter: brightness(1.08); } .sbx-run:disabled { opacity: .6; cursor: default; }
.sbx-hint { flex: 1; font-size: 11px; color: var(--text-ghost); }
.sbx-out-head { font-size: 10px; letter-spacing: 1.5px; color: var(--text-ghost); font-weight: 700; }
.sbx-out { margin: 0; background: #07090e; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; font-family: var(--mono); font-size: 12px; line-height: 1.5; color: #9fe7c4; max-height: 180px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.sbx-out.err { color: var(--err); }
.sbx-out.running { color: var(--text-faint); }
@media (max-width: 680px) { .sbx-body { grid-template-columns: 1fr; } .sbx-list { flex-direction: row; border-right: 0; border-bottom: 1px solid var(--border); padding: 0 0 8px; overflow-x: auto; } .sbx-item { min-width: 140px; } }

/* ===================== Pairing (QR) + APK ===================== */
.pair-qr { display: inline-block; padding: 12px; background: #fff; border-radius: 14px; box-shadow: var(--shadow-soft); }
.pair-qr svg { display: block; width: 220px; height: 220px; }
.pair-hint { color: var(--text-dim); font-size: 13px; margin: 14px 6px 6px; }
.pair-code { font-size: 13px; color: var(--text-faint); } .pair-code b { color: var(--text); letter-spacing: 2px; font-family: var(--mono); }
.pair-exp { font-size: 12px; color: var(--text-ghost); margin-top: 8px; } .pair-exp a { color: var(--accent); }
.apk-link { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 16px; padding: 11px; border: 1px solid var(--accent-line); border-radius: var(--radius-sm); color: var(--accent-2); font-weight: 650; font-size: 14px; text-decoration: none; background: var(--accent-soft); }
.apk-link:hover { filter: brightness(1.1); }

/* Sandbox mini-app kinds + web preview */
.sbx-kinds { display: inline-flex; gap: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; align-self: flex-start; }
.sbx-kind { padding: 6px 13px; background: var(--surface-2); color: var(--text-dim); border: 0; border-right: 1px solid var(--border); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.sbx-kind:last-child { border-right: 0; }
.sbx-kind:hover { color: var(--text); }
.sbx-kind.on { background: linear-gradient(135deg, var(--accent-deep), var(--accent)); color: #fff; }
.sbx-preview { width: 100%; flex: 1; min-height: 220px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; }
.sbx-item-kind { display: inline-block; font-size: 9px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; padding: 1px 5px; border-radius: 5px; background: var(--accent-soft); color: var(--accent-2); margin-right: 6px; vertical-align: 1px; }

/* Inline pairing QR in chat messages */
.pair-inline { display: inline-flex; flex-direction: column; align-items: center; gap: 6px; margin: 8px 0; padding: 12px; background: #fff; border-radius: 14px; box-shadow: var(--shadow-soft); }
.pair-inline svg { display: block; width: 180px; height: 180px; }
.pair-inline-cap { font-size: 11px; color: #4a5568; font-family: var(--mono); }
