/* SYNTHOOD app — #ask view (app-ask.js): chat with your synth. Scoped to .sa; colours from the Synthood palette with local
   fallbacks so the view looks right before and after the shell re-skin. */
.sa {
  --sa-ink: #05070D; --sa-p0: #0A0E18; --sa-p1: #0D1220; --sa-p2: #111829; --sa-line: #1A2236; --sa-line2: #243049;
  --sa-t0: #EEF3FF; --sa-t1: #B9C2D9; --sa-t2: #8A94AD; --sa-lime: #C8FF3A; --sa-lime-ink: #0B1000; --sa-cool: #7CC8FF;
  --sa-up: #3DDC97; --sa-down: #FF5470; --sa-warn: #FFC15A;
  --sa-mono: var(--mono, 'Geist Mono', 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace);
  --sa-sans: var(--sans, 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif);
  --sa-r: 14px; --sa-ease: cubic-bezier(.19, 1, .22, 1);
  display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; color: var(--sa-t0); font-family: var(--sa-sans);
}
.sa *, .sa *::before, .sa *::after { box-sizing: border-box; }
.sa svg { width: 16px; height: 16px; flex: none; }
.sa-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sa .sa-label { margin: 0 0 10px; font: 500 10.5px/1.2 var(--sa-mono); letter-spacing: .16em; color: var(--sa-t2); text-transform: uppercase; }
.sa .sa-label em { font-style: normal; color: var(--sa-t1); }
.sa .sa-label em.is-up { color: var(--sa-lime); }
.sa-fine { display: flex; gap: 7px; margin: 10px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--sa-t2); }
.sa-fine svg { width: 13px; height: 13px; margin-top: 2px; }

