/* X-Tract Playground — styled to match ai_clipping_poc_overview.html */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Avenir', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  color: #333;
  background-color: #ffffff;
  min-height: 100vh;
}

/* Header section */
.header-section {
  background: linear-gradient(135deg, #084C64 0%, #0A5F7A 100%);
  padding: 48px 0 56px;
  color: #ffffff;
  position: relative;
  overflow: hidden;
}

.header-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><rect width="100" height="100" fill="none"/><circle cx="50" cy="50" r="40" stroke="rgba(255,255,255,0.05)" stroke-width="2" fill="none"/></svg>');
  opacity: 0.1;
}

.header-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  margin-bottom: 28px;
  position: relative;
  z-index: 1;
}

.header-nav-link {
  color: rgba(255, 255, 255, 0.85);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.header-nav-link:hover {
  color: #F6DD00;
}

.header-nav-link.is-active {
  color: #F6DD00;
  border-bottom-color: #F6DD00;
}

.header-nav-link-external span {
  font-size: 0.85em;
  opacity: 0.75;
}

.header-job-context {
  margin-left: auto;
  min-width: 0;
  max-width: min(42rem, 100%);
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.85rem;
  line-height: 1.3;
}

.header-user {
  position: relative;
  margin-left: auto;
  z-index: 2;
}

.header-job-context + .header-user {
  margin-left: 0;
}

.header-section:has(.header-user[open]) {
  overflow: visible;
  z-index: 100;
}

.header-user-badge {
  list-style: none;
  cursor: pointer;
}

.header-user-badge::-webkit-details-marker {
  display: none;
}

.header-user-badge:hover,
.header-user-badge:focus-visible,
.header-user[open] .header-user-badge {
  filter: brightness(0.96);
  outline: none;
}

.header-user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 10rem;
  padding: 10px 12px;
  border: 1px solid #e0e6ea;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 28px rgba(16, 24, 40, 0.14);
}

.header-user-menu-name {
  color: #084C64;
  font-size: 0.85rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-logout-form {
  margin: 0;
}

.header-logout-button {
  display: block;
  width: 100%;
  background: none;
  border: 0;
  padding: 6px 0;
  color: #555;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
}

.header-logout-button:hover,
.header-logout-button:focus-visible {
  color: #084C64;
  outline: none;
}

.header-section h1 {
  font-size: 2.4em;
  font-weight: 600;
  margin-bottom: 12px;
  position: relative;
  z-index: 1;
  color: #ffffff;
  line-height: 1.2;
}

.header-section h1:has(.header-job-heading) {
  font-size: 1.5em;
  font-weight: 700;
  margin-bottom: 8px;
  line-height: 1.35;
}

.header-job-heading {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: baseline;
  gap: 0.35em 0.45em;
  max-width: 100%;
  min-width: 0;
}

.header-job-label {
  white-space: nowrap;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
}

.header-job-sep {
  color: rgba(255, 255, 255, 0.45);
  font-weight: 400;
  user-select: none;
}

.header-section .subtitle {
  font-size: 1.15em;
  font-weight: 300;
  color: rgba(255, 255, 255, 0.95);
  position: relative;
  z-index: 1;
  max-width: 800px;
  margin-bottom: 0;
}

.header-section .subtitle:empty {
  display: none;
}

.header-job-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 18px;
}

.header-job-source {
  font-weight: 600;
  color: #ffffff;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-section .header-job-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 500;
  font-size: 0.95em;
  word-break: break-all;
}

.header-section.header-compact {
  padding: 10px 0;
}

.header-section.header-compact .container {
  max-width: min(2256px, calc(100vw - 40px));
}

.header-section.header-compact .header-nav {
  margin-bottom: 0;
  gap: 6px 16px;
}

.header-section.header-compact .header-nav-link {
  font-size: 0.85rem;
}

.header-section.header-compact .header-job-context {
  font-size: 0.8rem;
}


