:root {
  color-scheme: light;
  --saas-bg: #f4f7fb;
  --saas-bg-soft: #fbfdff;
  --saas-surface: rgba(255, 255, 255, 0.82);
  --saas-surface-strong: rgba(255, 255, 255, 0.96);
  --saas-surface-alt: #f8fbff;
  --saas-line: rgba(15, 23, 42, 0.08);
  --saas-line-strong: rgba(37, 99, 235, 0.16);
  --saas-text: #14213d;
  --saas-muted: #66748d;
  --saas-muted-strong: #44516a;
  --saas-primary: #2563eb;
  --saas-primary-strong: #1d4ed8;
  --saas-accent: #0f766e;
  --saas-success: #15803d;
  --saas-warning: #d97706;
  --saas-danger: #dc2626;
  --saas-shadow: 0 24px 64px rgba(15, 23, 42, 0.08);
  --saas-shadow-soft: 0 12px 36px rgba(15, 23, 42, 0.06);
  --saas-radius-xl: 28px;
  --saas-radius-lg: 22px;
  --saas-radius-md: 16px;
}

body.saas-ui {
  font-family: "Segoe UI Variable", "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--saas-text);
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.16), transparent 32%),
    radial-gradient(circle at top right, rgba(15, 118, 110, 0.14), transparent 28%),
    linear-gradient(180deg, #fbfdff 0%, #f5f8fc 50%, #eef3f9 100%);
  padding: 24px 24px 36px;
}

body.saas-ui::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.05) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.32), transparent 70%);
}

body.saas-ui > *:not(.modal):not(.image-modal):not(.saas-panel-modal) {
  position: relative;
  z-index: 1;
}

body.saas-ui .api-key-bar,
body.saas-ui .tabs-header,
body.saas-ui .saas-hero,
body.saas-ui .saas-surface,
body.saas-ui .modal-content,
body.saas-ui .context-menu,
body.saas-ui .image-modal-btn {
  background: var(--saas-surface);
  border: 1px solid var(--saas-line);
  box-shadow: var(--saas-shadow);
  backdrop-filter: blur(20px);
}

body.saas-ui .api-key-bar {
  display: grid;
  grid-template-columns: auto minmax(240px, 1fr) auto auto auto;
  gap: 12px;
  padding: 16px 18px;
  border-radius: var(--saas-radius-lg);
  margin-bottom: 16px;
  position: sticky;
  top: 18px;
  z-index: 20;
}

body.saas-ui .tabs-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  padding: 18px 20px;
  border-radius: var(--saas-radius-xl);
  box-shadow: var(--saas-shadow-soft);
}

body.saas-ui .tabs-header h1 {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
}

body.saas-ui .saas-title-kicker {
  display: inline-flex;
  width: fit-content;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.1);
  color: var(--saas-primary-strong);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

body.saas-ui .saas-title-main {
  font-size: clamp(28px, 3.1vw, 42px);
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--saas-text);
}

body.saas-ui .saas-title-sub {
  font-size: 14px;
  color: var(--saas-muted);
}

body.saas-ui .saas-inline-badge {
  display: inline-flex;
  width: fit-content;
  margin-bottom: 4px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.1);
  color: var(--saas-accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

body.saas-ui .api-key-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
  color: var(--saas-muted);
}

body.saas-ui .saas-api-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--saas-text);
}

body.saas-ui .api-key-input,
body.saas-ui .form-field input[type="text"],
body.saas-ui .form-field input[type="number"],
body.saas-ui .form-field select,
body.saas-ui .form-field textarea,
body.saas-ui #imageUrlInputGeminiEdit,
body.saas-ui #imageUrlInputVidu {
  background: var(--saas-surface-alt);
  border: 1px solid rgba(148, 163, 184, 0.28);
  color: var(--saas-text);
  border-radius: var(--saas-radius-md);
  padding: 12px 14px;
  min-height: 48px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

body.saas-ui .api-key-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.12);
  color: var(--saas-muted);
  font-weight: 700;
}

body.saas-ui .api-key-status.ok {
  background: rgba(34, 197, 94, 0.14);
  color: var(--saas-success);
}

