/* ==========================================================================
   Messvate — demo web app
   ========================================================================== */

body.app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.app-bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.app-bg .aurora { position: absolute; border-radius: 50%; filter: blur(110px); opacity: .22; }
.app-bg .a1 { width: 600px; height: 600px; left: 20%; top: -320px; background: #7c5cff; }
.app-bg .a2 { width: 500px; height: 500px; right: -200px; bottom: -200px; background: #22e0c0; opacity: .14; }
.muted { color: var(--text-3); }
.small { font-size: 13px; }

/* ---------- top bar ---------- */
.topbar {
  position: relative; z-index: 5; flex: none;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
  height: 64px; padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-right { justify-content: flex-end; }
.demo-tag { font-size: 10.5px; letter-spacing: .12em; padding: 3px 8px; border-radius: 6px; background: var(--token-bg); color: var(--token); }
.shield-status {
  display: inline-flex; align-items: center; gap: 10px; padding: 7px 14px; border-radius: 999px;
  background: var(--surface-solid); border: 1px solid var(--border); font-size: 13.5px;
}
.shield-status .led { width: 8px; height: 8px; border-radius: 50%; background: var(--safe); box-shadow: 0 0 0 4px var(--safe-bg); animation: pulse 2s infinite; }
.shield-status strong { color: var(--safe); }
.shield-status .mono { font-size: 12px; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--border); background: var(--surface-2); }
.icon-btn svg { width: 18px; height: 18px; }
.only-mobile { display: none; }

/* ---------- layout ---------- */
.layout {
  position: relative; z-index: 1; flex: 1; min-height: 0;
  display: grid; grid-template-columns: 280px minmax(0, 1fr) 360px;
}
.side, .inspector { overflow-y: auto; padding: 20px 16px 32px; scrollbar-width: thin; }
.side { border-right: 1px solid var(--border); }
.inspector { border-left: 1px solid var(--border); background: color-mix(in srgb, var(--bg-2) 60%, transparent); }
.panel { margin-bottom: 26px; }
.panel-title { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--text-3); font-weight: 600; margin: 0 0 12px; }
.panel-title .mono { text-transform: none; letter-spacing: 0; }
.hint { font-size: 13px; color: var(--text-2); margin: 10px 2px 0; min-height: 40px; }

/* provider picker */
.providers-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.prov-opt {
  position: relative; display: flex; align-items: center; gap: 8px; padding: 10px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); font-size: 13.5px; font-weight: 600; text-align: left;
  transition: border-color .2s, background .2s, transform .2s var(--ease-out);
}
.prov-opt:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.prov-opt.is-active { border-color: var(--violet); background: var(--token-bg); }
.prov-opt i { width: 24px; height: 24px; flex: none; border-radius: 7px; display: grid; place-items: center; font-style: normal; font-size: 11px; color: #fff; font-weight: 700; }
.prov-opt small { display: block; font-weight: 400; font-size: 11px; color: var(--text-3); }

/* segmented control */
.seg { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); padding: 4px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.seg button { position: relative; z-index: 1; height: 34px; font-size: 13.5px; font-weight: 600; color: var(--text-2); transition: color .25s; }
.seg button.is-active { color: var(--text); }
.seg-pill { position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc((100% - 8px) / 3); border-radius: 9px; background: var(--surface-solid); box-shadow: var(--shadow); transition: transform .45s var(--ease-out); }

/* types */
.types { display: grid; gap: 4px; }
.type-row {
  display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 10px; font-size: 14px; cursor: pointer;
  transition: background .2s;
}
.type-row:hover { background: var(--surface-2); }
.type-row .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.type-row .eng { margin-left: auto; font-size: 10.5px; font-family: var(--font-mono); color: var(--text-3); }
.type-row .eng.claude { color: #d97757; }
.toggle { position: relative; width: 30px; height: 18px; flex: none; border-radius: 999px; background: var(--border-strong); transition: background .25s; }
.toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .3s var(--ease-out); box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.type-row input { position: absolute; opacity: 0; pointer-events: none; }
.type-row input:checked + .toggle { background: var(--violet); }
.type-row input:checked + .toggle::after { transform: translateX(12px); }

.engines .engine-row { display: grid; grid-template-columns: 12px 1fr; column-gap: 10px; font-size: 14px; font-weight: 500; padding: 6px 2px; }
.engines .engine-row .mono { grid-column: 2; font-size: 11.5px; font-weight: 400; }
.engines .dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 7px; }
.dot.local { background: var(--violet); box-shadow: 0 0 8px var(--violet); }
.dot.claude { background: #d97757; box-shadow: 0 0 8px #d97757; }

/* ---------- main / chat ---------- */
.main { position: relative; display: flex; flex-direction: column; min-height: 0; }
.chat { flex: 1; overflow-y: auto; padding: 28px clamp(16px, 4vw, 48px) 16px; scroll-behavior: smooth; }
.empty { max-width: 640px; margin: 6vh auto 0; text-align: center; }
.empty-icon { position: relative; width: 92px; height: 92px; margin: 0 auto 24px; display: grid; place-items: center; }
.empty-icon svg { width: 56px; height: 56px; filter: drop-shadow(0 12px 30px var(--glow)); }
.empty-icon .orbit { position: absolute; inset: 0; border-radius: 50%; border: 1.5px dashed var(--border-strong); animation: spin 14s linear infinite; }
.empty-icon .orbit::after { content: ""; position: absolute; top: -4px; left: 50%; width: 8px; height: 8px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 12px var(--teal); }
.empty h1 { font-family: var(--font-display); font-size: clamp(30px, 4.5vw, 46px); line-height: 1.05; letter-spacing: -.035em; margin: 0 0 14px; }
.empty p { color: var(--text-2); margin: 0 auto 28px; max-width: 480px; }
.samples { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; text-align: left; }
.sample {
  text-align: left;
  padding: 14px 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border);
  font-size: 14px; color: var(--text-2); line-height: 1.5;
  transition: border-color .2s, transform .25s var(--ease-out), box-shadow .25s;
}
.sample strong { display: block; color: var(--text); font-size: 14px; margin-bottom: 4px; }
.sample:hover { border-color: var(--violet); transform: translateY(-3px); box-shadow: var(--shadow); }
@media (max-width: 560px) { .samples { grid-template-columns: 1fr; } }

/* messages */
.msg { max-width: 760px; margin: 0 auto 22px; display: flex; gap: 12px; }
.msg.user { justify-content: flex-end; }
.bubble { position: relative; max-width: 86%; padding: 14px 18px; border-radius: 18px; line-height: 1.7; font-size: 15.5px; word-wrap: break-word; }
.bubble .content { white-space: pre-wrap; }
.msg.user .bubble { background: var(--surface-solid); border: 1px solid var(--border-strong); border-bottom-right-radius: 6px; }
.msg.ai .bubble { background: transparent; padding-left: 0; padding-top: 4px; max-width: 100%; }
.avatar { width: 32px; height: 32px; flex: none; border-radius: 10px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 12px; }
.msg-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; font-size: 12px; color: var(--text-3); white-space: normal; }
.meta-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; background: var(--safe-bg); color: var(--safe); font-weight: 600; }
.meta-pill svg { width: 12px; height: 12px; }
.view-toggle { font-size: 12px; color: var(--token); padding: 3px 9px; border-radius: 999px; border: 1px solid var(--token-bg); transition: background .2s; }
.view-toggle:hover { background: var(--token-bg); }
.typing { display: inline-flex; gap: 4px; padding: 8px 0; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); animation: bounce 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .4; } 40% { transform: translateY(-5px); opacity: 1; } }
.stream-caret { display: inline-block; width: 7px; height: 1em; background: var(--violet); vertical-align: -2px; margin-left: 2px; animation: pulse .9s steps(1) infinite; }
.rehydrate-sweep { position: relative; }
.rehydrate-sweep::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--safe-bg), transparent);
  transform: translateX(-100%); animation: sweep 1s var(--ease-out) forwards;
}
@keyframes sweep { to { transform: translateX(100%); } }

