:root {
  color-scheme: dark;
  --bg: #0f1414;
  --panel: #151b1b;
  --panel-strong: #1b2323;
  --ink: #f6f2e8;
  --muted: #aab3ae;
  --line: rgba(246, 242, 232, 0.12);
  --teal: #39d6bd;
  --amber: #f4bd50;
  --coral: #ff7a6f;
  --green: #a8f06d;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Inter", "Noto Sans JP", system-ui, sans-serif;
  background:
    linear-gradient(120deg, rgba(57, 214, 189, 0.1), transparent 28rem),
    linear-gradient(240deg, rgba(244, 189, 80, 0.08), transparent 24rem),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 32px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.brand,
.connection-pill,
.stage-header,
.card-heading {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
}

.brand-logo {
  width: 174px;
  height: 48px;
  object-fit: contain;
  object-position: left center;
  border-radius: 8px;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.82rem;
}

.connection-pill {
  gap: 9px;
  min-width: 118px;
  justify-content: center;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.84rem;
  font-weight: 800;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #77817c;
}

.connection-pill[data-status="connecting"] .status-dot {
  background: var(--amber);
  box-shadow: 0 0 0 5px rgba(244, 189, 80, 0.15);
}

.connection-pill[data-status="connected"] .status-dot {
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(168, 240, 109, 0.15);
}

.connection-pill[data-status="error"] .status-dot {
  background: var(--coral);
  box-shadow: 0 0 0 5px rgba(255, 122, 111, 0.15);
}

.workspace {
  display: grid;
  grid-template-columns: 320px minmax(420px, 1fr) minmax(380px, 0.78fr);
  gap: 14px;
  align-items: stretch;
}

.control-panel,
.stage,
.transcript-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(21, 27, 27, 0.92);
  box-shadow: var(--shadow);
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
}

.panel-title p,
.stage-header p,
.card-heading p {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.panel-title .panel-lead {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.96rem;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.7;
  text-transform: none;
}

.benefit-list {
  display: grid;
  gap: 9px;
}

.benefit-list div {
  padding: 11px 12px;
  border: 1px solid rgba(57, 214, 189, 0.2);
  border-radius: 8px;
  background: rgba(57, 214, 189, 0.06);
}

.benefit-list strong,
.benefit-list span {
  display: block;
}

.benefit-list strong {
  color: var(--ink);
  font-size: 0.94rem;
}

.benefit-list span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: clamp(1.8rem, 4vw, 2.65rem);
  line-height: 1.05;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.1rem, 2vw, 1.45rem);
  line-height: 1.18;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--panel-strong);
}

.room-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(57, 214, 189, 0.22);
  border-radius: 8px;
  background: rgba(57, 214, 189, 0.07);
}

.room-card span,
.room-card strong {
  display: block;
}

.room-card span {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
}

.room-card strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 0.92rem;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.button-stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 4px;
}

.security-note {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.55;
}

.primary-button,
.secondary-button,
.icon-button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 900;
}

.primary-button,
.secondary-button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}

.primary-button {
  color: #071110;
  background: var(--teal);
}

.secondary-button {
  color: var(--ink);
  background: #283030;
}

.compact-button {
  min-height: 38px;
  padding: 0 12px;
  white-space: nowrap;
  font-size: 0.82rem;
}

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

.stage {
  min-height: 650px;
  padding: 18px;
}

.stage-header,
.card-heading {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

output {
  min-width: 56px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--green);
  text-align: center;
  font-weight: 900;
}

#waveCanvas {
  width: 100%;
  height: min(42vh, 360px);
  min-height: 280px;
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101616;
}

