/* Theme Foundation - CSS Custom Properties */

:root {
  /* Font Family */
  --color-font-family: var(--theme-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);

  /* Shadow */
  --color-shadow: var(--theme-shadow);

  /* Primary Colors */
  --color-primary: var(--theme-primary);
  --color-primary-hover: var(--theme-primary-hover);
  --color-primary-soft: var(--theme-primary-soft);

  /* Accent Colors */
  --color-accent: var(--theme-accent);
  --color-accent-hover: var(--theme-accent-hover);

  /* Surface Colors */
  --color-surface: var(--theme-surface);
  --color-surface-elevated: var(--theme-surface-elevated);
  --color-surface-sunken: var(--theme-surface-sunken);

  /* Sidebar Colors */
  --color-sidebar: var(--theme-sidebar);
  --color-sidebar-elevated: var(--theme-sidebar-elevated);

  /* Editor Colors */
  --color-editor-bg: var(--theme-editor-bg);

  /* Modal Overlay */
  --color-overlay: var(--theme-overlay);

  /* Text Colors */
  --color-text-primary: var(--theme-text-primary);
  --color-text-secondary: var(--theme-text-secondary);
  --color-text-tertiary: var(--theme-text-tertiary);
  --color-text-on-dark: var(--theme-text-on-dark);
  --color-text-on-dark-secondary: var(--theme-text-on-dark-secondary);
  --color-content-search-muted: var(--theme-content-search-muted, #cbd5e1);
  --color-content-search-focus: var(--theme-content-search-focus, #93c5fd);

  /* Border Colors */
  --color-border: var(--theme-border);
  --color-border-subtle: var(--theme-border-subtle);

  /* Button Colors */
  --color-button-secondary: var(--theme-button-secondary);

  /* Status Colors */
  --color-danger: var(--theme-danger);
  --color-danger-hover: var(--theme-danger-hover);
  --color-success: var(--theme-success);

  /* Action Button Colors */
  --color-action-edit: var(--theme-action-edit);
  --color-action-delete: var(--theme-action-delete);
  --color-action-assign: var(--theme-action-assign);
  /* The row's *share* label needs a filled surface that white text reads on,
     which the pale `--theme-action-assign` text colour is not. Themed, with a
     fallback so a theme that does not define it still renders a legible chip. */
  --color-action-assign-strong: var(--theme-action-assign-strong, #16a34a);
  --color-action-assign-strong-hover: var(--theme-action-assign-strong-hover, #15803d);

  /* Content-row privacy badge. Unlike the category and share labels this one
     is deliberately outlined rather than filled, so its border is the only
     thing drawing its bounds — and the row underneath it changes surface on
     hover. `--color-border` and `--color-surface-sunken` are both slate-700
     in this theme, so a badge outlined in the generic border token was drawn
     in exactly the colour the hovered row painted behind it and vanished at
     1.00:1 precisely when the pointer was on it. These are therefore their
     own tokens, stepped off the row surfaces rather than reusing the generic
     border, so the badge cannot silently re-merge if either surface moves. */
  --color-privacy-border: var(--theme-privacy-border, #64748b);
  --color-privacy-border-hover: var(--theme-privacy-border-hover, #cbd5e1);
  --color-privacy-surface-hover: var(--theme-privacy-surface-hover, #475569);
  --color-privacy-text-hover: var(--theme-privacy-text-hover, #f1f5f9);
  /* The primary blue reads 2.00:1 on the hovered row surface, so the badge's
     focus ring needs a tint that clears 3:1 on page, hovered row and filled
     badge alike instead of disappearing on the state it is most used in. */
  --color-privacy-focus-ring: var(--theme-privacy-focus-ring, #93c5fd);

  /* Navigation Colors */
  --color-nav-text: var(--theme-nav-text);
}

/* CMS navigation and page bodies share one inline frame, including at narrow widths. */
:root {
  --cms-content-width: 72rem;
  --cms-content-gutter: 1rem;
}

@media (min-width: 48rem) {
  :root { --cms-content-gutter: 2rem; }
}

.cms-content-frame {
  width: 100%;
  max-width: var(--cms-content-width);
  margin-inline: auto;
  padding-inline: var(--cms-content-gutter);
}

/* One asymmetric blue ring for pre-boot and session resolution, matching
   front's 6rem/2px initial-loading spinner. The 4rem/4px page overlay is a
   separate, text-bearing data-loading context; the base scale stays inline. */
:root {
  --cms-spinner-size: 2rem;
  --cms-spinner-page-size: 4rem;
  --cms-spinner-large-size: 6rem;
  --cms-spinner-border: 2px;
  --cms-spinner-page-border: 4px;
  --cms-spinner-duration: 1s;
  --cms-spinner-color: var(--theme-primary-hover);
}

.cms-initial-loading {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cms-loading-status {
  display: flex;
  flex: 1;
  min-block-size: 100vh;
  align-items: center;
  justify-content: center;
  background: var(--color-surface);
}

.cms-shell .cms-loading-status {
  min-block-size: 0;
}

.cms-spinner {
  display: block;
  inline-size: var(--cms-spinner-size);
  block-size: var(--cms-spinner-size);
  border: var(--cms-spinner-border) solid transparent;
  border-top-color: var(--cms-spinner-color);
  border-bottom-color: var(--cms-spinner-color);
  border-radius: 50%;
  animation: cms-spinner-rotate var(--cms-spinner-duration) linear infinite;
}

.cms-spinner--page {
  inline-size: var(--cms-spinner-page-size);
  block-size: var(--cms-spinner-page-size);
  border-width: var(--cms-spinner-page-border);
}

.cms-spinner--large {
  inline-size: var(--cms-spinner-large-size);
  block-size: var(--cms-spinner-large-size);
}

@keyframes cms-spinner-rotate {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .cms-spinner { animation-duration: calc(var(--cms-spinner-duration) * 3); }
}

.cms-startup-error {
  padding: 2rem;
  color: var(--color-text-primary);
  text-align: center;
}

/* In normal flow after the CMS main, never overlaid on short or long pages. */
:root {
  --cms-footer-brand-gap: 8rem;
  --cms-footer-brand-padding: 2rem;
}

.cms-footer-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-block-start: var(--cms-footer-brand-gap);
  padding-block: var(--cms-footer-brand-padding);
  border-block-start: 1px solid var(--color-border);
}

/* Shared brand mark and entity glyphs retain their proportions without inline sizing. */
:root {
  --fleck-brand-mark-size: 2rem;
  --cms-entity-trigger-size: 1.5rem;
  --cms-entity-choice-size: 2rem;
}

.fleck-brand-mark {
  inline-size: var(--fleck-brand-mark-size);
  block-size: var(--fleck-brand-mark-size);
  flex: none;
}

.cms-entity-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.cms-entity-icon--trigger {
  --fleck-brand-mark-size: var(--cms-entity-trigger-size);
  inline-size: var(--cms-entity-trigger-size);
  block-size: var(--cms-entity-trigger-size);
}

.cms-entity-icon--choice {
  --fleck-brand-mark-size: var(--cms-entity-choice-size);
  inline-size: var(--cms-entity-choice-size);
  block-size: var(--cms-entity-choice-size);
}

.cms-entity-chip { inline-size: 100%; block-size: 100%; }

.cms-dropdown-chevron {
  inline-size: var(--cms-button-icon-size);
  block-size: var(--cms-button-icon-size);
  flex: none;
  transition: transform 150ms ease;
}
.cms-dropdown-chevron--open { transform: rotate(180deg); }

/* The content toolbar keeps the create action and the search field on one
   inline-start aligned row inside the shared frame. Below the wrap threshold
   the search field moves to its own row instead of overflowing the frame. */
:root {
  --cms-toolbar-gap: 1rem;
  --cms-toolbar-search-min: 14rem;
  --cms-toolbar-control-height: 2.75rem;
  --cms-button-icon-gap: 0.5rem;
  --cms-button-icon-size: 1.25rem;
  --cms-new-content-font-size: 1rem;
  --cms-new-content-line-height: 1.5;
  --cms-new-content-font-weight: 400;
}

.cms-content-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: var(--cms-toolbar-gap);
  inline-size: 100%;
}

.cms-content-toolbar-search {
  flex: 1 1 var(--cms-toolbar-search-min);
  min-inline-size: min(var(--cms-toolbar-search-min), 100%);
}

/* Only Content search uses the original front search palette: the generic
   .cms-input remains on the page surface for other forms. */
.cms-content-toolbar-search .cms-input {
  background: var(--color-surface-sunken);
  color: var(--color-text-primary);
}
.cms-content-toolbar-search .cms-input::placeholder {
  color: var(--color-content-search-muted);
  opacity: 1;
}
.cms-content-toolbar-search .cms-input:focus-visible {
  border-color: var(--color-content-search-focus);
  outline-color: var(--color-content-search-focus);
}
.cms-content-toolbar-search .cms-input:disabled {
  background: var(--color-surface-sunken);
  color: var(--color-content-search-muted);
  opacity: 1;
}
.cms-content-toolbar-search .cms-input:disabled::placeholder {
  color: var(--color-content-search-muted);
  opacity: 1;
}

/* The create action and the search field are one control pair on one row, so
   both take their height from a single token instead of from whatever their own
   font size, padding and border happen to sum to. Left intrinsic they diverge —
   the button's smaller type settles at 36px beside a 42px field — and a short
   button next to a taller field reads as misaligned, which the original
   front-end never showed because there both controls resolved to one height.
   The shared value is a step above the taller of the two, so the pair matches
   without the field having to shrink, and both stay at an accessible pointer
   target size. Height is set on the border box, so the tokens stay authoritative
   and no caller needs an inline style to correct the row. */
.cms-content-toolbar > .cms-button-icon,
.cms-content-toolbar-search .cms-input {
  box-sizing: border-box;
  block-size: var(--cms-toolbar-control-height);
}

.cms-button-icon {
  display: inline-flex;
  align-items: center;
  gap: var(--cms-button-icon-gap);
  white-space: nowrap;
}

.cms-button-icon > svg {
  inline-size: var(--cms-button-icon-size);
  block-size: var(--cms-button-icon-size);
  flex: none;
}

/* front's create button has no text-sm/font-semibold utility: its label is
   inherited 16px normal text with the Tailwind base 1.5 line height. Scope
   this correction to Content so other icon actions keep their own typography. */
.cms-content-toolbar .cms-new-content-button {
  font-family: var(--color-font-family);
  font-size: var(--cms-new-content-font-size);
  font-weight: var(--cms-new-content-font-weight);
  line-height: var(--cms-new-content-line-height);
}

/* Modal backdrop. The editor and confirmation dialogs sit above the CMS page
   rather than replacing it, so the scrim stays half transparent and the content
   behind it remains legible. Both the scrim colour and its alpha come from
   tokens, so no component carries a literal value and no palette utility can
   turn the overlay opaque again. */
:root {
  --cms-overlay-color: var(--color-overlay);
  --cms-overlay-opacity: 0.5;
  --cms-overlay-padding: 1rem;
}

.cms-editor-backdrop {
  background: color-mix(
    in srgb,
    var(--cms-overlay-color) calc(var(--cms-overlay-opacity) * 100%),
    transparent
  );
  padding: var(--cms-overlay-padding);
}

/* The original Content delete confirmation has its own 75%-black scrim,
   bottom-aligned mobile sheet, and centered 32rem panel at the sm breakpoint.
   Other dialogs keep the shared half-opacity backdrop. */
.cms-delete-backdrop {
  --cms-overlay-color: var(--color-overlay);
  --cms-overlay-opacity: 0.75;
  overflow-y: auto;
}
.cms-delete-positioner {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 100%;
  padding: 1rem 0 5rem;
  text-align: center;
}
.cms-delete-panel {
  display: inline-block;
  vertical-align: bottom;
  width: 100%;
  border-radius: 0.5rem;
  overflow: hidden;
  text-align: left;
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  transition: transform 150ms ease, opacity 150ms ease;
}
.cms-delete-body { padding: 1.25rem 1rem 1rem; }
.cms-delete-warning {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  margin-inline: auto;
  border-radius: 50%;
  background: #fee2e2;
  color: #dc2626;
}
.cms-delete-warning-icon { width: 1.5rem; height: 1.5rem; }
.cms-delete-copy { margin-block-start: 0.75rem; text-align: center; }
.cms-delete-title { color: var(--color-text-primary); font-size: 1.125rem; line-height: 1.5rem; font-weight: 500; }
.cms-delete-message { margin-block-start: 0.5rem; color: var(--color-text-secondary); font-size: 0.875rem; }
.cms-delete-actions { padding: 0.75rem 1rem; }
.cms-delete-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  font-size: 1rem;
  font-weight: 500;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}
.cms-delete-action + .cms-delete-action { margin-block-start: 0.75rem; }
.cms-delete-panel button:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
@media (min-width: 640px) {
  .cms-delete-positioner { align-items: center; padding: 0; }
  .cms-delete-panel { width: 100%; max-width: 32rem; margin-block: 2rem; vertical-align: middle; }
  .cms-delete-body { padding: 1.5rem 1.5rem 1rem; }
  .cms-delete-layout { display: flex; align-items: flex-start; }
  .cms-delete-warning { width: 2.5rem; height: 2.5rem; margin-inline: 0; }
  .cms-delete-copy { margin-block-start: 0; margin-inline-start: 1rem; text-align: left; }
  .cms-delete-actions { display: flex; flex-direction: row-reverse; padding-inline: 1.5rem; }
  .cms-delete-action { width: auto; font-size: 0.875rem; }
  .cms-delete-action + .cms-delete-action { margin-block-start: 0; margin-inline-end: 0.75rem; }
}
@media (prefers-reduced-motion: reduce) {
  .cms-delete-panel { transition: none; }
}

/* While an irreversible action is being confirmed, the list behind the dialog
   must not scroll: the backdrop covers the page but does not consume wheel
   events, so the row the question is about would otherwise move away from
   under it. The scrollbar gutter is kept so locking does not reflow the page
   sideways. */
/* The original content-operation toast sits at the viewport's bottom-left,
   independent of the full-page loading bar and of the confirmation dialog. */
.cms-content-delete-progress {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  z-index: 51;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  background: var(--color-primary);
  color: white;
  box-shadow: var(--color-shadow);
  font-size: 0.875rem;
}
.cms-content-delete-progress-spinner {
  inline-size: 1rem;
  block-size: 1rem;
  flex: none;
  border: 2px solid rgb(255 255 255 / 0.25);
  border-top-color: white;
  border-radius: 50%;
  animation: cms-spinner-rotate var(--cms-spinner-duration) linear infinite;
}
@media (prefers-reduced-motion: reduce) {
  .cms-content-delete-progress-spinner { animation-duration: calc(var(--cms-spinner-duration) * 3); }
}

.cms-delete-dialog-open {
  overflow: hidden;
  scrollbar-gutter: stable;
}

/* The rich Markdown editor surface. The pinned distribution paints its own
   chrome; the dialog and its host establish a definite height for the editor's
   percentage-sized panes while preserving the shared border token. */
:root {
  --cms-editor-dialog-height: min(90vh, 52rem);
  --cms-editor-dialog-width: min(90vw, 72rem);
  --cms-editor-height: 100%;
}

/* Keep the full toolbar visible at desktop widths, but leave a usable margin
   around the dialog. The form is the flex child that shrinks; the Markdown
   surface fills the remaining height instead of fixing itself at 24rem. */
.cms-editor-dialog {
  display: flex;
  flex-direction: column;
  inline-size: var(--cms-editor-dialog-width);
  max-inline-size: 100%;
  block-size: var(--cms-editor-dialog-height);
  max-block-size: calc(100dvh - 2 * var(--cms-overlay-padding));
  overflow: auto;
}

.cms-editor-dialog form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-block-size: 0;
}

.cms-editor-dialog form > .block {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-block-size: 0;
}

/* Toast UI sizes its mounted host as a percentage, so every ancestor between
   the flexing form and that host needs a resolved block size. */
.cms-rich-editor {
  display: block;
  flex: 1 1 auto;
  min-block-size: 0;
  block-size: var(--cms-editor-height);
}

.cms-rich-editor-host {
  block-size: 100%;
}

.cms-rich-editor .toastui-editor-defaultUI {
  border-color: var(--color-border);
  border-radius: 0.5rem;
}

/* The pinned Toast UI stylesheet reserves 36px below .ProseMirror for its
   mode switch (height: calc(100% - 36px)). This CMS editor disables that
   switch, leaving the dark container's #121212 exposed as a black stripe.
   Fill the available editing pane rather than repainting the gap. */
.cms-rich-editor .toastui-editor-md-container .ProseMirror {
  block-size: 100%;
}

@media (max-width: 48rem) {
  .cms-editor-dialog {
    inline-size: 100%;
  }
}

/* Keeps a form control's accessible name in the tree while the design shows
   only the placeholder. */
.cms-visually-hidden {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.cms-nav-actions { justify-content: flex-start; }
.cms-nav-account { margin-inline-start: auto; }

/* Original application typography and CMS management surfaces. Keep landing styles independent. */
body {
  font-family: var(--color-font-family);
}

.cms-shell {
  background: var(--color-surface);
  color: var(--color-text-primary);
}

.cms-panel {
  background: var(--color-surface-elevated);
  border: 1px solid var(--color-border);
  box-shadow: var(--color-shadow);
}

/* The original Assign dialog is max-w-md; existing direct grants remain a
   subordinate section after the two primary actions. Scroll within the panel
   when either the grant list or mobile keyboard reduces the available height. */
.cms-assign-panel { max-inline-size: 28rem; max-block-size: calc(100dvh - 2 * var(--cms-overlay-padding)); overflow-y: auto; }
.cms-assign-label { color: var(--color-text-secondary); }
.cms-assign-select { background: var(--color-surface-sunken); color: var(--color-text-primary); border: 1px solid var(--color-border); }
.cms-assign-select:focus-visible, .cms-assign-panel button:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.cms-assign-panel button:disabled { opacity: 0.5; cursor: not-allowed; }
.cms-assign-existing { border-block-start: 1px solid var(--color-border); padding-block-start: 1rem; }
.cms-assign-grant { background: var(--color-surface-sunken); color: var(--color-text-primary); }
.cms-assign-revoke, .cms-assign-error { color: var(--color-danger); }
.cms-assign-revoke:hover { background: var(--color-surface-elevated); }

.cms-list {
  background: var(--color-surface-elevated);
  border: 1px solid var(--color-border);
  box-shadow: var(--color-shadow);
}

.cms-list > * + * {
  border-top: 1px solid var(--color-border);
}

/* X list: one elevated card with divided rows, matching the original feed.
   Actions remain in the keyboard tree; pointer and focus reveal them. */
.cms-tweets-list > * + * { border-block-start: 1px solid var(--color-border); }
.cms-tweet-row { padding: 1.25rem; transition: background-color 0.2s; }
.cms-tweet-row:hover { background: var(--color-surface-sunken); }
.cms-tweet-header, .cms-tweet-footer {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}
.cms-tweet-header { align-items: flex-start; }
.cms-tweet-text { flex: 1 1 auto; min-inline-size: 0; margin-inline-end: 1rem; overflow-wrap: anywhere; white-space: pre-wrap; color: var(--color-text-primary); }
.cms-tweet-editor {
  flex: 1 1 auto;
  min-inline-size: 0;
  min-block-size: 5rem;
  padding: 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 0.375rem;
  background: var(--color-surface-sunken);
  color: var(--color-text-primary);
}
.cms-tweet-editor:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.cms-tweet-actions { display: flex; flex: none; align-items: flex-start; gap: 0.5rem; opacity: 0.3; transition: opacity 0.2s; }
.cms-tweet-row:hover .cms-tweet-actions, .cms-tweet-row:focus-within .cms-tweet-actions { opacity: 1; }
.cms-tweet-action { display: inline-flex; align-items: center; justify-content: center; min-inline-size: 2rem; min-block-size: 2rem; border-radius: 0.25rem; color: var(--color-text-secondary); font-size: 1.25rem; transition: color 0.2s, background-color 0.2s; }
.cms-tweet-action:hover { background: var(--color-surface-sunken); color: var(--color-text-primary); }
.cms-tweet-action--delete { color: var(--color-danger); font-size: 1rem; }
.cms-tweet-action:disabled { color: var(--color-text-tertiary); cursor: not-allowed; }
.cms-tweet-action:focus-visible, .cms-tweet-publish:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.cms-tweet-footer { align-items: flex-end; flex-wrap: wrap; margin-block-start: 0.75rem; }
.cms-tweet-metrics, .cms-tweet-date { color: var(--color-text-secondary); }
.cms-tweet-date { margin-inline-start: auto; font-size: 0.75rem; }
.cms-tweet-moderation { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.cms-tweet-moderation span { color: var(--color-accent); font-size: 0.75rem; }
.cms-tweet-publish { padding: 0.25rem 0.75rem; border-radius: 0.375rem; background: var(--color-button-secondary); color: var(--color-text-primary); font-size: 0.875rem; font-weight: 500; }
.cms-tweet-publish:disabled { opacity: 0.5; cursor: not-allowed; }
.cms-tweets-empty { display: flex; flex-direction: column; align-items: center; gap: 1rem; padding: 3rem; text-align: center; }
.cms-tweets-empty svg { inline-size: 4rem; block-size: 4rem; color: var(--color-text-tertiary); }
.cms-tweets-empty h3 { color: var(--color-text-secondary); font-size: 1.125rem; font-weight: 500; }
.cms-tweets-empty p { max-inline-size: 28rem; color: var(--color-text-tertiary); }
@media (max-width: 40rem) {
  .cms-tweet-header { flex-wrap: wrap; }
  .cms-tweet-actions { margin-inline-start: auto; }
  .cms-tweet-text, .cms-tweet-editor { flex-basis: 100%; margin-inline-end: 0; }
}
@media (hover: none) { .cms-tweet-actions { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .cms-tweet-row, .cms-tweet-actions, .cms-tweet-action { transition: none; }
}

.cms-list-item {
  background: transparent;
  transition: background-color 0.2s;
}

.cms-list-item:hover {
  background: var(--color-surface-sunken);
}

/* Content rows: actions belong to the title edge, access and date to the
   opposite edges of the footer. Wrapping preserves reading order on phones. */
.cms-list-item-header, .cms-list-item-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}
.cms-list-item-header { align-items: flex-start; }
.cms-list-item-header > .cms-heading { min-inline-size: 0; overflow-wrap: anywhere; }
.cms-list-item-actions { display: flex; flex-wrap: wrap; align-items: center; margin-inline-start: auto; }
.cms-list-action {
  padding: 0.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  background: transparent;
  border-radius: 0.25rem;
}
.cms-list-action--edit { color: var(--color-action-edit); }
.cms-list-action--delete { color: var(--color-action-delete); }
.cms-list-action--assign { color: var(--color-action-assign); }
.cms-list-action:hover { background: var(--color-surface-sunken); }
.cms-list-action:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
.cms-list-item-footer { align-items: flex-end; margin-block-start: 1rem; }
.cms-list-item-access { display: flex; flex: 1 1 auto; flex-wrap: wrap; align-items: center; gap: 0.25rem; min-inline-size: 0; }
.cms-list-item-date {
  margin-inline-start: auto;
  padding: 0.25rem;
  color: var(--color-text-secondary);
  font-size: 0.75rem;
  white-space: nowrap;
}
.cms-privacy-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  color: var(--color-text-secondary);
  font-size: 0.75rem;
  border: 1px solid var(--color-privacy-border);
  border-radius: 9999px;
  background: transparent;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

/* The badge states the row's visibility, so it has to stay readable as a
   distinct control while the row under it is hovered — including when the
   pointer is on the row but not on the badge itself, which is the state the
   generic border token lost. Hovering the row therefore lifts the badge's
   border, and hovering the badge additionally fills it, so "the row is
   active" and "this control is the target" stay tellable apart. */
.cms-list-item:hover .cms-privacy-toggle,
.cms-list-item:focus-within .cms-privacy-toggle {
  border-color: var(--color-privacy-border-hover);
  /* The secondary text colour reads 6.96:1 on the resting row but only
     4.04:1 once the row lifts to slate-700, which is under AA for 12px
     text. The label states visibility, so it is raised with the border
     rather than left to degrade on the state it is most often read in. */
  color: var(--color-text-primary);
}
.cms-privacy-toggle:hover,
.cms-privacy-toggle:focus-visible {
  background: var(--color-privacy-surface-hover);
  border-color: var(--color-privacy-border-hover);
  color: var(--color-privacy-text-hover);
}
.cms-privacy-toggle:focus-visible {
  outline: 2px solid var(--color-privacy-focus-ring);
  outline-offset: 2px;
}
/* Touch surfaces report no hover, so the badge never gets the hovered-row
   lift there and must carry the legible outline at rest instead. */
@media (hover: none) {
  .cms-privacy-toggle {
    border-color: var(--color-privacy-border-hover);
    color: var(--color-text-primary);
  }
}
@media (prefers-reduced-motion: reduce) {
  .cms-privacy-toggle { transition: none; }
}
.cms-privacy-icon { inline-size: 1rem; block-size: 1rem; flex: none; }

/* Assignment labels on a content row. The original app rendered two separate
   tag strips here (`content-category-tags` then `content-user-grant-tags`),
   and the distinction is meaningful rather than decorative: a category is an
   organizational label, a contact share is access granted to one person. They
   are therefore two classes with two fills, not one shared chip, so the two
   kinds remain tellable apart without reading the text. Neither is the
   privacy toggle, which states visibility and is deliberately left outlined
   rather than filled. */
.cms-category-chip,
.cms-share-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  font-size: 0.75rem;
  border: 1px solid transparent;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}
.cms-category-chip {
  color: var(--color-text-on-dark);
  background: var(--color-primary);
}
.cms-category-chip:hover { background: var(--color-primary-hover); }
.cms-share-chip {
  color: var(--color-text-on-dark);
  background: var(--color-action-assign-strong);
}
.cms-share-chip:hover { background: var(--color-action-assign-strong-hover); }
.cms-category-chip:focus-visible,
.cms-share-chip:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* The editor's audience control. A fieldset of three radios rather than a
   toggle, because the three states are not a progression: `shared` is a
   restricted intent the server stores explicitly, so it must be selectable as
   its own option instead of being derived from how many readers were added.
   The options wrap on a narrow viewport so none of the three is clipped. */
.cms-visibility { border: 0; margin: 0; padding: 0; }
.cms-visibility-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}
.cms-visibility-option {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  color: var(--color-text-primary);
  cursor: pointer;
}
.cms-visibility-option input:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
/* The three audiences stay tellable apart without reading the label, using the
   same vocabulary the list's privacy icon follows. */
.cms-visibility-state[data-visibility="public"] { color: var(--color-text-primary); }
.cms-visibility-state[data-visibility="restricted"] { color: var(--color-text-primary); }
.cms-visibility-state[data-visibility="private"] { color: var(--color-text-primary); }
/* Who the entry is shared with. Only rendered for the restricted audience, so
   it reads as part of that choice rather than as an independent setting. */
.cms-share-panel { display: block; }
.cms-share-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

/* Contacts is the original two-pane browser: a fixed-measure selectable list
   on the inline-start edge and the conversation pane filling the rest. The
   280px list measure, the sidebar surface behind it, and the sunken page
   surface are the original calibration, expressed as tokens so no component
   carries a literal and the panes can collapse on narrow viewports. */
:root {
  --cms-contact-list-width: 280px;
  --cms-contact-panes-gap: 1.5rem;
  /* The panes fill the viewport below the navbar; the original reserved
     140px for it. Kept as a token, and `dvh` so a mobile URL bar collapsing
     does not clip the list. */
  --cms-contact-panes-offset: 140px;
  --cms-contact-panes-height: calc(100dvh - var(--cms-contact-panes-offset));
  --cms-contact-panes-min-height: 24rem;
}

.cms-contact-panes {
  display: flex;
  gap: var(--cms-contact-panes-gap);
  block-size: var(--cms-contact-panes-height);
  min-block-size: var(--cms-contact-panes-min-height);
  background: var(--color-surface-sunken);
}

.cms-contact-list {
  display: flex;
  flex-direction: column;
  flex: none;
  inline-size: var(--cms-contact-list-width);
  max-inline-size: 100%;
  background: var(--color-sidebar);
  border: 1px solid var(--color-border);
  box-shadow: var(--color-shadow);
}

.cms-contact-list-scroll {
  flex: 1 1 auto;
  min-block-size: 0;
  overflow-y: auto;
  padding-block-start: 1rem;
}

.cms-contact-options { list-style: none; margin: 0; padding: 0; }

.cms-contact-option {
  padding: 0.75rem 1rem;
  color: var(--color-text-on-dark);
  background: transparent;
  cursor: pointer;
  transition: background-color 0.2s;
}

.cms-contact-option:hover { background: var(--color-sidebar-elevated); }
.cms-contact-option[aria-selected="true"] { background: var(--color-sidebar-elevated); }
.cms-contact-option:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

.cms-contact-option-name { font-weight: 500; }

.cms-contact-list-message { padding: 1rem; text-align: center; }
.cms-contact-list-message-title { color: var(--color-text-on-dark); }
.cms-contact-list-message-body { color: var(--color-text-on-dark-secondary); font-size: 0.875rem; }
.cms-contact-list-error-title { color: var(--color-danger); }

.cms-contact-pane {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-inline-size: 0;
  overflow: hidden;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: var(--color-shadow);
}

.cms-contact-pane-body {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  min-block-size: 0;
  overflow-y: auto;
  padding: 1.5rem;
  text-align: center;
}

.cms-contact-pane-card { max-inline-size: 32rem; }
.cms-contact-pane-title { color: var(--color-text-secondary); font-size: 1.125rem; }
.cms-contact-pane-text { color: var(--color-text-tertiary); font-size: 0.875rem; }
.cms-contact-pane-error { color: var(--color-danger); }
.cms-contact-pane-id {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 0.25rem;
  background: var(--color-surface-sunken);
  color: var(--color-text-primary);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}
.cms-contact-pane-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
.cms-contact-pane-actions a:focus-visible,
.cms-contact-pane-actions button:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Below the two-pane threshold the list becomes a capped-height band above
   the pane, so neither is reduced to an unusable sliver on a phone. */
@media (max-width: 48rem) {
  :root { --cms-contact-panes-height: auto; }
  .cms-contact-panes { flex-direction: column; min-block-size: 0; }
  .cms-contact-list { inline-size: 100%; max-block-size: 40vh; }
  .cms-contact-pane { min-block-size: var(--cms-contact-panes-min-height); }
}

@media (prefers-reduced-motion: reduce) {
  .cms-contact-option { transition: none; }
}

/* Settings follows the original narrow, vertically spaced card stack. */
.cms-settings-column { max-inline-size: 48rem; padding-block: 0.5rem; }
.cms-settings-card { margin-block-end: 2rem; }
.cms-settings-toggle { display: inline-flex; align-items: center; gap: 0.75rem; color: var(--color-text-primary); cursor: pointer; }
.cms-settings-toggle:has(input:disabled) { opacity: 0.7; cursor: not-allowed; }
.cms-settings-toggle input:disabled { cursor: not-allowed; }
.cms-settings-toggle-input { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; }
.cms-settings-toggle-track {
  position: relative; display: inline-block; flex: none; inline-size: 3.5rem; block-size: 2rem;
  border-radius: 9999px; background: var(--color-border); transition: background-color 0.2s;
}
.cms-settings-toggle-track::after {
  content: ""; position: absolute; inset-block-start: 0.25rem; inset-inline-start: 0.25rem;
  inline-size: 1.5rem; block-size: 1.5rem; border-radius: 50%; background: white;
  transition: transform 0.2s, background-color 0.2s;
}
.cms-settings-toggle-input:checked + .cms-settings-toggle-track::after {
  transform: translateX(100%); background: var(--color-primary);
}
[dir="rtl"] .cms-settings-toggle-input:checked + .cms-settings-toggle-track::after { transform: translateX(-100%); }
.cms-settings-toggle-input:focus-visible + .cms-settings-toggle-track { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.cms-settings-questions { list-style: none; padding: 0; }
.cms-settings-question { display: flex; align-items: center; gap: 0.5rem; margin-block-end: 0.5rem; }
.cms-settings-question input {
  flex: 1 1 auto; min-inline-size: 0; padding: 0.5rem;
  border: 1px solid var(--color-border); border-radius: 0.25rem;
  background: var(--color-surface-sunken);
}
/* The questions are stored with ids this deployment's writer cannot preserve,
   so the list is shown read-only rather than offered for a destructive edit.
   The inputs stay legible rather than being dimmed to the usual disabled
   grey: the content is still the operator's own data to read. */
.cms-settings-questions-locked { color: var(--color-text-secondary); }
.cms-settings-question input:disabled {
  color: var(--color-text-secondary); cursor: default; opacity: 1;
}
.cms-settings-remove { flex: none; color: var(--color-danger); }
.cms-settings-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; }
.cms-settings-connected { color: var(--color-success); }
.cms-settings-unavailable { color: var(--color-text-secondary); }
.cms-settings-unconnected, .cms-settings-remove { color: var(--color-danger); }
.cms-settings-remove:focus-visible, .cms-settings-actions button:focus-visible,
.cms-settings-social button:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .cms-settings-toggle-track, .cms-settings-toggle-track::after { transition: none; }
}

.cms-heading, .cms-primary-text { color: var(--color-text-primary); }
.cms-muted { color: var(--color-text-secondary); }
.cms-divider { border-color: var(--color-border); }
/* Keep the public header variant independent of CMS navigation. */
.cms-landing-header { border-block-end: 0 solid var(--color-border); }
.cms-feature-unavailable { background: var(--color-surface-elevated); opacity: .55; cursor: not-allowed; }
.cms-content-tab { color: var(--color-text-secondary); }
.cms-content-tab[aria-selected="true"] {
  background: var(--color-surface-elevated);
  color: var(--color-nav-text);
}
.cms-content-tab:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
.cms-input {
  background: var(--color-surface);
  border-color: var(--color-border);
  color: var(--color-text-primary);
}
.cms-input:focus-visible { border-color: var(--color-primary); outline: 2px solid var(--color-primary); outline-offset: 1px; }
.cms-primary-button { background: var(--color-primary); color: white; }
.cms-primary-button:hover { background: var(--color-primary-hover); }
.cms-secondary-button {
  background: var(--color-surface-elevated);
  border: 1px solid var(--color-border);
  color: var(--color-text-primary);
}
.cms-secondary-button:hover { background: var(--color-surface-sunken); }
.cms-success-button { background: var(--color-success); color: white; }
.cms-danger-button { background: var(--color-danger); color: white; }
.cms-danger-button:hover { background: var(--color-danger-hover); }
.cms-nav-button {
  background: var(--color-surface-elevated);
  border: 1px solid var(--color-border);
  color: var(--color-nav-text);
}
.cms-nav-button:hover:not(:disabled) { background: var(--color-surface-sunken); }
.cms-nav-button:disabled { opacity: 0.5; cursor: not-allowed; }
.cms-nav-button[aria-current="page"] { box-shadow: 0 0 0 2px var(--color-nav-text); }
/* The original preview lives at the viewport's top inline-start corner, not
   among the framed navbar actions. Logical placement mirrors it for RTL. */
.cms-nav-preview-position {
  position: fixed;
  inset-block-start: 0.75rem;
  inset-inline-start: 1rem;
  padding: 1rem;
  z-index: 51;
}
.cms-nav-preview {
  color: var(--color-text-primary);
  text-decoration: none;
}
.cms-nav-preview:hover { text-decoration: none; }
.cms-nav-preview:disabled { opacity: 0.5; cursor: not-allowed; }
.cms-popup {
  background: var(--color-surface-elevated);
  border: 1px solid var(--color-border);
  color: var(--color-text-primary);
}
.cms-popup button:hover { background: var(--color-surface-sunken); }
.cms-table { border-collapse: collapse; min-width: 34rem; }
.cms-table th { background: var(--color-surface-elevated); color: var(--color-text-secondary); }
.cms-table td { background: var(--color-surface); color: var(--color-text-primary); }
.cms-table tbody tr + tr { border-top: 1px solid var(--color-border); }
.cms-table th, .cms-table td { text-align: start; }

/* Global button hover effects */
button[style*="background-color: var(--color-danger)"]:hover {
  background-color: var(--color-danger-hover) !important;
  transition: background-color 0.2s ease;
}