:root {
  color-scheme: light;
  --ink: #17152f;
  --muted: #6f7185;
  --line: #e7e7ef;
  --surface: #ffffff;
  --soft: #f6f5fb;
  --accent: #6d5dfc;
  --accent-rgb: 109, 93, 252;
  font-family: "DM Sans", Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: #f4f3f8; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin-top: 0; }
.hidden { display: none !important; }

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 0.85fr) minmax(460px, 1.15fr);
  background: var(--surface);
}
.login-art {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(32px, 6vw, 80px);
  color: white;
  background:
    radial-gradient(circle at 72% 22%, rgba(167, 151, 255, .55), transparent 24%),
    radial-gradient(circle at 12% 88%, rgba(73, 205, 178, .25), transparent 32%),
    linear-gradient(145deg, #17152f 0%, #292059 52%, #5f4ce5 135%);
}
.login-art::after {
  content: "";
  position: absolute;
  width: 440px;
  height: 440px;
  right: -190px;
  bottom: -130px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 50%;
  box-shadow: 0 0 0 70px rgba(255,255,255,.035), 0 0 0 140px rgba(255,255,255,.025);
}
.brand { position: relative; z-index: 1; display: flex; align-items: center; gap: 12px; font: 800 19px "Manrope"; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 13px; background: rgba(255,255,255,.14); backdrop-filter: blur(10px); }
.hero-copy { position: relative; z-index: 1; max-width: 520px; }
.hero-copy h1 { margin-bottom: 18px; font: 800 clamp(40px, 5vw, 72px)/1.03 "Manrope"; letter-spacing: -.045em; }
.hero-copy p { max-width: 440px; color: rgba(255,255,255,.72); font-size: 17px; line-height: 1.65; }
.voice-orb { position: relative; z-index: 1; display: flex; align-items: center; gap: 16px; color: rgba(255,255,255,.8); }
.bars { display: flex; align-items: center; gap: 4px; height: 32px; }
.bars i { display: block; width: 3px; height: 10px; border-radius: 9px; background: #fff; animation: wave 1.1s ease-in-out infinite; }
.bars i:nth-child(2), .bars i:nth-child(5) { animation-delay: -.35s; height: 23px; }
.bars i:nth-child(3) { animation-delay: -.7s; height: 31px; }
.bars i:nth-child(4) { animation-delay: -.15s; height: 17px; }
@keyframes wave { 50% { transform: scaleY(.35); opacity: .55; } }

.login-form-wrap { display: grid; place-items: center; padding: 40px; }
.login-card { width: min(420px, 100%); }
.login-card .kicker, .eyebrow { margin-bottom: 10px; color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.login-card h2 { margin-bottom: 10px; font: 800 36px/1.2 "Manrope"; letter-spacing: -.035em; }
.subtle { color: var(--muted); line-height: 1.55; }
.form-stack { display: grid; gap: 18px; margin-top: 34px; }
.field { display: grid; gap: 8px; }
.field label { font-size: 13px; font-weight: 700; }
.field input, .field textarea, .field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 13px 14px;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border .2s, box-shadow .2s;
}
.field textarea { min-height: 92px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(var(--accent-rgb), .1); }
.primary, .secondary, .ghost {
  min-height: 46px;
  border: 0;
  border-radius: 13px;
  padding: 0 18px;
  font-weight: 800;
}
.primary { color: #fff; background: var(--accent); box-shadow: 0 10px 25px rgba(var(--accent-rgb), .24); }
.secondary { color: var(--ink); background: var(--soft); border: 1px solid var(--line); }
.ghost { color: var(--muted); background: transparent; }
.primary:disabled, .secondary:disabled { opacity: .55; cursor: wait; }
.form-error { min-height: 20px; color: #b42318; font-size: 13px; }

.dashboard { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 28px 20px; color: #fff; background: var(--ink); }
.sidebar .brand { margin: 0 10px 42px; }
.nav-label { margin: 0 12px 10px; color: #8d8ca0; font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; margin-bottom: 7px; border: 0; border-radius: 12px; padding: 12px 14px; color: #aaa8bd; background: transparent; text-align: left; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-item.active { color: #fff; background: rgba(255,255,255,.1); }
.sidebar-footer { position: absolute; right: 20px; bottom: 24px; left: 20px; }
.user-pill { padding: 13px; border-radius: 14px; background: rgba(255,255,255,.07); }
.user-pill strong, .user-pill span { display: block; overflow: hidden; text-overflow: ellipsis; }
.user-pill span { margin-top: 3px; color: #9492a7; font-size: 12px; }
.dashboard-main { min-width: 0; padding: 34px clamp(24px, 4vw, 56px) 60px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 32px; }
.topbar h1 { margin-bottom: 7px; font: 800 32px/1.2 "Manrope"; letter-spacing: -.035em; }
.status-chip { display: inline-flex; align-items: center; gap: 8px; border: 1px solid #dcebe5; border-radius: 999px; padding: 8px 12px; color: #39715a; background: #f0faf6; font-size: 12px; font-weight: 700; }
.status-chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #39a875; }
.studio-grid { display: grid; grid-template-columns: minmax(320px, .8fr) minmax(390px, 1.2fr); gap: 24px; align-items: start; }
.card { border: 1px solid var(--line); border-radius: 20px; padding: 24px; background: #fff; box-shadow: 0 10px 35px rgba(28, 24, 61, .045); }
.card + .card { margin-top: 20px; }
.card h2 { margin-bottom: 6px; font: 800 19px "Manrope"; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.settings-stack { display: grid; gap: 17px; }
.avatar-row { display: flex; align-items: center; gap: 16px; }
.avatar-preview { display: grid; place-items: center; flex: 0 0 auto; width: 76px; height: 76px; overflow: hidden; border-radius: 22px; color: #fff; background: var(--accent); font: 800 24px "Manrope"; }
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.upload-button { position: relative; overflow: hidden; }
.upload-button input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.color-row { display: grid; grid-template-columns: 54px 1fr; gap: 10px; }
.color-row input[type="color"] { height: 48px; padding: 5px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; padding-top: 4px; }
.embed-code { position: relative; margin-top: 16px; border-radius: 14px; padding: 16px 48px 16px 16px; color: #d9d7ea; background: #201e36; font: 12px/1.6 Consolas, monospace; overflow-wrap: anywhere; }
.copy-mini { position: absolute; top: 10px; right: 10px; border: 0; border-radius: 8px; padding: 7px; color: #fff; background: rgba(255,255,255,.1); }
.preview-shell { padding: 14px; border-radius: 22px; background: linear-gradient(145deg, #eceaf5, #f9f8fc); }
.preview-shell iframe { display: block; width: 100%; height: 610px; border: 0; border-radius: 18px; background: #fff; box-shadow: 0 18px 45px rgba(32, 29, 63, .13); }
.agent-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 20px; }
.agent-card { min-height: 315px; display: flex; flex-direction: column; }
.agent-card-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; }
.agent-avatar { display: grid; place-items: center; width: 62px; height: 62px; overflow: hidden; border-radius: 18px; color: #fff; background: var(--accent); font: 800 19px "Manrope"; }
.agent-avatar img { width: 100%; height: 100%; object-fit: cover; }
.agent-status { border-radius: 999px; padding: 6px 9px; color: #777589; background: #f0eff5; font-size: 11px; font-weight: 800; text-transform: capitalize; }
.agent-status.active { color: #287052; background: #eaf8f1; }
.agent-description { min-height: 43px; margin-bottom: 18px; }
.agent-meta { display: grid; gap: 9px; margin: 0 0 22px; }
.agent-meta div { display: flex; justify-content: space-between; gap: 15px; border-bottom: 1px solid var(--line); padding-bottom: 9px; }
.agent-meta dt { color: var(--muted); font-size: 12px; }
.agent-meta dd { margin: 0; font-size: 12px; font-weight: 800; text-align: right; }
.agent-edit { width: 100%; margin-top: auto; }
.empty-state { min-height: 300px; display: grid; place-items: center; align-content: center; text-align: center; }
.empty-state .subtle { max-width: 470px; }
.empty-icon { display: grid; place-items: center; width: 64px; height: 64px; margin-bottom: 18px; border-radius: 20px; color: var(--accent); background: rgba(var(--accent-rgb), .1); }
.empty-icon svg { width: 28px; height: 28px; fill: currentColor; }
.install-layout { display: grid; grid-template-columns: minmax(360px, 1.15fr) minmax(300px, .85fr); gap: 20px; align-items: start; }
.install-agent-field { margin: 20px 0 34px; }
.step-number { margin-bottom: 8px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.install-code { min-height: 82px; }
.guide-card { background: linear-gradient(145deg, #fff, #f7f6fc); }
.guide-check { display: grid; grid-template-columns: 30px 1fr; gap: 12px; align-items: start; margin-top: 20px; }
.guide-check > span { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; color: #fff; background: var(--accent); font-size: 12px; font-weight: 800; }
.guide-check p { margin: 3px 0 0; color: var(--muted); line-height: 1.5; }
.guide-note { margin-top: 26px; border: 1px solid #ddd9fa; border-radius: 14px; padding: 14px; color: #55516f; background: #f3f1ff; font-size: 12px; line-height: 1.55; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; border-radius: 12px; padding: 13px 17px; color: #fff; background: #201e36; box-shadow: 0 12px 36px rgba(0,0,0,.2); }

.embed-page { min-height: 100vh; display: grid; place-items: center; padding: 12px; background: transparent; }
.voice-widget { width: min(420px, 100%); height: min(590px, calc(100vh - 24px)); display: flex; flex-direction: column; overflow: hidden; border: 1px solid rgba(25, 22, 53, .09); border-radius: 24px; background: #fff; box-shadow: 0 24px 70px rgba(29, 25, 65, .16); }
.widget-head { display: flex; align-items: center; gap: 13px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.widget-avatar { display: grid; place-items: center; width: 48px; height: 48px; overflow: hidden; border-radius: 15px; color: #fff; background: var(--accent); font: 800 16px "Manrope"; }
.widget-avatar img { width: 100%; height: 100%; object-fit: cover; }
.widget-title { min-width: 0; flex: 1; }
.widget-title strong, .widget-title span { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.widget-title strong { font: 800 15px "Manrope"; }
.widget-title span { margin-top: 4px; color: #3f9b72; font-size: 11px; font-weight: 700; }
.widget-title span::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 5px; border-radius: 50%; background: #3fbb83; }
.widget-download { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; padding: 7px 9px; border: 0; border-radius: 9px; color: var(--accent); background: #f1efff; cursor: pointer; font-size: 11px; font-weight: 800; }
.widget-download[hidden] { display: none; }
.widget-download:hover { background: #e8e4ff; }
.widget-download svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.conversation { flex: 1; overflow-y: auto; padding: 22px 18px; background: linear-gradient(#fbfafe, #fff); }
.widget-hero { display: grid; justify-items: center; padding: 10px 0 18px; }
.hero-avatar { display: grid; place-items: center; width: 96px; height: 96px; overflow: hidden; border: 5px solid #fff; border-radius: 30px; color: #fff; background: var(--accent); box-shadow: 0 13px 35px rgba(var(--accent-rgb), .22); font: 800 26px "Manrope"; }
.hero-avatar img { width: 100%; height: 100%; object-fit: cover; }
.welcome { max-width: 300px; margin: 18px auto 8px; color: var(--muted); text-align: center; line-height: 1.55; }
.message { display: flex; gap: 10px; margin-bottom: 14px; }
.message.user { justify-content: flex-end; }
.bubble { max-width: 82%; border-radius: 17px 17px 17px 5px; padding: 11px 13px; color: #38364d; background: #f0eff5; font-size: 14px; line-height: 1.45; }
.message.user .bubble { border-radius: 17px 17px 5px 17px; color: #fff; background: var(--accent); }
.bubble.markdown { max-width: 90%; }
.bubble.markdown h3, .bubble.markdown h4, .bubble.markdown h5 { margin: 12px 0 5px; color: #24263a; font-size: 14px; line-height: 1.35; }
.bubble.markdown h3:first-child, .bubble.markdown h4:first-child, .bubble.markdown h5:first-child, .bubble.markdown p:first-child { margin-top: 0; }
.bubble.markdown p { margin: 0 0 8px; }
.bubble.markdown p:last-child, .bubble.markdown ul:last-child, .bubble.markdown ol:last-child { margin-bottom: 0; }
.bubble.markdown ul, .bubble.markdown ol { margin: 5px 0 10px; padding-left: 19px; }
.bubble.markdown li { margin: 3px 0; }
.bubble.markdown code { padding: 1px 4px; border-radius: 3px; background: #dedee8; font-size: .92em; }
.widget-controls { padding: 16px 18px 19px; border-top: 1px solid var(--line); background: #fff; }
.listen-status { min-height: 20px; margin-bottom: 10px; color: var(--muted); font-size: 12px; text-align: center; }
.mic-row { display: flex; align-items: center; justify-content: center; gap: 15px; }
.mic-button { display: grid; place-items: center; width: 58px; height: 58px; border: 0; border-radius: 50%; color: #fff; background: var(--accent); box-shadow: 0 10px 28px rgba(var(--accent-rgb), .3); transition: transform .2s; }
.talk-button { width: auto; min-width: 148px; height: 54px; display: inline-flex; gap: 10px; border-radius: 999px; padding: 0 23px; font-weight: 800; }
.talk-button span { display: inline; }
.mic-button:hover { transform: translateY(-2px); }
.mic-button.recording { animation: pulse 1.4s infinite; }
.mic-button svg { width: 24px; height: 24px; fill: currentColor; }
.end-button { border: 0; padding: 8px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 700; }
.powered { margin-top: 11px; color: #a2a0ae; font-size: 10px; text-align: center; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), .35); } 70% { box-shadow: 0 0 0 14px rgba(var(--accent-rgb), 0); } }

@media (max-width: 900px) {
  .login-page { grid-template-columns: 1fr; }
  .login-art { min-height: 340px; }
  .hero-copy h1 { font-size: 44px; }
  .dashboard { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; display: flex; align-items: center; padding: 16px 20px; }
  .sidebar .brand { margin: 0; }
  .sidebar nav, .sidebar-footer { display: none; }
  .studio-grid { grid-template-columns: 1fr; }
  .install-layout { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .login-art { display: none; }
  .login-form-wrap { min-height: 100vh; padding: 28px; }
  .dashboard-main { padding: 24px 16px 40px; }
  .topbar { display: block; }
  .status-chip { margin-top: 12px; }
  .card { padding: 19px; border-radius: 17px; }
  .preview-shell iframe { height: 560px; }
}