/* ---------- composer ---------- */
.composer { flex: none; padding: 0 clamp(16px, 4vw, 48px) 16px; }
.composer > * { max-width: 760px; margin-left: auto; margin-right: auto; }
.live-bar { display: flex; align-items: center; gap: 12px; padding: 0 4px 10px; min-height: 36px; }
.live-chips { display: flex; gap: 6px; flex: 1; overflow-x: auto; scrollbar-width: none; font-size: 13px; }
.live-chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; white-space: nowrap;
  font-size: 12px; font-weight: 600; background: var(--surface-solid); border: 1px solid var(--border);
}
.chip i { width: 7px; height: 7px; border-radius: 50%; }
.chip b { font-family: var(--font-mono); font-weight: 500; color: var(--text-3); }
.risk { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-3); flex: none; }
.risk-track { width: 70px; height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.risk-fill { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--teal), var(--amber), var(--pink)); background-size: 70px 100%; transition: width .5s var(--ease-out); }
.risk .mono { width: 22px; text-align: right; color: var(--text-2); }

.input-wrap {
  position: relative; display: flex; align-items: flex-end;
  border-radius: 22px; background: var(--surface-solid); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow); transition: border-color .25s, box-shadow .25s;
}
.input-wrap:focus-within { border-color: var(--violet); box-shadow: 0 0 0 4px var(--token-bg), var(--shadow); }
.input-wrap.has-sensitive:focus-within { border-color: var(--sensitive); box-shadow: 0 0 0 4px var(--sensitive-bg), var(--shadow); }
.backdrop, #input {
  font-family: var(--font-sans); font-size: 15.5px; line-height: 1.6; letter-spacing: normal;
  padding: 16px 64px 16px 20px; margin: 0; border: 0;
  white-space: pre-wrap; word-wrap: break-word; overflow-wrap: break-word;
}
.backdrop { position: absolute; inset: 0; color: transparent; overflow: hidden; pointer-events: none; }
.backdrop mark { color: transparent; border-radius: 5px; background: var(--sensitive-bg); box-shadow: inset 0 -2px 0 var(--sensitive); }
.backdrop mark.claude { background: rgba(217, 119, 87, .16); box-shadow: inset 0 -2px 0 #d97757; }
#input {
  position: relative; flex: 1; width: 100%; resize: none; outline: none; background: transparent;
  max-height: 220px; min-height: 56px; overflow-y: auto;
}
#input::placeholder { color: var(--text-3); }
.send {
  position: absolute; right: 10px; bottom: 9px; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; color: #fff; background: var(--grad);
  box-shadow: 0 6px 20px -6px var(--glow); transition: transform .25s var(--ease-out), opacity .2s;
}
.send svg { width: 18px; height: 18px; }
.send:hover { transform: scale(1.08); }
.send:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.composer-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 8px 6px 0; font-size: 12px; color: var(--text-3); }
.kbd { font-family: var(--font-mono); font-size: 11px; padding: 1px 5px; border-radius: 4px; border: 1px solid var(--border-strong); }

