/* AI Autopilot Command Center — premium SaaS layout */

:root {
  --ap-bg: #f4f6f9;
  --ap-surface: #ffffff;
  --ap-border: #e4e9f0;
  --ap-text: #0f172a;
  --ap-muted: #64748b;
  --ap-accent: #0d9488;
  --ap-accent-soft: #ecfdf5;
  --ap-accent-dark: #0f766e;
  --ap-sidebar: #0b1220;
  --ap-sidebar-text: #cbd5e1;
  --ap-sidebar-active: #14b8a6;
  --ap-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.04);
  --ap-radius: 14px;
  --ap-transition: 0.22s ease;
}

body.ap-body {
  margin: 0;
  background: var(--ap-bg);
  color: var(--ap-text);
  overflow-x: hidden;
}

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

.ap-sidebar {
  background: var(--ap-sidebar);
  color: var(--ap-sidebar-text);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 20;
}

.ap-brand {
  padding: 0 8px;
}

.ap-brand .eyebrow {
  color: #94a3b8;
  font-size: 11px;
  letter-spacing: 0.08em;
  margin: 0 0 6px;
}

.ap-brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
  color: #f8fafc;
  font-weight: 700;
}

.ap-brand p {
  margin: 8px 0 0;
  font-size: 13px;
  color: #94a3b8;
  line-height: 1.45;
}

.ap-nav {
  display: grid;
  gap: 4px;
}

.ap-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 10px;
  color: var(--ap-sidebar-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background var(--ap-transition), color var(--ap-transition);
}

.ap-nav a:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #f1f5f9;
}

.ap-nav a.active {
  background: rgba(20, 184, 166, 0.16);
  color: #5eead4;
}

.ap-nav a.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.ap-main {
  min-width: 0;
  overflow-x: hidden;
  padding: clamp(16px, 3vw, 32px);
  padding-bottom: 96px;
}

.ap-page-head {
  margin-bottom: 28px;
}

.ap-clarify-heading {
  margin: 8px 0 0;
  font-size: 16px;
  font-weight: 600;
}

.ap-page-head h2 {
  margin: 6px 0 8px;
  font-size: clamp(24px, 4vw, 32px);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.ap-page-head .lead {
  margin: 0;
  color: var(--ap-muted);
  font-size: 15px;
  line-height: 1.55;
  max-width: 640px;
}

.ap-grid {
  display: grid;
  gap: 20px;
}

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

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

.ap-card {
  background: var(--ap-surface);
  border: 1px solid var(--ap-border);
  border-radius: var(--ap-radius);
  padding: 20px;
  box-shadow: var(--ap-shadow);
  transition: transform var(--ap-transition), box-shadow var(--ap-transition);
}

.ap-card:hover {
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06), 0 12px 32px rgba(15, 23, 42, 0.06);
}

.ap-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.ap-card .ap-card-meta {
  color: var(--ap-muted);
  font-size: 13px;
  margin: 0;
}

.ap-hero-upload {
  padding: clamp(24px, 4vw, 40px);
  text-align: center;
  border: 2px dashed #cbd5e1;
  border-radius: calc(var(--ap-radius) + 4px);
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  transition: border-color var(--ap-transition), background var(--ap-transition);
  cursor: pointer;
}

.ap-hero-upload.dragover {
  border-color: var(--ap-accent);
  background: var(--ap-accent-soft);
}

.ap-hero-upload strong {
  display: block;
  font-size: clamp(18px, 3vw, 22px);
  margin-bottom: 8px;
}

.ap-hero-upload span {
  color: var(--ap-muted);
  font-size: 14px;
}

.ap-upload-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 18px;
}

.ap-btn {
  border: 0;
  border-radius: 10px;
  background: var(--ap-accent);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  transition: background var(--ap-transition), opacity var(--ap-transition), transform var(--ap-transition);
}

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

.ap-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ap-btn.secondary {
  background: #e2e8f0;
  color: var(--ap-text);
}

.ap-btn.secondary:hover {
  background: #cbd5e1;
}

.ap-btn.ghost {
  background: transparent;
  color: var(--ap-accent-dark);
  border: 1px solid var(--ap-border);
}

.ap-btn.block {
  width: 100%;
}

