:root {
  color-scheme: light;
  --bg: #f4f7f8;
  --panel: #ffffff;
  --text: #142022;
  --muted: #617073;
  --line: #dbe4e5;
  --brand: #126d73;
  --brand-dark: #0b4f55;
  --accent: #ef8a3a;
  --soft: #e8f3f2;
  --shadow: 0 22px 60px rgba(16, 37, 42, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.workspace,
.history {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.workspace {
  min-width: 0;
  padding: 22px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 5vw, 44px);
  line-height: 1.05;
}

h2 {
  font-size: 18px;
}

.status {
  min-width: 92px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--brand-dark);
  font-size: 13px;
  text-align: center;
}

.controls {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) 46px minmax(130px, 1fr) minmax(120px, 0.8fr) minmax(130px, 0.8fr) minmax(130px, 0.8fr);
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.access-panel,
.diagnostics-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfd;
}

.access-panel[hidden] {
  display: none;
}

.access-panel div,
.diagnostics-panel div:first-child {
  display: grid;
  gap: 4px;
}

.access-panel strong,
.diagnostics-panel strong {
  font-size: 15px;
}

.access-panel span,
.diagnostics-panel span,
.access-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.access-panel form,
.diagnostic-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.access-panel input {
  min-height: 42px;
  width: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
}

label span,
.panel-head,
.history-head {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

label {
  display: grid;
  gap: 7px;
}

select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfd;
  color: var(--text);
}

select {
  height: 46px;
  padding: 0 12px;
}

.icon-button {
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--brand);
  font-size: 24px;
  cursor: pointer;
}

.translator-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.audio-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfd;
}

.realtime-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid rgba(18, 109, 115, 0.28);
  border-radius: 8px;
  background: #eef8f7;
}

.realtime-controls {
  display: grid;
  grid-template-columns: 112px 112px auto minmax(160px, 1fr);
  align-items: end;
  gap: 10px;
}

.realtime-controls label {
  width: 100%;
}

.realtime-state {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
  min-height: 42px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: right;
  word-break: keep-all;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #9aa8aa;
}

.dot.active {
  background: #e5533d;
}

.dot.working {
  box-shadow: 0 0 0 6px rgba(229, 83, 61, 0.14);
}

.live-feed {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.voice-meter {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: -4px 0 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.voice-meter[hidden] {
  display: none;
}

.meter-track {
  flex: 1;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #dce8e9;
}

.meter-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 120ms linear;
}

.subtitle-stage {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101719;
  color: #f7fbfb;
}

.subtitle-label {
  color: #9fd7d2;
  font-size: 13px;
  font-weight: 700;
}

.subtitle-source {
  color: #c8d7d9;
  font-size: 18px;
  line-height: 1.45;
}

.subtitle-target {
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1.15;
  font-weight: 800;
}

.subtitle-meta {
  color: #9fb0b3;
  font-size: 13px;
  line-height: 1.45;
}

.usage-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfd;
}

.usage-panel div {
  display: grid;
  gap: 4px;
}

.usage-panel strong {
  font-size: 14px;
}

.usage-panel span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.live-feed:empty {
  display: none;
}

.live-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #fbfdfd;
}

.live-item.error {
  border-color: rgba(229, 83, 61, 0.35);
  background: #fff7f5;
}

.live-item.muted {
  background: #f2f6f6;
}

.live-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.live-item-head strong {
  font-size: 14px;
}

.live-item-head span {
  color: var(--muted);
  font-size: 12px;
}

.live-item p {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
}

.live-item p + p {
  margin-top: 6px;
  color: var(--brand-dark);
  font-weight: 700;
}

.audio-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.audio-copy strong {
  font-size: 15px;
}

.audio-copy span,
.audio-result p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.audio-copy span {
  overflow-wrap: anywhere;
}

.file-picker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  max-width: 220px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--brand);
  cursor: pointer;
}

.file-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-picker span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audio-result,
.image-result {
  display: grid;
  grid-template-columns: minmax(220px, 360px) minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.audio-result[hidden],
.image-result[hidden] {
  display: none;
}

.audio-result audio,
.audio-result video {
  width: 100%;
}

.audio-result video {
  max-height: 240px;
  border-radius: 8px;
  background: #0c1517;
}

.audio-result p {
  margin: 4px 0 0;
}

.image-result img {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  border-radius: 8px;
  background: #eef4f5;
}

.image-result p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfd;
  overflow: hidden;
}

.panel-head,
.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

textarea,
.result {
  min-height: 300px;
  resize: vertical;
  border: 0;
  border-radius: 0;
  padding: 18px;
  font-size: 18px;
  line-height: 1.55;
  outline: none;
}

.result {
  white-space: pre-wrap;
}

.notes {
  min-height: 22px;
  margin: 0;
  padding: 0 18px 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--brand-dark);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.ghost {
  min-height: auto;
  padding: 0;
  background: transparent;
  color: var(--brand);
}

.ghost:hover {
  background: transparent;
  color: var(--accent);
}

.provider {
  color: var(--accent);
}

.history {
  max-height: calc(100vh - 48px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.history-list {
  overflow: auto;
  padding: 10px;
}

.history-item {
  width: 100%;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdfd;
  cursor: pointer;
}

.history-item p {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

.history-item p + p {
  margin-top: 8px;
  color: var(--muted);
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .history {
    max-height: none;
  }
}

@media (max-width: 680px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding: 10px 0;
  }

  .workspace {
    padding: 14px;
  }

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

  .controls,
  .translator-grid,
  .audio-panel,
  .realtime-panel,
  .access-panel,
  .diagnostics-panel,
  .audio-result,
  .image-result {
    grid-template-columns: 1fr;
  }

  .access-panel form,
  .diagnostic-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .access-panel input {
    width: 100%;
  }

  .realtime-controls {
    grid-template-columns: 1fr;
  }

  .realtime-controls label {
    width: 100%;
  }

  .realtime-state {
    justify-content: flex-start;
    text-align: left;
  }

  .icon-button {
    width: 100%;
  }

  textarea,
  .result {
    min-height: 220px;
    font-size: 16px;
  }
}