a {
  color: #084C64;
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: #0A5F7A;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.container-narrow {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Main layout */
.page-content {
  padding: 24px 0 40px;
}

.page-content.bg-light {
  background-color: #f8f9fa;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.layout-column {
  display: flex;
  flex-direction: column;
  gap: 30px;
  min-width: 0;
}

.layout-stacked {
  display: flex;
  flex-direction: column;
  gap: 30px;
}

.layout-stacked .page-preview {
  position: static;
}

.layout-stacked .overlay-wrap {
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}

/* Dual-pane page detail: fill the viewport; columns scroll independently. */
body.page-detail-view {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  height: 100dvh;
  overflow: hidden;
}

body.page-detail-view .header-section,
body.page-detail-view .layout-single > .page-chrome {
  flex-shrink: 0;
}

body.page-detail-view .page-content,
body.page-detail-view .layout-single {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body.page-detail-view .page-content {
  padding-top: 12px;
  padding-bottom: 12px;
}

.page-detail-layout {
  --articles-panel-pct: 48%;
  display: grid;
  grid-template-columns: var(--articles-panel-pct) 16px minmax(0, 1fr);
  gap: 0;
  column-gap: 8px;
  align-items: stretch;
  max-width: min(2256px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 0 20px;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  width: 100%;
  overflow: hidden;
}

.layout-single > .page-detail-layout {
  max-width: none;
  padding-left: 0;
  padding-right: 0;
}

.page-detail-layout .articles-panel {
  grid-column: 1;
  min-width: 0;
  min-height: 0;
  width: 100%;
  max-width: none;
  overflow-x: hidden;
  overflow-y: scroll;
  overscroll-behavior: contain;
}

.page-detail-layout .page-preview {
  grid-column: 3;
  grid-row: 1;
  position: relative;
  top: auto;
  align-self: stretch;
  width: 100%;
  max-width: none;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.page-preview-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.page-process-form {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
}

.page-process-form .checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
}

.page-preview-clip-pending {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin: 0;
}

/* Beat `.inline-form { display: inline }` so the popup positions correctly. */
.page-preview-clip-pending.inline-form {
  display: inline-flex;
}

.page-preview-clip-pending[hidden] {
  display: none !important;
}

.page-preview-clip-pending-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: max-content;
  min-width: 16rem;
  max-width: min(22rem, calc(100vw - 24px));
  padding: 10px;
  border: 1px solid #e0e6ea;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 28px rgba(16, 24, 40, 0.14);
}

.page-preview-clip-pending-menu[hidden] {
  display: none;
}

.page-preview-clip-pending-menu .classification-model-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  font-size: 0.85rem;
}

.page-preview-clip-pending-menu .classification-model-field select {
  width: 100%;
  margin: 0;
  padding: 8px 10px;
}

.page-preview-header-actions {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

/* While drawing a new article, only show the draw controls. */
body.is-drawing-article .page-preview-header-actions > .page-preview-clip-pending,
body.is-drawing-article .page-preview-draw-toolbar > [data-draw-start],
body.is-drawing-article .page-preview-draw-toolbar > [data-delete-article-form] {
  display: none !important;
}

.page-preview-cutout-close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #084C64;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.page-preview-cutout-close:hover,
.page-preview-cutout-close:focus-visible {
  background: #084C64;
  color: #ffffff;
  outline: none;
  transform: none;
  box-shadow: none;
}

.page-preview-cutout[hidden] {
  display: none;
}

.page-preview-cutout-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-bottom: 12px;
}

.page-preview-cutout-title {
  flex: 1 1 12rem;
  margin: 0;
  font-size: 0.95rem;
  color: #084C64;
  min-width: 0;
}

.page-preview-cutout .image-zoom-toolbar {
  margin-left: auto;
}

.page-preview-cutout-stage {
  width: 100%;
  max-height: min(calc(100vh - 220px), 900px);
  background: #f4f7f8;
}

.page-preview-cutout-stage .image-zoom-content {
  display: block;
  width: 100%;
}

.page-preview-cutout-stage .image-zoom-content img {
  background: #ffffff;
}

.page-preview.is-showing-cutout .page-preview-cutout-stage {
  max-height: min(calc(100vh - 200px), 960px);
}

.page-detail-layout .page-preview-header {
  flex-shrink: 0;
}

.page-detail-layout .page-preview-page {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: scroll;
  overscroll-behavior: contain;
}

.page-detail-layout .page-preview-page[hidden] {
  display: none;
}

.page-detail-layout .page-preview-cutout:not([hidden]) {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.page-detail-layout .page-preview-cutout-toolbar {
  flex-shrink: 0;
}

.page-detail-layout .page-preview-cutout-stage,
.page-detail-layout .page-preview.is-showing-cutout .page-preview-cutout-stage {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  width: 100%;
  max-height: none;
  overflow-x: hidden;
  overflow-y: scroll;
  overscroll-behavior: contain;
}

/* Always reserve scrollbar space (white track when idle) so panel width never jumps. */
.page-detail-layout .articles-panel,
.page-detail-layout .page-preview-page,
.page-detail-layout .page-preview-cutout-stage {
  scrollbar-width: thin;
  scrollbar-color: #d5dce0 #ffffff;
}

.page-detail-layout .articles-panel::-webkit-scrollbar,
.page-detail-layout .page-preview-page::-webkit-scrollbar,
.page-detail-layout .page-preview-cutout-stage::-webkit-scrollbar {
  width: 10px;
}

.page-detail-layout .articles-panel::-webkit-scrollbar-track,
.page-detail-layout .page-preview-page::-webkit-scrollbar-track,
.page-detail-layout .page-preview-cutout-stage::-webkit-scrollbar-track {
  background: #ffffff;
}

.page-detail-layout .articles-panel::-webkit-scrollbar-thumb,
.page-detail-layout .page-preview-page::-webkit-scrollbar-thumb,
.page-detail-layout .page-preview-cutout-stage::-webkit-scrollbar-thumb {
  background-color: #d5dce0;
  border: 2px solid #ffffff;
  border-radius: 5px;
  background-clip: padding-box;
}

.page-detail-layout .articles-panel::-webkit-scrollbar-thumb:hover,
.page-detail-layout .page-preview-page::-webkit-scrollbar-thumb:hover,
.page-detail-layout .page-preview-cutout-stage::-webkit-scrollbar-thumb:hover {
  background-color: #c5d0d6;
}

.page-detail-layout .page-preview-cutout-stage .image-zoom-content,
.page-detail-layout .page-preview-cutout-stage .image-zoom-content img {
  display: block;
  width: 100%;
  height: auto;
}

.page-detail-resize-handle {
  grid-column: 2;
  grid-row: 1;
  position: relative;
  align-self: stretch;
  min-height: 120px;
  width: 100%;
  cursor: ew-resize;
  touch-action: none;
  z-index: 3;
}

.page-detail-resize-handle::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 4px;
  height: 48px;
  border-radius: 4px;
  background: linear-gradient(180deg, #c5d0d6 0%, #084C64 50%, #c5d0d6 100%);
  opacity: 0.55;
  transition: opacity 0.15s ease;
}

.page-detail-resize-handle:hover::after,
.page-detail-resize-handle:focus-visible::after,
.page-detail-resize-handle.is-dragging::after {
  opacity: 1;
}

.page-detail-resize-handle:focus-visible {
  outline: none;
}

body.page-preview-resizing {
  cursor: ew-resize;
  user-select: none;
}

body.page-preview-resizing iframe,
body.page-preview-resizing img {
  pointer-events: none;
}

.page-detail-layout .panel:not(.articles-panel) {
  padding: 14px 16px;
}

.page-detail-layout .articles-panel {
  padding: 0 16px 14px;
}

.page-detail-layout .overlay-wrap {
  position: relative;
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 0 0 16px;
}

.page-detail-layout .overlay-wrap img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
}

.page-detail-layout .articles-panel table {
  width: 100%;
}

.page-detail-layout .articles-panel .article-text {
  max-width: none;
  width: 100%;
}

.page-detail-layout .articles-panel .segment-image,
.page-detail-layout .articles-panel .article-card img.segment-image {
  width: auto;
  max-width: 100%;
  height: auto;
}

.article-text {
  margin-top: 8px;
  max-width: 48rem;
  font-family: Georgia, 'Times New Roman', Times, serif;
  color: #222;
}

.article-segment {
  display: grid;
  grid-template-columns: 2.75rem minmax(0, 1fr);
  gap: 0.35rem 0.65rem;
  align-items: start;
  margin-bottom: 0.55em;
  border-left: 2px solid #d5dce0;
  padding-left: 0.55rem;
}

.article-segment:last-child {
  margin-bottom: 0;
}

.segment-label {
  display: inline-block;
  padding: 0;
  border-radius: 0;
  font-family: 'Avenir', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 0.58rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: left;
  align-self: start;
  margin-top: 0.35em;
  background: none;
  color: #5a6a72;
  word-break: break-word;
}

.segment-text {
  margin: 0;
  padding: 0;
  line-height: 1.55;
  white-space: pre-wrap;
}

.article-segment.segment-h .segment-text {
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: #111;
}

.article-segment.segment-h {
  margin-bottom: 0.35em;
}

.article-segment.segment-s .segment-text,
.article-segment.segment-ss .segment-text,
.article-segment.segment-fs .segment-text {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.35;
  color: #333;
}

.article-segment.segment-s,
.article-segment.segment-ss,
.article-segment.segment-fs {
  margin-bottom: 0.45em;
}

.article-segment.segment-b .segment-text,
.article-segment.segment-fb .segment-text {
  font-family: 'Avenir', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 0.82rem;
  font-style: italic;
  line-height: 1.4;
  color: #666;
}

.article-segment.segment-b,
.article-segment.segment-fb {
  margin-bottom: 0.85em;
}

.article-segment.segment-t .segment-text {
  font-size: 0.98rem;
  line-height: 1.62;
  color: #222;
}

.article-segment.segment-t {
  margin-bottom: 0.65em;
}

.article-segment.segment-c .segment-text,
.article-segment.segment-r .segment-text {
  font-family: 'Avenir', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 0.8rem;
  line-height: 1.45;
  color: #777;
}

.article-segment.segment-c,
.article-segment.segment-r {
  margin-top: 0.35em;
  margin-bottom: 0.5em;
}

.article-segment.segment-o .segment-text {
  font-size: 0.92rem;
  line-height: 1.5;
  color: #444;
}

/* Block-type label colors (HSL). Text + left rail; no badge fill. */
.segment-label.label-h { color: hsl(220, 100%, 45%); background: none; }
.segment-label.label-o { color: hsl(320, 100%, 42%); background: none; }
.segment-label.label-fb { color: hsl(20, 100%, 42%); background: none; }
.segment-label.label-fs { color: hsl(150, 100%, 28%); background: none; }
.segment-label.label-l { color: hsl(80, 80%, 32%); background: none; }
.segment-label.label-b { color: hsl(20, 100%, 42%); background: none; }
.segment-label.label-s { color: hsl(150, 100%, 28%); background: none; }
.segment-label.label-ss { color: hsl(150, 100%, 28%); background: none; }
.segment-label.label-pq { color: hsl(270, 100%, 42%); background: none; }
.segment-label.label-pqc { color: hsl(270, 100%, 42%); background: none; }
.segment-label.label-co { color: hsl(220, 100%, 45%); background: none; }
.segment-label.label-u { color: hsl(0, 100%, 42%); background: none; }
.segment-label.label-c { color: hsl(320, 100%, 42%); background: none; }
.segment-label.label-r { color: hsl(20, 100%, 42%); background: none; }
.segment-label.label-section { color: hsl(190, 80%, 32%); background: none; }

.article-segment.segment-h { border-left-color: hsl(220, 100%, 60%); }
.article-segment.segment-o { border-left-color: hsl(320, 100%, 50%); }
.article-segment.segment-fb { border-left-color: hsl(20, 100%, 50%); }
.article-segment.segment-fs { border-left-color: hsl(150, 100%, 32%); }
.article-segment.segment-l { border-left-color: hsl(80, 100%, 50%); }
.article-segment.segment-b { border-left-color: hsl(20, 100%, 50%); }
.article-segment.segment-s,
.article-segment.segment-ss { border-left-color: hsl(150, 100%, 32%); }
.article-segment.segment-pq,
.article-segment.segment-pqc { border-left-color: hsl(270, 100%, 50%); }
.article-segment.segment-co { border-left-color: hsl(220, 100%, 60%); }
.article-segment.segment-u { border-left-color: hsl(0, 100%, 50%); }
.article-segment.segment-c { border-left-color: hsl(320, 100%, 50%); }
.article-segment.segment-r { border-left-color: hsl(20, 100%, 50%); }
.article-segment.segment-t,
.article-segment.segment-p { border-left-color: transparent; }

.article-segment.segment-p .segment-label,
.article-segment.segment-t .segment-label {
  visibility: hidden;
}

.article-segment-editing.segment-t .segment-label-select,
.article-segment-editing.segment-t .segment-label-trigger {
  visibility: visible;
}

.article-segment-editing.segment-p .segment-label-spacer {
  visibility: hidden;
}

.segment-image {
  display: block;
  max-width: 100%;
  width: auto;
  height: auto;
  margin: 0.15rem 0 0.35rem;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: none;
}

.image-zoom-viewer {
  max-width: 560px;
  margin: 16px auto;
}

.image-zoom-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.image-zoom-header .download-link {
  flex-shrink: 0;
}

.image-zoom-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 0;
}