.ap-btn:focus-visible,
.ap-mobile-toggle:focus-visible,
.ap-nav a:focus-visible,
.kr-dropzone:focus-visible,
input:focus-visible,
textarea:focus-visible,
.kr-conflict-choice:focus-within {
  outline: 2px solid var(--ap-accent);
  outline-offset: 2px;
}

.ap-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.ap-note-field {
  margin-top: 20px;
}

.ap-note-field label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.ap-note-field textarea {
  width: 100%;
  border: 1px solid var(--ap-border);
  border-radius: 10px;
  padding: 12px 14px;
  min-height: 88px;
  resize: vertical;
  background: #fff;
}

.ap-file-list {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.ap-file-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--ap-border);
  border-radius: 10px;
  background: #f8fafc;
  font-size: 13px;
}

.ap-thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.ap-thumb-card {
  border: 1px solid var(--ap-border);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  transition: border-color var(--ap-transition), box-shadow var(--ap-transition);
}

.ap-thumb-card.selected {
  border-color: var(--ap-accent);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.ap-thumb-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: #f1f5f9;
  display: block;
}

.ap-thumb-body {
  padding: 10px;
  display: grid;
  gap: 8px;
}

.ap-thumb-name {
  font-size: 11px;
  color: var(--ap-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ap-thumb-note {
  width: 100%;
  border: 1px solid var(--ap-border);
  border-radius: 8px;
  padding: 8px;
  font-size: 12px;
}

.ap-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--ap-muted);
}

.ap-status-pill.ready {
  background: var(--ap-accent-soft);
  color: var(--ap-accent-dark);
}

.ap-status-pill.pending {
  background: #fef3c7;
  color: #b45309;
}

.ap-group-note-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 16px;
  padding: 14px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid var(--ap-border);
}

.ap-timeline {
  display: grid;
  gap: 0;
  margin-top: 8px;
}

.ap-timeline-step {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 12px;
  position: relative;
  padding-bottom: 18px;
}

.ap-timeline-step:last-child {
  padding-bottom: 0;
}

.ap-timeline-step::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 28px;
  bottom: 0;
  width: 2px;
  background: #e2e8f0;
}

.ap-timeline-step:last-child::before {
  display: none;
}

.ap-timeline-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #cbd5e1;
  background: #fff;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--ap-muted);
  z-index: 1;
}

.ap-timeline-step.done .ap-timeline-dot {
  border-color: var(--ap-accent);
  background: var(--ap-accent);
  color: #fff;
}

.ap-timeline-step.active .ap-timeline-dot {
  border-color: var(--ap-accent);
  box-shadow: 0 0 0 4px rgba(13, 148, 136, 0.18);
  animation: ap-pulse 1.8s ease-in-out infinite;
}

.ap-timeline-step.active .ap-timeline-label {
  color: var(--ap-text);
  font-weight: 600;
}

.ap-timeline-label {
  padding-top: 4px;
  font-size: 14px;
  color: var(--ap-muted);
}

@keyframes ap-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(13, 148, 136, 0.18); }
  50% { box-shadow: 0 0 0 8px rgba(13, 148, 136, 0.08); }
}

.ap-skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: ap-shimmer 1.4s ease infinite;
  border-radius: 8px;
  min-height: 16px;
}

@keyframes ap-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.ap-page-card {
  display: flex;
  gap: 16px;
  align-items: center;
}

.ap-page-avatar {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, #0d9488, #0891b2);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
}

.ap-page-avatar.empty {
  background: #e2e8f0;
  color: #64748b;
}

.ap-stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.ap-stat {
  flex: 1 1 100px;
  min-width: 0;
}

.ap-stat strong {
  display: block;
  font-size: 22px;
  line-height: 1.2;
}

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

.ap-badge {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--ap-accent-soft);
  color: var(--ap-accent-dark);
}

.ap-badge.warn {
  background: #fef3c7;
  color: #b45309;
}

.ap-badge.muted {
  background: #f1f5f9;
  color: var(--ap-muted);
}

.ap-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--ap-muted);
}

.ap-clarify-card {
  border-left: 4px solid #f59e0b;
}

.ap-view-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--ap-border);
}

.ap-view-row:last-child {
  border-bottom: 0;
}

.ap-view-label {
  font-size: 13px;
  color: var(--ap-muted);
  min-width: 120px;
}

