/* SOP Hub — Notion-style pages + rich editor */

.sop-root {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 60vh;
}
.sop-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  justify-content: space-between;
}
.sop-search {
  flex: 1 1 12rem;
  max-width: 22rem;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel, #111);
  color: var(--text);
  font: inherit;
}
.sop-layout {
  display: grid;
  grid-template-columns: minmax(9rem, 11rem) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}
.sop-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 0;
  max-height: min(70vh, calc(100vh - 11rem));
}
.sop-langs {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 0 0 auto;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  background: var(--bg, #0a0a0a);
}
.sop-lang-label {
  margin: 0 0 0.15rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.sop-lang-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  width: 100%;
  padding: 0.4rem 0.55rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted, #888);
  font: inherit;
  font-size: 0.88rem;
  text-align: left;
  cursor: pointer;
}
.sop-lang-btn:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}
.sop-lang-btn.active {
  border-color: var(--accent, #6cf);
  background: rgba(102, 204, 255, 0.08);
  color: var(--text);
}
.sop-doc-lang-pill,
.sop-page-lang {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted, #888);
}
@media (max-width: 760px) {
  .sop-layout {
    grid-template-columns: 1fr;
  }
  .sop-sidebar {
    max-height: none;
  }
  .sop-cats {
    max-height: 14rem;
  }
}
.sop-cats {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 0.15rem;
}
.sop-cat-btn {
  text-align: left;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}
.sop-cat-btn.active {
  border-color: rgba(251, 146, 60, 0.55);
  background: rgba(251, 146, 60, 0.12);
  color: #fb923c;
}
.sop-cat-btn--add {
  border-style: dashed;
  color: var(--muted);
  text-align: center;
}
.sop-cat-btn--add:hover {
  color: var(--text);
  border-color: var(--accent, rgba(251, 146, 60, 0.55));
}
.sop-cat-count {
  opacity: 0.55;
  font-size: 0.72rem;
  margin-left: 0.25rem;
}
.sop-main {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.sop-sections-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.sop-sections-label {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.72rem;
}
.sop-sections {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.sop-section-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  padding: 0.35rem 0.65rem;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}
.sop-section-btn:hover {
  background: rgba(255, 255, 255, 0.04);
}
.sop-section-btn.active {
  border-color: rgba(102, 204, 255, 0.55);
  background: rgba(102, 204, 255, 0.1);
  color: #9bdcff;
}
.sop-section-btn--muted {
  color: var(--muted, #888);
}
.sop-section-edit {
  margin-left: 0.15rem;
  opacity: 0.55;
  font-size: 0.75rem;
}
.sop-section-edit:hover {
  opacity: 1;
}
.sop-cat-edit {
  margin-left: 0.35rem;
  opacity: 0.55;
  font-size: 0.75rem;
}
.sop-cat-edit:hover {
  opacity: 1;
}
.sop-access-summary {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--ops-border, rgba(255, 255, 255, 0.1));
}
.sop-access-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.sop-access-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.78rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.sop-access-chip--person {
  background: rgba(96, 165, 250, 0.12);
  border-color: rgba(96, 165, 250, 0.3);
}
.sop-access-chip--rank {
  background: rgba(52, 211, 153, 0.1);
  border-color: rgba(52, 211, 153, 0.28);
}
.sop-access-chip-src {
  opacity: 0.65;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.sop-section-delete {
  margin-left: 0.1rem;
  opacity: 0.45;
  font-size: 0.85rem;
  line-height: 1;
}
.sop-section-delete:hover {
  opacity: 1;
  color: #f87171;
}
.sop-section-modal-danger {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px dashed var(--border, rgba(255, 255, 255, 0.12));
}
.sop-doc-section-pill {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  background: rgba(102, 204, 255, 0.1);
  color: #9bdcff;
}
.sop-doc-group-title {
  margin: 0 0 0.45rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.sop-doc-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.sop-doc-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, opacity 0.15s ease;
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
}
.sop-doc-card--dragging {
  opacity: 0.55;
  border-color: rgba(251, 146, 60, 0.65);
}
.sop-doc-drag {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: grab;
  padding: 0.15rem 0.1rem 0 0;
  user-select: none;
}
.sop-doc-drag:active {
  cursor: grabbing;
}
.sop-doc-card-body {
  flex: 1;
  min-width: 0;
}
.sop-doc-card-actions {
  flex-shrink: 0;
  align-self: center;
  margin-left: auto;
  padding-left: 0.5rem;
}
.sop-doc-edit {
  white-space: nowrap;
}
.sop-doc-card:hover {
  border-color: rgba(251, 146, 60, 0.45);
  background: rgba(255, 255, 255, 0.04);
}
.sop-doc-cat-pill {
  display: inline-block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #fb923c;
  margin-bottom: 0.25rem;
}
.sop-doc-card-title {
  font-weight: 600;
  margin: 0 0 0.2rem;
  font-size: 0.95rem;
}
.sop-doc-card-meta {
  font-size: 0.72rem;
  color: var(--muted);
}
.sop-doc-preview {
  margin-top: 0.35rem;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Notion-like page */
.sop-page-view .sop-page,
.sop-page-edit .sop-page {
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
}
.sop-page-cat {
  display: inline-block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #fb923c;
  margin-bottom: 0.35rem;
}
.sop-page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.65rem;
}
.sop-page-title {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.sop-page-title-input {
  font-size: 1.35rem;
  font-weight: 600;
  width: 100%;
}
.sop-page-meta {
  margin: 0.35rem 0 1.25rem;
}
.sop-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* Prose (view + editor) */
.sop-prose {
  line-height: 1.65;
  word-break: break-word;
  color: var(--text);
}
.sop-prose p {
  margin: 0.55rem 0;
}
.sop-prose h1,
.sop-prose h2,
.sop-prose h3 {
  margin: 1.25rem 0 0.45rem;
  line-height: 1.25;
  font-weight: 700;
}
.sop-prose h1 { font-size: 1.5rem; }
.sop-prose h2 { font-size: 1.25rem; }
.sop-prose h3 { font-size: 1.05rem; }
.sop-prose ul,
.sop-prose ol {
  margin: 0.5rem 0 0.5rem 1.35rem;
  padding: 0;
}
.sop-prose li {
  margin: 0.25rem 0;
}
.sop-prose blockquote {
  margin: 0.75rem 0;
  padding: 0.35rem 0 0.35rem 0.85rem;
  border-left: 3px solid rgba(251, 146, 60, 0.5);
  color: var(--muted);
}
.sop-prose a {
  color: #60a5fa;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.sop-prose code {
  background: rgba(255, 255, 255, 0.06);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.sop-prose pre.sop-code-block {
  margin: 0.85rem 0;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.sop-prose pre.sop-code-block code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-size: 0.88em;
  white-space: pre-wrap;
}
.sop-prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}
.sop-prose table.sop-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.85rem 0;
  font-size: 0.92em;
}
.sop-prose table.sop-table th,
.sop-prose table.sop-table td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.55rem;
  text-align: left;
  vertical-align: top;
}
.sop-prose table.sop-table th {
  background: rgba(255, 255, 255, 0.04);
  font-weight: 600;
}
.sop-prose ul.sop-todo {
  list-style: none;
  margin: 0.5rem 0;
  padding: 0;
}
.sop-prose ul.sop-todo li {
  position: relative;
  padding-left: 1.35rem;
  margin: 0.3rem 0;
}
.sop-prose ul.sop-todo li.sop-todo-open::before {
  content: "☐";
  position: absolute;
  left: 0;
}
.sop-prose ul.sop-todo li.sop-todo-done::before {
  content: "☑";
  position: absolute;
  left: 0;
}
.sop-prose img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 0.65rem 0;
}
.sop-image-wrap {
  position: relative;
  display: block;
  margin: 1rem 0;
  max-width: 100%;
  line-height: 0;
}
.sop-image-wrap img.sop-hosted-image,
.sop-image-wrap img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0;
  border-radius: 8px;
}
.sop-image-wrap--selected {
  outline: 2px solid rgba(251, 146, 60, 0.85);
  outline-offset: 2px;
  border-radius: 10px;
}
.sop-image-resize-handle {
  display: none;
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: rgba(251, 146, 60, 0.95);
  border: 2px solid #fff;
  cursor: nwse-resize;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.sop-image-wrap--selected .sop-image-resize-handle {
  display: block;
}
.sop-image-remove {
  display: none;
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  z-index: 2;
  border: 0;
  border-radius: 8px;
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
}
.sop-image-wrap--selected .sop-image-remove {
  display: block;
}
.sop-image-remove:hover {
  background: rgba(180, 40, 40, 0.92);
}
.sop-rich-surface.sop-drag-over {
  outline: 2px dashed rgba(251, 146, 60, 0.75);
  outline-offset: -6px;
  background: rgba(251, 146, 60, 0.06);
}
.sop-rich-surface.sop-drop-caret-active {
  cursor: copy;
}
.sop-drop-caret {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  margin: 0;
  padding: 0;
  border: none;
  background: linear-gradient(90deg, #a78bfa 0%, rgba(167, 139, 250, 0.45) 100%);
  box-shadow: 0 0 10px rgba(124, 58, 237, 0.55);
  pointer-events: none;
  z-index: 12;
}
.sop-drop-caret::before {
  content: "";
  position: absolute;
  left: 0.2rem;
  top: -10px;
  width: 3px;
  height: 22px;
  border-radius: 2px;
  background: #c4b5fd;
  box-shadow: 0 0 0 1px rgba(167, 139, 250, 0.45), 0 0 14px rgba(124, 58, 237, 0.65);
}
.sop-drop-caret::after {
  content: "";
  position: absolute;
  left: 0.55rem;
  top: -4px;
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 7px solid #c4b5fd;
  filter: drop-shadow(0 0 4px rgba(124, 58, 237, 0.5));
}
.sop-video-wrap {
  position: relative;
  margin: 1rem 0;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  max-width: 100%;
}
.sop-prose video.sop-hosted-video,
.sop-video-wrap video {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(70vh, 480px);
  object-fit: contain;
  background: #000;
}
.sop-video-remove {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  z-index: 2;
  border: 0;
  border-radius: 8px;
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
}
.sop-video-remove:hover {
  background: rgba(180, 40, 40, 0.92);
}
.sop-video-error {
  margin: 0;
  padding: 0.65rem 0.85rem;
  background: rgba(255, 255, 255, 0.08);
}

.sop-video-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0.55rem 0.75rem 0.75rem;
  padding: 0.55rem 0.95rem;
  min-height: 44px;
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: inherit;
  line-height: 1.2;
  color: #e9d5ff;
  text-decoration: none;
  border: 1px solid rgba(167, 139, 250, 0.45);
  border-radius: 10px;
  background: rgba(124, 58, 237, 0.18);
  cursor: pointer;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: rgba(167, 139, 250, 0.25);
}

.sop-video-download:hover,
.sop-video-download:focus-visible {
  color: #fff;
  background: rgba(124, 58, 237, 0.35);
  outline: none;
}

.sop-upload-progress {
  margin: 0.65rem 0 0.85rem;
  padding: 0.75rem 0.85rem;
  border-radius: 10px;
  background: rgba(251, 146, 60, 0.1);
  border: 1px solid var(--border);
}
.sop-upload-progress--busy {
  border-color: rgba(251, 146, 60, 0.55);
  background: rgba(251, 146, 60, 0.14);
  box-shadow: 0 0 0 1px rgba(251, 146, 60, 0.12);
}
.sop-upload-progress-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.45rem;
}
.sop-upload-progress--busy .sop-upload-progress-label {
  color: var(--text, #f3f4f6);
}
.sop-upload-progress--indeterminate .sop-upload-progress-fill {
  width: 35% !important;
  animation: sop-upload-indeterminate 1.1s ease-in-out infinite;
}
@keyframes sop-upload-indeterminate {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}
.sop-video-loading {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 0.85rem;
}
.sop-video-loading-spinner {
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fb923c;
  animation: sop-video-spin 0.8s linear infinite;
}
@keyframes sop-video-spin {
  to { transform: rotate(360deg); }
}
.sop-upload-progress-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.sop-upload-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #fb923c, #f97316);
  transition: width 0.12s ease;
}
.sop-upload-progress-label {
  font-size: 0.875rem;
  color: var(--muted, #888);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sop-upload-progress-pct {
  flex-shrink: 0;
  font-size: 0.875rem;
  font-weight: 700;
  color: #fb923c;
}
.sop-rich-surface > p {
  min-height: 1.45em;
}
.sop-media-placeholder {
  color: var(--muted, #888);
  font-size: 0.85rem;
  padding: 0.5rem 0.75rem;
  border: 1px dashed var(--border);
  border-radius: 8px;
}
.sop-page-body {
  padding-bottom: 2rem;
}

/* Loom embed — inline player, responsive */
.sop-loom-wrap {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  height: 0;
  margin: 1.25rem 0;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.sop-loom-wrap iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.sop-loom-fs-btn {
  position: absolute;
  top: 0.55rem;
  left: 0.55rem;
  z-index: 3;
  border: 0;
  border-radius: 8px;
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  -webkit-tap-highlight-color: transparent;
}
.sop-loom-fs-btn:hover,
.sop-loom-fs-btn:focus-visible {
  background: rgba(40, 90, 200, 0.92);
  outline: none;
}
.sop-loom-wrap:fullscreen,
.sop-loom-wrap:-webkit-full-screen,
.sop-loom-wrap--page-fs {
  position: fixed !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-height: 100dvh !important;
  padding-bottom: 0 !important;
  margin: 0 !important;
  border-radius: 0 !important;
  z-index: 10050;
  box-shadow: none;
}
.sop-loom-wrap:fullscreen iframe,
.sop-loom-wrap:-webkit-full-screen iframe,
.sop-loom-wrap--page-fs iframe {
  border-radius: 0;
}
html.sop-loom-page-fs-lock {
  overflow: hidden;
}
.sop-loom-remove {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  z-index: 2;
  border: 0;
  border-radius: 8px;
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
}
.sop-loom-remove:hover {
  background: rgba(180, 40, 40, 0.92);
}

.sop-pdf-wrap {
  margin: 1.25rem 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.02);
}
.sop-pdf-wrap iframe.sop-hosted-pdf {
  display: block;
  width: 100%;
  min-height: 480px;
  height: 70vh;
  max-height: 720px;
  border: 0;
  background: #fff;
}
.sop-pdf-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0.65rem 0.85rem 0.85rem;
  color: var(--accent, #fb923c);
  font-size: 0.85rem;
  text-decoration: none;
}
.sop-pdf-link:hover {
  text-decoration: underline;
}
.sop-pdf-error {
  margin: 0.5rem 0.85rem 0.85rem;
}

/* Rich editor */
.sop-rich-editor {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.02);
}
.sop-rich-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}
.sop-tb-btn {
  border: none;
  background: transparent;
  color: var(--text);
  border-radius: 6px;
  padding: 0.3rem 0.45rem;
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  min-width: 1.75rem;
}
.sop-tb-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}
.sop-tb-strong { font-weight: 700; }
.sop-tb-em { font-style: italic; }
.sop-tb-sep {
  width: 1px;
  height: 1.1rem;
  background: var(--border);
  margin: 0 0.15rem;
}
.sop-rich-hint {
  padding: 0.35rem 0.75rem 0;
}
.sop-rich-surface-wrap {
  position: relative;
}
.sop-rich-surface {
  min-height: 20rem;
  padding: 1rem 1.1rem 1.5rem;
  outline: none;
  position: relative;
  overflow-anchor: none;
}
.sop-rich-surface p,
.sop-rich-surface h2,
.sop-rich-surface h3,
.sop-rich-surface li {
  scroll-margin-block: 1.25rem;
}
.sop-rich-surface:focus {
  box-shadow: inset 0 0 0 1px rgba(251, 146, 60, 0.35);
}
.sop-editor-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.85rem;
}
.sop-edit-topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.sop-edit-topbar .sop-save-status {
  margin-left: auto;
}
.sop-save-status {
  font-size: 0.82rem;
  color: var(--muted, #888);
}
.sop-save-status[data-state="pending"],
.sop-save-status[data-state="saving"] {
  color: var(--accent, #6cf);
}
.sop-save-status[data-state="saved"] {
  color: #6bcf8e;
}
.sop-save-status[data-state="error"] {
  color: #f87171;
}
.sop-title-field {
  margin-bottom: 0.35rem;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.sop-grants {
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  margin-top: 0.75rem;
}
.sop-grants-hint {
  margin: 0 0 0.75rem;
}
.sop-grants-section {
  margin-bottom: 0.85rem;
}
.sop-grants-section:last-child {
  margin-bottom: 0;
}
.sop-grants-section-head {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.4rem;
}
.sop-grants-section-title {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  flex: 1;
}
.sop-grant-checks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.35rem 0.65rem;
  max-height: 11rem;
  overflow-y: auto;
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.15);
}
.sop-grant-check {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  font-size: 0.82rem;
  cursor: pointer;
  line-height: 1.35;
}
.sop-grant-check input {
  margin-top: 0.15rem;
  flex-shrink: 0;
}
.sop-grant-check--inherited {
  opacity: 0.95;
}
.sop-grant-check--inherited input {
  cursor: default;
}
.sop-grant-inherited-badge {
  display: inline-block;
  margin-left: 0.3rem;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.18);
  vertical-align: middle;
}
.sop-grants-always {
  margin: -0.35rem 0 0.65rem;
}
.sop-grant-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  margin-bottom: 0.45rem;
}
.sop-versions {
  margin-top: 1.5rem;
  max-width: 760px;
  border-top: 1px dashed var(--border);
  padding-top: 0.75rem;
}
.sop-version-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0;
  font-size: 0.82rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.sop-empty {
  color: var(--muted);
  padding: 1.5rem 0;
  text-align: center;
}

