@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&family=Instrument+Serif:ital@0;1&display=swap");

:root {
  color-scheme: dark;
  --ink: #f7f7f7;
  --muted: #93a4ae;
  --dim: #5d707c;
  --line: rgba(89, 222, 251, 0.14);
  --panel: rgba(10, 25, 35, 0.76);
  --panel-deep: rgba(6, 18, 27, 0.92);
  --brand-blue: #037fd9;
  --brand-cyan: #06bde7;
  --brand-green: #94ca36;
  --brand-gradient: linear-gradient(90deg, var(--brand-blue), var(--brand-cyan) 56%, var(--brand-green));
  --accent: var(--brand-cyan);
  --accent-deep: #04131b;
  --danger: #ff776d;
  --radius: 18px;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: #071017; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "DM Sans", system-ui, sans-serif;
  background:
    radial-gradient(circle at 78% 4%, rgba(6, 189, 231, 0.14), transparent 32rem),
    radial-gradient(circle at 5% 84%, rgba(3, 127, 217, 0.14), transparent 30rem),
    radial-gradient(circle at 92% 88%, rgba(148, 202, 54, 0.07), transparent 24rem),
    #071017;
}

button, select, input { font: inherit; }

.shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding-bottom: 28px; }

.topbar {
  min-height: 76px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; font-weight: 600; letter-spacing: -.02em; }
.brand-role { margin-left: 7px; color: var(--dim); font-size: 8px; letter-spacing: .13em; vertical-align: 2px; }
.brand-mark { width: 25px; height: 25px; display: grid; grid-template-columns: repeat(4, 1fr); align-items: center; gap: 2px; }
.brand-mark span { display: block; border-radius: 5px; background: var(--brand-cyan); }
.brand-mark span:nth-child(1) { height: 32%; }
.brand-mark span:nth-child(2) { height: 74%; background: var(--brand-blue); }
.brand-mark span:nth-child(3) { height: 100%; background: var(--brand-cyan); }
.brand-mark span:nth-child(4) { height: 48%; background: var(--brand-green); }

.connection { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); box-shadow: 0 0 0 4px rgba(83, 97, 89, .12); }
.status-dot.live { background: var(--brand-green); box-shadow: 0 0 0 4px rgba(148, 202, 54, .12), 0 0 18px rgba(148, 202, 54, .4); }
.status-dot.connecting { background: #e7c85e; animation: pulse 1s infinite; }
.status-dot.error { background: var(--danger); }

.icon-button { justify-self: end; width: 40px; height: 40px; display: grid; place-items: center; color: var(--muted); border: 1px solid var(--line); border-radius: 11px; background: transparent; cursor: pointer; }
.icon-button:hover { color: var(--ink); border-color: rgba(214,236,222,.25); }
.icon-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.hero { padding: 74px 0 48px; max-width: 800px; }
.eyebrow { margin: 0 0 15px; color: var(--accent); font-size: 11px; font-weight: 600; letter-spacing: .18em; }
.hero h1 { margin: 0; font-family: "Instrument Serif", Georgia, serif; font-size: clamp(50px, 7vw, 88px); font-weight: 400; line-height: .92; letter-spacing: -.045em; }
.hero h1 em, .listener-hero h1 em {
  color: var(--brand-cyan);
  background: var(--brand-gradient);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 400;
}
.intro { max-width: 575px; margin: 28px 0 0; color: var(--muted); font-size: 16px; line-height: 1.6; }

.controls {
  display: grid;
  grid-template-columns: 1.35fr .8fr 1.1fr auto;
  gap: 1px;
  margin-bottom: 20px;
  padding: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--line);
}

