/* متغیرهای رنگ و سایه برای تم Preview */
:root {
  color-scheme: dark;
  --bg: #0b1017;
  --surface: #111923;
  --surface-2: #172230;
  --line: #29394b;
  --text: #f5f7fa;
  --muted: #92a0b1;
  --green: #29bd84;
  --blue: #5c9cff;
  --red: #ef5559;
  --shadow: 0 18px 56px #02060ba8;
  font-family: Inter, Segoe UI, Tahoma, Arial, sans-serif
}

* {
  box-sizing: border-box
}

/* اندازهٔ پایهٔ صفحه و پس‌زمینه */
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: radial-gradient(circle at 20% -20%, #1e344b 0, transparent 38%), var(--bg);
  color: var(--text)
}

button {
  border: 0;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  color: inherit;
  transition: transform .15s ease, background .15s ease
}

button:hover {
  transform: translateY(-1px)
}

/* نوار باریک بالای Preview؛ height ارتفاع و padding فاصلهٔ کناری را می‌سازد */
.preview-header {
  height: 68px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #243244;
  background: #0d141dcc
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid #6c89a9;
  border-radius: 9px;
  color: #dceafe;
  font-size: 19px
}

.brand strong {
  display: block;
  font-size: 15px
}

.brand small, .eyebrow, .muted {
  color: var(--muted);
  font-size: 12px
}

.live {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #b8c6d4;
  font-size: 13px
}

.live i {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 12px var(--green)
}

