:root {
  color-scheme: light;
  --bg: #eef1f5;
  --panel: #ffffff;
  --panel-soft: #f6f8fb;
  --panel-strong: #111827;
  --text: #16202d;
  --muted: #657184;
  --line: #d8dee8;
  --line-strong: #b8c2d1;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --accent-soft: #e4f4f1;
  --blue: #2563eb;
  --blue-soft: #e8efff;
  --warn: #9a5b00;
  --warn-soft: #fff3d8;
  --danger: #a13737;
  --danger-soft: #fde8e8;
  --ok: #217245;
  --ok-soft: #e6f4ec;
  --shadow: 0 14px 34px rgba(17, 24, 39, 0.09);
}

* {
  box-sizing: border-box;
}

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

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

button {
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease, transform 140ms ease;
}

button:hover {
  transform: translateY(-1px);
}

.app-shell {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  padding: 18px;
  min-width: 0;
  backdrop-filter: blur(14px);
}

.brand,
.topbar,
.status-strip,
.item-row,
.editor-head,
.section-head,
.asset-row,
.job-grid {
  display: flex;
  align-items: center;
}

.brand {
  justify-content: space-between;
  gap: 12px;
}

.brand strong {
  display: block;
  font-size: 18px;
  letter-spacing: 0;
}

.brand span,
.muted {
  color: var(--muted);
}

.brand span {
  display: block;
  margin-top: 3px;
  font-size: 13px;
}

.icon-btn,
.primary-btn,
.secondary-btn,
.tab {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 7px;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.icon-btn {
  width: 36px;
  height: 36px;
  font-size: 18px;
}

.primary-btn,
.secondary-btn {
  min-height: 38px;
  padding: 0 13px;
  font-weight: 650;
}

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

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

.secondary-btn:hover,
.icon-btn:hover {
  border-color: var(--line-strong);
  background: var(--panel-soft);
}

.search-wrap input {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
  background: var(--panel-soft);
}

.search-wrap input:focus,
textarea:focus,
.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.tab {
  min-height: 34px;
  border-color: transparent;
  background: transparent;
  font-size: 13px;
  font-weight: 650;
}

.tab.active {
  border-color: var(--line);
  background: var(--panel);
  color: var(--accent-strong);
  box-shadow: 0 4px 12px rgba(17, 24, 39, 0.08);
}

.item-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  padding-right: 2px;
}

.item-row {
  width: 100%;
  min-height: 78px;
  padding: 11px;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  text-align: left;
  cursor: pointer;
}

.item-row.active {
  border-color: var(--accent);
  background: linear-gradient(90deg, var(--accent-soft), #fff 55%);
  box-shadow: inset 3px 0 0 var(--accent);
}

.item-row strong {
  display: block;
  font-size: 14px;
  line-height: 1.28;
}

.item-row span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

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

.topbar {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

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

.topbar p {
  margin-top: 5px;
  color: var(--muted);
}

.status-strip {
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.badge.ok {
  border-color: #b8dfc7;
  background: var(--ok-soft);
  color: var(--ok);
}

.badge.warn {
  border-color: #f3d396;
  background: var(--warn-soft);
  color: var(--warn);
}

.badge.danger {
  border-color: #f0bcbc;
  background: var(--danger-soft);
  color: var(--danger);
}

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

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

.panel {
  padding: 16px;
}

.panel h2,
.hero-panel h2 {
  font-size: 17px;
}

.hero-panel {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 20px;
  padding: 18px;
  background:
    linear-gradient(135deg, #ffffff 0, #f9fbfd 52%, #eef7f5 100%);
}

.hero-panel p,
.section-head p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.eyebrow {
  display: block;
  margin-bottom: 6px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 760;
  text-transform: uppercase;
}

.progress-block {
  display: grid;
  align-content: center;
  min-width: 210px;
  gap: 6px;
}

.progress-block strong {
  font-size: 28px;
  line-height: 1;
}

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

.progress-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfe6ef;
}

.progress-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--blue));
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.dashboard-metrics {
  grid-template-columns: repeat(4, minmax(140px, 1fr));
}

.metric {
  display: grid;
  gap: 5px;
  padding: 14px;
}

.metric span,
.metric small {
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  font-size: 22px;
  line-height: 1.1;
}

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

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

.compact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 58px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
  text-align: left;
}

.compact-row.static {
  cursor: default;
}

.compact-row span {
  min-width: 0;
}

.compact-row strong,
.compact-row small {
  display: block;
}

.compact-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.compact-row small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.compact-row b {
  color: var(--accent-strong);
  font-size: 13px;
  white-space: nowrap;
}

.compact-row b.warn {
  color: var(--warn);
}

.compact-row b.danger {
  color: var(--danger);
}

.compact-row b.ok {
  color: var(--ok);
}

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

.config-list div,
.side-stat,
.side-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.config-list div {
  display: grid;
  gap: 4px;
  padding: 10px;
}

.config-list span,
.side-stat span {
  color: var(--muted);
  font-size: 12px;
}

