:root {
  --bg: #05040c; --panel: rgba(17, 14, 34, .72); --panel-solid: #110e22; --panel2: rgba(34, 27, 66, .55); --line: rgba(150, 120, 255, .18); --line2: rgba(178, 107, 255, .42);
  --text: #ece8ff; --muted: #9a93bd; --accent: #b26bff; --accent2: #ff4fd8; --cyan: #3fd8ff; --ok: #3ef0a5; --warn: #ffb547; --bad: #ff5d7a;
  --radius: 14px; --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --glow: 0 0 0 1px var(--line), 0 0 28px rgba(140, 80, 255, .12), inset 0 1px 0 rgba(255, 255, 255, .04);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; color: var(--text); font: 15px/1.5 var(--font); background: var(--bg); }
body { background: radial-gradient(1200px 700px at 50% 30%, #1a0f3d 0%, transparent 60%), radial-gradient(900px 600px at 85% 90%, #2a0c3a 0%, transparent 60%), var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; border-radius: 10px; padding: 8px 14px; background: var(--panel2); transition: background .15s, box-shadow .15s, transform .1s; }
button:hover { background: rgba(80, 55, 160, .5); }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary { background: linear-gradient(135deg, #8b4dff, #ff4fd8); color: #fff; font-weight: 600; box-shadow: 0 0 22px rgba(200, 80, 255, .35); }
button.ghost { background: rgba(20, 16, 40, .5); border: 1px solid var(--line2); color: #d9ccff; }
button.danger { background: rgba(255, 93, 122, .14); color: var(--bad); border: 1px solid rgba(255, 93, 122, .4); }
input, select, textarea { background: rgba(10, 8, 24, .7); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; width: 100%; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(178, 107, 255, .15); }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); margin: 8px 0; }
label.check { display: flex; align-items: center; gap: 8px; } label.check input { width: auto; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.err { color: var(--bad); min-height: 1.2em; font-size: 13px; }
.glass { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--glow); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }

/* Auth */
.screen { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.card { width: min(400px, 100%); background: var(--panel); border: 1px solid var(--line2); border-radius: 20px; padding: 28px; text-align: center; box-shadow: var(--glow); backdrop-filter: blur(14px); }
.card form { text-align: left; } .card h1 { margin: 8px 0 0; letter-spacing: 2px; }
.card .primary { width: 100%; margin-top: 12px; padding: 12px; }
details { margin: 10px 0; color: var(--muted); font-size: 13px; }
.mini-orb { width: 54px; height: 72px; margin: auto; clip-path: polygon(50% 0, 100% 40%, 50% 100%, 0 40%); background: linear-gradient(135deg, #f3d9ff, #b26bff 45%, #5b1fd6); filter: drop-shadow(0 0 18px #b26bff); animation: bob 4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px); } }

/* Layout: nav | centre | hud */
#app { display: grid; grid-template-columns: 250px minmax(0, 1fr) 300px; gap: 14px; height: 100dvh; padding: 14px; }
#side { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--glow); backdrop-filter: blur(14px); }
.side-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 14px 10px; }
.logo { display: flex; align-items: center; gap: 10px; } .logo svg { width: 30px; height: 40px; filter: drop-shadow(0 0 10px rgba(178, 107, 255, .8)); }
.logo small { display: block; font-size: 10px; letter-spacing: 2px; color: var(--muted); margin-top: -2px; }
.brand { font-weight: 800; font-size: 24px; letter-spacing: 3px; background: linear-gradient(135deg, #f3d9ff, #b26bff 50%, #ff4fd8); -webkit-background-clip: text; background-clip: text; color: transparent; }
.side-label, #hud h4 { font-size: 11px; letter-spacing: 2px; color: var(--muted); margin: 6px 16px; font-weight: 600; }
.search { margin: 0 12px 8px; width: auto; }
#sessions { flex: 1; overflow: auto; padding: 0 8px; }
#sessions a { display: block; padding: 8px 10px; border-radius: 10px; color: var(--text); text-decoration: none; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border: 1px solid transparent; }
#sessions a:hover { background: var(--panel2); }
#sessions a.on { background: linear-gradient(90deg, rgba(139, 77, 255, .35), rgba(139, 77, 255, .08)); border-color: var(--line2); }
#sessions small { display: block; color: var(--muted); font-size: 11px; }
.side-foot { padding: 12px 14px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
main { display: flex; flex-direction: column; min-width: 0; min-height: 0; gap: 12px; }
header { display: flex; align-items: center; gap: 14px; padding: 2px 4px; }
#menu { display: none; }
.tagline { flex: 1; min-width: 0; text-align: center; } .tagline b { letter-spacing: 1.5px; font-size: 15px; color: #cfc4ff; } .tagline em { font-style: normal; color: var(--cyan); text-shadow: 0 0 12px rgba(63, 216, 255, .6); }
#status-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
#clock { text-align: right; line-height: 1.15; } #clock b { display: block; font-size: 22px; font-weight: 500; letter-spacing: 1px; } #clock small { color: var(--muted); font-size: 11px; }
.sys { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border: 1px solid rgba(62, 240, 165, .35); border-radius: 12px; background: rgba(10, 40, 30, .35); }
.sys small { display: block; font-size: 10px; letter-spacing: 1.5px; color: var(--muted); } .sys b { color: var(--ok); font-size: 13px; }
.sys-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 12px var(--ok); animation: blink 2.4s infinite; }
@keyframes blink { 50% { opacity: .45; } }
.switch { display: flex; flex-direction: row; align-items: center; gap: 6px; margin: 0; color: var(--text); font-size: 13px; }
.switch input { width: auto; accent-color: var(--accent); }
#center { flex: 1; display: flex; flex-direction: column; gap: 12px; min-height: 0; }

/* Second Brain stage */
#stage { position: relative; flex: 1; min-height: 260px; overflow: hidden; display: grid; place-items: center; transition: flex .4s ease; border-color: var(--line2);
  background: radial-gradient(60% 60% at 50% 50%, rgba(80, 30, 170, .28), transparent 70%), rgba(9, 6, 22, .78); }
#brain { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.brain-head { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; z-index: 2; pointer-events: none; max-width: calc(100% - 24px); }
.brain-head svg { width: 28px; height: 28px; color: #e2c8ff; filter: drop-shadow(0 0 6px #b26bff); flex: none; }
.brain-head b { font-size: 14px; letter-spacing: 1.2px; } .brain-head b span { color: var(--muted); font-weight: 500; }
.brain-head small { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brain-head button { pointer-events: auto; padding: 5px 12px; font-size: 12px; }
#orb { position: relative; z-index: 2; width: 230px; height: 260px; padding: 0; background: transparent; border-radius: 50%; transition: width .4s, height .4s, transform .2s; }
#orb:hover { background: transparent; } #orb:active { transform: scale(.96); }
#orb canvas { width: 100%; height: 100%; display: block; pointer-events: none; }
#orb-label { position: absolute; z-index: 2; bottom: 104px; left: 0; right: 0; text-align: center; color: #cfc4ff; font-size: 13px; letter-spacing: .5px; text-shadow: 0 0 10px rgba(178, 107, 255, .8); pointer-events: none; }
#live-caption { position: absolute; z-index: 2; bottom: 128px; left: 10%; right: 10%; text-align: center; font-size: 15px; opacity: .9; pointer-events: none; text-shadow: 0 1px 8px #000; }
#brain-chips { position: absolute; z-index: 2; bottom: 14px; left: 12px; right: 12px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; font-size: 13px; border: 1px solid color-mix(in srgb, var(--c) 45%, transparent); background: rgba(12, 9, 28, .72); backdrop-filter: blur(8px); }
.chip span { filter: saturate(1.4); } .chip small { color: var(--muted); font-size: 11px; }
.chip:hover, .chip.on { background: color-mix(in srgb, var(--c) 22%, rgba(12, 9, 28, .8)); box-shadow: 0 0 16px color-mix(in srgb, var(--c) 45%, transparent); }
#note-panel { position: absolute; z-index: 4; top: 60px; right: 14px; bottom: 60px; width: min(420px, calc(100% - 28px)); display: flex; flex-direction: column; background: rgba(14, 11, 30, .94); border: 1px solid var(--line2); border-radius: 14px; padding: 14px; box-shadow: 0 0 40px rgba(120, 60, 255, .3); animation: up .2s ease-out; }
.np-top { display: flex; justify-content: space-between; gap: 8px; } .np-top h3 { margin: 0; font-size: 16px; } .np-meta { font-size: 11px; word-break: break-all; }
.np-body { flex: 1; overflow: auto; white-space: pre-wrap; font-size: 13px; margin: 10px 0; padding-right: 4px; }
.np-body pre { background: var(--panel2); padding: 8px; border-radius: 8px; overflow: auto; font: 12px var(--mono); }
#app.has-log #stage { flex: 0 0 38%; }
#app.has-log #orb { width: 150px; height: 170px; }
#app.has-log #orb-label, #app.has-log #live-caption { display: none; }
#app.brain-full #stage { flex: 1 1 100%; } #app.brain-full #log { display: none; }

/* Log */
#log { flex: 1; overflow: auto; padding: 4px 6px; display: none; flex-direction: column; gap: 10px; }
#app.has-log #log { display: flex; }
.msg { max-width: min(760px, 92%); padding: 10px 14px; border-radius: var(--radius); white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: linear-gradient(135deg, rgba(139, 77, 255, .45), rgba(255, 79, 216, .25)); border: 1px solid var(--line2); }
.msg.kara { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); }
.msg.kara code { font-family: var(--mono); font-size: 13px; background: var(--panel2); padding: 1px 5px; border-radius: 6px; }
.msg.kara pre { background: rgba(5, 4, 14, .7); padding: 10px; border-radius: 10px; overflow: auto; font: 12.5px/1.45 var(--mono); }
.msg a { color: var(--cyan); }
.msg.err { align-self: flex-start; color: var(--bad); border: 1px solid rgba(255, 93, 122, .4); background: transparent; }
.tool { align-self: flex-start; max-width: min(760px, 92%); font-size: 13px; border: 1px solid var(--line); border-radius: 12px; background: rgba(20, 15, 44, .6); }
.tool summary { padding: 7px 12px; cursor: pointer; list-style: none; display: flex; gap: 8px; align-items: center; color: var(--muted); }
.tool summary b { color: var(--text); font-weight: 600; }
.tool .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 8px var(--warn); animation: blink 1s infinite; }
.tool.ok .dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); animation: none; } .tool.bad .dot { background: var(--bad); animation: none; }
.tool pre { margin: 0; padding: 8px 12px 10px; font: 12px/1.45 var(--mono); white-space: pre-wrap; max-height: 280px; overflow: auto; color: var(--muted); }

/* Voice bar */
#voicebar { display: grid; grid-template-columns: auto minmax(0, 1.1fr) auto minmax(120px, 1.4fr); align-items: center; gap: 16px; padding: 10px 18px; }
.mic { width: 58px; height: 58px; border-radius: 50%; padding: 0; display: grid; place-items: center; background: radial-gradient(circle, rgba(139, 77, 255, .35), rgba(20, 10, 50, .8)); border: 2px solid var(--accent); box-shadow: 0 0 24px rgba(178, 107, 255, .55), inset 0 0 14px rgba(178, 107, 255, .4); }
.mic svg { width: 26px; height: 26px; color: #f0e2ff; }
#voicebar[data-state=listening] .mic { border-color: var(--ok); box-shadow: 0 0 30px rgba(62, 240, 165, .6); animation: blink 1.2s infinite; }
#voicebar[data-state=thinking] .mic { border-color: var(--cyan); }
.vb-text b { display: block; font-size: 13px; letter-spacing: 1px; } .vb-text small { color: var(--muted); font-size: 12px; }
.vb-wake { text-align: center; line-height: 1.1; } .vb-wake small { display: block; font-size: 10px; letter-spacing: 2px; color: var(--muted); }
.vb-wake span { font-size: 24px; font-weight: 300; text-shadow: 0 0 14px rgba(178, 107, 255, .9); white-space: nowrap; }
#wave { width: 100%; height: 48px; }

/* Composer */
#composer { display: flex; gap: 8px; padding: 0 0 env(safe-area-inset-bottom); }
#composer textarea { resize: none; max-height: 180px; background: var(--panel); border-color: var(--line2); }

/* HUD */
#hud { display: flex; flex-direction: column; gap: 14px; min-height: 0; overflow: auto; }
#hud section { padding: 12px 6px 14px; } #hud h4 { margin: 2px 10px 10px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 8px; }
.tile { padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: rgba(25, 18, 55, .5); }
.tile b { display: block; font-size: 24px; font-weight: 600; line-height: 1.1; background: linear-gradient(135deg, #fff, #c9a6ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tile small { color: var(--muted); font-size: 12px; } .tile.warn b { background: linear-gradient(135deg, #fff, var(--warn)); -webkit-background-clip: text; background-clip: text; }
.quick, .says { display: grid; gap: 8px; padding: 0 8px; }
.quick button { display: flex; gap: 10px; align-items: center; text-align: left; border: 1px solid var(--line); background: rgba(25, 18, 55, .5); }
.quick button span { font-size: 13px; font-weight: 600; } .quick small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; }
.says { grid-template-columns: 1fr 1fr; } .says button { font-size: 12px; text-align: left; border: 1px solid var(--line); background: rgba(25, 18, 55, .5); }
.quick button:hover, .says button:hover { border-color: var(--line2); box-shadow: 0 0 14px rgba(178, 107, 255, .25); }

/* Approval sheet */
.sheet { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); display: grid; place-items: end center; padding: 16px; z-index: 10; }
.sheet-card { width: min(560px, 100%); background: var(--panel-solid); border: 1px solid var(--warn); border-radius: 18px; padding: 18px; animation: up .2s ease-out; box-shadow: 0 0 40px rgba(255, 181, 71, .2); }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.sheet-title { font-weight: 700; color: var(--warn); } .ap-tool { margin: 6px 0; font-family: var(--mono); }
.sheet pre { background: rgba(5, 4, 14, .7); padding: 10px; border-radius: 10px; white-space: pre-wrap; max-height: 200px; overflow: auto; font: 12.5px var(--mono); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.chips span { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: rgba(255, 181, 71, .16); color: var(--warn); }
.row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }

/* Settings */
dialog { background: var(--panel-solid); color: var(--text); border: 1px solid var(--line2); border-radius: 18px; width: min(560px, calc(100% - 32px)); max-height: 88dvh; padding: 0; box-shadow: 0 0 60px rgba(120, 60, 255, .3); }
dialog::backdrop { background: rgba(0, 0, 0, .6); backdrop-filter: blur(3px); }
.settings { padding: 20px; } .settings h2 { margin-top: 0; } .settings h3 { margin: 18px 0 4px; font-size: 14px; }
.key-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.key-row .ok { color: var(--ok); font-size: 12px; }
.add-user { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr auto; gap: 6px; }
.user-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 14px; }
.add-conn { display: grid; gap: 6px; margin: 8px 0; }
.conn-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.conn-row small { color: var(--muted); } .conn-row button { padding: 2px 8px; font-size: 12px; }

/* Responsive */
@media (max-width: 1280px) { #app { grid-template-columns: 230px minmax(0, 1fr); } #hud { display: none; } }
@media (max-width: 900px) { .tagline, #clock { display: none; } header { justify-content: space-between; } }
@media (max-width: 760px) {
  #app { grid-template-columns: 1fr; padding: 10px; gap: 10px; }
  #side { position: fixed; inset: 10px 25% 10px 10px; z-index: 5; transform: translateX(-110%); transition: transform .2s; background: var(--panel-solid); }
  #app.side-open #side { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .5); }
  #menu { display: block; }
  .sys { padding: 6px 10px; } .sys small { display: none; }
  #orb { width: 170px; height: 195px; }
  #voicebar { grid-template-columns: auto 1fr; gap: 10px; padding: 8px 12px; } .vb-wake, .vb-text small { display: none; } #wave { grid-column: 1 / -1; height: 34px; }
  .mic { width: 46px; height: 46px; }
  .chip { padding: 4px 9px; font-size: 12px; } .chip small { display: none; }
  .brain-head small { display: none; }
  .add-user { grid-template-columns: 1fr 1fr; }
  .switch span { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Live widgets (floating holo panels) */
#center { position: relative; }
#widget-layer { position: absolute; inset: 0 0 56px 0; pointer-events: none; z-index: 6; }
.widget { position: absolute; pointer-events: auto; display: flex; flex-direction: column; min-width: 220px; min-height: 120px; resize: both; overflow: hidden;
  background: rgba(11, 8, 24, .9); border: 1px solid var(--line2); border-radius: 14px; backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 0 0 1px rgba(178, 107, 255, .12), 0 18px 50px rgba(0, 0, 0, .55), 0 0 36px rgba(140, 80, 255, .22); }
.widget::before { content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit; background: linear-gradient(120deg, rgba(178, 107, 255, .14), transparent 30%, transparent 70%, rgba(63, 216, 255, .1)); }
.widget > header { display: flex; align-items: center; gap: 8px; padding: 7px 8px 7px 12px; cursor: grab; user-select: none; border-bottom: 1px solid var(--line); background: rgba(30, 20, 66, .45); touch-action: none; }
.widget.drag > header { cursor: grabbing; } .widget.drag { opacity: .92; }
.widget > header b { font-size: 13px; letter-spacing: .4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.w-when { color: var(--muted); font-size: 11px; white-space: nowrap; }
.w-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); flex: none; }
.w-dot.live { background: var(--ok); box-shadow: 0 0 8px var(--ok); } .w-dot.ping { transform: scale(1.8); transition: transform .15s; }
.w-btns { display: flex; gap: 2px; } .w-btns button { padding: 1px 7px; font-size: 12px; background: transparent; color: var(--muted); border-radius: 6px; } .w-btns button:hover { color: #fff; background: rgba(178, 107, 255, .25); }
.w-body { flex: 1; min-height: 0; position: relative; }
.w-body iframe { width: 100%; height: 100%; border: 0; display: block; background: #0b0818; }
.w-body img { width: 100%; height: 100%; object-fit: contain; display: block; }
.w-body pre { margin: 0; padding: 8px 12px; font: 12px/1.4 var(--mono); white-space: pre-wrap; color: var(--muted); max-height: 40%; overflow: auto; }
.w-scroll { height: 100%; overflow: auto; } .w-md { padding: 10px 14px; white-space: pre-wrap; font-size: 13px; }
.w-body table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.w-body th { position: sticky; top: 0; background: #1a1238; text-align: left; font-weight: 600; color: #cfc4ff; padding: 6px 10px; border-bottom: 1px solid var(--line2); }
.w-body td { padding: 5px 10px; border-bottom: 1px solid var(--line); } .w-body td.n { text-align: right; font-variant-numeric: tabular-nums; }
.w-body tr:hover td { background: rgba(178, 107, 255, .08); }
.w-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; padding: 10px; height: 100%; overflow: auto; align-content: safe center; }
.w-metric { padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: rgba(25, 18, 55, .5); position: relative; }
.w-metric b { display: block; font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; background: linear-gradient(135deg, #fff, #c9a6ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.w-metric small { color: var(--muted); font-size: 12px; } .w-metric i { position: absolute; top: 8px; right: 10px; font-style: normal; font-size: 12px; } .w-metric i.up { color: var(--ok); } .w-metric i.dn { color: var(--bad); }
.w-note { font-size: 11px; color: var(--muted); padding: 0 12px; } .w-note:not(:empty) { padding: 5px 12px; border-top: 1px solid var(--line); }
.w-open { position: absolute; right: 8px; bottom: 8px; font-size: 11px; padding: 2px 8px; border-radius: 8px; background: rgba(11, 8, 24, .8); color: var(--cyan); text-decoration: none; }
.widget.min { height: auto !important; min-height: 0; resize: none; } .widget.min .w-body, .widget.min .w-note { display: none; }
.widget.max { left: 0 !important; top: 0 !important; width: 100% !important; height: 100% !important; resize: none; }
.widget.hello { animation: holo-in .6s cubic-bezier(.2, .9, .3, 1.2); }
.widget.flash { box-shadow: 0 0 0 1px var(--cyan), 0 0 40px rgba(63, 216, 255, .45); }
.widget.bye { transition: transform .2s, opacity .2s; transform: scale(.9); opacity: 0; }
@keyframes holo-in { 0% { opacity: 0; transform: scale(.82) translateY(14px); filter: brightness(2.2) blur(3px); } 60% { opacity: 1; filter: brightness(1.3) blur(0); } 100% { transform: none; filter: none; } }
@media (max-width: 760px) {
  #widget-layer { position: static; inset: auto; pointer-events: auto; display: flex; flex-direction: column; gap: 10px; }
  #widget-layer:empty { display: none; }
  .widget { position: relative; left: auto !important; top: auto !important; width: 100% !important; height: 300px !important; resize: vertical; }
  .widget.max { position: fixed; inset: 10px; height: auto !important; width: auto !important; z-index: 20; }
}
@media (max-width: 760px) {
  #center { overflow-y: auto; gap: 10px; }
  #stage { flex: 0 0 46vh; min-height: 300px; } #app.has-log #stage { flex: 0 0 32vh; min-height: 230px; }
  #log { flex: none; min-height: 30vh; overflow: visible; }
  .brain-head b { white-space: nowrap; } .brain-head b span { display: none; } .brain-head { top: 10px; gap: 8px; }
  #composer { position: sticky; bottom: 0; z-index: 7; padding: 6px 0 calc(4px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%); }
  #brain-chips { gap: 5px; bottom: 10px; } #orb-label { bottom: 92px; }
}

/* ---- Company ---- */
.co-sec h4 { display: flex; justify-content: space-between; align-items: center; } .co-open { font-size: 11px; padding: 2px 8px; }
.co-mini { padding: 0 12px 10px; font-size: 12px; } .co-row { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; }
#co-board { position: fixed; inset: 0; z-index: 60; background: rgba(3, 2, 10, .72); display: grid; place-items: center; padding: 16px; }
#co-board.hidden { display: none; }
.co-win { position: relative; width: min(1280px, 100%); height: min(860px, 100%); display: flex; flex-direction: column; gap: 10px; padding: 14px; overflow: hidden; }
.co-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; } .co-head h3 { margin: 0; } .co-head .sp { flex: 1; } .co-head select { width: auto; }
.co-agents { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; flex: none; }
.co-agent { display: grid; grid-template-columns: 10px 1fr; gap: 2px 8px; align-items: center; min-width: 190px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel2); }
.co-agent > small, .co-agent > button { grid-column: 2; } .co-agent small { display: block; color: var(--muted); font-size: 11px; } .co-agent button { font-size: 11px; padding: 2px 8px; justify-self: start; }
.co-agent i, .co-run i { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); display: inline-block; }
.st-running, .st-succeeded { background: var(--ok) !important; box-shadow: 0 0 8px var(--ok); } .st-running { animation: pulse 1.2s infinite; }
.st-paused, .st-skipped, .st-cancelled { background: var(--warn) !important; } .st-error, .st-failed, .st-terminated, .st-interrupted { background: var(--bad) !important; } .st-queued { background: var(--cyan) !important; }
.co-cols { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(5, minmax(180px, 1fr)); gap: 8px; overflow: auto; }
.co-col { background: rgba(20, 15, 45, .5); border: 1px solid var(--line); border-radius: 12px; padding: 8px; overflow-y: auto; min-height: 120px; }
.co-col h5 { margin: 0 0 8px; font-size: 12px; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; } .co-col h5 span { float: right; }
.co-card { display: block; width: 100%; text-align: left; margin-bottom: 6px; padding: 8px; border-radius: 10px; border: 1px solid var(--line); border-left: 3px solid var(--accent); background: rgba(34, 27, 66, .7); }
.co-card b { display: block; font-size: 13px; font-weight: 500; margin: 2px 0; } .co-card small { color: var(--muted); font-size: 11px; }
.co-card.pr-critical { border-left-color: var(--bad); } .co-card.pr-high { border-left-color: var(--warn); } .co-card.pr-low { border-left-color: var(--muted); }
.co-runs { flex: none; max-height: 160px; overflow: auto; font-size: 12px; } .co-run { padding: 3px 0; } .co-runs summary { cursor: pointer; color: var(--muted); }
.co-detail { position: absolute; top: 56px; right: 14px; bottom: 14px; width: min(440px, calc(100% - 28px)); display: flex; flex-direction: column; gap: 8px; background: rgba(14, 11, 30, .97); border: 1px solid var(--line2); border-radius: 14px; padding: 14px; z-index: 2; }
.co-detail.hidden { display: none; } .co-desc { white-space: pre-wrap; font-size: 13px; max-height: 140px; overflow: auto; }
.co-comments { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 6px; } .co-c { background: var(--panel2); border-radius: 8px; padding: 6px 8px; font-size: 13px; white-space: pre-wrap; } .co-c small { color: var(--muted); }
.co-cf .row { display: flex; gap: 8px; margin-top: 6px; } .co-cf select { flex: 1; }
@media (max-width: 760px) { .co-cols { grid-template-columns: repeat(5, 78vw); } .co-win { padding: 10px; } }
@keyframes pulse { 50% { opacity: .35; } }
/* ---- Controls ---- */
.ctl-sec { padding-bottom: 8px; } .ctl-free, .ctl-list { padding: 0 12px; } .ctl-more summary { cursor: pointer; color: var(--muted); padding: 6px 12px; font-size: 12px; }
.ctl { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; font-size: 13px; cursor: pointer; border-bottom: 1px solid rgba(150, 120, 255, .08); }
.ctl small { display: block; color: var(--muted); font-size: 11px; } .ctl input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ctl i { flex: none; width: 36px; height: 20px; border-radius: 10px; background: rgba(120, 110, 160, .35); position: relative; transition: .2s; }
.ctl i::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #cfc8ef; transition: .2s; }
.ctl input:checked + i { background: linear-gradient(90deg, var(--accent), var(--accent2)); box-shadow: 0 0 10px rgba(178, 107, 255, .6); } .ctl input:checked + i::after { left: 18px; background: #fff; }
.ctl input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.ctl-chain { padding: 6px 12px 0; font-size: 11px; word-break: break-all; }
.free-badge { font: 600 11px var(--mono, monospace); letter-spacing: .1em; padding: 3px 8px; border-radius: 8px; color: #0b0818; background: linear-gradient(90deg, var(--ok), var(--cyan)); box-shadow: 0 0 12px rgba(62, 240, 165, .6); margin-right: 8px; }
.free-badge.hidden { display: none; }
.focus-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 12px; }
/* Live Screen panel */
#screen-btn { white-space: nowrap; }
#screen-live { color: var(--bad); font-size: 11px; font-weight: 700; margin-left: 4px; animation: pulse 1.6s infinite; }
#screen-panel { position: fixed; right: 16px; top: 96px; width: min(720px, calc(100vw - 32px)); z-index: 60; background: var(--panel-solid); border: 1px solid var(--line2); border-radius: var(--radius); box-shadow: var(--glow); display: flex; flex-direction: column; overflow: hidden; }
#screen-panel.max { inset: 16px; width: auto; }
#screen-panel.yours { border-color: var(--warn); }
.sp-bar { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 13px; flex-wrap: wrap; }
.sp-bar button { padding: 6px 10px; min-height: 36px; }
.sp-gap { flex: 1; }
#sp-view { position: relative; background: #000; aspect-ratio: 16 / 10; }
#screen-panel.max #sp-view { flex: 1; aspect-ratio: auto; }
#sp-view > div:not(#sp-msg) { position: absolute; inset: 0; }
#sp-msg { position: absolute; inset: 0; display: grid; place-items: center; z-index: 1; }
@keyframes pulse { 50% { opacity: .35; } }
@media (max-width: 640px) { #screen-panel { right: 8px; left: 8px; top: 72px; width: auto; } #screen-panel.max { inset: 8px; } }
