/* Tilín Data Studio — Operate Mode Design System
   Restrained warm precision studio + Tilín Orange (#E86300) & Deep Purple (#35156A) accents */

:root {
  --bg-canvas: #F6F4F0;
  --bg-sidebar: #ECE8E1;
  --bg-surface: #FFFFFF;
  --bg-subtle: #F2EFEA;
  --border: #E2DCD3;
  --border-strong: #CEC6BA;

  --ink: #181512;
  --ink-secondary: #534C45;
  --ink-muted: #6E665E;

  --orange: #D95700;
  --orange-hover: #BA4A00;
  --orange-soft: #FFF2E6;
  --orange-border: #F5CBA7;

  --purple: #35156A;
  --purple-hover: #270F50;
  --purple-soft: #F3EEFA;
  --purple-border: #D5C6ED;

  --green: #0F766E;
  --green-soft: #E9F7F5;
  --amber: #A15C07;
  --amber-soft: #FEF6E7;
  --red: #B91C1C;
  --red-soft: #FEF1F1;

  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-popover: 0 12px 32px rgba(24, 21, 18, 0.14), 0 2px 6px rgba(24, 21, 18, 0.06);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
}

::selection {
  background: var(--orange-soft);
  color: var(--ink);
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-canvas);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  caret-color: var(--orange);
}

/* Custom restrained scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CFC8BE; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #AFA69A; }

:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.hidden {
  display: none !important;
}

.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}

/* ==================== APP SHELL ==================== */
.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100dvh;
}

.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100dvh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--purple);
  color: #FFFFFF;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-name {
  display: block;
  font-size: 14.5px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.2;
}

.brand-sub {
  display: block;
  font-size: 11.5px;
  color: var(--ink-muted);
  font-weight: 500;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.nav-item {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-secondary);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  text-align: left;
  transition: background-color 160ms var(--ease), color 160ms var(--ease);
}

.nav-item:hover {
  background: rgba(24, 21, 18, 0.05);
  color: var(--ink);
}

.nav-item.active {
  background: var(--bg-surface);
  border-color: var(--border);
  color: var(--ink);
}

.nav-item.active .ic {
  color: var(--orange);
}

.ic {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

.ic-sm {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.nav-count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(24, 21, 18, 0.08);
  color: var(--ink-secondary);
}

.nav-count.accent {
  background: var(--orange-soft);
  color: var(--orange);
}

/* Explicit anchor names for persistent app tour */
#nav-neon { anchor-name: --tour-neon; }
#nav-ingest { anchor-name: --tour-ingest; }
#nav-review { anchor-name: --tour-review; }
#nav-releases { anchor-name: --tour-releases; }

.sidebar-footer {
  margin-top: auto;
}

.engine-status-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.engine-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-strong);
  flex-shrink: 0;
}

.status-dot.ok { background: #16A34A; }
.status-dot.warn { background: #D97706; }
.status-dot.err { background: #DC2626; }

.engine-label {
  color: var(--ink-secondary);
  font-weight: 600;
}

.engine-val {
  margin-left: auto;
  font-size: 11px;
  color: var(--ink);
}

.engine-meta {
  font-size: 11px;
  color: var(--ink-muted);
  border-top: 1px solid var(--border);
  padding-top: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==================== WORKSPACE & TOPBAR ==================== */
.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-icon.mobile-menu-btn {
  display: none;
}

.view-title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--ink);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.main-content {
  padding: 22px 24px 40px;
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
}

.view {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.view[hidden] {
  display: none;
}

/* ==================== BUTTONS ==================== */
.btn {
  appearance: none;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease), color 160ms var(--ease), transform 120ms var(--ease);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

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

.btn-primary {
  background: var(--orange);
  color: #FFFFFF;
}

.btn-primary:hover:not(:disabled) {
  background: var(--orange-hover);
}

.btn-purple {
  background: var(--purple);
  color: #FFFFFF;
}

.btn-purple:hover:not(:disabled) {
  background: var(--purple-hover);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--ink);
  border-color: var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-subtle);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(24, 21, 18, 0.06);
  color: var(--ink);
}

.btn-danger-ghost {
  background: var(--red-soft);
  color: var(--red);
  border-color: #F5C2C2;
}

.btn-danger-ghost:hover:not(:disabled) {
  background: #FDE2E2;
}

.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-xs { padding: 5px 9px; font-size: 12px; }

.btn-icon {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-secondary);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.btn-icon:hover {
  background: var(--bg-subtle);
  color: var(--ink);
}

/* ==================== ONBOARDING PANEL ==================== */
.onboarding-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}

.onboarding-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}

