:root {
  --bg: #0f1115; --panel: #171a21; --panel2: #1e222b; --line: #2b313d; --text: #e7e9ee; --muted: #8d95a5;
  --accent: #5eead4; --accent2: #a78bfa; --warn: #fbbf24; --danger: #f87171; --ok: #4ade80; --r: 12px;
  color-scheme: dark;
}
:root.light { --bg: #f4f5f8; --panel: #fff; --panel2: #eef0f4; --line: #dde1e8; --text: #151821; --muted: #5d6576; --accent: #0d9488; --accent2: #7c3aed; color-scheme: light; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
.app { display: grid; grid-template-columns: 220px 1fr; height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 14px 10px; display: flex; flex-direction: column; gap: 4px; overflow: auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; padding: 4px 8px 14px; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.nav { display: flex; gap: 10px; align-items: center; text-align: left; background: none; border: 0; padding: 10px 12px; border-radius: 10px; cursor: pointer; color: var(--muted); }
.nav:hover { background: var(--panel2); color: var(--text); }
.nav.active { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--text); }
.nav .ic { width: 18px; text-align: center; color: var(--accent); }
.side-foot { margin-top: auto; font-size: 11px; padding: 8px; }
main { overflow: auto; padding: 22px 26px 80px; outline: none; }
h1 { font-size: 22px; margin: 0 0 4px; } h2 { font-size: 16px; margin: 0 0 10px; } h3 { margin: 0 0 8px; font-size: 15px; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.sub { color: var(--muted); margin: 0 0 18px; }
.grid { display: grid; gap: 16px; } .g2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); } .g3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; min-width: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; } .row.end { justify-content: flex-end; } .row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.btn { border: 1px solid var(--line); background: var(--panel2); padding: 8px 14px; border-radius: 9px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--muted); } .btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #062a26; border-color: transparent; font-weight: 600; }
.btn.danger { background: var(--danger); color: #2b0606; border-color: transparent; }
.btn.ghost { background: transparent; } .btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.rec { background: #ef4444; color: #fff; border: 0; font-weight: 600; min-width: 140px; }
.btn.rec.on { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, .2); } }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tab { border: 1px solid var(--line); background: var(--panel); padding: 8px 16px; border-radius: 999px; cursor: pointer; }
.tab.active { background: var(--accent); color: #062a26; border-color: transparent; font-weight: 600; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); min-width: 0; }
.field > span { font-weight: 600; }
input[type=text], input[type=search], input:not([type]), input[type=password], input[type=number], select, textarea { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; color: var(--text); width: 100%; }
textarea { resize: vertical; line-height: 1.5; }
input[type=range] { width: 100%; accent-color: var(--accent); }
canvas { width: 100%; display: block; border-radius: 8px; }
canvas.wave { height: 110px; } canvas.radar { height: 340px; } canvas.contour { height: 150px; }
audio { width: 100%; margin-top: 8px; }
.meter { height: 8px; background: var(--panel2); border-radius: 99px; overflow: hidden; } .meter > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--ok), var(--warn), var(--danger)); transition: width .05s; }
.drop { border: 2px dashed var(--line); border-radius: var(--r); padding: 34px; text-align: center; cursor: pointer; }
.drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.feat { display: grid; grid-template-columns: 110px 1fr; gap: 2px 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.feat b { font-weight: 600; } .feat .val { font-size: 13px; } .feat .val .after { color: var(--accent2); }
.feat .bar { grid-column: 2; height: 4px; background: var(--panel2); border-radius: 9px; position: relative; overflow: hidden; }
.feat .bar i { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 9px; }
.ctl { display: grid; grid-template-columns: 104px 30px 1fr 30px 56px; gap: 6px; align-items: center; padding: 3px 0; }
.ctl .lbl { font-weight: 600; font-size: 13px; } .ctl .num { text-align: right; font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); }
.ctl .pm { padding: 2px 0; border-radius: 6px; } .ends { grid-column: 3; display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); margin-top: -6px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; } .chip { font-size: 11px; padding: 2px 8px; border-radius: 99px; background: var(--panel2); border: 1px solid var(--line); color: var(--muted); }
.chip.k { color: var(--accent); }
.list { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); } .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.note { background: color-mix(in srgb, var(--warn) 10%, transparent); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); border-radius: 10px; padding: 10px 12px; font-size: 12px; }
.empty { text-align: center; padding: 40px; color: var(--muted); }
code { background: var(--panel2); padding: 1px 5px; border-radius: 5px; font-size: 12px; }
#busy { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: grid; place-items: center; z-index: 50; }
#busy[hidden] { display: none; }
.busy-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px 22px; width: min(440px, 90vw); }
.bar { height: 6px; background: var(--panel2); border-radius: 9px; margin-top: 12px; overflow: hidden; } #busy-bar { height: 100%; background: var(--accent); width: 0; transition: width .2s; }
#busy-bar.indet { width: 40% !important; animation: indet 1.1s infinite linear; } @keyframes indet { from { margin-left: -40%; } to { margin-left: 100%; } }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 40px); opacity: 0; background: var(--panel); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; transition: .25s; z-index: 60; max-width: 90vw; }
#toast.show { opacity: 1; transform: translate(-50%, 0); } #toast.error { border-color: var(--danger); } #toast.ok { border-color: var(--ok); }
dialog.modal { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px; width: min(460px, 92vw); padding: 18px; }
dialog.modal::backdrop { background: rgba(0, 0, 0, .5); }
dialog.modal form { display: flex; flex-direction: column; gap: 12px; }
.toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
[dir=rtl] { text-align: right; }
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .side { order: 2; flex-direction: row; border-right: 0; border-top: 1px solid var(--line); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); overflow-x: auto; }
  .brand, .side-foot { display: none; }
  .nav { flex-direction: column; gap: 2px; font-size: 10px; padding: 6px 8px; min-width: 64px; text-align: center; }
  .nav .ic { font-size: 16px; }
  main { padding: 16px 14px 30px; }
  .ctl { grid-template-columns: 84px 28px 1fr 28px 46px; }
  canvas.radar { height: 300px; }
}