.field, .toggle-field { min-height: 78px; padding: 15px 18px; background: var(--panel-deep); }
.field { display: flex; flex-direction: column; justify-content: center; gap: 7px; }
.field > span, .toggle-field small { color: var(--muted); font-size: 11px; letter-spacing: .03em; }
.field select { width: 100%; padding: 0 26px 0 0; color: var(--ink); border: 0; outline: 0; background: transparent; font-size: 14px; font-weight: 500; cursor: pointer; }
.field:focus-within { background: #0b2230; }
.field input { width: 100%; padding: 0; color: var(--ink); border: 0; outline: 0; background: transparent; font: inherit; font-size: 14px; font-weight: 500; }
.field input::placeholder { color: var(--dim); font-weight: 400; }
.field input:disabled { color: var(--muted); }
#channelInput { text-transform: uppercase; letter-spacing: .06em; }
.access-controls { grid-template-columns: 1fr 1fr; }
.channel-code { color: var(--ink); font-size: 26px; font-weight: 600; letter-spacing: .08em; }

.toggle-field { display: flex; align-items: center; justify-content: space-between; gap: 16px; cursor: pointer; }
.toggle-field > span { display: flex; flex-direction: column; gap: 5px; }
.toggle-field strong { font-size: 13px; font-weight: 500; }
.toggle-field input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-field i { width: 42px; height: 24px; padding: 3px; border: 1px solid var(--line); border-radius: 99px; background: #243541; transition: .2s; }
.toggle-field i::after { content: ""; display: block; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: .2s; }
.toggle-field input:checked + i { background: var(--accent); }
.toggle-field input:checked + i::after { transform: translateX(18px); background: var(--accent-deep); }
.toggle-field input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 3px; }

.start-button { min-width: 180px; display: flex; align-items: center; justify-content: center; gap: 11px; padding: 0 24px; color: white; border: 0; background: var(--brand-gradient); font-weight: 600; cursor: pointer; }
.start-button:hover { filter: brightness(1.09); }
.start-button.stop { color: var(--ink); background: #38201e; }
.start-button:disabled, .listen-button:disabled { cursor: wait; opacity: .65; }
.copy-button:disabled { cursor: not-allowed; opacity: .4; }
.button-icon { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 50%; background: rgba(7, 17, 13, .12); }
.button-icon svg { width: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.broadcast-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 22px;
  margin: 0 0 20px;
  padding: 18px 20px;
  border: 1px solid rgba(6, 189, 231, .22);
  border-radius: var(--radius);
  background: rgba(10, 28, 39, .78);
}
.broadcast-card > div:first-child { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.broadcast-kicker { color: var(--accent); font-size: 9px; font-weight: 600; letter-spacing: .14em; }
.broadcast-card strong { overflow: hidden; color: var(--ink); font-size: 13px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.copy-button { padding: 10px 14px; color: var(--ink); border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.03); cursor: pointer; font-size: 12px; }
.copy-button:hover { border-color: rgba(6, 189, 231, .5); }
.audience-state { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; white-space: nowrap; }

.live-grid { display: grid; grid-template-columns: .82fr 1.18fr; gap: 20px; min-height: 390px; }
.transcript-card { display: flex; flex-direction: column; min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); backdrop-filter: blur(16px); }
.translation-card { border-color: rgba(6, 189, 231, .25); background: linear-gradient(145deg, rgba(8, 40, 57, .92), rgba(7, 22, 32, .82)); }
.card-heading { display: flex; align-items: center; justify-content: space-between; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.card-heading > div { display: flex; align-items: center; gap: 10px; }
.language-code { min-width: 30px; padding: 5px 6px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; font-size: 9px; font-weight: 600; text-align: center; letter-spacing: .08em; }
.language-code.accent { color: white; border-color: var(--brand-cyan); background: var(--brand-gradient); }
.card-heading h2 { margin: 0; font-size: 14px; font-weight: 500; }
.live-badge { color: var(--dim); font-size: 9px; font-weight: 600; letter-spacing: .12em; }
.live-badge.active { color: var(--accent); }
.live-badge.active::before { content: ""; display: inline-block; width: 5px; height: 5px; margin-right: 7px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s infinite; }
.transcript { flex: 1; max-height: 520px; overflow-y: auto; padding: 25px 26px 34px; color: #a9b4ad; font-family: "Instrument Serif", Georgia, serif; font-size: clamp(23px, 2.25vw, 32px); line-height: 1.35; white-space: pre-wrap; scroll-behavior: smooth; }
.transcript.translated { color: var(--ink); font-size: clamp(28px, 2.8vw, 40px); line-height: 1.27; }
.placeholder { margin: 0; color: #46534c; font-style: italic; }

.session-bar { display: flex; align-items: center; gap: 38px; margin-top: 16px; padding: 0 4px; color: var(--muted); }
.session-bar > div { display: grid; grid-template-columns: auto auto; gap: 8px; align-items: baseline; }
.session-bar span { color: var(--dim); font-size: 9px; font-weight: 600; letter-spacing: .12em; }
.session-bar strong { color: var(--muted); font-size: 11px; font-weight: 500; }
.session-bar p { margin: 0 0 0 auto; font-size: 11px; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 5; max-width: min(420px, calc(100% - 48px)); padding: 15px 18px; color: #ffe6e3; border: 1px solid rgba(255,119,109,.3); border-radius: 12px; background: #321714; box-shadow: 0 18px 50px rgba(0,0,0,.35); font-size: 13px; line-height: 1.5; }

.listener-body { display: grid; place-items: start center; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
.listener-shell { width: min(620px, calc(100% - 32px)); }
.listener-header { min-height: 76px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.event-chip { padding: 7px 10px; color: var(--brand-green); border: 1px solid rgba(148,202,54,.28); border-radius: 99px; background: rgba(148,202,54,.07); font-size: 9px; font-weight: 600; letter-spacing: .12em; }
.listener-hero { padding: 66px 0 38px; }
.listener-hero h1 { margin: 0; font-family: "Instrument Serif", Georgia, serif; font-size: clamp(48px, 12vw, 76px); font-weight: 400; line-height: .95; letter-spacing: -.042em; }
.listener-hero > p:last-child { max-width: 480px; margin: 24px 0 0; color: var(--muted); line-height: 1.6; }
.player-card { display: grid; justify-items: center; gap: 28px; padding: 28px; border: 1px solid rgba(6,189,231,.23); border-radius: 24px; background: linear-gradient(150deg, rgba(8,41,58,.92), rgba(6,20,29,.92)); box-shadow: 0 30px 80px rgba(0,0,0,.2); }
.listener-status { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; }
.sound-wave { height: 62px; display: flex; align-items: center; gap: 6px; }
.sound-wave i { width: 5px; height: 12px; border-radius: 6px; background: #304753; transition: background .2s; }
.sound-wave i:nth-child(2), .sound-wave i:nth-child(6) { height: 26px; }
.sound-wave i:nth-child(3), .sound-wave i:nth-child(5) { height: 43px; }
.sound-wave i:nth-child(4) { height: 60px; }
.sound-wave.playing i { background: var(--brand-cyan); animation: wave .8s ease-in-out infinite alternate; }
.sound-wave.playing i:nth-child(1), .sound-wave.playing i:nth-child(2) { background: var(--brand-blue); }
.sound-wave.playing i:nth-child(6), .sound-wave.playing i:nth-child(7) { background: var(--brand-green); }
.sound-wave.playing i:nth-child(2), .sound-wave.playing i:nth-child(6) { animation-delay: -.2s; }
.sound-wave.playing i:nth-child(3), .sound-wave.playing i:nth-child(5) { animation-delay: -.4s; }
.sound-wave.playing i:nth-child(4) { animation-delay: -.6s; }
.listen-button { width: min(100%, 360px); min-height: 66px; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 0 20px; color: white; border: 0; border-radius: 16px; background: var(--brand-gradient); cursor: pointer; font-weight: 600; }
.listen-button:hover { filter: brightness(1.09); }
.listen-button.connected { color: var(--ink); border: 1px solid rgba(6,189,231,.28); background: rgba(6,189,231,.09); }
.headphones { width: 30px; height: 30px; display: grid; place-items: center; }
.headphones svg { width: 25px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.channel-field { width: min(100%, 360px); display: grid; gap: 8px; color: var(--muted); font-size: 11px; letter-spacing: .03em; }
.channel-field input { width: 100%; min-height: 54px; padding: 0 16px; color: var(--ink); border: 1px solid var(--line); border-radius: 14px; outline: 0; background: rgba(255,255,255,.04); font: inherit; font-size: 22px; font-weight: 600; letter-spacing: .1em; text-align: center; text-transform: uppercase; }
.channel-field input::placeholder { color: var(--dim); font-size: 16px; font-weight: 400; letter-spacing: .04em; }
.channel-field input:focus { border-color: rgba(6,189,231,.55); }
.channel-field input:disabled { color: var(--muted); }
.volume-control { width: min(100%, 360px); display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 16px; color: var(--muted); font-size: 11px; }
.volume-control input { width: 100%; accent-color: var(--accent); }
.caption-card { margin-top: 18px; padding: 20px 22px 24px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); }
.caption-card > span { color: var(--dim); font-size: 9px; font-weight: 600; letter-spacing: .13em; }
.caption-card p { min-height: 52px; margin: 12px 0 0; color: var(--ink); font-family: "Instrument Serif", Georgia, serif; font-size: 23px; line-height: 1.35; white-space: pre-wrap; }
.listener-note { margin: 18px 4px 30px; color: var(--dim); font-size: 11px; line-height: 1.5; text-align: center; }

@keyframes pulse { 50% { opacity: .4; } }
@keyframes wave { to { transform: scaleY(.38); opacity: .48; } }

@media (max-width: 1050px) {
  .controls { grid-template-columns: 1fr 1fr; }
  .start-button { min-height: 72px; }
  .broadcast-card { grid-template-columns: 1fr auto; }
  .audience-state { grid-column: 1 / -1; }
  .live-grid { grid-template-columns: 1fr; }
  .transcript-card { min-height: 280px; }
}

@media (max-width: 560px) {
  .shell { width: min(100% - 24px, 1180px); }
  .topbar { grid-template-columns: 1fr auto; }
  .connection { grid-column: 1 / -1; grid-row: 2; padding-bottom: 13px; }
  .hero { padding: 46px 2px 36px; }
  .hero h1 { font-size: 52px; }
  .controls, .access-controls { grid-template-columns: 1fr; }
  .start-button { min-height: 68px; }
  .broadcast-card { grid-template-columns: 1fr; gap: 14px; }
  .copy-button { justify-self: start; }
  .audience-state { grid-column: auto; }
  .session-bar { gap: 20px; flex-wrap: wrap; }
  .session-bar p { width: 100%; margin: 0; }
  .listener-shell { width: min(100% - 24px, 620px); }
  .listener-hero { padding: 50px 2px 32px; }
  .player-card { padding: 25px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