body.saas-ui .api-key-status.warn {
  background: rgba(239, 68, 68, 0.12);
  color: var(--saas-danger);
}

body.saas-ui .form-field textarea {
  min-height: 120px;
}

body.saas-ui .api-key-input:focus,
body.saas-ui .form-field input:focus,
body.saas-ui .form-field select:focus,
body.saas-ui .form-field textarea:focus,
body.saas-ui #imageUrlInputGeminiEdit:focus,
body.saas-ui #imageUrlInputVidu:focus {
  border-color: rgba(37, 99, 235, 0.45);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.08);
}

body.saas-ui .tab-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px;
  border-radius: 18px;
  background: rgba(226, 232, 240, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.18);
}

body.saas-ui .tab-button {
  min-width: 188px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--saas-text);
}

body.saas-ui .tab-button:hover {
  background: rgba(255, 255, 255, 0.72);
  border-color: rgba(37, 99, 235, 0.12);
  transform: translateY(-1px);
}

body.saas-ui .tab-button.active {
  background: linear-gradient(135deg, #1d4ed8 0%, #0f766e 100%);
  color: white;
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow: 0 16px 32px rgba(29, 78, 216, 0.24);
}

body.saas-ui .saas-tab-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 700;
}

body.saas-ui .saas-tab-icon {
  font-size: 18px;
}

body.saas-ui .saas-tab-meta {
  font-size: 12px;
  color: var(--saas-muted);
}

body.saas-ui .tab-button.active .saas-tab-meta {
  color: rgba(255, 255, 255, 0.78);
}

body.saas-ui .saas-hero {
  max-width: 1800px;
  margin: 18px auto 22px;
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) repeat(3, minmax(160px, 1fr));
  gap: 16px;
  padding: 0;
  border-radius: var(--saas-radius-xl);
  overflow: hidden;
}

body.saas-ui .saas-hero-main,
body.saas-ui .saas-hero-card {
  padding: 22px 24px;
}

body.saas-ui .saas-hero-main {
  background:
    radial-gradient(circle at top right, rgba(37, 99, 235, 0.15), transparent 34%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(246, 250, 255, 0.92));
}

body.saas-ui .saas-hero-badge {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.1);
  color: var(--saas-primary-strong);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 14px;
}

body.saas-ui .saas-hero-title {
  font-size: clamp(28px, 3vw, 38px);
  line-height: 1.08;
  margin-bottom: 10px;
  letter-spacing: -0.03em;
}

body.saas-ui .saas-hero-desc {
  font-size: 14px;
  line-height: 1.7;
  color: var(--saas-muted);
  max-width: 62ch;
}

body.saas-ui .saas-hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

body.saas-ui .saas-hero-tag {
  padding: 8px 11px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.05);
  border: 1px solid rgba(148, 163, 184, 0.18);
  color: var(--saas-muted-strong);
  font-size: 12px;
  font-weight: 600;
}

body.saas-ui .saas-hero-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(247, 250, 255, 0.88));
  border-left: 1px solid var(--saas-line);
}

body.saas-ui .saas-hero-card-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--saas-muted);
}

body.saas-ui .saas-hero-card-value {
  font-size: 20px;
  line-height: 1.2;
  font-weight: 800;
  color: var(--saas-text);
}

body.saas-ui .container {
  gap: 24px;
  min-height: calc(100vh - 280px);
  height: auto;
  align-items: start;
}

body.saas-ui .config-panel,
body.saas-ui .results-panel {
  border-radius: var(--saas-radius-xl);
  padding: 28px;
  overflow: visible;
}

body.saas-ui .config-panel {
  position: sticky;
  top: 126px;
  max-height: calc(100vh - 146px);
  overflow: auto;
  padding-bottom: 138px;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.45) transparent;
}

body.saas-ui .results-panel {
  min-height: 720px;
}

body.saas-ui .config-panel::-webkit-scrollbar {
  width: 10px;
}

body.saas-ui .config-panel::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.45);
  border-radius: 999px;
}