.image-zoom-btn {
  padding: 6px 12px;
  font-size: 0.9rem;
  min-width: 2.5rem;
}

.image-zoom-btn.image-zoom-reset {
  padding: 6px 14px;
}

.image-zoom-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.image-zoom-btn:disabled:hover {
  background-color: #e9ecef;
  color: #084C64;
}

.image-zoom-level {
  min-width: 3.5rem;
  text-align: center;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  color: #666;
}

.image-zoom-stage {
  overflow: auto;
  max-height: min(70vh, 640px);
  border: 2px solid #e9ecef;
  border-radius: 6px;
  background: #f8f9fa;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.page-detail-layout .image-zoom-stage {
  max-height: min(calc(100vh - 280px), 900px);
}

.image-zoom-stage.can-pan {
  cursor: grab;
}

.image-zoom-stage.can-pan.is-dragging {
  cursor: grabbing;
  user-select: none;
}

.image-zoom-content {
  transform-origin: top left;
  will-change: transform;
}

.image-zoom-content img {
  display: block;
  width: 100%;
  height: auto;
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.layout-single {
  max-width: min(2256px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 0 20px;
}

/* Typography */
h2 {
  font-size: 1.8em;
  font-weight: 600;
  color: #084C64;
  margin-bottom: 24px;
  line-height: 1.3;
}

h3 {
  font-size: 1.3em;
  font-weight: 600;
  color: #084C64;
  margin-bottom: 12px;
}

h3 a {
  color: inherit;
}

h3 a:hover {
  color: #0A5F7A;
}

p {
  margin-bottom: 16px;
  color: #555;
}

/* Cards / panels */
.panel,
.feature-card,
.page-card,
.article-card,
.job-item {
  background: #ffffff;
  padding: 30px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.page-card:hover,
.job-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

/* Forms */
label {
  display: block;
  margin-bottom: 18px;
  font-weight: 600;
  color: #084C64;
  font-size: 0.95em;
}

label.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 500;
}

label[hidden] {
  display: none !important;
}

[data-processing-options][hidden],
[data-pages-list][hidden],
[data-classification-model-field][hidden] {
  display: none !important;
}

.page-process-form [data-segmentation-model-field],
.page-process-form [data-classification-model-field],
.page-chrome-reprocess [data-segmentation-model-field],
.page-chrome-reprocess [data-classification-model-field] {
  width: 100%;
  font-size: 0.85rem;
}

.page-chrome-reprocess .checkbox-label,
.page-process-form .checkbox-label {
  margin-bottom: 0.5rem;
}

.form-field {
  display: block;
  margin-bottom: 18px;
}

.form-field-label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  color: #084C64;
  font-size: 0.95em;
}

.segmented-control {
  display: inline-flex;
  align-items: stretch;
  margin-top: 2px;
  padding: 4px;
  gap: 2px;
  background: #ffffff;
  border: 1px solid #e6ebef;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(8, 76, 100, 0.08);
}

.segmented-option {
  position: relative;
  display: block;
  margin: 0;
  font-weight: 500;
  color: #1a1a1a;
  cursor: pointer;
}

.segmented-option input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.segmented-option-text {
  display: block;
  min-width: 4.5rem;
  padding: 0.55rem 1.1rem;
  border-radius: 9px;
  text-align: center;
  font-size: 0.95rem;
  line-height: 1.2;
  transition: background-color 0.15s ease, color 0.15s ease;
}

[data-classify-toggle] .segmented-option-text {
  min-width: 3.25rem;
}

.segmented-option input:checked + .segmented-option-text {
  background: #9fd6cf;
  color: #0b3d3a;
}

.segmented-option input:focus-visible + .segmented-option-text {
  outline: 2px solid #084C64;
  outline-offset: 2px;
}

input[type="text"],
input[type="password"],
input[type="number"],
select {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid #e9ecef;
  border-radius: 4px;
  font: inherit;
  color: #333;
  background: #ffffff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: #084C64;
  box-shadow: 0 0 0 3px rgba(8, 76, 100, 0.12);
}

.file-field {
  display: block;
}

.file-input {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-top: 6px;
  min-width: 0;
}

.file-input input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  opacity: 0;
  cursor: pointer;
  font-size: 0;
}

.file-input-button {
  flex: 0 0 auto;
  display: inline-block;
  padding: 10px 18px;
  border-radius: 4px;
  background-color: #e9ecef;
  color: #084C64;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.file-input:hover .file-input-button,
.file-input:focus-within .file-input-button {
  background-color: #084C64;
  color: #ffffff;
}

.file-input:focus-within .file-input-button {
  box-shadow: 0 0 0 3px rgba(8, 76, 100, 0.12);
}

.file-input-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #6c757d;
  font-weight: 500;
  font-size: 0.95em;
}

/* Buttons */
button,
.button {
  display: inline-block;
  background-color: #F6DD00;
  color: #084C64;
  padding: 14px 32px;
  border: 0;
  border-radius: 4px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.3s ease;
}

button:hover,
.button:hover {
  background-color: #084C64;
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(8, 76, 100, 0.3);
}

.btn-secondary {
  background-color: #e9ecef;
  color: #084C64;
}

.btn-secondary:hover {
  background-color: #084C64;
  color: #ffffff;
}

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

.btn-danger:hover {
  background-color: #dc2626;
  color: #ffffff;
}

.btn-primary {
  background-color: #F6DD00;
  color: #084C64;
}

.btn-primary:hover:not(:disabled) {
  background-color: #084C64;
  color: #ffffff;
}

.btn-sm {
  padding: 7px 14px;
  font-size: 0.82rem;
  border-radius: 4px;
}

.btn-sm:hover {
  transform: none;
  box-shadow: none;
}

button:disabled,
button:disabled:hover {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.job-overview-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 28px;
  align-items: start;
}

.job-overview-row > * {
  padding: 12px 16px;
  background: #f8f9fa;
  border-radius: 8px;
}

.job-overview-row .meta-grid {
  margin: 0;
  padding: 0;
  background: none;
}

.job-overview-row h2,
.job-defaults-form label {
  margin: 0;
}

.job-defaults-form select {
  margin-top: 2px;
  padding: 4px 8px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 28px;
}

.inline-form {
  display: inline;
}

/* Status badges */
.status {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 15px;
  font-size: 0.85em;
  font-weight: 600;
  background: #e9ecef;
  color: #084C64;
}

.status-completed {
  background: #d4edda;
  color: #155724;
}

.status-failed {
  background: #f8d7da;
  color: #721c24;
}

.status-processing,
.status-ingesting,
.status-pending {
  background: #cce5ff;
  color: #004085;
}

.status-partial {
  background: #fff3cd;
  color: #856404;
}

.article-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.article-card-header h3 {
  margin: 0;
}

.article-card-failed {
  border-left: 4px solid #dc2626;
}

.article-error-message {
  margin: 10px 0 14px 0;
  padding: 10px 14px;
  font-size: 0.88rem;
  line-height: 1.4;
  word-break: break-word;
}

.article-retry-form {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
}

.article-retry-form .classification-model-field {
  display: inline-flex;
  flex-direction: column;
  margin: 0;
  font-size: 0.85rem;
  white-space: nowrap;
}

.article-retry-form .classification-model-field select {
  width: auto;
  min-width: 11rem;
  margin-top: 4px;
  padding: 8px 10px;
}

.meta {
  color: #888;
  font-size: 0.9em;
}

/* Alerts */
.errors {
  background: #f8d7da;
  color: #721c24;
  padding: 16px 20px;
  border-radius: 4px;
  border-left: 4px solid #dc2626;
  margin-bottom: 20px;
}

