/*
   Arabic first. Tajawal is a humanist sans with a full Arabic set and real weights; Noto Naskh
   is the fallback for readers who have it and prefer naskh forms in long legal passages, and
   Segoe UI / Tahoma cover a Windows box with neither webfont available. Latin glyphs come from
   the same stack, so a mixed sentence does not change typeface mid-line.
*/
/* Tajawal, self-hosted (Google Fonts v12 TTFs, OFL) so its vertical metrics can be pinned.
   The font ships two sets: hhea/typo ascent 643 / descent 357 (what Android and macOS use) and
   usWin 1065 / 411 (what Windows uses, USE_TYPO_METRICS unset). At 16px that puts the baseline
   5.2px below the line's centre on Windows but 2.3px on a phone, so every flex-centred label —
   the top-bar brand, chips, buttons — sat ~3px lower on desktop than on a Pixel 7 (2026-10-17).
   The overrides make every platform use the hhea numbers; nudge nothing per platform. */
@font-face {
    font-family: "Tajawal";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("fonts/Tajawal-400.ttf") format("truetype");
    ascent-override: 64.3%;
    descent-override: 35.7%;
    line-gap-override: 20%;
}

@font-face {
    font-family: "Tajawal";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("fonts/Tajawal-500.ttf") format("truetype");
    ascent-override: 64.3%;
    descent-override: 35.7%;
    line-gap-override: 20%;
}

@font-face {
    font-family: "Tajawal";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("fonts/Tajawal-700.ttf") format("truetype");
    ascent-override: 64.3%;
    descent-override: 35.7%;
    line-gap-override: 20%;
}

:root {
    --font-arabic: "Tajawal", "Noto Naskh Arabic", "Segoe UI", Tahoma, sans-serif;
    --font-mono: "Cascadia Mono", Consolas, "Courier New", monospace;

    --bg: #f7f7f8;
    --surface: #ffffff;
    --surface-2: #f1f2f4;
    /* The sidebar follows the colour scheme since 2026-10-17 (it was always dark, which read as
       a foreign panel beside a light transcript on a light-mode phone). Its lines, hovers and
       the selected tab are alpha tokens so one rule set serves both schemes. */
    --sidebar-bg: #eef0f3;
    --sidebar-fg: #16181d;
    --sidebar-muted: #5c6270;
    --sidebar-line: rgba(16, 18, 22, .12);
    --sidebar-hover: rgba(16, 18, 22, .06);
    --sidebar-selected: rgba(16, 18, 22, .12);
    --sidebar-field: #ffffff;
    /* The logo band on the sign-in card stays dark in both schemes: the logo is drawn for it. */
    --brand-band: #14161a;
    --ink: #16181d;
    --ink-muted: #5c6270;
    --line: #e2e4e9;
    --accent: #1f6feb;
    --accent-soft: #e8f0fe;
    /* The question bubble, ChatGPT-style: a filled blue with its own text colour, borderless on
       screen. Its own tokens rather than --accent because print must restore a dark-on-white
       bubble — browsers drop backgrounds on paper, and white text alone would vanish. */
    --user-bubble-bg: #1f6feb;
    --user-bubble-fg: #ffffff;
    --user-bubble-line: transparent;
    --danger: #b4232a;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(16, 18, 22, .06), 0 8px 24px rgba(16, 18, 22, .06);
    /* The section switcher's pill: a track a shade off whatever it sits on (the page above the
       breakpoint, the surface below it), so alpha; the active segment an opaque fill above it. */
    --segment-track: rgba(16, 18, 22, .07);
    --segment-hover: rgba(16, 18, 22, .05);
    --segment-active: #ffffff;
    --segment-active-shadow: 0 1px 3px rgba(16, 18, 22, .18);
    /* Fixed, so what sizes itself to the viewport under the bar (the documents text pane) can
       subtract it, and so the bar does not change height with the page's actions. */
    --topbar-height: 3.25rem;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    font-family: var(--font-arabic);
    font-size: 16px;
    line-height: 1.75;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ---------- scrollbars ---------- */

/* The standard properties, not ::-webkit-scrollbar - Chrome disables the webkit styling
   entirely once scrollbar-color is set, so mixing the two means only these apply anyway.
   The thumb is translucent so a single value sits right on every surface it scrolls over:
   the light page, the dark sidebar, and the dark passage cards - which also keeps it
   correct in both color schemes without another variable pair. */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(128, 138, 156, .45) transparent;
}

/* ---------- shell ---------- */

.chat-shell {
    display: flex;
    /* dvh, with vh as the fallback for browsers without it: on iOS Safari 100vh is the height
       with the toolbars collapsed, so the shell overflowed the visible viewport and the document
       itself scrolled — the top bar and its menu button rode off the screen with the transcript
       (2026-10-17). The dynamic unit tracks the toolbars, so the shell is never taller than what
       is visible and only the transcript scrolls. */
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

.chat-sidebar {
    width: 288px;
    flex: 0 0 288px;
    background: var(--sidebar-bg);
    color: var(--sidebar-fg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-main {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg);
}

.chat-topbar {
    /* Shown at every width since the section switcher moved here from the sidebar (user request
       2026-10-17). Three columns, the outer two equal, so the switcher sits on the column's centre
       whether or not the menu button or a page action is present. Above the breakpoint it takes
       the page's background and no rule, so it reads as the top of the column, not a toolbar. */
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    column-gap: .5rem;
    flex: 0 0 auto;
    min-height: var(--topbar-height);
    padding: .25rem .75rem;
    background: var(--bg);
}

.topbar-start,
.topbar-end {
    display: flex;
    align-items: center;
    min-width: 0;
}

/* The inline end — the left, in this RTL document. */
.topbar-end {
    justify-content: flex-end;
}

/* The sidebar is always visible above the breakpoint, so the menu button only exists below it.
   Two classes: .icon-btn sets display later in the file at equal specificity. */
.chat-topbar .topbar-menu {
    display: none;
}

/* ---------- section switcher ---------- */

/* ChatGPT's "Chat | Work" switch: a pill track with the current section filled. */
.section-switcher {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    border-radius: 999px;
    background: var(--segment-track);
}

.section-tab {
    display: inline-block;
    padding: calc(.4rem + 1.5px) 1rem calc(.4rem - 1.5px); /* see .quiet-btn */
    border-radius: 999px;
    /* Muted until chosen: weight and fill alone left the active segment hard to pick out in dark
       mode (user feedback 2026-10-17), so the colour carries the difference too. */
    color: var(--ink-muted);
    font-size: .86rem;
    font-weight: 500;
    /* Tighter than the body's 1.75 so the pill fits the bar's fixed height with room around it. */
    line-height: 1.5;
    white-space: nowrap;
    text-decoration: none;
    transition: background .12s ease, color .12s ease;
}

/* Bootstrap's a:hover outranks a single class, hence the colour and underline restated here.
   Fainter than the active fill, so a hovered segment never reads as the chosen one. Pointer
   devices only: a touch screen keeps :hover on the last element tapped, so on a phone the tab
   just left stayed lit beside the new one and read as a second selection (2026-10-17). */
a.section-tab:hover {
    color: var(--ink-muted);
    text-decoration: none;
}

@media (hover: hover) {
    a.section-tab:hover {
        color: var(--ink);
        background: var(--segment-hover);
    }
}

.section-tab[aria-current="page"] {
    color: var(--ink);
    background: var(--segment-active);
    box-shadow: var(--segment-active-shadow);
    font-weight: 700;
    cursor: default;
}

.section-tab:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

/* Menu button, three labels and print on one line at 360px, with no wrap and no sideways scroll. */
@media (max-width: 560px) {
    .chat-topbar {
        column-gap: .25rem;
        padding-inline: .5rem;
    }

    .section-tab {
        padding-inline: .7rem;
    }
}

.chat-backdrop {
    display: none;
}

/* Below the breakpoint the sidebar becomes an overlay. It slides in from the inline start,
   which the logical property resolves to the right in this RTL document without a second rule. */
@media (max-width: 900px) {
    /* Here the sidebar is an overlay, so the bar is a toolbar over the edge-to-edge column. */
    .chat-topbar {
        border-bottom: 1px solid var(--line);
        background: var(--surface);
    }

    .chat-topbar .topbar-menu {
        display: inline-flex;
    }

    .chat-sidebar {
        position: fixed;
        inset-block: 0;
        inset-inline-start: 0;
        z-index: 30;
        transform: translateX(0);
        transition: transform .18s ease-out;
        /* A scroll container of its own with chaining cut, so a scroll gesture that starts on a
           part of the panel that does not scroll (the user row, the new button) ends at the panel
           instead of being handed to the transcript behind it — iOS Safari did exactly that
           (2026-10-17). The list inside keeps its own scroller and is contained the same way. */
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    html[dir="rtl"] .chat-sidebar {
        transform: translateX(100%);
    }

    html[dir="ltr"] .chat-sidebar {
        transform: translateX(-100%);
    }

    .chat-shell.is-open .chat-sidebar {
        transform: translateX(0);
    }

    .chat-shell.is-open .chat-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 20;
        background: rgba(10, 12, 16, .45);
    }
}

/* ---------- sidebar ---------- */

.sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: .75rem;
    gap: .75rem;
}

.new-chat-btn {
    display: flex;
    align-items: center;
    gap: .5rem;
    width: 100%;
    padding: calc(.6rem + 1.5px) .75rem calc(.6rem - 1.5px); /* see .quiet-btn */
    border: 1px solid var(--sidebar-line);
    border-radius: 10px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: background .12s ease;
}

.new-chat-btn:hover {
    background: var(--sidebar-hover);
}

.new-chat-btn .plus {
    font-size: 1.15rem;
    line-height: 1;
}

.sidebar-lists {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain; /* see .chat-sidebar in the phone block */
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

.conversation-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* The lists are navigation, not text: a selection left behind by a rename (the input is replaced
   by the row, and the browser moves the selection onto the new title) would otherwise sit on the
   name as a pale block for as long as the window is unfocused. */
.conversation-list .conversation {
    user-select: none;
}

.conversation-list .rename-input {
    user-select: text;
}

/* Two lines where a conversation has one: the title, then what kind of document it is and how far
   it got. The status is the reason to open a draft again, so it stays visible without hovering. */
.draft-link {
    display: flex;
    flex-direction: column;
    gap: .2rem;
}

.draft-line {
    display: flex;
    align-items: center;
    gap: .4rem;
    min-width: 0;
}

.draft-glyph {
    flex: 0 0 auto;
    color: var(--sidebar-muted);
}

.draft-meta {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding-inline-start: 1.25rem;
    font-size: .74rem;
    color: var(--sidebar-muted);
}

.status-pill {
    border-radius: 999px;
    padding: 0 .5rem;
    font-size: .7rem;
    font-weight: 700;
    line-height: 1.6;
    background: var(--sidebar-selected);
    color: var(--sidebar-fg);
}

.status-pill.status-ready {
    background: rgba(91, 157, 255, .22);
    color: #b9d3ff;
}

.status-pill.status-drafting {
    background: rgba(230, 168, 30, .22);
    color: #f3d38a;
}

.status-pill.status-done {
    background: rgba(46, 160, 67, .25);
    color: #a6e3b3;
}

.status-pill.status-failed {
    background: rgba(180, 35, 42, .3);
    color: #f5b5b9;
}

.conversation {
    display: flex;
    align-items: center;
    gap: .25rem;
    border-radius: 10px;
    padding-inline: .25rem;
}

.conversation:hover,
.conversation.active {
    background: var(--sidebar-hover);
}

.conversation-link {
    flex: 1 1 auto;
    min-width: 0;
    padding: .5rem .35rem;
    color: inherit;
    text-decoration: none;
}

.conversation-title {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .93rem;
}

/* One "⋯" per row opening a small menu (rename, delete), in place of the two icons it replaced
   (2026-10-17). The flows behind both items are unchanged. */
.row-menu {
    position: relative;
    flex: 0 0 auto;
}

.row-menu-btn {
    display: none;
}

/* Revealed on hover only where hover exists. On iOS a tap on a row whose :hover rule shows new
   content is spent on the hover, and the link only follows on a second tap — which also left
   the phone menu open after choosing a thread (2026-10-17). Touch screens see the button
   always, as the active row and the row whose menu is open do everywhere. */
.conversation.active .row-menu-btn,
.row-menu.open .row-menu-btn {
    display: inline-flex;
}

.row-menu.open .row-menu-btn {
    opacity: 1;
    background: var(--sidebar-hover);
}

@media (hover: hover) {
    .conversation:hover .row-menu-btn {
        display: inline-flex;
    }
}

@media (hover: none) {
    .row-menu-btn {
        display: inline-flex;
    }
}

/* Under the popover and over everything else; ChatSidebar renders it only while a menu is open. */
.row-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 34;
    background: transparent;
}

.row-menu-popover {
    position: absolute;
    top: calc(100% + 4px);
    inset-inline-end: 0;
    z-index: 35;
    min-width: 11rem;
    padding: .3rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow);
}