body.saas-ui .config-panel::-webkit-scrollbar-track {
  background: transparent;
}

body.saas-ui .config-panel h2,
body.saas-ui .results-header h2 {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 22px;
  font-size: 28px;
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -0.03em;
}

body.saas-ui .section {
  padding: 18px;
  margin-bottom: 18px;
  border-radius: 20px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(248, 251, 255, 0.78));
}

body.saas-ui .saas-panel-flow {
  margin: -4px 0 18px;
  padding: 16px 18px;
  border-radius: 20px;
  border: 1px solid rgba(37, 99, 235, 0.14);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.06), rgba(15, 118, 110, 0.06));
}

body.saas-ui .saas-panel-flow-top {
  margin-bottom: 12px;
}

body.saas-ui .saas-panel-flow-title {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--saas-primary-strong);
  margin-bottom: 4px;
}

body.saas-ui .saas-panel-flow-copy {
  font-size: 13px;
  line-height: 1.6;
  color: var(--saas-muted);
}

body.saas-ui .saas-panel-flow-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

body.saas-ui .saas-flow-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(148, 163, 184, 0.12);
}

body.saas-ui .saas-flow-item-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.1);
  color: var(--saas-primary-strong);
  font-size: 12px;
  font-weight: 800;
}

body.saas-ui .saas-flow-item-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--saas-text);
}

body.saas-ui .section-title {
  margin-bottom: 14px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--saas-muted-strong);
}

body.saas-ui .saas-step-section {
  position: relative;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

body.saas-ui .saas-step-section.is-focused {
  border-color: rgba(37, 99, 235, 0.3);
  box-shadow: 0 14px 32px rgba(37, 99, 235, 0.08);
}

body.saas-ui .saas-step-section.is-complete {
  border-color: rgba(34, 197, 94, 0.28);
}

body.saas-ui .saas-step-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: start;
}

body.saas-ui .saas-step-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(15, 118, 110, 0.12));
  color: var(--saas-primary-strong);
  font-size: 12px;
  font-weight: 800;
}

body.saas-ui .saas-step-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

body.saas-ui .saas-step-title-text {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--saas-text);
  text-transform: none;
}

body.saas-ui .saas-step-copy {
  font-size: 12px;
  line-height: 1.6;
  color: var(--saas-muted);
  letter-spacing: normal;
  text-transform: none;
}

body.saas-ui .saas-step-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.06);
  color: var(--saas-muted-strong);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

body.saas-ui .saas-step-section.is-optional .saas-step-flag {
  background: rgba(245, 158, 11, 0.12);
  color: var(--saas-warning);
}

body.saas-ui .form-field label,
body.saas-ui .checkbox-field label {
  font-weight: 600;
  color: var(--saas-muted-strong);
}

body.saas-ui .form-field small {
  color: var(--saas-muted);
  margin-top: 6px;
}

body.saas-ui .checkbox-field {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(248, 250, 252, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.16);
}

body.saas-ui .upload-mini,
body.saas-ui .image-slot,
body.saas-ui #addImageBtnGeminiEdit {
  border-radius: 18px;
  border: 1.5px dashed rgba(148, 163, 184, 0.4);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 251, 255, 0.84));
}

body.saas-ui .upload-mini:hover,
body.saas-ui .image-slot:hover,
body.saas-ui #addImageBtnGeminiEdit:hover {
  border-color: rgba(37, 99, 235, 0.42);
  background: linear-gradient(180deg, rgba(245, 249, 255, 0.98), rgba(238, 246, 255, 0.92));
  transform: translateY(-1px);
}

body.saas-ui .upload-mini.has-image,
body.saas-ui .image-slot.has-image {
  border-style: solid;
  border-color: rgba(37, 99, 235, 0.28);
}