/* Job list */
.job-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.job-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "primary meta"
    "details meta";
  align-items: center;
  gap: 6px 12px;
  padding: 18px 22px;
}

.job-item-primary {
  grid-area: primary;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.job-item-details {
  grid-area: details;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  min-width: 0;
  font-size: 0.9em;
  color: #666;
}

.job-item .meta {
  grid-area: meta;
  margin-left: 0;
  white-space: nowrap;
}

.job-edition {
  font-weight: 600;
  color: #084C64;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.job-pages {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
}

.job-item a {
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
  word-break: break-all;
}

.empty-state {
  color: #888;
  font-style: italic;
}

.field-hint {
  display: block;
  margin-top: 6px;
  color: #888;
  font-size: 0.85em;
  font-weight: 400;
}

.page-process-prompt {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: flex-start;
}

/* Meta grid */
.meta-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px 24px;
  margin-bottom: 28px;
  padding: 24px;
  background: #f8f9fa;
  border-radius: 8px;
}

.meta-grid dt {
  font-weight: 600;
  color: #084C64;
}

.meta-grid dd {
  margin: 0;
  color: #555;
}

/* Page grid */
.page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
}

.page-card img {
  width: 100%;
  height: auto;
  border: 2px solid #e9ecef;
  border-radius: 6px;
  margin: 12px 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.page-card .article-count {
  margin-bottom: 0;
  font-size: 0.9em;
  color: #666;
}

/* Article cutout gallery on job detail */
.cutout-page-group {
  margin-bottom: 36px;
}

.cutout-page-group:last-child {
  margin-bottom: 0;
}

.cutout-page-group > h3 {
  margin-bottom: 16px;
  font-size: 1.15em;
}

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

.cutout-card {
  position: relative;
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.cutout-link {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #ffffff;
  cursor: pointer;
  border-radius: 7px;
  color: inherit;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cutout-thumb {
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #f1f4f6;
}

.cutout-thumb::after {
  content: 'Open article →';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(8, 76, 100, 0.52);
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-align: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.cutout-link:hover,
.cutout-link:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(8, 76, 100, 0.2);
}

.cutout-link:hover .cutout-thumb::after,
.cutout-link:focus-visible .cutout-thumb::after {
  opacity: 1;
}

.cutout-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  transition: transform 0.2s ease;
}

.cutout-link:hover .cutout-thumb img,
.cutout-link:focus-visible .cutout-thumb img {
  transform: scale(1.03);
}

.cutout-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 8px 10px 9px;
  border-top: 1px solid #eef2f4;
  background: #ffffff;
}

.cutout-meta-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

.cutout-index {
  flex-shrink: 0;
  color: #084C64;
  font-size: 0.72rem;
  font-weight: 700;
}

.cutout-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #555;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.3;
}

.cutout-section {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #6b7280;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.25;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.cutout-section.is-empty {
  color: #b91c1c;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
}

.cutout-card.is-missing-required {
  border-color: #fca5a5;
  box-shadow: 0 2px 10px rgba(185, 28, 28, 0.14);
}

.cutout-card.is-pending {
  border-color: #93c5fd;
  box-shadow: 0 2px 10px rgba(8, 76, 100, 0.14);
}

.cutout-card.is-popover-open {
  overflow: visible;
  z-index: 25;
}

.cutout-required-trigger {
  width: 100%;
  padding: 0;
  border: 0;
  font: inherit;
  text-align: left;
}

.cutout-missing-overlay,
.cutout-status-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-align: center;
  line-height: 1.25;
  pointer-events: none;
}

.cutout-missing-overlay {
  background: rgba(185, 28, 28, 0.58);
}

.cutout-status-pending {
  background: rgba(8, 76, 100, 0.58);
}

.cutout-grounding-tag {
  position: absolute;
  top: -6px;
  right: -6px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background: transparent;
  line-height: 1;
  cursor: help;
  pointer-events: auto;
}

.cutout-grounding-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 8px 4px 6px;
  border-radius: 999px;
  background: #084C64;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1.2;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
}

.cutout-grounding-pct {
  color: #f6dd00;
}

.cutout-grounding-tooltip {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 4;
  display: none;
  flex-direction: column;
  gap: 6px;
  width: max-content;
  max-width: 260px;
  padding: 10px 11px;
  border-radius: 6px;
  background: #1a1a1a;
  color: #f8f8f8;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.4;
  text-align: left;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);
  white-space: normal;
}

.cutout-grounding-tooltip-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #f6dd00;
}

.cutout-grounding-tooltip-scores {
  color: #ffffff;
  font-weight: 500;
}

.cutout-grounding-tooltip-scores strong {
  font-weight: 700;
}

.cutout-grounding-tooltip-expl {
  color: #e5e5e5;
}

.cutout-grounding-tag:hover .cutout-grounding-tooltip,
.cutout-grounding-tag:focus-visible .cutout-grounding-tooltip {
  display: flex;
}

/* Badge hangs off the card corner; thumb keeps overflow:hidden so image zoom stays clipped. */
.cutout-card.is-low-grounding {
  overflow: visible;
}

.cutout-card:has(.cutout-grounding-tag:hover),
.cutout-card:has(.cutout-grounding-tag:focus-visible) {
  z-index: 30;
}

.cutout-card.is-missing-required .cutout-thumb::after,
.cutout-card.is-pending .cutout-thumb::after {
  display: none;
}

.cutout-card.is-missing-required .cutout-link:hover,
.cutout-card.is-missing-required .cutout-link:focus-visible {
  box-shadow: 0 10px 24px rgba(185, 28, 28, 0.22);
}

.cutout-card.is-pending .cutout-link:hover,
.cutout-card.is-pending .cutout-link:focus-visible {
  box-shadow: 0 10px 24px rgba(8, 76, 100, 0.22);
}

.cutout-required-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 40;
  width: min(220px, calc(100vw - 32px));
  padding: 10px;
  border: 1px solid #f1c0c0;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 12px 28px rgba(185, 28, 28, 0.18);
}

.cutout-required-popover::before {
  content: '';
  position: absolute;
  top: -5px;
  left: 16px;
  width: 8px;
  height: 8px;
  border-left: 1px solid #f1c0c0;
  border-top: 1px solid #f1c0c0;
  background: #ffffff;
  transform: rotate(45deg);
}

.cutout-required-label {
  display: block;
  margin-bottom: 4px;
  color: #084C64;
  font-size: 0.72rem;
  font-weight: 700;
}

.cutout-required-input {
  width: 100%;
  margin: 0 0 8px;
  padding: 7px 9px;
  border: 1px solid #c5d0c7;
  border-radius: 4px;
  color: #084C64;
  font-size: 0.82rem;
  background: #fff;
  box-sizing: border-box;
}

.cutout-required-input:focus {
  outline: 2px solid #084C64;
  outline-offset: 1px;
}

.cutout-required-status {
  margin: 0 0 8px;
  color: #991b1b;
  font-size: 0.72rem;
}