.config-list strong {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.side-summary {
  display: grid;
  gap: 6px;
  padding: 12px;
}

.side-summary.ok {
  border-color: #b8dfc7;
  background: var(--ok-soft);
}

.side-summary.warn {
  border-color: #f3d396;
  background: var(--warn-soft);
}

.side-summary.danger {
  border-color: #f0bcbc;
  background: var(--danger-soft);
}

.side-summary strong {
  font-size: 14px;
}

.side-summary span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.side-stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  padding: 9px 10px;
}

.side-stat strong {
  font-size: 16px;
}

.section-head {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-head.compact {
  margin-bottom: 10px;
}

.timeline {
  display: grid;
  gap: 10px;
}

.stage {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.stage.done {
  border-color: #b8dfc7;
  background: linear-gradient(90deg, var(--ok-soft), #fff);
}

.stage-marker {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-weight: 750;
}

.stage.done .stage-marker {
  border-color: var(--ok);
  background: var(--ok);
  color: #fff;
}

.stage-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.stage-title strong {
  font-size: 14px;
}

.stage-body p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.42;
}

.stage-files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.stage-files span {
  min-height: 24px;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(340px, 0.88fr);
  gap: 16px;
}

.editor-head {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

textarea,
.field input,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfd;
  color: var(--text);
  outline: none;
}

textarea {
  min-height: 360px;
  padding: 12px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  line-height: 1.45;
}

#promptEditor {
  min-height: 520px;
}

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

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.field input,
.field select {
  min-height: 40px;
  padding: 0 10px;
}

.job-grid {
  align-items: stretch;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field.wide {
  grid-column: 1 / -1;
}

.clip-command-center {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(340px, 0.85fr);
  gap: 16px;
}

.clip-form-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.clip-start-panel,
.live-panel {
  align-self: start;
}

.asset-groups,
.assets {
  display: grid;
  gap: 8px;
}

.prompt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.prompt-card,
.channel-card {
  display: grid;
  gap: 6px;
  min-height: 82px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.prompt-card.active,
.channel-card.active {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--accent-soft), #fff);
  box-shadow: inset 3px 0 0 var(--accent);
}

.prompt-card strong,
.channel-card strong {
  font-size: 14px;
}

.prompt-card span,
.channel-card span,
.channel-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.channel-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.channel-notes {
  margin-top: 12px;
}

.channel-notes textarea {
  min-height: 150px;
}

.prompt-name-field {
  margin-bottom: 12px;
}

.clip-run {
  display: grid;
  gap: 12px;
}

.clip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.clip-card {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.clip-card video {
  max-height: 440px;
}

.asset-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  overflow: hidden;
}

.asset-group summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
  padding: 0 10px;
  cursor: pointer;
  font-weight: 700;
}

.asset-group summary span {
  color: var(--muted);
  font-size: 12px;
}

.asset-group .assets {
  padding: 8px;
}

.asset-row {
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
}

.asset-row a {
  color: var(--accent-strong);
  text-decoration: none;
  word-break: break-word;
  font-size: 13px;
}

.task-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.task-row.clip-task {
  background: linear-gradient(135deg, #ffffff, #f1f8f6);
}

.task-row strong,
.task-row span {
  display: block;
}

.task-row span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  word-break: break-word;
}

.task-progress {
  width: 100%;
  height: 7px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 4px;
  background: #dce3e8;
}

.task-progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 320ms ease;
}

.task-progress-fill.active {
  background: linear-gradient(90deg, var(--accent), #43a876, var(--accent));
  background-size: 200% 100%;
  animation: task-progress-flow 1.6s linear infinite;
}

.task-progress-label {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

@keyframes task-progress-flow {
  from {
    background-position: 100% 0;
  }

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

.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.clip-schedule-box {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.inline-check {
  margin-top: 0;
  color: var(--text);
  font-weight: 650;
}

.secret-field label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.secret-field label span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.oauth-action-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 6px;
}

.oauth-action-row span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.publish-target-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 4px 0 12px;
}

.schedule-grid,
.secret-grid {
  margin-top: 12px;
}

.publish-status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 8px;
}

.publish-status {
  display: grid;
  gap: 4px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--warn-soft);
  color: var(--warn);
}

.publish-status.ready {
  border-color: #b8dfc7;
  background: var(--ok-soft);
  color: var(--ok);
}

.publish-status span {
  font-size: 12px;
}

.publish-queue-list {
  max-height: 520px;
  overflow: auto;
}

.danger-text {
  color: var(--danger) !important;
}

.error-box {
  max-height: 170px;
  overflow: auto;
  margin: 10px 0 0;
  padding: 10px;
  border: 1px solid #f0bcbc;
  border-radius: 7px;
  background: var(--danger-soft);
  color: var(--danger);
  white-space: pre-wrap;
  font-size: 12px;
}

video,
img.preview {
  width: 100%;
  max-height: 540px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111827;
}

img.preview {
  object-fit: contain;
  background: var(--panel-soft);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 420px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state h2 {
  color: var(--text);
  margin-bottom: 8px;
}

@media (max-width: 1120px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .clip-command-center,
  .two-col {
    grid-template-columns: 1fr;
  }
}

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

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 52vh;
  }

  .hero-panel {
    display: grid;
  }

  .progress-block {
    min-width: 0;
  }

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

  .clip-form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .workspace {
    padding: 16px;
  }

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

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