body.saas-ui .btn-primary {
  background: linear-gradient(135deg, #1d4ed8 0%, #0f766e 100%);
  box-shadow: 0 18px 40px rgba(29, 78, 216, 0.18);
  border-radius: 18px;
  min-height: 54px;
}

body.saas-ui .btn-primary:hover:not(:disabled) {
  box-shadow: 0 22px 42px rgba(29, 78, 216, 0.24);
}

body.saas-ui .quick-prompt-btn,
body.saas-ui .api-key-btn,
body.saas-ui .btn-small,
body.saas-ui .download-btn,
body.saas-ui .copy-btn,
body.saas-ui .gemini-copy-btn,
body.saas-ui .results-header button,
body.saas-ui .config-panel button:not(.btn):not(.btn-small):not(.quick-prompt-btn) {
  border-radius: 14px !important;
  font-weight: 600 !important;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

body.saas-ui .api-key-btn.save {
  background: linear-gradient(135deg, #1d4ed8, #0f766e);
}

body.saas-ui .api-key-btn.toggle {
  background: linear-gradient(135deg, #0f172a, #334155);
}

body.saas-ui .saas-action-dock {
  position: sticky;
  bottom: -28px;
  margin: 26px -28px -28px;
  padding: 18px 28px 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: end;
  border-top: 1px solid rgba(148, 163, 184, 0.16);
  background: linear-gradient(180deg, rgba(250, 252, 255, 0.9), rgba(255, 255, 255, 0.98));
  backdrop-filter: blur(14px);
  z-index: 4;
}

body.saas-ui .saas-action-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--saas-text);
  margin-bottom: 4px;
}

body.saas-ui .saas-action-copy {
  font-size: 13px;
  line-height: 1.6;
  color: var(--saas-muted);
}

body.saas-ui .saas-action-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

body.saas-ui .saas-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(255, 255, 255, 0.86);
  font-size: 12px;
}

body.saas-ui .saas-check-label {
  font-weight: 800;
  color: var(--saas-text);
}

body.saas-ui .saas-check-detail {
  color: var(--saas-muted);
}

body.saas-ui .saas-check.is-ready {
  border-color: rgba(34, 197, 94, 0.22);
  background: rgba(34, 197, 94, 0.1);
}

body.saas-ui .saas-check.is-ready .saas-check-detail {
  color: var(--saas-success);
}

body.saas-ui .saas-check.is-pending {
  border-color: rgba(245, 158, 11, 0.22);
  background: rgba(245, 158, 11, 0.1);
}

body.saas-ui .saas-check.is-pending .saas-check-detail {
  color: var(--saas-warning);
}

body.saas-ui .saas-action-button {
  min-width: 240px;
}

body.saas-ui .saas-action-button .btn {
  width: 100%;
  margin: 0;
}

body.saas-ui .results-header {
  align-items: flex-start;
  gap: 18px;
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

body.saas-ui .results-header > div {
  flex-wrap: wrap;
}

body.saas-ui .stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(92px, 1fr));
  gap: 10px;
}

body.saas-ui .stat-item {
  min-width: 92px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(245, 248, 252, 0.92));
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

body.saas-ui .stat-item span:first-child {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--saas-muted);
}

body.saas-ui .stat-num {
  font-size: 24px;
  line-height: 1;
  color: var(--saas-text);
}

body.saas-ui .results-grid {
  gap: 18px;
}

body.saas-ui .result-card,
body.saas-ui .gemini-result-card {
  border-radius: 22px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(248, 251, 255, 0.92));
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.06);
  overflow: hidden;
}

body.saas-ui .result-card::before,
body.saas-ui .gemini-result-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.88), rgba(15, 118, 110, 0.88));
}