.cutout-required-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cutout-required-open {
  color: #084C64;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.cutout-required-open:hover,
.cutout-required-open:focus-visible {
  color: #b91c1c;
}

/* Page preview / overlay */
.page-preview {
  position: relative;
  align-self: start;
}

.overlay-wrap {
  position: relative;
  margin-bottom: 16px;
  user-select: none;
  -webkit-user-select: none;
}

.overlay-wrap img {
  width: 100%;
  height: auto;
  border: 2px solid #e9ecef;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  display: block;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}

.overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.page-preview-draw-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.page-preview-draw-toolbar .inline-form {
  margin: 0;
}

.page-preview-draw-toolbar .inline-form[hidden] {
  display: none !important;
}

.page-preview-draw-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-preview-draw-controls[hidden] {
  display: none !important;
}

.page-preview-draw-mode {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.page-preview-draw-mode .segmented-control {
  margin-top: 0;
  padding: 2px;
  gap: 1px;
  border-radius: 8px;
  box-shadow: none;
}

.page-preview-draw-mode .segmented-option-text {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 4px 7px;
  border-radius: 6px;
  line-height: 1;
}

.page-preview-draw-mode-icon {
  display: block;
  width: 14px;
  height: 14px;
}

.page-preview-draw-help {
  position: relative;
  display: inline-flex;
}

.page-preview-draw-help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  padding: 0;
  border: 1px solid #c5d0c7;
  border-radius: 999px;
  background: #fff;
  color: #084C64;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  cursor: help;
}

.page-preview-draw-help-btn:hover,
.page-preview-draw-help-btn:focus-visible {
  border-color: #084C64;
  background: #f3f8f7;
}

.page-preview-draw-help-btn:focus-visible {
  outline: 2px solid #084C64;
  outline-offset: 2px;
}

.page-preview-draw-help-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 30;
  width: max-content;
  max-width: min(18rem, 70vw);
  padding: 10px 12px;
  border: 1px solid #d9e2e7;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(8, 76, 100, 0.16);
  color: #084C64;
  font-size: 0.75rem;
  line-height: 1.35;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease, visibility 0.12s ease;
}

.page-preview-draw-help-popover p {
  margin: 0;
}

.page-preview-draw-help-popover p + p {
  margin-top: 0.4rem;
}

.page-preview-draw-help-popover::before {
  content: '';
  position: absolute;
  top: -5px;
  left: 10px;
  width: 8px;
  height: 8px;
  border-left: 1px solid #d9e2e7;
  border-top: 1px solid #d9e2e7;
  background: #ffffff;
  transform: rotate(45deg);
}

.page-preview-draw-help:hover .page-preview-draw-help-popover,
.page-preview-draw-help:focus-within .page-preview-draw-help-popover {
  opacity: 1;
  visibility: visible;
}

.page-preview-draw-hint {
  font-size: 0.75rem;
  color: #084C64;
  white-space: nowrap;
}

.page-preview-draw-hint:empty {
  display: none;
}

.overlay-wrap.is-drawing-rectangle {
  cursor: crosshair;
}

.page-preview-draw-headline {
  width: min(220px, 28vw);
  margin: 0;
  padding: 6px 10px;
  border: 1px solid #c5d0c7;
  border-radius: 4px;
  font-size: 0.82rem;
  color: #084C64;
  background: #fff;
}

.page-preview-draw-section {
  width: min(140px, 18vw);
  margin: 0;
  padding: 6px 10px;
  border: 1px solid #c5d0c7;
  border-radius: 4px;
  font-size: 0.82rem;
  color: #084C64;
  background: #fff;
}

.page-preview-draw-headline:focus,
.page-preview-draw-section:focus {
  outline: none;
  border-color: #084C64;
  box-shadow: 0 0 0 2px rgba(8, 76, 100, 0.15);
}

.overlay-wrap.is-drawing {
  cursor: crosshair;
}

.overlay-wrap.is-drawing .draw-draft-vertex {
  cursor: grab;
}

.overlay-wrap.is-dragging-vertex,
.overlay-wrap.is-dragging-vertex .draw-draft-vertex {
  cursor: grabbing;
}

.overlay.is-drawing {
  pointer-events: auto;
}

.draw-draft-line {
  fill: none;
  stroke: #084C64;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
  pointer-events: none;
}

.draw-draft-fill {
  fill: rgba(8, 76, 100, 0.18);
  stroke: #084C64;
  stroke-width: 1.5;
  pointer-events: none;
}

.draw-draft-vertex {
  fill: #084C64;
  stroke: #ffffff;
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
  pointer-events: auto;
}

.draw-draft-vertex.is-first {
  fill: #e6b800;
  stroke: #ffffff;
  stroke-width: 1.75;
}

.region {
  fill: var(--region-fill);
  stroke: var(--region-stroke);
  stroke-width: 1.25;
  paint-order: stroke fill;
  transition: fill 0.15s ease, stroke 0.15s ease, stroke-width 0.15s ease, opacity 0.15s ease;
  pointer-events: auto;
  outline: none;
}

.region:focus,
.region:focus-visible {
  outline: none;
}

.region-clickable {
  cursor: pointer;
}

.region-clickable:hover {
  fill: var(--region-fill-hover);
}

.region-active {
  fill: var(--region-fill-active);
  stroke: var(--region-stroke-active);
  stroke-width: 2.5;
}

.region-dimmed {
  opacity: 0.45;
}

.region-dimmed:hover {
  opacity: 0.7;
}

.region-controls {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.region-expand-btn {
  position: absolute;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1.5px solid #084C64;
  border-radius: 4px;
  background: #F6DD00;
  color: #084C64;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transform: none;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.region-expand-btn svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: none;
}

.region-expand-btn:hover,
.region-expand-btn:focus-visible {
  background: #084C64;
  color: #F6DD00;
  opacity: 1;
  outline: none;
  transform: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.region-expand-btn.is-active {
  background: #084C64;
  color: #F6DD00;
  opacity: 1;
}

/* Page chrome: overview + page select + article tabs */
.page-chrome {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e9ecef;
}

.page-chrome-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}

.page-chrome-overview {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border: 2px solid #e9ecef;
  border-radius: 5px;
  background: #ffffff;
  color: #555;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.25;
  text-decoration: none;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.page-chrome-overview:hover {
  border-color: #084C64;
  color: #084C64;
}

.page-chrome-overview.is-active,
.page-chrome-overview.is-active:hover {
  border-color: #084C64;
  background: #e3f2f8;
  color: #084C64;
}

.page-chrome-viewers {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.page-chrome-viewer-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 5px;
  border: 2px solid;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  cursor: default;
}

.page-select-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  margin-bottom: 0;
  font-weight: 600;
  color: #084C64;
  font-size: 0.8rem;
}

.page-select-menu {
  position: relative;
  display: inline-flex;
  min-width: 0;
}

.page-nav-btn {
  flex-shrink: 0;
  text-decoration: none;
}

a.page-nav-btn:hover,
a.page-nav-btn:focus-visible {
  border-color: #084C64;
  background: #e3f2f8;
  color: #084C64;
  outline: none;
}

.page-nav-btn.is-disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

.page-select-label {
  white-space: nowrap;
}

.page-select {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: auto;
  min-width: 11rem;
  max-width: min(20rem, 100%);
  margin: 0;
  margin-top: 0;
  padding: 5px 28px 5px 10px;
  border: 2px solid #e9ecef;
  border-radius: 5px;
  background-color: #ffffff;
  color: #333;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.25;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23084C64' d='M1.4.6 6 5.2 10.6.6 12 2 6 8 0 2z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 10px 7px;
  transition: border-color 0.15s ease;
  box-shadow: none;
  text-align: left;
}

.page-select-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-select:hover,
.page-select:focus,
.page-select-menu.is-open .page-select {
  border-color: #084C64;
  outline: none;
  box-shadow: none;
}

.page-select-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 30;
  min-width: 100%;
  max-height: min(320px, 50vh);
  margin: 0;
  padding: 6px;
  list-style: none;
  overflow: auto;
  border: 1px solid #d9e2e7;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 28px rgba(8, 76, 100, 0.16);
}

.page-select-list[hidden] {
  display: none;
}

.page-select-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 10px;
  border-radius: 5px;
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.25;
}

.page-select-option:hover,
.page-select-option:focus-visible {
  outline: none;
  filter: brightness(0.97);
}

.page-select-option.is-selected {
  box-shadow: inset 0 0 0 1.5px currentColor;
}

.page-select-option-status {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: lowercase;
  opacity: 0.9;
}

.page-select--completed,
.page-select-option--completed {
  color: #155724;
  background-color: #f3faf5;
}

.page-select--failed,
.page-select-option--failed {
  color: #721c24;
  background-color: #fdf5f6;
}

.page-select--partial,
.page-select-option--partial {
  color: #856404;
  background-color: #fffbeb;
}

.page-select--processing,
.page-select--ingesting,
.page-select--pending,
.page-select-option--processing,
.page-select-option--ingesting,
.page-select-option--pending {
  color: #004085;
  background-color: #f3f8fd;
}

.page-select--completed {
  border-color: #a7d4b3;
}

.page-select--completed:hover,
.page-select--completed:focus,
.page-select-menu.is-open .page-select--completed {
  border-color: #155724;
}

.page-select--failed {
  border-color: #e5b4b9;
}

.page-select--failed:hover,
.page-select--failed:focus,
.page-select-menu.is-open .page-select--failed {
  border-color: #721c24;
}

.page-select--partial {
  border-color: #e6d59a;
}

.page-select--partial:hover,
.page-select--partial:focus,
.page-select-menu.is-open .page-select--partial {
  border-color: #856404;
}

.page-select--processing,
.page-select--ingesting,
.page-select--pending {
  border-color: #9fc2e8;
}

