:root {
  color-scheme: light;
  --bg: #ffffff;
  --text: #171717;
  --muted: #6b7280;
  --source: #7a8491;
  --line: #d7dde6;
  --accent: #006cff;
  --accent-dark: #0051c2;
  --surface: #ffffff;
  --target: #171717;
  --mono: "Courier New", Courier, monospace;
  --readable: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
}

main {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  height: 100vh;
}

.masthead {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--line);
  background: #fff;
  padding: 18px clamp(18px, 4vw, 48px) 14px;
}

h1 {
  margin: 0 auto 18px;
  max-width: 720px;
  text-align: center;
  font-family: var(--mono);
  font-size: clamp(24px, 3.5vw, 40px);
  line-height: 1;
  letter-spacing: 0;
  color: var(--accent);
}

form {
  display: grid;
  grid-template-columns: 1fr;
  justify-items: stretch;
  gap: 10px;
  max-width: 560px;
  margin: 0 auto;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
}

input,
select,
button {
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  color: var(--text);
  font-family: var(--mono);
  font-size: 15px;
}

input:focus-visible,
select:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 0;
}

select {
  appearance: none;
  min-width: 190px;
  padding: 0 46px 0 18px;
  background-image: url("data:image/svg+xml,%3Csvg width='14' height='14' viewBox='0 0 14 14' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 5L7 9L11 5' stroke='%23171717' stroke-width='1.8' stroke-linecap='square'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 18px center;
  background-size: 14px 14px;
}

input {
  width: 100%;
  min-width: 0;
  padding: 0 12px;
}

button {
  min-width: 88px;
  padding: 0 18px;
  cursor: pointer;
  font-weight: 700;
}

#play {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

#play:hover {
  background: var(--accent-dark);
}

button:disabled,
input:disabled {
  cursor: default;
  opacity: 0.5;
}

button:disabled:hover {
  background: var(--surface);
}

#play:disabled:hover {
  background: var(--accent);
}

.primary-controls {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto auto auto;
  align-items: center;
  gap: 10px;
}

#status {
  min-height: 20px;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.wallet-panel {
  position: absolute;
  top: 18px;
  right: clamp(18px, 4vw, 48px);
  display: grid;
  gap: 4px;
  justify-items: end;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.wallet-panel p {
  margin: 0;
}

.video-preview {
  display: block;
  border-bottom: 1px solid var(--line);
  background: #fff;
  padding: 10px clamp(18px, 4vw, 48px) 14px;
}

.video-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 20px;
  max-width: 980px;
  margin: 0 auto;
}

.video-title-line {
  display: flex;
  grid-column: 2;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: 9px;
}

.video-preview:not(.has-title) .video-title-line {
  visibility: hidden;
}

.live-mark {
  display: inline-block;
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  background: #9ca3af;
  box-shadow: 0 0 0 4px rgb(156 163 175 / 0.12);
}

.video-preview.offline .video-title-line p {
  color: var(--muted);
}

.video-preview.live .live-mark {
  background: #ff0033;
  box-shadow: 0 0 0 4px rgb(255 0 51 / 0.12);
}

.video-title-line p {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-family: var(--readable);
  font-size: clamp(16px, 2vw, 24px);
  font-weight: 760;
  line-height: 1.1;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.credit-stack {
  display: grid;
  grid-column: 3;
  justify-self: end;
  gap: 2px;
  justify-items: end;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.1;
  text-align: right;
}

.credit-stack[hidden] {
  display: none;
}

.credit-stack p {
  margin: 0;
}

.studio-player {
  width: min(420px, calc(100vw - 36px));
  aspect-ratio: 16 / 9;
  margin: 12px auto 0;
  border: 1px solid var(--line);
  background: #000;
}

.studio-player[hidden] {
  display: none;
}

.studio-player iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.transcripts {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: 0;
  gap: 1px;
  background: var(--line);
}

.column {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
  padding: clamp(20px, 4vw, 48px);
}

.column h2 {
  margin: 0 0 18px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0;
}

.column p {
  margin: 0;
  min-height: 0;
  overflow-y: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  scroll-behavior: smooth;
  font-family: var(--readable);
  font-size: clamp(22px, 3vw, 36px);
  line-height: 1.22;
  letter-spacing: 0;
}

.source-column p {
  color: var(--source);
}

.target-column p {
  color: var(--target);
}

[data-transcript] span {
  color: var(--segment-color, currentColor);
}

.english-mode .transcripts {
  grid-template-columns: minmax(0, 1fr);
}

.english-mode .target-column {
  display: none;
}

.session-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgb(23 23 23 / 0.28);
}

.session-modal[hidden] {
  display: none;
}

.stream-overlay {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgb(255 255 255 / 0.68);
}

.stream-overlay[hidden] {
  display: none;
}

.stream-overlay-panel {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 18px 22px;
  box-shadow: 0 12px 36px rgb(23 23 23 / 0.12);
}

.stream-overlay-panel p {
  margin: 0;
  color: var(--ink);
  font-family: "Courier New", monospace;
  font-weight: 700;
}