/* The last rows of a list open upward: .sidebar-lists is a scroll box and would clip the popover
   below them. Which rows is decided in ChatSidebar.OpensUpward, not by measuring. */
.row-menu.flip-up .row-menu-popover {
    top: auto;
    bottom: calc(100% + 4px);
}

.row-menu-item {
    display: flex;
    align-items: center;
    gap: .6rem;
    width: 100%;
    padding: calc(.5rem + 1.5px) .7rem calc(.5rem - 1.5px); /* see .quiet-btn */
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: .9rem;
    text-align: start;
    white-space: nowrap;
    cursor: pointer;
}

/* The glyph sits on the letter bodies, not on the box the padding shift moved them in. */
.row-menu-item svg {
    flex: 0 0 auto;
    transform: translateY(-1.5px);
}

.row-menu-item:hover,
.row-menu-item:focus-visible {
    background: var(--surface-2);
    outline: none;
}

.row-menu-item.danger {
    color: var(--danger);
}

.row-menu-sep {
    height: 1px;
    margin: .25rem .3rem;
    background: var(--line);
}

.rename-input {
    width: 100%;
    margin: .25rem 0;
    padding: .35rem .5rem;
    border: 1px solid var(--accent);
    border-radius: 8px;
    background: var(--sidebar-field);
    color: var(--sidebar-fg);
    font: inherit;
    font-size: .9rem;
}

.empty-note,
.sidebar-footer .muted {
    color: var(--sidebar-muted);
    font-size: .82rem;
}

.sidebar-footer {
    border-top: 1px solid var(--sidebar-line);
    padding-top: .6rem;
}

.sidebar-user {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .5rem;
}

/* The name is the one part of this row that can be arbitrarily long; it gives up its width
   first so the button never wraps under it. */
.sidebar-user-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .88rem;
}

/* .quiet-btn is drawn for the page, so the surface and line colours are the only two things
   overridden here, in the sidebar's own tokens. */
.logout-btn {
    flex: 0 0 auto;
    border-color: var(--sidebar-line);
    background: transparent;
    color: var(--sidebar-muted);
    font-size: .8rem;
}

.logout-btn:hover {
    color: var(--sidebar-fg);
    border-color: var(--sidebar-muted);
}

/* ---------- sign-in ---------- */

.bare-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem;
}

.login-card {
    width: min(24rem, 100%);
    padding: 1.75rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* The brand mark is white and orange on transparency, so it sits on the sidebar's dark band
   in both colour schemes; the band bleeds to the card's edges through the negative margins. */
.login-brand {
    display: flex;
    justify-content: center;
    margin: -1.75rem -1.75rem 1.25rem;
    padding: 1.25rem 1.75rem;
    background: var(--brand-band);
}

.login-logo {
    width: min(17rem, 100%);
    height: auto;
    display: block;
}

.login-title {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
}

/* Routes.razor's FocusOnNavigate moves focus to the h1 after each navigation so screen readers
   announce the page; the browser's focus ring around a heading is noise for everyone else. */
.login-title:focus,
.hero-title:focus {
    outline: none;
}

.login-subtitle {
    margin: .15rem 0 1.25rem;
    color: var(--ink-muted);
    font-size: .9rem;
}

.login-field {
    display: block;
    margin-bottom: .9rem;
}

.login-label {
    display: block;
    margin-bottom: .3rem;
    font-size: .85rem;
    color: var(--ink-muted);
}

.login-input {
    width: 100%;
    padding: .5rem .7rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    /* Form controls do not inherit either of these; in the dark scheme the UA defaults put
       near-black text on a near-black field. Same reason .composer-input sets them. */
    color: var(--ink);
    font: inherit;
    caret-color: var(--accent);
}

.login-input:focus {
    outline: none;
    border-color: var(--accent);
}

/* A phone number and a code read left-to-right inside the RTL document; the field itself
   stays in the RTL flow, only its content is re-anchored. */
.login-input[type="tel"],
.login-input[autocomplete="one-time-code"] {
    direction: ltr;
    text-align: left;
}

.login-code {
    letter-spacing: .3em;
}

.login-note {
    margin: 0 0 1rem;
    font-size: .88rem;
    color: var(--ink-muted);
}

.login-dev {
    margin-bottom: 1rem;
    padding: .5rem .75rem;
    border: 1px dashed var(--line);
    border-radius: 10px;
    font-size: .85rem;
}

.login-link {
    display: block;
    margin-top: .9rem;
    text-align: center;
    font-size: .88rem;
    color: var(--accent);
}

.login-submit {
    width: 100%;
    padding: .55rem;
    border: 0;
    border-radius: 12px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-weight: 500;
    cursor: pointer;
}

.login-submit:hover {
    filter: brightness(1.06);
}

.draft-missing {
    margin-bottom: 1rem;
    font-size: 1rem;
}

.login-submit:disabled {
    opacity: .6;
    cursor: default;
}

.login-error,
.login-validation {
    color: var(--danger);
    font-size: .85rem;
}

.login-error {
    margin-bottom: 1rem;
    padding: .55rem .75rem;
    border: 1px solid rgba(180, 35, 42, .35);
    border-radius: 10px;
    background: rgba(180, 35, 42, .08);
}

.login-validation {
    display: block;
    margin-top: .25rem;
}

/* ---------- buttons ---------- */

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
    opacity: .75;
}

.icon-btn:hover {
    opacity: 1;
    background: rgba(127, 127, 127, .18);
}

.quiet-btn {
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink-muted);
    font: inherit;
    font-size: .85rem;
    /* Padding shifted 1.5px from bottom to top on every text button (here, .danger-btn,
       .new-chat-btn, .section-tab, .draft-generate-btn): Tajawal's ascenders rise far above the
       letter bodies while nothing dips below, so a label centred by its box reads high. Same
       optical rule as the chips (2026-10-17); the button's height is unchanged. */
    padding: calc(.2rem + 1.5px) .8rem calc(.2rem - 1.5px);
    cursor: pointer;
}

.quiet-btn:hover {
    color: var(--ink);
    border-color: #c9cdd6;
}

.danger-btn {
    border: 0;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font: inherit;
    font-size: .85rem;
    padding: calc(.2rem + 1.5px) .8rem calc(.2rem - 1.5px); /* see .quiet-btn */
    cursor: pointer;
}

/* ---------- delete confirmation ---------- */

/* Above the phone sidebar (30) and the ruling drawer (40), below the reconnect dialog (60). The
   sidebar renders both through the layout's "dialog" outlet, so fixed means the viewport. */
.modal-backdrop-app {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(10, 12, 16, .55);
}

.confirm-dialog {
    position: fixed;
    z-index: 51;
    inset-inline: 1rem;
    top: 50%;
    transform: translateY(-50%);
    margin-inline: auto;
    width: min(26rem, calc(100% - 2rem));
    padding: 1.4rem 1.5rem 1.25rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow);
}

.confirm-dialog-close {
    position: absolute;
    top: .6rem;
    inset-inline-end: .6rem;
}

.confirm-dialog-title {
    margin: 0;
    margin-block-end: .5rem;
    padding-inline-end: 2rem;
    font-size: 1.15rem;
    font-weight: 700;
}

.confirm-dialog-text {
    margin: 0 0 1.1rem;
    color: var(--ink-muted);
    font-size: .95rem;
}

.confirm-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
}

.confirm-dialog-actions .quiet-btn,
.confirm-dialog-actions .danger-btn {
    font-size: .92rem;
    padding: calc(.45rem + 1.5px) 1.1rem calc(.45rem - 1.5px); /* see .quiet-btn */
}

/* ---------- page ---------- */