.page-select--processing:hover,
.page-select--processing:focus,
.page-select-menu.is-open .page-select--processing,
.page-select--ingesting:hover,
.page-select--ingesting:focus,
.page-select-menu.is-open .page-select--ingesting,
.page-select--pending:hover,
.page-select--pending:focus,
.page-select-menu.is-open .page-select--pending {
  border-color: #004085;
}

.page-select-option--completed:hover,
.page-select-option--completed:focus-visible {
  background-color: #e5f5ea;
}

.page-select-option--failed:hover,
.page-select-option--failed:focus-visible {
  background-color: #f8e6e8;
}

.page-select-option--partial:hover,
.page-select-option--partial:focus-visible {
  background-color: #fff3cd;
}

.page-select-option--processing:hover,
.page-select-option--processing:focus-visible,
.page-select-option--ingesting:hover,
.page-select-option--ingesting:focus-visible,
.page-select-option--pending:hover,
.page-select-option--pending:focus-visible {
  background-color: #e3f0fb;
}



.page-chrome-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin: 0;
  padding: 0;
  border: 2px solid #e9ecef;
  border-radius: 999px;
  background: #ffffff;
  color: #084C64;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.page-chrome-icon-btn svg {
  width: 15px;
  height: 15px;
  display: block;
}

.page-chrome-icon-btn:hover,
.page-chrome-icon-btn:focus-visible {
  border-color: #084C64;
  background: #e3f2f8;
  outline: none;
}

.page-chrome-reprocess {
  position: relative;
  margin: 0;
  display: inline-flex;
  align-items: center;
}

.page-chrome-reprocess.is-open {
  z-index: 40;
}

.page-chrome-reprocess-btn {
  color: #b42318;
  border-color: #f3c2c0;
}

.page-chrome-reprocess-btn:hover,
.page-chrome-reprocess-btn:focus-visible,
.page-chrome-reprocess.is-open .page-chrome-reprocess-btn {
  color: #ffffff;
  background: #b42318;
  border-color: #b42318;
}

.page-chrome-reprocess-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: max-content;
  min-width: 18rem;
  max-width: min(22rem, calc(100vw - 24px));
  padding: 10px;
  border: 1px solid #e0e6ea;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 28px rgba(16, 24, 40, 0.14);
}

.page-chrome-reprocess-menu[hidden] {
  display: none;
}

.page-chrome-reprocess-warning {
  margin: 0 0 2px;
  padding: 0 2px;
  color: #8a2e28;
  font-size: 0.75rem;
  line-height: 1.35;
}

.page-chrome-reprocess-classify {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 2px;
  color: #555;
  font-size: 0.8rem;
  line-height: 1.3;
  cursor: pointer;
  user-select: none;
}

.page-chrome-reprocess-option {
  display: block;
  width: 100%;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid #e0e6ea;
  border-radius: 6px;
  background: #ffffff;
  color: #333;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: left;
  line-height: 1.3;
  cursor: pointer;
}

.page-chrome-reprocess-option:hover,
.page-chrome-reprocess-option:focus-visible {
  outline: none;
}

.page-chrome-reprocess-option-danger {
  border-color: #f3c2c0;
  background: #fff5f4;
  color: #8a2e28;
}

.page-chrome-reprocess-option-danger:hover,
.page-chrome-reprocess-option-danger:focus-visible {
  border-color: #b42318;
  background: #fde8e6;
  color: #7a1f1a;
}

.page-chrome-token-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.page-chrome-token-tip[hidden] {
  display: none;
}

.page-chrome-token-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 20;
  width: max-content;
  min-width: 32rem;
  max-width: min(42rem, 94vw);
  padding: 12px 14px;
  border: 1px solid #d9e2e7;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(8, 76, 100, 0.16);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease, visibility 0.12s ease;
}

.page-chrome-token-popover::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 14px;
  width: 10px;
  height: 10px;
  border-left: 1px solid #d9e2e7;
  border-top: 1px solid #d9e2e7;
  background: #ffffff;
  transform: rotate(45deg);
}

.page-chrome-token-tip:hover .page-chrome-token-popover,
.page-chrome-token-tip:focus-within .page-chrome-token-popover {
  opacity: 1;
  visibility: visible;
}

.page-chrome-token-title {
  margin-bottom: 10px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9aa6ad;
}

.page-chrome-token-rows {
  display: block;
  width: 100%;
}

.page-chrome-token-table {
  width: 100%;
  margin: 0;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.78rem;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  background: transparent;
  box-shadow: none;
}

.page-chrome-token-table thead {
  background: transparent;
  color: inherit;
}

.page-chrome-token-table th,
.page-chrome-token-table td {
  padding: 7px 10px;
  vertical-align: top;
  border-bottom: 1px solid #eef2f4;
  text-align: left;
}

.page-chrome-token-table thead th {
  padding-top: 0;
  padding-bottom: 8px;
  border-bottom: 1px solid #d5dee3;
  color: #88959c;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.page-chrome-token-table thead th:nth-child(2),
.page-chrome-token-table thead th:nth-child(3),
.page-chrome-token-table td:nth-child(2),
.page-chrome-token-table td:nth-child(3),
.page-chrome-token-table tfoot th:nth-child(2),
.page-chrome-token-table tfoot td:nth-child(2),
.page-chrome-token-table tfoot th:nth-child(3),
.page-chrome-token-table tfoot td:nth-child(3) {
  text-align: right;
}

.page-chrome-token-table thead th:nth-child(1),
.page-chrome-token-table td:nth-child(1),
.page-chrome-token-table tfoot th:nth-child(1) {
  width: 34%;
}

.page-chrome-token-table thead th:nth-child(2),
.page-chrome-token-table td:nth-child(2),
.page-chrome-token-table tfoot td:nth-child(2) {
  width: 48%;
}

.page-chrome-token-table thead th:nth-child(3),
.page-chrome-token-table td:nth-child(3),
.page-chrome-token-table tfoot td:nth-child(3) {
  width: 18%;
}

.page-chrome-token-item {
  color: #4a5a63;
  font-weight: 700;
  overflow: hidden;
}

.page-chrome-token-tokens {
  color: #4a5a63;
}

.page-chrome-token-total {
  display: block;
  font-weight: 600;
}

.page-chrome-token-detail {
  display: block;
  margin-top: 2px;
  color: #88959c;
  font-size: 0.7rem;
  font-weight: 500;
  white-space: normal;
  line-height: 1.35;
}

.page-chrome-token-detail + .page-chrome-token-detail {
  margin-top: 1px;
}

.page-chrome-token-cost {
  color: #084C64;
  font-weight: 700;
  white-space: nowrap;
}

.page-chrome-token-table tr.is-active .page-chrome-token-item {
  color: #084C64;
}

.page-chrome-token-table tbody tr.is-active td,
.page-chrome-token-table tbody tr.is-active th {
  background: #f3f8fd;
}

.page-chrome-token-table tbody tr:hover td,
.page-chrome-token-table tbody tr:hover th {
  background: transparent;
}

.page-chrome-token-table tbody tr.is-active:hover td,
.page-chrome-token-table tbody tr.is-active:hover th {
  background: #f3f8fd;
}

.page-chrome-token-table tbody tr:last-child th,
.page-chrome-token-table tbody tr:last-child td {
  border-bottom: 0;
}

.page-chrome-token-table tfoot th,
.page-chrome-token-table tfoot td {
  border-bottom: 0;
  border-top: 1.5px solid #d5dee3;
  padding-top: 9px;
  color: #084C64;
  font-weight: 700;
  background: #f7fafb;
}

.page-chrome-token-table tfoot .page-chrome-token-detail {
  color: #6b7a82;
}

.page-chrome .article-tabs {
  flex: none;
  width: 100%;
  margin: 0;
  padding: 0;
  border-bottom: 0;
  min-width: 0;
}

/* Job tabs (legacy / unused on job detail) */
.job-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid #e9ecef;
}

.job-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 2px solid #e9ecef;
  border-radius: 6px;
  background: #ffffff;
  color: #555;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 400;
  line-height: 1.3;
  text-decoration: none;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.job-tab:hover {
  border-color: #084C64;
  color: #084C64;
  background: #ffffff;
}

.job-tab.is-active,
.job-tab.is-active:hover {
  border: 3px solid #084C64;
  padding: 9px 13px;
  background: #e3f2f8;
  color: #084C64;
}

