/* ─────────────────────────────────────────────────────────────────────────────
   Aegis CMS — module-scoped CSS  (C.1 Item overhaul 2026-06-14)
   Implementation of GPT R2-validated spec cms-item-overhaul-spec-r2-20260614.md.
   ───────────────────────────────────────────────────────────────────────────── */

/* ── Module-scope tokens ────────────────────────────────────────────────────
   Scoped to all module-level selectors. --aegis-sidebar-width is intentionally
   NOT declared here — .cms-sticky-bar consumes it via var() fallback only
   (R2 NEW-1 fix: declaring it at CMS scope would override host-inherited values). */
.cms-editor-grid, .cms-tab-strip, .cms-editor-toolbar, .cms-editor-textarea,
.cms-sticky-bar, .cms-preview-panel, .cms-draft-banner, .cms-item-header,
.cms-preview-frame, .cms-preview-toolbar, .cms-preview-chrome,
.cms-preview-site-header {
    --cms-accent:        #4f46e5;
    --cms-accent-soft:   #eef2ff;
    --cms-accent-border: #c7d2fe;
    --cms-text:          #172b4d;
    --cms-sub:           #374151;
    --cms-muted:         #6b7280;
    --cms-faint:         #9ca3af;
    --cms-border:        #e5e7eb;
    --cms-border-soft:   #f3f4f6;
    --cms-surface:       #ffffff;
    --cms-surface-alt:   #f9fafb;
    --cms-draft-bg:      #fef3c7;
    --cms-draft-fg:      #b45309;
    --cms-draft-border:  #fde68a;
    --cms-green:         #16a34a;
    --cms-green-soft:    #dcfce7;
    --cms-green-text:    #15803d;
}

/* ── Item header (inline status badge strip below page header) ──────────── */
.cms-item-header {
    margin-bottom: 1rem;
}

.cms-item-status-row {
    display:     flex;
    align-items: center;
    gap:         10px;
}

.cms-back-link {
    margin-left:     auto;
    font-size:       .8rem;
    color:           var(--cms-muted);
    text-decoration: none;
    border:          1px solid var(--cms-border);
    border-radius:   .375rem;
    padding:         .2rem .55rem;
}

.cms-back-link:hover {
    color:            var(--cms-text);
    background-color: var(--cms-surface-alt);
}

/* ── Badge base + status variants ──────────────────────────────────────────
   Purpose-built replacements for Bootstrap .badge so the editor is
   self-contained. */
.cms-bs-dot {
    font-size: 6px;
}

.bs {
    display:       inline-flex;
    align-items:   center;
    gap:           3px;
    font-size:     10px;
    font-weight:   600;
    padding:       2px 8px;
    border-radius: 10px;
}

.bs-draft {
    background: #fef3c7;
    color:      #b45309;
}

.bs-published {
    background: #dcfce7;
    color:      #15803d;
}

.bs-muted {
    background: #f3f4f6;
    color:      #6b7280;
}

/* ── Editor grid (two-column author / preview split) ─────────────────────── */
.cms-editor-grid {
    display:               grid;
    grid-template-columns: minmax(0, 55fr) minmax(0, 45fr);
    gap:                   1.25rem;
    align-items:           start;
    padding-bottom:        80px; /* prevent fixed sticky bar from overlaying content */
}

@media (max-width: 992px) {
    .cms-editor-grid { grid-template-columns: 1fr; }
}

/* ── Editor column (left — hosts draft banner + tab strip + panels) ───────── */
.cms-editor-column {
    display:        flex;
    flex-direction: column;
    min-width:      0;
}

/* ── Draft banner ─────────────────────────────────────────────────────────── */
.cms-draft-banner {
    display:        flex;
    align-items:    center;
    gap:            .4rem;
    background:     var(--cms-draft-bg);
    color:          var(--cms-draft-fg);
    border:         1px solid var(--cms-draft-border);
    border-radius:  .375rem;
    padding:        .45rem .75rem;
    margin-bottom:  .75rem;
    font-size:      .78rem;
    font-weight:    600;
    letter-spacing: .02em;
}

/* ── Tab strip (Editor / Page data) ──────────────────────────────────────── */
.cms-tab-strip {
    display:       flex;
    gap:           0;
    border-bottom: 1px solid var(--cms-border);
    margin-bottom: 0;
    padding-bottom: 0;
}

.cms-tab-link {
    border:          0;
    border-bottom:   2px solid transparent;
    border-radius:   0;
    margin-bottom:   -1px;
    text-decoration: none;
    padding:         .55rem 1rem;
    color:           var(--cms-muted);
    font-size:       .85rem;
    font-weight:     500;
    background:      transparent;
    cursor:          pointer;
    display:         inline-flex;
    align-items:     center;
    gap:             .3rem;
}

