:root {
  --bg: #0f1222; --panel: #181c33; --ink: #eef0fa; --muted: #9aa0c3;
  --accent: #7c5cff; --accent2: #22c4a8; --warn: #ffb020; --bad: #ff5c7a;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans Arabic", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
body { padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
[hidden] { display: none !important; }
.view { max-width: 520px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; padding: 16px; }

/* login */
#login { justify-content: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 12px; justify-content: center; }
.logo { width: 48px; height: 48px; border-radius: 14px; background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: grid; place-items: center; font-size: 28px; font-weight: 700; }
h1 { font-size: 26px; margin: 0; }
form { display: flex; flex-direction: column; gap: 14px; background: var(--panel); padding: 20px; border-radius: 18px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
input, select { font-size: 17px; padding: 12px; border-radius: 12px; border: 1px solid #2b3056; background: #0d1020; color: var(--ink); }
button { font: inherit; cursor: pointer; }
.primary { background: var(--accent); color: white; border: 0; padding: 14px; border-radius: 12px; font-size: 17px; font-weight: 600; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.error { color: var(--bad); min-height: 1.2em; margin: 0; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; margin: 24px auto 8px; display: block; }

/* call */
#call header { display: flex; justify-content: space-between; align-items: center; }
.who { font-size: 18px; font-weight: 600; }
.icon { background: var(--panel); border: 0; color: var(--ink); width: 44px; height: 44px; border-radius: 12px; font-size: 20px; }
.spend { margin: 14px 0 4px; }
.bar { height: 6px; background: #262b4d; border-radius: 4px; overflow: hidden; }
#spendFill { height: 100%; width: 0; background: var(--accent2); transition: width .4s; }
#spendFill.warn { background: var(--warn); } #spendFill.full { background: var(--bad); }
.spendText { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-top: 6px; }

.stage { display: flex; flex-direction: column; align-items: center; padding: 28px 0 12px; gap: 14px; }
.talk { position: relative; width: 190px; height: 190px; border-radius: 50%; border: 0; color: white; font-size: 20px; font-weight: 600;
  background: radial-gradient(circle at 30% 30%, #9a82ff, var(--accent)); box-shadow: 0 10px 40px rgba(124, 92, 255, .45); }
.talk .ring { position: absolute; inset: -10px; border-radius: 50%; border: 3px solid transparent; }
.talk.live { background: radial-gradient(circle at 30% 30%, #ff8aa0, var(--bad)); box-shadow: 0 10px 40px rgba(255, 92, 122, .45); }
.talk.live.listening .ring { border-color: var(--accent2); animation: pulse 1.4s infinite; }
.talk.live.speaking .ring { border-color: #fff; animation: pulse .7s infinite; }
.talk.live.checking .ring { border-color: var(--warn); animation: spin 1s linear infinite; border-top-color: transparent; }
.talk:disabled { opacity: .5; }
@keyframes pulse { 0% { transform: scale(1); opacity: 1; } 100% { transform: scale(1.18); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
.status { color: var(--muted); margin: 0; min-height: 1.3em; text-align: center; }

.captions { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-bottom: 12px; }
.cap { padding: 10px 12px; border-radius: 14px; max-width: 88%; line-height: 1.45; font-size: 16px; unicode-bidi: plaintext; }
.cap.user { align-self: flex-end; background: #2a2f57; }
.cap.firas { align-self: flex-start; background: var(--panel); }
.cap.sys { align-self: center; background: none; color: var(--muted); font-size: 13px; }

/* settings sheet */
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; z-index: 10; }
.sheetInner { background: var(--panel); width: 100%; max-width: 520px; margin: 0 auto; max-height: 92vh; overflow-y: auto;
  border-radius: 20px 20px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
.sheetInner header { display: flex; justify-content: space-between; align-items: center; }
.sheetInner h2 { margin: 0; } .sheetInner h3 { margin: 8px 0 0; font-size: 15px; color: var(--muted); }
.current { font-size: 15px; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.filters input { grid-column: 1 / -1; }
.voices { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.voices li { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; background: #0f1328; padding: 10px; border-radius: 12px; }
.voices li.selected { outline: 2px solid var(--accent2); }
.voices .play { width: 44px; height: 44px; border-radius: 50%; border: 0; background: #262b4d; color: white; font-size: 16px; }
.voices .meta { font-size: 13px; color: var(--muted); }
.voices .name { font-weight: 600; font-size: 15px; }
.voices .use { background: var(--accent); border: 0; color: white; padding: 8px 12px; border-radius: 10px; }
.voices li.selected .use { background: var(--accent2); }