.ap-view-value {
  flex: 1;
  font-size: 15px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.ap-edit-inline {
  display: none;
  gap: 8px;
  margin-top: 8px;
}

.ap-view-row.editing .ap-edit-inline {
  display: grid;
}

.ap-view-row.editing .ap-view-value-text {
  display: none;
}

.ap-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.ap-filter-chip {
  border: 1px solid var(--ap-border);
  background: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--ap-transition);
}

.ap-filter-chip.active {
  background: var(--ap-accent);
  border-color: var(--ap-accent);
  color: #fff;
}

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

.ap-media-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 10px;
  background: #f1f5f9;
}

.ap-sticky-cta {
  position: fixed;
  left: 240px;
  right: 0;
  bottom: 0;
  padding: 12px clamp(16px, 3vw, 32px);
  background: rgba(244, 246, 249, 0.92);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--ap-border);
  z-index: 15;
  display: flex;
  justify-content: flex-end;
}

.ap-mobile-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 30;
  background: var(--ap-sidebar);
  color: #fff;
  border: 0;
  border-radius: 10px;
  width: 44px;
  height: 44px;
  cursor: pointer;
}

.ap-toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  max-width: min(360px, calc(100vw - 32px));
  background: var(--ap-sidebar);
  color: #fff;
  border-radius: 12px;
  padding: 14px 16px;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
}

.ap-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.ap-product-card {
  padding: 16px;
  border: 1px solid var(--ap-border);
  border-radius: 12px;
  background: #fafbfc;
}

.ap-section-title {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ap-muted);
}

.hidden {
  display: none !important;
}

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

  .ap-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(280px, 86vw);
    transform: translateX(-110%);
    transition: transform var(--ap-transition);
    box-shadow: var(--ap-shadow);
  }

  .ap-sidebar.open {
    transform: translateX(0);
  }

  .ap-mobile-toggle {
    display: grid;
    place-items: center;
  }

  .ap-main {
    padding-top: 64px;
  }

  .ap-sticky-cta {
    left: 0;
  }

  .ap-grid.two,
  .ap-grid.three {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 480px) {
  .ap-page-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .ap-sticky-cta {
    justify-content: stretch;
  }

  .ap-sticky-cta .ap-btn {
    flex: 1;
  }
}

.ap-plan-card {
  display: grid;
  gap: 14px;
}

.ap-plan-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.ap-plan-topic {
  margin: 0;
  font-size: 18px;
  line-height: 1.35;
  word-break: break-word;
}

.ap-plan-assets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ap-plan-asset {
  width: 88px;
  height: 110px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--ap-border);
  background: #f8fafc;
}

.ap-plan-asset.missing {
  display: grid;
  place-items: center;
  font-size: 11px;
  color: var(--ap-muted);
}

.ap-plan-block {
  min-width: 0;
}

.ap-plan-textarea,
.ap-plan-copy {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  font: inherit;
  line-height: 1.5;
}

.ap-plan-textarea {
  border: 1px solid var(--ap-border);
  border-radius: 10px;
  padding: 10px 12px;
  resize: vertical;
  min-height: 120px;
}

.ap-plan-copy {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.ap-plan-copy.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}

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

.ap-plan-actions .ap-btn {
  flex: 1 1 auto;
  min-width: 0;
}

.ap-warn {
  color: #b45309;
}

.ap-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 16px;
}

.ap-modal-card {
  background: var(--ap-surface);
  border-radius: var(--ap-radius);
  box-shadow: var(--ap-shadow);
  padding: 20px;
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.ap-progress-steps {
  display: grid;
  gap: 6px;
  margin: 8px 0;
}

.ap-progress-step {
  font-size: 13px;
  color: var(--ap-muted);
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--ap-border);
}

.ap-progress-step.active {
  border-color: var(--ap-accent);
  background: var(--ap-accent-soft);
  color: var(--ap-accent-dark);
  font-weight: 600;
}

.ap-progress-step.done {
  color: var(--ap-accent-dark);
  border-color: #99f6e4;
}

.ap-activity-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--ap-border);
  font-size: 13px;
}

.ap-activity-item:last-child {
  border-bottom: none;
}

.ap-preview-img {
  width: 100%;
  max-width: 280px;
  border-radius: 10px;
  border: 1px solid var(--ap-border);
}

