/* Judgment review (CaseReviewPanel, CaseMetaSection, CaseChunkList). Global stylesheet, "cr-" prefixed.
   Uses the Portal's dark-theme design tokens (--ls-*, defined in app.css) throughout — this file originally
   shipped with light-theme Tailwind-gray hardcoded hex colors (#fff cards, #1f2937 text, etc.), which rendered
   as washed-out text on jarring white cards against the Portal's actual black/gold dark theme. Every color
   below is now a token; if a new rule is added here, it must use one too, not a literal hex/rgb value. */

.cr-root { --cr-chrome: 230px; --cr-min-width: 900px; display: flex; flex-direction: column; gap: 12px; color: var(--ls-text); min-width: var(--cr-min-width); }
/* The Portal shell clips horizontal overflow (.page-body { overflow-x: hidden }), so a review wider than the window used to
   lose its right-hand buttons. While a review is on screen the shell scrolls sideways instead, and .cr-root keeps a minimum
   width so nothing is squeezed into clipping. */
main.page-body:has(.cr-root) { overflow-x: auto; }
.cr-state { padding: 40px 16px; text-align: center; color: var(--ls-text-muted); }
.cr-state.cr-error { color: var(--ls-error); }

.cr-bar { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.cr-eyebrow { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--ls-text-dim); }
.cr-title h2 { margin: 2px 0 2px; font-size: 20px; font-weight: 600; color: var(--ls-text); }
.cr-sub { margin: 0; color: var(--ls-text-dim); font-size: 13px; }
.cr-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cr-confirm-inline { display: inline-flex; gap: 8px; align-items: center; font-size: 13px; color: var(--ls-warning); }

.cr-banner { padding: 10px 14px; border-radius: 8px; background: var(--ls-info-50); color: var(--ls-info); font-size: 14px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; border: 1px solid var(--ls-info-100); }
.cr-banner.warn { background: var(--ls-warning-50); color: var(--ls-warning); border-color: var(--ls-warning-100); }

.cr-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.cr-body.with-pdf { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
.cr-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.cr-pdf { position: sticky; top: 8px; height: max(360px, calc(100vh - var(--cr-chrome))); }

.cr-card { min-width: 0; overflow-x: auto; background: var(--ls-surface); border: 1px solid var(--ls-border); border-radius: 10px; padding: 14px 16px; }
.cr-card h3 { margin: 0 0 10px; font-size: 15px; font-weight: 600; color: var(--ls-text); }
.cr-card h4 { margin: 16px 0 6px; font-size: 13px; font-weight: 600; color: var(--ls-text-muted); }
.cr-muted { color: var(--ls-text-dim); }
.cr-hint { margin: 6px 0 0; font-size: 13px; color: var(--ls-warning); }

.cr-all-clear { margin: 0; padding: 10px 14px; border-radius: 8px; background: var(--ls-success-50); border: 1px solid var(--ls-success); color: var(--ls-success); font-size: 14px; font-weight: 500; }

.cr-field-error { margin: 6px 0 0; font-size: 13px; color: var(--ls-warning); line-height: 1.5; }
.cr-input.has-error { border-color: var(--ls-warning); }

.cr-todo { border-color: var(--ls-warning); background: var(--ls-warning-50); }
.cr-todo h3 { color: var(--ls-warning); }
.cr-todo-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.cr-todo-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 14px; color: var(--ls-text); }
.cr-todo-list .cr-link { white-space: nowrap; font-weight: 600; }
.cr-todo .cr-todo-kind { margin: 12px 0 6px; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--ls-text-dim); }
.cr-todo .cr-todo-kind:first-of-type { margin-top: 0; }
.cr-todo-done { border-color: var(--ls-success); background: var(--ls-success-50); }
.cr-todo-done h3 { color: var(--ls-success); margin-bottom: 4px; }

.cr-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px 18px; margin: 0; }
.cr-facts > div { min-width: 0; }
.cr-facts > div.wide { grid-column: 1 / -1; }
.cr-facts dt { font-size: 12px; color: var(--ls-text-dim); font-weight: 500; margin-bottom: 2px; }
.cr-facts dd { margin: 0; font-size: 14px; color: var(--ls-text); }

.cr-facts-label { display: block; margin: 10px 0 4px; font-size: 12px; color: var(--ls-text-dim); font-weight: 500; }
.cr-facts-label:first-of-type { margin-top: 0; }

.cr-input { width: 100%; padding: 5px 8px; border: 1px solid var(--ls-border-strong); border-radius: 6px; font-size: 14px; background: var(--ls-surface-raised); color: var(--ls-text); }
.cr-input::placeholder { color: var(--ls-text-dim); }
.cr-input:focus { outline: none; border-color: var(--ls-gold); box-shadow: 0 0 0 3px var(--ls-gold-50); }
.cr-textarea { resize: vertical; font-family: inherit; line-height: 1.45; }
.cr-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.cr-table th { text-align: left; font-weight: 500; color: var(--ls-text-dim); font-size: 12px; padding: 4px 8px 4px 0; }
.cr-table td { padding: 5px 8px 5px 0; vertical-align: middle; color: var(--ls-text); }
.cr-table td .cr-input { width: auto; min-width: 150px; }
.cr-suggest { margin-left: 8px; border: 1px dashed var(--ls-hue-purple); background: var(--ls-hue-purple-bg); color: var(--ls-hue-purple-text); border-radius: 6px; padding: 3px 8px; font-size: 12px; cursor: pointer; }
.cr-suggest:hover { background: var(--ls-hue-purple-bg-soft); }
.cr-details { margin-top: 12px; font-size: 13px; color: var(--ls-text-muted); }
.cr-details summary { cursor: pointer; }