/* چیدمان Host: استیج در ستون بزرگ و ریل کنترل در ستون کناری */
.preview-host {
  height: calc(100vh - 68px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 352px;
  gap: 16px;
  padding: 16px
}

/* سطح نمایش Rhino و محدودهٔ جای‌گیری model و cursor */
.canvas {
  min-height: 0;
  position: relative;
  overflow: hidden;
  border: 1px solid #29394b;
  border-radius: 20px;
  background: linear-gradient(145deg, #243d51, #101923 70%);
  box-shadow: var(--shadow)
}

.canvas-grid {
  position: absolute;
  inset: 0;
  opacity: .28;
  background-image: linear-gradient(#a9c8df20 1px, transparent 1px), linear-gradient(90deg, #a9c8df20 1px, transparent 1px);
  background-size: 32px 32px
}

.canvas-model {
  position: absolute;
  inset: 17% 14% 10%;
  border: 1px solid #d8e8f140;
  border-radius: 48% 52% 35% 38% / 34% 28% 56% 48%;
  transform: rotate(-9deg);
  background: radial-gradient(ellipse at 55% 42%, #738c9e 0 5%, #385668 29%, #182833 70%);
  box-shadow: inset -40px -20px 60px #0008, 0 20px 50px #0009
}

.canvas-model:before, .canvas-model:after {
  content: "";
  position: absolute;
  border: 1px solid #d8e8f15c;
  border-radius: 50%
}

.canvas-model:before {
  inset: 18% 8%;
  transform: rotate(17deg)
}

.canvas-model:after {
  inset: 38% -8% 10% 20%;
  transform: rotate(-16deg)
}

.canvas-label {
  position: absolute;
  left: 22px;
  top: 22px;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 11px;
  border-radius: 10px;
  background: #071019b5;
  color: #d8e5f2;
  font-size: 12px
}

.canvas-label i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green)
}

.preview-cursor {
  position: absolute;
  left: 59%;
  top: 44%;
  width: 17px;
  height: 17px;
  border: 2px solid #ff6868;
  border-radius: 50%;
  box-shadow: 0 0 10px #ff4141;
  background: #ff4a4a40
}

.preview-cursor:after {
  content: "میترا";
  position: absolute;
  top: 27px;
  right: -9px;
  padding: 5px 9px;
  border-radius: 9px;
  background: #2b9db3b1;
  color: #fff;
  font-size: 11px
}

/* ستون کناری کارت‌های کنترل Host */
.rail {
  overflow: auto;
  padding-right: 2px
}

.rail-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 5px 12px
}

.rail-title h1 {
  font-size: 15px;
  margin: 0
}

.rail-title span {
  color: #7c8ea2;
  font-size: 12px
}

/* کارت‌های جلسه، پنجره، صدا و مشتری‌ها؛ padding و border-radius فضای داخلی و گردی را می‌سازند */
.card {
  margin-bottom: 12px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(145deg, #141e2a, #111923);
  box-shadow: 0 8px 22px #0003
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 13px
}

.card h2 {
  margin: 0;
  font-size: 14px
}

.pill {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #1b382f;
  color: #75e0ad
}

.pill.gray {
  background: #273341;
  color: #c3cfdd
}

.session-row, .client-row, .request-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px
}

.session-row+.session-row, .client-row+.client-row, .request-row+.request-row {
  border-top: 1px solid #253445;
  margin-top: 10px;
  padding-top: 10px
}

.session-row strong, .client-row strong, .request-row strong {
  font-size: 13px;
  display: block
}

.session-row small, .client-row small, .request-row small {
  font-size: 11px;
  color: var(--muted)
}

/* نقش‌های رنگی دکمه‌های اصلی، ثانویه، خنثی و خطر */
.btn-primary {
  height: 48px;
  width: 100%;
  border-radius: 12px;
  background: var(--green);
  color: #071610
}

.btn-secondary {
  height: 40px;
  border-radius: 10px;
  padding: 0 13px;
  background: #29394b
}

.btn-quiet {
  height: 34px;
  border-radius: 9px;
  padding: 0 10px;
  background: #202d3b;
  color: #cad6e2;
  font-size: 12px
}

.btn-danger {
  background: #48242c;
  color: #ffabb0
}

.window-choice {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 11px;
  background: #0d1620;
  border: 1px solid #314457
}

.window-icon {
  width: 33px;
  height: 33px;
  border-radius: 8px;
  background: #305575;
  display: grid;
  place-items: center
}

.window-choice div {
  flex: 1;
  min-width: 0
}

.window-choice strong {
  display: block;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.window-choice small {
  font-size: 11px;
  color: var(--muted)
}

.audio-toggle {
  display: flex;
  gap: 8px
}

.audio-toggle button {
  height: 40px;
  flex: 1;
  border-radius: 10px;
  background: #26384a;
  font-size: 12px
}

.audio-toggle button.active {
  background: #1c6e54;
  color: #cbffe6
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #3e5977;
  color: #e6f2ff;
  font-size: 12px;
  flex: none
}

.avatar.orange {
  background: #745230
}

.avatar.purple {
  background: #5a487e
}

.client-main {
  display: flex;
  gap: 9px;
  align-items: center;
  flex: 1;
  min-width: 0
}

.client-main div {
  min-width: 0
}

.request-actions {
  display: flex;
  gap: 5px
}

/* کارت مرکزی Client پیش از ورود */
.view-shell {
  height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px
}

.client-prejoin {
  width: min(460px, 100%);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(145deg, #151f2c, #0d141d);
  box-shadow: var(--shadow);
  text-align: center
}

.client-prejoin .brand-mark {
  margin: 0 auto 18px;
  width: 52px;
  height: 52px;
  font-size: 26px
}

.client-prejoin h1 {
  font-size: 23px;
  margin: 0 0 9px
}

.client-prejoin p {
  margin: 0 auto 23px;
  max-width: 325px;
  line-height: 1.8;
  color: var(--muted);
  font-size: 14px
}

.designer-card {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 24px;
  padding: 12px;
  border: 1px solid #2c3c4e;
  border-radius: 14px;
  text-align: right;
  background: #0c141e
}

.designer-card .avatar {
  width: 38px;
  height: 38px
}

.designer-card strong {
  font-size: 13px;
  display: block
}

.designer-card span {
  font-size: 11px;
  color: #79dcb0
}

.prejoin-note {
  font-size: 11px;
  color: #77879a;
  margin-top: 14px
}

/* قاب جلسهٔ Client، هدر نام طراح و stage ویدیو */
.client-session {
  height: 100vh;
  padding: 16px;
  display: grid;
  grid-template-rows: 52px minmax(0, 1fr)
}

.client-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px
}

.client-top .person {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px
}

.client-stage {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(145deg, #274455, #101923)
}

.client-stage .canvas-model {
  inset: 12% 11% 8%
}

.client-stage .canvas-grid {
  opacity: .25
}

/* نوار شناور تماس روی تصویر Client */
.toolbar {
  position: absolute;
  z-index: 2;
  bottom: 25px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  padding: 11px;
  border: 1px solid #334356;
  border-radius: 19px;
  background: #111923eb;
  box-shadow: 0 14px 40px #0009
}

.float {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #273748;
  font-size: 18px
}

.float.active {
  background: #1d7558
}

.float.end {
  background: var(--red)
}

.mode-switch {
  position: fixed;
  bottom: 14px;
  right: 16px;
  z-index: 4;
  height: 34px;
  padding: 0 11px;
  border-radius: 9px;
  background: #202d3b;
  font-size: 11px;
  color: #aebccb
}

/* شکست چیدمان Host و Client در نمایشگرهای باریک */
@media(max-width:900px) {
  .preview-host {
    grid-template-columns: 1fr;
    padding: 10px;
    height: auto;
    min-height: calc(100vh - 68px)
  }

  .canvas {
    min-height: 58vh
  }

  .rail {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px
  }

  .rail-title {
    grid-column: 1/-1
  }

  .card {
    margin: 0
  }

  .preview-header {
    padding: 0 16px
  }
}

@media(max-width:560px) {
  .preview-header {
    height: 60px
  }

  .preview-host {
    height: auto
  }

  .rail {
    grid-template-columns: 1fr
  }

  .canvas {
    min-height: 48vh
  }

  .client-session {
    padding: 8px
  }

  .toolbar {
    bottom: 16px
  }

  .view-shell {
    padding: 16px
  }

  .client-prejoin {
    padding: 24px 19px
  }
}

/* قوانین تکمیلی تم روشن؛ بعضی selectorهای بالا را عمداً بازنویسی می‌کنند */
.preview-host {
  direction: ltr
}

.preview-host>.canvas, .preview-host>.rail {
  direction: rtl
}

[hidden] {
  display: none !important
}

/* اندازه‌ها و ظاهر نسخهٔ جدید stage و Toolbar؛ این selectorها نسخه‌های قبلی را override می‌کنند */
.client-stage {
  overflow: visible
}

.toolbar {
  bottom: -10px;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 25px;
  background: #111923;
  transition: transform .2s ease, background .2s ease, border-color .2s ease, box-shadow .2s ease
}

.float {
  width: 44px;
  height: 44px
}

.float svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round
}

.float.end svg {
  width: 22px;
  height: 22px
}

.float.toolbar-toggle {
  position: absolute;
  left: 50%;
  top: -31px;
  width: 86px;
  height: 33px;
  transform: translateX(-50%);
  border: 1px solid #334356;
  border-bottom: 0;
  border-radius: 25px 25px 0 0;
  background: #111923;
  color: #c5d4e4;
  box-shadow: none
}

.float.toolbar-toggle:hover {
  background: #182433;
  color: #fff
}

.toolbar-toggle .chevron-up {
  display: none
}

.toolbar.minimized {
  transform: translateX(-50%) translateY(76px);
  background: transparent;
  border-color: transparent;
  box-shadow: none
}

.toolbar.minimized .float:not(.toolbar-toggle) {
  visibility: hidden
}

.toolbar.minimized .toolbar-toggle .chevron-down {
  display: none
}

.toolbar.minimized .toolbar-toggle .chevron-up {
  display: block;
  width: 18px;
  height: 18px
}

/* Light Blue & White preview theme.  All theme tokens live here for quick iteration. */
:root {
  color-scheme: light;
  --bg: #F5F9FF;
  --surface: #FFFFFF;
  --surface-soft: #F8FBFF;
  --surface-blue: #DCEBFF;
  --primary: #1677FF;
  --primary-hover: #0E63D7;
  --primary-active: #0959C6;
  --text: #142746;
  --muted: #60738F;
  --line: #C9DFFF;
  --line-strong: #AFCBF3;
  --success: #2E9B68;
  --success-soft: #E8F7EF;
  --danger: #E5484D;
  --danger-soft: #FFF0F1;
  --shadow: 0 12px 32px #315d9724
}

body {
  background: linear-gradient(145deg, #F5F9FF 0%, #EAF3FF 100%);
  color: var(--text)
}

button {
  color: var(--text)
}

button:hover {
  transform: translateY(-1px)
}

.preview-header {
  background: #FFFFFFE8;
  border-color: var(--line);
  box-shadow: 0 2px 12px #315d970f
}

.brand-mark {
  border-color: var(--primary);
  background: var(--surface-blue);
  color: var(--primary)
}

.brand small, .eyebrow, .muted {
  color: var(--muted)
}

.live {
  color: var(--muted)
}

.live i {
  background: var(--success);
  box-shadow: 0 0 10px #2E9B6866
}

.preview-host {
  background: transparent
}

.canvas {
  border-color: var(--line-strong);
  background: linear-gradient(145deg, #EDF5FF, #D8E9FC);
  box-shadow: 0 10px 28px #315d9720
}

.canvas-grid {
  opacity: .55;
  background-image: linear-gradient(#719DCD2b 1px, transparent 1px), linear-gradient(90deg, #719DCD2b 1px, transparent 1px)
}

.canvas-model {
  border-color: #4E7FA855;
  background: radial-gradient(ellipse at 55% 42%, #F9FDFF 0 5%, #B9D6F2 30%, #79A5CD 69%);
  box-shadow: inset -35px -20px 55px #4A779933, 0 18px 36px #315D9730
}

.canvas-model:before, .canvas-model:after {
  border-color: #487AA55c
}

.canvas-label {
  background: #FFFFFFE8;
  color: var(--text);
  box-shadow: 0 5px 16px #315D9720
}

.canvas-label i {
  background: var(--success)
}

.preview-cursor {
  border-color: #F05A61;
  background: #FF6B6B2B;
  box-shadow: 0 0 18px #F05A6166
}

.preview-cursor:after {
  background: #142746;
  color: #fff
}

.rail-title span {
  color: var(--muted)
}

.card {
  background: var(--surface);
  border-color: var(--line);
  box-shadow: 0 7px 20px #315D9714
}

.pill {
  background: var(--success-soft);
  color: #237C52
}

.pill.gray {
  background: var(--surface-blue);
  color: #3F6393
}

.session-row+.session-row, .client-row+.client-row, .request-row+.request-row {
  border-color: #E1EDFC
}

.session-row small, .client-row small, .request-row small {
  color: var(--muted)
}

.btn-primary {
  background: var(--primary);
  color: #fff
}

.btn-primary:hover {
  background: var(--primary-hover)
}

.btn-secondary {
  background: var(--surface-blue);
  color: var(--primary)
}

.btn-secondary:hover {
  background: #C9E0FF
}

.btn-quiet {
  background: #EEF5FF;
  color: #31567F
}

.btn-quiet:hover {
  background: #DCEBFF
}

.btn-danger {
  background: var(--danger-soft);
  color: #C83A42
}

.window-choice {
  background: var(--surface-soft);
  border-color: var(--line)
}

.window-icon {
  background: var(--surface-blue);
  color: var(--primary)
}

.window-choice small {
  color: var(--muted)
}

.audio-toggle button {
  background: #EEF5FF;
  color: #31567F
}

.audio-toggle button.active {
  background: var(--primary);
  color: #fff
}

.avatar {
  background: #DCEBFF;
  color: #285486
}

.avatar.orange {
  background: #FFE8D1;
  color: #A85C15
}

.avatar.purple {
  background: #EEE6FF;
  color: #6B48A4
}

.view-shell {
  background: transparent
}

.client-prejoin {
  background: var(--surface);
  border-color: var(--line);
  box-shadow: var(--shadow)
}

.client-prejoin p {
  color: var(--muted)
}

.designer-card {
  background: var(--surface-soft);
  border-color: var(--line)
}

.designer-card span {
  color: var(--success)
}

.prejoin-note {
  color: var(--muted)
}

.client-top .person {
  color: var(--text)
}

.client-stage {
  border-color: var(--line-strong);
  background: linear-gradient(145deg, #EDF5FF, #D8E9FC);
  box-shadow: 0 10px 28px #315D971C
}

.client-stage.waiting-share {
  background: #F5F9FF url('/assets/client-waiting-share.png') center / contain no-repeat;
}

.client-stage.waiting-share>.canvas-grid,
.client-stage.waiting-share>.canvas-model,
.client-stage.waiting-share>.canvas-label,
.client-stage.waiting-share>.preview-cursor {
  display: none;
}

.toolbar {
  background: #FFFFFF;
  border-color: var(--line-strong);
  box-shadow: 0 12px 30px #315D9730
}

.float {
  background: var(--surface-blue);
  color: #31567F
}

.float:hover {
  background: #C9E0FF
}

.float.active {
  background: var(--primary);
  color: #fff
}

.float.end {
  background: var(--danger);
  color: #fff
}

.float.toolbar-toggle {
  background: #FFFFFF;
  border-color: var(--line-strong);
  color: #31567F
}

.float.toolbar-toggle:hover {
  background: #F1F7FF;
  color: var(--primary)
}

.toolbar.minimized {
  background: transparent;
  border-color: transparent;
  box-shadow: none
}

.toolbar.minimized .float.toolbar-toggle {
  background: #FFFFFF;
  border-color: var(--line-strong)
}

.mode-switch {
  background: #FFFFFF;
  color: var(--primary);
  border: 1px solid var(--line);
  box-shadow: 0 5px 14px #315D971C
}

.mode-switch:hover {
  background: #EEF5FF
}

.btn-primary:active, .float.active:active {
  background: var(--primary-active)
}

.request-actions button[style] {
  background: var(--success) !important;
  color: #fff
}

button:disabled {
  background: #EAF1FA !important;
  color: #94A8C1 !important;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important
}

input, select, textarea {
  background: #FFFFFF;
  color: var(--text);
  border-color: var(--line)
}

input::placeholder, textarea::placeholder {
  color: #8AA0BB
}

/* Reference toolbar: one 1066 × 404 coordinate system, uniformly scaled.
   The outline/clip is measured from the 1774 × 887 reference, not the older text dimensions. */
/* viewport محلی Toolbar؛ position مرجع SVG و دکمه‌های شناور است */
.toolbar-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
  pointer-events: none;
  z-index: 2;
}

/* پوستهٔ شیشه‌ای، اندازه و محل نوار نسبت به stage */
.toolbar {
  --toolbar-width: 410px;
  --toolbar-icon: #365577;
  --toolbar-glass-tint: rgba(225, 239, 255, .32);
  --toolbar-edge: rgba(116, 215, 233, 0.85);
  --toolbar-button-tint: rgba(228, 241, 255, .46);
  --toolbar-shadow: rgba(42, 65, 94, .16);
  --toolbar-danger-start: #e63733;
  --toolbar-danger-end: #dd2821;
  --toolbar-duration: 225ms;
  all: unset;
  box-sizing: border-box;
  position: absolute;
  display: block;
  z-index: 2;
  left: 50%;
  bottom: 20px;
  width: min(var(--toolbar-width), calc(100% - 32px));
  aspect-ratio: 1310 / 404;
  container-type: inline-size;
  direction: ltr;
  pointer-events: none;
  transform: translateX(-50%);
  transition: transform var(--toolbar-duration) cubic-bezier(.4, 0, .2, 1);
}

/* مسیر SVG هم‌مرز با شیشه، clip و حاشیهٔ Toolbar */
.toolbar-shell {
  all: unset;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  overflow: visible;
  pointer-events: none;
  filter: drop-shadow(0 1.13cqw 2.82cqw var(--toolbar-shadow));
}

.toolbar-outline {
  fill: rgba(225, 239, 255, .08);
  stroke: var(--toolbar-edge);
  stroke-width: 4.5;
  stroke-linejoin: round;
}

.toolbar-glass {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  clip-path: url(#toolbar-glass-clip);
  background: linear-gradient(150deg, rgba(255, 255, 255, .22), transparent 54%),
    var(--toolbar-glass-tint);
  backdrop-filter: blur(1.876cqw) saturate(135%);
  -webkit-backdrop-filter: blur(1.876cqw) saturate(135%);
}

.toolbar .float {
  all: unset;
  box-sizing: border-box;
  position: absolute;
  z-index: 2;
  top: 63.613861%;
  left: var(--button-x);
  display: grid;
  place-items: center;
  width: 15.267176%;
  aspect-ratio: 1;
  border: .375234cqw solid var(--toolbar-edge);
  border-radius: 50%;
  background: linear-gradient(145deg, rgba(255, 255, 255, .23), transparent 70%),
    var(--toolbar-button-tint);
  color: var(--toolbar-icon);
  box-shadow: 0 2.158cqw 3.096cqw var(--toolbar-shadow),
    inset 0 .094cqw .188cqw rgba(255, 255, 255, .35);
  backdrop-filter: blur(1.126cqw);
  -webkit-backdrop-filter: blur(1.126cqw);
  transform: translate(-50%, -50%);
  transition: background 150ms ease, filter 150ms ease;
  cursor: pointer;
  pointer-events: auto;
}

.toolbar .toolbar-fullscreen {
  --button-x: 13.129771%;
  color: #456085;
}

.toolbar .toolbar-camera {
  --button-x: 31.526718%;
  color: #365577;
}

.toolbar .toolbar-camera.camera-enabled {
  background: linear-gradient(145deg, rgba(147, 201, 154, 0.55)sparent 70%),
    rgba(186, 201, 212, 0.88);
  color: #b02121;
  border-color: rgba(45, 119, 169, 0.88);
}

.toolbar .end {
  --button-x: 50%;
}

.toolbar .toolbar-speaker {
  --button-x: 68.473282%;
}

.toolbar .toolbar-mic {
  --button-x: 86.870229%;
  color: #40536d;
}

.toolbar .float:hover {
  background-color: rgba(244, 250, 255, .64);
  transform: translate(-50%, -50%);
}

.toolbar .float:active {
  filter: brightness(.97);
  transform: translate(-50%, -50%);
}

.toolbar .float:focus-visible {
  outline: .2814cqw solid #1677ff;
  outline-offset: .2814cqw;
}

.toolbar .float svg,
.toolbar .float.end svg {
  all: unset;
  display: block;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: none;
  overflow: visible;
  pointer-events: none;
}

.toolbar .icon-line {
  fill: none;
  stroke: currentColor;
  stroke-width: 8.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.toolbar .icon-fill {
  fill: currentColor;
  stroke: none;
}

.toolbar .speaker-wave {
  stroke-width: 8;
  stroke-linecap: butt;
}

.toolbar .float.end {
  background: linear-gradient(165deg, var(--toolbar-danger-start), var(--toolbar-danger-end));
  color: #fff;
  border-color: rgba(255, 205, 205, .62);
  /* Same neutral shadow, exact diameter and stacking as all three glass buttons. */
  box-shadow: 0 2.158cqw 3.096cqw var(--toolbar-shadow),
    inset 0 .094cqw .188cqw rgba(255, 255, 255, .35);
}

.toolbar .float.end:hover {
  filter: brightness(1.04);
}

.toolbar .float.toolbar-toggle {
  all: unset;
  box-sizing: border-box;
  position: absolute;
  z-index: 3;
  left: 34.427481%;
  top: 0;
  width: 31.145038%;
  height: 27.722772%;
  display: grid;
  place-items: center;
  background: transparent;
  border: 0;
  box-shadow: none;
  color: var(--toolbar-icon);
  cursor: pointer;
  pointer-events: auto;
}

.toolbar .float.toolbar-toggle:hover,
.toolbar .float.toolbar-toggle:active {
  background: transparent;
  box-shadow: none;
  transform: none;
  color: var(--toolbar-icon);
}

.toolbar .toolbar-toggle svg {
  width: 14.705882%;
  height: auto;
  transform: translateY(.7cqw);
  transition: transform var(--toolbar-duration) ease;
}

.toolbar .toolbar-toggle .icon-line {
  stroke-width: 8;
}

/* وضعیت جمع‌شده؛ بدنه پایین می‌رود و فقط زبانه می‌ماند */
.toolbar.minimized {
  transform: translateX(-50%) translateY(89%);
  background: transparent;
  border: 0;
  box-shadow: none;
}

.toolbar.minimized .float:not(.toolbar-toggle) {
  visibility: visible;
  opacity: 1;
  pointer-events: none;
}

.toolbar.minimized .float.toolbar-toggle {
  background: transparent;
  border: 0;
  box-shadow: none;
}

.toolbar.minimized .toolbar-toggle svg {
  transform: translateY(.7cqw) rotate(180deg);
}

/* در تمام‌صفحه stage مبنای اندازه و موقعیت Toolbar باقی می‌ماند */
.client-stage:fullscreen {
  border-radius: 0;
}

@media (max-width: 560px) {
  .toolbar {
    width: min(var(--toolbar-width), calc(50% - 16px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .toolbar {
    --toolbar-duration: 0ms;
  }
}

/* Host preview: prominent pending request above the shared design stage. */
.preview-host>.host-stage-column {
  direction: rtl;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  min-width: 0;
  min-height: 0;
}

/* کارت درخواست اتصال شناور بالای استیج Host */
.request-toast {
  min-height: 116px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 20px;
  border: 1px solid #AFCBF3;
  border-radius: 23px;
  background: linear-gradient(115deg, rgba(255, 255, 255, .9), rgba(228, 240, 255, .84));
  box-shadow: 0 12px 28px rgba(49, 93, 151, .18), inset 0 1px rgba(255, 255, 255, .96);
  backdrop-filter: blur(14px);
}

.request-summary {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
  flex: 1;
}

.request-icon {
  width: 42px;
  height: 42px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid #C7DCFA;
  border-radius: 13px;
  background: linear-gradient(145deg, #fff, #DCEBFF);
  color: #1677FF;
  font-size: 24px;
  font-weight: 800;
  box-shadow: 0 5px 12px #315D971c;
}

.request-heading,
.request-person {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.request-heading {
  min-width: 142px;
}

.request-heading strong {
  color: #142746;
  font-size: 15px;
}

.request-heading small,
.request-person small {
  color: #637C9E;
  font-size: 12px;
}

.request-divider {
  width: 1px;
  height: 46px;
  flex: none;
  margin-inline: 4px;
  background: #B8D0F0;
}

.request-person {
  flex: 1;
}

.request-person strong {
  color: #142746;
  font-size: 16px;
}

.request-toast .avatar {
  width: 52px;
  height: 52px;
  border: 1px solid #fff;
  box-shadow: 0 3px 12px #315D971c;
  color: #31567F;
  font-size: 18px;
}

.request-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: none;
  padding: 7px 11px;
  border-radius: 999px;
  background: #E5F1FF;
  color: #1677FF;
  font-size: 12px;
  font-weight: 700;
}

.request-status i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #1677FF;
  box-shadow: 0 0 0 4px #1677FF20;
}

.request-actions {
  flex: none;
  gap: 10px;
  padding-inline-start: 16px;
  border-inline-start: 1px solid #B8D0F0;
}

.request-actions button {
  min-width: 76px;
  height: 42px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 750;
  box-shadow: 0 5px 12px #315D971c;
}

.request-reject {
  background: linear-gradient(#b52828);
  border-color: #D5E5FA !important;
  color: #f8f8f9;
}

.request-accept {
  background: linear-gradient(145deg, #22A978, #16885F);
  color: #fff;
}

/* ردیف دکمه‌های صوت و قطع تماس در پنل Host */
.device-card-title { display: flex; align-items: center; gap: 7px; }
.device-card-title svg { width: 19px; height: 19px; color: #1677ff; }
.preview-end-session, .preview-end-session:hover { background: #ffe5e8; color: #a82430; }
.preview-device-status[data-state="checking"] { background: #e2efff; color: #1767c4; }
.preview-device-status[data-state="missing"] { background: #ffe8e9; color: #b8323b; }
.preview-device-error { display: block; margin-top: 5px; color: #b8323b; }
.preview-device-error[hidden] { display: none; }
.preview-device-toggle { width: 100%; margin-top: 14px; padding: 10px 12px; display: flex; justify-content: space-between; align-items: center; border: 1px solid #c9dfff; border-radius: 12px; background: #eff6ff; color: #24578f; font-family: Vazirmatn, sans-serif; font-size: 12px; font-weight: 600; cursor: pointer; }
.preview-device-toggle > span { display: flex; align-items: center; gap: 8px; }
.preview-device-toggle svg { width: 18px; height: 18px; }
.preview-device-chevron { transition: transform 200ms ease; }
.preview-device-toggle[aria-expanded="true"] .preview-device-chevron { transform: rotate(180deg); }
.preview-devices { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 200ms ease; }
.preview-devices.is-open { grid-template-rows: 1fr; }
.preview-devices-inner { min-height: 0; overflow: hidden; }
.preview-devices label { display: block; margin-top: 12px; color: #536b89; font-family: Vazirmatn, sans-serif; font-size: 11px; font-weight: 600; }
.preview-devices select { display: block; width: 100%; margin-top: 5px; padding: 9px 10px; border: 1px solid #c9dfff; border-radius: 10px; background: #f5f9ff; color: #142746; font-family: Vazirmatn, sans-serif; font-size: 12px; }
@media (prefers-reduced-motion: reduce) { .preview-device-chevron, .preview-devices { transition: none; } }
.host-audio-controls {
  display: flex;
  align-items: start;
  gap: 10px;
}

.host-audio-control {
  min-width: 0;
  flex: 1;
  display: grid;
  justify-items: center;
  gap: 7px;
  color: #31567F;
  font-size: 12px;
  font-weight: 650;
}

/* دکمه‌های دایره‌ای Camera، Microphone، Speaker و پایان تماس */
.host-audio-button {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border: 1px solid #C9DFFF;
  border-radius: 50%;
  background: linear-gradient(145deg, rgba(255, 255, 255, .96), rgba(230, 241, 255, .84));
  color: #2e71cf;
  box-shadow: 0 7px 16px #315D9724, inset 0 1px #fff;
  backdrop-filter: blur(8px);
}



.host-audio-button:hover {
  background: #E6F1FF;
}

.host-audio-button svg {
  width: 110%;
  height: 110%;
  fill: none;
  overflow: visible;
}

#preview-host-camera svg {
  width: 80%;
  height: 80%;
}

#preview-host-camera .slash {
  stroke-width: 2px;
  stroke: #901a2c;
}

#preview-host-camera .slash-halo {
  stroke-width: 3.5px;
}

.host-audio-button .icon-line {
  stroke: currentColor;
  stroke-width: 9.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.host-audio-button .icon-fill {
  fill: currentColor;
  stroke: none;
}

.host-audio-button .speaker-wave {
  stroke-width: 8.5;
}

.host-audio-button.preview-toggle[aria-pressed="false"] {
  color: #31567f;
}

.host-audio-button .slash-halo {
  fill: none;
  stroke: #fff;
  stroke-width: 17;
  stroke-linecap: round;
}

.host-audio-button .slash {
  fill: none;
  stroke: #142746;
  stroke-width: 8;
  stroke-linecap: round;
}

.host-audio-button[aria-label="دوربین"] svg {
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* عنوان تنظیمات و دکمهٔ چرخ‌دنده در ریل Host */
.settings-trigger {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 8px;
  border: 0;
  background: transparent;
  color: #142746;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.settings-trigger span {
  color: #1677ff;
  font-size: 20px;
}

/* پنجرهٔ نمونه و segmented control کیفیت در Preview */
.preview-window-select {
  display: block;
  color: #31567f;
  font-size: 11px;
}

.preview-window-select select {
  width: 100%;
  margin-top: 7px;
  padding: 9px 10px;
  border: 1px solid #c9dfff;
  border-radius: 11px;
  color: #142746;
  background: #f8fbff;
  font: inherit;
  font-size: 12px;
  direction: ltr;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23142746' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.preview-quality {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* وضعیت و دکمهٔ نمایشی اشتراک تصویر در کارت Design Window */
.preview-share-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.preview-share-status i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #91a3b9;
}

.preview-share-status.is-playing i {
  background: #168c63;
}

.preview-share-button {
  width: 100%;
  margin-top: 12px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid #1675ff;
  border-radius: 12px;
  background: #1675ff;
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px #1677ff24;
}

.preview-share-button:hover {
  background: #0866ea;
}

.preview-share-button:disabled {
  opacity: .65;
  cursor: wait;
}

.preview-share-icon {
  font-size: 12px;
}

.preview-share-actions {
  display: flex;
  gap: 0;
  margin-top: 13px;
  transition: gap 200ms ease;
}

.preview-share-actions.is-started {
  gap: 8px;
}

.preview-share-actions .preview-share-button {
  flex: 1 1 100%;
  width: 0;
  min-width: 0;
  margin-top: 0;
  transition: flex-basis 200ms ease, background 150ms ease;
}

.preview-share-actions.is-started .preview-share-button {
  flex-basis: 50%;
}

.preview-share-stop {
  flex: 0 0 0;
  width: 0;
  min-width: 0;
  min-height: 40px;
  padding: 0;
  border: 0 solid #ff9da5;
  border-radius: 12px;
  overflow: hidden;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  background: #ffe0e3;
  color: #bd1017;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: flex-basis 200ms ease, opacity 160ms ease, visibility 200ms;
}

.preview-share-actions.is-started .preview-share-stop {
  flex: 1 1 50%;
  border-width: 1px;
  opacity: 1;
  visibility: visible;
}

.preview-share-stop span+span {
  margin-inline-start: 8px;
}

.preview-share-stop:hover {
  background: #ffd2d7;
}

.quality-group {
  flex: 1;
  min-width: 0;
}

.quality-title {
  display: block;
  margin: 0 0 6px;
  text-align: center;
  color: #536b89;
  font-size: 11px;
  font-family: "Vazirmatn", sans-serif;
  font-weight: 600;
}

/* ظرف هر گروه انتخاب؛ indicator با transform به گزینهٔ دیگر می‌لغزد */
.segmented {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  min-height: 35px;
  padding: 4px;
  border: 1px solid #d9e8fb;
  border-radius: 999px;
  background: #eff6ff;

}

/* پس‌زمینهٔ فعال متحرک؛ width نصف گروه و transition مدت حرکت را کنترل می‌کند */
.segment-indicator {
  position: absolute;
  z-index: 0;
  top: 3px;
  bottom: 3px;
  right: 3px;
  width: calc((100% - 6px)/2);
  border-radius: 999px;
  background: #1677ff;
  box-shadow: 0 2px 8px #1677ff40;
  transform: translateX(calc(var(--active-index, 0)*-100%));
  transition: transform 220ms cubic-bezier(.2, .8, .2, 1);
}

.segment {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 4px 3px;
  border-radius: 999px;
  color: #526b89;
  font-size: 10px;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: color 180ms;
}

.segment:has(input:checked) {
  color: white;
}

.segment input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  opacity: 0;
  cursor: pointer;
}

.segment input:focus-visible+span {
  outline: 2px solid #142746;
  outline-offset: 2px;
  border-radius: 4px;
}

/* پرده و پنل نمونهٔ تنظیمات میکروفن، خروجی صدا و دوربین */
.preview-settings-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 16px;
  background: #152a4570;
  backdrop-filter: blur(5px);
}

.preview-settings-backdrop[hidden] {
  display: none;
}

.preview-settings-panel {
  width: min(420px, 100%);
  padding: 20px;
  border: 1px solid #c9dfff;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 24px 70px #163b6740;
}

.preview-settings-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.preview-settings-head h2 {
  margin: 0;
  color: #142746;
  font-size: 16px;
}

.preview-settings-head button {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: #edf5ff;
  color: #31567f;
  font-size: 20px;
  cursor: pointer;
}

.preview-settings-panel label {
  display: block;
  margin: 14px 0 5px;
  color: #31567f;
  font-size: 12px;
  font-weight: 700;
}

.preview-settings-panel select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 9px;
  border: 1px solid #c9dfff;
  border-radius: 10px;
  background: #f8fbff;
  color: #142746;
  font: inherit;
  font-size: 12px;
}

.preview-settings-panel small, .preview-settings-panel p {
  color: #627c9a;
  font-size: 11px;
  line-height: 1.7;
}

.host-audio-button.is-danger {
  border-color: #b92929;
  background: linear-gradient(#c91f2d);
  color: #fffefe;
  box-shadow: 0 7px 16px #E5484D24, inset 0 0px #8f1e1e;
}

@media (max-width: 1100px) {
  .request-summary {
    gap: 9px;
  }

  .request-heading {
    min-width: 120px;
  }

  .request-status {
    font-size: 11px;
  }
}

@media (max-width: 900px) {
  .preview-host>.host-stage-column {
    min-height: auto;
  }

  .request-toast {
    min-height: 108px;
  }
}

@media (max-width: 620px) {
  .request-toast {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
  }

  .request-summary {
    flex-wrap: wrap;
  }

  .request-heading {
    flex: 1;
  }

  .request-divider {
    display: none;
  }

  .request-person {
    flex-basis: calc(100% - 72px);
  }

  .request-status {
    margin-inline-start: 4px;
  }

  .request-actions {
    justify-content: flex-start;
    padding-inline-start: 0;
    border-inline-start: 0;
  }

  .request-actions button {
    flex: 1;
  }


}

#preview-share-status.is-playing {
  background: #e7e0e0;
  color: #b70a0a;
}

/* فقط نقطه وضعیت در حال پخش */
#preview-share-status.is-playing i {
  background: #ff304f;
}

/* در حالت توقف موقت، دکمهٔ ادامه پخش سبز می‌شود. */
.preview-share-actions.is-paused #preview-share-button {
  background: #16a34a;
  border-color: #16a34a;
}

/* Start sharing button - green */
.preview-share-actions:not(.is-started) #preview-share-button {
  background: #16a34a;

  border: 2px solid #13793d;
  font-family: "Vazirmatn", sans-serif;
  font-size: 15px;
  font-weight: 600;
}

#preview-share-button,
#preview-share-stop {
  font-family: "Vazirmatn", sans-serif;
  font-size: 13px;
  font-weight: 600;
}
