html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

a, .btn-link {
    color: #006bb7;
}

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.content {
    padding-top: 1.1rem;
}

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* ── Viewport lock ────────────────────────────────────────────────
   The entire app fits exactly in the viewport. Nothing scrolls at
   the html/body/layout level. Only interior regions scroll:
   - .jaws-canvas for the document renderer
   - .app-content-inner for standard list pages
   - .jaws-inspector for the inspector panel
   Everything else — header, sidebar, top strip — is stationary. */

html, body {
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
}

.app-layout {
    height: 100vh !important;
    max-height: 100vh !important;
    min-height: 100vh !important;
    overflow: hidden !important;
}

/* PP-27 / EM-02 — chromeless embed layout (sibling lock to .app-layout,
   minus header / sidebar / content shell). Hands the entire viewport to
   the embedded page's flex chain so the document surface fills the
   WebView. Sits alongside .app-layout so the height/flex contract is
   immediately comparable. */
.embed-layout {
    height: 100vh;
    max-height: 100vh;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

/* PP-27 / EM-02 — embed page loading + error states. Both consume the
   full embed layout so the spinner / alert is centered in the WebView
   while the snapshot resolves. Distinct from .app-content-inner (which
   expects a sidebar / header context that the embed layout does not
   have). */
.embed-loading,
.embed-error {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.embed-error .alert {
    max-width: 520px;
}

.app-body {
    min-height: 0 !important; /* Allow flex children to shrink */
}

/* Main content area: flex column, never scrolls itself. */
.app-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden !important;
    min-height: 0;
}

/* Standard content pages (Documents, Health, etc.) scroll their inner region */
.app-content-inner {
    flex: 1;
    overflow-y: auto;
}

/* ── Contextual toolbar (TM-01 / PP-26) ───────────────────────────
   Floating, selection-anchored action toolbar (kind-dispatched capture
   shell). The container is the visual frame — solid background, border,
   rounded shape, shadow — so the toolbar reads as ONE elevated object
   sitting above the document instead of two outlined buttons on it.
   Buttons inside stay .btn-ghost .btn-sm: their own border is removed
   so the container's frame doesn't double up. Shares the --bg-primary /
   --border-primary palette with the annotate and editor panels so the
   three editor surfaces feel like one family. Positioning (top/left)
   is set inline by PositionStyle — a fixed, viewport-anchored pill that
   re-anchors when the selection changes; re-anchoring on scroll/zoom is
   a later refinement per the task spec.

   PP-26 — the container is a vertical stack: a compact primary row
   (Edit + Annotate + expand chevron) on top, and an overflow container
   below that is hidden until the chevron is toggled. The max-width caps
   the pill so the collapsed row reads as a compact ~190px pill (matching
   PositionStyle's 200px clamp) and the expanded overflow wraps rather
   than growing the pill unbounded. */
.jaws-context-toolbar {
    display: inline-flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 4px;
    max-width: 320px;
    background: var(--bg-primary, #1e1e1e);
    border: 1px solid var(--border-primary, #333);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* PP-26 — primary row: the always-visible 95% actions (Edit + Annotate
   + chevron). Inline-flex so the buttons sit on one line. */
.jaws-context-toolbar-primary {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* PP-26 — overflow: everything behind the chevron (Style, Appearance,
   cell/table/object clusters). Flex column so the kind-appropriate
   clusters stack vertically. A top border separates it from the
   primary row when expanded. */
.jaws-context-toolbar-overflow {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-top: 4px;
    margin-top: 4px;
    border-top: 1px solid var(--border-primary, #333);
}

/* ── Paragraph appearance cluster (TF-04) ─────────────────────────
   Five-attribute control cluster (align / indent / spacing / list /
   shading) that lives inside the contextual toolbar. Mirrors the
   ScalarControls row layout (label + control per row, rows stacked)
   so the two stacks feel like one family. The cluster is its own
   flex column inside the toolbar's inline-flex; each row is a flex
   row with a fixed-width label column so the five control columns
   line up. The cluster caps its own height and scrolls if a shading
   swatch list would otherwise grow it past the floating-toolbar
   budget. */
.jaws-appearance-cluster {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 240px;
    overflow-y: auto;
    padding-right: 2px;
}

.jaws-appearance-row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 28px;
    flex-wrap: wrap;
}

.jaws-appearance-label {
    width: 60px;
    flex-shrink: 0;
    font-size: 11px;
    color: var(--text-muted, #888);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ── Segmented buttons (alignment / list) ── */
.jaws-appearance-seg {
    width: 26px;
    height: 26px;
    padding: 0;
    font-size: 13px;
    background: transparent;
    border: 1px solid var(--border-primary, #444);
    border-radius: 3px;
    color: var(--text-primary, #eee);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.jaws-appearance-seg:hover:not(:disabled) {
    border-color: var(--accent-primary, #4a9eff);
}
.jaws-appearance-seg:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ── Number inputs (indent / spacing) ──
   PP-26 — widened from 60px to 72px so the "Before" placeholder in the
   spacing row is no longer truncated to "Befon". */
.jaws-appearance-input {
    width: 72px;
    height: 26px;
    font-size: 12px;
    padding: 0 6px;
    background: var(--bg-primary, #1e1e1e);
    border: 1px solid var(--border-primary, #444);
    border-radius: 3px;
    color: var(--text-primary, #eee);
}
.jaws-appearance-input:focus {
    outline: none;
    border-color: var(--accent-primary, #4a9eff);
    box-shadow: 0 0 0 1px var(--accent-primary, #4a9eff);
}
.jaws-appearance-input:disabled {
    opacity: 0.45;
}

/* ── Shading swatch picker (asset-only) ── */
.jaws-appearance-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    flex: 1;
    min-width: 0;
    max-height: 80px;
    overflow-y: auto;
}

.jaws-appearance-swatch {
    width: 22px;
    height: 22px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border-primary, #444);
    border-radius: 3px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.jaws-appearance-swatch:hover:not(:disabled) {
    border-color: var(--accent-primary, #4a9eff);
}
.jaws-appearance-swatch:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.jaws-appearance-swatch-preview {
    width: 14px;
    height: 14px;
    border-radius: 2px;
    /* background-color is set inline from SwatchPreviewStyle */
}

.jaws-appearance-empty {
    font-size: 12px;
    color: var(--text-muted, #888);
    font-style: italic;
}

/* ── Annotate overlay (TM-04) ─────────────────────────────────────
   Centered modal panel for the review-note input. The backdrop dims the
   canvas; the panel sits above with a small header (selection summary),
   the textarea, an optional error line, and a footer with Cancel/Save.
   Fixed positioning + flex centering keeps it viewport-anchored on
   scroll/zoom (a later refinement the toolbar already notes). */
.jaws-annotate-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 200;
}

.jaws-annotate-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(520px, calc(100vw - 32px));
    max-height: calc(100vh - 64px);
    display: flex;
    flex-direction: column;
    background: var(--bg-primary, #1e1e1e);
    border: 1px solid var(--border-primary, #333);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    z-index: 201;
    padding: 12px 14px;
}

.jaws-annotate-header {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--text-primary, #eee);
    margin-bottom: 8px;
}

.jaws-annotate-textarea {
    width: 100%;
    min-height: 120px;
    resize: vertical;
    font-size: 13px;
    line-height: 1.4;
    background: var(--bg-secondary, #2a2a2a);
    color: var(--text-primary, #eee);
    border: 1px solid var(--border-primary, #333);
    border-radius: 4px;
    padding: 8px 10px;
    font-family: inherit;
}

.jaws-annotate-textarea:focus {
    outline: none;
    border-color: var(--accent-primary, #4a9eff);
    box-shadow: 0 0 0 1px var(--accent-primary, #4a9eff);
}

.jaws-annotate-error {
    margin-top: 8px;
    padding: 6px 8px;
    background: rgba(229, 0, 0, 0.08);
    border: 1px solid rgba(229, 0, 0, 0.4);
    border-radius: 4px;
    color: #ff6b6b;
    font-size: 12px;
}

.jaws-annotate-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 10px;
}

/* ── Construct editor overlay (TE-05) ───────────────────────────────
   Off-canvas single-construct editor. Wider than the annotate panel
   because it hosts a real contentEditable surface (paragraph or cell)
   that the reviewer can type into. Mirrors the annotate overlay's
   backdrop/panel/header/footer shape so the two feel consistent. */
.jaws-editor-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 200;
}

.jaws-editor-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(720px, calc(100vw - 32px));
    max-height: calc(100vh - 64px);
    display: flex;
    flex-direction: column;
    background: var(--bg-primary, #1e1e1e);
    border: 1px solid var(--border-primary, #333);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    z-index: 201;
    padding: 12px 14px;
}

.jaws-editor-header {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--text-primary, #eee);
    margin-bottom: 8px;
}

.jaws-editor-surface {
    min-height: 160px;
    max-height: calc(100vh - 240px);
    overflow-y: auto;
    font-size: 14px;
    line-height: 1.5;
    background: var(--bg-secondary, #2a2a2a);
    color: var(--text-primary, #eee);
    border: 1px solid var(--border-primary, #333);
    border-radius: 4px;
    padding: 10px 12px;
    outline: none;
    /* The TE-01 marker-span vocabulary uses .jaws-fmt — give it a
       subtle visual hint so the reviewer can see where formatting
       boundaries land even without cosmetic styling. */
}
.jaws-editor-surface:focus {
    border-color: var(--accent-primary, #4a9eff);
    box-shadow: 0 0 0 1px var(--accent-primary, #4a9eff);
}

.jaws-editor-error {
    margin-top: 8px;
    padding: 6px 8px;
    background: rgba(229, 0, 0, 0.08);
    border: 1px solid rgba(229, 0, 0, 0.4);
    border-radius: 4px;
    color: #ff6b6b;
    font-size: 12px;
}

.jaws-editor-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 10px;
}

/* ── Asset pickers (TE-06) ────────────────────────────────────────
   Three JawsId pickers between the contentEditable and the editor's
   Accept / Cancel footer: colours (swatch row), font family (select),
   character style (select). Asset-only by construction — every visible
   option is a snapshot-backed asset, never a free-text entry. */
.jaws-asset-pickers {
    margin-top: 10px;
    padding: 8px 10px;
    background: var(--bg-secondary, #2a2a2a);
    border: 1px solid var(--border-primary, #333);
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.jaws-asset-pickers-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 28px;
}

.jaws-asset-pickers-label {
    width: 60px;
    flex-shrink: 0;
    font-size: 12px;
    color: var(--text-muted, #888);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.jaws-asset-pickers-empty {
    font-size: 12px;
    color: var(--text-muted, #888);
    font-style: italic;
}

/* ── Swatches row ── */
.jaws-asset-pickers-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 100px;
    overflow-y: auto;
    flex: 1;
    min-width: 0;
}

.jaws-asset-pickers-swatch {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 6px;
    font-size: 12px;
    background: var(--bg-primary, #1e1e1e);
    border: 1px solid var(--border-primary, #444);
    border-radius: 3px;
    color: var(--text-primary, #eee);
    cursor: pointer;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.jaws-asset-pickers-swatch:hover:not(:disabled) {
    border-color: var(--accent-primary, #4a9eff);
}
.jaws-asset-pickers-swatch:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* TE-11 — active state for the swatch that matches the live Selection's
   uniform data-color. Mirrors the ScalarControls pressed tokens (accent
   fill + accent border) so the two pressed visuals feel like one family. */
.jaws-asset-pickers-swatch.is-active {
    border-color: var(--accent-primary, #4a9eff);
    box-shadow: inset 0 0 0 1px var(--accent-primary, #4a9eff);
    color: var(--accent-primary, #4a9eff);
}

.jaws-asset-pickers-swatch-preview {
    flex-shrink: 0;
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 1px solid rgba(0, 0, 0, 0.45);
    border-radius: 2px;
    /* background-color is set inline from SwatchPreviewStyle */
}

.jaws-asset-pickers-swatch-name {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Select dropdowns (font family, character style) ── */
.jaws-asset-pickers-select {
    flex: 1;
    min-width: 0;
    height: 28px;
    font-size: 12px;
    padding: 2px 6px;
    background: var(--bg-primary, #1e1e1e);
    color: var(--text-primary, #eee);
    border: 1px solid var(--border-primary, #444);
    border-radius: 3px;
}
.jaws-asset-pickers-select:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ── Scalar / toggle controls (TE-07) ─────────────────────────────
   The only direct-value controls in the editor — size, position, and
   the four character toggles. Mirrors the asset-pickers row layout
   (label + control) so the two stacks feel like one block. */

.jaws-scalar-controls {
    margin-top: 8px;
    padding: 8px 10px;
    background: var(--bg-secondary, #2a2a2a);
    border: 1px solid var(--border-primary, #333);
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.jaws-scalar-controls-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 28px;
    flex-wrap: wrap;
}

.jaws-scalar-controls-label {
    width: 60px;
    flex-shrink: 0;
    font-size: 12px;
    color: var(--text-muted, #888);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ── Size (number input + pt suffix + preset chips) ── */
.jaws-scalar-controls-size-input {
    flex: 0 0 80px;
    width: 80px;
    height: 28px;
    font-size: 12px;
    padding: 2px 6px;
    background: var(--bg-primary, #1e1e1e);
    color: var(--text-primary, #eee);
    border: 1px solid var(--border-primary, #444);
    border-radius: 3px;
}
.jaws-scalar-controls-size-input:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.jaws-scalar-controls-size-unit {
    font-size: 11px;
    color: var(--text-muted, #888);
    flex-shrink: 0;
}

.jaws-scalar-controls-size-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.jaws-scalar-controls-size-preset {
    height: 22px;
    min-width: 28px;
    padding: 0 6px;
    font-size: 11px;
    background: var(--bg-primary, #1e1e1e);
    border: 1px solid var(--border-primary, #444);
    border-radius: 3px;
    color: var(--text-primary, #eee);
    cursor: pointer;
}
.jaws-scalar-controls-size-preset:hover:not(:disabled) {
    border-color: var(--accent-primary, #4a9eff);
}
.jaws-scalar-controls-size-preset:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ── Position (Normal / Super / Sub — pressed state) ── */
.jaws-scalar-controls-position {
    display: inline-flex;
    border: 1px solid var(--border-primary, #444);
    border-radius: 3px;
    overflow: hidden;
    background: var(--bg-primary, #1e1e1e);
}
.jaws-scalar-controls-position-btn {
    height: 26px;
    padding: 0 10px;
    font-size: 11px;
    background: transparent;
    border: none;
    border-right: 1px solid var(--border-primary, #444);
    color: var(--text-primary, #eee);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}
.jaws-scalar-controls-position-btn:last-child {
    border-right: none;
}
.jaws-scalar-controls-position-btn:hover:not(:disabled) {
    background: rgba(74, 158, 255, 0.12);
}
.jaws-scalar-controls-position-btn.is-active {
    background: var(--accent-primary, #4a9eff);
    color: #fff;
}
.jaws-scalar-controls-position-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ── Toggles (Bold / Italic / Underline / Strike) ── */
.jaws-scalar-controls-toggles {
    display: inline-flex;
    gap: 4px;
}

.jaws-scalar-controls-toggle {
    width: 30px;
    height: 28px;
    font-size: 13px;
    background: var(--bg-primary, #1e1e1e);
    border: 1px solid var(--border-primary, #444);
    border-radius: 3px;
    color: var(--text-primary, #eee);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.jaws-scalar-controls-toggle:hover:not(:disabled) {
    border-color: var(--accent-primary, #4a9eff);
}
.jaws-scalar-controls-toggle.is-active {
    background: var(--accent-primary, #4a9eff);
    border-color: var(--accent-primary, #4a9eff);
    color: #fff;
}
.jaws-scalar-controls-toggle:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