body.saas-ui .result-card.processing::before {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

body.saas-ui .result-card.success::before {
  background: linear-gradient(90deg, #16a34a, #22c55e);
}

body.saas-ui .result-card.error::before {
  background: linear-gradient(90deg, #dc2626, #f87171);
}

body.saas-ui .card-body {
  padding: 18px;
}

body.saas-ui .card-prompt,
body.saas-ui .result-info {
  color: var(--saas-text);
}

body.saas-ui .result-header,
body.saas-ui .gemini-result-header {
  padding: 18px 18px 0;
  border-bottom: none;
}

body.saas-ui .result-info {
  margin: 0 18px 16px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(248, 250, 252, 0.82);
  border: 1px solid rgba(148, 163, 184, 0.14);
}

body.saas-ui .param-tag,
body.saas-ui .status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

body.saas-ui .param-tag {
  background: rgba(37, 99, 235, 0.08);
  color: var(--saas-primary-strong);
}

body.saas-ui .status-badge.processing {
  background: rgba(245, 158, 11, 0.12);
  color: var(--saas-warning);
}

body.saas-ui .status-badge.success {
  background: rgba(34, 197, 94, 0.14);
  color: var(--saas-success);
}

body.saas-ui .status-badge.error {
  background: rgba(239, 68, 68, 0.12);
  color: var(--saas-danger);
}

body.saas-ui .card-status {
  background: rgba(248, 250, 252, 0.78);
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 16px;
}

body.saas-ui .status-text {
  color: var(--saas-muted);
}

body.saas-ui .btn-small,
body.saas-ui .download-btn,
body.saas-ui .copy-btn,
body.saas-ui .gemini-copy-btn {
  min-height: 40px;
}

body.saas-ui .empty-state {
  padding: 56px 24px;
  border-radius: 24px;
  border: 1px dashed rgba(148, 163, 184, 0.34);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(246, 249, 253, 0.68));
  color: var(--saas-muted);
}

body.saas-ui .empty-state-icon {
  filter: drop-shadow(0 10px 20px rgba(37, 99, 235, 0.14));
}

body.saas-ui .modal,
body.saas-ui .image-modal {
  background: rgba(7, 16, 31, 0.66);
  backdrop-filter: blur(12px);
}

body.saas-ui .modal-content {
  border-radius: 28px;
  padding: 24px;
}

body.saas-ui .video-loading {
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
}

body.saas-ui .modal-close,
body.saas-ui .image-modal-close {
  border-radius: 50%;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.18);
}

body.saas-ui .video-info,
body.saas-ui .error-message {
  border-radius: 16px;
  background: rgba(248, 250, 252, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.14);
  color: var(--saas-muted-strong);
}

body.saas-ui .btn-detail {
  background: linear-gradient(135deg, #0f172a, #334155);
  color: #fff;
}

body.saas-ui .task-inline-note {
  flex: 999;
  align-self: center;
  padding: 0 8px;
  color: var(--saas-muted);
  font-size: 12px;
  text-align: center;
}

body.saas-ui .task-detail-trigger {
  cursor: pointer;
  transition: color 0.2s ease;
}

body.saas-ui .task-detail-trigger:hover {
  color: var(--saas-primary-strong);
}

body.saas-ui .task-detail-link {
  margin-top: 8px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--saas-primary-strong);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
}

html.prompt-library-open,
body.prompt-library-open {
  overflow: hidden;
}

body.saas-ui .prompt-library-inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

body.saas-ui .prompt-library-inline-btn {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(248, 250, 252, 0.92);
  color: var(--saas-muted-strong);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

body.saas-ui .prompt-library-inline-btn.primary {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(15, 118, 110, 0.12));
  color: var(--saas-primary-strong);
}

body.saas-ui .prompt-library-inline-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(37, 99, 235, 0.28);
}

body.saas-ui .prompt-library-modal {
  position: fixed !important;
  inset: 0 !important;
  display: none;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 3vw, 30px);
  background: rgba(7, 16, 31, 0.64);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 6300 !important;
}

body.saas-ui .prompt-library-modal.show {
  display: flex !important;
}

body.saas-ui .prompt-library-content {
  width: min(1180px, 94vw);
  max-width: 1180px;
  max-height: min(88vh, 920px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  overflow: hidden;
  margin: auto;
  position: relative;
  border-radius: 30px;
  box-shadow: 0 34px 96px rgba(7, 16, 31, 0.26);
}

body.saas-ui .prompt-library-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding-right: 48px;
}

body.saas-ui .prompt-library-kicker {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--saas-primary-strong);
  margin-bottom: 6px;
}

body.saas-ui .prompt-library-title {
  margin: 0 0 8px;
  font-size: 30px;
  line-height: 1.08;
  letter-spacing: -0.03em;
}