/* ---- voice agents ---- */
.avatar { width: 46px; height: 46px; flex: 0 0 46px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #06221f; display: grid; place-items: center; font-weight: 800; font-size: 20px; }
.avatar.lvl { --lvl: 0; width: 54px; height: 54px; flex-basis: 54px; box-shadow: 0 0 0 calc(var(--lvl) * 14px) color-mix(in srgb, var(--accent) 30%, transparent); transition: box-shadow .08s; }
.avatar.lvl[data-state=speaking] { animation: talk 0.9s infinite; }
.avatar.lvl[data-state=thinking] { animation: think 1.2s infinite; }
@keyframes talk { 50% { box-shadow: 0 0 0 10px color-mix(in srgb, var(--accent2) 35%, transparent); } }
@keyframes think { 50% { opacity: .55; } }
.log { height: 300px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; background: var(--panel2); border-radius: 10px; padding: 12px; }
.msg { max-width: 85%; padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.msg.agent { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); }
.msg.user { align-self: flex-end; background: var(--accent); color: #062a26; }
.msg.partial { opacity: .75; }
[dir=rtl] .msg.agent { align-self: flex-end; } [dir=rtl] .msg.user { align-self: flex-start; }
[dir=rtl] .nav { text-align: right; } [dir=rtl] .side { border-right: 0; border-left: 1px solid var(--line); }
#call-text { flex: 1; }

/* ---- 1.4: transcribe, audiobooks, design, delivery ---- */
.row.wrap { flex-wrap: wrap; }
.grid.g3 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.designs { margin-top: 14px; }
.chip.btnchip { cursor: pointer; border: 1px solid var(--line, #333); background: transparent; color: inherit; font: inherit; font-size: 12px; text-align: start; }
.chip.btnchip:hover { border-color: var(--accent); }
.segs { display: flex; flex-direction: column; gap: 4px; max-height: 52vh; overflow: auto; padding-inline-end: 4px; }
.seg { display: grid; grid-template-columns: auto 1fr auto; gap: 6px; align-items: start; }
.seg textarea { min-height: 34px; resize: vertical; font-size: 14px; padding: 6px 8px; }
.seg .ts { font-variant-numeric: tabular-nums; min-width: 58px; }
.chapter { padding: 12px 14px; gap: 8px; }
.chapter .grow, input.grow { flex: 1; min-width: 120px; }
.chapter select { max-width: 220px; }
.book-row { align-items: center; }
.delivery { border-top: 1px solid var(--line, #2a2f3a); padding-top: 10px; display: flex; flex-direction: column; gap: 2px; }

/* ---- 1.5: emotions, library, instant clone, recorder, changer ---- */
.emobar { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.emobar .emo { display: inline-flex; gap: 4px; align-items: center; background: var(--panel2); border: 1px solid var(--line); border-radius: 99px; padding: 2px 8px 2px 6px; font-size: 12px; cursor: pointer; color: inherit; }
.emobar .emo:hover { border-color: var(--accent); }
.emobar .emo span { color: var(--muted); }
.libcard { gap: 8px; }
.libgrid { margin-top: 14px; }
.steps { display: flex; gap: 8px; flex-wrap: wrap; }
.steps .step { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: 13px; padding: 4px 10px; border-radius: 99px; border: 1px solid var(--line); }
.steps .step b { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--panel2); font-size: 11px; }
.steps .step.on { color: var(--text); border-color: var(--accent); }
.steps .step.on b, .steps .step.done b { background: var(--accent); color: #062a24; }
.instant { border-color: var(--accent); }
.readme { background: var(--panel2); border-radius: 10px; padding: 12px 14px; font-size: 15px; line-height: 1.6; }
.rectrack { position: relative; height: 10px; border-radius: 99px; background: var(--panel2); margin: 26px 0 18px; }
.rectrack > i { position: absolute; inset-block: 0; inset-inline-start: 0; width: 0; border-radius: 99px; background: #f87171; transition: width .1s linear; }
.rectrack.ok > i { background: #fbbf24; } .rectrack.good > i { background: var(--accent); }
.rectrack .mark { position: absolute; top: -22px; transform: translateX(-50%); font-size: 11px; text-align: center; white-space: nowrap; color: var(--muted); }
.rectrack .mark em { display: block; font-style: normal; margin-top: 18px; }
.rectrack .mark.max { transform: translateX(-100%); }
.tips { border-top: 1px solid var(--line); padding-top: 8px; }
.tabs.small .tab { padding: 4px 12px; font-size: 13px; }
.charimg { max-width: 160px; max-height: 160px; border-radius: 10px; border: 1px solid var(--line); }
.row.wrap > select { width: auto; flex: 1 1 150px; min-width: 130px; }
.skl { display: grid; gap: 14px; }
.skl-h { height: 30px; width: 220px; border-radius: 8px; }
.skl-card { height: 120px; border-radius: var(--r); }
.skl-h, .skl-card { background: var(--panel2); animation: skl 1.2s infinite; }
@keyframes skl { 50% { opacity: .55; } }