.job-tab-failed:not(.is-active) {
  border-color: #f5c6cb;
}

.job-tab-label {
  font-weight: 700;
}

.job-tab .status {
  font-size: 0.75rem;
}

/* Article tabs */
.page-watch-dock {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  max-width: min(420px, calc(100vw - 24px));
  pointer-events: none;
}

.page-watch-dock > * {
  pointer-events: auto;
}

.page-watch-toasts {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  width: 100%;
}

.page-watch-toast {
  width: 100%;
  margin: 0;
  padding: 8px 10px;
  border-radius: 6px;
  background: #ffffff;
  border: 1px solid #ffc107;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  color: #1a1a1a;
  font-size: 0.78rem;
  line-height: 1.35;
  animation: page-watch-toast-in 0.2s ease-out;
}

.page-watch-toast--update {
  border-color: #fd7e14;
  background: #fff8f0;
}

.page-watch-toast--info {
  border-color: #084C64;
  background: #e3f2f8;
}

.page-watch-toast--error {
  border-color: #dc2626;
  background: #fef2f2;
  color: #7f1d1d;
}

.page-watch-toast-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.page-watch-toast-text {
  flex: 1;
  margin: 0;
  font-weight: 600;
  min-width: 0;
}

.page-watch-toast-close {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin: -2px -2px 0 0;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  font-size: 1.15rem;
  line-height: 1;
  opacity: 0.55;
  cursor: pointer;
}

.page-watch-toast-close:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.06);
}

.page-watch-toast--error .page-watch-toast-close:hover {
  background: rgba(127, 29, 29, 0.1);
}

.page-watch-toast-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.page-watch-toast-row + .page-watch-toast-actions {
  margin-top: 6px;
}

.page-watch-toast-btn {
  padding: 3px 8px;
  border: 0;
  border-radius: 4px;
  background: #084C64;
  color: #ffffff;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}

.page-watch-toast-btn:hover {
  background: #0A5F7A;
}

.page-watch-toast-btn-muted {
  background: #e9ecef;
  color: #495057;
}

.page-watch-toast-btn-muted:hover {
  background: #dee2e6;
}

@keyframes page-watch-toast-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: #0d6efd;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.link-button:hover {
  color: #0a58ca;
}

.articles-panel > .errors {
  margin-bottom: 16px;
}

.article-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 12px;
  padding: 0 0 10px;
  border-bottom: 1px solid #e9ecef;
}

.article-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border: 2px solid #e9ecef;
  border-radius: 5px;
  background: #ffffff;
  color: #555;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.25;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.article-tab:hover {
  border-color: #084C64;
  color: #084C64;
  background: #ffffff;
  transform: none;
  box-shadow: none;
}

.article-tab.is-active,
.article-tab.is-active:hover {
  border: 3px solid #084C64;
  padding: 4px 8px;
  background: #e3f2f8;
  color: #084C64;
  transform: none;
  box-shadow: none;
}

.article-tab-failed:not(.is-active) {
  border-color: #f5c6cb;
}

.article-tab-label {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.article-tab-title {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.article-tab .status {
  font-size: 0.62rem;
  padding: 1px 5px;
}

.article-tab-panels {
  min-height: 120px;
}

.article-tab-panel {
  display: none;
}

.article-tab-panel.is-active {
  display: block;
}

.articles-panel .article-tab-panel .article-card {
  margin-bottom: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
  border-bottom: none;
}

/* Article cards */
.article-card {
  margin-bottom: 30px;
}

.panel .article-card {
  box-shadow: none;
  padding: 0 0 32px;
  margin-bottom: 32px;
  border-bottom: 1px solid #e9ecef;
  border-radius: 0;
}

.panel .article-card:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.article-card:last-child {
  margin-bottom: 0;
}

.article-card > p {
  font-size: 0.9em;
  color: #666;
}

.article-card img {
  max-width: 100%;
  border: 2px solid #e9ecef;
  border-radius: 6px;
  margin: 16px 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.article-card img.segment-image {
  max-width: 100%;
  width: auto;
  height: auto;
  margin: 0.15rem 0 0.35rem;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.article-card-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 10px 14px;
  position: sticky;
  top: 0;
  z-index: 10;
  background: #fff;
  padding-block: 10px;
  margin-bottom: 12px;
  box-shadow: 0 4px 8px -4px rgba(0, 0, 0, 0.18);
}

.page-detail-layout .article-card-toolbar {
  margin-inline: -16px;
  padding-inline: 16px;
}

.article-editor-toolbar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.article-editor-toolbar[hidden] {
  display: none !important;
}

.article-editor-toolbar-editing {
  flex-wrap: wrap;
}

.article-editor-status {
  font-size: 0.82rem;
  color: #666;
}

.article-editor-status[data-status-type="dirty"] {
  color: #856404;
}

.article-editor-status[data-status-type="error"] {
  color: #991b1b;
}

.article-editor-status[data-status-type="saved"] {
  color: #155724;
}

.article-text.is-editing {
  margin-top: 4px;
}

.article-text.is-editing .article-segment {
  border-left-color: transparent;
}

.article-segment-editing {
  grid-template-columns: 3.5rem 3.25rem minmax(0, 1fr);
  gap: 0.35rem 0.65rem;
  align-items: start;
  padding: 0.35rem 0;
  border-radius: 4px;
}

.article-segment-editing:focus-within {
  background: rgba(8, 76, 100, 0.04);
}

.segment-label-dropdown {
  position: relative;
  width: 100%;
  max-width: 3.25rem;
  z-index: 1;
}

.segment-label-dropdown.is-open {
  z-index: 20;
}

.segment-label-trigger {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.15rem 0.2rem;
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  visibility: visible;
  font-family: 'Avenir', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: left;
  line-height: 1.2;
}

.segment-label-trigger:hover,
.segment-label-trigger:focus {
  outline: none;
  border-color: rgba(0, 0, 0, 0.2);
  box-shadow: 0 0 0 3px rgba(8, 76, 100, 0.08);
  filter: brightness(1.08);
}

.segment-label-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 30;
  width: max-content;
  min-width: 8.5rem;
  padding: 0.4rem;
  border: 1px solid #d5dce0;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.segment-label-menu[hidden] {
  display: none !important;
}

.segment-label-group {
  display: grid;
  grid-template-columns: repeat(3, 2rem);
  gap: 3px;
}

.segment-label-group + .segment-label-group {
  margin-top: 0.4rem;
  padding-top: 0.35rem;
  border-top: 1px solid #eef1f3;
}

.segment-label-group-title {
  grid-column: 1 / -1;
  margin: 0 0 0.15rem;
  padding: 0 0.1rem;
  font-family: 'Avenir', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #5a6a72;
}

.segment-label-option {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 1.5rem;
  margin: 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  font-family: 'Avenir', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: center;
  text-transform: uppercase;
}

.segment-label-option:hover,
.segment-label-option:focus {
  outline: none;
  filter: brightness(1.08);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.segment-label-option.is-selected {
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.85);
}

.segment-actions {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-self: start;
  margin-top: 0.15em;
}

.segment-action-row {
  display: flex;
  flex-direction: row;
  gap: 2px;
}

.segment-header-spacer {
  display: inline-block;
  width: 1.65rem;
  height: 1.65rem;
}

.article-header-slot .segment-label {
  margin-top: 0.45em;
}

.segment-drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.65rem;
  height: 1.65rem;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: #eef1f3;
  color: #6b7b85;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.segment-drag-handle::before {
  content: "⋮⋮";
  font-size: 0.72rem;
  line-height: 1;
  letter-spacing: -0.12em;
  font-weight: 700;
}

.segment-drag-handle:hover {
  background: #dce4e8;
  color: #084C64;
}

.segment-drag-handle:active {
  cursor: grabbing;
}

.article-segment-editing.is-dragging {
  opacity: 0.45;
}

.article-segment-editing.is-drop-target {
  background: rgba(8, 76, 100, 0.08);
  box-shadow: inset 0 0 0 2px rgba(8, 76, 100, 0.28);
}

.segment-action-btn {
  width: 1.65rem;
  height: 1.65rem;
  padding: 0;
  border-radius: 4px;
  font-size: 0.72rem;
  line-height: 1;
  font-weight: 700;
  background: #eef1f3;
  color: #084C64;
}

.segment-action-btn:disabled,
.segment-action-btn[hidden] {
  display: none;
}

.segment-action-btn:hover:not(:disabled) {
  background: #084C64;
  color: #fff;
}

.segment-delete-btn .material-symbols-outlined {
  display: block;
  font-size: 1.05rem;
  line-height: 1;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
}

.segment-delete-btn.is-armed,
.segment-delete-btn.is-armed:hover:not(:disabled) {
  background: #c0392b;
  color: #fff;
}

.segment-text-input {
  width: 100%;
  min-height: 1.5em;
  margin: 0;
  padding: 0.15rem 0.35rem;
  border: 1px solid transparent;
  border-radius: 4px;
  resize: none;
  overflow: hidden;
  background: transparent;
  font: inherit;
  line-height: inherit;
  color: inherit;
}

.segment-text-input:focus {
  outline: none;
  border-color: rgba(8, 76, 100, 0.35);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(8, 76, 100, 0.08);
}

.article-segment-editing.segment-h .segment-text-input {
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.25;
}

.article-segment-editing.segment-s .segment-text-input,
.article-segment-editing.segment-ss .segment-text-input,
.article-segment-editing.segment-fs .segment-text-input {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.35;
}

.article-segment-editing.segment-b .segment-text-input,
.article-segment-editing.segment-fb .segment-text-input {
  font-family: 'Avenir', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 0.82rem;
  font-style: italic;
}

.article-segment-editing.segment-t .segment-text-input {
  font-size: 0.98rem;
  line-height: 1.62;
}

.article-segment-editing.segment-c .segment-text-input,
.article-segment-editing.segment-r .segment-text-input {
  font-family: 'Avenir', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 0.8rem;
}

.article-text-empty {
  margin-top: 0;
}

.article-card .download-link,
.image-zoom-header .download-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  font-size: 0.9rem;
  color: #084C64;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1.5px;
  transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

.article-card .download-link:hover,
.image-zoom-header .download-link:hover {
  color: #0A5F7A;
  text-decoration-color: #0A5F7A;
}

/* Panel header row */
.panel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px 20px;
  margin-bottom: 24px;
}

