:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --panel: #ffffff;
  --text: #1f2523;
  --muted: #65706b;
  --line: #d8ddd5;
  --accent: #1f8a70;
  --accent-strong: #10624f;
  --warn: #b85c38;
  --ink: #0d1110;
  --screen: #070807;
  --screen-text: #f5f7f2;
  --soft: #edf3ef;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  min-height: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  padding: 10px 14px;
  text-decoration: none;
  cursor: pointer;
  transition:
    background 120ms ease,
    border-color 120ms ease,
    transform 120ms ease;
}

button:hover,
.button:hover {
  background: var(--accent-strong);
}

button:active,
.button:active {
  transform: translateY(1px);
}

button.secondary,
.button.secondary {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

button.secondary:hover,
.button.secondary:hover {
  background: var(--soft);
}

button.danger {
  background: var(--warn);
}

button.danger:hover {
  background: #8f4328;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
}

textarea {
  min-height: 108px;
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.92rem;
}

.shell {
  min-height: 100vh;
}

.topbar {
  border-bottom: 1px solid var(--line);
  background: rgba(247, 245, 239, 0.9);
  backdrop-filter: blur(18px);
}

.topbar-inner,
.page,
.home-grid,
.timeline-wrap {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
}

.topbar-inner {
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.brand-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.brand-title {
  font-size: 1rem;
  font-weight: 800;
}

.brand-subtitle {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.nav a {
  border-radius: var(--radius);
  color: var(--text);
  padding: 9px 11px;
  text-decoration: none;
}

.nav a.active,
.nav a:hover {
  background: var(--soft);
}

.page {
  padding: 28px 0 48px;
}

.intro {
  display: grid;
  gap: 8px;
  margin-bottom: 22px;
}

.intro h1,
.panel h2 {
  margin: 0;
  line-height: 1.08;
}

.intro h1 {
  font-size: clamp(2rem, 5vw, 4.2rem);
  max-width: 820px;
}

.intro.compact h1 {
  font-size: clamp(2rem, 4vw, 3rem);
}

.intro p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: 1.06rem;
  line-height: 1.55;
}

.home-grid,
.control-grid {
  display: grid;
  gap: 16px;
}

.home-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.control-grid {
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 18px;
}

.panel h2 {
  font-size: 1.2rem;
}

.panel p {
  color: var(--muted);
  line-height: 1.5;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.status-row,
.metric-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  padding: 6px 10px;
  font-size: 0.86rem;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9aa39d;
}

.dot.good {
  background: #1f8a70;
}

.dot.warn {
  background: var(--warn);
}

.qr {
  display: grid;
  gap: 12px;
  justify-items: start;
}

.qr img {
  width: 220px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 8px;
}

.url-box {
  width: 100%;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.form-stack,
.speaker-live,
.language-picker {
  display: grid;
  gap: 14px;
}

.speaker-console {
  gap: 16px;
}

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

.status-card {
  display: grid;
  gap: 4px;
  min-height: 96px;
  border: 1px solid var(--line);
  border-left: 5px solid #9aa39d;
  border-radius: var(--radius);
  background: #fff;
  padding: 12px;
}

.status-card.good {
  border-left-color: var(--accent);
}

.status-card.warn {
  border-left-color: var(--warn);
}

.status-card span,
.status-card small {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
}

.status-card span {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.status-card strong {
  overflow-wrap: anywhere;
  font-size: 1.15rem;
}

.status-card small {
  font-size: 0.82rem;
  line-height: 1.35;
}

.inline-form,
.launch-row {
  display: grid;
  align-items: end;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.publish-state {
  margin: 10px 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--muted);
  padding: 10px 12px;
  font-size: 0.92rem;
}

.publish-state.ok {
  border-color: rgba(31, 138, 112, 0.4);
  color: var(--accent-strong);
}

.publish-state.error {
  border-color: rgba(184, 92, 56, 0.45);
  color: var(--warn);
}

.transcript-box {
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 16px;
  color: var(--text);
  font-size: 1.28rem;
  line-height: 1.45;
}

.transcript-box.empty {
  color: var(--muted);
}

.simple-operator {
  display: grid;
  min-height: 100vh;
  place-items: center;
  background: var(--bg);
  padding: 24px;
}

.simple-card {
  display: grid;
  width: min(560px, 100%);
  gap: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: clamp(22px, 6vw, 36px);
}

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

.password-form,
.simple-actions {
  display: grid;
  gap: 12px;
}

.password-form label {
  color: var(--text);
  font-size: clamp(1.6rem, 7vw, 2.7rem);
  font-weight: 800;
  line-height: 1.08;
}

.password-form input {
  margin-top: 10px;
  font-size: 1.1rem;
}

.simple-actions button {
  min-height: 62px;
  width: 100%;
  font-size: 1.08rem;
  font-weight: 800;
}

.simple-transcript {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  font-size: 1.18rem;
  line-height: 1.45;
}

.simple-transcript[hidden],
.simple-state[hidden],
.audience-caption[hidden] {
  display: none;
}

.simple-state {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--muted);
  padding: 10px 12px;
  font-size: 0.92rem;
}

.form-error {
  min-height: 1.35em;
  color: var(--warn);
  font-size: 0.95rem;
}

.timeline {
  display: grid;
  gap: 10px;
}

.segment {
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px 14px;
}

.segment.pending {
  border-left-color: #9aa39d;
}

.segment.error {
  border-left-color: var(--warn);
}

.segment-text {
  margin: 0;
  font-size: 1rem;
  line-height: 1.45;
}

.segment-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.8rem;
}

.screen-view {
  min-height: 100vh;
  background: var(--screen);
  color: var(--screen-text);
  display: grid;
}

.screen-stage {
  display: grid;
  align-content: end;
  gap: clamp(24px, 4vh, 52px);
  min-height: 100vh;
  width: min(1320px, calc(100vw - 56px));
  margin: 0 auto;
  padding: 7vh 0 10vh;
}

.screen-caption {
  margin: 0;
  color: #fff;
  font-size: clamp(2.4rem, 6.2vw, 5.9rem);
  font-weight: 800;
  line-height: 1.08;
  text-wrap: pretty;
}

.screen-caption span {
  display: inline-block;
  opacity: 0.8;
  transform: translateY(0);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.screen-caption .active-word {
  opacity: 1;
  transform: translateY(-0.06em);
}

.screen-caption.muted {
  color: rgba(245, 247, 242, 0.45);
}

.screen-previous {
  display: grid;
  gap: clamp(16px, 2.5vh, 30px);
  color: rgba(245, 247, 242, 0.4);
  font-size: clamp(1.2rem, 2.8vw, 2.7rem);
  font-weight: 700;
  line-height: 1.18;
}

.screen-line {
  padding-bottom: clamp(10px, 1.6vh, 20px);
  border-bottom: 1px solid rgba(245, 247, 242, 0.12);
}

.qr-display {
  display: grid;
  min-height: 100vh;
  place-items: center;
  background: #fff;
  color: var(--ink);
  padding: 32px;
  text-align: center;
}

.qr-display-inner {
  display: grid;
  justify-items: center;
  gap: 18px;
}

.qr-display-code {
  width: min(62vh, 520px);
  max-width: calc(100vw - 64px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.qr-display h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4rem);
}

.qr-display p {
  max-width: min(760px, calc(100vw - 48px));
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.35rem);
}

.qr-display .qr-display-lead {
  color: var(--ink);
  font-size: clamp(1.2rem, 2.4vw, 1.8rem);
  font-weight: 750;
}

.screen-select {
  color: #fff;
}

.screen-select option {
  color: #111;
}

.audience {
  display: grid;
  min-height: 100vh;
  background: #fbfaf6;
  grid-template-rows: auto 1fr;
}

.audience-header {
  border-bottom: 1px solid var(--line);
  background: #fff;
  padding: 16px;
}

.audience-header-inner,
.audience-main {
  width: min(840px, calc(100vw - 28px));
  margin: 0 auto;
}

.audience-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.audience-main {
  display: grid;
  align-content: start;
  gap: 18px;
  padding: 24px 0 44px;
}

.audience-caption {
  min-height: 32vh;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: clamp(18px, 5vw, 34px);
  font-size: clamp(1.6rem, 6vw, 3.3rem);
  font-weight: 750;
  line-height: 1.16;
}

.audience-caption.empty {
  color: var(--muted);
  font-weight: 600;
}

.notice {
  border: 1px solid #e7cfab;
  border-radius: var(--radius);
  background: #fff8ea;
  color: #6a4b16;
  padding: 12px 14px;
  line-height: 1.45;
}

.hidden {
  display: none !important;
}

@media (max-width: 860px) {
  .home-grid,
  .control-grid {
    grid-template-columns: 1fr;
  }

  .console-status {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar-inner,
  .audience-header-inner {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav {
    justify-content: flex-start;
  }

  .inline-form,
  .launch-row {
    grid-template-columns: 1fr;
  }

  .screen-stage {
    width: min(100vw - 28px, 1320px);
    padding-bottom: 8vh;
  }
}

@media (max-width: 560px) {
  .console-status {
    grid-template-columns: 1fr;
  }
}