.chat-page {
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.banner {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin: .75rem auto 0;
    padding: .6rem 1rem;
    width: min(48rem, calc(100% - 2rem));
    border: 1px solid #f0d9a8;
    border-radius: 10px;
    background: #fdf6e3;
    color: #6b5312;
    font-size: .92rem;
}

.banner span {
    flex: 1 1 auto;
}

.message-scroll {
    flex: 1 1 auto;
    overflow-y: auto;
    scroll-behavior: smooth;
}

/* The single measure the whole conversation is set to. Long Arabic legal prose is unreadable
   across a 1600px window, and centring the column keeps the answer, its sources and the input
   box on one axis. */
.message-column {
    width: min(48rem, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1.5rem 0 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* ---------- messages ---------- */

.message {
    display: flex;
    min-width: 0;
}

/* The question is the only side that reads as a bubble. An answer runs to paragraphs, sources
   and an action row, so chrome around it would box the page's own content; the question is a
   line or two and needs to be told apart from it at a glance.

   A column so the stamp can sit centred over the bubble. align-items is the inline axis here,
   and flex-start resolves to the right edge in this RTL document — the same side the reference
   keeps its questions on. */
.message.user {
    flex-direction: column;
    align-items: flex-start;
    gap: .35rem;
}

/* Centred over the bubble the way the reference stamps a question; sized as chrome, not content. */
.message-time {
    align-self: center;
    font-size: .72rem;
    color: var(--ink-muted);
}

.bubble {
    flex: 1 1 auto;
    min-width: 0;
}

/* Shrink-to-fit rather than stretched, and capped short of the measure: a bubble as wide as the
   column would read as another answer. The radius is the composer's 18px rather than --radius:
   the question is the composer's own text given back, and the reference rounds it the same way. */
.message.user .bubble {
    flex: 0 1 auto;
    max-width: min(85%, 34rem);
    background: var(--user-bubble-bg);
    color: var(--user-bubble-fg);
    border: 1px solid var(--user-bubble-line);
    border-radius: 18px;
    padding: .35rem 1rem;
    box-shadow: var(--shadow);
}

/* unicode-bidi: plaintext makes each paragraph pick its own direction from its first strong
   character, so an English question inside this RTL page reads left to right — and an Arabic
   answer that quotes an English term does not have its punctuation thrown to the wrong end. */
.content {
    unicode-bidi: plaintext;
}

.content > :first-child {
    margin-top: 0;
}

.content > :last-child {
    margin-bottom: 0;
}

.content p,
.content li {
    margin: .5rem 0;
}

.content h1, .content h2, .content h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 1.1rem 0 .4rem;
}

.content table {
    width: 100%;
    border-collapse: collapse;
    margin: .75rem 0;
    font-size: .93rem;
}

.content th,
.content td {
    border: 1px solid var(--line);
    padding: .4rem .6rem;
    text-align: start;
}

.content blockquote {
    margin: .75rem 0;
    padding-inline-start: .9rem;
    border-inline-start: 3px solid var(--line);
    color: var(--ink-muted);
}

/* A phone reads the same answer in a 380px column, where the desktop rhythm — half-rem gaps on
   every paragraph and list item, the browser's 32px list indent — spreads a ten-line answer
   over two screens. Tightened here only; the measure above 560px is untouched. Line height and
   body size are left alone (the 1.6 line height was tried and reverted the same day): a
   reader's own font scale applies on top of them and must keep doing so (2026-10-17). */
@media (max-width: 560px) {
    .message-column {
        padding: 1rem 0 1.5rem;
        gap: 1rem;
    }

    .content p,
    .content li {
        margin: .3rem 0;
    }

    .content ol,
    .content ul {
        padding-inline-start: 1.25rem;
        margin-block: .4rem;
    }

    .content h1, .content h2, .content h3 {
        margin: .8rem 0 .3rem;
    }

    .content blockquote {
        margin: .5rem 0;
        padding-inline-start: .7rem;
    }
}

/* Code is the one thing that is never RTL, whatever the surrounding document says: a shell
   command or a JSON fragment mirrored by the bidi algorithm is unreadable and, worse, looks
   plausible. */
.content pre,
.content code {
    font-family: var(--font-mono);
    direction: ltr;
    text-align: left;
    unicode-bidi: embed;
}

.content code {
    background: var(--surface-2);
    border-radius: 5px;
    padding: .1rem .3rem;
    font-size: .88em;
}

.content pre {
    background: #14161a;
    color: #e7e9ee;
    padding: .85rem 1rem;
    border-radius: 10px;
    overflow-x: auto;
}

.content pre code {
    background: transparent;
    padding: 0;
    color: inherit;
}

.user-text {
    white-space: pre-wrap;
}

/* The citation marker Markdig's output is post-processed into. Superscript, so it sits out of
   the reading line, and tinted so a reader can tell a source reference from a bracketed
   article number in the ruling's own text. */
.content .cite {
    color: var(--accent);
    font-size: .72em;
    font-weight: 700;
    padding-inline: .1rem;
}

.cursor {
    display: inline-block;
    width: .5rem;
    height: 1.05rem;
    margin-inline-start: .15rem;
    vertical-align: text-bottom;
    border-radius: 2px;
    background: var(--accent);
    animation: cursor-pulse 1s steps(2, start) infinite;
}

@keyframes cursor-pulse {
    to {
        opacity: .15;
    }
}

/* The pre-token phases (searching, thinking). Shown instead of the cursor while the bubble
   is still empty, because retrieval and the model's reasoning are silent and a bare cursor
   there reads as a hang. */
.thinking {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding-block: .15rem;
    color: var(--ink-muted);
    font-size: .9rem;
}

.thinking-dots {
    display: inline-flex;
    gap: .28rem;
}

.thinking-dots span {
    width: .42rem;
    height: .42rem;
    border-radius: 50%;
    background: var(--accent);
    animation: thinking-bounce 1.2s ease-in-out infinite;
}

.thinking-dots span:nth-child(2) {
    animation-delay: .15s;
}

.thinking-dots span:nth-child(3) {
    animation-delay: .3s;
}

@keyframes thinking-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: .35;
    }

    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

/* Opacity-only variant of the dots for reduced motion. Same rhythm, no travel. */
@keyframes thinking-fade {
    0%, 60%, 100% {
        opacity: .3;
    }

    30% {
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    /* Windows "animation effects off" lands every user here, so this must stay an
       indicator, not a freeze: a static row of dots reads as a hang, which is the exact
       problem the indicator exists to solve. The preference targets spatial motion — the
       bounce goes, an opacity breathe stays, and the cursor's own pulse is already
       opacity-only so it is left running. The nth-child delays survive because those rules
       are more specific than this shorthand. */
    .thinking-dots span {
        animation: thinking-fade 1.6s ease-in-out infinite;
    }

    .message-scroll {
        scroll-behavior: auto;
    }
}

.message-error {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    padding: .65rem .9rem;
    border: 1px solid #f0c2c2;
    border-radius: 10px;
    background: #fdf2f2;
    color: #7d2020;
    font-size: .92rem;
}

.stopped-note,
.message-actions {
    margin-top: .5rem;
}

.stopped-note {
    color: var(--ink-muted);
    font-size: .85rem;
}

/* One row holds everything a finished answer offers. The page is RTL, so the thumbs sit at the
   inline start — under the answer's opening words — and إعادة التوليد follows them. */
.message-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.feedback {
    display: inline-flex;
    gap: .1rem;
}

/* Deliberately quieter than .icon-btn: this pair sits inside the answer rather than in a
   toolbar, and an unrated answer should not look like it is asking to be rated. */
.feedback-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--ink-muted);
    font: inherit;
    cursor: pointer;
    opacity: .6;
}

.feedback-btn:hover {
    opacity: 1;
    background: rgba(127, 127, 127, .18);
}

.feedback-btn.on {
    color: var(--accent);
    opacity: 1;
}

/* The outline is the unrated state and the fill is the chosen one; at 16px the colour change
   alone is too easy to miss on a glance. */
.feedback-btn.on svg {
    fill: currentColor;
}

/* ---------- citations ---------- */

.citations {
    margin-top: .9rem;
    border-top: 1px solid var(--line);
    padding-top: .7rem;
}

.citations-head {
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
}

.citations-title {
    font-size: .85rem;
    font-weight: 700;
    color: var(--ink-muted);
}

/* Muted and unadorned, matching .stopped-note: it qualifies the sources rather than warning about
   them, and a coloured banner would read as a failed turn to someone whose answer is fine. */
.literal-search-note {
    margin: .45rem 0 0;
    color: var(--ink-muted);
    font-size: .82rem;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: .3rem;
}

/* The paper counterpart of the chips-and-card pair; the print block below swaps them. */
.citations-print {
    display: none;
}

.chip {
    min-width: 28px;
    height: 28px;
    /* Top padding only: the label is a digit, and Tajawal's digits are cap-height figures with
       no descender, so their ink centre sits ~3px above the line's centre in a 28px box. The
       button centres its content box, so 5px of top padding moves the ink down by half that
       (measured 2026-10-17; Arabic labels elsewhere need no such nudge). */
    padding: 5px .45rem 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink-muted);
    font: inherit;
    font-size: .82rem;
    font-weight: 700;
    cursor: pointer;
    transition: all .12s ease;
}

.chip:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.chip.open {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.citation-card {
    margin-top: .6rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    padding: .75rem .9rem;
}

/* A block, not a wrapping row: the reader switches cards by clicking chips, and a flow layout
   re-places every label as soon as one value is longer or absent. Scoped to the card — the
   drawer's own meta row keeps the flex behaviour. */
.citation-meta {
    font-size: .84rem;
    color: var(--ink-muted);
    margin-bottom: .5rem;
}

.citation-meta-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .4rem;
}

/* max-content over a fixed label set, so the label column is the same width on every source and
   the values all start at one line. */
.citation-meta-grid {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: .25rem .5rem;
    margin: 0;
}

.citation-meta-grid dd {
    margin: 0;
}

.meta-label {
    color: #8b909b;
}

.meta-label::after {
    content: ":";
    margin-inline-end: .2rem;
}

.badge {
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: 999px;
    padding: .05rem .6rem;
    font-weight: 700;
}

/* Capped and scrollable: a MemHokom chunk runs to a thousand characters, and letting it push
   the answer off screen defeats the purpose of showing it. */
.citation-text {
    max-height: 15rem;
    overflow-y: auto;
    white-space: pre-wrap;
    font-size: .92rem;
    line-height: 1.85;
    unicode-bidi: plaintext;
    padding-inline-end: .3rem;
}

/* The legislation the ruling rests on. Set below the passage and quieter than it: this is
   context for the citation, not a second body of text. */
.cited-laws {
    margin-top: .7rem;
    padding-top: .6rem;
    border-top: 1px dashed var(--line);
}

.cited-laws-title {
    display: block;
    font-size: .8rem;
    font-weight: 700;
    color: var(--ink-muted);
    margin-bottom: .4rem;
}

.cited-laws-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: .3rem;
    margin: 0;
    padding: 0;
}

.cited-law {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: .1rem .6rem;
    font-size: .82rem;
    color: var(--ink);
    unicode-bidi: plaintext;
}

/* A reconstructed law title below the confidence threshold, or none at all. Muted rather than
   hidden — the article number is exact either way; see CitedLaw.Confidence. */
.cited-law.tentative {
    color: var(--ink-muted);
    border-style: dashed;
    background: transparent;
    cursor: help;
}

.cited-laws-more {
    display: inline-block;
    margin-top: .35rem;
    font-size: .78rem;
    color: var(--ink-muted);
}

/* Below the passage and its legislation, at the foot of the card: the action is about the whole
   ruling, not about anything the reader is part-way through. */
.citation-actions {
    margin-top: .7rem;
}

/* ---------- legal-consultation sources ---------- */

/* Egyptian material is never to read as Kuwaiti law (user decision 2026-10-19): the amber of the
   app's other cautions, on the chip, the badge and the note under the heading. */
.chip.chip-eg {
    border-color: #e9d9a6;
    color: #6b5312;
}

.chip.chip-eg.open {
    background: #6b5312;
    border-color: #6b5312;
    color: #fff;
}

.legal-badges {
    display: inline-flex;
    flex-wrap: wrap;
    gap: .3rem;
}

.badge.badge-eg {
    background: #fdf6e3;
    color: #6b5312;
    border: 1px solid #e9d9a6;
}

.legal-heading {
    margin: 0 0 .35rem;
    color: var(--ink);
    font-weight: 700;
    line-height: 1.6;
    unicode-bidi: plaintext;
}

.legal-eg-note {
    margin: 0 0 .4rem;
    color: #6b5312;
    font-weight: 700;
}

/* ---------- ruling viewer ---------- */

/* Fixed to the viewport rather than to .chat-page: the drawer covers the sidebar too, and a
   stacking context created by any ancestor transform would otherwise trap it. */
.drawer-layer {
    position: fixed;
    inset: 0;
    z-index: 40;
}

.drawer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 12, 16, .5);
}

/* Anchored to the inline start, which the logical property resolves to the right in this RTL
   document — the same side the sidebar overlay uses, so the two never read as opposite gestures. */
.drawer {
    position: absolute;
    inset-block: 0;
    inset-inline-start: 0;
    width: min(46rem, 100%);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-inline-end: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.drawer-head {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    padding: .85rem 1.1rem .6rem;
    border-bottom: 1px solid var(--line);
}

.drawer-title {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* The topic path arrives as lines and is kept as lines: it is a hierarchy, and joining it with
   separators would read as one long title. */
.drawer-path-line {
    font-size: .95rem;
    font-weight: 700;
    line-height: 1.5;
}

.drawer-path-line:not(:first-child) {
    font-weight: 500;
    color: var(--ink-muted);
    font-size: .85rem;
}

.drawer-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .3rem .9rem;
    padding: .5rem 1.1rem;
    border-bottom: 1px solid var(--line);
    background: var(--surface-2);
    font-size: .82rem;
    color: var(--ink-muted);
}

/* Pinned to the row's far edge — the left, in RTL — away from the date it would otherwise
   crowd. inline-start is the right side here, so the auto margin pushes leftwards. */
.drawer-meta .drawer-meta-end {
    margin-inline-start: auto;
}

/* The scroller is the body, not the page. A MemHokom section runs to tens of thousands of
   characters, and scrolling the document instead would take the header off screen with it. */
.drawer-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 1rem 1.1rem 2rem;
}

.drawer-section + .drawer-section {
    margin-top: 1.5rem;
    padding-top: 1.2rem;
    border-top: 1px solid var(--line);
}

.drawer-section-title {
    margin: 0 0 .5rem;
    font-size: .85rem;
    font-weight: 700;
    color: var(--accent);
}