.section-heading {
  margin: 0 0 4px;
  font-size: 16.5px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.section-sub {
  margin: 0;
  font-size: 13px;
  color: var(--ink-secondary);
  max-width: 68ch;
}

.onboarding-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.progress-pill {
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--purple-soft);
  color: var(--purple);
}

.onboarding-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.ob-step {
  background: var(--bg-canvas);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.ob-step.done {
  background: var(--green-soft);
  border-color: #B7E4DF;
}

.ob-step-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ob-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  font-size: 11.5px;
  font-weight: 800;
  color: var(--ink);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.ob-step.done .ob-check {
  background: var(--green);
  border-color: var(--green);
  color: #FFFFFF;
}

.ob-step h3 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 700;
}

.ob-step p {
  margin: 0;
  font-size: 12.2px;
  color: var(--ink-secondary);
  line-height: 1.42;
  flex: 1;
}

.ob-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

/* ==================== KPI STRIP ==================== */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.kpi-cell {
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-right: 1px solid var(--border);
}

.kpi-cell:last-child {
  border-right: none;
}

.kpi-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
}

.kpi-value {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.2;
}

.kpi-meta {
  font-size: 11.5px;
  color: var(--ink-secondary);
}

/* ==================== NOTICE ==================== */
.inline-notice {
  background: var(--purple-soft);
  border: 1px solid var(--purple-border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.notice-body > strong {
  display: block;
  font-size: 13px;
  color: var(--purple);
  margin-bottom: 2px;
}

.notice-body p {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-secondary);
  max-width: 78ch;
}

/* ==================== PANELS & TABLES ==================== */
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 800;
  letter-spacing: -0.015em;
}

.panel-desc {
  margin: 3px 0 0;
  font-size: 12.6px;
  color: var(--ink-secondary);
  max-width: 68ch;
}

.split-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 18px;
  align-items: start;
}

.split-ingest {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 18px;
  align-items: start;
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 10px;
  border-bottom: 1px solid var(--bg-subtle);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background: #FAF8F5;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-green { background: var(--green-soft); color: var(--green); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-purple { background: var(--purple-soft); color: var(--purple); }
.badge-orange { background: var(--orange-soft); color: var(--orange); }
.badge-neutral { background: var(--bg-subtle); color: var(--ink-secondary); }

/* ==================== FORMS (modern-web-guidance: validate-input-after-interaction) ==================== */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
}

.hint {
  display: block;
  font-size: 11.5px;
  color: var(--ink-muted);
  line-height: 1.3;
}

.field input[type="text"],
.field input[type="tel"],
.field input[type="number"],
.field select,
.field textarea,
.copilot-form textarea,
.hitl-list-head select {
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ink);
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  width: 100%;
  transition: border-color 150ms var(--ease), background-color 150ms var(--ease);
}

.field textarea, .copilot-form textarea {
  resize: vertical;
}

.error-msg {
  display: none;
  color: var(--red);
  font-size: 12px;
  font-weight: 600;
  margin-top: 2px;
}

/* Show validation state ONLY after interaction (:user-invalid + fallback via :is()) */
.field :is(input, select, textarea):is(:user-invalid, .user-invalid-fallback) {
  border-color: var(--red);
  background-color: var(--red-soft);
}

.field :is(input, select, textarea):is(:user-invalid, .user-invalid-fallback) + .error-msg {
  display: block;
}

.field :is(input, select, textarea):user-valid {
  border-color: var(--green);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.8px;
  color: var(--ink-secondary);
  cursor: pointer;
}

.form-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 4px;
}

/* ==================== DROPZONE ==================== */
.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-canvas);
  padding: 22px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 160ms var(--ease), background-color 160ms var(--ease);
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--orange);
  background: var(--orange-soft);
}