.cms-tab-link:hover {
    color: var(--cms-text);
}

.cms-tab-link.active {
    border-bottom-color: var(--cms-accent);
    color:               var(--cms-accent);
    font-weight:         600;
    background:          transparent;
}

/* ── Tab panel wrapper ────────────────────────────────────────────────────── */
.cms-tab-panel {
    padding-top: 1rem;
}

/* ── Editor toolbar ───────────────────────────────────────────────────────── */
.cms-editor-toolbar {
    display:     flex;
    align-items: center;
    gap:         4px;
    padding:     8px 12px;
    background:  #fafafa;
    border:      1px solid var(--cms-border);
    border-bottom: 0;
    border-radius: .5rem .5rem 0 0;
    flex-wrap:   wrap;
}

.cms-toolbar-select {
    height:        28px;
    padding:       0 .5rem;
    font-size:     .78rem;
    border:        1px solid var(--cms-border);
    border-radius: 4px;
    background:    var(--cms-surface);
    color:         var(--cms-text);
    cursor:        pointer;
    margin-right:  4px;
}

.cms-toolbar-group {
    display:       flex;
    flex-direction: row;
    border:        1px solid var(--cms-border);
    border-radius: 4px;
    overflow:      hidden;
}

.cms-toolbar-btn {
    width:       28px;
    height:      28px;
    border:      none;
    background:  #fff;
    font-size:   13px;
    cursor:      pointer;
    display:     inline-flex;
    align-items: center;
    justify-content: center;
    padding:     0;
    color:       var(--cms-sub);
}

.cms-toolbar-btn:hover {
    background: #f3f4f6;
}

.cms-toolbar-u {
    text-decoration: underline;
}

.cms-toolbar-mode-toggle {
    margin-left:    auto;
    display:        inline-flex;
    border:         1px solid var(--cms-border);
    border-radius:  6px;
    overflow:       hidden;
}

.cms-mode-btn {
    padding:     4px 12px;
    font-size:   11px;
    font-weight: 700;
    border:      none;
    background:  #f3f4f6;
    color:       #6b7280;
    cursor:      pointer;
    display:     inline-flex;
    align-items: center;
    gap:         .25rem;
}

.cms-mode-btn.active {
    background: #4f46e5;
    color:      #fff;
}

/* ── Editor textarea ──────────────────────────────────────────────────────── */
.cms-editor-textarea {
    display:     block;
    width:       100%;
    min-height:  420px;
    margin:      0;
    padding:     .85rem 1rem;
    font-family: "SFMono-Regular", "Menlo", "Monaco", Consolas, "Liberation Mono", "Courier New", monospace;
    font-size:   .82rem;
    line-height: 1.55;
    color:       var(--cms-text);
    background:  var(--cms-surface);
    border:      1px solid var(--cms-border);
    border-radius: 0 0 .5rem .5rem;
    resize:      vertical;
    box-sizing:  border-box;
}

.cms-editor-textarea:focus {
    outline:      none;
    border-color: var(--cms-accent);
    box-shadow:   0 0 0 2px var(--cms-accent-soft);
}

.cms-editor-textarea-help {
    margin-top: .4rem;
    color:      var(--cms-faint);
    font-size:  .75rem;
}

/* ── JSON pretty-print view (readonly sibling to textarea) ────────────────── */
.cms-editor-json-pretty {
    display:     block;
    width:       100%;
    min-height:  420px;
    margin:      0;
    padding:     .85rem 1rem;
    font-family: "SFMono-Regular", "Menlo", "Monaco", Consolas, "Liberation Mono", "Courier New", monospace;
    font-size:   .82rem;
    line-height: 1.55;
    color:       var(--cms-sub);
    background:  var(--cms-surface-alt);
    border:      1px solid var(--cms-border);
    border-radius: 0 0 .5rem .5rem;
    overflow-x:  auto;
    box-sizing:  border-box;
    cursor:      default;
    white-space: pre;
}

/* ── Preview panel (right column) ────────────────────────────────────────── */
.cms-preview-panel {
    background:    var(--cms-surface);
    border:        1px solid var(--cms-border);
    border-radius: 8px;
    overflow:      hidden;
    position:      sticky;
    top:           1rem;
}

/* ── Preview toolbar ──────────────────────────────────────────────────────── */
.cms-preview-toolbar {
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    padding:         10px 16px;
    border-bottom:   1px solid var(--cms-border);
}

