@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@600;700;800&display=swap");

:root {
  color-scheme: dark;
  --bg: #07111f;
  --surface: #0d1a2b;
  --surface-2: #122238;
  --line: rgba(255, 255, 255, 0.1);
  --text: #f4f7fb;
  --muted: #98a8bb;
  --accent: #4ce0b3;
  --accent-dark: #092e29;
  --danger: #ff6b6b;
  --warning: #ffcf70;
  font-family: "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--text); background:
  radial-gradient(circle at 80% -10%, rgba(55, 133, 255, .16), transparent 36rem),
  radial-gradient(circle at 0% 100%, rgba(76, 224, 179, .08), transparent 30rem), var(--bg); }
button, select, textarea { font: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }

.shell { width: min(1180px, calc(100% - 32px)); margin-inline: auto; }
.topbar { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 11px; font: 700 18px "Manrope", sans-serif; letter-spacing: -.02em; }
.brand--large { font-size: 21px; padding-top: 26px; }
.brand__mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; color: var(--bg); background: var(--accent); font-weight: 800; }
.topbar__meta { display: flex; align-items: center; gap: 18px; color: var(--muted); font-size: 14px; }
.status { display: inline-flex; align-items: center; gap: 8px; }
.status__dot { width: 8px; height: 8px; border-radius: 99px; background: #657489; }
.status--live .status__dot { background: var(--accent); box-shadow: 0 0 0 5px rgba(76,224,179,.11); }
.status--live { color: var(--text); }

.landing { min-height: 100vh; display: flex; flex-direction: column; }
.hero { padding: clamp(70px, 11vw, 132px) 0 52px; max-width: 820px; }
.eyebrow { margin: 0 0 14px; color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }
.hero h1 { margin: 0; font: 800 clamp(48px, 8vw, 92px)/.98 "Manrope", sans-serif; letter-spacing: -.06em; }
.hero h1 span { color: var(--muted); }
.hero__copy { max-width: 610px; margin: 30px 0 0; color: var(--muted); font-size: clamp(17px, 2vw, 21px); line-height: 1.55; }
.role-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.role-card { min-height: 250px; display: flex; flex-direction: column; align-items: flex-start; padding: 30px; border: 1px solid var(--line); border-radius: 24px; background: rgba(13,26,43,.82); transition: transform .18s ease, border-color .18s ease; }
.role-card:hover { transform: translateY(-3px); border-color: rgba(255,255,255,.25); }
.role-card--speaker { background: linear-gradient(145deg, #10293a, #0d1a2b); }
.role-card--screen { background: linear-gradient(145deg, #1a2034, #0d1a2b); }
.role-card__icon { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 28px; border-radius: 14px; color: var(--accent); background: var(--accent-dark); }
.role-card strong { font: 700 26px "Manrope", sans-serif; margin-bottom: 10px; }
.role-card > span:not(.eyebrow):not(.role-card__icon):not(.role-card__link) { color: var(--muted); line-height: 1.5; }
.role-card__link { margin-top: auto; padding-top: 28px; font-weight: 600; }
.landing__footer { margin-top: auto; padding: 42px 0 28px; color: var(--muted); font-size: 12px; letter-spacing: .2em; }

.app { min-height: 100vh; }
.workspace { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(290px, .7fr); gap: 22px; padding-block: 30px 42px; }
.panel { border: 1px solid var(--line); border-radius: 22px; background: rgba(13, 26, 43, .86); overflow: hidden; }
.panel__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.panel__head h1, .panel__head h2 { margin: 0; font: 700 20px "Manrope", sans-serif; }
.panel__head p { margin: 7px 0 0; color: var(--muted); font-size: 14px; }
.panel__body { padding: 24px; }
.transcript { height: min(58vh, 570px); overflow-y: auto; padding: 26px; }
.transcript__empty { height: 100%; display: grid; place-items: center; text-align: center; color: var(--muted); }
.transcript__empty strong { display: block; margin-bottom: 8px; color: var(--text); font-size: 17px; }
.utterance { max-width: 820px; margin: 0 0 22px; font-size: clamp(19px, 2vw, 26px); line-height: 1.5; letter-spacing: -.01em; }
.utterance--live::after { content: ""; display: inline-block; width: 7px; height: 1.1em; margin-left: 5px; vertical-align: -.15em; background: var(--accent); animation: blink 1s steps(2) infinite; }
.utterance--preview { color: #d5deea; opacity: .88; }
@keyframes blink { 50% { opacity: 0; } }

.controls { display: grid; gap: 22px; }
.control-group label, .label { display: block; margin-bottom: 9px; color: var(--muted); font-size: 13px; font-weight: 600; }
.range-label { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.range-label strong { color: var(--accent); font-size: 13px; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.level { height: 7px; margin-top: 10px; overflow: hidden; border-radius: 99px; background: #081522; }
.level span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width 80ms linear, background 80ms linear; }
.hint { margin: 9px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 13px; color: var(--text); background: #081522; outline: none; }
textarea { min-height: 180px; resize: vertical; padding: 14px; line-height: 1.5; }
select { min-height: 50px; padding: 0 42px 0 14px; }
textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(76,224,179,.1); }
textarea:disabled { opacity: .55; }
.metric-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.metric { padding: 15px; border: 1px solid var(--line); border-radius: 13px; }
.metric span { display: block; color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin-top: 4px; font-size: 21px; }
.button { min-height: 52px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; border: 0; border-radius: 14px; padding: 0 20px; cursor: pointer; color: #051411; background: var(--accent); font-weight: 700; transition: filter .15s ease, transform .15s ease; }
.button:hover { filter: brightness(1.06); }
.button:active { transform: scale(.99); }
.button--danger { color: white; background: #d84d57; }
.button--ghost { color: var(--text); background: var(--surface-2); border: 1px solid var(--line); }
.button[disabled] { opacity: .45; cursor: not-allowed; }
.button--wide { width: 100%; }
.error { display: none; padding: 12px 14px; border: 1px solid rgba(255,107,107,.28); border-radius: 12px; color: #ffb2b2; background: rgba(255,107,107,.08); font-size: 13px; }
.error--visible { display: block; }

.listener { width: min(820px, calc(100% - 28px)); height: 100dvh; min-height: 500px; margin-inline: auto; display: flex; flex-direction: column; overflow: hidden; }
.listener-main { min-height: 0; flex: 1; display: flex; flex-direction: column; padding: 30px 0 24px; overflow: hidden; }
.language-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.language-row h1 { margin: 0; font: 700 clamp(25px, 5vw, 38px) "Manrope", sans-serif; letter-spacing: -.035em; }
.language-row select { width: min(220px, 48vw); }
.translation-feed { min-height: 0; flex: 1; padding: clamp(22px, 5vw, 42px); border: 1px solid var(--line); border-radius: 24px; background: rgba(13,26,43,.82); overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.translation-feed .utterance { font-size: clamp(24px, 4.2vw, 42px); line-height: 1.35; }
.listener-actions { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding-top: 16px; }
.connection-note { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.listener-audio { width: 56px; height: 56px; min-height: 0; padding: 0; justify-self: end; border: 1.5px solid rgba(116,237,194,.72); border-radius: 50%; color: var(--accent); background: rgba(13,30,49,.92); box-shadow: 0 6px 22px rgba(0,0,0,.18); }
.listener-audio svg { width: 46px; height: 36px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.listener-audio .profile-head { fill: rgba(76,224,179,.04); }
.listener-audio .music-note { fill: currentColor; stroke-width: 1.9; }
.listener-audio--active { color: #07111f; border-color: var(--accent); background: linear-gradient(135deg,#64e9bb,#7be0ba); }
[dir="rtl"] .utterance { text-align: right; }

.screen-page, html:has(.screen-page) { min-height: 100dvh; overflow: hidden; background: transparent !important; }
.screen-stage { position: relative; width: 100%; height: 100dvh; overflow: hidden; background: transparent; }
.screen-subtitle-wrap { position: absolute; left: 1.5vw; right: 1.5vw; bottom: 4vh; display: flex; justify-content: center; }
.screen-subtitle { width: 100%; height: calc(2.36em + 4px); margin: 0; padding: 0 .28em; display: grid; place-items: center; overflow: hidden; color: #fff; background: transparent; text-align: center; font: 700 clamp(34px, 4.2vw, 72px)/1.18 "Manrope", sans-serif; text-shadow: 0 2px 7px rgba(0,0,0,.95); }
.screen-subtitle__text { width: 100%; min-width: 0; display: block; overflow: visible; white-space: normal; line-height: inherit; }
.screen-subtitle[dir="rtl"] { font-family: "DM Sans", sans-serif; }
.screen-subtitle--measure { position: fixed; left: -200vw; top: 0; width: 97vw; visibility: hidden; pointer-events: none; }

@media (max-width: 800px) {
  .role-grid, .workspace { grid-template-columns: 1fr; }
  .hero { padding-top: 70px; }
  .workspace { padding-top: 18px; }
  .workspace > .panel:first-child { order: 2; }
  .transcript { height: 45vh; }
  .topbar__meta .topbar__label { display: none; }
}

@media (max-width: 520px) {
  .shell { width: min(100% - 20px, 1180px); }
  .topbar { min-height: 66px; }
  .role-card { min-height: 230px; padding: 24px; }
  .panel__head, .panel__body { padding: 18px; }
  .language-row { align-items: flex-start; flex-direction: column; }
  .language-row select { width: 100%; }
  .listener-actions { grid-template-columns: 1fr auto; }
  .listener-actions .connection-note { justify-content: flex-start; }
}

/* Refined speaker and listener interface */
.speaker-page, .listener-page { min-height: 100dvh; background: radial-gradient(circle at 76% 8%, rgba(38,105,171,.14), transparent 34rem), radial-gradient(circle at 6% 90%, rgba(76,224,179,.055), transparent 30rem), var(--bg); }
.speaker-app { width: min(1240px, calc(100% - 28px)); }
.speaker-header, .listener-header { position: relative; min-height: 78px; display: grid; place-items: center; border-bottom: 1px solid var(--line); }
.brand--speaker, .brand--listener { font-size: 21px; }
.brand--speaker .brand__mark, .brand--listener .brand__mark { width: 44px; height: 44px; border-radius: 13px; font-size: 23px; background: linear-gradient(135deg, #74edc2, #63d7ae); box-shadow: 0 8px 30px rgba(76,224,179,.15); }
.speaker-status { position: absolute; right: 0; }
.speaker-workspace { display: grid; grid-template-columns: minmax(0,1.55fr) minmax(360px,.9fr); gap: 20px; padding: 18px 0 30px; align-items: stretch; }
.speaker-transcript-panel, .speaker-control-panel { min-height: calc(100dvh - 126px); }
.speaker-transcript-head { min-height: 152px; padding: 34px 28px 26px; }
.speaker-transcript-head .eyebrow { color: #a9b9cc; }
.speaker-transcript-head h1 { font-size: 25px; }
.speaker-transcript-head p:last-child { font-size: 15px; }
.speaker-transcript-panel .transcript { height: calc(100% - 152px); min-height: 520px; padding: 34px 28px; }
.speaker-transcript-panel .utterance { font-size: clamp(20px,2vw,29px); }
.speaker-control-panel { overflow: visible; }
.speaker-controls { padding: 30px; display: grid; gap: 0; }
.speaker-controls > .control-group, .speaker-primary-actions { padding: 0 0 28px; margin: 0 0 28px; border-bottom: 1px solid var(--line); }
.speaker-controls > .control-group:last-child { padding-bottom: 0; margin-bottom: 0; border-bottom: 0; }
.speaker-controls label { margin-bottom: 12px; color: #b8c4d4; font-size: 14px; font-weight: 700; }
.select-with-icon { position: relative; }
.select-with-icon::after, .listener-language::after { content: ""; position: absolute; z-index: 1; right: 23px; top: 50%; width: 10px; height: 10px; border-right: 2px solid #f4f7fb; border-bottom: 2px solid #f4f7fb; transform: translateY(-68%) rotate(45deg); pointer-events: none; }
.select-with-icon svg, .listener-language svg { position: absolute; z-index: 1; left: 18px; top: 50%; width: 24px; height: 24px; transform: translateY(-50%); fill: none; stroke: currentColor; stroke-width: 1.8; color: var(--accent); pointer-events: none; }
.select-with-icon select { height: 60px; padding: 0 56px 0 58px; appearance: none; border: 1.5px solid rgba(116,237,194,.42); border-radius: 15px; background: linear-gradient(180deg,rgba(23,43,66,.98),rgba(12,28,47,.98)); box-shadow: 0 0 0 3px rgba(76,224,179,.045),inset 0 1px 0 rgba(255,255,255,.05); font-size: 17px; font-weight: 600; cursor: pointer; }
.select-with-icon select:hover, .select-with-icon select:focus { border-color: rgba(116,237,194,.82); box-shadow: 0 0 0 4px rgba(76,224,179,.1),inset 0 1px 0 rgba(255,255,255,.07); }
.gain-control .range-label { margin-bottom: 11px; }
.gain-control .range-label label { margin: 0; }
.gain-control input[type="range"] { height: 22px; }
.gain-control .level { height: 4px; margin-top: 7px; opacity: .75; }
.gain-control .hint { max-width: 390px; margin-top: 14px; font-size: 13px; }
.speaker-primary-actions { display: grid; gap: 12px; }
.speaker-start { min-height: 86px; border-radius: 16px; font: 800 24px "Manrope",sans-serif; background: linear-gradient(105deg,#64e9bb,#7be0ba); }
.speaker-start svg { width: 48px; height: 48px; fill: none; stroke: #07111f; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.speaker-start.button--danger { color: white; background: linear-gradient(105deg,#d84d57,#bc3947); }
.speaker-start.button--danger svg { stroke: white; }
.speaker-pause { min-height: 58px; border-color: rgba(255,207,112,.5); color: #ffe2a3; background: rgba(255,207,112,.08); }
.speaker-pause[hidden], .speaker-pause-note[hidden] { display: none; }
.speaker-pause svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.speaker-pause .resume-icon { display: none; }
.speaker-pause--paused { border-color: var(--accent); color: #07111f; background: linear-gradient(105deg,#64e9bb,#7be0ba); }
.speaker-pause--paused .pause-icon { display: none; }
.speaker-pause--paused .resume-icon { display: block; }
.speaker-pause-note { margin: 0; padding: 12px 14px; border: 1px solid rgba(255,207,112,.36); border-radius: 12px; color: #ffe2a3; background: rgba(255,207,112,.08); text-align: center; font-size: 13px; font-weight: 700; }
.status--paused { color: #ffe2a3; }
.status--paused .status__dot { background: var(--warning); box-shadow: 0 0 0 5px rgba(255,207,112,.12); }
.speaker-listener-link { min-height: 62px; border-color: rgba(255,255,255,.34); background: transparent; font-size: 15px; }
.speaker-stats { min-height: 28px; display: flex; align-items: center; justify-content: center; gap: 11px; color: var(--muted); font-size: 12px; }
.speaker-stats strong { color: var(--text); }
.speaker-stats i { width: 3px; height: 3px; border-radius: 50%; background: #596a7d; }
.speaker-controls textarea { min-height: 155px; }

.listener { width: min(820px,calc(100% - 36px)); height: 100dvh; min-height: 560px; }
.listener-header { min-height: 112px; }
.listener-main { padding: 30px 0 8px; }
.listener-language { position: relative; flex: none; }
.listener-language svg { left: 25px; width: 28px; height: 28px; color: var(--accent); }
.listener-language select { width: 100%; height: 76px; padding: 0 62px 0 72px; appearance: none; border: 1.5px solid rgba(116,237,194,.48); border-radius: 20px; background: linear-gradient(180deg,rgba(23,43,66,.98),rgba(11,27,46,.98)); box-shadow: 0 0 0 3px rgba(76,224,179,.055),inset 0 1px 0 rgba(255,255,255,.055); font: 600 20px "Manrope",sans-serif; cursor: pointer; }
.listener-language select:hover, .listener-language select:focus { border-color: rgba(116,237,194,.9); box-shadow: 0 0 0 4px rgba(76,224,179,.11),inset 0 1px 0 rgba(255,255,255,.07); }
.listener .translation-feed { min-height: 0; flex: 1; margin-top: 18px; padding: 34px 6px 24px; border: 0; border-radius: 0; background: transparent; overflow-y: auto; scrollbar-width: thin; mask-image: linear-gradient(to bottom,transparent 0,#000 22px,#000 calc(100% - 18px),transparent 100%); }
.listener .translation-feed .utterance { max-width: 100%; margin: 0 0 26px; color: #f6f8fb; font: 600 clamp(25px,4vw,38px)/1.42 "Manrope",sans-serif; letter-spacing: -.025em; }
.listener-waiting { height: 100%; min-height: 240px; display: grid; place-items: center; color: #aab7ca; font-size: clamp(25px,4vw,34px); }
.listener-error { flex: none; margin-top: 8px; }
.listener-footer { flex: none; min-height: 72px; padding: 10px 0 max(18px,env(safe-area-inset-bottom)); display: grid; grid-template-columns: 64px 1fr 64px; align-items: center; background: linear-gradient(to top,var(--bg) 72%,rgba(7,17,31,0)); }
.listener-audio { grid-column: 3; width: 56px; height: 56px; min-height: 0; padding: 7px; justify-self: end; border: 1.5px solid rgba(116,237,194,.72); border-radius: 50%; color: var(--accent); background: rgba(13,30,49,.92); box-shadow: 0 6px 22px rgba(0,0,0,.18); }
.listener-audio img { width: 100%; height: 100%; display: block; object-fit: contain; }
.listener-audio:hover, .listener-audio:focus-visible { border-color: var(--accent); background: rgba(22,49,67,.98); box-shadow: 0 0 0 4px rgba(76,224,179,.1),0 8px 28px rgba(0,0,0,.2); }
.listener-audio--active { border-color: var(--accent); background: linear-gradient(135deg,#64e9bb,#7be0ba); box-shadow: 0 0 0 4px rgba(76,224,179,.1),0 10px 32px rgba(76,224,179,.15); }
.listener-audio--active img { filter: brightness(0) saturate(100%); }
.listener-footer .connection-note { grid-column: 2; grid-row: 1; justify-content: center; color: #e5eaf0; font-size: 15px; }
.listener-footer .status__dot { width: 9px; height: 9px; background: #627083; }
.listener-page.is-broadcast-live .listener-footer .status__dot { background: var(--accent); }

@media (max-width: 800px) {
  .speaker-app.shell { width: min(100% - 38px,680px); }
  .speaker-header { min-height: 118px; border-bottom: 0; }
  .brand--speaker { font-size: 26px; }
  .brand--speaker .brand__mark { width: 54px; height: 54px; border-radius: 15px; font-size: 28px; }
  .speaker-status { top: 18px; right: 0; font-size: 11px; }
  .speaker-status:not(.status--live) { display: none; }
  .speaker-workspace { display: flex; flex-direction: column; gap: 22px; padding: 5px 0 40px; }
  .speaker-control-panel { order: 1; min-height: auto; border: 0; border-radius: 0; background: transparent; }
  .speaker-transcript-panel { order: 2; min-height: 480px; }
  .speaker-page:not(.is-live) .speaker-transcript-panel { display: none; }
  .speaker-controls { padding: 0; }
  .speaker-controls > .control-group, .speaker-primary-actions { padding-bottom: 30px; margin-bottom: 30px; }
  .speaker-controls label { font-size: 16px; }
  .select-with-icon select { height: 68px; font-size: 20px; }
  .gain-control .range-label strong { font-size: 18px; }
  .gain-control .hint { font-size: 14px; }
  .speaker-start { min-height: 94px; font-size: 30px; }
  .speaker-listener-link { min-height: 64px; font-size: 17px; }
  .speaker-stats { font-size: 13px; }
  .speaker-transcript-panel .transcript { height: 55vh; min-height: 350px; }
}

@media (max-width: 520px) {
  .speaker-app.shell { width: min(100% - 34px,680px); }
  .speaker-header { min-height: 110px; }
  .brand--speaker { font-size: 24px; }
  .brand--speaker .brand__mark { width: 50px; height: 50px; }
  .speaker-controls > .control-group, .speaker-primary-actions { padding-bottom: 26px; margin-bottom: 26px; }
  .select-with-icon select { height: 64px; font-size: 18px; }
  .speaker-start { min-height: 88px; font-size: 27px; }
  .listener { width: min(100% - 32px,820px); min-height: 500px; }
  .listener-header { min-height: 118px; border-bottom: 1px solid var(--line); }
  .brand--listener { font-size: 24px; }
  .brand--listener .brand__mark { width: 50px; height: 50px; border-radius: 14px; }
  .listener-main { padding-top: 22px; }
  .listener-language select { height: 66px; padding-left: 62px; border-radius: 16px; font-size: 18px; }
  .listener-language svg { left: 20px; width: 25px; height: 25px; }
  .listener .translation-feed { margin-top: 8px; padding-top: 20px; }
  .listener .translation-feed .utterance { font-size: clamp(23px,7vw,31px); }
  .listener-waiting { font-size: 25px; }
  .listener-footer { min-height: 66px; padding-top: 6px; grid-template-columns: 58px 1fr 58px; }
  .listener-audio { width: 52px; height: 52px; }
}