body.saas-ui .prompt-library-desc {
  margin: 0;
  max-width: 60ch;
  font-size: 14px;
  line-height: 1.7;
  color: var(--saas-muted);
}

body.saas-ui .prompt-library-header-actions {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

body.saas-ui .prompt-library-workspaces,
body.saas-ui .prompt-library-source-tabs,
body.saas-ui .prompt-library-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

body.saas-ui .prompt-library-workspaces {
  margin-bottom: 14px;
}

body.saas-ui .prompt-library-tab,
body.saas-ui .prompt-library-source-tab,
body.saas-ui .prompt-library-chip {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(248, 250, 252, 0.92);
  color: var(--saas-muted-strong);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

body.saas-ui .prompt-library-tab.active,
body.saas-ui .prompt-library-source-tab.active,
body.saas-ui .prompt-library-chip.active {
  background: linear-gradient(135deg, #1d4ed8, #0f766e);
  color: #fff;
  border-color: transparent;
}

body.saas-ui .prompt-library-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  margin-bottom: 14px;
}

body.saas-ui .prompt-library-search input {
  width: 100%;
  min-height: 48px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(248, 250, 252, 0.92);
  padding: 0 16px;
  color: var(--saas-text);
  font-size: 14px;
}

body.saas-ui .prompt-library-categories {
  margin-bottom: 18px;
}

body.saas-ui .prompt-library-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.92fr) minmax(0, 1.35fr);
  gap: 16px;
  min-height: 0;
  overflow: hidden;
}

body.saas-ui .prompt-library-list,
body.saas-ui .prompt-library-detail {
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

body.saas-ui .prompt-library-list {
  display: grid;
  gap: 12px;
}

body.saas-ui .prompt-library-card {
  width: 100%;
  padding: 16px;
  border-radius: 20px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 251, 255, 0.9));
  text-align: left;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

body.saas-ui .prompt-library-card:hover,
body.saas-ui .prompt-library-card.active {
  transform: translateY(-1px);
  border-color: rgba(37, 99, 235, 0.24);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

body.saas-ui .prompt-library-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

body.saas-ui .prompt-library-card-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--saas-text);
}

body.saas-ui .prompt-library-card-source,
body.saas-ui .prompt-library-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.08);
  color: var(--saas-primary-strong);
  font-size: 12px;
  font-weight: 700;
}

body.saas-ui .prompt-library-card-source.custom,
body.saas-ui .prompt-library-badge.custom {
  background: rgba(245, 158, 11, 0.12);
  color: var(--saas-warning);
}

body.saas-ui .prompt-library-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--saas-muted);
  font-size: 12px;
}

body.saas-ui .prompt-library-card-summary,
body.saas-ui .prompt-library-detail-summary {
  color: var(--saas-muted);
  font-size: 13px;
  line-height: 1.7;
}

body.saas-ui .prompt-library-detail {
  padding: 20px;
  border-radius: 24px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 251, 255, 0.92));
}

body.saas-ui .prompt-library-detail-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

body.saas-ui .prompt-library-detail-title {
  font-size: 24px;
  line-height: 1.15;
  font-weight: 800;
  color: var(--saas-text);
  margin-bottom: 10px;
}

body.saas-ui .prompt-library-detail-meta,
body.saas-ui .prompt-library-tag-row,
body.saas-ui .prompt-library-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

body.saas-ui .prompt-library-detail-actions {
  justify-content: flex-end;
}

body.saas-ui .prompt-library-detail-label {
  margin: 18px 0 10px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--saas-muted);
}

body.saas-ui .prompt-library-detail-prompt {
  padding: 18px;
  border-radius: 20px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(248, 250, 252, 0.82);
  color: var(--saas-text);
  font-size: 14px;
  line-height: 1.9;
  white-space: pre-wrap;
  word-break: break-word;
}

body.saas-ui .prompt-library-detail-footnote {
  margin-top: 12px;
  color: var(--saas-muted);
  font-size: 12px;
}