.timeline {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.event-row {
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 10px;
  align-items: start;
  padding: 11px 12px;
  border: 1px solid rgba(246, 242, 232, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.event-row span {
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--amber);
}

.event-row p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.transcript-grid {
  display: grid;
  gap: 14px;
  min-height: 650px;
}

.transcript-card {
  min-height: 0;
  padding: 16px;
}

.transcript-card.translated {
  background:
    linear-gradient(180deg, rgba(57, 214, 189, 0.08), transparent 52%),
    rgba(21, 27, 27, 0.92);
}

.icon-button {
  width: 34px;
  height: 34px;
  color: var(--muted);
  background: #242c2c;
}

.transcript-list {
  height: 210px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
}

.transcript-line,
.empty-state {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.045);
  line-height: 1.65;
}

.transcript-line:not(.is-final) {
  color: var(--muted);
}

.translated .transcript-line {
  border-color: rgba(57, 214, 189, 0.25);
  font-size: 1.05rem;
}

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

.invite-card {
  background:
    linear-gradient(180deg, rgba(244, 189, 80, 0.08), transparent 54%),
    rgba(21, 27, 27, 0.92);
}

.qr-layout {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
}

.qr-layout img {
  width: 120px;
  height: 120px;
  border: 8px solid #f6f2e8;
  border-radius: 8px;
  background: #f6f2e8;
}

.qr-layout strong,
.qr-layout span {
  display: block;
}

.qr-layout strong {
  margin-bottom: 6px;
  font-size: 1.1rem;
}

.qr-layout span,
.note {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.62;
}

.language-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.language-link {
  border: 1px solid rgba(57, 214, 189, 0.28);
  border-radius: 999px;
  padding: 8px 10px;
  color: var(--ink);
  text-decoration: none;
  background: rgba(57, 214, 189, 0.08);
  font-size: 0.8rem;
  font-weight: 900;
}

.participant-mode .workspace {
  grid-template-columns: minmax(360px, 0.58fr) minmax(420px, 1fr);
}

.participant-mode .transcript-grid {
  grid-template-columns: 1fr;
}

.participant-mode .invite-card,
.participant-mode .event-field,
.participant-mode .room-card,
.participant-mode .source-card,
.participant-mode .button-stack {
  display: none;
}

.participant-mode .stage {
  min-height: 560px;
}

.participant-mode .panel-title h1 {
  font-size: clamp(1.65rem, 3.5vw, 2.35rem);
}

.participant-mode .panel-title h1::before {
  content: "QRを開いたら、言語を確認して開始。";
}

.participant-mode .panel-title h1 {
  color: transparent;
  position: relative;
}

.participant-mode .panel-title h1::before {
  color: var(--ink);
  position: absolute;
  inset: 0;
}

.participant-mode .translated-card {
  min-height: 560px;
}

.participant-mode .translated-card .transcript-list {
  height: 480px;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 280px 1fr;
  }

  .transcript-grid {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    min-height: auto;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 560px);
    padding-top: 12px;
  }

  .topbar,
  .workspace,
  .transcript-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .connection-pill {
    width: 100%;
  }

  .stage,
  .transcript-grid {
    min-height: 0;
  }

  #waveCanvas {
    min-height: 220px;
  }

  .qr-layout {
    grid-template-columns: 96px 1fr;
  }

  .qr-layout img {
    width: 96px;
    height: 96px;
  }

  .participant-mode .app-shell {
    width: min(100% - 16px, 560px);
    padding-top: 8px;
  }

  .participant-mode .topbar {
    gap: 10px;
    margin-bottom: 10px;
  }

  .participant-mode .brand-logo {
    width: 136px;
    height: 40px;
  }

  .participant-mode .brand span {
    display: none;
  }

  .participant-mode .connection-pill {
    padding: 7px 10px;
  }

  .participant-mode .workspace {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .participant-mode .control-panel {
    order: 0;
    gap: 10px;
    padding: 12px;
  }

  .participant-mode .panel-title {
    display: none;
  }

  .participant-mode .field span {
    font-size: 0.76rem;
  }

  .participant-mode select {
    min-height: 40px;
  }

  .participant-mode .transcript-grid {
    order: 1;
  }

  .participant-mode .translated-card {
    min-height: calc(100vh - 174px);
    padding: 14px;
  }

  .participant-mode .translated-card .transcript-list {
    height: calc(100vh - 250px);
    min-height: 430px;
  }

  .participant-mode .translated .transcript-line,
  .participant-mode .translated .empty-state {
    font-size: clamp(1.05rem, 5vw, 1.55rem);
    line-height: 1.55;
  }

  .participant-mode .stage {
    order: 2;
    min-height: 0;
    padding: 12px;
  }

  .participant-mode #waveCanvas {
    display: none;
  }

  .participant-mode .stage-header {
    margin-bottom: 0;
  }

  .participant-mode .stage-header p,
  .participant-mode output {
    display: none;
  }

  .participant-mode .stage h2 {
    font-size: 0.95rem;
    color: var(--muted);
  }

  .participant-mode .timeline {
    margin-top: 10px;
  }
}
