:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-soft: #eef3f7;
  --text: #172026;
  --muted: #697783;
  --border: #dce4ea;
  --accent: #247f7a;
  --accent-strong: #185f5b;
  --accent-soft: #e4f4f2;
  --warning: #ad6b00;
  --shadow: 0 16px 40px rgba(23, 32, 38, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  min-height: 38px;
  padding: 0 14px;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

button:hover:not(:disabled) {
  border-color: #9eb8c5;
}

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

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

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

.app-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
}

.topbar h1,
.topbar p,
.rail h2,
.main-pane h2,
.inspector h2 {
  margin: 0;
}

.topbar h1 {
  font-size: 24px;
  line-height: 1.15;
  font-weight: 720;
  letter-spacing: 0;
}

.topbar p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr) minmax(280px, 360px);
  gap: 18px;
  padding: 18px;
}

.rail,
.main-pane,
.inspector {
  min-width: 0;
}

.rail,
.inspector {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.topic-form,
.review-pane,
.log-pane,
.inspector {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.topic-form {
  padding: 16px;
}

.topic-form label,
.script-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.topic-form p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.inline-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input {
  min-height: 38px;
  padding: 0 12px;
}

textarea {
  min-height: 310px;
  resize: vertical;
  padding: 14px;
  line-height: 1.8;
  font-size: 16px;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(36, 127, 122, 0.12);
}

.rail h2,
.log-pane h2,
.inspector h2 {
  padding: 0 2px;
  font-size: 14px;
  font-weight: 760;
}

.topic-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.topic-item {
  width: 100%;
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  text-align: left;
}

.topic-item.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

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

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

.main-pane {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 14px;
}

.steps {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  overflow-x: auto;
}

.step {
  min-height: 58px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.step span {
  display: block;
  width: 22px;
  height: 22px;
  margin-bottom: 6px;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--muted);
  text-align: center;
  font-size: 12px;
  line-height: 22px;
}

.step strong {
  display: block;
  font-size: 11px;
  line-height: 1.2;
}

.step.is-done span,
.step.is-active span {
  background: var(--accent);
  color: #fff;
}

.step.is-active {
  border-color: var(--accent);
}

.review-pane {
  min-height: 0;
  padding: 18px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-title h2 {
  font-size: 20px;
  line-height: 1.25;
}

.section-title p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.status-pill {
  align-self: flex-start;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.log-pane {
  padding: 14px;
}

.log-pane ol {
  display: grid;
  gap: 6px;
  margin: 10px 0 0;
  padding: 0 0 0 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.inspector {
  padding: 16px;
}

.file-list {
  display: grid;
  gap: 8px;
}

.file-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.file-item:last-child {
  border-bottom: 0;
}

.file-item strong {
  display: block;
  font-size: 13px;
}

.file-item span {
  display: block;
  max-width: 240px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-state {
  color: var(--warning);
  font-size: 12px;
  font-weight: 700;
}

.file-state.is-ready {
  color: var(--accent);
}

.audio-box audio,
.publish-box pre {
  width: 100%;
}

.audio-box {
  min-height: 42px;
}

.publish-box pre {
  max-height: 210px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f9fbfc;
  padding: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.empty-state {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  }

  .inspector {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    padding: 16px;
  }

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

  .inline-field,
  .section-title,
  .actions {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .steps {
    grid-template-columns: repeat(7, 106px);
  }

  textarea {
    min-height: 260px;
  }
}