/* pre-wrap because the section's paragraph breaks are its structure — CleanSectionText rejoins
   paragraphs with a blank line and nothing else marks them. */
.drawer-text {
    white-space: pre-wrap;
    font-size: .95rem;
    line-height: 1.9;
    unicode-bidi: plaintext;
}

.drawer-text mark {
    background: rgba(255, 214, 102, .45);
    color: inherit;
    border-radius: 3px;
    padding: .05rem 0;
}

/* The passage the reader actually clicked. Distinct from its siblings rather than merely
   brighter: several passages of one ruling are commonly retrieved together. */
.drawer-text mark.focus {
    background: rgba(255, 190, 40, .75);
    box-shadow: 0 0 0 2px rgba(255, 190, 40, .35);
}

.drawer-notice {
    margin: 0 0 .5rem;
    font-size: .8rem;
    color: var(--ink-muted);
}

/* Rulings resting on the same legislation. Separated from the last section by the same border a
   section uses, because that is what it is to a reader scrolling: another block after the text —
   not a sidebar, and not part of the ruling. */
.drawer-similar {
    margin-top: 1.5rem;
    padding-top: 1.2rem;
    border-top: 1px solid var(--line);
}

.similar-item {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    padding: .6rem .7rem;
    border-radius: 10px;
    background: var(--surface-2);
}

.similar-item + .similar-item {
    margin-top: .4rem;
}

.similar-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: .15rem;
}

.similar-title {
    font-size: .9rem;
    font-weight: 600;
    line-height: 1.5;
}

.similar-meta {
    font-size: .8rem;
    color: var(--ink-muted);
}

/* The instruments the two rulings have in common — the whole basis of the row being here, so it
   is stated rather than left to the heading. */
.similar-shared {
    font-size: .78rem;
    color: var(--ink-muted);
    unicode-bidi: plaintext;
}

.similar-more {
    margin-inline-start: .3rem;
}

/* The action keeps its own line once the row is narrow: at this width the button and a topic path
   share a line only by squeezing the path to a few characters. */
@media (max-width: 560px) {
    .similar-item {
        flex-direction: column;
    }
}

@media (max-width: 900px) {
    .drawer {
        width: 100%;
    }
}

/* ---------- empty state ---------- */

.empty-state {
    flex: 1 1 auto;
    display: grid;
    place-items: center;
    overflow-y: auto;
    padding: 2rem 1rem;
}

.hero {
    width: min(48rem, 100%);
    text-align: center;
}

.hero-title {
    font-size: 1.9rem;
    font-weight: 700;
    margin: 0 0 .5rem;
}

.hero-subtitle {
    color: var(--ink-muted);
    margin: 0 auto 2rem;
    max-width: 34rem;
}

.prompt-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
    gap: .75rem;
    text-align: start;
}

.prompt-card {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    padding: .85rem 1rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    font: inherit;
    cursor: pointer;
    text-align: start;
    transition: border-color .12s ease, transform .12s ease;
}

.prompt-card:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
}

.prompt-title {
    font-weight: 700;
    font-size: .88rem;
    color: var(--accent);
}

.prompt-text {
    font-size: .93rem;
    color: var(--ink-muted);
}

/* ---------- topic scope ---------- */

/* Shares the country row's measure and side padding so the two scopes read as one stack above
   the composer. Its own row because a leaf title is a sentence, not a five-character label, and
   wrapping it through the fixed country chips would break their alignment. */
.topic-scope-row {
    display: flex;
    width: min(48rem, 100%);
    margin: 0 auto .35rem;
    padding-inline: .55rem;
}

/* Filled in the accent rather than outlined like a country chip: this one is off by default and
   changes what the corpus even contains for the next question, so it should be the loudest thing
   in the row while it is on. */
.topic-chip {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    max-width: 100%;
    min-height: 26px;
    padding-inline: .7rem .35rem;
    border: 1px solid var(--accent);
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: .78rem;
    font-weight: 700;
}

/* One line whatever the title's length: the chip sits directly above the composer, and a wrapped
   one pushes the input down the page every time the scope changes. */
.topic-chip-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topic-chip-clear {
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    line-height: 1;
    padding: .1rem .3rem;
    opacity: .7;
    cursor: pointer;
}

.topic-chip-clear:hover {
    opacity: 1;
}

/* ---------- country scope ---------- */

/* Sits on top of the composer and shares its measure, so the scope reads as part of the input
   rather than as a toolbar over the conversation. Opaque rather than the composer's gradient:
   the message list scrolls underneath this row and would otherwise show through the chips. */
.country-scope {
    padding: .5rem 1rem 0;
    background: var(--bg);
}

/* The block's first line, the way ChatGPT pins its own caution over the composer. Smaller than
   the chips under it so the row of controls stays the thing the eye lands on; the measure keeps
   it aligned with the column the thread uses. */
.chat-disclaimer {
    width: min(48rem, 100%);
    margin: 0 auto .4rem;
    text-align: center;
    font-size: .72rem;
    color: var(--ink-muted);
}

.country-scope-row {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    width: min(48rem, 100%);
    margin: 0 auto;
    /* Matches .composer-inner's own side padding, so a chip's edge lines up with the text in
       the box below it rather than with the box's border. */
    padding-inline: .55rem;
}

/* Deliberately not .chip: that one is the citation opener, sized to a one- or two-digit
   number and toggled per answer. The two share only an idea. */
.country-chip {
    height: 26px;
    /* Top padding only, like .chip: the label's ascenders (الكويت, الإمارات) reach well above
       the letter bodies while nothing dips below, so the word reads high in a 26px pill. The
       button centres its content box, so 3px moves the ink down ~1.5px (2026-10-17). */
    padding: 3px .7rem 0;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink-muted);
    font: inherit;
    font-size: .78rem;
    font-weight: 700;
    cursor: pointer;
    transition: all .12s ease;
}

.country-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* After the :hover rule and at equal specificity, so a selected chip keeps its filled look
   while the pointer is over it. */
.country-chip.on {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* The last country standing. Still a button — the click is simply a no-op — so the title
   stays reachable on hover and the state is announced rather than merely implied. */
.country-chip[aria-disabled="true"] {
    cursor: default;
}

/* ---------- composer ---------- */

.composer {
    padding: .75rem 1rem 1rem;
    background: linear-gradient(to top, var(--bg) 65%, rgba(247, 247, 248, 0));
}

/* A column so a page's attachments sit inside the box above the text, as ChatGPT and Claude
   show a message's files; the row below is the one every page has. */
.composer-inner {
    display: flex;
    flex-direction: column;
    width: min(48rem, 100%);
    margin: 0 auto;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.composer-inner:focus-within {
    border-color: var(--accent);
}

.composer-row {
    display: flex;
    align-items: flex-end;
    gap: .5rem;
    padding: .45rem .55rem;
}

.composer-attachments {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem;
    padding: .5rem .55rem 0;
}

.composer-leading {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
}

.composer-leading .icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    color: var(--ink-muted);
}

.composer-leading .icon-btn:hover:not(:disabled) {
    color: var(--accent);
}

.composer-leading .icon-btn:disabled {
    opacity: .35;
    cursor: default;
    background: transparent;
}

.composer-input {
    flex: 1 1 auto;
    resize: none;
    border: 0;
    outline: none;
    background: transparent;
    font: inherit;
    line-height: 1.7;
    padding: .35rem .5rem;
    max-height: 220px;
    /* Form controls do not inherit color; without this the UA default (near-black) sits on the
       dark surface and the draft is unreadable. No unicode-bidi: plaintext here — it re-anchors
       a Latin-only draft to the left edge; see the note on the textarea itself. */
    color: var(--ink);
    caret-color: var(--accent);
}

.composer-input::placeholder {
    /* --ink-muted is the colour of secondary labels, legible on purpose; at full strength the
       hint read as typed text. Opacity, not a lighter token, so it dims the same in both schemes
       (Firefox already applies ~.54; Chrome none). */
    color: var(--ink-muted);
    opacity: .55;
}

.send-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 12px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    transition: opacity .12s ease;
}

.send-btn:disabled {
    opacity: .35;
    cursor: default;
}

/* The stop state keeps the send button's full accent: the square icon is the state change, and a
   muted background reads as disabled on exactly the turn the button is most needed. */

/* ---------- drafting ---------- */

.draft-kind-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
    gap: .75rem;
    text-align: start;
}

.draft-kind-card.on {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.draft-kind-card:disabled {
    cursor: default;
    transform: none;
}

/* The short forms: a row of three smaller cards under the claim and the defence, so five choices
   read as two documents and three requests rather than one undifferentiated grid. */
.draft-form-kinds {
    margin-top: .9rem;
    text-align: start;
}

/* The second row of forms («في دعوى قائمة») sits closer to the first than the first to the documents. */
.draft-form-kinds + .draft-form-kinds {
    margin-top: .6rem;
}

.draft-form-kinds-label {
    display: block;
    margin-bottom: .4rem;
    font-size: .82rem;
    color: var(--ink-muted);
}

.draft-form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .5rem;
}

.draft-form-card {
    padding: .6rem .75rem;
}

.draft-form-card .prompt-text {
    font-size: .8rem;
}

/* Wide enough for the cards' own lines; the row's copy is the phone's. */
.draft-form-blurb {
    display: none;
}

/* A short form's plan in the generation bubble: the requests it chose, each tagged with its kind. */
.draft-form-requests {
    margin-top: .5rem;
    font-size: .85rem;
    text-align: start;
}

.draft-form-requests-title {
    color: var(--ink-muted);
    font-size: .82rem;
}

.draft-form-requests ol {
    margin: .25rem 0 0;
    padding-inline-start: 1.4rem;
}

.draft-request-category {
    display: inline-block;
    margin-inline-start: .4rem;
    padding: 0 .4rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: .72rem;
    color: var(--ink-muted);
}

/* «من تمثّل؟»: the wizard's answer chips on the case-type row's measure, so the entry reads as one
   stack of choices under the kind cards. */
.draft-role {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
    margin-top: 1.1rem;
    text-align: start;
    font-size: .9rem;
}

.draft-role-label {
    font-weight: 700;
    color: var(--ink-muted);
}

.draft-role-chips {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
}

/* The longest label («المجني عليه / المدعي بالحق المدني») may wrap on a narrow phone. */
.draft-role-chip {
    height: auto;
    min-height: 36px;
}

.draft-role-mismatch {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
}

.draft-side-choice {
    flex-wrap: wrap;
}

.draft-case-type {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
    margin-top: 1.1rem;
    text-align: start;
    font-size: .9rem;
}

.draft-case-type label {
    font-weight: 700;
    color: var(--ink-muted);
}

.draft-case-type select {
    flex: 1 1 14rem;
    min-width: 0;
    max-width: 100%;
    padding: .4rem .6rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
}

.draft-note {
    margin: .45rem 0 0;
    font-size: .82rem;
    color: var(--ink-muted);
    text-align: start;
}

.draft-note.warn {
    color: #8a6412;
}

.draft-entry-error {
    margin-top: .9rem;
    text-align: start;
}

/* Between the disclaimer and the composer, on the same measure as both. */
.draft-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    width: min(48rem, 100%);
    margin: 0 auto;
    padding-inline: .55rem;
}

.draft-generate-btn {
    border: 0;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-size: .88rem;
    font-weight: 700;
    padding: calc(.3rem + 1.5px) 1rem calc(.3rem - 1.5px); /* see .quiet-btn */
    cursor: pointer;
}

.draft-generate-btn:disabled,
.quiet-btn:disabled,
.danger-btn:disabled {
    opacity: .5;
    cursor: default;
}

/* The interview wizard (InterviewWizard): one question at a time where .draft-actions sits, on the
   same measure. The stage clips the card's entrance so the slide never widens the page on a phone;
   clip rather than hidden, so focusing a field mid-slide cannot scroll the stage itself. */
