:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #d8e1ee;
  --blue: #1f5fe0;
  --blue-soft: #eaf1ff;
  --green: #0f9d58;
  --amber: #d97706;
  --red: #dc2626;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: transparent;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}
.app {
  width: min(1100px, calc(100% - 32px));
  margin: 24px auto 48px;
  display: grid;
  gap: 16px;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 10px 26px rgba(31,52,84,.06);
  padding: 18px;
}
.topbar {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-start;
}
.brand-wrap {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #4f8df8);
  color: #fff;
  font-weight: 800;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.topbar h1 {
  margin: 0 0 6px;
  font-size: 24px;
}
.subtitle {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}
.topbar-meta {
  display: grid;
  gap: 8px;
  justify-items: end;
}
.badge-exp {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid #b6c8ef;
  background: #f2f7ff;
  color: #3058a6;
  font-weight: 700;
  font-size: 12px;
  padding: 6px 10px;
}
.meta-note {
  color: var(--muted);
  font-size: 12px;
}
.hero h1,
.hero h2 {
  margin: 0 0 10px;
  font-size: 28px;
  line-height: 1.15;
}
.hero p {
  margin: 0;
  color: #415169;
  line-height: 1.5;
}
h3 {
  margin: 0 0 10px;
  font-size: 20px;
}
textarea,
input {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 11px 12px;
  font: inherit;
}
textarea {
  min-height: 110px;
  resize: vertical;
}
textarea:focus,
input:focus {
  outline: none;
  border-color: #8fb1ff;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}
.row {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}
button {
  border: 1px solid #b7c8ea;
  background: #ecf2ff;
  color: #1847aa;
  border-radius: 10px;
  padding: 9px 12px;
  font-weight: 700;
  cursor: pointer;
}
.btn-primary {
  border-color: #2f63ca;
  background: var(--blue);
  color: #fff;
}
button[disabled] {
  opacity: .55;
  cursor: not-allowed;
}
.examples {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.example-chip {
  border-radius: 999px;
  background: #fff;
  color: #2f5aa2;
}
.status {
  margin: 10px 0 0;
  color: var(--muted);
}
.status.error { color: var(--red); }
.status.ok { color: var(--green); }
.helper-note,
.empty-note,
.empty-state {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 14px;
}
.topbar-brand {
  font-size: 24px;
  font-weight: 800;
}
.exp-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid #b6c8ef;
  background: #f2f7ff;
  color: #3058a6;
  font-weight: 700;
  font-size: 12px;
  padding: 6px 10px;
}
.topbar-note {
  color: var(--muted);
  font-size: 12px;
}
.ui2-material-page {
  display: grid;
  gap: 18px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.ui2-material-head {
  margin-bottom: 4px;
}

.ui2-material-grid {
  display: grid;
  gap: 16px;
}

.material-panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(214, 226, 238, 0.96);
  border-radius: 18px;
  box-shadow: 0 12px 26px rgba(22, 58, 110, 0.05);
}

.ui2-material-section-title {
  margin: 0 0 12px;
  font-size: 26px;
  line-height: 1.12;
}

.ui2-material-page .row {
  margin-top: 14px;
}
.draft {
  margin: 0;
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 8px 14px;
}
.draft dt { font-weight: 700; color: #334155; }
.draft dd { margin: 0; }
.cards-plan {
  display: grid;
  gap: 10px;
}
.plan-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  display: grid;
  gap: 8px;
  background: #fbfdff;
}
.plan-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.plan-title { font-weight: 700; }
.plan-main {
  color: #334155;
  font-size: 14px;
  margin-top: 2px;
}
.badge {
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-not_selected { background: #eef2f7; color: #4b5563; }
.badge-found { background: #e8f7ee; color: var(--green); }
.badge-generating { background: #fff4e5; color: var(--amber); }
.badge-ready { background: #e8f7ee; color: var(--green); }
.badge-error { background: #feecec; color: var(--red); }
.plan-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.plan-meta {
  font-size: 13px;
  color: var(--muted);
}
@media (max-width: 840px) {
  .topbar {
    grid-template-columns: 1fr;
    display: grid;
  }
  .topbar-meta {
    justify-items: start;
  }
  .hero h2 {
    font-size: 24px;
  }
}
@media (max-width: 720px) {
  .draft {
    grid-template-columns: 1fr;
  }
}


.auth-debug {
  border-color: #c9d8f5;
  background: #f9fbff;
}
.auth-summary {
  margin: 0 0 8px;
  font-weight: 700;
}
.auth-details {
  font-size: 13px;
  color: #334155;
  display: grid;
  gap: 4px;
  word-break: break-word;
}
.auth-row code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}


.btn-ghost {
  border: 1px solid #c6d4ef;
  background: #f7faff;
  color: #274b93;
}

.step-card {
  position: relative;
  border: 1px solid #d6e1f2;
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
  box-shadow: 0 8px 20px rgba(36, 64, 109, 0.06);
  padding: 12px;
}

.step-card::after {
  content: '';
  position: absolute;
  left: 28px;
  bottom: -12px;
  width: 2px;
  height: 12px;
  background: #d5e0f5;
}

.step-card.step-card-last::after {
  display: none;
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid #c3d3f2;
  background: #eef4ff;
  color: #2e5196;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
}

.step-layout {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 12px;
  margin-top: 8px;
}

.step-preview {
  width: 170px;
  height: 170px;
  border-radius: 12px;
  border: 1px solid #ccd9ef;
  overflow: hidden;
  background: #fff;
  display: grid;
  place-items: center;
  padding: 0;
}

.step-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.step-preview-placeholder {
  width: 170px;
  height: 170px;
  border-radius: 12px;
  border: 1px dashed #c9d4e5;
  background: #f8fafd;
  color: #667085;
  font-size: 13px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 8px;
}

.step-content {
  display: grid;
  gap: 8px;
}

.status-badge {
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.step-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.step-actions .step-btn {
  border: 1px solid #b8ccef;
  background: #eef4ff;
  color: #1f4ca7;
}

.step-actions .step-btn.primary {
  border-color: #2f63ca;
  background: #1f5fe0;
  color: #fff;
}

.step-actions .step-btn[disabled] {
  opacity: 0.62;
  cursor: not-allowed;
}

.step-error {
  margin: 0;
  color: #dc2626;
  font-size: 13px;
  font-weight: 600;
}

@media (max-width: 720px) {
  .step-layout {
    grid-template-columns: 1fr;
  }

  .step-preview,
  .step-preview-placeholder {
    width: 100%;
    height: 190px;
  }
}


.step-preview-placeholder.is-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.step-spinner {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 3px solid #d5e3fb;
  border-top-color: #1f5fe0;
  animation: step-spin 0.9s linear infinite;
}

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


.db-results {
  display: grid;
  gap: 8px;
}

.db-note {
  margin: 0;
  color: #5f6f86;
  font-size: 13px;
}

.db-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}

.db-card {
  border: 1px solid #d7e2f3;
  border-radius: 10px;
  background: #fff;
  padding: 8px;
  display: grid;
  gap: 6px;
}

.db-card.is-selected {
  border-color: #2f63ca;
  box-shadow: 0 0 0 2px rgba(31, 95, 224, 0.14);
}

.db-thumb-wrap {
  position: relative;
}

.db-thumb {
  width: 100%;
  height: 96px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #d7e2f3;
  background: #f8fbff;
  display: block;
}

.db-thumb-placeholder {
  display: grid;
  place-items: center;
  color: #6b7280;
  font-size: 12px;
}

.db-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  background: #e8f7ee;
  color: #0f9d58;
}

.db-title {
  font-size: 12px;
  color: #334155;
  line-height: 1.3;
  min-height: 32px;
}

.db-select-btn,
.db-more-btn {
  width: 100%;
}

.upload-future {
  display: grid;
  gap: 6px;
}


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

.step-manage-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.step-btn-mini {
  padding: 5px 8px;
  font-size: 12px;
  line-height: 1;
}

.step-edit-box {
  border: 1px solid #d8e3f3;
  border-radius: 10px;
  background: #f7faff;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.step-edit-box label {
  display: grid;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}

.step-edit-box input,
.step-edit-box textarea {
  border-radius: 8px;
  border: 1px solid #c9d7ee;
  background: #fff;
  padding: 8px 10px;
  font: inherit;
  font-size: 14px;
}

.step-edit-box textarea {
  min-height: 70px;
  resize: vertical;
}

.step-edit-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}


.material-auth-hidden {
  display: none;
}


.img-fallback {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 8px;
}

.material-field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #334155;
}

.material-preview-head {
  display: grid;
  gap: 6px;
  margin: 14px 0 12px;
}

.material-preview-caption {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: #667085;
}

.material-preview-title {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.15;
  color: #172033;
}

.material-preview-chain {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 8px;
  align-items: stretch;
}

.material-preview-step {
  min-width: 168px;
  max-width: 196px;
  flex: 0 0 168px;
  display: grid;
  gap: 8px;
}

.material-preview-card {
  background: #fbfdff;
  border: 1px solid #d8e1ee;
  border-radius: 14px;
  padding: 10px;
  display: grid;
  gap: 8px;
  box-shadow: 0 8px 18px rgba(23, 32, 51, 0.05);
}

.material-preview-image,
.material-preview-image-placeholder {
  width: 100%;
  aspect-ratio: 4 / 5;
  border-radius: 12px;
  overflow: hidden;
  background: #edf2f7;
}

.material-preview-image {
  object-fit: cover;
  display: block;
}

.material-preview-image-placeholder {
  display: grid;
  place-items: center;
  text-align: center;
  color: #667085;
  font-size: 13px;
  padding: 12px;
}

.material-preview-card-title {
  font-weight: 700;
  color: #172033;
}

.material-preview-step-title {
  font-size: 13px;
  line-height: 1.4;
  color: #42506a;
}

.material-preview-arrow {
  flex: 0 0 26px;
  align-self: center;
  color: #8aa0c9;
  font-size: 22px;
  font-weight: 800;
  text-align: center;
}

.material-save-row {
  align-items: center;
  flex-wrap: wrap;
}

.material-open-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid #b7c8ea;
  background: #fff;
  color: #1847aa;
  border-radius: 10px;
  font-weight: 700;
  text-decoration: none;
}

@media (max-width: 720px) {
  .material-preview-title {
    font-size: 20px;
  }

  .material-preview-step {
    min-width: 146px;
    flex-basis: 146px;
  }
}