.session-dialog {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  padding: 22px;
  box-shadow: 0 18px 48px rgb(23 23 23 / 0.18);
}

.session-dialog h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.session-amount {
  margin: 12px 0 4px;
  color: var(--accent);
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
}

.session-copy,
.session-note,
#session-status {
  min-height: 20px;
  margin: 8px 0 14px;
  color: var(--muted);
  font-size: 14px;
}

.session-note {
  font-size: 12px;
  line-height: 1.35;
}

.session-actions {
  display: flex;
  justify-content: end;
  gap: 10px;
  margin-top: 14px;
}

#authorize-session {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

@media (max-width: 720px) {
  main {
    height: auto;
    min-height: 100vh;
  }

  form {
    max-width: none;
  }

  .wallet-panel {
    position: static;
    justify-items: center;
    margin-bottom: 14px;
  }

  label,
  input,
  select,
  button {
    width: 100%;
  }

  .primary-controls,
  .video-meta {
    grid-template-columns: 1fr;
  }

  .video-meta {
    gap: 8px;
  }

  .credit-stack {
    grid-column: auto;
    justify-items: start;
    text-align: left;
  }

  .video-title-line {
    grid-column: auto;
  }

  button {
    min-width: 0;
  }

  .transcripts {
    grid-template-columns: 1fr;
    min-height: 65vh;
  }

  .column {
    min-height: 50vh;
  }

  .session-actions {
    display: grid;
  }
}

.jambot-page {
  overflow: hidden;
}

.jambot-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
}

.jambot-header {
  position: relative;
  width: 100vw;
  margin-left: calc(50% - 50vw);
  border-bottom: 1px solid var(--line);
  background: #fff;
  padding: 18px clamp(18px, 4vw, 48px) 14px;
  text-align: center;
}

.jambot-header h1 {
  margin: 0;
  max-width: none;
}

.jambot-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.82fr) minmax(320px, 0.9fr) minmax(340px, 0.9fr);
  min-height: 0;
  gap: 1px;
  background: var(--line);
}

.host-view .jambot-grid {
  grid-template-columns: minmax(320px, 560px) minmax(340px, 560px);
  justify-content: center;
}

.host-view .transcript-pane,
.host-view .chat-form,
.host-view .username-modal {
  display: none;
}

.jambot-pane {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
  padding: clamp(20px, 4vw, 44px);
}

.transcript-pane {
  grid-template-rows: auto auto minmax(0, 1fr);
}

.jambot-pane h2 {
  margin: 0 0 18px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0;
}

.pane-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.answers-total,
.transcript-word-count,
.viewer-roster {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 750;
  text-align: right;
}