/* M3B Knowledge Review */
.kr-screen.hidden {
  display: none;
}

.kr-dropzone.dragover {
  border-color: var(--ap-accent);
  background: var(--ap-accent-soft);
}

.kr-start-actions {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.kr-progress-steps {
  display: grid;
  gap: 10px;
  margin: 12px 0 16px;
}

.kr-progress-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f8fafc;
  color: var(--ap-muted);
  font-size: 14px;
}

.kr-progress-step.active {
  background: var(--ap-accent-soft);
  color: var(--ap-accent-dark);
  font-weight: 600;
}

.kr-progress-step.done {
  color: var(--ap-text);
}

.kr-progress-dot {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e2e8f0;
  font-size: 12px;
  flex-shrink: 0;
}

.kr-progress-step.active .kr-progress-dot {
  background: var(--ap-accent);
  color: #fff;
}

.kr-progress-step.done .kr-progress-dot {
  background: #10b981;
  color: #fff;
}

.kr-progress-current {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}

.kr-error {
  margin-top: 16px;
  padding: 12px;
  border-radius: 10px;
  background: #fef2f2;
  color: #991b1b;
}

.kr-group {
  margin-bottom: 12px;
}

.kr-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.kr-group-head h3 {
  margin: 0;
  font-size: 16px;
}

.kr-count {
  display: inline-flex;
  min-width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #e2e8f0;
  font-size: 13px;
  font-weight: 700;
}

.kr-count.warn {
  background: #fef3c7;
  color: #92400e;
}

.kr-count.danger {
  background: #fee2e2;
  color: #991b1b;
}

.kr-fact-list {
  display: grid;
  gap: 10px;
}

.kr-fact-card {
  padding: 12px;
  border: 1px solid var(--ap-border);
  border-radius: 12px;
  background: #fff;
}

.kr-fact-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
}

.kr-fact-label {
  font-weight: 600;
  font-size: 14px;
}

.kr-fact-meta {
  font-size: 12px;
  color: var(--ap-muted);
}

.kr-fact-value {
  margin: 0;
  font-size: 15px;
  line-height: 1.45;
  word-break: break-word;
}

.kr-fact-actions,
.kr-inline-edit,
.kr-conflict-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  align-items: center;
}

.kr-inline-edit {
  width: 100%;
}

.kr-edit-input,
.kr-custom-value {
  flex: 1;
  min-width: 160px;
  min-height: 40px;
  border: 1px solid var(--ap-border);
  border-radius: 10px;
  padding: 8px 12px;
  font: inherit;
}

.kr-conflict-choice {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--ap-border);
  border-radius: 10px;
  font-size: 14px;
}

.kr-confirm-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

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

