:root {
  --ink: #10272E;
  --teal: #167D80;
  --teal-hover: #12696C;
  --teal-soft: #E5F1EF;
  --amber: #F2B544;
  --surface: #FFFFFF;
  --background: #EEF3F1;
  --border: #D7E2DE;
  --muted: #6C7E80;
  --success: #197044;
  --success-bg: #EAF6EF;
  --danger: #B42318;
  --danger-bg: #FDECEC;
  --font: 'IBM Plex Sans Arabic', 'Alexandria', Tahoma, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh; padding: 0 16px 24px;
  background: linear-gradient(150deg, var(--teal), var(--ink));
  color: var(--ink); font-family: var(--font); direction: rtl; overflow-x: hidden;
}
button, input, select { font: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.app-shell { width: min(100%, 860px); margin: 0 auto; }
.topbar { min-height: 76px; display: flex; align-items: center; justify-content: space-between; color: #fff; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark, .avatar { display: grid; place-items: center; flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%; background: #fff; color: var(--teal); font-weight: 700; font-size: 22px; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 17px; }
.brand span { margin-top: 3px; font-size: 12px; opacity: .9; }
.ghost-button { padding: 8px 14px; border: 1px solid #fff; border-radius: 999px; background: transparent; color: #fff; font-size: 13px; }
.workspace { overflow: hidden; border-radius: 18px; background: var(--surface); box-shadow: 0 10px 30px rgba(0,0,0,.18); }
.conversation-head { display: flex; align-items: center; gap: 12px; min-height: 68px; padding: 10px 18px; background: var(--ink); color: #fff; }
.avatar { width: 40px; height: 40px; background: var(--amber); color: var(--ink); font-size: 19px; }
.contact { flex: 1; }
.contact strong { display: block; font-size: 15px; }
.contact > span { display: block; margin-top: 3px; font-size: 11px; opacity: .9; }
.contact i { display: inline-block; width: 7px; height: 7px; margin-left: 4px; border-radius: 50%; background: #43A047; }
.icon-button { width: 38px; height: 38px; border: 0; border-radius: 50%; background: transparent; color: #fff; font-size: 22px; }
.icon-button:hover { background: rgba(255,255,255,.12); }
.chat { display: flex; flex-direction: column; gap: 10px; min-height: 320px; max-height: 58vh; max-height: 58dvh; overflow-y: auto; padding: 18px clamp(12px, 4vw, 36px); background: var(--background); }
.voice-bubble { max-width: min(88%, 560px); padding: 10px 14px; border-radius: 14px; line-height: 1.75; font-size: 14px; box-shadow: 0 1px 2px rgba(0,0,0,.08); overflow-wrap: anywhere; }
.voice-bubble p { margin: 0 0 4px; }
.voice-bubble p:last-of-type { margin-bottom: 0; }
.voice-teacher { align-self: flex-start; background: var(--teal); color: #fff; border-bottom-right-radius: 4px; }
.voice-system { align-self: flex-end; background: var(--surface); border-bottom-left-radius: 4px; }
.voice-system.saved { background: var(--success-bg); color: var(--success); }
.voice-system.error { background: var(--danger-bg); color: var(--danger); }
.voice-system.warning { background: var(--teal-soft); }
.voice-time { display: block; margin-top: 4px; font-size: 11px; opacity: .65; }
.voice-example, .hint { color: var(--muted); font-size: 13px; }
.voice-waiting { color: var(--muted); }
.voice-choices { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.voice-choices .btn, .voice-undo, .mini-button { padding: 7px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--ink); font-size: 13px; text-decoration: none; display: inline-block; }
.mini-button.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.voice-undo { margin-top: 8px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 6px; margin: 8px 0; }
.stat { padding: 8px; border-radius: 10px; background: var(--teal-soft); text-align: center; }
.stat b { display: block; font-size: 20px; color: var(--teal); }
.stat span { font-size: 12px; color: var(--muted); }
.list { margin: 6px 0 0; padding: 0; list-style: none; }
.list li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; padding: 7px 0; border-top: 1px solid var(--border); }
.list li:first-child { border-top: 0; }
.list small { color: var(--muted); }
.list .row-actions { display: flex; gap: 6px; }
.section-title { margin: 10px 0 2px; font-weight: 700; }
.login-form { display: grid; gap: 8px; margin-top: 8px; }
.login-form input, .composer input { width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff; color: var(--ink); }
.login-form button, .send { padding: 11px 16px; border: 0; border-radius: 10px; background: var(--teal); color: #fff; font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding: 12px 14px 4px; background: var(--surface); }
.action-button { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 112px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--ink); font-size: 13px; }
.action-button:hover { border-color: var(--teal); background: var(--teal-soft); }
.action-icon { font-size: 20px; }
.voice-unsupported { margin: 8px 14px 0; padding: 9px 12px; border-radius: 10px; background: var(--danger-bg); color: var(--danger); font-size: 13px; }
.composer { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 12px 14px; background: var(--surface); }
.mic { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 64px; height: 64px; border: 0; border-radius: 50%; background: var(--teal); color: #fff; font-size: 24px; }
.mic small { font-size: 9px; line-height: 1.2; }
.mic[hidden] { display: none; }
.mic.listening { background: var(--danger); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(180,35,24,.45); } 50% { box-shadow: 0 0 0 12px rgba(180,35,24,0); } }
.chat-footer { display: flex; gap: 8px; justify-content: center; padding: 10px 14px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; text-align: center; }
.creator-footer { padding: 10px 14px 14px; text-align: center; color: var(--muted); font-size: 12px; }
.creator-footer p { margin: 0 0 3px; }
.toast-container { position: fixed; inset: auto 16px 16px 16px; display: grid; gap: 8px; z-index: 10; }
.toast { padding: 11px 14px; border-radius: 10px; background: var(--ink); color: #fff; font-size: 14px; }
.toast.error { background: var(--danger); }
[hidden] { display: none !important; }
@media (max-width: 600px) {
  body { padding: 0 8px 12px; }
  .topbar { min-height: 62px; }
  .chat { min-height: 0; height: calc(100vh - 330px); height: calc(100dvh - 330px); max-height: none; }
  .actions { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; padding: 10px 10px 2px; scrollbar-width: none; }
  .actions::-webkit-scrollbar { display: none; }
  .action-button { flex: 0 0 auto; flex-direction: row; min-width: 0; padding: 8px 12px; border-radius: 999px; white-space: nowrap; }
  .action-icon { font-size: 16px; }
  .composer { gap: 8px; padding: 10px; }
  .mic { width: 56px; height: 56px; font-size: 22px; }
  .mic small { display: none; }
  .creator-footer { display: none; }
}