body.saas-ui .prompt-library-empty {
  padding: 18px;
  border-radius: 20px;
  border: 1px dashed rgba(148, 163, 184, 0.24);
  background: rgba(248, 250, 252, 0.68);
  color: var(--saas-muted);
  font-size: 13px;
  line-height: 1.8;
}

html.task-detail-modal-open,
body.task-detail-modal-open {
  overflow: hidden;
}

body.saas-ui .task-detail-modal {
  position: fixed !important;
  inset: 0 !important;
  display: none;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 3vw, 32px);
  background: rgba(6, 16, 32, 0.64);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 6200 !important;
  overflow: auto;
}

body.saas-ui .task-detail-modal.show {
  display: flex !important;
}

body.saas-ui .task-detail-content {
  width: min(1080px, 92vw);
  max-width: 1080px;
  max-height: 88vh;
  margin: auto;
  position: relative;
  align-items: stretch;
  overflow: hidden;
  box-shadow: 0 32px 96px rgba(7, 16, 31, 0.28);
}

body.saas-ui .task-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding-right: 48px;
}

body.saas-ui .task-detail-eyebrow {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--saas-primary-strong);
  margin-bottom: 6px;
}

body.saas-ui .task-detail-title {
  margin: 0;
  font-size: 28px;
  line-height: 1.08;
  letter-spacing: -0.03em;
  color: var(--saas-text);
}

body.saas-ui .task-detail-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

body.saas-ui .task-detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.95fr);
  gap: 16px;
  min-height: 0;
  overflow: hidden;
}

body.saas-ui .task-detail-main,
body.saas-ui .task-detail-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  min-height: 0;
}

body.saas-ui .task-detail-section {
  padding: 18px;
  border-radius: 22px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 251, 255, 0.9));
}

body.saas-ui .task-detail-section-title {
  margin-bottom: 12px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--saas-muted);
}

body.saas-ui .task-detail-prompt {
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(248, 250, 252, 0.82);
  color: var(--saas-text);
  font-size: 14px;
  line-height: 1.85;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: auto;
  max-height: 52vh;
}

body.saas-ui .task-detail-reference-groups {
  display: grid;
  gap: 14px;
}

body.saas-ui .task-detail-reference-group {
  display: grid;
  gap: 10px;
}

body.saas-ui .task-detail-reference-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--saas-text);
}

body.saas-ui .task-detail-reference-list {
  display: grid;
  gap: 10px;
}

body.saas-ui .task-detail-resource {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(248, 250, 252, 0.78);
  text-decoration: none;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

body.saas-ui .task-detail-resource:hover {
  transform: translateY(-1px);
  border-color: rgba(37, 99, 235, 0.26);
  background: rgba(242, 247, 255, 0.92);
}

body.saas-ui .task-detail-resource-label {
  color: var(--saas-primary-strong);
  font-size: 13px;
  font-weight: 700;
}

body.saas-ui .task-detail-resource-url {
  color: var(--saas-muted);
  font-size: 12px;
  word-break: break-all;
}

body.saas-ui .task-detail-meta {
  display: grid;
  gap: 10px;
}

body.saas-ui .task-detail-meta-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

body.saas-ui .task-detail-meta-row-inline {
  grid-template-columns: 86px minmax(0, 1fr);
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(248, 250, 252, 0.78);
}

body.saas-ui .task-detail-meta-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--saas-muted);
}

body.saas-ui .task-detail-meta-value {
  color: var(--saas-text);
  font-size: 13px;
  line-height: 1.65;
  word-break: break-word;
}

body.saas-ui .task-detail-links {
  display: grid;
  gap: 12px;
}

body.saas-ui .task-detail-action-row {
  display: grid;
  gap: 10px;
}

body.saas-ui .task-detail-action-btn {
  margin: 0;
}

body.saas-ui .task-detail-secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(248, 250, 252, 0.82);
  color: var(--saas-primary-strong);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
}

body.saas-ui .task-detail-empty {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px dashed rgba(148, 163, 184, 0.24);
  background: rgba(248, 250, 252, 0.62);
  color: var(--saas-muted);
  font-size: 13px;
  line-height: 1.7;
}

body.saas-ui .context-menu {
  border-radius: 20px;
  overflow: hidden;
}