/* ---------- inspector ---------- */
.insp-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.link-btn { font-size: 12.5px; color: var(--sensitive); }
.link-btn:hover { text-decoration: underline; }
.pipeline { position: relative; display: grid; gap: 2px; margin: 8px 0 24px; }
.pipeline::before { content: ""; position: absolute; left: 11px; top: 16px; bottom: 16px; width: 2px; background: var(--border); }
.pl-step { position: relative; display: flex; gap: 12px; padding: 8px 0; font-size: 14px; color: var(--text-3); transition: color .3s; }
.pl-step div { display: flex; flex-direction: column; }
.pl-step .mono { font-size: 11.5px; color: var(--text-3); min-height: 1em; }
.pl-dot { position: relative; z-index: 1; width: 24px; height: 24px; flex: none; border-radius: 50%; background: var(--surface-solid); border: 2px solid var(--border-strong); transition: border-color .3s, background .3s, box-shadow .3s; }
.pl-step.is-running { color: var(--text); }
.pl-step.is-running .pl-dot { border-color: var(--violet); box-shadow: 0 0 0 5px var(--token-bg); }
.pl-step.is-running .pl-dot::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; border: 2px solid var(--violet); border-top-color: transparent; animation: spin .7s linear infinite; }
.pl-step.is-done { color: var(--text); }
.pl-step.is-done .pl-dot { border-color: var(--safe); background: var(--safe) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5L20 7'/%3E%3C/svg%3E") center/12px no-repeat; }
.pl-step.is-skipped { opacity: .45; }
.insp-block { margin-bottom: 24px; }
.insp-block h3 { display: flex; justify-content: space-between; font-size: 13px; margin: 0 0 10px; font-weight: 600; }
.wire {
  margin: 0; padding: 14px; border-radius: 12px; font-size: 12.5px; line-height: 1.7;
  background: var(--surface-2); border: 1px solid var(--border); white-space: pre-wrap; word-break: break-word; max-height: 220px; overflow: auto;
}
.wire .tk { color: var(--token); background: var(--token-bg); border-radius: 4px; padding: 0 3px; }
.vault { display: grid; gap: 6px; }
.vault-row {
  display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: center;
  padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); font-size: 12.5px;
}
.vault-row .tk { font-family: var(--font-mono); color: var(--token); font-size: 12px; }
.vault-row .val { font-family: var(--font-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.vault-row .lbl { grid-column: 1 / -1; font-size: 11px; color: var(--text-3); display: flex; gap: 6px; align-items: center; }
.vault-row .lbl i { width: 6px; height: 6px; border-radius: 50%; }

/* ---------- responsive ---------- */
@media (max-width: 1240px) {
  .layout { grid-template-columns: minmax(0, 1fr) 340px; }
  .side {
    position: fixed; z-index: 20; top: 64px; bottom: 0; left: 0; width: 300px;
    background: var(--surface-solid); box-shadow: var(--shadow-lg);
    transform: translateX(-105%); transition: transform .45s var(--ease-out);
  }
  .side.is-open { transform: none; }
  .only-mobile { display: grid; }
}
@media (max-width: 860px) {
  body.app { height: auto; overflow: auto; }
  .layout { display: block; }
  .main { min-height: calc(100dvh - 64px); }
  .chat { overflow: visible; }
  .composer { position: sticky; bottom: 0; padding-top: 28px; background: linear-gradient(transparent, var(--bg) 28px); }
  .composer-foot > span:first-child { display: none; }
  .inspector { border-left: 0; border-top: 1px solid var(--border); overflow: visible; }
  .topbar { grid-template-columns: auto 1fr; }
  .topbar-center { display: none; }
  .demo-tag { display: none; }
  .topbar { position: sticky; top: 0; }
}
@media (max-width: 420px) { .topbar-right .btn { padding: 0 12px; } .risk-track { width: 44px; } }