.file-input-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-icon {
  width: 28px;
  height: 28px;
  color: var(--orange);
  margin: 0 auto 8px;
  display: block;
}

.drop-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
}

.drop-sub {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 3px;
}

.pipeline-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.stage-chip {
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-subtle);
  color: var(--ink-secondary);
  padding: 3px 8px;
  border-radius: 6px;
}

.queue-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.queue-row {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.queue-row strong {
  display: block;
  font-size: 13px;
}

.queue-row small {
  color: var(--ink-muted);
  font-size: 11.5px;
}

/* ==================== TABS (modern-web-guidance: tabs) ==================== */
.tablist {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scroll-snap-type: inline proximity;
}

[role="tab"] {
  appearance: none;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-secondary);
  padding: 10px 14px;
  cursor: pointer;
  position: relative;
  flex: none;
  scroll-snap-align: start;
}

[role="tab"]:hover {
  color: var(--ink);
}

[role="tab"][aria-selected="true"] {
  color: var(--ink);
}

/* Indicator drawn with border on ::after (WCAG 1.4.1 & forced-colors safe, no dimension shift) */
[role="tab"][aria-selected="true"]::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  border-block-end: 2.5px solid var(--orange);
}

/* Per MWG tabs guide: no padding/margin/border on [role="tabpanel"] itself when using hidden="until-found" */
[role="tabpanel"] {
  padding: 0;
  margin: 0;
  border: 0;
}

.tabpanel-inner {
  padding-top: 16px;
}

/* ==================== HITL INSPECTOR ==================== */
.hitl-layout {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.hitl-list-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hitl-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.hitl-list-head select {
  width: auto;
  padding: 5px 8px;
  font-size: 12px;
}

.episode-rail {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 70vh;
  overflow-y: auto;
}

.ep-rail-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-canvas);
  border-radius: var(--radius-md);
  padding: 10px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: border-color 140ms var(--ease), background-color 140ms var(--ease);
}

.ep-rail-btn:hover {
  border-color: var(--border-strong);
  background: var(--bg-surface);
}

.ep-rail-btn.selected {
  border-color: var(--orange);
  background: var(--orange-soft);
}

.ep-rail-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
}

.ep-rail-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  color: var(--ink-muted);
}

.hitl-workspace {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}

.hitl-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.det-meta {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 3px;
}

.hitl-decision-bar {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.video-metrics-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.9fr);
  gap: 16px;
  margin-bottom: 18px;
}

.video-stage video {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #11100E;
  border-radius: var(--radius-md);
  display: block;
}

.video-caption-bar {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--ink-muted);
}

.signal-box {
  background: var(--bg-canvas);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.signal-box h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
}

.metric-dl {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  font-size: 12.2px;
}

.metric-dl dt { color: var(--ink-muted); }
.metric-dl dd { margin: 0; font-weight: 700; text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.qa-feedback-box {
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.qa-fb-title {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--purple);
  margin-bottom: 3px;
}

.qa-feedback-box p {
  margin: 0;
  font-size: 12.2px;
  color: var(--ink-secondary);
}

/* Action Segments Timeline */
.segments-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.segment-row {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.seg-time-btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--bg-canvas);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.seg-time-btn:hover {
  border-color: var(--orange);
  color: var(--orange);
}

.seg-main strong {
  display: block;
  font-size: 13px;
  color: var(--ink);
}

.seg-main p {
  margin: 2px 0 6px;
  font-size: 12.2px;
  color: var(--ink-secondary);
}

.seg-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.diag-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.diag-item {
  background: var(--bg-canvas);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}

.diag-item span {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-muted);
  margin-bottom: 3px;
}

.diag-item p {
  margin: 0;
  font-size: 13px;
  color: var(--ink);
}

.code-block {
  background: #1B1816;
  color: #F3EEE9;
  padding: 14px;
  border-radius: var(--radius-md);
  font-size: 12px;
  overflow-x: auto;
  margin: 0;
}

/* ==================== NEON INTELLIGENCE VIEW ==================== */
.neon-spec-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.neon-spec-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: var(--bg-canvas);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  gap: 10px;
}

.prompt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 10px;
}

