/*
 * Editorial completion pass
 *
 * Scope is intentionally driven by WorkspaceSideNav's active data-nav-key.
 * Calendar and Users are omitted so those surfaces remain untouched until
 * their dedicated follow-up work.
 */

:is(
  body:has(#editorial-workspace-nav [data-nav-key="overview"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="review_desk"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="pitches"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="articles"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="review_notes"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="themes"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="library"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="reports"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="publish_failures"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="notifications"][aria-current="page"])
) .studio-brand-workspace main {
  background: #fff;
}

/* Section-tier StudioCard wrappers flatten when they are direct page children. */
:is(
  body:has(#editorial-workspace-nav [data-nav-key="review_desk"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="pitches"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="review_notes"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="themes"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="library"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="reports"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="publish_failures"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="notifications"][aria-current="page"])
) .studio-brand-workspace main > div[class*="space-y-"] > .border.border-hairlineSoft.bg-canvas {
  border: 0 !important;
  background: transparent !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

/* Adjacent page sections use spacing and a hairline rather than card gaps. */
:is(
  body:has(#editorial-workspace-nav [data-nav-key="review_desk"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="pitches"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="review_notes"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="themes"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="library"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="reports"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="publish_failures"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="notifications"][aria-current="page"])
) .studio-brand-workspace main > div[class*="space-y-"] > .border.border-hairlineSoft.bg-canvas + .border.border-hairlineSoft.bg-canvas {
  border-top: 1px solid rgba(16, 39, 30, 0.14) !important;
  padding-top: 1.5rem !important;
}

/* Shared Editorial register treatment. */
:is(
  body:has(#editorial-workspace-nav [data-nav-key="review_desk"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="pitches"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="articles"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="themes"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="library"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="reports"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="publish_failures"][aria-current="page"])
) .studio-brand-workspace .studio-table {
  border-collapse: collapse;
}

:is(
  body:has(#editorial-workspace-nav [data-nav-key="review_desk"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="pitches"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="articles"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="themes"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="library"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="reports"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="publish_failures"][aria-current="page"])
) .studio-brand-workspace .studio-table thead {
  color: rgba(16, 39, 30, 0.62);
}

:is(
  body:has(#editorial-workspace-nav [data-nav-key="review_desk"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="pitches"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="articles"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="themes"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="library"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="reports"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="publish_failures"][aria-current="page"])
) .studio-brand-workspace .studio-table tbody tr {
  transition: background-color 120ms ease;
}

:is(
  body:has(#editorial-workspace-nav [data-nav-key="review_desk"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="pitches"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="articles"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="themes"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="library"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="publish_failures"][aria-current="page"])
) .studio-brand-workspace .studio-table tbody tr:hover {
  background: rgba(0, 50, 31, 0.025);
}

/* Legacy underlined record links become the shared quiet record-title action. */
:is(
  body:has(#editorial-workspace-nav [data-nav-key="overview"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="review_desk"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="pitches"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="articles"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="review_notes"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="themes"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="library"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="publish_failures"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="notifications"][aria-current="page"])
) .studio-brand-workspace main button.underline {
  text-decoration: none !important;
  color: #00321f;
  font-weight: 700;
  text-underline-offset: 4px;
}

:is(
  body:has(#editorial-workspace-nav [data-nav-key="overview"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="review_desk"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="pitches"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="articles"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="review_notes"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="themes"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="library"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="publish_failures"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="notifications"][aria-current="page"])
) .studio-brand-workspace main button.underline:hover {
  text-decoration: underline !important;
}

/* Pitches migrated to StudioRegister in PR100. */

/* Articles migrated to StudioRegister in PR100. */

/* Review notes and notifications become hairline activity streams, not stacks of cards. */
:is(
  body:has(#editorial-workspace-nav [data-nav-key="review_notes"][aria-current="page"]),
  body:has(#editorial-workspace-nav [data-nav-key="notifications"][aria-current="page"])
) .studio-brand-workspace main div.space-y-2 > .border.p-3 {
  border-width: 0 0 1px 0 !important;
  border-color: rgba(16, 39, 30, 0.14) !important;
  background: transparent !important;
  padding: 0.9rem 0 !important;
}

/* Themes and Library migrated to StudioRegister in PR100. */

/* Publish failures are genuine exceptions: keep stronger boundaries but remove decorative nesting. */
body:has(#editorial-workspace-nav [data-nav-key="publish_failures"][aria-current="page"]) .studio-brand-workspace main > div.space-y-4 > .border.border-hairlineSoft.bg-canvas:last-child {
  border-left: 2px solid #b42318 !important;
  padding-left: 1rem !important;
}

body:has(#editorial-workspace-nav [data-nav-key="publish_failures"][aria-current="page"]) .studio-brand-workspace main .grid.md\:grid-cols-2 > .border {
  border-width: 0 0 1px 0 !important;
  background: transparent !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

/* Notifications: tab controls stay compact; notification state should not look like a second badge system. */
body:has(#editorial-workspace-nav [data-nav-key="notifications"][aria-current="page"]) .studio-brand-workspace main div.space-y-2 > .border.p-3 > div:first-child > span[class*="border"] {
  border: 0 !important;
  background: transparent !important;
  padding: 0 !important;
}

/* Overview metric strip is already structurally right; reduce dashboard-like box weight. */
body:has(#editorial-workspace-nav [data-nav-key="overview"][aria-current="page"]) .studio-brand-workspace main .grid.border-t.border-l {
  border-color: rgba(16, 39, 30, 0.14) !important;
}

body:has(#editorial-workspace-nav [data-nav-key="overview"][aria-current="page"]) .studio-brand-workspace main .grid.border-t.border-l > div {
  border-color: rgba(16, 39, 30, 0.14) !important;
  background: transparent !important;
}

/* Editor: preserve the writing surface and settings architecture, clean only the chrome/title. */
body:has(#editorial-workspace-nav [data-nav-key="editor"][aria-current="page"]) .studio-brand-workspace main {
  padding: 0 !important;
  background: #fff;
}

body:has(#editorial-workspace-nav [data-nav-key="editor"][aria-current="page"]) #editor-post-title {
  font-size: clamp(1.75rem, 3.2vw, 2.35rem) !important;
  line-height: 1.08 !important;
  font-weight: 750 !important;
  letter-spacing: -0.03em !important;
  border-left: 0 !important;
  border-bottom: 1px solid rgba(16, 39, 30, 0.18) !important;
  padding-left: 0 !important;
  padding-bottom: 0.75rem !important;
  margin-bottom: 0.75rem !important;
  color: #10271e !important;
}

body:has(#editorial-workspace-nav [data-nav-key="editor"][aria-current="page"]) #editor-post-title:focus {
  border-bottom-color: #00321f !important;
  box-shadow: none !important;
}

body:has(#editorial-workspace-nav [data-nav-key="editor"][aria-current="page"]) #editor-post-title::placeholder {
  color: rgba(16, 39, 30, 0.28) !important;
}

body:has(#editorial-workspace-nav [data-nav-key="editor"][aria-current="page"]) #editor-post-title + div {
  margin-bottom: 1rem !important;
}

body:has(#editorial-workspace-nav [data-nav-key="editor"][aria-current="page"]) #editor-post-title + div > span:not([class*="inline-flex"]) {
  color: rgba(16, 39, 30, 0.56) !important;
  font-size: 0.7rem !important;
  letter-spacing: 0.04em !important;
}

/* Mobile: lists remain scan-first rows rather than card stacks. */
@media (max-width: 767px) {
  :is(
    body:has(#editorial-workspace-nav [data-nav-key="review_desk"][aria-current="page"]),
    body:has(#editorial-workspace-nav [data-nav-key="pitches"][aria-current="page"]),
    body:has(#editorial-workspace-nav [data-nav-key="articles"][aria-current="page"]),
    body:has(#editorial-workspace-nav [data-nav-key="review_notes"][aria-current="page"]),
    body:has(#editorial-workspace-nav [data-nav-key="themes"][aria-current="page"]),
    body:has(#editorial-workspace-nav [data-nav-key="library"][aria-current="page"]),
    body:has(#editorial-workspace-nav [data-nav-key="notifications"][aria-current="page"])
  ) .studio-brand-workspace main {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  :is(
    body:has(#editorial-workspace-nav [data-nav-key="review_desk"][aria-current="page"]),
    body:has(#editorial-workspace-nav [data-nav-key="pitches"][aria-current="page"]),
    body:has(#editorial-workspace-nav [data-nav-key="articles"][aria-current="page"]),
    body:has(#editorial-workspace-nav [data-nav-key="themes"][aria-current="page"]),
    body:has(#editorial-workspace-nav [data-nav-key="library"][aria-current="page"])
  ) .studio-brand-workspace main .md\:hidden.space-y-2 {
    gap: 0 !important;
  }
}

/* PR101 Editorial launch polish */

/* Editor empty state: keep the canvas open and lightweight rather than turning
   the absence of a selected article into a giant object card. */
body:has(#editorial-workspace-nav [data-nav-key="editor"][aria-current="page"]) .studio-brand-workspace main > .border.p-6.bg-white/95 {
  max-width: 44rem;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  padding: 2rem 0 !important;
  box-shadow: none !important;
}

/* Review Notes and Notifications are activity feeds, but they render with
   different DOM shapes. Keep their launch contracts explicit so selectors
   cannot silently match one feed and miss the other. */
/* Review Notes rows render as div.space-y-4 > article.relative.pl-9 >
   div.rounded-md.border.p-4 — the feed wrapper's spacing is Tailwind's
   margin-based space-y-4 (not CSS gap), so it has to be overridden as
   margin, and the card selectors must route through the <article> wrapper
   rather than assuming it is a direct child of the space-y-4 container. */
body:has(#editorial-workspace-nav [data-nav-key="review_notes"][aria-current="page"]) .studio-brand-workspace main div.space-y-4:has(> article > .rounded-md.border.p-4) > article ~ article {
  margin-top: 0.7rem !important;
}

body:has(#editorial-workspace-nav [data-nav-key="review_notes"][aria-current="page"]) .studio-brand-workspace main div.space-y-4 > article > .rounded-md.border.p-4 {
  min-height: 0;
  border-width: 0 0 1px 0 !important;
  border-radius: 0 !important;
  border-color: rgba(16, 39, 30, 0.14) !important;
  background: transparent !important;
  padding: 0.7rem 0 !important;
}

body:has(#editorial-workspace-nav [data-nav-key="review_notes"][aria-current="page"]) .studio-brand-workspace main div.space-y-4 > article > .rounded-md.border.p-4 p.text-xs {
  line-height: 1.35;
}

body:has(#editorial-workspace-nav [data-nav-key="notifications"][aria-current="page"]) .studio-brand-workspace main div.space-y-2 {
  gap: 0 !important;
}

body:has(#editorial-workspace-nav [data-nav-key="notifications"][aria-current="page"]) .studio-brand-workspace main div.space-y-2 > .border.p-3 {
  min-height: 0;
  padding: 0.7rem 0 !important;
}

body:has(#editorial-workspace-nav [data-nav-key="notifications"][aria-current="page"]) .studio-brand-workspace main div.space-y-2 > .border.p-3 p.text-xs {
  line-height: 1.35;
}

/* Reports are read/scan surfaces. Keep controls compact and let tables retain
   usable width at narrow-desktop sizes rather than crushing columns. */
body:has(#editorial-workspace-nav [data-nav-key="reports"][aria-current="page"]) .studio-brand-workspace main :where(input, select) {
  min-height: 32px;
}

body:has(#editorial-workspace-nav [data-nav-key="reports"][aria-current="page"]) .studio-brand-workspace main .studio-table {
  font-size: 0.78rem;
}

body:has(#editorial-workspace-nav [data-nav-key="reports"][aria-current="page"]) .studio-brand-workspace main .studio-table th,
body:has(#editorial-workspace-nav [data-nav-key="reports"][aria-current="page"]) .studio-brand-workspace main .studio-table td {
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
}

/* Publish Failures are genuine exceptions, but the exception treatment should
   be compact and operational rather than a set of oversized cards. */
body:has(#editorial-workspace-nav [data-nav-key="publish_failures"][aria-current="page"]) .studio-brand-workspace main > div.space-y-4 {
  gap: 0.75rem !important;
}

body:has(#editorial-workspace-nav [data-nav-key="publish_failures"][aria-current="page"]) .studio-brand-workspace main .grid.md\:grid-cols-2 {
  gap: 0.75rem !important;
}

body:has(#editorial-workspace-nav [data-nav-key="publish_failures"][aria-current="page"]) .studio-brand-workspace main .grid.md\:grid-cols-2 > .border {
  padding-top: 0.7rem !important;
  padding-bottom: 0.7rem !important;
}

/* Narrow desktop/tablet launch sweep. The PR100 register pages already change
   grammar below 1200px; supporting Editorial surfaces should also avoid
   squeezed controls and accidental horizontal overflow in this band. */
@media (min-width: 768px) and (max-width: 1199px) {
  :is(
    body:has(#editorial-workspace-nav [data-nav-key="review_notes"][aria-current="page"]),
    body:has(#editorial-workspace-nav [data-nav-key="reports"][aria-current="page"]),
    body:has(#editorial-workspace-nav [data-nav-key="publish_failures"][aria-current="page"]),
    body:has(#editorial-workspace-nav [data-nav-key="notifications"][aria-current="page"])
  ) .studio-brand-workspace main {
    min-width: 0;
  }

  body:has(#editorial-workspace-nav [data-nav-key="reports"][aria-current="page"]) .studio-brand-workspace main .studio-table,
  body:has(#editorial-workspace-nav [data-nav-key="publish_failures"][aria-current="page"]) .studio-brand-workspace main .studio-table {
    min-width: 680px;
  }
}

@media (max-width: 767px) {
  :is(
    body:has(#editorial-workspace-nav [data-nav-key="review_notes"][aria-current="page"]),
    body:has(#editorial-workspace-nav [data-nav-key="reports"][aria-current="page"]),
    body:has(#editorial-workspace-nav [data-nav-key="publish_failures"][aria-current="page"]),
    body:has(#editorial-workspace-nav [data-nav-key="notifications"][aria-current="page"])
  ) .studio-brand-workspace main {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  body:has(#editorial-workspace-nav [data-nav-key="reports"][aria-current="page"]) .studio-brand-workspace main :where(input, select, button) {
    max-width: 100%;
  }
}


/* Studio shell + focused Editor layout */
body:has(#editorial-workspace-nav [data-nav-key="editor"][aria-current="page"]) .editor-empty-state {
  width: min(100%, 56rem);
  margin: 0 auto;
  padding: 3rem 2rem;
  border: 0;
  background: transparent;
}

body:has(#editorial-workspace-nav [data-nav-key="editor"][aria-current="page"]) .editor-workspace-shell {
  border-radius: 0;
}

@media (min-width: 1024px) {
  body:has(#editorial-workspace-nav [data-nav-key="editor"][aria-current="page"]) .editor-workspace-shell {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    max-height: none;
    flex-direction: column;
    border: 0;
  }

  body:has(#editorial-workspace-nav [data-nav-key="editor"][aria-current="page"]) .editor-workspace-body {
    flex: 1 1 auto;
    min-height: 0 !important;
    overflow: hidden;
  }

  body:has(#editorial-workspace-nav [data-nav-key="editor"][aria-current="page"]) .editor-settings-rail,
  body:has(#editorial-workspace-nav [data-nav-key="editor"][aria-current="page"]) .editor-writing-pane {
    height: 100%;
    max-height: 100%;
    min-height: 0;
    overscroll-behavior: contain;
  }

  body:has(#editorial-workspace-nav [data-nav-key="editor"][aria-current="page"]) .editor-settings-rail,
  body:has(#editorial-workspace-nav [data-nav-key="editor"][aria-current="page"]) .editor-writing-pane {
    overflow-y: auto;
  }
}

@media (max-width: 1023px) {
  body:has(#editorial-workspace-nav [data-nav-key="editor"][aria-current="page"]) .editor-workspace-shell,
  body:has(#editorial-workspace-nav [data-nav-key="editor"][aria-current="page"]) .editor-workspace-body,
  body:has(#editorial-workspace-nav [data-nav-key="editor"][aria-current="page"]) .editor-writing-pane {
    height: auto;
    max-height: none;
    min-height: 0;
    overflow: visible;
  }

  body:has(#editorial-workspace-nav [data-nav-key="editor"][aria-current="page"]) .editor-writing-pane {
    overscroll-behavior: auto;
  }

  body:has(#editorial-workspace-nav [data-nav-key="editor"][aria-current="page"]) .editor-writing-canvas {
    height: auto;
    min-height: 0;
  }
}

@media (max-width: 767px) {
  body:has(#editorial-workspace-nav [data-nav-key="editor"][aria-current="page"]) .editor-empty-state {
    padding: 2rem 1rem;
  }
}


/* Simplified Editor settings rail */
.editor-settings-rail {
  gap: 0 !important;
}

.editor-settings-rail > .editor-settings-section,
.editor-settings-rail > section.editor-settings-section,
.editor-settings-rail > section > .editor-settings-section {
  margin: 0 !important;
  padding: 1rem 0 !important;
  border: 0 !important;
  border-top: 1px solid rgba(10, 47, 34, 0.12) !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.editor-settings-rail > section.editor-settings-section:first-of-type {
  border-top: 0 !important;
  padding-top: 0.25rem !important;
}

.editor-settings-rail .editor-settings-section .rounded-lg,
.editor-settings-rail .editor-settings-section .rounded-md {
  border-radius: 3px;
}