.wizard-stage {
    overflow: hidden;
    overflow: clip;
}

.wizard-card {
    width: min(48rem, 100%);
    margin: 0 auto .5rem;
    padding: .9rem 1rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    text-align: start;
}

.wizard-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: .75rem;
    font-size: .8rem;
    color: var(--ink-muted);
}

.wizard-count {
    flex: 0 0 auto;
    font-size: 1rem;
    font-weight: 700;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

/* One segment per question of the phase, in reading order: answered filled, skipped dashed, the
   current one ringed, the rest empty. */
.wizard-steps {
    display: flex;
    gap: 3px;
    margin-top: .45rem;
}

.wizard-step {
    flex: 1 1 0;
    min-width: 0;
    height: 6px;
    border-radius: 3px;
    background: var(--line);
}

.wizard-step.answered {
    background: var(--accent);
}

.wizard-step.skipped {
    background: repeating-linear-gradient(90deg, var(--ink-muted) 0 3px, transparent 3px 6px);
    opacity: .55;
}

.wizard-step.current {
    background: var(--accent-soft);
    box-shadow: inset 0 0 0 1.5px var(--accent);
}

/* A card enters from the side the reading moves toward: the next question from the inline end
   (the left in RTL), a previous one from the inline start. Both classes run one animation, so a
   card that only changes class does not replay it. */
.wizard-card.slide-next {
    --wizard-enter: 2rem;
}

.wizard-card.slide-prev {
    --wizard-enter: -2rem;
}

[dir="rtl"] .wizard-card.slide-next {
    --wizard-enter: -2rem;
}

[dir="rtl"] .wizard-card.slide-prev {
    --wizard-enter: 2rem;
}

.wizard-card.slide-next,
.wizard-card.slide-prev {
    animation: wizard-enter 220ms ease-out;
}

@keyframes wizard-enter {
    from {
        opacity: 0;
        transform: translateX(var(--wizard-enter));
    }
}

@keyframes wizard-fade {
    from {
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .wizard-card.slide-next,
    .wizard-card.slide-prev {
        animation-name: wizard-fade;
    }
}

.wizard-question {
    margin: .35rem 0 .7rem;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--ink);
}

.wizard-widget {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
}

.wizard-widget + .wizard-widget {
    margin-top: .5rem;
}

.wizard-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    margin-top: .75rem;
}

.wizard-generate-now {
    margin-inline-start: auto;
}

/* The reminder of skipped core questions (InterviewWizard): under the offer's sentence, set apart by
   a rule; alone in its card above the generate button once nothing is left to ask. */
.wizard-question + .wizard-skipped {
    padding-top: .7rem;
    border-top: 1px solid var(--line);
}

.wizard-skipped-head {
    margin: 0;
    font-size: .9rem;
    font-weight: 700;
    color: var(--ink);
}

.wizard-skipped-list {
    margin: .35rem 0 0;
    padding-inline-start: 1.25rem;
    font-size: .88rem;
    line-height: 1.6;
    color: var(--ink);
    overflow-wrap: anywhere;
}

.wizard-skipped .wizard-actions {
    margin-top: .55rem;
}

/* .country-chip's shape at a tap target's height; the same top-only padding moves the label's ink
   down to the optical centre (see .country-chip). */
.answer-chip {
    height: 36px;
    padding: 3px 1rem 0;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: .9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all .12s ease;
}

/* Hover only where a pointer can hover: a tapped chip keeps :hover on a touch screen. */
@media (hover: hover) {
    .answer-chip:hover {
        border-color: var(--accent);
        color: var(--accent);
    }
}

.answer-chip:active,
.answer-chip.on {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
}

.answer-chip:disabled {
    opacity: .5;
    cursor: default;
}

/* A suggested answer (InterviewWizard) can run to a short sentence: it wraps inside the chip, never
   past the card, and reads lighter than the chips that submit. */
.answer-chip.suggestion {
    height: auto;
    min-height: 36px;
    max-width: 100%;
    padding: 6px 1rem 3px;
    font-weight: 400;
    line-height: 1.45;
    white-space: normal;
    overflow-wrap: anywhere;
}

/* .draft-case-type select's field. */
.wizard-input {
    flex: 1 1 14rem;
    min-width: 0;
    max-width: 100%;
    padding: .4rem .6rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    text-align: start;
}

textarea.wizard-input {
    flex-basis: 100%;
    resize: vertical;
    line-height: 1.6;
}

.wizard-unit {
    flex: 0 1 6rem;
}

/* The date question's three fields, year rightmost (the row is dir="rtl"), each caption under its
   field. The fields shrink before the row would overflow; the year stays the widest. */
.wizard-date {
    display: flex;
    align-items: flex-start;
    gap: .35rem;
    min-width: 0;
    max-width: 100%;
}

.wizard-date-part {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 0 1 3.6rem;
    min-width: 2.4rem;
}

.wizard-date-year {
    flex: 0 1 5.4rem;
    min-width: 3.6rem;
}

.wizard-date-field {
    width: 100%;
    min-width: 0;
    padding: .4rem .3rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.wizard-date-label {
    margin-top: .1rem;
    font-size: .72rem;
    line-height: 1.3;
    color: var(--ink-muted);
}

/* On the field's line, not the caption's: the parts are taller than the fields. */
.wizard-date-sep {
    flex: 0 0 auto;
    padding-top: .45rem;
    color: var(--ink-muted);
}

.wizard-date-pick {
    position: relative;
    flex: 0 0 auto;
    align-self: flex-start;
    margin-top: .3rem;
}

/* The native box the calendar opens from: under the button so the picker anchors there, never
   seen or reached. */
.wizard-date-pick input[type="date"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    opacity: 0;
    pointer-events: none;
}

.wizard-date-invalid {
    flex-basis: 100%;
    margin: 0;
}

/* An interview round's questions and answers under its bubble, collapsed: the transcript's one
   record of them. */
.draft-qa {
    margin-top: .6rem;
    font-size: .86rem;
    color: var(--ink-muted);
    text-align: start;
}

.draft-qa summary {
    cursor: pointer;
}

.draft-qa-list {
    margin: .4rem 0 0;
    padding: 0;
    list-style: none;
}

.draft-qa-row {
    display: flex;
    flex-direction: column;
    gap: .1rem;
    padding: .4rem 0;
    border-top: 1px solid var(--line);
    line-height: 1.55;
}

.draft-qa-a {
    color: var(--ink);
    font-weight: 600;
    overflow-wrap: anywhere;
}

.draft-qa-row.skipped .draft-qa-a,
.draft-qa-row.unanswered .draft-qa-a {
    color: var(--ink-muted);
    font-weight: 400;
}

@media (max-width: 560px) {
    .wizard-card {
        padding: .75rem .8rem;
    }

    .answer-chip {
        flex: 1 1 auto;
    }

    .wizard-input,
    .wizard-unit {
        flex-basis: 100%;
        width: 100%;
    }

    .wizard-date {
        gap: .25rem;
    }
}

.draft-extras:empty {
    display: none;
}

.draft-extras + .content {
    margin-top: .75rem;
}

/* The generation's progress, at the head of the bubble it reports on. Sticky while live so it
   stays in view as the sections pile up below it: the scroller is .message-scroll and nothing
   between it and the panel (.message-column, .message, .bubble) clips, which sticky needs. The
   surface and shadow are for the stuck state, where the text scrolls underneath it. */
.draft-progress {
    margin-bottom: .75rem;
    padding: .6rem .8rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: .9rem;
}

.draft-progress.live {
    position: sticky;
    top: .5rem;
    z-index: 2;
    box-shadow: var(--shadow);
}

.draft-progress-head {
    display: flex;
    align-items: center;
    gap: .55rem;
    color: var(--ink);
    font-weight: 500;
}

.draft-progress-list {
    list-style: none;
    margin: .45rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: .3rem;
}

.draft-progress-item {
    display: flex;
    align-items: center;
    gap: .45rem;
    color: var(--ink-muted);
}

.draft-progress-item.current {
    color: var(--ink);
}

/* One fixed box for the glyph and the dots alike, so the label does not shift when a row's
   mark changes from dots to tick. */
.draft-progress-mark {
    flex: 0 0 1.25rem;
    display: inline-flex;
    justify-content: center;
}

.draft-progress-mark.thinking-dots {
    gap: .12rem;
}

.draft-progress-mark.thinking-dots span {
    width: .32rem;
    height: .32rem;
}

.draft-progress-item.done .draft-progress-mark {
    color: var(--accent);
}

.draft-progress-verb {
    color: var(--ink-muted);
    font-weight: 400;
}

@media (max-width: 560px) {
    .draft-progress {
        padding: .5rem .6rem;
    }
}

/* Over the content column only: positioned against .chat-page, which never scrolls (the
   transcript inside it does) and never spans the sidebar, so the bar stays put at the column's
   top whatever the scroll position, and out of the flow it shifts nothing when it appears. */
.generation-bar {
    position: absolute;
    top: 0;
    inset-inline: 0;
    height: 3px;
    z-index: 40;
    overflow: hidden;
    background: var(--accent-soft);
    pointer-events: none;
}

/* inset-inline-start is the right edge in this RTL page, so the slide runs right to left. */
.generation-bar span {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 30%;
    inset-inline-start: -30%;
    background: var(--accent);
    animation: generation-slide 1.4s linear infinite;
}

@keyframes generation-slide {
    from {
        inset-inline-start: -30%;
    }

    to {
        inset-inline-start: 100%;
    }
}

/* Same rule as .thinking-dots: an indicator, not a freeze. The slide (spatial motion) goes;
   the full-width bar breathes in opacity so it still reads as "in progress". */
@media (prefers-reduced-motion: reduce) {
    .generation-bar span {
        width: 100%;
        inset-inline-start: 0;
        animation: thinking-fade 1.6s ease-in-out infinite;
    }
}

.draft-document {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 1rem 1.1rem;
    min-width: 0;
}

/* What needs the lawyer's action before the draft is used, as sentences; the counts and the
   compliance verdict stay in the report. Amber is the draft notes' warning colour. */
.draft-review-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    padding: .75rem 1rem;
    margin-bottom: 1rem;
}

.draft-review-card.has-items {
    border-color: #e9d9a6;
    background: #fdf6e3;
    color: #6b5312;
}

.draft-review-card.clear {
    border: 0;
    padding: 0;
    background: none;
    font-size: .85rem;
    color: var(--ink-muted);
}

.draft-review-card-title {
    margin: 0 0 .35rem;
    font-size: .85rem;
    font-weight: 700;
}

.draft-review-card ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.draft-review-card li {
    position: relative;
    padding-inline-start: 1.2rem;
    font-size: .9rem;
    line-height: 1.7;
}

.draft-review-card li::before {
    content: "⚠︎";
    position: absolute;
    inset-inline-start: 0;
}

.link-btn {
    border: 0;
    padding: 0;
    background: none;
    font: inherit;
    color: inherit;
    text-align: start;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: .2em;
    cursor: pointer;
}

.link-btn:hover,
.link-btn:focus-visible {
    text-decoration-style: solid;
}

.draft-review-card-more {
    margin-top: .4rem;
    font-size: .85rem;
    font-weight: 700;
}

/* A revision's changed quotations, quoted under their line; they have no appendix entry to link to. */
.draft-review-card .draft-review-quotes {
    margin: .2rem 0 .1rem;
}

.draft-review-card .draft-review-quotes li {
    padding-inline-start: .9rem;
    font-size: .85rem;
    line-height: 1.6;
}

.draft-review-card .draft-review-quotes li::before {
    content: "–";
}

.draft-review-card .draft-review-quotes li.more::before {
    content: none;
}

