/* ====================================================================
   Checklist 3D Viewer Shell — Narrow-Panel Styles
   viewer3d.css
   ====================================================================
   This stylesheet is loaded globally by App.razor for all routes.
   Styles are scoped to .v3d-* and .checklist-viewer3d-* prefixes so
   they do not interfere with the main checklist layout.
   ==================================================================== */

/* ── Layout shell ──────────────────────────────────────────────────── */

.v3d-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background: var(--color-background, #f3f5f7);
}

/* ── Narrow panel (fixed width within the TC iframe panel) ─────────── */

.v3d-panel {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--color-white, #fff);
}

/* ── Sticky header ─────────────────────────────────────────────────── */

.v3d-header {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 12px 6px;
    background: var(--color-white, #fff);
    border-bottom: 1px solid var(--color-border-subtle, #e0e0e0);
    z-index: 10;
}

.v3d-header-row1 {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.v3d-header-title {
    flex: 1 1 0;
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--color-text-primary, #1a1a1a);
    margin: 0;
}

.v3d-header-row2 {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

/* ── Status chip ───────────────────────────────────────────────────── */

.v3d-status-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

.v3d-status-chip.draft    { background: #e8f0fe; color: #1a56db; }
.v3d-status-chip.inreview { background: #fef3c7; color: #92400e; }
.v3d-status-chip.approved { background: #d1fae5; color: #065f46; }
.v3d-status-chip.rejected { background: #fee2e2; color: #991b1b; }
.v3d-status-chip.submitted { background: #ede9fe; color: #5b21b6; }

/* ── Save indicator ────────────────────────────────────────────────── */

.v3d-save-indicator {
    font-size: 0.72rem;
    color: var(--color-text-muted, #6b7280);
    white-space: nowrap;
    margin-left: auto;
}

.v3d-save-indicator.saving {
    color: var(--color-primary, #005f9e);
}

.v3d-save-indicator.saved {
    color: var(--color-success, #2e8540);
}

.v3d-save-indicator.error {
    color: var(--color-error, #d64545);
}

/* ── BCF header button / badge ─────────────────────────────────────── */

.v3d-bcf-header-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border: 1px solid var(--color-primary, #005f9e);
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-primary, #005f9e);
    background: transparent;
    cursor: pointer;
    white-space: nowrap;
}

.v3d-bcf-header-btn:hover {
    background: #e8f0fe;
}

.v3d-bcf-header-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border: none;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    background: #005f9e;
    color: #fff;
    cursor: pointer;
    white-space: nowrap;
}

.v3d-bcf-header-badge:hover {
    background: #00437b;
}

/* ── Scrolling question list ───────────────────────────────────────── */

.v3d-question-list {
    flex: 1 1 0;
    overflow-y: auto;
    padding: 8px 0;
}

/* ── Attached files section ────────────────────────────────────────── */

.v3d-files-section {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px 12px;
    border-bottom: 1px solid var(--color-border-subtle, #e0e0e0);
    background: var(--color-white, #fff);
}

.v3d-files-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-height: 108px;
    overflow-y: auto;
}

.v3d-file-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    border-radius: 5px;
    border: 1px solid var(--color-border-subtle, #e0e0e0);
    background: var(--color-white, #fff);
    font-size: 0.78rem;
    color: var(--color-text-primary, #1a1a1a);
}

.v3d-file-chip-name {
    flex: 1 1 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.v3d-file-chip-view {
    flex-shrink: 0;
    border: none;
    background: transparent;
    color: var(--color-primary, #005f9e);
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 4px;
    transition: background 0.1s;
}

.v3d-file-chip-view:hover {
    background: var(--color-primary-light, #e8f0fe);
}


.v3d-section-header {
    padding: 6px 12px 2px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--color-text-muted, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    position: sticky;
    top: 0;
    background: var(--color-background, #f3f5f7);
    z-index: 5;
}

/* ── QuestionRowNarrow ─────────────────────────────────────────────── */

.v3d-question-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--color-border-subtle, #e0e0e0);
    transition: background 0.1s ease;
}

.v3d-question-row:last-child {
    border-bottom: none;
}

.v3d-question-row.focused {
    background: var(--color-primary-light, #e8f0fe);
}

.v3d-question-header {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    min-width: 0;
}

.v3d-question-number {
    flex-shrink: 0;
    font-size: 0.75rem;
    color: var(--color-text-muted, #6b7280);
    font-weight: 600;
    margin-top: 2px;
    min-width: 24px;
}

.v3d-question-text {
    flex: 1 1 0;
    font-size: 0.875rem;
    color: var(--color-text-primary, #1a1a1a);
    line-height: 1.4;
    min-width: 0;
}

.v3d-question-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

/* Context badge button */
.v3d-context-btn {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 7px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 500;
    border: 1px solid var(--color-border-subtle, #e0e0e0);
    background: transparent;
    color: var(--color-text-muted, #6b7280);
    cursor: pointer;
    white-space: nowrap;
    line-height: 1.5;
    transition: background 0.15s, color 0.15s;
}

.v3d-context-btn:hover {
    background: var(--color-primary-light, #e8f0fe);
    color: var(--color-primary, #005f9e);
    border-color: var(--color-primary, #005f9e);
}

.v3d-context-btn.has-context {
    background: #e8f0fe;
    color: var(--color-primary, #005f9e);
    border-color: var(--color-primary, #005f9e);
}

/* Answer area */
.v3d-answer-area {
    padding-left: 32px; /* align with text (past number) */
}

/* Comment area */
.v3d-comment-area {
    padding-left: 32px;
}

.v3d-comment-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78rem;
    color: var(--color-text-muted, #6b7280);
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 2px 0;
}

.v3d-comment-btn:hover {
    color: var(--color-primary, #005f9e);
}

/* ── Sticky footer ─────────────────────────────────────────────────── */

.v3d-footer {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-top: 1px solid var(--color-border-subtle, #e0e0e0);
    background: var(--color-white, #fff);
}

.v3d-footer-spacer {
    flex: 1 1 0;
}

/* ── Overview page ─────────────────────────────────────────────────── */

.v3d-overview {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.v3d-filter-bar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--color-border-subtle, #e0e0e0);
    background: var(--color-white, #fff);
}

.v3d-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid var(--color-border-subtle, #e0e0e0);
    background: transparent;
    color: var(--color-text-primary, #1a1a1a);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.v3d-filter-btn:hover {
    background: var(--color-primary-light, #e8f0fe);
    border-color: var(--color-primary, #005f9e);
}

.v3d-filter-btn.active {
    background: var(--color-primary, #005f9e);
    color: #fff;
    border-color: var(--color-primary, #005f9e);
}

.v3d-filter-spacer {
    flex: 1 1 0;
}

.v3d-list {
    flex: 1 1 0;
    overflow-y: auto;
}

.v3d-list-empty {
    padding: 24px 16px;
    text-align: center;
    color: var(--color-text-muted, #6b7280);
    font-size: 0.875rem;
}

.v3d-list-loading {
    padding: 24px 16px;
    text-align: center;
    color: var(--color-text-muted, #6b7280);
    font-size: 0.875rem;
}

/* ── Two-line checklist row ────────────────────────────────────────── */

.v3d-instance-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--color-border-subtle, #e0e0e0);
    cursor: pointer;
    transition: background 0.1s ease;
}

.v3d-instance-row:hover {
    background: var(--color-primary-light, #e8f0fe);
}

.v3d-instance-row:last-child {
    border-bottom: none;
}

.v3d-instance-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text-primary, #1a1a1a);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.v3d-instance-chips {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.v3d-badge {
    display: inline-flex;
    align-items: center;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 500;
    white-space: nowrap;
    border: 1px solid transparent;
}

.v3d-badge-status {
    background: var(--color-border-subtle, #e0e0e0);
    color: var(--color-text-muted, #6b7280);
}

.v3d-badge-3d {
    background: #e8f0fe;
    color: var(--color-primary, #005f9e);
    border-color: var(--color-primary, #005f9e);
    font-weight: 700;
    letter-spacing: 0.02em;
}

.v3d-badge-discipline {
    background: #f0fdf4;
    color: #065f46;
}

.v3d-badge-phase {
    background: #fefce8;
    color: #92400e;
}

.v3d-badge-bcf {
    background: #005f9e;
    color: #fff;
    font-weight: 600;
}

/* ── Create page ───────────────────────────────────────────────────── */

.v3d-create-page {
    flex: 1 1 0;
    overflow-y: auto;
    padding: 0 0 24px;
}

/* ── Responsive: collapse action chips below 320px ─────────────────── */

@container v3d-question-row (max-width: 320px) {
    .v3d-question-actions {
        flex-wrap: wrap;
    }
}

/* ======================================================================
   Context bottom sheet
   ====================================================================== */

.v3d-context-sheet {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    min-height: 120px;
    max-height: 600px;
    border-top: 2px solid var(--color-primary, #005f9e);
    background: var(--color-white, #fff);
    box-shadow: 0 -3px 10px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

/* ── Drag handle ──────────────────────────────────────────────────── */

.v3d-context-sheet-drag {
    flex-shrink: 0;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: ns-resize;
    background: var(--color-background, #f3f5f7);
    user-select: none;
}

.v3d-context-sheet-drag-indicator {
    width: 32px;
    height: 4px;
    border-radius: 2px;
    background: var(--color-border-subtle, #e0e0e0);
    transition: background 0.15s;
}

.v3d-context-sheet-drag:hover .v3d-context-sheet-drag-indicator {
    background: var(--color-primary, #005f9e);
}

/* ── Sheet header ─────────────────────────────────────────────────── */

.v3d-context-sheet-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    border-bottom: 1px solid var(--color-border-subtle, #e0e0e0);
}

.v3d-context-sheet-title {
    flex: 1 1 0;
    font-size: 0.8rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--color-text-primary, #1a1a1a);
}

.v3d-context-close-btn {
    flex-shrink: 0;
    border: none;
    background: transparent;
    padding: 2px 4px;
    cursor: pointer;
    color: var(--color-text-muted, #6b7280);
    border-radius: 4px;
    line-height: 1;
    font-size: 0.8rem;
}

.v3d-context-close-btn:hover {
    background: var(--color-border-subtle, #e0e0e0);
    color: var(--color-text-primary, #1a1a1a);
}

/* ── Tab strip ────────────────────────────────────────────────────── */

.v3d-context-sheet-tabs {
    flex-shrink: 0;
    display: flex;
    overflow-x: hidden;
    border-bottom: 1px solid var(--color-border-subtle, #e0e0e0);
    background: var(--color-white, #fff);
}

.v3d-tab-btn {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 3px;
    font-size: 0.75rem;
    font-weight: 500;
    border: none;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--color-text-muted, #6b7280);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.v3d-tab-btn:hover {
    color: var(--color-primary, #005f9e);
}

.v3d-tab-btn.active {
    color: var(--color-primary, #005f9e);
    border-bottom-color: var(--color-primary, #005f9e);
}

.v3d-tab-count {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 10px;
    background: var(--color-primary-light, #e8f0fe);
    color: var(--color-primary, #005f9e);
    line-height: 1.4;
}

.v3d-tab-btn.active .v3d-tab-count {
    background: var(--color-primary, #005f9e);
    color: #fff;
}

/* ── Tab body ─────────────────────────────────────────────────────── */

.v3d-context-sheet-body {
    flex: 1 1 0;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.v3d-tab-empty {
    padding: 14px 8px;
    text-align: center;
    color: var(--color-text-muted, #6b7280);
    font-size: 0.8rem;
}

/* ── Objects tab toolbar ──────────────────────────────────────────── */

.v3d-obj-toolbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.v3d-obj-toolbar-spacer {
    flex: 1 1 0;
}

.v3d-obj-toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 0.78rem;
    font-weight: 500;
    border: 1px solid var(--color-border-subtle, #e0e0e0);
    background: transparent;
    color: var(--color-text-primary, #1a1a1a);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
}

.v3d-obj-toolbar-btn:hover:not(:disabled) {
    background: var(--color-primary-light, #e8f0fe);
    border-color: var(--color-primary, #005f9e);
    color: var(--color-primary, #005f9e);
}

.v3d-obj-toolbar-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.v3d-obj-toolbar-btn.active {
    background: var(--color-primary, #005f9e);
    color: #fff;
    border-color: var(--color-primary, #005f9e);
}

.v3d-obj-toolbar-btn.active:hover {
    background: #004a7c;
}

.v3d-btn-danger {
    background: var(--color-error-light, #fee2e2);
    color: var(--color-error, #d64545);
    border-color: #fca5a5;
}

.v3d-btn-danger:hover:not(:disabled) {
    background: var(--color-error, #d64545);
    color: #fff;
    border-color: var(--color-error, #d64545);
}

/* ── Soft-limit banners ───────────────────────────────────────────── */

.v3d-limit-banner {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.78rem;
    flex-shrink: 0;
}

.v3d-limit-banner.warn {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.v3d-limit-banner.hard {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

/* ── Confirm-clear banner ─────────────────────────────────────────── */

.v3d-confirm-clear {
    padding: 8px 10px;
    border-radius: 6px;
    background: #fee2e2;
    border: 1px solid #fca5a5;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

.v3d-confirm-clear p {
    margin: 0;
    font-size: 0.8rem;
    color: #991b1b;
}

.v3d-confirm-clear-actions {
    display: flex;
    gap: 6px;
}

/* ── Object chip list ─────────────────────────────────────────────── */

.v3d-obj-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.v3d-obj-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border-radius: 6px;
    border: 1px solid var(--color-border-subtle, #e0e0e0);
    background: var(--color-white, #fff);
    cursor: pointer;
    transition: background 0.1s, border-color 0.1s;
    font-size: 0.8rem;
    color: var(--color-text-primary, #1a1a1a);
    user-select: none;
}

.v3d-obj-chip:hover {
    background: var(--color-primary-light, #e8f0fe);
    border-color: var(--color-primary, #005f9e);
}

.v3d-obj-chip-label {
    flex: 1 1 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.8rem;
    color: var(--color-primary, #005f9e);
    font-weight: 500;
}

.v3d-obj-chip-guid {
    flex-shrink: 0;
    font-size: 0.68rem;
    color: var(--color-text-muted, #6b7280);
    font-family: monospace;
}

.v3d-obj-chip-remove {
    flex-shrink: 0;
    border: none;
    background: transparent;
    color: var(--color-text-muted, #6b7280);
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
    padding: 1px 3px;
    border-radius: 4px;
    transition: background 0.1s, color 0.1s;
}

.v3d-obj-chip-remove:hover {
    background: #fee2e2;
    color: var(--color-error, #d64545);
}


/* ======================================================================
   Views tab
   ====================================================================== */

/* ── Section headers ──────────────────────────────────────────────── */

.v3d-views-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.v3d-views-section-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 6px 8px;
    font-size: 0.8rem;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    background: var(--color-background, #f3f5f7);
    color: var(--color-text-primary, #1a1a1a);
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
}

.v3d-views-section-toggle:hover {
    background: var(--color-primary-light, #e8f0fe);
}

/* ── View cards grid ──────────────────────────────────────────────── */

.v3d-view-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 6px;
    padding: 4px 0;
}

.v3d-view-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    border: 1px solid var(--color-border-subtle, #e0e0e0);
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    background: var(--color-white, #fff);
    transition: box-shadow 0.15s, border-color 0.15s;
}

.v3d-view-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    border-color: var(--color-primary, #005f9e);
}

.v3d-view-thumb {
    width: 100%;
    aspect-ratio: 3 / 2;
    overflow: hidden;
    background: var(--color-background, #f3f5f7);
    cursor: pointer;
}

.v3d-view-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.v3d-view-thumb-placeholder {
    width: 100%;
    aspect-ratio: 3 / 2;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-background, #f3f5f7);
    color: var(--color-text-muted, #6b7280);
    font-size: 1.2rem;
}

.v3d-view-card-name {
    padding: 4px 6px;
    font-size: 0.72rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--color-text-primary, #1a1a1a);
}

.v3d-view-card-group {
    padding: 0 6px 3px;
    font-size: 0.65rem;
    color: var(--color-text-muted, #6b7280);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.v3d-view-delete-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    border: none;
    background: rgba(255, 255, 255, 0.85);
    color: var(--color-text-muted, #6b7280);
    border-radius: 4px;
    padding: 2px 5px;
    font-size: 0.8rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s, color 0.15s;
}

.v3d-view-card:hover .v3d-view-delete-btn {
    opacity: 1;
}

.v3d-view-delete-btn:hover {
    background: #fee2e2;
    color: var(--color-error, #d64545);
}

/* Snap inline rename input */
.v3d-snap-rename-input {
    font-size: 0.72rem;
    padding: 3px 6px;
    border: 1px solid var(--color-primary, #005f9e);
    border-radius: 3px;
    outline: none;
    width: 100%;
    box-sizing: border-box;
}

.v3d-snap-name {
    cursor: text;
}

/* ── Enlarged thumbnail overlay ───────────────────────────────────── */

.v3d-thumb-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2100;
    cursor: zoom-out;
}

.v3d-thumb-overlay-img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 6px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* ======================================================================
   Add-view modal
   ====================================================================== */

.v3d-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 16px;
}

.v3d-modal {
    width: 100%;
    max-width: 420px;
    min-height: 40vh;
    background: var(--color-white, #fff);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
}

/* Wider variant used by the Add View modal */
.v3d-modal.v3d-modal--views {
    max-width: 700px;
    max-height: 80vh;
}

/* Section body — remove extra padding and allow scroll */
.v3d-views-grid-body {
    padding: 0 !important;
    overflow: auto;
    max-height: 400px;
}

/*
 * Plain HTML view-selection table.
 * Always renders as a proper fixed table — no card/stacked mode.
 */
.v3d-views-table {
    table-layout: fixed;
    width: 100%;
    min-width: 320px;
    font-size: 0.75rem;  /* ~30% smaller than default */
    border-collapse: collapse;
}

.v3d-views-table th,
.v3d-views-table td {
    padding: 4px 6px;
    vertical-align: middle;
    overflow: hidden;
}

.v3d-views-table thead th {
    font-weight: 600;
    background: var(--color-background, #f3f5f7);
    border-bottom: 1px solid var(--color-border-subtle, #e0e0e0);
    white-space: nowrap;
}

.v3d-views-table tbody tr:nth-child(even) {
    background: rgba(0,0,0,0.03);
}

.v3d-views-table tbody tr:hover {
    background: var(--color-primary-light, #e8f0fe);
}

/* Name column — equal share of remaining space */
.v3d-views-th-name {
    width: 28%;
}

/* Description column — equal share of remaining space */
.v3d-views-th-desc {
    width: auto;
}

/* Date column — fixed narrow */
.v3d-views-th-date {
    width: 60px;
}

/* Action column — icon-only, fixed very narrow */
.v3d-views-th-action {
    width: 38px;
    text-align: center;
}

.v3d-views-date-cell {
    white-space: nowrap;
    overflow: hidden;
}

.v3d-views-action-cell {
    text-align: center;
    padding: 2px 4px !important;
}

/* Name cell — single-line with ellipsis */
.v3d-views-name-cell {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Description cell — single line with ellipsis to keep each view on one row */
.v3d-views-desc-cell {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Compact icon-only select button */
.v3d-views-select-btn {
    padding: 2px 5px;
    font-size: 0.8rem;
    line-height: 1;
    white-space: nowrap;
}

/* Sort bar — Name / Date toggle buttons above the view list */
.v3d-views-sort-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px 2px;
}

.v3d-views-sort-btn {
    padding: 2px 10px;
    font-size: 0.72rem;
    border: 1px solid var(--color-border-subtle, #e0e0e0);
    border-radius: 12px;
    background: transparent;
    color: var(--color-text-secondary, #555);
    cursor: pointer;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.v3d-views-sort-btn:hover {
    background: var(--color-primary-light, #e8f0fe);
    border-color: var(--color-primary, #005f9e);
    color: var(--color-primary, #005f9e);
}

.v3d-views-sort-btn.active {
    background: var(--color-primary, #005f9e);
    border-color: var(--color-primary, #005f9e);
    color: #fff;
    font-weight: 600;
}


    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border-subtle, #e0e0e0);
}

.v3d-modal-title {
    flex: 1 1 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text-primary, #1a1a1a);
}

.v3d-modal-body {
    flex: 1 1 0;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* ── Modal accordion sections ─────────────────────────────────────── */

.v3d-modal-section {
    border: 1px solid var(--color-border-subtle, #e0e0e0);
    border-radius: 8px;
}

.v3d-modal-section-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 9px 12px;
    font-size: 0.82rem;
    font-weight: 600;
    border: none;
    background: var(--color-background, #f3f5f7);
    color: var(--color-text-primary, #1a1a1a);
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
}

.v3d-modal-section-toggle:hover {
    background: var(--color-primary-light, #e8f0fe);
}

.v3d-modal-section-body {
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ── Project-view search + grid ───────────────────────────────────── */

.v3d-view-search {
    width: 100%;
    padding: 6px 10px;
    font-size: 0.8rem;
    border: 1px solid var(--color-border-subtle, #e0e0e0);
    border-radius: 6px;
    outline: none;
    box-sizing: border-box;
}

.v3d-view-search:focus {
    border-color: var(--color-primary, #005f9e);
}

.v3d-proj-view-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 6px;
    max-height: 220px;
    overflow-y: auto;
}

.v3d-proj-view-card {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    border: 1px solid var(--color-border-subtle, #e0e0e0);
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    background: transparent;
    padding: 0;
    transition: box-shadow 0.15s, border-color 0.15s;
    text-align: left;
}

.v3d-proj-view-card:hover:not(:disabled),
.v3d-proj-view-card.picking {
    border-color: var(--color-primary, #005f9e);
    box-shadow: 0 0 0 2px rgba(0, 95, 158, 0.2);
}

.v3d-proj-view-card:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── Form elements in modal ───────────────────────────────────────── */

.v3d-form-label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--color-text-primary, #1a1a1a);
}

.v3d-form-label .v3d-required {
    color: var(--color-error, #d64545);
    margin-left: 2px;
}

.v3d-form-input {
    width: 100%;
    padding: 7px 10px;
    font-size: 0.82rem;
    border: 1px solid var(--color-border-subtle, #e0e0e0);
    border-radius: 6px;
    outline: none;
    box-sizing: border-box;
}

.v3d-form-input:focus {
    border-color: var(--color-primary, #005f9e);
}

/* ======================================================================
   Properties tab
   ====================================================================== */

/* ── Object group ─────────────────────────────────────────────────── */

.v3d-prop-obj-group {
    margin-bottom: 10px;
}

.v3d-prop-obj-header {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 8px;
    font-size: 0.78rem;
    font-weight: 600;
    background: var(--color-background, #f3f5f7);
    border-radius: 6px;
    color: var(--color-text-primary, #1a1a1a);
    margin-bottom: 4px;
}

/* ── PropertySet sub-group ────────────────────────────────────────── */

.v3d-prop-ps-group {
    padding-left: 8px;
    margin-bottom: 4px;
}

.v3d-prop-ps-header {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--color-text-muted, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 3px 0 2px;
    border-bottom: 1px solid var(--color-border-subtle, #e0e0e0);
    margin-bottom: 2px;
}

/* ── Property rows ────────────────────────────────────────────────── */

.v3d-prop-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    border-radius: 5px;
    font-size: 0.78rem;
    transition: background 0.12s;
}

.v3d-prop-row:hover {
    background: var(--color-primary-light, #e8f0fe);
}

.v3d-prop-badge {
    flex-shrink: 0;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.v3d-prop-badge.badge-property {
    background: #fff3e0;
    color: #e65100;
}

.v3d-prop-badge.badge-value {
    background: #e3f2fd;
    color: #1565c0;
}

.v3d-prop-name {
    flex: 1 1 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--color-text-primary, #1a1a1a);
}

.v3d-prop-value {
    flex-shrink: 0;
    color: var(--color-text-muted, #6b7280);
    font-size: 0.75rem;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.v3d-prop-remove-btn {
    flex-shrink: 0;
    border: none;
    background: transparent;
    color: var(--color-text-muted, #6b7280);
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.12s, color 0.12s, background 0.12s;
    line-height: 1;
}

.v3d-prop-row:hover .v3d-prop-remove-btn {
    opacity: 1;
}

.v3d-prop-remove-btn:hover {
    background: #fee2e2;
    color: var(--color-error, #d64545);
}

/* ── AddPropertiesModal table ─────────────────────────────────────── */

.v3d-prop-modal-group {
    margin-bottom: 12px;
}

.v3d-prop-modal-group-header {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--color-text-muted, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 4px 0 3px;
    border-bottom: 1px solid var(--color-border-subtle, #e0e0e0);
    margin-bottom: 4px;
    text-align: left;
}

.v3d-prop-modal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.v3d-prop-modal-table th {
    text-align: left;
    padding: 3px 6px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--color-text-muted, #6b7280);
    border-bottom: 1px solid var(--color-border-subtle, #e0e0e0);
}

.v3d-prop-modal-table td {
    padding: 4px 6px;
    vertical-align: middle;
}

.v3d-prop-modal-table tr:hover td {
    background: var(--color-primary-light, #e8f0fe);
}

.v3d-prop-modal-name {
    font-weight: 500;
    color: var(--color-text-primary, #1a1a1a);
}

.v3d-prop-modal-value {
    color: var(--color-text-muted, #6b7280);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.v3d-prop-varies {
    font-style: italic;
    color: var(--color-text-muted, #6b7280);
}

.v3d-prop-modal-actions {
    white-space: nowrap;
}

.v3d-prop-flag-btn {
    border: none;
    background: transparent;
    padding: 3px 6px;
    border-radius: 5px;
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--color-text-muted, #6b7280);
    transition: background 0.12s, color 0.12s;
}

.v3d-prop-flag-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.v3d-prop-flag-btn.flag-property:not(:disabled):hover {
    background: #fff3e0;
    color: #e65100;
}

.v3d-prop-flag-btn.flag-value:not(:disabled):hover {
    background: #e3f2fd;
    color: #1565c0;
}

.v3d-prop-flag-btn.flag-split:not(:disabled):hover {
    background: var(--color-primary-light, #e8f0fe);
    color: var(--color-primary, #005f9e);
}

/* ======================================================================
   BCF "Add to BCF" button on question rows
   ====================================================================== */

.v3d-bcf-add-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--color-text-muted, #6b7280);
    padding: 3px 6px;
    border-radius: 5px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
    line-height: 1;
}

.v3d-bcf-add-btn:not([disabled]):hover {
    background: #dbeafe;
    color: #1d4ed8;
}

.v3d-bcf-add-btn[disabled],
.v3d-bcf-add-btn.disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* ======================================================================
   AddToBcfModal
   ====================================================================== */

.v3d-bcf-form-group {
    margin-bottom: 12px;
}

.v3d-bcf-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text-muted, #6b7280);
    margin-bottom: 4px;
}

.v3d-bcf-textarea {
    width: 100%;
    border: 1px solid var(--color-border-subtle, #e0e0e0);
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 0.8rem;
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
    color: var(--color-text-primary, #1a1a1a);
    background: #fff;
    box-sizing: border-box;
}

.v3d-bcf-textarea:focus {
    outline: none;
    border-color: var(--color-primary, #005f9e);
    box-shadow: 0 0 0 2px rgba(0,95,158,0.12);
}

.v3d-bcf-checkbox-group {
    margin-bottom: 10px;
}

.v3d-bcf-checkbox-label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.8rem;
    cursor: pointer;
    user-select: none;
}

.v3d-bcf-checkbox-label input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
    accent-color: var(--color-primary, #005f9e);
}

.v3d-bcf-hint {
    font-size: 0.72rem;
    color: var(--color-text-muted, #6b7280);
    font-style: italic;
}

.v3d-bcf-count {
    font-size: 0.72rem;
    color: var(--color-text-muted, #6b7280);
}

.v3d-bcf-view-select {
    margin-top: 6px;
    padding-left: 22px;
}

.v3d-bcf-select {
    width: 100%;
    border: 1px solid var(--color-border-subtle, #e0e0e0);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.78rem;
    background: #fff;
    color: var(--color-text-primary, #1a1a1a);
    margin-top: 4px;
}

.v3d-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid var(--color-border-subtle, #e0e0e0);
    flex-shrink: 0;
}

.v3d-btn-primary {
    background: var(--color-primary, #005f9e);
    color: #fff;
    border: none;
}

.v3d-btn-primary:hover:not([disabled]) {
    background: #004b80;
}

.v3d-btn-primary[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ======================================================================
   ChecklistModelContextReadOnly — shared read-only rendering
   ====================================================================== */

.mc-ro-container {
    margin-top: 10px;
    padding: 0 0 4px 0;
    border-top: 1px solid var(--color-border-subtle, #e0e0e0);
}

.mc-ro-section {
    margin-top: 8px;
    padding: 0 12px;
}

.mc-ro-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted, #6b7280);
    margin-bottom: 4px;
}

.mc-ro-bullet-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.mc-ro-bullet-item {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: 0.78rem;
    padding: 2px 0;
    color: var(--color-text-primary, #1a1a1a);
}

.mc-ro-bullet-item::before {
    content: "•";
    color: var(--color-text-muted, #9ca3af);
    flex-shrink: 0;
}

.mc-ro-guid-hint {
    font-size: 0.68rem;
    color: var(--color-text-muted, #9ca3af);
    font-family: monospace;
}

/* ── Thumbnail strip ── */

.mc-ro-thumbnail-strip {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.mc-ro-thumbnail-card {
    flex-shrink: 0;
    width: 120px;
    border: 1px solid var(--color-border-subtle, #e0e0e0);
    border-radius: 6px;
    overflow: hidden;
    background: #fafafa;
    cursor: pointer;
    transition: box-shadow 0.12s;
}

.mc-ro-thumbnail-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.mc-ro-thumbnail-img {
    width: 100%;
    height: 72px;
    object-fit: cover;
    display: block;
    cursor: zoom-in;
}

.mc-ro-thumbnail-placeholder {
    width: 100%;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted, #9ca3af);
    font-size: 1.4rem;
    background: #f3f4f6;
}

.mc-ro-thumbnail-footer {
    padding: 3px 5px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
}

.mc-ro-thumbnail-name {
    font-size: 0.65rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--color-text-primary, #374151);
    flex: 1;
    min-width: 0;
}

.mc-ro-thumbnail-badge {
    font-size: 0.58rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 1px 4px;
    border-radius: 3px;
    flex-shrink: 0;
}

.mc-ro-thumbnail-badge.project {
    background: #dbeafe;
    color: #1d4ed8;
}

.mc-ro-thumbnail-badge.snap {
    background: #fef3c7;
    color: #b45309;
}

/* ── Properties ── */

.mc-ro-prop-group {
    margin-top: 4px;
}

.mc-ro-prop-group-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--color-text-muted, #6b7280);
    padding-left: 4px;
    margin-bottom: 2px;
}

.mc-ro-prop-mode-badge {
    font-size: 0.65rem;
    background: #ffe4e6;
    color: #be123c;
    border-radius: 3px;
    padding: 1px 4px;
}

/* ── BCF refs ── */

.mc-ro-bcf-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: #1d4ed8;
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.mc-ro-bcf-link:hover {
    color: #1e40af;
}

.mc-ro-bcf-date {
    font-size: 0.68rem;
    color: var(--color-text-muted, #9ca3af);
}

/* ── Properties modal: object picker ── */

.v3d-prop-modal-picker {
    margin-bottom: 12px;
}

/* ── Properties modal: collapsible Pset toggle button ── */

.v3d-pset-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--color-border-subtle, #e0e0e0);
    padding: 4px 0 3px;
    cursor: pointer;
    text-align: left;
    justify-content: left;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--color-text-muted, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    transition: color 0.12s;
}

.v3d-pset-toggle:hover {
    color: var(--color-primary, #1967d2);
}
