:root {
  color-scheme: light;
  --bg: #eef1f5;
  --surface: #ffffff;
  --surface-soft: #f7f8fa;
  --text: #18202d;
  --muted: #697386;
  --line: #d8dee8;
  --accent: #176b5b;
  --accent-strong: #0f4f43;
  --danger: #a43d3d;
  --shadow: 0 14px 40px rgba(28, 39, 57, 0.12);
}

* {
  box-sizing: border-box;
}

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

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

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

.workspace {
  display: grid;
  gap: 16px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 2px 4px;
}

h1,
h2,
p {
  margin: 0;
}

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

h2 {
  font-size: 16px;
}

p {
  margin-top: 8px;
  color: var(--muted);
}

.status {
  min-width: 88px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  background: var(--surface);
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.status.ok {
  border-color: rgba(23, 107, 91, 0.25);
  color: var(--accent);
}

.status.error {
  border-color: rgba(164, 61, 61, 0.25);
  color: var(--danger);
}

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

.compact {
  box-shadow: none;
}

.sidebar {
  display: grid;
  align-content: start;
  gap: 16px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-title span {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.result-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.result-tools select {
  width: 110px;
}

.form-grid,
.options-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}

.options-row {
  grid-template-columns: repeat(3, minmax(0, 1fr)) 140px;
  align-items: end;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
  outline: none;
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 260px;
  resize: vertical;
  padding: 14px;
  line-height: 1.6;
}

.dialogue-view {
  display: grid;
  gap: 10px;
  max-height: 420px;
  overflow: auto;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  padding: 12px;
}

.dialogue-view:empty {
  display: none;
}

.dialogue-view p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.dialogue-line {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 0 0 10px;
}

.dialogue-line:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.dialogue-speaker {
  color: var(--accent);
  font-weight: 700;
}

.dialogue-time {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.dialogue-text {
  line-height: 1.6;
}

.progress-wrap {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.progress-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.progress-line strong {
  color: var(--text);
}

.progress-track {
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: #dce3ec;
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.25s ease;
}

.result-debug {
  color: var(--muted);
  font-size: 12px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(23, 107, 91, 0.58);
  box-shadow: 0 0 0 3px rgba(23, 107, 91, 0.12);
}

.dropzone {
  display: grid;
  place-items: center;
  min-height: 156px;
  margin-bottom: 14px;
  border: 1px dashed #aab4c2;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  cursor: pointer;
}

.dropzone input {
  display: none;
}

.dropzone.dragging {
  border-color: var(--accent);
  background: #edf6f3;
}

.switch-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  color: var(--text);
}

.switch-line input {
  width: 18px;
  min-height: 18px;
}

.primary-button,
.ghost-button {
  border: 1px solid transparent;
  border-radius: 6px;
  min-height: 40px;
  padding: 0 14px;
  cursor: pointer;
}

.primary-button {
  background: var(--accent);
  color: #fff;
}

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

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

.ghost-button {
  background: var(--surface-soft);
  border-color: var(--line);
  color: var(--text);
}

.metric {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding: 12px 0;
  color: var(--muted);
}

.metric strong {
  color: var(--text);
  font-weight: 600;
  text-align: right;
}

.speaker-editor {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.speaker-editor p {
  margin: 0;
  font-size: 13px;
}

.speaker-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.speaker-row span {
  color: var(--muted);
  font-size: 13px;
}

.export-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.history-list,
.segment-editor {
  display: grid;
  gap: 10px;
}

.history-list p,
.segment-editor p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.history-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  padding: 10px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.history-item strong,
.history-item span {
  display: block;
}

.history-item span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.segment-editor {
  max-height: 420px;
  overflow: auto;
  padding-right: 4px;
}

.segment-row {
  display: grid;
  grid-template-columns: 82px 120px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.segment-time {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.segment-text {
  margin: 0;
  line-height: 1.5;
  color: var(--text);
}

pre {
  overflow: auto;
  max-height: 420px;
  margin: 12px 0 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #101820;
  color: #d7e1ea;
  padding: 12px;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

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

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

  .topbar {
    flex-direction: column;
  }
}