.panel-header h2 {
  margin-bottom: 0;
}

.panel-summary {
  margin: 0;
}

.panel-link {
  font-weight: 600;
  font-size: 0.95em;
  white-space: nowrap;
}

/* Job table */
.table-wrap {
  overflow-x: auto;
}

.job-table {
  margin-top: 0;
}

.job-table .job-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
  max-width: 220px;
}

.job-table .job-id a {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-table .job-source {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-table .job-pages {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
  white-space: nowrap;
}

.job-table .job-date {
  white-space: nowrap;
  font-size: 0.85em;
  color: #666;
}

.audit-th-filter {
  position: relative;
  vertical-align: middle;
}

.audit-th-menu-wrap {
  position: relative;
  display: inline-block;
  max-width: 100%;
}

.audit-th-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  max-width: 100%;
  margin: 0;
  padding: 0.15rem 0.2rem;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  text-align: left;
  cursor: pointer;
}

.audit-th-toggle:hover,
.audit-th-menu-wrap.is-open .audit-th-toggle {
  background: rgba(8, 76, 100, 0.08);
}

.audit-th-filter.is-filtered .audit-th-toggle {
  background: #F6DD00;
  color: #084C64;
}

.audit-th-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 10rem;
}

.audit-th-caret {
  flex: 0 0 auto;
  font-size: 0.75em;
  opacity: 0.7;
}

.audit-th-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 20;
  min-width: 11rem;
  max-width: 22rem;
  max-height: 16rem;
  overflow: auto;
  padding: 0.3rem;
  border: 1px solid #e2e5ea;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.audit-th-option {
  display: block;
  padding: 0.4rem 0.55rem;
  border-radius: 3px;
  color: #333;
  text-decoration: none;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.audit-th-option:hover,
.audit-th-option:focus-visible {
  background: rgba(8, 76, 100, 0.08);
  outline: none;
}

.audit-th-option.is-selected {
  background: #F6DD00;
  color: #084C64;
  font-weight: 600;
}

.audit-changes {
  margin: 0.45rem 0 0;
  padding-left: 1.1rem;
  max-width: 36rem;
  font-size: 0.9em;
  line-height: 1.45;
}

.audit-changes li {
  margin: 0.2rem 0;
}

.audit-details {
  margin: 0.4rem 0 0;
  max-width: 36rem;
  max-height: 12rem;
  overflow: auto;
  white-space: pre-wrap;
  font-size: 0.8em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #666;
}

/* Pagination */
.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 12px;
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid #e9ecef;
}

.pagination a {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid #e9ecef;
  border-radius: 4px;
  background: #ffffff;
  font-weight: 600;
  font-size: 0.9em;
}

.pagination a:hover {
  border-color: #084C64;
  background: #f8f9fa;
}

.pagination-current {
  padding: 8px 14px;
  font-weight: 600;
  color: #084C64;
  font-size: 0.9em;
}

.pagination-disabled {
  padding: 8px 14px;
  color: #bbb;
  font-size: 0.9em;
}

/* Segment-style table */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0 0;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  font-size: 0.9rem;
}

thead {
  background: linear-gradient(135deg, #084C64 0%, #0A5F7A 100%);
  color: #ffffff;
}

th,
td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid #e9ecef;
  vertical-align: top;
}

th {
  font-weight: 600;
}

tbody tr:hover {
  background-color: #f8f9fa;
}

.label-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.75em;
  font-weight: 600;
  text-transform: uppercase;
  background: #e9ecef;
  color: #084C64;
}

/* Responsive */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  body.page-detail-view {
    display: block;
    height: auto;
    overflow: visible;
  }

  body.page-detail-view .page-content,
  body.page-detail-view .layout-single {
    display: block;
    flex: none;
    min-height: 0;
    overflow: visible;
    height: auto;
  }

  body.page-detail-view .page-content {
    padding-bottom: 40px;
  }

  .page-detail-layout {
    grid-template-columns: 1fr;
    gap: 16px;
    display: grid;
    flex: none;
    min-height: 0;
    overflow: visible;
    height: auto;
  }

  .page-detail-resize-handle {
    display: none;
  }

  .page-detail-layout .page-preview {
    grid-column: 1;
    grid-row: 1;
    position: static;
    display: block;
    overflow: visible;
    min-height: 0;
  }

  .page-detail-layout .articles-panel,
  .page-detail-layout .page-preview-page,
  .page-detail-layout .page-preview-cutout-stage {
    overflow: visible;
    overscroll-behavior: auto;
    scrollbar-width: auto;
    scrollbar-color: auto;
  }

  .page-detail-layout .page-preview-cutout:not([hidden]) {
    display: block;
    overflow: visible;
  }

  .page-detail-layout .page-preview-cutout-stage,
  .page-detail-layout .page-preview.is-showing-cutout .page-preview-cutout-stage {
    max-height: min(70vh, 640px);
  }

  .page-detail-layout .articles-panel {
    grid-column: 1;
    grid-row: 2;
  }

  .page-preview {
    position: static;
  }

  .job-item {
    grid-template-columns: 1fr;
    grid-template-areas:
      "primary"
      "details"
      "meta";
  }

  .job-item .meta {
    margin-left: 0;
    width: 100%;
  }
}

@media (max-width: 768px) {
  .header-section {
    padding: 32px 0 40px;
  }

  .header-section.header-compact {
    padding: 10px 0;
  }

  .header-job-context {
    margin-left: 0;
    flex: 1 1 100%;
    max-width: 100%;
  }

  .header-section h1 {
    font-size: 1.8em;
  }

  .header-section h1:has(.header-job-id) {
    font-size: 1.25em;
  }

  .header-section .subtitle {
    font-size: 1em;
  }

  h2 {
    font-size: 1.5em;
  }

  .panel,
  .feature-card,
  .page-card,
  .article-card {
    padding: 20px;
  }

  .page-content {
    padding: 16px 0 32px;
  }

  .header-user {
    margin-left: auto;
  }
}

/* Login */
.login-page .header-section {
  padding-bottom: 40px;
}

.login-main {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.login-layout {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  padding: 0 16px;
}

.login-panel h2 {
  margin-bottom: 20px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-form label {
  display: block;
  font-weight: 600;
  color: #084C64;
}

.login-form .btn-primary {
  margin-top: 8px;
  width: 100%;
}
