:root {
  color-scheme: dark;
  --bg: #070912;
  --panel: rgba(17, 20, 34, .72);
  --panel-strong: rgba(21, 25, 42, .94);
  --text: #f4f6fb;
  --muted: #9da6ba;
  --line: rgba(255, 255, 255, .09);
  --accent: #8b5cf6;
  --danger: #ef4444;
  --success: #22c55e;
  --shadow: 0 24px 70px rgba(0, 0, 0, .34);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--text); background:
  radial-gradient(circle at 20% -10%, rgba(139, 92, 246, .16), transparent 34%),
  radial-gradient(circle at 95% 10%, rgba(6, 182, 212, .1), transparent 30%),
  linear-gradient(180deg, #090b15 0%, #060810 100%); }
body, button, input, textarea, select { font: inherit; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { outline: none; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }

.glass-panel { border: 1px solid var(--line); background: linear-gradient(150deg, rgba(255,255,255,.055), rgba(255,255,255,.018)); backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px); box-shadow: var(--shadow); }
.muted { color: var(--muted); line-height: 1.7; }
.eyebrow { margin: 0 0 10px; color: #b8a8ff; font-size: .75rem; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
.brand { display: inline-flex; align-items: center; gap: 11px; font-weight: 800; letter-spacing: -.02em; }
.brand-mark { width: 54px; height: 54px; border-radius: 18px; display: grid; place-items: center; color: white; font-weight: 900; background: linear-gradient(145deg, #8b5cf6, #5b21b6); box-shadow: 0 15px 35px rgba(139,92,246,.34), inset 0 1px rgba(255,255,255,.35); }
.brand-mark.small { width: 37px; height: 37px; border-radius: 12px; font-size: .75rem; }

.primary-button, .secondary-button, .subtle-button, .danger-button { border: 0; border-radius: 14px; min-height: 46px; padding: 0 19px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 800; transition: transform .18s ease, opacity .18s ease, border-color .18s ease; }
.primary-button { color: #fff; background: linear-gradient(135deg, #8b5cf6, #6d28d9); box-shadow: 0 13px 30px rgba(109,40,217,.28); }
.secondary-button { color: #e6e9f2; border: 1px solid var(--line); background: rgba(255,255,255,.035); }
.subtle-button { min-height: 40px; padding: 0 15px; color: #d8dcea; border: 1px solid var(--line); background: rgba(255,255,255,.035); }
.danger-button { color: #fecaca; border: 1px solid rgba(239,68,68,.3); background: rgba(239,68,68,.1); }
.primary-button:hover, .secondary-button:hover, .subtle-button:hover, .danger-button:hover { transform: translateY(-1px); }
.compact-button { min-height: 40px; padding-inline: 15px; font-size: .9rem; }

.alert { padding: 14px 16px; border-radius: 14px; margin: 0 0 18px; line-height: 1.5; border: 1px solid var(--line); }
.alert.error { color: #fecaca; background: rgba(239,68,68,.1); border-color: rgba(239,68,68,.24); }
.alert.success { color: #bbf7d0; background: rgba(34,197,94,.1); border-color: rgba(34,197,94,.24); }
.alert.info { color: #bfdbfe; background: rgba(59,130,246,.1); border-color: rgba(59,130,246,.24); }

/* Setup and login */
.setup-page { display: grid; place-items: center; padding: 36px 18px; }
.setup-shell { width: min(820px, 100%); }
.setup-card { border-radius: 30px; padding: clamp(26px, 5vw, 50px); }
.setup-card h1 { margin: 18px 0 10px; font-size: clamp(2rem, 5vw, 3.5rem); letter-spacing: -.055em; line-height: 1; }
.login-card { width: min(520px, 100%); margin-inline: auto; }
.back-link { display: inline-block; margin-top: 22px; color: var(--muted); font-size: .9rem; }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; margin-top: 28px; }
.form-grid.single-column { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: 9px; min-width: 0; }
.field > span, .check-field > span { color: #d8dce7; font-size: .84rem; font-weight: 750; }
.field small { color: #7f899e; font-size: .76rem; line-height: 1.45; }
.field input, .field textarea, .field select { width: 100%; border: 1px solid var(--line); border-radius: 13px; color: var(--text); background: rgba(4,7,15,.62); padding: 13px 14px; transition: border-color .16s ease, box-shadow .16s ease; }
.field input, .field select { min-height: 47px; }
.field textarea { resize: vertical; line-height: 1.55; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: rgba(139,92,246,.7); box-shadow: 0 0 0 4px rgba(139,92,246,.1); }
.field input[type="color"] { padding: 6px; min-height: 47px; }
.field input[type="file"] { padding: 10px; }
.field.full, .full { grid-column: 1 / -1; }
.check-field { display: flex; align-items: center; gap: 10px; align-self: end; min-height: 46px; }
.check-field.inline { min-height: 0; margin-top: 10px; }
.check-field input, .toggle-field input { accent-color: #8b5cf6; width: 17px; height: 17px; }
.toggle-field { display: flex; gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: 15px; padding: 14px; background: rgba(255,255,255,.025); }
.toggle-field > span { display: flex; flex-direction: column; gap: 3px; }
.toggle-field strong { font-size: .9rem; }
.toggle-field small { color: var(--muted); }
.readout { min-height: 47px; display: flex; align-items: center; border: 1px dashed var(--line); border-radius: 13px; padding: 12px 14px; color: var(--muted); background: rgba(255,255,255,.018); word-break: break-word; }

/* Home */
.home-page { overflow-x: hidden; }
.ambient { position: fixed; width: 420px; height: 420px; border-radius: 50%; filter: blur(95px); opacity: .16; pointer-events: none; }
.ambient-one { left: -180px; top: 10%; background: #8b5cf6; }
.ambient-two { right: -180px; bottom: 10%; background: #0891b2; }
.site-header { width: min(1180px, calc(100% - 36px)); margin: 0 auto; height: 88px; display: flex; align-items: center; justify-content: space-between; }
.home-main { width: min(1180px, calc(100% - 36px)); margin: 0 auto; padding: 70px 0 90px; }
.hero { max-width: 780px; margin-bottom: 52px; }
.hero h1 { margin: 0; max-width: 760px; font-size: clamp(3.2rem, 9vw, 7.3rem); line-height: .94; letter-spacing: -.075em; }
.hero h1 span { color: transparent; background: linear-gradient(100deg,#a78bfa,#67e8f9); background-clip: text; -webkit-background-clip: text; }
.hero > p:last-child { max-width: 620px; color: var(--muted); font-size: 1.08rem; line-height: 1.7; }
.bot-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 20px; }
.bot-card { position: relative; min-height: 260px; padding: 26px; border-radius: 25px; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; isolation: isolate; transition: transform .22s ease, border-color .22s ease; }
.bot-card::after { content:""; position:absolute; width:180px; height:180px; border-radius:50%; right:-75px; top:-75px; background:var(--accent); filter:blur(55px); opacity:.2; z-index:-1; }
.bot-card:hover { transform: translateY(-5px); border-color: color-mix(in srgb, var(--accent) 55%, transparent); }
.bot-avatar { position: relative; width: 72px; height: 72px; border-radius: 23px; display: grid; place-items: center; overflow: visible; background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 80%, white 8%), color-mix(in srgb, var(--accent) 70%, black)); box-shadow: 0 17px 40px color-mix(in srgb, var(--accent) 28%, transparent); font-size: 1.5rem; font-weight: 900; }
.bot-avatar img { width:100%; height:100%; object-fit:cover; border-radius:inherit; }
.bot-avatar i { position:absolute; width:14px; height:14px; right:-2px; bottom:1px; border-radius:50%; border:3px solid #101321; background:#22c55e; }
.bot-avatar.compact { width: 48px; height: 48px; border-radius: 16px; font-size: 1rem; flex: 0 0 auto; }
.bot-avatar.compact i { width:11px; height:11px; border-width:2px; }
.bot-card-copy h2 { margin: 0 0 8px; font-size: 1.35rem; letter-spacing: -.035em; }
.bot-card-copy p { margin:0; color:var(--muted); line-height:1.55; font-size:.91rem; }
.card-arrow { position:absolute; right:24px; top:26px; width:36px; height:36px; border-radius:50%; display:grid; place-items:center; color:#cbd2e2; background:rgba(255,255,255,.06); border:1px solid var(--line); }
.empty-state { border-radius: 24px; padding: 38px; text-align:center; }
.site-footer { padding: 0 18px 34px; text-align:center; color:#6f788d; font-size:.8rem; }

/* Chat */
.chat-page { height: 100vh; overflow: hidden; background:
  radial-gradient(circle at 50% 105%, color-mix(in srgb, var(--accent) 17%, transparent), transparent 40%),
  linear-gradient(180deg,#090b14,#060810); }
.chat-app { width: min(920px, 100%); height: 100%; margin: 0 auto; display: grid; grid-template-rows: auto 1fr auto; padding: 14px 16px 12px; }
.chat-header { min-height: 72px; border-radius: 21px; padding: 10px 14px; display:flex; align-items:center; gap:13px; z-index:3; }
.icon-button { width: 42px; height: 42px; border-radius: 13px; border:1px solid var(--line); color:#dce1ec; background:rgba(255,255,255,.035); display:grid; place-items:center; font-weight:800; }
.chat-identity { display:flex; align-items:center; gap:12px; min-width:0; flex:1; }
.chat-identity h1 { margin:0; font-size:1rem; letter-spacing:-.02em; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.chat-identity p { margin:4px 0 0; color:var(--muted); font-size:.75rem; }
.online-dot { display:inline-block; width:7px; height:7px; margin-right:5px; border-radius:50%; background:#22c55e; box-shadow:0 0 10px rgba(34,197,94,.8); }
.header-actions { display:flex; align-items:center; gap:8px; }
.voice-switch { min-height:42px; padding:0 12px; border:1px solid var(--line); border-radius:13px; display:flex; gap:8px; align-items:center; color:#bfc6d5; font-size:.8rem; background:rgba(255,255,255,.035); }
.voice-switch input { accent-color:var(--accent); }
.voice-switch.disabled { opacity:.42; }
.messages { min-height:0; overflow-y:auto; padding:26px 4px 18px; scrollbar-width:thin; scrollbar-color:rgba(255,255,255,.12) transparent; }
.message-row { display:flex; gap:10px; align-items:flex-end; margin:0 0 15px; animation:messageIn .22s ease both; }
.message-row.user { justify-content:flex-end; }
.message-avatar { flex:0 0 auto; width:30px; height:30px; border-radius:10px; display:grid; place-items:center; overflow:hidden; color:white; font-size:.7rem; font-weight:900; background:linear-gradient(145deg,var(--accent),color-mix(in srgb,var(--accent) 70%,black)); }
.message-avatar img { width:100%; height:100%; object-fit:cover; }
.message-bubble { max-width:min(76%,680px); padding:13px 16px; border-radius:18px 18px 18px 6px; color:#e9ecf4; background:rgba(26,30,47,.9); border:1px solid rgba(255,255,255,.075); box-shadow:0 10px 30px rgba(0,0,0,.18); }
.message-row.user .message-bubble { border-radius:18px 18px 6px 18px; color:white; background:linear-gradient(135deg,color-mix(in srgb,var(--accent) 86%,white 3%),color-mix(in srgb,var(--accent) 75%,black)); border-color:transparent; }
.message-text { white-space:pre-wrap; overflow-wrap:anywhere; line-height:1.58; font-size:.94rem; }
.error-message .message-bubble { border-color:rgba(239,68,68,.28); background:rgba(127,29,29,.22); }
.typing-bubble { display:flex; gap:5px; align-items:center; min-width:60px; min-height:43px; }
.typing-bubble i { width:6px; height:6px; border-radius:50%; background:#8f98ad; animation:typing 1.1s infinite ease-in-out; }
.typing-bubble i:nth-child(2){animation-delay:.14s}.typing-bubble i:nth-child(3){animation-delay:.28s}
.suggestion-row { display:flex; flex-wrap:wrap; gap:8px; margin:0 0 18px 40px; animation:messageIn .22s ease both; }
.suggestion-chip { border:1px solid color-mix(in srgb,var(--accent) 35%,var(--line)); border-radius:999px; padding:9px 13px; color:#dce2ef; background:color-mix(in srgb,var(--accent) 9%,rgba(255,255,255,.025)); font-size:.8rem; }
.composer-wrap { position:relative; z-index:4; }
.mic-status { min-height:24px; padding:0 8px 7px; text-align:center; color:#7d879d; font-size:.75rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.mic-status[data-state="listening"] { color:#c4b5fd; }
.mic-status[data-state="processing"] { color:#67e8f9; }
.mic-status[data-state="error"] { color:#fca5a5; }
.composer { min-height:64px; border-radius:21px; display:flex; align-items:flex-end; gap:9px; padding:8px; }
.composer textarea { flex:1; min-height:46px; max-height:140px; resize:none; border:0; color:#edf0f7; background:transparent; padding:12px 9px; line-height:1.45; }
.composer textarea::placeholder { color:#667087; }
.send-button, .mic-button { position:relative; flex:0 0 auto; width:48px; height:48px; border:0; border-radius:15px; color:white; display:grid; place-items:center; }
.send-button { background:linear-gradient(135deg,var(--accent),color-mix(in srgb,var(--accent) 70%,black)); font-size:1rem; box-shadow:0 12px 25px color-mix(in srgb,var(--accent) 25%,transparent); }
.mic-button { overflow:visible; color:#dfe4ef; background:rgba(255,255,255,.06); border:1px solid var(--line); touch-action:none; user-select:none; -webkit-user-select:none; }
.mic-button:disabled, .send-button:disabled { opacity:.45; cursor:not-allowed; }
.mic-glyph { width:14px; height:20px; border-radius:8px; background:currentColor; color:inherit; font-size:0; position:relative; }
.mic-glyph::before { content:""; position:absolute; left:50%; bottom:-7px; width:18px; height:11px; border:2px solid currentColor; border-top:0; border-radius:0 0 12px 12px; transform:translateX(-50%); }
.mic-glyph::after { content:""; position:absolute; left:50%; bottom:-11px; width:2px; height:6px; background:currentColor; transform:translateX(-50%); }
.mic-rings { position:absolute; inset:-3px; border:2px solid transparent; border-radius:18px; pointer-events:none; }
.mic-button.listening { color:white; background:linear-gradient(135deg,#ef4444,#be123c); border-color:transparent; box-shadow:0 0 0 7px rgba(239,68,68,.1),0 12px 30px rgba(239,68,68,.28); transform:scale(1.04); }
.mic-button.listening .mic-rings { border-color:rgba(248,113,113,.5); animation:micPulse 1.15s infinite; }
.disclaimer { margin:7px 0 0; text-align:center; color:#545d70; font-size:.68rem; }

/* Admin */
.admin-page { min-height:100vh; }
.admin-shell { min-height:100vh; display:grid; grid-template-columns:250px minmax(0,1fr); }
.admin-sidebar { position:sticky; top:0; height:100vh; padding:25px 18px; border-right:1px solid var(--line); background:rgba(8,10,18,.88); backdrop-filter:blur(25px); z-index:20; display:flex; flex-direction:column; }
.admin-sidebar nav { display:flex; flex-direction:column; gap:5px; margin-top:38px; }
.admin-sidebar nav a, .logout-link { padding:12px 13px; border-radius:12px; color:#9ca5b8; font-size:.88rem; font-weight:650; }
.admin-sidebar nav a:hover, .admin-sidebar nav a.active { color:white; background:rgba(139,92,246,.12); }
.logout-link { margin-top:auto; color:#fca5a5; }
.admin-main { width:100%; max-width:1320px; padding:34px clamp(20px,4vw,58px) 70px; min-width:0; }
.admin-topbar { display:flex; align-items:center; justify-content:space-between; margin-bottom:28px; }
.admin-topbar h1 { margin:0; font-size:clamp(2rem,4vw,3.15rem); letter-spacing:-.055em; }
.mobile-nav-button { display:none; width:42px; height:42px; border:1px solid var(--line); border-radius:12px; color:white; background:rgba(255,255,255,.04); }
.admin-actions-row, .form-toolbar { display:flex; align-items:center; justify-content:space-between; gap:20px; margin-bottom:22px; }
.admin-actions-row p, .form-toolbar p { margin:0; }
.stat-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:16px; margin-bottom:22px; }
.stat-card { border-radius:20px; padding:22px; display:flex; flex-direction:column; gap:5px; }
.stat-card strong { font-size:2rem; letter-spacing:-.05em; }
.stat-card span { color:#c9cedb; font-size:.85rem; }
.stat-card small { color:#6f788d; font-size:.72rem; }
.admin-card-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:18px; }
.admin-bot-card { position:relative; border-radius:22px; padding:22px; overflow:hidden; }
.admin-bot-card::after { content:""; position:absolute; top:-60px; right:-60px; width:140px; height:140px; border-radius:50%; background:var(--accent); opacity:.13; filter:blur(42px); pointer-events:none; }
.admin-bot-head { display:flex; justify-content:space-between; gap:15px; }
.status-pill { height:27px; padding:0 10px; border-radius:999px; display:inline-flex; align-items:center; font-size:.68rem; font-weight:800; }
.status-pill.live { color:#86efac; background:rgba(34,197,94,.1); border:1px solid rgba(34,197,94,.22); }
.status-pill.draft { color:#cbd5e1; background:rgba(148,163,184,.09); border:1px solid rgba(148,163,184,.18); }
.admin-bot-card h2 { margin:20px 0 7px; letter-spacing:-.035em; }
.admin-bot-card > p { min-height:47px; margin:0; color:var(--muted); line-height:1.55; font-size:.85rem; }
.admin-bot-card dl { margin:18px 0; padding:14px 0; display:grid; gap:9px; border-top:1px solid var(--line); border-bottom:1px solid var(--line); }
.admin-bot-card dl div { display:flex; justify-content:space-between; gap:10px; }
.admin-bot-card dt { color:#778197; font-size:.72rem; }
.admin-bot-card dd { margin:0; color:#cbd1de; font-size:.72rem; text-align:right; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.card-actions { display:flex; justify-content:flex-end; gap:9px; }
.admin-form { display:flex; flex-direction:column; gap:20px; }
.narrow-form { max-width:1000px; }
.form-section { border-radius:24px; padding:clamp(20px,3vw,30px); }
.section-heading { display:flex; gap:15px; align-items:flex-start; margin-bottom:5px; }
.section-heading > span { flex:0 0 auto; width:36px; height:36px; border-radius:11px; display:grid; place-items:center; color:#c4b5fd; font-size:.72rem; font-weight:850; background:rgba(139,92,246,.12); border:1px solid rgba(139,92,246,.2); }
.section-heading h2 { margin:0 0 4px; font-size:1.15rem; }
.section-heading p { margin:0; color:var(--muted); font-size:.82rem; line-height:1.5; }
.bottom-save-bar { position:sticky; bottom:14px; border-radius:19px; padding:11px; display:flex; align-items:center; justify-content:space-between; z-index:10; }
.bottom-save-bar > div { display:flex; gap:9px; }

@keyframes typing { 0%,60%,100%{transform:translateY(0);opacity:.45}30%{transform:translateY(-4px);opacity:1} }
@keyframes messageIn { from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)} }
@keyframes micPulse { 0%{transform:scale(.92);opacity:.9}100%{transform:scale(1.35);opacity:0} }

@media (max-width: 980px) {
  .bot-grid, .admin-card-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .admin-shell { grid-template-columns:220px minmax(0,1fr); }
  .admin-main { padding-inline:24px; }
}

@media (max-width: 760px) {
  .form-grid { grid-template-columns:1fr; }
  .field.full, .full { grid-column:auto; }
  .bot-grid { grid-template-columns:1fr; }
  .hero { margin-bottom:35px; }
  .home-main { padding-top:42px; }
  .bot-card { min-height:210px; }
  .admin-shell { display:block; }
  .admin-sidebar { position:fixed; left:0; top:0; width:260px; transform:translateX(-102%); transition:transform .2s ease; box-shadow:20px 0 60px rgba(0,0,0,.4); }
  .admin-sidebar.open { transform:translateX(0); }
  .admin-main { padding:24px 16px 60px; }
  .mobile-nav-button { display:grid; place-items:center; }
  .stat-grid, .admin-card-grid { grid-template-columns:1fr; }
  .admin-actions-row, .form-toolbar { align-items:flex-start; flex-direction:column; }
  .admin-actions-row .primary-button, .form-toolbar .primary-button { width:100%; }
  .bottom-save-bar { bottom:8px; }
}

@media (max-width: 560px) {
  .site-header { height:72px; }
  .home-main, .site-header { width:min(100% - 24px,1180px); }
  .hero h1 { font-size:clamp(3rem,18vw,5rem); }
  .home-main { padding-bottom:60px; }
  .chat-app { padding:8px 8px max(8px, env(safe-area-inset-bottom)); }
  .chat-header { min-height:64px; border-radius:17px; padding:8px; }
  .header-actions .icon-button { display:none; }
  .voice-switch { padding:0 9px; }
  .message-bubble { max-width:86%; padding:12px 14px; }
  .messages { padding-top:18px; }
  .composer { border-radius:18px; gap:6px; padding:7px; }
  .send-button,.mic-button { width:45px; height:45px; border-radius:14px; }
  .suggestion-row { margin-left:0; }
  .setup-page { padding:16px 10px; }
  .setup-card { border-radius:22px; padding:24px 18px; }
  .bottom-save-bar { align-items:stretch; flex-direction:column; }
  .bottom-save-bar > div { display:grid; grid-template-columns:1fr 1fr; }
}