.cr-flags { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.cr-flag { display: flex; gap: 8px; align-items: baseline; font-size: 14px; color: var(--ls-text); }
.cr-flag-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ls-text-dim); flex: none; transform: translateY(-1px); }
.cr-flag.sev-error .cr-flag-dot { background: var(--ls-error); }
.cr-flag.sev-warn .cr-flag-dot { background: var(--ls-warning); }

.cr-listbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.cr-listbar h3 { margin: 0; }
.cr-filter { display: flex; gap: 6px; }
.cr-pill { border: 1px solid var(--ls-border-strong); background: var(--ls-surface-raised); color: var(--ls-text-muted); border-radius: 999px; padding: 3px 12px; font-size: 13px; cursor: pointer; }
.cr-pill.active { background: var(--ls-gold); color: var(--ls-ink-on-gold); border-color: var(--ls-gold); }

.cr-chunk { border: 1px solid var(--ls-border); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; background: var(--ls-surface); }
.cr-chunk.is-quote { margin-left: 18px; background: var(--ls-surface-raised); border-left: 3px solid var(--ls-border-strong); }
.cr-chunk.is-heading { background: var(--ls-surface-hover); }
.cr-chunk.is-deleted { opacity: .55; }
.cr-chunk.is-deleted .cr-text { text-decoration: line-through; }
.cr-chunk.needs-confirm { border-color: var(--ls-warning); background: var(--ls-warning-50); }
.cr-chunk-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.cr-para { font-weight: 600; font-size: 13px; color: var(--ls-text); }
.cr-pages { color: var(--ls-text-dim); font-size: 12px; }
.cr-pages-edit { display: inline-flex; align-items: center; gap: 4px; }
.cr-page-input { width: 54px; min-width: 0; padding: 2px 4px; text-align: center; }
.cr-role { width: auto; min-width: 150px; }
.cr-chip { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--ls-surface-hover); color: var(--ls-text-muted); font-size: 12px; }
.cr-chip.warn { background: var(--ls-warning-50); color: var(--ls-warning); }
.cr-chip.ok { background: var(--ls-success-50); color: var(--ls-success); }
.cr-text { margin: 0; font-size: 14px; line-height: 1.5; white-space: pre-wrap; color: var(--ls-text); }
.cr-text.clamped { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.cr-link { background: none; border: none; padding: 0; color: var(--ls-gold); font-size: 13px; cursor: pointer; }
.cr-link:hover { color: var(--ls-gold-soft); }
.cr-link.danger { color: var(--ls-error); }
.cr-link.danger:hover { color: var(--ls-error-hover); }
.cr-chunk-actions { display: flex; gap: 12px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.cr-spacer { flex: 1; }
.cr-confirm { font-size: 13px; display: inline-flex; gap: 6px; align-items: center; color: var(--ls-success); }
.cr-confirm.pending { color: var(--ls-warning); font-weight: 500; }

.cr-footer { position: sticky; bottom: 0; background: var(--ls-bg-raised); border: 1px solid var(--ls-border); border-radius: 10px; padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; box-shadow: 0 -4px 12px rgba(0, 0, 0, .35); z-index: 5; }
.cr-pending { display: flex; flex-direction: column; gap: 4px; font-size: 14px; min-width: 0; flex: 1; }
.cr-pending p { margin: 0; color: var(--ls-text); }
.cr-pending p.pending { color: var(--ls-warning); }
.cr-ack { font-size: 14px; display: inline-flex; gap: 6px; align-items: center; color: var(--ls-warning); }
.cr-footer-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; margin-left: auto; }
.cr-footer-actions > button { white-space: nowrap; }

.cr-rows { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.cr-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cr-grow { flex: 1; min-width: 160px; }
.cr-narrow { width: auto; min-width: 130px; }
.cr-short { width: 84px; min-width: 0; }
.cr-inline { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--ls-text-muted); }
.cr-hint-muted { margin: 8px 0 0; font-size: 13px; color: var(--ls-text-dim); }
.cr-facts dd .cr-chip { margin-left: 6px; }
.cr-table td .cr-input.cr-short { min-width: 0; }

@media (max-width: 1100px) { .cr-body.with-pdf { grid-template-columns: minmax(0, 1fr); } .cr-pdf { position: static; height: 70vh; } }
@media (max-width: 1100px) { .cr-footer { padding: 8px 12px; } .cr-pending { flex-basis: 100%; } }

/* Opinions and the external summary */
.cr-opinion-head { margin: 18px 0 6px; padding: 6px 10px; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
    color: var(--ls-text-muted); border-left: 3px solid var(--ls-gold); background: var(--ls-surface); }
.cr-table tr.cr-merged td { opacity: 0.55; }
.cr-summary { margin: 8px 0 0; padding: 10px 12px; max-height: 320px; overflow: auto; white-space: pre-wrap; font: inherit; font-size: 13px;
    color: var(--ls-text-muted); background: var(--ls-surface); border: 1px solid var(--ls-border); border-radius: 8px; }
