/* Studio Pro AI — LMArena-style chat (no battles: single-model chat) */
* { box-sizing: border-box; margin: 0; padding: 0; }
/* author display rules (.userbox{display:flex}, .btn{…}) otherwise beat the
   UA [hidden] rule and leak hidden boxes — e.g. an empty "Sign out" for guests */
[hidden] { display: none !important; }
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --border: #e4e6ea;
  --text: #1a1a1e;
  --muted: #76777f;
  --brand: #7c5cff;
  --brand-2: #4ea8ff;
  --ok: #16a34a;
  --danger: #dc2626;
  --ring: rgba(124, 92, 255, .35);
  --shadow-sm: 0 1px 2px rgba(16, 18, 24, .06);
  --shadow-md: 0 4px 16px rgba(16, 18, 24, .10);
  --shadow-lg: 0 18px 50px rgba(16, 18, 24, .16);
}
html, body { height: 100%; }
body {
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background:
    radial-gradient(900px 420px at 12% -8%, rgba(124, 92, 255, .10), transparent 60%),
    radial-gradient(900px 420px at 88% -8%, rgba(78, 168, 255, .10), transparent 60%),
    var(--bg);
  color: var(--text);
  display: flex; flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---- top bar ---- */
.app { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 10px 18px; flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand .logo { width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0; display: block; }
.p-logo { width: 44px; height: 44px; border-radius: 11px; display: block; margin: 0 auto; }
.brand-name { font-weight: 750; font-size: 15px; letter-spacing: -.01em; line-height: 1.2; }
.brand-name small { display: block; font-weight: 500; color: var(--muted); font-size: 11px; margin-top: 1px; }
.top-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ---- user box ---- */
.userbox { display: flex; align-items: center; gap: 10px; }
.userbox .who { font-size: 12.5px; font-weight: 650; text-align: right; line-height: 1.25; }
.userbox .who small { display: block; font-weight: 600; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .05em; }
.userbox .row { display: flex; gap: 6px; }

/* ---- buttons ---- */
.btn {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 12px; font-weight: 600;
  cursor: pointer; transition: border-color .15s, background-color .15s, box-shadow .15s, opacity .15s;
}
.btn:hover { border-color: var(--brand); box-shadow: var(--shadow-sm); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.btn.grad { background: linear-gradient(135deg, var(--brand), var(--brand-2)); border: 0; color: #fff; }
.btn.grad:hover { box-shadow: 0 4px 14px rgba(124, 92, 255, .35); }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; border-color: #f1c3cc; color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); background: #fdf0f2; box-shadow: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---- chat column ---- */
.main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat {
  flex: 1; overflow-y: auto; width: 100%; max-width: 860px; margin: 0 auto;
  padding: 26px 20px 10px; display: flex; flex-direction: column; gap: 18px;
}
.msg { display: flex; align-items: flex-start; gap: 10px; max-width: 86%; }
.msg.user { align-self: flex-end; justify-content: flex-end; }

/* agent avatar — gradient circle with spark */
.av {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; margin-top: 1px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 2px 8px rgba(124, 92, 255, .35);
  display: grid; place-items: center; color: #fff; font-size: 13px;
}
.av::before { content: "✦"; }

.bubble {
  padding: 10px 15px; border-radius: 18px; white-space: pre-wrap; overflow-wrap: break-word;
  animation: pop .18s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.msg.user .bubble {
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff;
  border-bottom-right-radius: 6px; box-shadow: 0 3px 12px rgba(124, 92, 255, .28);
  max-width: 100%;
}
.msg.agent .bubble {
  background: var(--surface); border: 1px solid var(--border);
  border-bottom-left-radius: 6px; box-shadow: var(--shadow-sm);
}
.msg.err { align-self: flex-start; }
.msg.err .bubble {
  background: #fdf0f2; border: 1px solid #f1c3cc; color: #b4232f;
  border-bottom-left-radius: 6px;
}
.msg .who { display: none; } /* role is obvious from alignment + avatar */
.msg b { font-weight: 700; }
.msg.user b { color: #fff; }
.msg code {
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 1px 5px; border-radius: 6px; font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.msg.user code { background: rgba(255,255,255,.22); border-color: transparent; color: #fff; }

/* CTA card: rendered from a [[CTA|label|url]] marker the model puts at the end
   of an answer. Only Studio Pro destinations pass safeCTA(), so this is safe to
   style as a first-party button. */
.cta {
  display: flex; align-items: center; gap: 10px;
  margin-top: 9px; padding: 9px 13px;
  border: 1px solid var(--border); border-radius: 13px;
  background: linear-gradient(135deg, rgba(124, 92, 255, .09), rgba(78, 168, 255, .09));
  text-decoration: none; color: var(--text); white-space: normal;
  transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease;
}
.cta:hover { border-color: var(--brand); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.cta:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.cta-i {
  width: 26px; height: 26px; flex-shrink: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; font-size: 14px; line-height: 1;
}
.cta-t { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.cta-t b { font-size: 13px; font-weight: 700; }
.cta-t small { color: var(--muted); font-size: 11px; }
.mono {
  background: var(--surface-2) !important;
  border: 1px solid var(--border) !important; color: var(--text) !important;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* typing indicator */
.msg.typing .bubble { display: flex; align-items: center; gap: 6px; padding: 12px 15px; }
.dots { display: inline-flex; gap: 4px; }
.dots i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--muted);
  animation: bounce 1.2s infinite ease-in-out;
}
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }

/* ---- composer ---- */
.composer {
  width: 100%; max-width: 860px; margin: 0 auto; padding: 8px 20px 4px;
  display: flex; gap: 10px; align-items: flex-end;
}
.composer textarea {
  flex: 1; resize: none; background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: 18px; padding: 13px 16px; font: inherit; font-size: 14px;
  min-height: 48px; max-height: 160px; outline: none; box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
.composer textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.composer textarea::placeholder { color: #a4a5ad; }
.composer button {
  width: 46px; height: 46px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff;
  border: 0; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 4px 14px rgba(124, 92, 255, .35); transition: opacity .15s, transform .1s, box-shadow .15s;
}
.composer button:hover:not(:disabled) { box-shadow: 0 6px 20px rgba(124, 92, 255, .45); transform: translateY(-1px); }
.composer button:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }
.hint { font-size: 11px; color: var(--muted); text-align: center; padding: 10px 20px 16px; }
.hint a { color: var(--muted); text-decoration: none; font-weight: 600; transition: color .15s, text-decoration-color .15s; text-underline-offset: 2px; }
.hint a:hover { color: var(--brand); text-decoration: underline; }

/* ---- auth overlay ---- */
.overlay {
  position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center;
  background: rgba(24, 25, 32, .5); backdrop-filter: blur(8px);
}
.overlay.hidden, .modal.hidden { display: none; }
.panel {
  width: 360px; max-width: calc(100vw - 32px); background: var(--surface);
  border: 1px solid var(--border); border-radius: 20px; padding: 28px 26px;
  box-shadow: var(--shadow-lg); animation: pop .2s ease-out;
  text-align: center;
}
.panel .t { font-size: 18px; font-weight: 750; margin: 14px 0 3px; letter-spacing: -.01em; }
.panel .s { font-size: 12.5px; color: var(--muted); margin-bottom: 20px; }
.field { width: 100%; margin-bottom: 13px; text-align: left; }
.field label { display: block; font-size: 11px; font-weight: 650; color: var(--muted); margin-bottom: 5px; letter-spacing: .02em; }
.field input, .field select {
  width: 100%; background: var(--surface-2); color: var(--text); border: 1px solid transparent;
  border-radius: 12px; padding: 11px 13px; font: inherit; font-size: 13.5px; outline: none;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
.field input:focus, .field select:focus { background: var(--surface); border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.formerr { font-size: 12px; color: var(--danger); margin: -4px 0 12px; min-height: 0; }
.panel .btn { width: 100%; padding: 12px; font-size: 13.5px; }

/* ---- users modal ---- */
.modal {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: rgba(24, 25, 32, .5); backdrop-filter: blur(8px);
}
.modal .panel { width: 500px; max-height: 82vh; display: flex; flex-direction: column; text-align: left; }
.modal .panel .hd { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal .panel .hd .t { margin: 0; }
.modal .panel .hd .btn { width: auto; padding: 6px 14px; font-size: 12px; }
.modal .scroll { overflow-y: auto; margin: 0 -6px 0 0; padding-right: 6px; }
.chip { font-size: 12px; color: var(--muted); }
.user-row {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px;
  border: 1px solid var(--border); border-radius: 14px; margin-bottom: 8px;
  background: var(--surface); box-shadow: var(--shadow-sm);
}
.user-row .u { flex: 1; min-width: 0; }
.user-row .u b { display: block; font-size: 13px; overflow-wrap: break-word; }
.user-row .u small { color: var(--muted); font-size: 11px; }
.tag { font-size: 10px; font-weight: 750; text-transform: uppercase; letter-spacing: .05em; padding: 3px 9px; border-radius: 999px; }
.tag.admin { background: rgba(124, 92, 255, .12); color: #6d4cff; }
.tag.user { background: rgba(22, 163, 74, .12); color: #15803d; }
.user-row .btn.danger { width: auto; padding: 5px 12px; font-size: 11.5px; }
.add-user { border-top: 1px solid var(--border); margin-top: 16px; padding-top: 16px; }
.add-user .row { display: flex; gap: 10px; }
.add-user .row .field { flex: 1; margin-bottom: 0; }
.add-user .row .btn { width: auto; padding: 11px 16px; align-self: flex-end; height: 42px; }

/* ---- scrollbars ---- */
.chat::-webkit-scrollbar, .scroll::-webkit-scrollbar { width: 9px; }
.chat::-webkit-scrollbar-thumb, .scroll::-webkit-scrollbar-thumb { background: #d4d6db; border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
.chat::-webkit-scrollbar-thumb:hover, .scroll::-webkit-scrollbar-thumb:hover { background: #b9bcc4; border: 2px solid transparent; background-clip: content-box; }

/* ---- small screens ---- */
@media (max-width: 620px) {
  .top { padding: 10px 12px; }
  .brand-name small { display: none; }
  .chat { padding: 18px 12px 8px; max-width: none; }
  .msg { max-width: 92%; }
  .composer { padding: 8px 12px 4px; max-width: none; }
}

/* ==== ?embed=1 — the floating widget on prostudio.my =====================
   Dark, site-matched palette (site: #070B0D surfaces, violet #7C46E8 glow)
   and no chrome of our own: the widget bar supplies the title and the close
   button, so the frame gets maximum chat space. */
html.embed, html.embed body {
  background: #070B0D;
}
html.embed {
  --bg: #070B0D;
  --surface: #0E0B1E;
  --surface-2: #171233;
  --border: rgba(124, 70, 232, .28);
  --text: #F1EAFF;
  --muted: rgba(241, 234, 255, .55);
  --brand: #7C46E8;
  --brand-2: #A78BFA;
  --ring: rgba(124, 70, 232, .45);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, .55);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, .7);
}
html.embed .top, html.embed .hint { display: none !important; }
html.embed .chat { padding-top: 12px; }
html.embed .msg.user .bubble { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; }
html.embed .msg.err .bubble {
  background: rgba(232, 93, 117, .14); border-color: rgba(232, 93, 117, .45); color: #FFD9DF;
}
html.embed .cta {
  background: linear-gradient(135deg, rgba(124, 70, 232, .20), rgba(167, 139, 250, .12));
}
html.embed .chat::-webkit-scrollbar-thumb, html.embed .scroll::-webkit-scrollbar-thumb {
  background: #3A2E6E; border: 2px solid transparent; background-clip: content-box;
}
html.embed .chat::-webkit-scrollbar-thumb:hover, html.embed .scroll::-webkit-scrollbar-thumb:hover {
  background: #5442A6; border: 2px solid transparent; background-clip: content-box;
}
html.embed .overlay { background: rgba(7, 11, 13, .92); }
html.embed .card { background: var(--surface); border-color: var(--border); }