.viewer-roster {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.viewer-roster button {
  min-width: 0;
  height: auto;
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 0;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.viewer-list {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 5;
  display: none;
  width: max-content;
  max-width: min(280px, 70vw);
  border: 1px solid var(--line);
  background: #fff;
  padding: 8px 10px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
  box-shadow: 0 8px 18px rgb(23 23 23 / 0.08);
}

.viewer-roster:hover .viewer-list,
.viewer-roster:focus-within .viewer-list {
  display: block;
}

.jambot-transcript,
.jambot-answers {
  min-height: 0;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.jambot-transcript {
  color: var(--text);
  font-family: var(--readable);
  font-size: 16px;
  line-height: 1.32;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.jamchat-studio-player {
  width: 100%;
  max-width: 560px;
  margin: 0 0 18px;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  background: #f8fafc;
}

.jamchat-studio-player[hidden] {
  display: none;
}

.jamchat-studio-player iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.jambot-capture {
  background: #d9fbe5;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  padding: 0.05em 0.08em;
}

.jambot-answers {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.jambot-card:first-child {
  margin-top: auto;
}

.chat-pane {
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.host-view .chat-pane {
  grid-template-rows: auto minmax(0, 1fr);
}

.host-view .answer-support-button {
  display: none;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 20px;
  scroll-behavior: smooth;
}

.host-view .chat-messages {
  padding-bottom: 36px;
}

.chat-message {
  position: relative;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: #fff;
  padding: 10px 12px;
  will-change: transform, opacity;
}

.chat-message:first-child {
  margin-top: auto;
}

.chat-message.mentioned {
  border-color: #171717;
  font-weight: 700;
}

.mention-dk {
  background: #dff0ff;
}

.mention-max {
  background: #ffe1ee;
}

.mention-steve {
  background: #fff5bf;
}

.mention-hosts {
  background: #daf8d8;
}

.chat-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 6px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 750;
}

.chat-meta time {
  font-weight: 600;
}

.chat-text {
  margin: 0;
  color: var(--text);
  font-family: var(--readable);
  font-size: 16px;
  line-height: 1.32;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.chat-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.chat-reactions[hidden] {
  display: none;
}

.chat-reaction-count {
  border: 1px solid var(--line);
  background: #fff;
  padding: 2px 6px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
}

.chat-reaction-picker {
  position: absolute;
  right: 8px;
  bottom: calc(100% - 8px);
  z-index: 4;
  display: none;
  gap: 4px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 4px;
  box-shadow: 0 8px 18px rgb(23 23 23 / 0.08);
}

.chat-message:hover .chat-reaction-picker,
.chat-message:focus-within .chat-reaction-picker {
  display: flex;
}

.chat-reaction-picker button {
  min-width: 28px;
  height: 28px;
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--text);
  font-size: 16px;
}

.chat-reaction-picker button:hover,
.chat-reaction-picker button:focus-visible {
  background: #eef4ff;
}

.chat-form {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  width: 100%;
  justify-self: stretch;
  max-width: none;
  margin: 12px 0 0;
}

.chat-form textarea {
  width: 100%;
  min-height: 36px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 10px;
  color: var(--text);
  font-family: var(--readable);
  font-size: 15px;
}

.chat-form textarea:disabled {
  background: #f8fafc;
  color: var(--muted);
}

.chat-form button {
  min-width: 72px;
  height: auto;
  border-radius: 0;
}

.mention-suggest {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 8px;
}

.mention-suggest[hidden] {
  display: none;
}

.mention-suggest button {
  min-width: 0;
  height: 30px;
  padding: 0 10px;
  border-color: var(--line);
  color: var(--text);
  font-size: 12px;
}

.chat-help {
  grid-column: 1 / -1;
  margin: -2px 0 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.35;
}

.username-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgb(255 255 255 / 0.82);
}

.username-modal[hidden] {
  display: none;
}

.username-dialog {
  display: grid;
  gap: 12px;
  width: min(360px, 100%);
  border: 1px solid var(--line);
  background: #fff;
  padding: 20px;
}

.username-dialog h2 {
  margin: 0;
  color: var(--text);
  font-family: var(--mono);
  font-size: 18px;
}

.username-dialog input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 10px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 16px;
}

.jambot-card {
  position: relative;
  align-self: start;
  min-height: max-content;
  overflow: visible;
  border: 1px solid var(--line);
  background: #fff;
  padding: 16px;
}

.jambot-card.pending {
  border-color: var(--accent);
}

.jambot-card.answer-flash {
  animation: answer-card-flash 1350ms ease-out;
}

@keyframes answer-card-flash {
  0% {
    background: #d9fbe5;
  }

  100% {
    background: #fff;
  }
}

.jambot-card-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.jambot-request {
  margin: 0 0 16px;
  color: #087a3d;
  font-family: var(--readable);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.32;
}

.jambot-answer {
  margin: 0;
  color: var(--text);
  font-family: var(--readable);
  font-size: 16px;
  line-height: 1.32;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.jambot-answer a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.jambot-citations {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.jambot-citations a {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.answer-support {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.answer-support-total {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 750;
}

.answer-support-button {
  min-width: 92px;
  height: 36px;
  border-radius: 0;
}

.answer-confetti {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}

.answer-confetti-piece {
  position: absolute;
  right: 84px;
  bottom: 42px;
  width: 7px;
  height: 12px;
  background: var(--c);
  animation: answer-confetti-pop 1100ms cubic-bezier(.16, .84, .28, 1) forwards;
  animation-delay: var(--d);
}

@keyframes answer-confetti-pop {
  0% {
    opacity: 0;
    transform: translate(0, 0) rotate(0deg) scale(0.85);
  }

  12% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translate(var(--x), var(--y)) rotate(var(--r)) scale(1);
  }
}

.contribution-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgb(255 255 255 / 0.82);
}

.contribution-modal[hidden] {
  display: none;
}

.contribution-dialog {
  position: relative;
  display: grid;
  gap: 12px;
  width: min(520px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  border: 1px solid var(--line);
  background: #fff;
  padding: 22px;
}

.contribution-dismiss {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  min-width: 0;
  width: 34px;
  height: 34px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 25px;
  line-height: 1;
}

.contribution-dismiss:hover,
.contribution-dismiss:focus-visible {
  color: var(--text);
}

.contribution-dialog h2 {
  margin: 0;
  padding-right: 34px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 20px;
}

.contribution-status {
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
}

.contribution-qr {
  justify-self: center;
  width: min(300px, 100%);
  height: auto;
  image-rendering: pixelated;
}

.contribution-dialog textarea {
  width: 100%;
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 10px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  resize: vertical;
}

.contribution-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.button-like {
  display: inline-grid;
  place-items: center;
  min-width: 118px;
  height: 44px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 750;
  text-decoration: none;
}

.button-like[aria-disabled] {
  pointer-events: none;
  opacity: 0.55;
}

@media (max-width: 900px) {
  .jambot-page {
    overflow: auto;
  }

  .jambot-shell {
    height: auto;
    min-height: 100vh;
  }

  .jambot-grid {
    grid-template-columns: 1fr;
  }

  .host-view .jambot-grid {
    grid-template-columns: 1fr;
  }

  .jambot-pane {
    min-height: 55vh;
  }

}