.kr-confirm-footer {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

.kr-complete-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.kr-stat {
  text-align: center;
  padding: 12px 8px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid var(--ap-border);
}

.kr-stat strong {
  display: block;
  font-size: 22px;
  margin-bottom: 4px;
}

.kr-stat span {
  font-size: 12px;
  color: var(--ap-muted);
}

@media (max-width: 640px) {
  .kr-complete-stats {
    grid-template-columns: 1fr;
  }

  .kr-fact-actions .ap-btn {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
  }

  .kr-confirm-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .kr-confirm-toolbar .ap-btn {
    width: 100%;
  }
}

/* M3D — knowledge review QA */
.kr-stale-banner {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
  font-size: 14px;
  line-height: 1.45;
}

.kr-stale-banner.hidden,
.kr-progress-busy.hidden {
  display: none;
}

.kr-progress-busy {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  color: var(--ap-muted);
  font-size: 14px;
}

.kr-loading-spinner {
  width: 22px;
  height: 22px;
  border: 2px solid #e2e8f0;
  border-top-color: var(--ap-accent);
  border-radius: 999px;
  animation: kr-spin 0.75s linear infinite;
  flex-shrink: 0;
}

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

.kr-btn-compact {
  min-height: 44px;
  font-size: 13px;
  padding: 0 12px;
  margin-top: 8px;
}

.kr-fact-label,
.kr-fact-meta,
.kr-fact-value,
.kr-conflict-choice span,
.kr-conflict-choice small {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.kr-conflict-choice {
  min-height: 44px;
  cursor: pointer;
}

.kr-conflict-choice input[type="radio"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin: 2px 0 0;
}

.kr-edit-input:focus-visible,
.kr-custom-value:focus-visible {
  outline: 2px solid var(--ap-accent);
  outline-offset: 1px;
}

.ap-main[aria-busy="true"] .kr-screen:not(.hidden) {
  opacity: 0.92;
}

/* M4F — structured content planning UI */
.cp-main {
  min-width: 0;
  min-height: 0;
}

.cp-stale-banner {
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #9a3412;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
  overflow-wrap: anywhere;
}

.cp-generate-form {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.cp-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.cp-field span {
  font-size: 13px;
  color: var(--ap-muted, #64748b);
}

.cp-field input,
.cp-field select,
.cp-input {
  min-height: 44px;
  min-width: 0;
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 10px;
  overflow-wrap: anywhere;
}

.cp-error {
  margin-top: 12px;
  padding: 10px;
  border-radius: 8px;
  background: #fef2f2;
  border: 1px solid #fecaca;
}

.cp-plan-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  min-width: 0;
}

.cp-plan-toolbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.cp-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  min-width: 0;
  min-height: 0;
}

@media (min-width: 1024px) {
  .cp-workspace {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  }
}

.cp-list-pane {
  min-width: 0;
  min-height: 0;
}

.cp-item-list {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.cp-plan-card {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px;
  min-width: 0;
  overflow: hidden;
  background: #fff;
}

.cp-plan-card.selected {
  border-color: var(--ap-accent, #2563eb);
  box-shadow: 0 0 0 1px var(--ap-accent, #2563eb);
}

.cp-plan-card.disabled {
  opacity: 0.72;
}

.cp-card-grid {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 10px;
  min-width: 0;
}

.cp-card-body {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.cp-card-title {
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.cp-card-angle {
  margin: 0;
  font-size: 13px;
  color: #475569;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-all;
}

.cp-card-product {
  margin: 0;
  font-size: 12px;
  color: #64748b;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-all;
  min-width: 0;
}

.cp-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: #64748b;
  min-width: 0;
}

.cp-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.cp-btn-compact {
  min-height: 44px;
  font-size: 13px;
  padding: 0 10px;
}

.cp-layout-preview {
  position: relative;
  width: 100%;
  max-width: 96px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  min-width: 0;
  overflow: hidden;
}

.cp-layout-preview[data-broken="1"] {
  background: #fef2f2;
  border-color: #fecaca;
}

.cp-layout-frames {
  display: grid;
  gap: 4px;
  padding: 6px;
  min-width: 0;
  min-height: 0;
}

.cp-layout-frame {
  background: linear-gradient(135deg, #e2e8f0, #f1f5f9);
  border-radius: 4px;
  min-height: 12px;
}

.cp-layout-meta {
  display: block;
  font-size: 10px;
  color: #64748b;
  padding: 0 6px 6px;
  overflow-wrap: anywhere;
}

.cp-detail-panel {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  min-width: 0;
  max-height: calc(100vh - 180px);
  overflow: auto;
}

.cp-detail-inner {
  padding: 12px;
  min-width: 0;
}

.cp-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.cp-detail-head h3 {
  margin: 0;
  font-size: 16px;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cp-detail-dl {
  display: grid;
  gap: 10px;
  margin: 12px 0;
  min-width: 0;
}

.cp-detail-dl dt {
  font-size: 12px;
  color: #64748b;
}

.cp-detail-dl dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
  min-width: 0;
}

.cp-detail-caption {
  max-height: 240px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.cp-clamp-1 {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cp-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cp-mobile-sheet {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 40;
  display: flex;
  align-items: flex-end;
}

.cp-mobile-sheet-body {
  width: 100%;
  max-height: 92vh;
  overflow: auto;
  background: #fff;
  border-radius: 16px 16px 0 0;
  min-width: 0;
}

.cp-skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 37%, #f1f5f9 63%);
  background-size: 400% 100%;
  animation: cp-shimmer 1.2s ease infinite;
  border-radius: 8px;
  min-height: 14px;
}

.cp-skeleton-head {
  height: 22px;
  width: 60%;
}

.cp-skeleton-line.short {
  width: 40%;
}

.cp-generating-label {
  margin-top: 12px;
  font-size: 14px;
  color: #475569;
}

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

.cp-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 12px;
}

.cp-list-footer {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-width: 0;
}
