:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --border: #d7dde3;
  --text: #1d252c;
  --muted: #64717d;
  --accent: #126b5c;
  --accent-dark: #0d5146;
  --error: #a42626;
  --ready: #126b5c;
  --shadow: 0 10px 28px rgba(23, 35, 44, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
  line-height: 1.2;
}

h2 {
  font-size: 14px;
}

#serviceStatus {
  max-width: 520px;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

#serviceStatus[data-state="error"] {
  color: var(--error);
}

#serviceStatus[data-state="ready"] {
  color: var(--ready);
}

.controls {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

label,
.file-control span {
  color: var(--muted);
  font-size: 13px;
}

input[type="text"],
input:not([type]),
button {
  min-height: 38px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.combo {
  position: relative;
  display: flex;
  width: 170px;
  margin-top: 5px;
}

#languageInput,
#targetLanguageInput {
  display: block;
  width: 100%;
  padding: 0 36px 0 9px;
  color: var(--text);
  background: #fff;
}

.combo-toggle {
  position: absolute;
  top: 0;
  right: 0;
  width: 34px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  background: transparent;
  border-color: transparent;
  border-left-color: var(--border);
  border-radius: 0 6px 6px 0;
}

.combo-toggle::before {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--muted);
}

.combo-toggle:hover:not(:disabled) {
  background: #eef3f5;
}

.combo-menu {
  display: none;
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.combo[data-open="true"] .combo-menu {
  display: block;
}

.combo-option {
  display: block;
  width: 100%;
  min-height: 32px;
  padding: 7px 9px;
  color: var(--text);
  text-align: left;
  background: var(--surface);
  border: 0;
  border-radius: 0;
}

.combo-option:hover,
.combo-option:focus {
  color: var(--text);
  background: #eef3f5;
  outline: none;
}

.file-control input {
  display: block;
  width: 210px;
  margin-top: 5px;
}

button {
  padding: 0 13px;
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  cursor: pointer;
}

button:hover:not(:disabled) {
  background: var(--accent-dark);
}

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

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.38fr);
  gap: 16px;
  padding: 16px;
  min-height: 0;
}

.pane {
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.transcript-pane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
}

#connectionState {
  color: var(--muted);
  font-size: 13px;
}

#connectionState[data-state="ready"] {
  color: var(--ready);
}

.output {
  flex: 1;
  overflow: auto;
  padding: 12px 14px;
}

.line {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid #edf0f2;
}

.time {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.line p,
.compact-pane p {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.55;
  font-size: 16px;
}

.side {
  display: grid;
  grid-template-rows: minmax(160px, 0.8fr) minmax(160px, 0.8fr) minmax(120px, 0.55fr);
  gap: 16px;
  min-height: 0;
}

.compact-pane {
  overflow: auto;
  padding: 13px 14px;
}

.compact-pane h2 {
  margin-bottom: 10px;
}

.compact-pane p {
  color: var(--muted);
}

@media (max-width: 900px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .controls {
    justify-content: stretch;
  }

  .controls > *,
  .combo,
  .file-control input,
  #languageInput,
  #targetLanguageInput,
  button {
    width: 100%;
  }

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

  .side {
    grid-template-rows: repeat(3, minmax(130px, auto));
  }
}

@media (max-width: 560px) {
  .line {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}
