:root {
  --blue: #2563eb;
  --blue-700: #1d4ed8;
  --nav: #07111f;
  --bg: #f6f8fb;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --soft-blue: #eff6ff;
  --danger: #dc2626;
  --success: #0f766e;
  --warning: #f59e0b;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
  --radius: 18px;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", Inter, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  background: var(--bg);
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 18px;
  background: linear-gradient(180deg, #07111f 0%, #020817 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  text-decoration: none;
  color: #fff;
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 900;
  background: var(--blue);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.brand small,
.sidebar-card small,
.eyebrow {
  display: block;
  font-size: 11px;
  letter-spacing: 0;
  text-transform: uppercase;
  color: #7da2dd;
  font-weight: 700;
}

.brand strong {
  display: block;
  font-size: 18px;
  line-height: 1.25;
}

.main-nav {
  display: grid;
  gap: 10px;
}

.nav-item {
  border: 0;
  border-radius: 12px;
  padding: 14px;
  color: rgba(255, 255, 255, 0.72);
  background: transparent;
  text-align: left;
}

.nav-item span {
  display: block;
  font-weight: 800;
  color: #fff;
}

.nav-item small {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.58);
}

.nav-item.active {
  background: var(--blue);
  box-shadow: 0 14px 32px rgba(37, 99, 235, 0.32);
}

.sidebar-card {
  margin-top: auto;
  border-radius: 14px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
}

.sidebar-card p {
  margin: 8px 0 0;
  color: rgba(255, 255, 255, 0.72);
  line-height: 1.7;
  font-size: 13px;
}

.main {
  min-width: 0;
  padding-bottom: 34px;
}

.topbar {
  min-height: 108px;
  padding: 26px 28px 20px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar h1 {
  margin: 6px 0 0;
  font-size: 32px;
  line-height: 1.1;
}

.top-actions,
.hero-actions,
.button-row,
.card-actions,
.file-row,
.comment-form,
.clip-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.page {
  display: none;
  padding: 20px 28px 0;
}

.page.active {
  display: block;
}

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

.hero-panel {
  padding: 24px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  margin-bottom: 20px;
}

.hero-panel h2,
.panel h3 {
  margin: 4px 0 8px;
  font-size: 24px;
}

.hero-panel p,
.muted,
.panel p {
  color: var(--muted);
  line-height: 1.75;
}

.two-column {
  display: grid;
  grid-template-columns: 430px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.workbench-grid,
.interaction-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(460px, 1.25fr);
  gap: 20px;
  align-items: start;
}

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

.panel {
  padding: 20px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}

.create-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-bottom: 10px;
}

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

input:focus,
textarea:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.13);
}

label,
.full-label {
  display: grid;
  gap: 8px;
  color: #334155;
  font-weight: 700;
  font-size: 13px;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.danger-btn {
  border-radius: 11px;
  min-height: 42px;
  padding: 0 16px;
  font-weight: 800;
  border: 1px solid transparent;
}

.primary-btn {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 12px 26px rgba(37, 99, 235, 0.24);
}

.primary-btn:hover {
  background: var(--blue-700);
}

.secondary-btn {
  background: #fff;
  color: var(--blue);
  border-color: #bfdbfe;
}

.ghost-btn {
  background: var(--soft-blue);
  color: var(--blue);
}

.danger-btn {
  background: var(--danger);
  color: #fff;
}

.small {
  min-height: 36px;
  padding: 0 12px;
}

.wide {
  width: 100%;
}

.status-chip,
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  border-radius: 999px;
  padding: 0 12px;
  background: var(--soft-blue);
  color: var(--blue);
  font-weight: 800;
  font-size: 13px;
}

.list-stack {
  display: grid;
  gap: 12px;
}

.list-card,
.suggestion-card {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.list-card.active {
  border-color: var(--blue);
  background: linear-gradient(180deg, #eff6ff, #fff);
}

.list-card p,
.suggestion-card p {
  margin: 4px 0;
}

.empty-state {
  border: 1px dashed #bfdbfe;
  background: #f8fbff;
  color: var(--muted);
  border-radius: 14px;
  padding: 18px;
  line-height: 1.7;
}

.connected-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.flow-step {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid #bfdbfe;
  background: #f8fbff;
}

.flow-step span {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--blue);
  color: #fff;
  font-weight: 900;
  margin-bottom: 10px;
}

.flow-step strong,
.flow-step small {
  display: block;
}

.flow-step small {
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.6;
}

.upload-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid #bfdbfe;
  background: #f8fbff;
  margin-bottom: 16px;
}