.chip-btn {
  appearance: none;
  border: 1px solid var(--purple-border);
  background: var(--purple-soft);
  color: var(--purple);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.chip-btn:hover {
  background: #E7DCF7;
}

.copilot-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
}

.copilot-output {
  margin-top: 14px;
  background: var(--bg-canvas);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
}

.copilot-out-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 11.5px;
  color: var(--ink-muted);
}

.copilot-answer {
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  color: var(--ink);
}

/* ==================== EMPTY STATES ==================== */
.empty-state {
  padding: 34px 20px;
  text-align: center;
  max-width: 480px;
  margin: 0 auto;
}

.empty-icon {
  width: 36px;
  height: 36px;
  color: var(--ink-muted);
  margin: 0 auto 10px;
  display: block;
}

.empty-state h3 {
  margin: 0 0 5px;
  font-size: 15px;
  font-weight: 800;
}

.empty-state p {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--ink-secondary);
}

.empty-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ==================== NATIVE MODAL DIALOG (modern-web-guidance: dialog) ==================== */
dialog.studio-dialog {
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  color: var(--ink);
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 32px);
  box-shadow: var(--shadow-popover);
}

/* Scope display to dialog[open] so closed state is never overridden */
dialog.studio-dialog[open] {
  display: flex;
  flex-direction: column;
}

/* Mandatory scroll containment per MWG dialog guide — scoped to modal dialogs only so non-modal tour popovers stay clear */
dialog:modal {
  overscroll-behavior: contain;
}

dialog:modal::backdrop {
  background: rgba(24, 21, 18, 0.45);
  backdrop-filter: blur(2px);
  overflow: hidden;
  overscroll-behavior: contain;
}

.tour-popover::backdrop {
  background: transparent;
  backdrop-filter: none;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.dialog-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}

.dialog-body {
  padding: 18px 20px;
  overflow-y: auto;
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 8px;
}

/* ==================== PERSISTENT APP TOUR POPOVER (modern-web-guidance: persistent-app-tours) ==================== */
.tour-popover {
  max-width: 310px;
  padding: 16px;
  border: 1px solid var(--purple-border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--ink);
  box-shadow: var(--shadow-popover);
}

[popover]:is(:popover-open, .\:popover-open).tour-popover {
  display: block;
}

/* Gate inset: auto inside @supports so unsupported browsers never strand at (0,0) */
@supports (position-area: block-end) {
  .tour-popover[data-anchor="neon"] { position-anchor: --tour-neon; }
  .tour-popover[data-anchor="ingest"] { position-anchor: --tour-ingest; }
  .tour-popover[data-anchor="review"] { position-anchor: --tour-review; }
  .tour-popover[data-anchor="releases"] { position-anchor: --tour-releases; }

  .tour-popover {
    inset: auto;
    margin: 0 0 0 12px;
    position-area: right center;
    position-try-fallbacks: flip-inline, flip-block;
  }
}

@supports not (position-area: block-end) {
  .tour-popover {
    position: fixed;
    inset: auto 20px 20px auto;
    margin: 0;
  }
}

.tour-step-meta {
  font-size: 11px;
  font-weight: 700;
  color: var(--purple);
  margin-bottom: 4px;
}

.tour-title {
  margin: 0 0 6px;
  font-size: 14.5px;
  font-weight: 800;
}

.tour-body {
  margin: 0 0 12px;
  font-size: 12.8px;
  color: var(--ink-secondary);
  line-height: 1.45;
}

.tour-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ==================== TOASTS ==================== */
.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
}

.toast {
  background: var(--ink);
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-popover);
  max-width: 360px;
}

.toast.error { background: var(--red); }
.toast.ok { background: var(--green); }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1080px) {
  .onboarding-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-cell { border-bottom: 1px solid var(--border); }
  .split-2, .split-ingest, .hitl-layout, .video-metrics-grid { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 260px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 200ms var(--ease);
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-popover); }
  .btn-icon.mobile-menu-btn { display: grid; }
  .topbar { padding: 10px 14px; }
  .main-content { padding: 14px; }
  .onboarding-header { flex-direction: column; gap: 10px; }
  .onboarding-steps, .field-row, .diag-grid { grid-template-columns: 1fr; }
  .topbar-actions .btn span { display: none; }
}