.cms-preview-toolbar-left {
    display:     flex;
    align-items: center;
    gap:         8px;
}

.cms-preview-label {
    font-size:      11px;
    font-weight:    700;
    color:          #6b7280;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.cms-preview-device-toggle {
    display:       inline-flex;
    border:        1px solid var(--cms-border);
    border-radius: 6px;
    overflow:      hidden;
}

.cms-pdt-btn {
    padding:      5px 12px;
    font-size:    11px;
    font-weight:  700;
    border:       none;
    border-right: 1px solid var(--cms-border);
    background:   #fff;
    color:        #6b7280;
    cursor:       pointer;
    display:      inline-flex;
    align-items:  center;
    gap:          .2rem;
}

.cms-pdt-btn:last-child {
    border-right: none;
}

.cms-pdt-btn.active {
    background: #172b4d;
    color:      #fff;
}

.cms-preview-ext-btn {
    border:        1px solid var(--cms-border);
    border-radius: 6px;
    padding:       4px 9px;
    background:    transparent;
    cursor:        pointer;
    font-size:     13px;
    color:         var(--cms-muted);
}

.cms-preview-ext-btn:disabled {
    opacity: .5;
    cursor:  not-allowed;
}

/* ── Browser chrome bar ───────────────────────────────────────────────────── */
.cms-preview-chrome {
    display:       flex;
    align-items:   center;
    gap:           8px;
    background:    #f9fafb;
    border-bottom: 1px solid var(--cms-border);
    padding:       8px 12px;
}

.cms-browser-dots {
    display:    flex;
    gap:        5px;
    flex-shrink: 0;
}

.cms-browser-dot {
    width:         10px;
    height:        10px;
    border-radius: 50%;
    display:       inline-block;
}

