:root {
  color-scheme: light;
  /* A restrained operations-console palette keeps the UI readable for repeated use. */
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-soft: #f0f3f6;
  --line: #d8dee6;
  --text: #14181f;
  --muted: #667085;
  --good: #17803d;
  --warn: #a16207;
  --bad: #b42318;
  --accent: #1769aa;
  --accent-dark: #0f4f82;
  --shadow: 0 18px 45px rgba(20, 24, 31, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

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

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

button,
.secondary,
.primary {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 40px;
  padding: 0 14px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  touch-action: manipulation;
}

button:hover,
.secondary:hover {
  border-color: #aeb9c6;
}

.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
  gap: 8px;
}

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

.disabled {
  opacity: 0.5;
  pointer-events: none;
}

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

.button-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #ffffff;
  border-radius: 999px;
  animation: spin 760ms linear infinite;
}

.shell {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 36px;
}

.topbar,
.form-header,
.block-title,
.result-actions,
.ops-row,
.counter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar {
  margin-bottom: 18px;
}

.eyebrow,
.label {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.1;
}

h1 {
  font-size: clamp(28px, 4vw, 44px);
}

h2 {
  font-size: 18px;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.mode-button {
  border: 0;
  border-radius: 7px;
  background: transparent;
  min-width: 84px;
}

.mode-button.active {
  background: var(--text);
  color: #ffffff;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.status-panel,
.composer,
.side-panel,
.panel-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.status-panel {
  min-height: 92px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.status-panel strong {
  display: block;
  font-size: 22px;
  overflow-wrap: anywhere;
}

.status-panel small {
  color: var(--muted);
}

.status-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--muted);
  flex: 0 0 auto;
}

.status-dot.good {
  background: var(--good);
}

.status-dot.bad {
  background: var(--bad);
}

.status-dot.warn {
  background: var(--warn);
}

.meter {
  width: 100%;
  height: 8px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--panel-soft);
}

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

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

.composer {
  padding: 18px;
}

.activity-panel {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfd;
  display: grid;
  gap: 10px;
}

.activity-panel.running {
  border-color: rgba(23, 105, 170, 0.35);
  background: #f4f9fd;
}

.activity-panel.complete {
  border-color: rgba(23, 128, 61, 0.35);
  background: #f5fbf7;
}

.activity-panel.failed {
  border-color: rgba(180, 35, 24, 0.35);
  background: #fff7f6;
}

.activity-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.activity-header strong {
  display: block;
  font-size: 18px;
}

.activity-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.activity-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--panel-soft);
}

.activity-bar span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 260ms ease;
}

.activity-panel.running .activity-bar span {
  background: linear-gradient(90deg, var(--accent), #47a3d8, var(--accent));
  background-size: 180% 100%;
  animation: shimmer 1.25s linear infinite;
}

.activity-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.activity-steps li {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 8px;
  color: var(--muted);
  background: #ffffff;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.activity-steps li.active {
  border-color: var(--accent);
  color: var(--accent-dark);
  background: #eaf4fb;
}

.activity-steps li.done {
  border-color: rgba(23, 128, 61, 0.35);
  color: var(--good);
  background: #ecfdf3;
}

.activity-steps li.failed {
  border-color: rgba(180, 35, 24, 0.35);
  color: var(--bad);
  background: #fef3f2;
}

.activity-detail {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

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

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  min-height: 42px;
  padding: 10px 12px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 105, 170, 0.16);
}

textarea {
  min-height: 430px;
  line-height: 1.55;
  resize: vertical;
}

.span-all {
  margin-top: 18px;
}

.counter-row {
  margin: 8px 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
}

.toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 14px;
}

.toggles label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.toggles input {
  width: auto;
  min-height: auto;
}

.side-panel {
  display: grid;
  gap: 12px;
  padding: 0;
  box-shadow: none;
  background: transparent;
  border: 0;
}

.panel-block {
  padding: 16px;
  display: grid;
  gap: 12px;
}

audio {
  width: 100%;
  min-height: 42px;
}

.metadata {
  margin: 0;
  display: grid;
  gap: 8px;
}

.metadata div {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

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

dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

pre {
  max-height: 220px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border-radius: 8px;
  background: #111827;
  color: #e5e7eb;
  font-size: 12px;
  line-height: 1.45;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--text);
  color: #ffffff;
  box-shadow: var(--shadow);
}

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

  .status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .mode-switch {
    width: 100%;
  }

  textarea {
    min-height: 320px;
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100vw - 20px, 100%);
    padding: 12px 0 22px;
  }

  .status-grid,
  .control-grid {
    grid-template-columns: 1fr;
  }

  .status-panel,
  .composer,
  .panel-block {
    padding: 14px;
  }

  .form-header,
  .activity-header,
  .block-title,
  .result-actions,
  .ops-row,
  .counter-row {
    align-items: stretch;
    flex-direction: column;
  }

  .form-header .primary,
  .block-title button,
  .result-actions > *,
  .ops-row button {
    width: 100%;
  }

  h1 {
    font-size: 30px;
  }

  .metadata div {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .activity-steps {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 420px) {
  .shell {
    width: 100%;
    padding: 8px;
  }

  .topbar,
  .status-grid,
  .workspace {
    gap: 8px;
  }

  .mode-button {
    min-width: 0;
  }

  textarea {
    min-height: 260px;
  }

  button,
  .secondary,
  .primary,
  input,
  select {
    min-height: 44px;
  }
}

@media (min-width: 1280px) {
  .side-panel {
    position: sticky;
    top: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes shimmer {
  from {
    background-position: 0% 0;
  }

  to {
    background-position: 180% 0;
  }
}