.sop-global-upload-overlay {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 1.25rem;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.28);
}
.sop-global-upload-overlay[hidden] {
  display: none !important;
}
.sop-global-upload-card {
  width: min(520px, calc(100vw - 2rem));
  padding: 1rem 1.1rem 1.05rem;
  border-radius: 14px;
  border: 1px solid rgba(251, 146, 60, 0.45);
  background: rgba(18, 18, 22, 0.96);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
}
.sop-global-upload-kicker {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fb923c;
  margin-bottom: 0.2rem;
}
.sop-global-upload-title {
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text, #f3f4f6);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sop-global-upload-detail {
  margin: 0.35rem 0 0.65rem;
  font-size: 0.92rem;
  color: var(--muted, #cbd5e1);
}
.sop-global-upload-pct {
  margin-top: 0.45rem;
  font-size: 0.92rem;
  font-weight: 700;
  color: #fb923c;
  text-align: right;
}
.sop-global-upload-track {
  margin-top: 0.15rem;
}
.sop-global-upload-overlay--indeterminate .sop-global-upload-track .sop-upload-progress-fill {
  width: 35% !important;
  animation: sop-upload-indeterminate 1.1s ease-in-out infinite;
}

.sop-video-upload-slot {
  margin: 1rem 0;
  border-radius: 12px;
  border: 1px dashed rgba(251, 146, 60, 0.55);
  background: rgba(251, 146, 60, 0.08);
  overflow: hidden;
}
.sop-video-upload-slot-inner {
  padding: 0.9rem 1rem 1rem;
}
.sop-video-upload-slot-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.sop-video-upload-slot-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.92rem;
}
.sop-video-upload-slot-pct {
  flex-shrink: 0;
  font-size: 0.92rem;
  font-weight: 700;
  color: #fb923c;
}
.sop-video-upload-slot-detail {
  margin: 0.45rem 0 0.65rem;
  font-size: 0.86rem;
  color: var(--muted, #cbd5e1);
}
.sop-video-upload-spinner {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  border: 2px solid rgba(251, 146, 60, 0.25);
  border-top-color: #fb923c;
  animation: sop-video-spin 0.8s linear infinite;
  flex-shrink: 0;
}