body.saas-ui .context-menu-header {
  background: linear-gradient(135deg, #1d4ed8 0%, #0f766e 100%);
}

body.saas-ui .context-menu-item:hover {
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.08) 0%, rgba(15, 118, 110, 0.08) 100%);
}

body.saas-ui .error-message {
  padding: 24px 18px;
  text-align: center;
}

body.saas-ui .loading-spinner,
body.saas-ui .video-loading-spinner {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 4px solid rgba(37, 99, 235, 0.12);
  border-top-color: var(--saas-primary);
  animation: saas-spin 0.9s linear infinite;
}

body.saas-ui .toast {
  border-radius: 18px;
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.16);
  backdrop-filter: blur(14px);
}

@media (max-width: 960px) {
  body.saas-ui .prompt-library-modal {
    align-items: flex-start;
    padding: 12px;
  }

  body.saas-ui .prompt-library-content {
    width: min(96vw, 96vw);
    max-height: 92vh;
  }

  body.saas-ui .prompt-library-header,
  body.saas-ui .prompt-library-detail-top {
    flex-direction: column;
    padding-right: 0;
  }

  body.saas-ui .prompt-library-toolbar,
  body.saas-ui .prompt-library-layout {
    grid-template-columns: 1fr;
  }

  body.saas-ui .prompt-library-detail-actions {
    justify-content: flex-start;
  }

  body.saas-ui .task-detail-modal {
    align-items: flex-start;
    padding: 12px;
  }

  body.saas-ui .task-detail-content {
    width: min(96vw, 96vw);
    max-height: 92vh;
  }

  body.saas-ui .task-detail-header {
    flex-direction: column;
    padding-right: 0;
  }

  body.saas-ui .task-detail-badges {
    justify-content: flex-start;
  }

  body.saas-ui .task-detail-layout {
    grid-template-columns: 1fr;
    overflow: auto;
    padding-right: 4px;
  }

  body.saas-ui .task-detail-prompt {
    max-height: none;
  }
}

body.saas-ui .toast.success {
  background: linear-gradient(135deg, #15803d, #22c55e);
}

body.saas-ui .toast.error {
  background: linear-gradient(135deg, #b91c1c, #ef4444);
}

body.saas-ui .toast.info,
body.saas-ui .toast.warning {
  background: linear-gradient(135deg, #1d4ed8, #0ea5e9);
}

@keyframes saas-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1400px) {
  body.saas-ui .saas-hero {
    grid-template-columns: 1fr 1fr;
  }

  body.saas-ui .saas-hero-main {
    grid-column: 1 / -1;
  }
}

@media (max-width: 1200px) {
  body.saas-ui .container {
    grid-template-columns: 1fr;
  }

  body.saas-ui .config-panel {
    position: static;
    max-height: none;
    overflow: visible;
    padding-bottom: 28px;
  }

  body.saas-ui .results-panel {
    min-height: auto;
  }

  body.saas-ui .api-key-bar {
    grid-template-columns: 1fr;
  }

  body.saas-ui .tabs-header {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  body.saas-ui {
    padding: 16px 16px 28px;
  }

  body.saas-ui .saas-hero {
    grid-template-columns: 1fr;
  }

  body.saas-ui .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.saas-ui .tab-button {
    min-width: calc(50% - 4px);
  }

  body.saas-ui .config-panel,
  body.saas-ui .results-panel {
    padding: 22px 18px;
  }

  body.saas-ui .saas-panel-flow-grid {
    grid-template-columns: 1fr;
  }

  body.saas-ui .saas-action-dock {
    grid-template-columns: 1fr;
    margin: 22px -18px -22px;
    padding: 16px 18px 18px;
    bottom: -22px;
  }

  body.saas-ui .saas-action-button {
    min-width: 100%;
  }
}

@media (max-width: 640px) {
  body.saas-ui .tab-button {
    min-width: 100%;
  }

  body.saas-ui .stats {
    grid-template-columns: 1fr 1fr;
  }

  body.saas-ui .results-grid {
    grid-template-columns: 1fr;
  }
}
