/* Theme-aware policy text blocks */
.policy-text-block {
    white-space: pre-wrap;
    word-break: break-word;
}

.policy-rfc-plain {
    font-family: var(--bs-font-monospace);
    font-size: 0.9rem;
    line-height: 1.45;
}

.navbar-quorum {
    border-bottom: 1px solid var(--bs-border-color);
}

.user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--bs-primary);
    color: var(--bs-white);
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

.notification-bell-btn {
    width: 2rem;
    height: 2rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--bs-body-color);
}

.notification-bell-btn:hover,
.notification-bell-btn:focus {
    background-color: var(--bs-tertiary-bg);
    color: var(--bs-body-color);
}

.notification-bell-icon {
    display: block;
}

.notification-bell-badge {
    font-size: 0.65rem;
    min-width: 1.1rem;
}

.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-block;
}

.htmx-request.htmx-indicator {
    display: inline-block;
}

#theme-toggle {
    min-width: 5.5rem;
}

.section-intro {
    max-width: 42rem;
    line-height: 1.5;
}

.diff-block {
    white-space: pre-wrap;
    word-break: break-word;
    font-family: var(--bs-font-monospace);
    font-size: 0.8125rem;
    line-height: 1.45;
    max-height: 16rem;
    overflow: auto;
}

.diff-line {
    display: block;
}

.diff-line-added {
    background: rgba(25, 135, 84, 0.18);
}

.diff-line-removed {
    background: rgba(220, 53, 69, 0.18);
}

.diff-line-context {
    color: var(--bs-secondary-color);
}

/* Loosen Bootstrap's fixed container caps so content uses more of the viewport. */
@media (min-width: 992px) {
    .container {
        max-width: min(94vw, 1800px);
    }
}

@media (min-width: 1200px) {
    .container {
        max-width: min(94vw, 2200px);
    }
}

@media (min-width: 1920px) {
    .container {
        max-width: min(96vw, 3400px);
    }
}

.auto-resize-textarea {
    resize: none;
    overflow-y: hidden;
}

#planning-workspace {
    min-height: 28rem;
}

#planning-workspace > [class*="col-"] {
    display: flex;
    flex-direction: column;
}

#advisor-workspace {
    min-height: 28rem;
}

#advisor-workspace > [class*="col-"] {
    display: flex;
    flex-direction: column;
}

#advisor-chat {
    flex: 1 1 auto;
    min-height: 0;
}

.planning-chat-card {
    display: flex;
    flex-direction: column;
}

.planning-chat-body {
    display: flex;
    flex-direction: column;
}

.planning-messages-scroll {
    overflow-y: auto;
    overscroll-behavior: contain;
    min-height: 16rem;
    max-height: min(32rem, 50vh);
}

.ai-thinking-preview {
    max-height: 10rem;
    overflow-y: auto;
}

.ai-thinking-text {
    max-height: 8rem;
    overflow-y: auto;
}

.planning-chat-footer {
    flex: 0 0 auto;
    border-top: 1px solid var(--bs-border-color-translucent);
    background: var(--bs-body-bg);
}

#record-relationships-panel .relationship-add-input-group {
    flex-wrap: nowrap;
}

#record-relationships-panel .relationship-type-select {
    max-width: 8.5rem;
    min-width: 7rem;
}

#record-relationships-panel .relationship-rationale-input {
    min-width: 0;
}

#record-relationships-panel .relationship-add-form {
    overflow-x: auto;
}

.draft-submit-gate-callout {
    border-left: 3px solid var(--bs-secondary);
}

#draft-submit-button:disabled {
    cursor: not-allowed;
}

#draft-section-editor .section-drag-handle,
#draft-section-editor .subsection-drag-handle {
    cursor: grab;
    user-select: none;
    line-height: 1;
}

#draft-section-editor .section-editor-item.section-dragging,
#draft-section-editor .subsection-editor-item.section-dragging {
    opacity: 0.65;
}

#draft-section-editor .section-editor-item.section-drag-over,
#draft-section-editor .subsection-editor-item.section-drag-over {
    outline: 2px dashed var(--bs-primary);
    outline-offset: -2px;
}

#draft-section-editor .subsection-accordion {
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    padding: 0.25rem;
    background: var(--bs-body-bg);
}

#draft-section-editor .subsection-accordion .accordion-item {
    border: 0;
}

#draft-section-editor .subsection-accordion .accordion-header {
    flex-wrap: nowrap;
}

.draft-preview-ast .draft-preview-body p {
    white-space: pre-line;
}

#draft-section-editor .accordion-button {
    min-width: 0;
}