.draft-review-card-note {
    margin: .4rem 0 0;
    font-size: .8rem;
    opacity: .85;
}

/* The document's version switcher, once there is more than one version: السابقة, the picker,
   التالية and the diff link. Wraps rather than scrolls on a phone. */
.draft-version-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem .5rem;
    margin: 0 0 .75rem;
    font-size: .85rem;
    min-width: 0;
}

.draft-version-bar select {
    min-width: 0;
    max-width: 100%;
    padding: .2rem .4rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
}

.draft-version-bar .draft-diff-link {
    margin-inline-start: .3rem;
}

.draft-version-bar + .draft-note.warn {
    margin: -.4rem 0 .75rem;
}

/* An earlier version is on show: the review card's amber, since what follows is not the draft
   the composer would revise. */
.draft-version-notice {
    border: 1px solid #e9d9a6;
    border-radius: var(--radius);
    background: #fdf6e3;
    color: #6b5312;
    padding: .65rem 1rem;
    margin-bottom: 1rem;
}

.draft-version-notice p {
    margin: 0;
    font-weight: 700;
}

.draft-version-notice-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-top: .5rem;
}

/* An earlier version, where its document was in the transcript: one line, its links at the end. */
.draft-version-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    padding: .55rem .9rem;
    min-width: 0;
}

.draft-version-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .25rem .6rem;
    font-size: .9rem;
}

.draft-version-title {
    font-weight: 700;
}

.draft-version-source,
.draft-version-time {
    font-size: .8rem;
    color: var(--ink-muted);
}

.draft-version-actions {
    display: inline-flex;
    flex-wrap: wrap;
    gap: .9rem;
    margin-inline-start: auto;
    font-size: .85rem;
}

.draft-version-actions .link-btn:disabled {
    opacity: .5;
    cursor: default;
}

/* ---------- draft diff drawer ---------- */

/* RulingViewer's drawer with the two version pickers in its meta row. The diff colours are local
   tokens so the dark block below swaps them in one place; the hues are the status pills'. */
.draft-diff-drawer {
    --diff-ins-bg: #e6f4ea;
    --diff-ins-fg: #1e6b34;
    --diff-ins-edge: #2ea043;
    --diff-del-bg: #fdf2f2;
    --diff-del-fg: #7d2020;
    --diff-del-edge: #d1453b;
}

.draft-diff-pickers {
    align-items: center;
}

.draft-diff-picker {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    min-width: 0;
}

.draft-diff-picker select {
    max-width: 14rem;
    padding: .2rem .4rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
}

.draft-diff-summary {
    margin: 0;
    font-size: .88rem;
    font-weight: 700;
}

.draft-diff-blocks {
    display: flex;
    flex-direction: column;
    gap: .7rem;
    margin-top: .9rem;
}

/* The markdown source as written: pre-wrap keeps its line breaks, plaintext lets each line take
   its own direction as the rendered document's dir="auto" paragraphs do. */
.draft-diff-block {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    unicode-bidi: plaintext;
    font-size: .95rem;
    line-height: 1.9;
    padding-inline-start: .7rem;
    border-inline-start: 3px solid transparent;
}

.draft-diff-block.heading {
    font-weight: 700;
}

.draft-diff-block.insert {
    background: var(--diff-ins-bg);
    color: var(--diff-ins-fg);
    border-inline-start-color: var(--diff-ins-edge);
}

.draft-diff-block.delete {
    background: var(--diff-del-bg);
    color: var(--diff-del-fg);
    border-inline-start-color: var(--diff-del-edge);
    text-decoration: line-through;
}

.draft-diff-block.change {
    border-inline-start-color: var(--line);
}

.draft-diff-block ins {
    background: var(--diff-ins-bg);
    color: var(--diff-ins-fg);
    text-decoration: none;
    border-radius: 3px;
}

.draft-diff-block del {
    background: var(--diff-del-bg);
    color: var(--diff-del-fg);
    border-radius: 3px;
}

.draft-diff-fold {
    align-self: center;
    font-size: .82rem;
    color: var(--ink-muted);
}

/* The review card's jump target, so the eye finds the heading the page scrolled to; a gap note and
   its reference, jumped to from each other, the same way. */
.draft-review.flash,
.draft-review .flash,
.draft-body .flash {
    animation: review-flash 1.2s ease-out;
}

@keyframes review-flash {
    from {
        outline: 2px solid #c48e16;
        outline-offset: 2px;
    }

    to {
        outline: 2px solid transparent;
        outline-offset: 2px;
    }
}

/* Long legal prose, tables and article lists from the API's render must not widen the page. */
.draft-body {
    overflow-wrap: anywhere;
}

/* The engine's standing disclaimer, the blockquote right under the title: on screen the card above
   says what to act on, so it is kept as a footnote. Print keeps it a full quote. */
@media screen {
    .draft-body > h1 + blockquote {
        font-size: .82rem;
        color: var(--ink-muted);
        border: 0;
        padding: 0;
        margin: 0 0 1rem;
    }
}

.draft-body table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
}

/* A citation marker after a quotation (DraftCitations.Decorate). The element holds only the space
   that preceded the marker; the label is drawn from data-label so a selection or a browser copy
   never carries it, and print draws data-print (the formal citation) instead or hides the element,
   space and all. A small muted chip that wraps with the line rather than widening it; the cassation
   variant is a button that opens the ruling. */
.draft-cite::after {
    content: attr(data-label);
    padding: 0 .4em;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--ink-muted);
    font-size: .78em;
    font-weight: 400;
    line-height: 1.6;
    white-space: normal;
    overflow-wrap: anywhere;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
}

/* A button's own leading space collapses (it is an inline block), so the gap is a margin. */
.draft-cite.link {
    display: inline;
    max-width: 100%;
    margin: 0;
    margin-inline-start: .25em;
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    text-align: start;
    cursor: pointer;
}

.draft-cite.link::after {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.draft-cite.link:hover::after {
    border-color: var(--accent);
}

.draft-cite.link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    border-radius: 6px;
}

/* A gap note's reference (DraftGapNotes): the engine's «(لم يُبيَّن: …)» moved to the list closing
   the document. The numbers are generated content (data-n, data-s), like a citation's label, so a
   selection quoted into «عدّل هذا المقطع» does not carry them. Small, tinted, never underlined. */
.gap-ref {
    font-size: .7em;
    font-weight: 600;
    line-height: 0;
    color: var(--accent);
    opacity: .8;
    padding-inline-start: .1em;
    white-space: nowrap;
}

.gap-ref-n::before {
    content: attr(data-n);
}

.gap-ref-sep::before {
    content: attr(data-s);
}

.gap-ref a {
    color: inherit;
    text-decoration: none;
}

.gap-ref:hover {
    opacity: 1;
}

.gap-ref a:focus-visible {
    outline: 1px solid var(--accent);
    outline-offset: 1px;
    border-radius: 2px;
}

/* The notes themselves, numbered in the document's own Arabic-Indic digits. */
.draft-gap-notes ol {
    list-style-type: arabic-indic;
}

.gap-note-back {
    margin-inline-start: .3em;
    color: var(--ink-muted);
    text-decoration: none;
    font-size: .85em;
}

.gap-note-back::before {
    content: "↑";
}

.gap-note-back:hover {
    color: var(--accent);
}

/* «عدّل هذا المقطع» beside a selection in the latest document; chatUi.attachSelectionAction sets
   left/top in viewport pixels. Above the transcript, below the phone sidebar's backdrop (20) and
   everything over it, so an opened panel or drawer covers it. */
.draft-select-action {
    position: fixed;
    z-index: 15;
    white-space: nowrap;
    font-size: .8rem;
    color: var(--ink);
    box-shadow: var(--shadow);
}

.draft-select-action[hidden] {
    display: none;
}

.draft-review {
    margin-top: 1rem;
    border-top: 1px solid var(--line);
    padding-top: .7rem;
}

.draft-review summary {
    cursor: pointer;
    font-size: .88rem;
    font-weight: 700;
    color: var(--ink-muted);
}

.draft-review .content {
    margin-top: .6rem;
    font-size: .92rem;
}

/* A cassation source in the report's sources table (DraftReportSources): the citation itself is the
   link to the ruling, as a tam- chip in the body is. */
.draft-review .draft-report-ruling {
    color: var(--accent);
}

.draft-sources {
    margin-top: 1rem;
    border-top: 1px solid var(--line);
    padding-top: .7rem;
}

.draft-source-list {
    list-style: none;
    margin: .45rem 0 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: .3rem;
}

.draft-source-list code {
    display: inline-block;
    padding: .2rem .45rem;
    border-radius: 6px;
    background: var(--surface-2);
    font-family: var(--font-mono);
    font-size: .78rem;
    color: var(--ink-muted);
}

.draft-source-chip {
    width: auto;
    font-family: var(--font-mono);
    font-weight: 400;
}

.draft-doc-actions {
    flex-wrap: wrap;
    margin-top: 1rem;
}

.confirm-inline {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem;
    font-size: .85rem;
    color: var(--ink-muted);
}

@media (max-width: 560px) {
    .draft-document {
        padding: .8rem .75rem;
    }

    /* The entry screen's kind cards, select and composer have to share a phone's height; the
       cards already say what the subtitle says. */
    .draft-page .hero-subtitle {
        display: none;
    }

    .draft-kind-card {
        padding: .6rem .8rem;
    }

    /* A third of a phone holds a title, not a sentence: the picked form's line follows the row. */
    .draft-form-card {
        padding: .55rem .6rem;
        justify-content: center;
    }

    .draft-form-card .prompt-text {
        display: none;
    }

    .draft-form-blurb {
        display: block;
    }
}

/* ---------- draft split pane ---------- */

/* Below the pane's width both wrappers drop out of the box tree, so the transcript, the scope row
   and the composer are .chat-page's own flex children exactly as on every other page. The width is
   DraftPane.WideQuery; the page sets has-pane only when it also draws the pane. */
.draft-workspace,
.draft-transcript {
    display: contents;
}

.draft-pane-marker {
    margin: 0;
    font-size: .85rem;
    color: var(--ink-muted);
}

/* Screen only: a landscape sheet can be wider than the breakpoint, and the pane's scroller would
   clip the document on paper. Two columns, each its own scroller — not sticky, since the shell is a
   viewport-tall box with overflow hidden and nothing outside the columns scrolls. */
@media screen and (min-width: 1100px) {
    .draft-page.has-pane .draft-workspace {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        grid-template-rows: minmax(0, 1fr);
        flex: 1 1 auto;
        min-height: 0;
    }

    .draft-page.has-pane .draft-transcript {
        display: flex;
        flex-direction: column;
        min-height: 0;
        min-width: 0;
    }

    /* The scroll padding matches the top padding, so scrolling the document into view (a card's
       عرض) lands the pane at its top rather than one padding below it. */
    .draft-page.has-pane .draft-pane {
        min-width: 0;
        overflow-y: auto;
        padding: 1.5rem 1.25rem 2rem;
        scroll-padding-block-start: 1.5rem;
        border-inline-start: 1px solid var(--line);
    }

    .draft-page.has-pane .draft-pane > .draft-document {
        max-width: 48rem;
        margin-inline: auto;
    }
}

/* ---------- draft attachments ---------- */

/* Inside the composer box (.composer-attachments), compact so a chip row does not take the text's
   room. An Arabic label in a pill: the 1.5px top-for-bottom shift of .quiet-btn, for the same reason
   (Tajawal's ascenders rise far above the letter bodies, nothing dips below). */
.attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    max-width: 100%;
    height: 28px;
    padding: 1.5px .2rem 0 .55rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--bg);
    color: var(--ink);
    font-size: .76rem;
}

.attachment-icon {
    flex: none;
    color: var(--accent);
}

.attachment-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 16rem;
    font-weight: 700;
}