.upload-card h4,
.asset-section h4,
.manual-speak h4 {
  margin: 0 0 6px;
  font-size: 17px;
}

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

.status-grid.compact {
  margin-top: 8px;
}

.metric-card {
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fff;
  padding: 16px;
}

.metric-card small {
  color: var(--muted);
  font-weight: 800;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

.metric-card.ok {
  border-color: #99f6e4;
  background: #f0fdfa;
}

.metric-card p {
  margin: 8px 0 0;
  font-size: 13px;
}

.asset-section {
  border-top: 1px solid var(--line);
  padding-top: 18px;
  margin-top: 18px;
}

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

.section-title small {
  color: var(--muted);
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.media-grid.small {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.media-card {
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 12px;
  display: grid;
  gap: 10px;
  background: #fff;
}

.media-card.wide {
  grid-template-columns: 220px minmax(0, 1fr);
  align-items: center;
}

.media-card video {
  width: 100%;
  border-radius: 12px;
  background: #0b1220;
  aspect-ratio: 16 / 9;
  object-fit: contain;
}

.media-card audio {
  width: 100%;
}

.action-card.default {
  border-color: var(--blue);
  background: #f8fbff;
}

.button-row.tight {
  gap: 8px;
}

.clip-toolbar {
  margin-bottom: 12px;
}

.clip-toolbar select,
.clip-toolbar input {
  width: auto;
  min-width: 128px;
}

.preview-panel {
  min-height: 640px;
}

.green-preview {
  width: min(360px, 100%);
  aspect-ratio: 9 / 16;
  margin: 0 auto;
  background: #00ff00;
  border-radius: 20px;
  overflow: hidden;
  display: grid;
  place-items: center;
  border: 1px solid #16a34a;
}

.green-preview video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.avatar-silhouette {
  width: 48%;
  height: 48%;
  display: grid;
  place-items: center;
  border-radius: 999px 999px 18px 18px;
  background: linear-gradient(180deg, #e2e8f0, #94a3b8);
  color: #0f172a;
  font-weight: 800;
  text-align: center;
  padding: 18px;
}

.mini-state {
  margin-top: 14px;
  display: grid;
  gap: 5px;
  padding: 14px;
  border-radius: 14px;
  background: #f8fbff;
  border: 1px solid #bfdbfe;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.action-switcher {
  margin-top: 16px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #f8fafc;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.action-switcher button {
  min-height: 40px;
  border: 1px solid #bfdbfe;
  border-radius: 11px;
  color: var(--blue);
  background: #fff;
  font-weight: 800;
}

.action-switcher button.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.22);
}

.comment-form {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr) auto;
  margin-bottom: 14px;
}

.suggestion-card {
  display: grid;
  align-items: start;
}

.manual-speak {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.truth-list {
  margin: 0;
  padding-left: 18px;
  line-height: 1.9;
  color: #334155;
}

.auth-view {
  position: fixed;
  inset: 0;
  background: rgba(7, 17, 31, 0.72);
  display: grid;
  place-items: center;
  z-index: 100;
}

.auth-card {
  width: min(420px, calc(100vw - 40px));
  border-radius: 20px;
  background: #fff;
  padding: 26px;
  display: grid;
  gap: 14px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.24);
}

.inline-message {
  margin: 0;
  color: var(--danger);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 120;
  max-width: 420px;
  padding: 14px 16px;
  border-radius: 14px;
  background: #07111f;
  color: #fff;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.25);
}

.toast[data-type="success"] {
  background: var(--success);
}

.toast[data-type="error"] {
  background: var(--danger);
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .two-column,
  .workbench-grid,
  .interaction-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .topbar,
  .hero-panel,
  .upload-card,
  .media-card.wide {
    display: grid;
  }

  .status-grid,
  .connected-steps,
  .form-grid,
  .comment-form,
  .action-switcher {
    grid-template-columns: 1fr;
  }
}

/* Program Output: independent capture window */
.program-output-body {
  margin: 0;
  background: #00ff00;
  overflow: hidden;
  cursor: none;
}

.green-output-stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: #00ff00;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.green-output-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: transparent;
}

.green-output-empty {
  color: rgba(0, 80, 0, 0.72);
  font-size: 32px;
  font-weight: 800;
}

.capture-mode .green-output-empty,
.capture-mode .green-output-loading {
  display: none !important;
}

.green-output-loading {
  position: fixed;
  left: 24px;
  bottom: 24px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: #0f172a;
  font-weight: 800;
}