/* ---------- chat panel ---------- */
.sa-chat {
  position: relative; display: flex; flex-direction: column; min-width: 0;
  height: clamp(540px, calc(100svh - var(--sa-offset, 170px)), 880px);
  background: linear-gradient(180deg, rgba(13, 18, 32, .92), rgba(8, 11, 20, .96)), var(--sa-p0);
  border: 1px solid var(--sa-line); border-radius: var(--sa-r); overflow: hidden;
  box-shadow: 0 1px 0 rgba(238, 243, 255, .04) inset, 0 30px 80px -40px rgba(0, 0, 0, .8);
}
.sa-chat::before { content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: linear-gradient(rgba(124, 200, 255, .035) 1px, transparent 1px), linear-gradient(90deg, rgba(124, 200, 255, .035) 1px, transparent 1px);
  background-size: 28px 28px; mask-image: radial-gradient(120% 70% at 50% 0%, #000 30%, transparent 80%); -webkit-mask-image: radial-gradient(120% 70% at 50% 0%, #000 30%, transparent 80%); }
.sa-tick { position: absolute; width: 12px; height: 12px; pointer-events: none; z-index: 2; }
.sa-tick--tl { top: 7px; left: 7px; border-top: 1.5px solid var(--sa-lime); border-left: 1.5px solid var(--sa-lime); }
.sa-tick--br { right: 7px; bottom: 7px; border-right: 1.5px solid var(--sa-lime); border-bottom: 1.5px solid var(--sa-lime); }

.sa-head { position: relative; z-index: 1; display: flex; align-items: center; gap: 13px; padding: 16px 20px; border-bottom: 1px solid var(--sa-line); background: rgba(5, 7, 13, .55); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.sa-id { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.sa-name { font-size: 16.5px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sa-state { display: inline-flex; align-items: center; gap: 7px; font: 500 10.5px/1 var(--sa-mono); letter-spacing: .14em; color: var(--sa-t2); white-space: nowrap; overflow: hidden; }
.sa-state span { overflow: hidden; text-overflow: ellipsis; }
.sa-state i { width: 7px; height: 7px; border-radius: 50%; background: var(--sa-up); box-shadow: 0 0 0 3px rgba(61, 220, 151, .14); flex: none; }
.sa-state.is-think i { background: var(--sa-cool); box-shadow: 0 0 0 3px rgba(124, 200, 255, .16); animation: sa-pulse 1s ease-in-out infinite; }
.sa-state.is-talk i { background: var(--sa-lime); box-shadow: 0 0 0 3px rgba(200, 255, 58, .16); animation: sa-pulse .7s ease-in-out infinite; }
.sa-state.is-off { color: var(--sa-warn); }
.sa-state.is-off i { background: var(--sa-warn); box-shadow: 0 0 0 3px rgba(255, 193, 90, .14); }
.sa-ctl { display: flex; align-items: center; gap: 8px; flex: none; }
.sa-quota { display: inline-flex; align-items: baseline; gap: 2px; height: 32px; padding: 0 11px; border: 1px solid var(--sa-line2); border-radius: 999px; font: 500 12.5px/30px var(--sa-mono); color: var(--sa-t1); }
.sa-quota b { color: var(--sa-t0); font-weight: 600; }
.sa-quota small { margin-left: 6px; font-size: 9.5px; letter-spacing: .14em; color: var(--sa-t2); }
.sa-quota.is-low b { color: var(--sa-warn); }
.sa-quota.is-out { border-color: rgba(255, 84, 112, .45); }
.sa-quota.is-out b { color: var(--sa-down); }
.sa-voice { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--sa-line2); background: transparent; color: var(--sa-t2); cursor: pointer;
  font: 500 10.5px/1 var(--sa-mono); letter-spacing: .14em; transition: color .2s, border-color .2s, background-color .2s; }
.sa-voice:hover { color: var(--sa-t0); border-color: #33415f; }
.sa-voice.is-on { color: var(--sa-lime-ink); background: var(--sa-lime); border-color: var(--sa-lime); }
.sa-voice svg { width: 14px; height: 14px; }

/* ---------- avatar ---------- */
.sa-av { position: relative; display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 10px; background: var(--sa-p2); border: 1px solid var(--sa-line2); overflow: visible; }
.sa-av img { width: 100%; height: 100%; border-radius: inherit; image-rendering: pixelated; display: block; }
.sa-av__mark { width: 46%; height: 46%; border-radius: 3px; border: 1.5px solid var(--sa-lime); box-shadow: inset 0 0 0 3px var(--sa-p2), inset 0 0 0 7px rgba(200, 255, 58, .5); }
.sa-av__ring { position: absolute; inset: -4px; border-radius: 13px; border: 1.5px solid var(--sa-lime); opacity: 0; transform: scale(.94); transition: opacity .25s, transform .25s; pointer-events: none; }
.sa-av--head { width: 44px; height: 44px; border-radius: 12px; }
.sa-av--head .sa-av__ring { border-radius: 15px; }
.sa-av--big { width: 64px; height: 64px; border-radius: 14px; }
.sa-av--hero { width: 88px; height: 88px; border-radius: 20px; box-shadow: 0 0 0 6px rgba(200, 255, 58, .05), 0 24px 60px -20px rgba(200, 255, 58, .25); }
.sa-av--hero .sa-av__ring { border-radius: 24px; inset: -6px; }
.sa-root.is-speaking .sa-av--head .sa-av__ring, .sa-root.is-speaking .sa-av--hero .sa-av__ring { opacity: 1; transform: scale(1); animation: sa-ring 1.1s ease-in-out infinite; }

/* ---------- log + messages ---------- */
.sa-log { position: relative; z-index: 1; flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 22px 20px 12px; display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth; scrollbar-width: thin; scrollbar-color: var(--sa-line2) transparent; }
.sa-log > * { flex-shrink: 0; }
.sa-msg { display: flex; gap: 11px; max-width: 100%; animation: sa-in .45s var(--sa-ease) both; }
.sa-msg--me { flex-direction: column; align-items: flex-end; align-self: flex-end; max-width: min(78%, 560px); }
.sa-msg--me p { margin: 0; padding: 11px 15px; border-radius: 14px 14px 4px 14px; background: #162038; border: 1px solid #22305080; color: var(--sa-t0); font-size: 15px; line-height: 1.5; overflow-wrap: anywhere; }
.sa-msg time, .sa-msg__f time { font: 500 10px/1 var(--sa-mono); letter-spacing: .1em; color: #5f6a85; }
.sa-msg--me time { margin-top: 6px; }
.sa-msg--synth { align-self: flex-start; max-width: min(92%, 700px); }
.sa-msg--synth > .sa-av { margin-top: 2px; }
.sa-msg__b { min-width: 0; }
.sa-msg__a { margin: 0; padding: 12px 16px; border-radius: 4px 14px 14px 14px; background: rgba(17, 24, 41, .85); border: 1px solid var(--sa-line); font-size: 15.5px; line-height: 1.6; color: var(--sa-t0); overflow-wrap: anywhere; white-space: pre-wrap; }
.sa-msg__a.is-typing::after { content: ''; display: inline-block; width: 7px; height: 1.05em; margin-left: 3px; vertical-align: -2px; background: var(--sa-lime); animation: sa-caret .8s steps(1) infinite; }
.sa-msg__f { display: flex; align-items: center; gap: 4px; margin-top: 6px; padding-left: 4px; min-height: 26px; }
.sa-msg__f time { margin-left: 6px; }
.sa-ib { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; border: 0; background: transparent; color: var(--sa-t2); cursor: pointer; transition: color .2s, background-color .2s; }
.sa-ib:hover { color: var(--sa-t0); background: rgba(238, 243, 255, .05); }
.sa-ib.is-on { color: var(--sa-lime); }
.sa-ib svg { width: 15px; height: 15px; }
.sa-tag { margin-left: 8px; padding: 3px 7px; border-radius: 5px; border: 1px solid var(--sa-line2); font: 500 9.5px/1 var(--sa-mono); letter-spacing: .12em; color: var(--sa-t2); }
.sa-tag--ex { color: var(--sa-warn); border-color: rgba(255, 193, 90, .4); }
.sa-msg.is-think .sa-msg__b { padding: 12px 16px; border-radius: 4px 14px 14px 14px; background: rgba(17, 24, 41, .6); border: 1px dashed var(--sa-line2); }
.sa-dots { display: flex; align-items: center; gap: 5px; margin: 0; font: 500 10.5px/1 var(--sa-mono); letter-spacing: .14em; color: var(--sa-t2); text-transform: uppercase; }
.sa-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--sa-cool); animation: sa-dot 1.1s ease-in-out infinite; }
.sa-dots i:nth-child(2) { animation-delay: .15s; } .sa-dots i:nth-child(3) { animation-delay: .3s; }
.sa-dots span { margin-left: 8px; }
.sa-msg--sys { flex-direction: column; align-self: stretch; gap: 6px; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--sa-line2); background: rgba(13, 18, 32, .9); font-size: 14px; color: var(--sa-t1); }
.sa-msg--sys b { color: var(--sa-t0); }
.sa-msg--sys p { margin: 0; }
.sa-msg--sys.is-warn { border-color: rgba(255, 193, 90, .35); }
.sa-msg--sys.is-err { border-color: rgba(255, 84, 112, .35); }
.sa-msg--sys .sa-btn { align-self: flex-start; margin-top: 4px; }

/* ---------- tool card (terminal) ---------- */
.sa-tool { align-self: flex-start; width: min(100%, 560px); margin-left: 45px; border: 1px solid var(--sa-line2); border-radius: 10px; background: #070A12; font-family: var(--sa-mono); overflow: hidden; animation: sa-in .45s var(--sa-ease) both; }
.sa-tool__h { display: flex; align-items: center; gap: 9px; padding: 10px 12px; border-bottom: 1px solid var(--sa-line); font-size: 11px; letter-spacing: .12em; color: var(--sa-t1); }
.sa-tool__h svg { width: 15px; height: 15px; color: var(--sa-cool); }
.sa-tool__h b { font-weight: 600; color: var(--sa-t0); }
.sa-tool__h code { color: var(--sa-t2); letter-spacing: .02em; font-family: inherit; }
.sa-tool__st { margin-left: auto; font-size: 10px; letter-spacing: .14em; color: var(--sa-cool); }
.sa-tool.is-done .sa-tool__st { color: var(--sa-up); }
.sa-tool.is-err .sa-tool__st { color: var(--sa-down); }
.sa-tool.is-stop .sa-tool__st { color: var(--sa-t2); }
.sa-tool__x { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-left: 4px; border: 1px solid var(--sa-line2); border-radius: 6px; background: transparent; color: var(--sa-t2); cursor: pointer; }
.sa-tool__x:hover { color: var(--sa-t0); }
.sa-tool__x svg { width: 11px; height: 11px; }
.sa-tool__bar { height: 2px; background: var(--sa-line); }
.sa-tool__bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--sa-cool), var(--sa-lime)); transition: width .35s var(--sa-ease); }
.sa-tool.is-done .sa-tool__bar i { background: var(--sa-up); }
.sa-tool.is-err .sa-tool__bar i { background: var(--sa-down); }
.sa-tool__log { list-style: none; margin: 0; padding: 9px 12px 11px; display: grid; gap: 4px; font-size: 11.5px; line-height: 1.45; color: var(--sa-t2); min-height: 20px; }
.sa-tool__log li { overflow-wrap: anywhere; }
.sa-tool__log li::before { content: '› '; color: #4b5672; }
.sa-tool__log li:last-child { color: var(--sa-t1); }
.sa-tool__log li.is-ok { color: var(--sa-up); } .sa-tool__log li.is-warn { color: var(--sa-warn); } .sa-tool__log li.is-err { color: var(--sa-down); }
.sa-tool__go { display: inline-flex; align-items: center; gap: 6px; margin: 0 12px 12px; font-size: 11px; letter-spacing: .08em; color: var(--sa-lime); text-decoration: none; }
.sa-tool__go:hover { text-decoration: underline; }
.sa-tool__go svg { width: 13px; height: 13px; }

/* ---------- empty state ---------- */
.sa-empty { margin: auto 0; padding: 26px 6px 10px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; animation: sa-in .6s var(--sa-ease) both; }
.sa-empty h2 { margin: 10px 0 0; font-size: clamp(24px, 3.2vw, 32px); font-weight: 600; letter-spacing: -.025em; }
.sa-empty > p { margin: 0; max-width: 520px; font-size: 15px; line-height: 1.6; color: var(--sa-t1); }
.sa-sugg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; width: min(100%, 600px); margin-top: 14px; }
.sa-chip { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; padding: 12px 14px; border-radius: 11px; border: 1px solid var(--sa-line2); background: rgba(13, 18, 32, .8); color: var(--sa-t0); font: 500 14px/1.35 var(--sa-sans); text-align: left; cursor: pointer; transition: border-color .2s, background-color .2s, transform .3s var(--sa-ease); }
.sa-chip small { font: 500 9.5px/1 var(--sa-mono); letter-spacing: .14em; color: var(--sa-t2); text-transform: uppercase; }
.sa-chip:hover { border-color: rgba(200, 255, 58, .55); background: rgba(200, 255, 58, .045); transform: translateY(-1px); }
.sa-chip:hover small { color: var(--sa-lime); }

/* ---------- compose ---------- */
.sa-compose { position: relative; z-index: 1; padding: 12px 16px 14px; border-top: 1px solid var(--sa-line); background: rgba(5, 7, 13, .7); }
.sa-compose__box { display: flex; align-items: flex-end; gap: 8px; padding: 7px 7px 7px 14px; border-radius: 13px; border: 1px solid var(--sa-line2); background: var(--sa-p1); transition: border-color .2s, box-shadow .2s; cursor: text; }
.sa-compose__box:focus-within { border-color: rgba(200, 255, 58, .6); box-shadow: 0 0 0 4px rgba(200, 255, 58, .08); }
.sa-prompt { align-self: center; font: 600 17px/1 var(--sa-mono); color: var(--sa-lime); }
.sa-compose textarea { flex: 1; min-width: 0; min-height: 38px; max-height: 150px; resize: none; padding: 9px 2px; border: 0; outline: 0; background: transparent; color: var(--sa-t0); font: 400 15.5px/1.45 var(--sa-sans); }
.sa-compose textarea::placeholder { color: #5f6a85; }
.sa-send { display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none; border: 0; border-radius: 10px; background: var(--sa-lime); color: var(--sa-lime-ink); cursor: pointer; transition: transform .25s var(--sa-ease), opacity .2s, box-shadow .2s; }
.sa-send:hover:not(:disabled) { box-shadow: 0 8px 26px -8px rgba(200, 255, 58, .7); transform: translateY(-1px); }
.sa-send:disabled { opacity: .35; cursor: not-allowed; }
.sa-send svg { width: 18px; height: 18px; }
.sa-compose__meta { display: flex; justify-content: space-between; gap: 12px; margin-top: 8px; padding: 0 4px; font-size: 11.5px; color: #66718c; }
.sa-kbd { font-family: var(--sa-mono); font-size: 10.5px; letter-spacing: .04em; white-space: nowrap; }

/* ---------- rail ---------- */
.sa-rail { display: grid; gap: 14px; position: sticky; top: calc(var(--nav-h, 72px) + 14px); }
.sa-panel { position: relative; padding: 18px; border-radius: var(--sa-r); border: 1px solid var(--sa-line); background: var(--sa-p0); }
.sa-me { display: flex; gap: 14px; align-items: flex-start; }
.sa-me__t { min-width: 0; flex: 1; }
.sa-me__n { display: block; font-size: 16px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sa-me > div > .sa-fine { margin-top: 0; }
.sa-me .sa-btn { margin-top: 12px; }
.sa-addr { display: inline-flex; align-items: center; gap: 5px; margin-top: 3px; font: 500 12px/1.3 var(--sa-mono); color: var(--sa-cool); text-decoration: none; }
.sa-addr svg { width: 12px; height: 12px; opacity: .7; }
.sa-addr:hover { text-decoration: underline; }
.sa-kv { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 12px 0 0; }
.sa-kv div { min-width: 0; }
.sa-kv dt { font: 500 9.5px/1.2 var(--sa-mono); letter-spacing: .14em; color: var(--sa-t2); }
.sa-kv dd { margin: 3px 0 0; font: 500 14px/1.2 var(--sa-mono); color: var(--sa-t0); }
.sa-caps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.sa-caps li { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; line-height: 1.4; color: var(--sa-t1); }
.sa-caps li svg { color: var(--sa-lime); margin-top: 1px; }
.sa-caps b { color: var(--sa-t0); font-weight: 600; }
.sa-meter { height: 6px; border-radius: 99px; background: var(--sa-line); overflow: hidden; }
.sa-meter i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--sa-lime), var(--sa-cool)); transition: width .6s var(--sa-ease); }
.sa-planline { margin: 10px 0 0; font-size: 14px; color: var(--sa-t1); }
.sa-planline b { color: var(--sa-t0); font-family: var(--sa-mono); font-weight: 600; }
.sa-btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--sa-line2); background: transparent; color: var(--sa-t0); font: 550 13.5px/1 var(--sa-sans); text-decoration: none; cursor: pointer; white-space: nowrap; transition: border-color .2s, background-color .2s, color .2s; }
.sa-btn svg { width: 14px; height: 14px; }
.sa-btn--ghost:hover { border-color: #3a4867; background: rgba(238, 243, 255, .03); }
.sa-btn--lime { background: var(--sa-lime); border-color: var(--sa-lime); color: var(--sa-lime-ink); }
.sa-btn--lime:hover { box-shadow: 0 8px 26px -10px rgba(200, 255, 58, .7); }
.sa-panel .sa-btn { margin-top: 12px; width: 100%; }

/* ---------- motion ---------- */
@keyframes sa-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes sa-dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@keyframes sa-caret { 50% { opacity: 0; } }
@keyframes sa-pulse { 50% { opacity: .35; } }
@keyframes sa-ring { 0%, 100% { opacity: .9; transform: scale(1); } 50% { opacity: .35; transform: scale(1.06); } }
@media (prefers-reduced-motion: reduce) { .sa *, .sa *::before, .sa *::after { animation: none !important; transition: none !important; } .sa-log { scroll-behavior: auto; } }

/* ---------- widths ---------- */
@media (max-width: 1100px) { .sa { grid-template-columns: minmax(0, 1fr) 260px; } }
@media (max-width: 900px) {
  .sa { grid-template-columns: minmax(0, 1fr); }
  .sa-rail { position: static; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sa-rail > :nth-child(2) { display: none; }
}
@media (max-width: 600px) {
  .sa { gap: 12px; }
  .sa-chat { height: calc(100svh - var(--sa-offset-m, 150px)); min-height: 460px; border-radius: 12px; }
  .sa-head { padding: 12px 14px; gap: 10px; }
  .sa-av--head { width: 38px; height: 38px; }
  .sa-name { font-size: 15px; }
  .sa-state { font-size: 9.5px; letter-spacing: .1em; }
  .sa-voice span { display: none; }
  .sa-voice { width: 32px; padding: 0; justify-content: center; }
  .sa-quota small { display: none; }
  .sa-log { padding: 16px 12px 10px; gap: 12px; }
  .sa-msg--me { max-width: 88%; }
  .sa-msg--synth { max-width: 100%; }
  .sa-msg--synth > .sa-av { width: 28px; height: 28px; border-radius: 8px; }
  .sa-msg__a { font-size: 15px; padding: 11px 13px; }
  .sa-tool { margin-left: 0; }
  .sa-sugg { grid-template-columns: minmax(0, 1fr); }
  .sa-av--hero { width: 72px; height: 72px; }
  .sa-compose { padding: 10px 10px 12px; }
  .sa-compose__meta .sa-kbd { display: none; }
  .sa-rail { grid-template-columns: minmax(0, 1fr); }
}