.attachment-meta {
    flex: none;
    color: var(--ink-muted);
    font-size: .7rem;
}

.attachment-chip.unavailable {
    border-style: dashed;
    color: var(--ink-muted);
}

.attachment-chip.unavailable .attachment-icon {
    color: var(--ink-muted);
}

.attachment-chip.unavailable .attachment-name {
    text-decoration: line-through;
}

.attachment-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 22px;
    height: 22px;
    margin-top: -1.5px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--ink-muted);
    cursor: pointer;
}

.attachment-remove:hover {
    background: rgba(127, 127, 127, .18);
    color: var(--ink);
}

/* Its own line under the chips; shown only once half the budget is spent. */
.draft-budget {
    flex: 1 0 100%;
    display: flex;
    align-items: center;
    gap: .6rem;
    font-size: .72rem;
    color: var(--ink-muted);
}

.draft-budget-bar {
    flex: 1 1 auto;
    max-width: 12rem;
    height: 4px;
    border-radius: 999px;
    background: var(--line);
    overflow: hidden;
}

.draft-budget-bar > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
}

.draft-budget.danger .draft-budget-bar > span {
    background: var(--danger);
}

.draft-budget.danger .draft-budget-text {
    color: var(--danger);
}

/* ---------- document picker ---------- */

/* The delete dialog, wider, with the list scrolling inside so the actions stay in view. */
.confirm-dialog.picker-dialog {
    display: flex;
    flex-direction: column;
    width: min(34rem, calc(100% - 2rem));
    max-height: 85dvh;
}

.picker-list {
    flex: 1 1 auto;
    min-height: 4rem;
    overflow-y: auto;
    margin-block-end: .6rem;
    border: 1px solid var(--line);
    border-radius: 10px;
}

.picker-list > .draft-note {
    margin: .8rem;
}

.picker-row {
    display: flex;
    align-items: center;
    gap: .6rem;
    min-height: 44px;
    padding: .4rem .75rem;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
}

.picker-row:last-of-type {
    border-bottom: 0;
}

.picker-row.disabled {
    cursor: default;
    opacity: .6;
}

.picker-row input {
    flex: none;
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--accent);
}

.picker-row-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.45;
}

.picker-row-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .9rem;
    font-weight: 700;
}

.picker-row-meta {
    font-size: .76rem;
    color: var(--ink-muted);
}

.picker-row-hint {
    color: var(--danger);
}

.picker-more {
    display: block;
    margin: .5rem auto;
}

.picker-total {
    margin: 0 0 .6rem;
    font-size: .8rem;
    color: var(--ink-muted);
}

.picker-upload {
    margin-block-end: .8rem;
}

.picker-upload-title {
    margin: 0 0 .35rem;
    font-size: .85rem;
    font-weight: 700;
}

.picker-dialog .message-error {
    margin-block-end: .8rem;
}

@media (max-width: 560px) {
    .confirm-dialog.picker-dialog {
        inset-inline: 16px;
        width: calc(100% - 32px);
        padding: 1.1rem 1rem 1rem;
    }

    .attachment-name {
        max-width: 10rem;
    }
}

@media (prefers-color-scheme: dark) {
    /* --danger is a fill colour; as text on the dark page it is too dim (as for .row-menu-item). */
    .draft-budget.danger .draft-budget-text,
    .picker-row-hint {
        color: #f47c82;
    }
}

/* ---------- reconnect ---------- */

/* Blazor's reconnect states, on the element App.razor provides (see the comment there). Hidden
   until the framework adds a state class; above the sidebar (30) and the drawer (40). The
   framework's own dialog set its text in a colour that vanished on this theme and spoke English
   (2026-10-17). */
.reconnect {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 60;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(10, 12, 16, .55);
}

.reconnect.components-reconnect-show,
.reconnect.components-reconnect-failed,
.reconnect.components-reconnect-rejected {
    display: flex;
}

.reconnect-card {
    width: min(22rem, 100%);
    padding: 1.4rem 1.5rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow);
    text-align: center;
}

.reconnect-state {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
}

.components-reconnect-show .reconnect-rejoining,
.components-reconnect-failed .reconnect-failed,
.components-reconnect-rejected .reconnect-rejected {
    display: flex;
}

.reconnect-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--ink);
}

.reconnect-detail {
    margin: 0;
    font-size: .88rem;
    color: var(--ink-muted);
}

.reconnect-btn {
    margin-top: .5rem;
    border: 0;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-size: .9rem;
    font-weight: 700;
    padding: calc(.4rem + 1.5px) 1.2rem calc(.4rem - 1.5px); /* see .quiet-btn */
    cursor: pointer;
}

.reconnect-spinner {
    width: 2rem;
    height: 2rem;
    margin-bottom: .25rem;
    border: 3px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: reconnect-spin .9s linear infinite;
}

@keyframes reconnect-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Reduced motion (Windows "animation effects off" lands every user here): the ring stops
   rotating and breathes in opacity instead. A frozen ring was reported as a stuck reconnect. */
@media (prefers-reduced-motion: reduce) {
    .reconnect-spinner {
        animation: thinking-fade 1.6s ease-in-out infinite;
    }
}

/* ---------- dark ---------- */

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1115;
        --surface: #171a20;
        --surface-2: #1e2229;
        --sidebar-bg: #0a0c10;
        --sidebar-fg: #e7e9ee;
        --sidebar-muted: #9aa1ad;
        --sidebar-line: rgba(255, 255, 255, .14);
        --sidebar-hover: rgba(255, 255, 255, .08);
        --sidebar-selected: rgba(255, 255, 255, .16);
        --sidebar-field: #0c0e12;
        --ink: #e7e9ee;
        --ink-muted: #a2a9b6;
        --line: #262b34;
        --accent: #5b9dff;
        --accent-soft: #16233a;
        /* Desaturated against the dark page: the light theme's saturated accent glows here, and
           the reference's own dark bubble is this muted slate blue. */
        --user-bubble-bg: #33507e;
        --user-bubble-fg: #eef2f8;
        --shadow: 0 1px 2px rgba(0, 0, 0, .4);
        --segment-track: rgba(255, 255, 255, .06);
        --segment-hover: rgba(255, 255, 255, .05);
        --segment-active: #4a5263;
        --segment-active-shadow: none;
    }

    .banner {
        background: #2a2412;
        border-color: #4a3d17;
        color: #e8d6a3;
    }

    .message-error {
        background: #2a1618;
        border-color: #4d2528;
        color: #f0b9bc;
    }

    .composer {
        background: linear-gradient(to top, var(--bg) 65%, rgba(15, 17, 21, 0));
    }

    .draft-note.warn {
        color: #e8d6a3;
    }

    .draft-diff-drawer {
        --diff-ins-bg: #142a1a;
        --diff-ins-fg: #a6e3b3;
        --diff-ins-edge: #2f7d43;
        --diff-del-bg: #2a1618;
        --diff-del-fg: #f0b9bc;
        --diff-del-edge: #9c3a40;
    }

    .draft-review-card.has-items,
    .draft-version-notice {
        border-color: #4a3f1e;
        background: #2a2412;
        color: #e8d6a3;
    }

    .badge.badge-eg,
    .chip.chip-eg {
        border-color: #4a3f1e;
        background: #2a2412;
        color: #e8d6a3;
    }

    .chip.chip-eg.open {
        background: #e8d6a3;
        border-color: #e8d6a3;
        color: #2a2412;
    }

    .legal-eg-note {
        color: #e8d6a3;
    }

    /* A yellow that works on white is invisible against the dark surface. Kept as an amber wash
       rather than the accent blue: blue is the citation marker's colour in this app, and a blue
       highlight over legal prose would read as a link. */
    .drawer-text mark {
        background: rgba(196, 142, 22, .35);
        color: inherit;
    }

    .drawer-text mark.focus {
        background: rgba(230, 168, 30, .55);
        box-shadow: 0 0 0 2px rgba(230, 168, 30, .3);
    }

    /* --danger is a fill colour for white labels; as text on the dark popover it is too dim. */
    .row-menu-item.danger {
        color: #f47c82;
    }
}

/* ---------- print ---------- */

/* Last in the file on purpose. The dark palette above is a media query of the same weight, so the
   light values re-asserted here win only by coming after it — a reader whose machine is in dark
   mode would otherwise print pale text and dim highlights onto white paper.

   Two layouts share one block: with no class on the body it is the transcript, and body.print-ruling
   flips it to the drawer. chatUi.printPage sets the class for the duration of the print call. */

