: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);
}

.donation-panel {
  position: absolute;
  top: 18px;
  left: clamp(18px, 4vw, 48px);
  max-width: min(360px, 34vw);
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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;
  }

  .donation-panel {
    position: static;
    max-width: none;
    margin-bottom: 10px;
    text-align: center;
    white-space: normal;
  }

  .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;
  }
}
