:root {
  --bg: #eef3f8;
  --surface: #ffffff;
  --surface-subtle: #f7fafc;
  --ink: #17212b;
  --muted: #526170;
  --line: #d9e2ea;
  --brand: #0f766e;
  --brand-dark: #0b514c;
  --brand-soft: #d7f5f1;
  --stage: #071c1a;
  --stage-ink: #e9fffc;
  --danger: #b42318;
  --danger-soft: #fee4e2;
  --warning: #8a4b08;
  --warning-soft: #fff1d6;
  --success: #08775f;
  --success-soft: #d9f5eb;
  --focus: #168f85;
  --radius: 14px;
  --shadow: 0 20px 54px rgba(24, 39, 56, .09);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Tahoma, "Segoe UI", Arial, sans-serif;
  line-height: 1.55;
}

button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .52; }
button:focus-visible, input:focus-visible { outline: 3px solid color-mix(in srgb, var(--focus), transparent 64%); outline-offset: 2px; }

.topbar {
  min-height: 72px;
  padding: 12px max(22px, calc((100vw - 1180px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; }
.brand-mark { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 11px; background: var(--brand); color: white; font-size: 20px; font-weight: 800; }
.brand b, .brand small { display: block; }
.brand b { font-size: 15px; }
.brand small { color: var(--muted); font-size: 11px; margin-top: -1px; }
.environment { padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: var(--surface-subtle); font: 600 11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; direction: ltr; }

.shell { width: min(1180px, calc(100% - 44px)); margin: 0 auto; padding: 34px 0 56px; }
.intro { display: flex; align-items: end; justify-content: space-between; gap: 28px; margin-bottom: 24px; }
.intro h1 { margin: 0; font-size: 28px; line-height: 1.3; letter-spacing: -.02em; text-wrap: balance; }
.intro p { max-width: 66ch; margin: 8px 0 0; color: var(--muted); font-size: 14px; text-wrap: pretty; }
.route { display: flex; align-items: center; gap: 7px; color: var(--brand-dark); font-size: 11px; font-weight: 700; white-space: nowrap; }
.route span { padding: 6px 8px; border: 1px solid #b6dcd7; border-radius: 7px; background: #f3fffd; }
.route i { font-style: normal; color: #6c8d89; }

.workspace { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(310px, .8fr); gap: 20px; align-items: stretch; }
.call-panel, .diagnostics, .event-log { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.call-panel { padding: 20px; }
.diagnostics { padding: 20px; }
.call-head, .diagnostics-head, .event-log-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.section-label { margin: 0 0 2px; color: var(--muted); font-size: 11px; font-weight: 700; }
h2 { margin: 0; font-size: 17px; line-height: 1.45; }

.status-pill { display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto; padding: 6px 10px; border-radius: 999px; background: #edf1f4; color: #40505f; font-size: 11px; font-weight: 700; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #7f8d99; }
.status-pill[data-state="ready"] { background: var(--success-soft); color: var(--success); }
.status-pill[data-state="ready"] .status-dot, .status-pill[data-state="active"] .status-dot { background: var(--success); }
.status-pill[data-state="connecting"] { background: var(--warning-soft); color: var(--warning); }
.status-pill[data-state="connecting"] .status-dot { background: #c56a0a; }
.status-pill[data-state="active"] { background: var(--brand-soft); color: var(--brand-dark); }
.status-pill[data-state="error"] { background: var(--danger-soft); color: var(--danger); }
.status-pill[data-state="error"] .status-dot { background: var(--danger); }

.voice-stage { min-height: 326px; margin-top: 18px; padding: 34px 20px 25px; display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden; position: relative; background: var(--stage); color: var(--stage-ink); border-radius: 12px; text-align: center; }
.voice-stage::before { content: ""; position: absolute; width: 340px; height: 340px; border-radius: 50%; top: -235px; right: -100px; background: rgba(67, 226, 208, .1); }
.agent-orbit { width: 112px; height: 112px; display: grid; place-items: center; border: 1px solid rgba(146, 255, 242, .2); border-radius: 50%; box-shadow: 0 0 0 18px rgba(69, 222, 205, .035), 0 0 70px rgba(52, 211, 193, .13); }
.agent-core { width: 78px; height: 78px; display: grid; place-items: center; border-radius: 50%; background: #0e6159; color: white; font-size: 31px; font-weight: 700; }
.wave { height: 26px; margin: 24px 0 13px; display: flex; align-items: center; gap: 5px; }
.wave i { width: 3px; height: 5px; border-radius: 3px; background: #72e6d9; opacity: .5; transform-origin: center; }
.voice-stage[data-active="true"] .wave i { animation: voice-bar .8s ease-in-out infinite alternate; opacity: .9; }
.voice-stage[data-active="true"] .wave i:nth-child(2), .voice-stage[data-active="true"] .wave i:nth-child(8) { animation-delay: -.15s; }
.voice-stage[data-active="true"] .wave i:nth-child(3), .voice-stage[data-active="true"] .wave i:nth-child(7) { animation-delay: -.4s; }
.voice-stage[data-active="true"] .wave i:nth-child(4), .voice-stage[data-active="true"] .wave i:nth-child(6) { animation-delay: -.25s; }
.voice-stage[data-active="true"] .wave i:nth-child(5) { animation-delay: -.55s; }
@keyframes voice-bar { to { height: 25px; } }
.voice-stage strong { font-size: 17px; }
.voice-stage > span { margin-top: 3px; color: #a7c7c3; font-size: 12px; }
.voice-stage time { margin-top: 15px; font: 600 13px/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: #8ff2e7; direction: ltr; }

.call-actions { margin-top: 16px; display: flex; align-items: center; gap: 9px; }
.button { min-height: 42px; padding: 9px 15px; border-radius: 9px; border: 1px solid transparent; font-weight: 700; font-size: 13px; transition: background-color 180ms ease, border-color 180ms ease, transform 180ms ease; }
.button:not(:disabled):active { transform: translateY(1px); }
.button-primary { min-width: 148px; background: var(--brand); color: white; }
.button-primary:not(:disabled):hover { background: var(--brand-dark); }
.button-secondary { background: var(--surface); border-color: #b8c5cf; color: #30404d; }
.button-secondary:not(:disabled):hover { background: var(--surface-subtle); border-color: #8c9da9; }
.button-secondary[aria-pressed="true"] { background: var(--warning-soft); border-color: #e3a85d; color: var(--warning); }
.button-danger { margin-inline-start: auto; background: var(--surface); border-color: #efb3ae; color: var(--danger); }
.button-danger:not(:disabled):hover { background: var(--danger-soft); }
.button-icon { display: inline-block; margin-inline-end: 6px; }
.privacy-note { margin: 11px 0 0; color: var(--muted); font-size: 11px; }

.icon-button { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--brand-dark); font-size: 18px; }
.icon-button:hover { background: var(--surface-subtle); }
.readiness-summary { margin-top: 18px; padding: 12px; display: flex; align-items: center; gap: 10px; border-radius: 10px; background: #edf1f4; color: #40505f; }
.summary-icon { width: 28px; height: 28px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; background: rgba(255,255,255,.72); font-weight: 800; }
.readiness-summary strong, .readiness-summary span { display: block; }
.readiness-summary strong { font-size: 12px; }
.readiness-summary div span { margin-top: 1px; font-size: 10px; opacity: .82; }
.readiness-summary[data-state="ready"] { background: var(--success-soft); color: var(--success); }
.readiness-summary[data-state="missing"] { background: var(--warning-soft); color: var(--warning); }
.readiness-summary[data-state="error"] { background: var(--danger-soft); color: var(--danger); }

.facts { margin: 17px 0 0; }
.facts div { min-height: 36px; padding: 8px 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid #e8edf1; }
.facts dt { color: var(--muted); font-size: 11px; }
.facts dd { margin: 0; max-width: 62%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font: 600 11px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.missing-block { margin-top: 17px; }
.missing-block h3, .webhook-block label { margin: 0 0 8px; color: #344451; font-size: 11px; font-weight: 700; }
code { padding: 2px 4px; border-radius: 4px; background: #e9eef2; direction: ltr; }
.checklist { margin: 0; padding: 0; list-style: none; }
.checklist li { padding: 7px 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid #edf1f4; color: #344451; font: 600 10px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; direction: ltr; text-align: left; }
.checklist li::after { content: "ناقص"; padding: 2px 6px; border-radius: 999px; background: var(--danger-soft); color: var(--danger); font: 700 9px/1.5 Tahoma, sans-serif; direction: rtl; }
.webhook-block { margin-top: 18px; }
.copy-field { display: flex; direction: ltr; }
.copy-field input { min-width: 0; flex: 1; height: 38px; padding: 8px 9px; border: 1px solid #c8d3dc; border-radius: 8px 0 0 8px; background: var(--surface-subtle); color: #3b4a56; font: 10px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }
.copy-field button { padding: 0 11px; border: 1px solid var(--brand); border-radius: 0 8px 8px 0; background: var(--brand); color: white; font-size: 11px; font-weight: 700; }

.event-log { margin-top: 20px; padding: 18px 20px; box-shadow: none; }
.event-log-head { align-items: center; }
.event-log-head button { border: 0; background: transparent; color: var(--muted); font-size: 11px; text-decoration: underline; text-underline-offset: 3px; }
.event-log ol { max-height: 180px; margin: 14px 0 0; padding: 0; overflow-y: auto; list-style: none; }
.event-log li { min-height: 31px; padding: 6px 0; display: grid; grid-template-columns: 70px 1fr; gap: 10px; border-top: 1px solid #edf1f4; color: #344451; font-size: 11px; }
.event-log li time { color: var(--muted); font: 10px/1.7 ui-monospace, SFMono-Regular, Menlo, monospace; direction: ltr; }

noscript { display: block; margin: 20px; padding: 12px; background: var(--danger-soft); color: var(--danger); text-align: center; }

@media (max-width: 880px) {
  .intro { align-items: flex-start; flex-direction: column; }
  .workspace { grid-template-columns: 1fr; }
  .diagnostics { order: -1; }
}

@media (max-width: 560px) {
  .topbar { min-height: 64px; padding-inline: 16px; }
  .environment { display: none; }
  .shell { width: min(100% - 26px, 1180px); padding-top: 24px; }
  .intro h1 { font-size: 23px; }
  .route { width: 100%; overflow-x: auto; padding-bottom: 4px; }
  .call-panel, .diagnostics { padding: 15px; }
  .call-head { align-items: flex-start; flex-direction: column; }
  .voice-stage { min-height: 290px; }
  .call-actions { align-items: stretch; flex-direction: column; }
  .button, .button-primary { width: 100%; }
  .button-danger { margin-inline-start: 0; }
  .event-log li { grid-template-columns: 58px 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