#draft-section-editor .section-reorder-controls .btn {
    min-width: 2rem;
}

#draft-section-editor .section-remove-btn {
    min-width: 2rem;
}

.draft-preview-ast .record-metadata-table th {
    width: 38%;
    font-weight: 600;
}

.draft-preview-ast .record-metadata-table td {
    word-break: break-word;
}

.draft-preview-ast .draft-preview-title {
    font-size: 1.15rem;
    margin-bottom: 0.75rem;
}

.draft-preview-ast .policy-body > :last-child {
    margin-bottom: 0;
}

.draft-preview-ast .normative-keyword {
    font-weight: 700;
}

.draft-preview-ast .policy-definition {
    font-style: normal;
    font-weight: 600;
}

.draft-preview-ast .policy-rationale {
    color: var(--bs-secondary-color);
}

.draft-preview-ast .policy-consequence {
    color: var(--bs-info);
}

.draft-preview-ast .policy-exception {
    border-bottom: 1px dotted var(--bs-warning);
}

.draft-preview-ast .policy-source-ref {
    font-variant: small-caps;
}

.draft-preview-ast .policy-amendment {
    font-weight: 600;
    text-decoration: underline;
    text-decoration-style: dotted;
}

.draft-preview-ast .policy-citation {
    font-weight: 600;
}

.draft-preview-ast .policy-link {
    word-break: break-all;
}

body.command-palette-open {
    overflow: hidden;
}

.command-palette {
    position: fixed;
    inset: 0;
    z-index: 1080;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 4.5rem 1rem 1rem;
}

.command-palette[hidden] {
    display: none;
}

.command-palette-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
}

.command-palette-dialog {
    position: relative;
    width: min(640px, 100%);
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.75rem;
    box-shadow: 0 1rem 2.5rem rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

.command-palette-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--bs-border-color);
}

.command-palette-search-icon {
    flex-shrink: 0;
    color: var(--bs-secondary-color);
}

.command-palette-input {
    flex: 1;
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 1rem;
    outline: none;
}

.command-palette-input::placeholder {
    color: var(--bs-secondary-color);
}

.command-palette-results {
    max-height: 320px;
    overflow-y: auto;
}

.command-palette-result {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.5rem 0.75rem;
    align-items: center;
    padding: 0.65rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--bs-border-color-translucent);
}

.command-palette-result:last-child {
    border-bottom: 0;
}

.command-palette-result.is-active,
.command-palette-result:hover {
    background: var(--bs-tertiary-bg);
}

.command-palette-result-identifier {
    font-weight: 600;
    font-family: var(--bs-font-monospace);
    font-size: 0.85rem;
}

.command-palette-result-title {
    color: var(--bs-body-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.command-palette-result-badge {
    font-size: 0.65rem;
    text-transform: capitalize;
}

.command-palette-empty {
    padding: 1rem;
}

.command-palette-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: center;
    padding: 0.65rem 1rem;
    border-top: 1px solid var(--bs-border-color);
    background: var(--bs-tertiary-bg);
}

.command-palette-footer-hints {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.command-palette-footer-hints kbd {
    font-size: 0.7rem;
    padding: 0.1rem 0.35rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.25rem;
    background: var(--bs-body-bg);
}

/* Dark theme overrides for Bootstrap light utility classes */
[data-bs-theme="dark"] .table-light,
[data-bs-theme="dark"] .table-light > tr > th,
[data-bs-theme="dark"] .table-light > tr > td,
[data-bs-theme="dark"] .table-light > th,
[data-bs-theme="dark"] .table-light > td {
    --bs-table-color: var(--bs-body-color);
    --bs-table-bg: var(--bs-tertiary-bg);
    --bs-table-border-color: var(--bs-border-color-translucent);
    --bs-table-striped-bg: var(--bs-tertiary-bg);
    --bs-table-striped-color: var(--bs-body-color);
    --bs-table-active-bg: var(--bs-secondary-bg);
    --bs-table-active-color: var(--bs-body-color);
    --bs-table-hover-bg: var(--bs-secondary-bg);
    --bs-table-hover-color: var(--bs-body-color);
    color: var(--bs-body-color) !important;
    background-color: var(--bs-tertiary-bg) !important;
    border-color: var(--bs-border-color-translucent);
}

[data-bs-theme="dark"] .bg-light {
    background-color: var(--bs-tertiary-bg) !important;
    color: var(--bs-body-color) !important;
}

[data-bs-theme="dark"] .text-bg-light {
    background-color: var(--bs-tertiary-bg) !important;
    color: var(--bs-body-color) !important;
    border-color: var(--bs-border-color) !important;
}

