:root {
  --bg: #0d0b14;
  --panel: #17141f;
  --panel2: #211c2c;
  --line: #2c2638;
  --text: #f3f0fa;
  --muted: #9a93ab;
  --accent: #8b5cf6;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 16px/1.45 -apple-system, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif; overscroll-behavior: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: #c4b5fd; }
#app { height: 100%; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; position: relative; }
.view { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* ---------- Yuqori panel ---------- */
.top { display: flex; align-items: center; justify-content: space-between; padding: calc(14px + var(--safe-t)) 18px 8px; }
.brand { font-weight: 800; font-size: 24px; letter-spacing: -.5px; }
.brand small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.icon-btn { width: 42px; height: 42px; border-radius: 14px; background: var(--panel); display: grid; place-items: center; font-size: 19px; position: relative; }
.icon-btn .badge { position: absolute; top: -3px; right: -3px; background: var(--red); color: #fff; font-size: 11px; min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; }
.top-actions { display: flex; gap: 8px; }

/* ---------- Kartochkalar karuseli ---------- */
.home-scroll { flex: 1; overflow-y: auto; padding-bottom: calc(110px + var(--safe-b)); }
.carousel { display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 8px 18px 4px; scrollbar-width: none; }
.carousel::-webkit-scrollbar { display: none; }
.card { flex: 0 0 82%; scroll-snap-align: center; height: min(62vh, 520px); border-radius: 30px; position: relative; overflow: hidden; display: flex; flex-direction: column; padding: 22px; isolation: isolate; text-align: left; box-shadow: 0 20px 50px -20px rgba(0,0,0,.7); }
.card::before { content: ""; position: absolute; inset: 0; z-index: -2; background: radial-gradient(120% 80% at 50% 100%, var(--c1) 0%, transparent 60%), radial-gradient(90% 60% at 80% 10%, var(--c2) 0%, transparent 70%), #120f1a; opacity: .95; }
.card::after { content: ""; position: absolute; inset: 0; z-index: -1; background: radial-gradient(2px 2px at 20% 30%, #fff8, transparent), radial-gradient(2px 2px at 70% 20%, #fff6, transparent), radial-gradient(1.5px 1.5px at 40% 60%, #fff5, transparent), radial-gradient(1.5px 1.5px at 85% 55%, #fff5, transparent), linear-gradient(transparent 55%, #0008); }
.card .kicker { font-size: 12px; font-weight: 600; letter-spacing: .5px; opacity: .85; text-transform: uppercase; }
.card .name { font-size: clamp(32px, 10vw, 44px); font-weight: 900; line-height: 1; letter-spacing: -1.5px; margin-top: 6px; text-shadow: 0 4px 30px rgba(0,0,0,.35); }
.card .avatar { flex: 1; display: grid; place-items: center; font-size: clamp(110px, 34vw, 160px); filter: drop-shadow(0 25px 35px rgba(0,0,0,.45)); animation: float 5s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-10px) rotate(-2deg); } }
.card .foot { display: flex; align-items: center; justify-content: space-between; }
.pill { display: inline-flex; align-items: center; gap: 7px; background: rgba(0,0,0,.35); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); padding: 7px 12px; border-radius: 99px; font-size: 13px; font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); }
.dot.busy { background: var(--amber); box-shadow: 0 0 10px var(--amber); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.card .go { width: 46px; height: 46px; border-radius: 50%; background: #fff; color: #111; display: grid; place-items: center; font-size: 20px; font-weight: 800; }
.dots { display: flex; justify-content: center; gap: 6px; padding: 12px 0 6px; }
.dots span { width: 6px; height: 6px; border-radius: 3px; background: var(--line); transition: .25s; }
.dots span.on { width: 20px; background: var(--accent); }

.section-title { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; padding: 16px 20px 8px; display: flex; justify-content: space-between; align-items: center; }
.section-title button { color: var(--accent); font-size: 13px; text-transform: none; letter-spacing: 0; font-weight: 600; }
.list { padding: 0 14px; display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--panel); border-radius: 18px; text-align: left; width: 100%; }
.row .ava { width: 46px; height: 46px; border-radius: 15px; display: grid; place-items: center; font-size: 24px; background: linear-gradient(135deg, var(--c1), var(--c2)); flex: none; }
.row .t { flex: 1; min-width: 0; }
.row .t b { display: block; font-size: 16px; }
.row .t span { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.row .st { font-size: 12px; color: var(--muted); }

/* Pastki buyruq paneli (bosh sahifa) */
.dock { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 560px; padding: 10px 14px calc(12px + var(--safe-b)); background: linear-gradient(transparent, var(--bg) 35%); z-index: 5; }

/* ---------- Chat ---------- */
.chat-head { display: flex; align-items: center; gap: 10px; padding: calc(10px + var(--safe-t)) 12px 10px; background: linear-gradient(135deg, color-mix(in srgb, var(--c1) 45%, var(--bg)), color-mix(in srgb, var(--c2) 35%, var(--bg))); border-bottom: 1px solid #ffffff10; }
.chat-head .ava { width: 44px; height: 44px; border-radius: 50%; background: #0003; display: grid; place-items: center; font-size: 26px; }
.chat-head .t { flex: 1; min-width: 0; }
.chat-head .t b { display: block; font-size: 17px; }
.chat-head .t span { font-size: 12.5px; opacity: .85; display: flex; align-items: center; gap: 6px; }
.chat-head .icon-btn { background: #0003; width: 38px; height: 38px; }
.msgs { flex: 1; overflow-y: auto; padding: 14px 12px 10px; display: flex; flex-direction: column; gap: 12px; }
.empty { margin: auto; text-align: center; color: var(--muted); padding: 30px 20px; }
.empty .big { font-size: 72px; }
.empty h3 { color: var(--text); margin: 8px 0 4px; }
.sugg { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }
.sugg button { background: var(--panel2); padding: 9px 13px; border-radius: 14px; font-size: 14px; text-align: left; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: 20px; word-wrap: break-word; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--accent); border-bottom-right-radius: 6px; white-space: pre-wrap; }
.msg.user .from { font-size: 11px; opacity: .8; margin-bottom: 2px; }
.msg.agent { align-self: flex-start; background: var(--panel); border-bottom-left-radius: 6px; width: 88%; }
.msg.agent.err { border: 1px solid #ef444466; }
.msg .att { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.msg .att span { background: #0003; padding: 3px 8px; border-radius: 8px; font-size: 12.5px; }
.steps { list-style: none; margin: 2px 0 8px; padding: 0; display: flex; flex-direction: column; gap: 5px; font-size: 13.5px; color: #d8d2e6; }
.steps li { display: flex; gap: 8px; align-items: flex-start; }
.steps li i { font-style: normal; width: 18px; flex: none; text-align: center; }
.steps li.ok i { color: var(--green); }
.steps li.err i { color: var(--red); }
.spin { display: inline-block; width: 13px; height: 13px; border: 2px solid #fff3; border-top-color: #fff; border-radius: 50%; animation: sp .8s linear infinite; margin-top: 3px; }
@keyframes sp { to { transform: rotate(360deg); } }
.md p { margin: 0 0 8px; } .md p:last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 10px 0 6px; font-size: 16.5px; }
.md ul, .md ol { margin: 4px 0 8px; padding-left: 20px; }
.md li { margin: 2px 0; }
.md code { background: #0005; padding: 1px 5px; border-radius: 6px; font-size: 13.5px; }
.md pre { background: #0006; padding: 10px; border-radius: 12px; overflow-x: auto; font-size: 13px; white-space: pre-wrap; }
.md pre code { background: none; padding: 0; }
.md table { border-collapse: collapse; font-size: 13.5px; display: block; overflow-x: auto; margin: 6px 0; }
.md th, .md td { border: 1px solid var(--line); padding: 5px 8px; text-align: left; vertical-align: top; }
.md blockquote { margin: 6px 0; padding-left: 10px; border-left: 3px solid var(--accent); color: #ddd; }
.files { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.files video, .files img { width: 100%; max-height: 60vh; border-radius: 14px; background: #000; object-fit: contain; }
.files audio { width: 100%; }
.file-card { display: flex; align-items: center; gap: 10px; background: var(--panel2); padding: 10px 12px; border-radius: 14px; text-decoration: none; color: var(--text); font-size: 14px; }
.file-card span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.links { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.link-btn { display: block; padding: 12px 14px; border-radius: 14px; text-decoration: none; color: #fff; font-weight: 700; font-size: 15px; background: #2a2340; }
.link-btn.whatsapp { background: #128c4a; } .link-btn.telegram { background: #2481cc; } .link-btn.call { background: #444; }
.link-btn small { display: block; font-weight: 400; opacity: .85; font-size: 12.5px; margin-top: 3px; white-space: pre-wrap; max-height: 5.5em; overflow: hidden; }
.msg-tools { display: flex; gap: 12px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.msg-tools button { color: var(--muted); font-size: 12px; padding: 0; }
.cursor::after { content: "▍"; animation: pulse 1s infinite; }

/* ---------- Yozish paneli ---------- */
.composer { padding: 8px 10px calc(10px + var(--safe-b)); background: var(--bg); border-top: 1px solid #ffffff0d; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 0 2px 8px; }
.chip { flex: none; display: flex; align-items: center; gap: 6px; background: var(--panel2); padding: 6px 10px; border-radius: 12px; font-size: 13px; max-width: 220px; }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip button { color: var(--muted); }
.bar { display: flex; align-items: flex-end; gap: 8px; background: var(--panel); border-radius: 26px; padding: 6px; }
.bar textarea { flex: 1; resize: none; border: 0; outline: 0; background: none; padding: 9px 4px; max-height: 140px; min-height: 40px; line-height: 1.35; }
.bar .ib { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 20px; flex: none; color: var(--muted); }
.bar .send { background: var(--accent); color: #fff; }
.bar .mic { background: #e11d48; color: #fff; }
.bar .stop { background: #fff; color: #111; }

/* Ovoz yozish oynasi */
.rec { position: fixed; inset: 0; background: #000c; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 30px; text-align: center; }
.rec .ava { width: 170px; height: 170px; border-radius: 40px; display: grid; place-items: center; font-size: 100px; background: linear-gradient(135deg, var(--c1), var(--c2)); box-shadow: 0 0 0 0 #fff3; animation: ring 1.6s infinite; }
@keyframes ring { 0% { box-shadow: 0 0 0 0 #ffffff30; } 100% { box-shadow: 0 0 0 40px #ffffff00; } }
.rec canvas { width: 240px; height: 50px; }
.rec .stopbtn { width: 76px; height: 76px; border-radius: 50%; background: #e11d48; display: grid; place-items: center; }
.rec .stopbtn i { width: 26px; height: 26px; background: #fff; border-radius: 6px; }
.rec .cancel { color: var(--muted); }

/* ---------- Sozlamalar / panellar ---------- */
.page { flex: 1; overflow-y: auto; padding: 0 16px calc(30px + var(--safe-b)); }
.box { background: var(--panel); border-radius: 20px; padding: 16px; margin-bottom: 14px; }
.box h3 { margin: 0 0 4px; font-size: 16px; }
.box p.hint { margin: 0 0 12px; color: var(--muted); font-size: 13.5px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; outline: none; width: 100%; }
.field textarea { min-height: 110px; resize: vertical; }
.btn { background: var(--accent); color: #fff; padding: 11px 16px; border-radius: 13px; font-weight: 700; }
.btn.ghost { background: var(--panel2); color: var(--text); }
.btn.danger { background: #3a1620; color: #fca5a5; }
.btn:disabled { opacity: .5; }
.kv { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.kv:last-child { border-bottom: 0; }
.kv span { flex: 1; }
.kv button { color: var(--muted); font-size: 18px; }
.kv input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }
.kv.done span { text-decoration: line-through; color: var(--muted); }
.status-ok { color: var(--green); font-weight: 600; }
.status-bad { color: var(--amber); font-weight: 600; }

/* Login */
.login { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 30px; gap: 14px; text-align: center; }
.login .logo { font-size: 80px; }

#toast { position: fixed; left: 50%; bottom: calc(100px + var(--safe-b)); transform: translateX(-50%) translateY(20px); background: #fff; color: #111; padding: 10px 16px; border-radius: 14px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 50; max-width: 90%; text-align: center; }
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