.cms-browser-dot-red    { background: #FF5F57; }
.cms-browser-dot-yellow { background: #FFBD2E; }
.cms-browser-dot-green  { background: #28C840; }

.cms-address-bar {
    flex:          1;
    display:       flex;
    align-items:   center;
    gap:           5px;
    background:    #fff;
    border:        1px solid var(--cms-border);
    border-radius: 5px;
    padding:       4px 10px;
}

.cms-address-lock {
    font-size: 10px;
    color:     #10B981;
}

.cms-address-text {
    color:       #172b4d;
    font-weight: 500;
    font-size:   11px;
}

/* ── Preview frame ────────────────────────────────────────────────────────── */
.cms-preview-frame {
    position:   relative;
    background: #fff;
    height:     600px;
    overflow-y: auto;
}

/* ── Draft ribbon (in-frame) ──────────────────────────────────────────────── */
.cms-preview-draft-ribbon {
    background:     #fef3c7;
    border-bottom:  1px solid #fde68a;
    padding:        7px 16px;
    font-size:      11px;
    color:          #92400e;
    text-align:     center;
    font-weight:    600;
    letter-spacing: .04em;
}

/* ── Unsaved indicator (pill badge with pulse dot) ─────────────────────────── */
.cms-preview-unsaved {
    position:        absolute;
    top:             10px;
    right:           10px;
    z-index:         20;
    display:         inline-flex;
    align-items:     center;
    gap:             5px;
    background:      #172b4d;
    color:           #fff;
    font-size:       10px;
    font-weight:     600;
    padding:         3px 9px;
    border-radius:   10px;
}

.cms-preview-unsaved-pulse {
    display:       inline-block;
    width:         6px;
    height:        6px;
    border-radius: 50%;
    background:    #FBBF24;
    animation:     pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%,100% { opacity: 1; }
    50%      { opacity: .4; }
}

/* ── Preview site-header (generic illustrative chrome, NOT the tenant's real nav) ── */
.cms-preview-site-header {
    background:      #1a1a2e;
    padding:         14px 28px;
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    flex-shrink:     0;
}

.cms-preview-site-brand {
    font-size:   14px;
    font-weight: 700;
    color:       #fff;
}

.cms-preview-site-nav {
    display: flex;
    gap:     18px;
    list-style: none;
    margin:  0;
    padding: 0;
}

.cms-preview-site-nav a {
    font-size:       12px;
    color:           rgba(255, 255, 255, 0.6);
    text-decoration: none;
}

.cms-preview-site-nav a.cms-preview-site-nav-active {
    color:       #fff;
    font-weight: 600;
}

/* ── Preview content ──────────────────────────────────────────────────────── */
.cms-preview-content {
    padding:     32px 24px 48px;
    font-size:   14px;
    line-height: 1.75;
    color:       #374151;
}

.cms-preview-eyebrow {
    font-size:      11px;
    font-weight:    700;
    text-transform: uppercase;
    letter-spacing: .8px;
    color:          #4f46e5;
    margin-bottom:  8px;
}

.cms-preview-title {
    font-size:   26px;
    font-weight: 700;
    color:       #111;
    line-height: 1.25;
    margin:      0 0 8px;
}

.cms-preview-meta {
    display:       grid;
    grid-template-columns: auto 1fr;
    gap:           4px 12px;
    font-size:     12px;
    color:         var(--cms-muted);
    border-top:    1px solid var(--cms-border);
    padding-top:   12px;
    margin-top:    8px;
}

.cms-preview-meta dt {
    font-weight: 600;
    color:       var(--cms-faint);
}

.cms-preview-meta dd {
    margin: 0;
    color:  var(--cms-sub);
}

/* ── Sticky save bar ──────────────────────────────────────────────────────── */
/* --aegis-sidebar-width is consumed-only here via var() fallback.
   It is NOT declared at CMS scope (R2 NEW-1 fix). The host/layout layer
   declares --aegis-sidebar-width when a non-default sidebar width is needed. */
.cms-sticky-bar {
    position:        fixed;
    bottom:          0;
    left:            var(--aegis-sidebar-width, 240px);
    right:           0;
    background:      #fff;
    border-top:      1px solid var(--cms-border);
    padding:         12px 28px;
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    z-index:         50;
}

.cms-sticky-status {
    display:     flex;
    align-items: center;
    gap:         10px;
}

.cms-sticky-label {
    font-size:   12px;
    font-weight: 600;
    color:       #6b7280;
}

.cms-sticky-timestamp {
    font-size: 12px;
    color:     #9ca3af;
}

.cms-sticky-actions {
    display: flex;
    gap:     8px;
}

/* ── Action buttons (sticky bar) ─────────────────────────────────────────── */
.cms-action-btn {
    padding:     8px 18px;
    font-size:   13px;
    font-weight: 600;
    border:      1px solid var(--cms-border);
    border-radius: 6px;
    cursor:      pointer;
    font-family: inherit;
}

.cms-action-btn-secondary {
    background: #fff;
    color:      #374151;
}

.cms-action-btn-publish {
    background:   #16a34a;
    color:        #fff;
    border-color: #16a34a;
    padding:      8px 22px;
}

.cms-action-btn-unpublish {
    background:   #fff;
    color:        #dc2626;
    border-color: var(--cms-border);
}

.cms-action-btn:disabled,
.cms-action-btn.disabled {
    opacity: .5;
    cursor:  not-allowed;
}

/* ── Misc helpers ─────────────────────────────────────────────────────────── */
.cms-defs-flush {
    margin-bottom: 0;
}

/* ── Content worklist toolbar (Content list page — do not remove) ─────────── */
.cms-content-toolbar {
    display:         flex;
    align-items:     flex-end;
    justify-content: space-between;
    gap:             1rem;
    margin-bottom:   1rem;
    flex-wrap:       wrap;
}

.cms-content-filterbar {
    display:       flex;
    gap:           .5rem;
    flex-wrap:     wrap;
    align-items:   end;
    margin-bottom: 0;
    flex:          1;
    min-width:     0;
}

.cms-content-filter-locale {
    max-width: 8rem;
}

.cms-content-new-btn {
    flex-shrink:  0;
    white-space:  nowrap;
    background:   var(--cms-accent) !important;
    border-color: var(--cms-accent) !important;
}

.cms-content-new-btn:hover {
    filter: brightness(.92);
}

/* ─────────────────────────────────────────────────────────────────────────────
   CMS CONTENT BODY TYPOGRAPHY
   Shared stylesheet loaded by BOTH the Item editor preview AND PublicCmsPage.
   Changes here affect both surfaces equally — that is intentional.
   ───────────────────────────────────────────────────────────────────────────── */

/* T3b: Delivery/preview visibility — blocks marked [data-cms-hidden] are hidden
   on the live site and in the editor preview panel.
   The IDE editor canvas overrides this rule so hidden blocks remain visible
   (dimmed + "Hidden" badge) while authoring — see aegis-cms-ide.css. */
[data-cms-hidden] { display: none; }

/* Hide the "Body" label emitted by SafeJsonContentRenderer for cms-safe-html fields.
   Applied via the shared stylesheet so the public page and the preview panel
   are identical (the spec's preview-==published CSS parity guarantee).
   Plain .cms-field labels (e.g. "Excerpt") remain visible. */
.cms-safe-html > .cms-field-label {
    display: none;
}

/* ── Delivered-page article column ──
   Was an inline style on Bridge's /p/{slug} <main>, which nothing tenant-authored could undo. As a
   class, a full-width site design (e.g. a raw-body parity port) can override it from its own
   body-carried stylesheet with plain equal-specificity rules. Default rendering is unchanged. */
.cms-page-main {
    max-width: 56rem;
    margin: 3rem auto;
    padding: 0 1.5rem;
}

/* Article body typography — matches cp-article-body from the canon prototype */
.cms-content .cms-field { margin-bottom: 0; }

.cms-content .cms-safe-html .cms-value h2 {
    font-size:   1.2rem;
    font-weight: 700;
    margin:      1.5rem 0 .5rem;
    color:       #111;
}

.cms-content .cms-safe-html .cms-value h3 {
    font-size:   1rem;
    font-weight: 700;
    margin:      1.25rem 0 .375rem;
    color:       #374151;
}

.cms-content .cms-safe-html .cms-value p {
    margin:      0 0 .875rem;
    color:       #374151;
    line-height: 1.75;
}

.cms-content .cms-safe-html .cms-value ul,
.cms-content .cms-safe-html .cms-value ol {
    margin:      0 0 .875rem 1.25rem;
    color:       #374151;
}

.cms-content .cms-safe-html .cms-value li {
    margin-bottom: .3rem;
}

/* Inline anchors in body copy (CmsBlocksToHtml canonical <a href> emission) —
   theme primary with a fallback matching the platform indigo used elsewhere here. */
.cms-content .cms-safe-html .cms-value a {
    color:                 var(--cms-tk-color-primary, #4f46e5);
    text-decoration:       underline;
    text-underline-offset: 2px;
}

.cms-content .cms-safe-html .cms-value a:hover {
    text-decoration-thickness: 2px;
}

.cms-content .cms-safe-html .cms-value blockquote {
    border-left:   3px solid #4f46e5;
    padding:       .625rem 1rem;
    margin:        1rem 0;
    background:    #f5f3ff;
    color:         #3730a3;
    font-style:    italic;
    border-radius: 0 6px 6px 0;
}

.cms-content .cms-safe-html .cms-value code {
    font-family: "SFMono-Regular", Menlo, Monaco, Consolas, "Courier New", monospace;
    font-size:   .875em;
    background:  #f3f4f6;
    padding:     .1em .3em;
    border-radius: 3px;
}

.cms-content .cms-safe-html .cms-value pre {
    background:  #1e1e2e;
    color:       #cdd6f4;
    padding:     1rem;
    border-radius: 6px;
    overflow-x:  auto;
    margin:      0 0 1rem;
}

.cms-content .cms-safe-html .cms-value pre code {
    background: none;
    padding:    0;
    font-size:  .82rem;
}

/* ── .cms-mark — highlighted text (Editor.js Marker tool) ── */
.cms-mark {
    background: #fffb8f;
    padding:    0 1px;
    border-radius: 2px;
}

/* ── .cms-quote-cite — quote caption / citation ── */
.cms-quote-cite {
    display:    block;
    margin-top: .375rem;
    font-size:  .7rem;
    font-style: normal;
    opacity:    .75;
    color:      #374151;
}

/* ── .cms-delimiter — horizontal divider block ── */
.cms-content .cms-safe-html .cms-value hr.cms-delimiter {
    border:        none;
    border-top:    2px solid #e5e7eb;
    margin:        1.5rem auto;
    width:         40%;
}

/* ── Editor.js mount area ── */
#cms-editorjs {
    min-height:  420px;
    padding:     .75rem 1rem;
    background:  #fff;
    border:      1px solid #e5e7eb;
    border-top:  none;
    border-radius: 0 0 .5rem .5rem;
    font-size:   14px;
    line-height: 1.7;
    color:       #374151;
    box-sizing:  border-box;
}

/* Override Editor.js defaults to fill container */
#cms-editorjs .codex-editor { padding: 0 !important; }
#cms-editorjs .codex-editor__redactor { padding-bottom: 40px !important; }
#cms-editorjs .ce-block__content { max-width: 100% !important; }
#cms-editorjs .ce-toolbar__content { max-width: 100% !important; }
#cms-editorjs .cdx-quote__text { font-style: italic; }

/* ── Legacy safeHtml-only read-only view ── */
.cms-legacy-view {
    border:        1px solid #fde68a;
    border-top:    none;
    border-radius: 0 0 .5rem .5rem;
    background:    #fffbeb;
    padding:       1rem;
    min-height:    200px;
}

.cms-legacy-notice {
    font-size:     .78rem;
    color:         #92400e;
    margin-bottom: .75rem;
    display:       flex;
    align-items:   center;
    gap:           .4rem;
}

.cms-convert-btn {
    padding:       .35rem .75rem;
    font-size:     .78rem;
    font-weight:   600;
    border:        1px solid #92400e;
    border-radius: .375rem;
    background:    #fff;
    color:         #92400e;
    cursor:        pointer;
    font-family:   inherit;
}

.cms-convert-btn:hover {
    background: #fffbeb;
}

/* ── JSON mode textarea ── */
.cms-json-textarea {
    display:     block;
    width:       100%;
    min-height:  420px;
    margin:      0;
    padding:     .85rem 1rem;
    font-family: "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size:   .82rem;
    line-height: 1.55;
    color:       #1f2937;
    background:  #f9fafb;
    border:      none;
    border-top:  1px solid #e5e7eb;
    resize:      vertical;
    box-sizing:  border-box;
    outline:     none;
}

/* ── Disabled-soon affordance ── */
.cms-toolbar-btn[disabled],
.cms-toolbar-btn.cms-soon {
    opacity:  .45;
    cursor:   not-allowed;
    position: relative;
}

/* ── Preview body live area ── */
.cms-preview-body-live {
    font-size:   14px;
    line-height: 1.75;
    color:       #374151;
}

.cms-preview-error {
    padding:       .5rem 1rem;
    background:    #fef2f2;
    border:        1px solid #fecaca;
    border-radius: 4px;
    color:         #b91c1c;
    font-size:     .8rem;
    margin:        .5rem 0;
}

/* ════════════════════════════════════════════════════════════════════════════
   SHELL RECLAIM — the Bridge shell (site.css) themes EVERY non-.btn content-area
   button via `.app-main-content button:not(.btn)` (specificity 0,2,1), painting
   our flat .cms-* controls with the tenant brand fill (navy on Snurpy). These
   selectors match that specificity (0,2,1) and, since aegis-cms.css loads AFTER
   site.css (@section Styles), win the cascade — restoring each CMS control's own
   palette. No !important needed. Verified against the LIVE shell CSS in a faithful
   harness (the prior harness omitted the shell stylesheets → false PASS).
   ════════════════════════════════════════════════════════════════════════════ */
.app-main-content button.cms-tab-link {
    display: inline-flex; padding: .55rem 1rem; font-size: .85rem; font-weight: 500;
    color: var(--cms-muted); background: transparent;
    border: 0; border-bottom: 2px solid transparent; border-radius: 0;
}
.app-main-content button.cms-tab-link:hover { color: var(--cms-text); }
.app-main-content button.cms-tab-link.active {
    color: var(--cms-accent); font-weight: 600; border-bottom-color: var(--cms-accent);
}
.app-main-content button.cms-toolbar-btn {
    display: inline-flex; width: 28px; height: 28px; padding: 0;
    font-size: 13px; font-weight: 400; color: var(--cms-sub);
    background: #fff; border: none; border-radius: 0;
}
.app-main-content button.cms-toolbar-btn:hover { background: #f3f4f6; }
.app-main-content button.cms-toolbar-btn.cms-soon { opacity: .45; cursor: not-allowed; }
.app-main-content button.cms-mode-btn {
    display: inline-flex; padding: 4px 12px; font-size: 11px; font-weight: 700;
    color: #6b7280; background: #f3f4f6; border: none; border-radius: 0;
}
.app-main-content button.cms-mode-btn.active { color: #fff; background: #4f46e5; }
.app-main-content button.cms-pdt-btn {
    display: inline-flex; padding: 5px 12px; font-size: 11px; font-weight: 700;
    color: #6b7280; background: #fff; border: none;
    border-right: 1px solid var(--cms-border); border-radius: 0;
}
.app-main-content button.cms-pdt-btn:last-child { border-right: none; }
.app-main-content button.cms-pdt-btn.active { color: #fff; background: #172b4d; }
.app-main-content button.cms-preview-ext-btn {
    padding: 4px 9px; font-size: 13px; color: var(--cms-muted);
    background: transparent; border: 1px solid var(--cms-border); border-radius: 6px;
}
.app-main-content button.cms-action-btn {
    padding: 8px 18px; font-size: 13px; font-weight: 600;
    border: 1px solid var(--cms-border); border-radius: 6px; background: #fff; color: var(--cms-sub);
}
.app-main-content button.cms-action-btn-secondary { color: #374151; background: #fff; }
.app-main-content button.cms-action-btn-publish {
    color: #fff; background: #16a34a; border-color: #16a34a; padding: 8px 22px;
}
.app-main-content button.cms-action-btn-unpublish { color: #dc2626; background: #fff; border-color: var(--cms-border); }
.app-main-content button.cms-action-btn:disabled,
.app-main-content button.cms-action-btn.disabled { opacity: .5; cursor: not-allowed; }
/* Legacy "Convert to block editor" affordance (button in the legacy read-only view) */
.app-main-content button.cms-convert-btn {
    color: var(--cms-accent); background: var(--cms-accent-soft, #eef2ff);
    border: 1px solid var(--cms-accent-border, #c7d2fe); border-radius: 6px;
    padding: 6px 14px; font-size: .8rem; font-weight: 600;
}

/* ── SHELL RECLAIM, part 2: form controls, text, footer clearance ────────────
   The shell also themes `.app-main-content input/select/textarea` (0,1,1, stomps
   Bootstrap .form-control) and `.app-main-content h1` (forces 1.5rem). Reclaim the
   CMS form controls + the preview title to canon values; reserve bottom space so
   the fixed save bar never clips the Support panel. */

/* Page-data tab fields (Title / Meta title / Meta description) — clean full-width inputs.
   The shell input rule carries four :not([type=…]) → specificity (0,5,1); !important is the
   reliable escape (it's the one place the shell out-specifies a sane scoped selector). */
.app-main-content .cms-tab-panel input.form-control,
.app-main-content .cms-tab-panel textarea.form-control {
    display: block !important; width: 100%; max-width: 100%;
    padding: .5rem .65rem !important; font-size: .82rem !important; line-height: 1.45;
    color: #111827; background: #fff;
    border: 1px solid var(--cms-border) !important; border-radius: .375rem !important;
}
.app-main-content .cms-tab-panel input.form-control:disabled,
.app-main-content .cms-tab-panel input.form-control[readonly] {
    background: var(--cms-surface-alt); color: var(--cms-muted);
}
.app-main-content .cms-tab-panel textarea.form-control { min-height: 4.5rem; resize: vertical; }
.app-main-content .cms-tab-panel .form-label { margin-bottom: .25rem; font-size: .8rem; }
.app-main-content .cms-tab-panel .mb-3 { margin-bottom: .85rem !important; }

/* Toolbar block-type select — compact, NOT a full-width shell input */
.app-main-content select.cms-toolbar-select {
    display: inline-block; width: auto; height: 28px; padding: 0 .45rem;
    font-size: .78rem; line-height: 1; color: var(--cms-text);
    background: var(--cms-surface); border: 1px solid var(--cms-border); border-radius: 4px;
}
/* JSON-mode raw textarea */
.app-main-content textarea.cms-editor-textarea {
    display: block; width: 100%; min-height: 420px; margin: 0; padding: .85rem 1rem;
    font-family: "SFMono-Regular","Menlo","Monaco",Consolas,"Liberation Mono","Courier New",monospace;
    font-size: .82rem; line-height: 1.55; color: var(--cms-text);
    background: var(--cms-surface); border: 1px solid var(--cms-border); border-radius: 0 0 .5rem .5rem;
}

/* Preview article title — shell forces h1 to 1.5rem; restore the canon size */
.app-main-content h1.cms-preview-title {
    margin: 0 0 8px; font-size: 26px; font-weight: 700; line-height: 1.25; color: #111;
}

/* Footer clearance — the sticky save bar is position:fixed; this spacer (always
   present on the item page) keeps the Support panel scrollable above it. */
.cms-page-foot-spacer { height: 4.5rem; }

/* ── T5a: design-token vocabulary — platform-default presets ─────────────────
   Token values (color, type, spacing) are platform-curated defaults.
   Tenants override in T5b (per-tenant :root overrides via the Design panel, OQ4).
   Utility classes are the SOLE output of the token converter (CmsBlocksToHtml.StyleTokenClasses).
   They must survive HtmlAllowlistSanitizer unchanged (parity invariant).
   ──────────────────────────────────────────────────────────────────────────── */
:root {
  /* Color tokens (text) — platform defaults; tenants override in T5b */
  --cms-tk-color-primary: #4f46e5;
  --cms-tk-color-accent:  #8a6d1f; /* AA on white (4.9:1); keep in sync with CmsThemeTokens.Specs */
  --cms-tk-color-neutral: #1f2937;
  --cms-tk-color-muted:   #6b7280;
  /* Type scale */
  --cms-tk-type-display-size: 2.25rem; --cms-tk-type-display-weight: 700;
  --cms-tk-type-heading-size: 1.5rem;  --cms-tk-type-heading-weight: 600;
  --cms-tk-type-body-size:    1rem;    --cms-tk-type-body-weight:    400;
  --cms-tk-type-label-size:   .8125rem; --cms-tk-type-label-weight:  600;
  /* Spacing scale (padding) */
  --cms-tk-space-sm: 8px; --cms-tk-space-md: 16px; --cms-tk-space-lg: 24px; --cms-tk-space-xl: 48px;

  /* ── T5b (SITE-3) additions ────────────────────────────────────────────────
     Delivery-level tokens the tenant Design panel edits. DECLARED HERE, NOT
     CONSUMED HERE — on purpose.

     Nothing in this stylesheet reads them, so adding these five lines cannot
     change one pixel for the SITE-1/SITE-2 tenants already live in production
     (a custom property only affects rendering when something references it).
     The rules that DO reference them are emitted by ICmsThemeCssEmitter, and
     only for a tenant that has actually saved a theme — that is what makes
     "defaults are absence" (spec §9 invariant 5) hold byte-for-byte.

     They are declared here anyway so the platform default for every token lives
     in exactly one place next to the T5a values it extends, and so the IDE
     canvas has a base to override optimistically while the panel is dirty.
     Keep in lockstep with CmsThemeTokens.Specs — CmsThemeTokenDefaultsTests
     fails if the two drift.
     ────────────────────────────────────────────────────────────────────────── */
  --cms-tk-page-bg: #ffffff;
  --cms-tk-page-fg: #1f2937;
  --cms-tk-font-display: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --cms-tk-font-body:    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --cms-tk-radius: 6px;
}
/* Color / Type / Spacing utility classes. !important because these are override
   utilities — the author explicitly picked a token, so it must win over the article
   typography (e.g. .cms-content .cms-safe-html .cms-value sets color at higher
   specificity). CSS-only; does not affect the converter HTML or the parity invariant. */
.cms-tk-color-primary { color: var(--cms-tk-color-primary) !important; }
.cms-tk-color-accent  { color: var(--cms-tk-color-accent)  !important; }
.cms-tk-color-neutral { color: var(--cms-tk-color-neutral) !important; }
.cms-tk-color-muted   { color: var(--cms-tk-color-muted)   !important; }
/* Type utility classes */
.cms-tk-type-display { font-size: var(--cms-tk-type-display-size) !important; font-weight: var(--cms-tk-type-display-weight) !important; line-height: 1.1 !important; }
.cms-tk-type-heading { font-size: var(--cms-tk-type-heading-size) !important; font-weight: var(--cms-tk-type-heading-weight) !important; line-height: 1.25 !important; }
.cms-tk-type-body    { font-size: var(--cms-tk-type-body-size)    !important; font-weight: var(--cms-tk-type-body-weight)    !important; line-height: 1.6 !important; }
.cms-tk-type-label   { font-size: var(--cms-tk-type-label-size)   !important; font-weight: var(--cms-tk-type-label-weight)   !important; line-height: 1.4 !important; letter-spacing: .04em !important; text-transform: uppercase !important; }
/* Spacing (padding) utility classes */
.cms-tk-pad-sm { padding: var(--cms-tk-space-sm) !important; }
.cms-tk-pad-md { padding: var(--cms-tk-space-md) !important; }
.cms-tk-pad-lg { padding: var(--cms-tk-space-lg) !important; }
.cms-tk-pad-xl { padding: var(--cms-tk-space-xl) !important; }

/* ── BE2b: figure.cms-image delivery styles ── */
figure.cms-image {
    margin: 0;
}
figure.cms-image img {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 6px;
}
figure.cms-image figcaption {
    font-size: .8rem;
    color: #6b7280;
    text-align: center;
    margin-top: .35rem;
}


/* ── T6a: Bound grid delivery styles (generic names; no vertical references) ── */
.cms-bound-placeholder {
    display: none; /* placeholder is invisible in delivery; live rows render at serve time */
}
.cms-bound-empty {
    padding: 1rem;
    color: #6b7280;
    font-style: italic;
}
.cms-bound-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}
.cms-bound-item {
    display: flex;
    flex-direction: column;
    gap: .4rem;
}
.cms-bound-item img {
    width: 100%;
    height: auto;
    object-fit: cover;
    border-radius: 4px;
}
.cms-bound-field {
    font-size: .9rem;
    line-height: 1.4;
}
.cms-bound-title {
    font-weight: 600;
}
.cms-bound-subtitle {
    color: #4b5563;
    font-size: .85rem;
}
.cms-bound-price {
    font-weight: 700;
    color: #111827;
}
.cms-bound-meta {
    color: #6b7280;
    font-size: .8rem;
}