@media print {
    :root {
        --bg: #f7f7f8;
        --surface: #ffffff;
        --surface-2: #f1f2f4;
        --sidebar-bg: #14161a;
        --ink: #16181d;
        --ink-muted: #5c6270;
        --line: #e2e4e9;
        --accent: #1f6feb;
        --accent-soft: #e8f0fe;
        /* Paper drops backgrounds, so the bubble goes dark-on-white and gets its border back. */
        --user-bubble-bg: #ffffff;
        --user-bubble-fg: #16181d;
        --user-bubble-line: #e2e4e9;
        --shadow: 0 1px 2px rgba(16, 18, 22, .06), 0 8px 24px rgba(16, 18, 22, .06);
    }

    /* The three component rules the dark block overrides outside the token set. Same reasoning as
       the palette: they are equal-specificity media rules and only order settles them. */
    .message-error {
        border-color: #f0c2c2;
        background: #fdf2f2;
        color: #7d2020;
    }

    .drawer-text mark {
        background: rgba(255, 214, 102, .45);
    }

    .drawer-text mark.focus {
        background: rgba(255, 190, 40, .75);
        box-shadow: 0 0 0 2px rgba(255, 190, 40, .35);
    }

    body {
        background: #fff;
    }

    /* Navigation, controls, and the two indicators that only mean something while an answer is
       still arriving. The drawer goes with them and is restored below: the transcript is what a
       classless print produces. */
    .chat-sidebar,
    .chat-topbar,
    .chat-backdrop,
    .banner,
    .country-scope,
    .composer,
    .message-actions,
    .citation-actions,
    .thinking,
    .cursor,
    .generation-bar,
    .draft-select-action,
    .draft-pane-marker,
    .drawer-layer {
        display: none !important;
    }

    /* The sources swap forms on paper: the chips are clicks and the card is one passage at a
       time, so both go, and the references list — hidden on screen — stands in for them with
       every [n] resolvable. The list keeps the light palette's line colour by token, since the
       print block re-asserts it above. */
    .chips,
    .citation-card {
        display: none !important;
    }

    .citations-print {
        display: block;
        margin: .5rem 0 0;
        padding-inline-start: 1.4rem;
        font-size: .82rem;
        line-height: 1.7;
    }

    .citations-print li {
        break-inside: avoid;
        margin: .15rem 0;
    }

    /* On screen the shell is a viewport-tall flexbox whose transcript is an inner scroller, which
       prints as one page holding whatever happened to be in view. Releasing the whole chain turns
       the conversation back into ordinary flowing content the printer can paginate. */
    html,
    body,
    .chat-shell,
    .chat-main,
    .chat-page {
        display: block;
        height: auto;
        min-height: 0;
        overflow: visible;
    }

    .message-scroll {
        overflow: visible;
    }

    /* Goes the way .citation-actions does. It tells a reader working in the app why these
       particular passages came back, so the next question can be retyped; a printed transcript is
       read away from the app by someone who cannot act on it. */
    .literal-search-note {
        display: none !important;
    }

    /* The reading measure exists to keep a line short on a wide screen; paper already has margins. */
    .message-column {
        width: auto;
        padding: 0;
    }

    /* Only the small atomic blocks. An assistant answer runs to several pages and must be allowed
       to break, so nothing here targets .message or .bubble generally. */
    .message.user {
        break-inside: avoid;
    }

    /* Browsers drop backgrounds when printing, and in these two the background *is* the meaning:
       which passage was highlighted, and which section a card quotes. */
    mark,
    .badge {
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    /* The drawer prints alone. It cannot be isolated by hiding .chat-shell — the drawer renders
       inside .chat-page, so the shell is its ancestor and hiding it takes the drawer too — so the
       transcript's own surfaces are hidden instead and the panel is flattened into the page flow. */
    body.print-ruling .message-scroll,
    body.print-ruling .empty-state {
        display: none !important;
    }

    body.print-ruling .drawer-layer {
        display: block !important;
        position: static;
    }

    body.print-ruling .drawer-backdrop {
        display: none;
    }

    body.print-ruling .drawer {
        position: static;
        display: block;
        width: auto;
        height: auto;
        border: 0;
        box-shadow: none;
    }

    body.print-ruling .drawer-body {
        overflow: visible;
    }

    /* Every one of them: the close control, the back control, and the print control that started
       this. Written against the class rather than against each button, so a control added to the
       header is off the printed page by default. */
    body.print-ruling .drawer-head .icon-btn {
        display: none;
    }

    /* The header block only. A section is the ruling's body text and is expected to run for pages;
       forcing it whole would leave most of every sheet blank. */
    body.print-ruling .drawer-meta {
        break-inside: avoid;
    }

    /* Navigation, and it goes the way .citation-actions does above: a printed judgment ends at the
       ruling's own text. Rulings that merely cite the same statutes are not part of it, and on
       paper the panel's buttons lead nowhere. */
    body.print-ruling .drawer-similar {
        display: none !important;
    }

    /* A draft's citation markers: paper gets the formal citation of a ruling, principle or statute
       (data-print, the same text copy and download write) as plain text where the chip was, and
       nothing for an internal document — that element, and the space it holds, is hidden. Not
       scoped to print-draft: the browser's own print of the page must not carry the chips either. */
    .draft-cite:not([data-print]) {
        display: none !important;
    }

    .draft-cite[data-print] {
        display: inline;
        cursor: auto;
    }

    /* A button never breaks across lines, so a citation longer than what is left of the line would
       jump whole to the next; without its box the citation flows and wraps as the sentence does.
       The space the button holds goes with the box, so the citation carries its own. */
    .draft-cite.link[data-print] {
        display: contents;
    }

    .draft-cite.link[data-print]::after {
        content: " " attr(data-print);
    }

    /* A gap reference prints as a plain superscript number; the way back from a note leads nowhere on paper. */
    .gap-ref {
        color: inherit;
        opacity: 1;
    }

    .gap-note-back {
        display: none;
    }

    .draft-cite[data-print]::after {
        content: attr(data-print);
        padding: 0;
        border: 0;
        border-radius: 0;
        background: none;
        color: inherit;
        font-size: inherit;
        font-weight: inherit;
        line-height: inherit;
        text-decoration: none;
    }

    /* The finished draft prints alone, the way print-ruling isolates the drawer: every message
       but the one holding the document goes, and inside it only the document body survives —
       the review card, the report, the sources and the buttons are the reader's, not the court's. */
    body.print-draft .message:not(:has(.draft-document)),
    body.print-draft .draft-review-card,
    body.print-draft .draft-version-bar,
    body.print-draft .draft-version-bar + .draft-note,
    body.print-draft .draft-version-notice,
    body.print-draft .draft-review,
    body.print-draft .draft-sources,
    body.print-draft .draft-doc-actions,
    body.print-draft .draft-select-action,
    body.print-draft .draft-diff-layer {
        display: none !important;
    }

    body.print-draft .draft-document {
        border: 0;
        padding: 0;
    }

    /* One .draft-document exists at any time: inline in its bubble on a narrow screen, in the pane
       beside the transcript on a wide one (Draft.razor never draws both). So the :has() rule above
       hides every message when the document is in the pane, and the pane — still in the DOM, since
       the print width does not re-render the page — is flattened into the flow and prints alone. */
    body.print-draft .draft-workspace,
    body.print-draft .draft-transcript {
        display: block;
    }

    body.print-draft .draft-pane {
        overflow: visible;
        height: auto;
        border: 0;
        padding: 0;
    }

    body.print-draft .draft-pane > .draft-document {
        max-width: none;
    }
}

/* ---------- document-grounded conversation ---------- */

/* Takes the scope rows' place and measure: a document thread has one source and no scope. */
.document-scope-row {
    display: flex;
    width: min(48rem, 100%);
    margin: 0 auto;
    padding-inline: .55rem;
}

/* Styled as the topic chip because it is the same kind of fact — what the next answer draws on —
   but a link rather than a dismissible pin. */
.document-chip {
    display: inline-block;
    max-width: 100%;
    line-height: 24px;
    padding-inline: .7rem;
    border: 1px solid var(--accent);
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: .78rem;
    font-weight: 700;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.document-chip:hover {
    text-decoration: underline;
}

.document-empty-hint {
    color: var(--ink-muted);
    text-align: center;
}

/* ---------- documents ---------- */

/* Uploaded and processing are both "not ready yet": the drafting pill's amber. */
.status-pill.status-uploaded,
.status-pill.status-processing {
    background: rgba(230, 168, 30, .22);
    color: #f3d38a;
}

.list-sentinel {
    block-size: 1px;
}

/* The page scrolls as a whole: the image pane runs as long as the page image, and the text pane
   beside it stays in view (sticky) while it does. */
.documents-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 1.25rem 16px 2rem;
}

.documents-entry,
.documents-missing {
    width: min(40rem, 100%);
    margin: 2rem auto 0;
    text-align: center;
}

.documents-missing .quiet-btn {
    display: inline-block;
    text-decoration: none;
}

.document-drop {
    border: 2px dashed var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    transition: border-color .12s ease, background .12s ease;
}

.document-drop:hover,
.document-drop:focus-within,
.document-drop.dragging {
    border-color: var(--accent);
}

.document-drop.dragging {
    background: var(--accent-soft);
}

.document-drop.busy {
    border-style: solid;
    border-color: var(--line);
}

.document-drop-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
    margin: 0;
    padding: 2rem 1rem;
    cursor: pointer;
}

.document-drop.busy .document-drop-label {
    cursor: progress;
}

.document-drop-icon {
    color: var(--accent);
}

.document-drop-title {
    font-weight: 700;
}

.document-drop-hint,
.document-drop-file {
    font-size: .85rem;
    color: var(--ink-muted);
}

.document-drop-file {
    max-inline-size: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.document-drop-btn {
    margin-block-start: .25rem;
}

.document-upload-error {
    margin-block-start: .9rem;
    text-align: start;
}

.document-usage {
    display: flex;
    flex-direction: column;
    gap: .4rem;
    margin-block-start: 1.25rem;
    font-size: .88rem;
    color: var(--ink-muted);
}

.document-usage-bar {
    block-size: 6px;
    border-radius: 999px;
    background: var(--surface-2);
    overflow: hidden;
}

.document-usage-bar > span {
    display: block;
    block-size: 100%;
    background: var(--accent);
    border-radius: inherit;
}

.documents-status {
    width: min(48rem, 100%);
    margin: 1rem auto 0;
}

.document-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem 1rem;
    margin-block-end: .75rem;
}

.document-title {
    margin: 0;
    min-width: 0;
    font-size: 1.25rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.document-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    font-size: .82rem;
    color: var(--ink-muted);
}

/* The sidebar's pills are tuned to its dark background; on the page they need light washes. */
.documents-scroll .status-pill {
    background: var(--surface-2);
    color: var(--ink-muted);
}

.documents-scroll .status-pill.status-done {
    background: #e6f4ea;
    color: #1e6b34;
}

.documents-scroll .status-pill.status-failed {
    background: #fdf2f2;
    color: #7d2020;
}

.documents-scroll .status-pill.status-uploaded,
.documents-scroll .status-pill.status-processing {
    background: #fdf6e3;
    color: #6b5312;
}

.document-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    margin-block-end: 1rem;
}

.document-actions a.quiet-btn {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.document-action-error {
    margin-block-end: 1rem;
}

.document-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}

.document-image-pane {
    display: flex;
    flex-direction: column;
    gap: .6rem;
    min-width: 0;
    outline: none;
}

.document-image-pane:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 4px;
    border-radius: 8px;
}

.document-pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
}

.document-pager-label {
    font-size: .88rem;
    color: var(--ink-muted);
}

/* ltr because what sits inside is geometry: the overlay's x runs from the image's left edge
   whatever the page's direction. White under the image so a transparent PNG reads as paper. */
.document-page-frame {
    position: relative;
    direction: ltr;
    line-height: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    box-shadow: var(--shadow);
}

.document-page-image {
    display: block;
    inline-size: 100%;
    block-size: auto;
}

.document-overlay {
    position: absolute;
    inset: 0;
    inline-size: 100%;
    block-size: 100%;
}

/* The viewBox is stretched to the image, so a stroke in its units would be a hair one way and a
   bar the other; non-scaling-stroke keeps it one CSS pixel. Transparent, not none, so the rect
   still takes the pointer. */
.ocr-box {
    fill: transparent;
    stroke: rgba(31, 111, 235, .3);
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
    pointer-events: all;
    cursor: pointer;
}

.ocr-box.hovered {
    fill: rgba(31, 111, 235, .12);
    stroke: var(--accent);
}

.ocr-box.selected {
    fill: rgba(230, 168, 30, .22);
    stroke: #c48e16;
    stroke-width: 2;
}

.document-text-host {
    position: sticky;
    top: 0;
    min-width: 0;
}

.document-text-pane {
    display: flex;
    flex-direction: column;
    max-block-size: calc(100dvh - 3rem - var(--topbar-height));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
}

.document-tabs {
    display: flex;
    gap: .25rem;
    padding: .4rem;
    border-block-end: 1px solid var(--line);
    background: var(--surface-2);
}

.document-tab {
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--ink-muted);
    font: inherit;
    font-size: .88rem;
    font-weight: 700;
    padding: .2rem .9rem;
    cursor: pointer;
}

.document-tab.on {
    background: var(--surface);
    color: var(--accent);
    box-shadow: var(--shadow);
}

.document-text,
.document-markdown {
    min-block-size: 0;
    overflow-y: auto;
    padding: .75rem 1rem 1rem;
    overflow-wrap: anywhere;
}

.document-text-page {
    font-size: .78rem;
    font-weight: 700;
    color: var(--ink-muted);
}

.document-text-empty {
    color: var(--ink-muted);
}

.ocr-paragraph {
    margin: .35rem 0;
    padding: .2rem .5rem;
    border-radius: 6px;
    border-inline-start: 3px solid transparent;
}

.ocr-paragraph.paired {
    cursor: pointer;
}

.ocr-paragraph.hovered {
    background: var(--accent-soft);
    border-inline-start-color: var(--accent);
}

.ocr-paragraph.selected {
    background: rgba(230, 168, 30, .18);
    border-inline-start-color: #c48e16;
}

@media (max-width: 900px) {
    .document-workspace {
        grid-template-columns: minmax(0, 1fr);
    }

    .document-text-host {
        position: static;
    }

    .document-text-pane {
        max-block-size: 70vh;
    }
}

@media (prefers-color-scheme: dark) {
    .documents-scroll .status-pill.status-done {
        background: #142a1a;
        color: #a6e3b3;
    }

    .documents-scroll .status-pill.status-failed {
        background: #2a1618;
        color: #f0b9bc;
    }

    .documents-scroll .status-pill.status-uploaded,
    .documents-scroll .status-pill.status-processing {
        background: #2a2412;
        color: #e8d6a3;
    }

    .ocr-paragraph.selected {
        background: rgba(230, 168, 30, .2);
    }
}

/* On a document's page the status sits under the header, aligned with it rather than centred. */
.document-head ~ .documents-status {
    margin-inline: 0;
}
