/**
 * AI Editor - Modal Styles
 * Modals, settings tabs, role cards, connection cards, capability badges, help
 */

/* ============================================
   REVERT MODAL - FILE LIST STYLING
   ============================================ */

.revert-file-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    font-size: var(--font-md);
    transition: background 0.15s;
}

.revert-file-item:last-child {
    border-bottom: none;
}

.revert-file-item:hover {
    background: var(--bg-hover);
}

.revert-file-item.current {
    background: rgba(14, 125, 202, 0.1);
    border-left: 3px solid var(--accent);
}

.revert-file-icon {
    flex-shrink: 0;
    font-size: var(--font-lg);
}

.revert-file-path {
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.revert-current-badge {
    background: var(--accent);
    color: white;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: var(--font-xs);
    font-weight: 600;
    flex-shrink: 0;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   MODALS
   ============================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 90%;
    max-width: calc(var(--ui-font-size) * 40);  /* ~520px at 13, ~640px at 16, ~800px at 20 */
    min-width: 320px;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: var(--font-lg);
    font-weight: 500;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: var(--font-xl);
    padding: 0.25rem;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 1rem;
    overflow-y: auto;
}

.modal-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* Form elements in modals */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: var(--font-md);
    color: var(--text-secondary);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    font-size: var(--font-base);
    font-family: inherit;
}

/* Checkboxes: reset full-width text-input styling */
.form-group input[type="checkbox"],
.form-group input[type="range"] {
    width: auto;
    padding: 0;
    border: revert;
    border-radius: revert;
    background: revert;
}

.form-group input[type="checkbox"] {
    vertical-align: middle;
    margin-right: 0.4rem;
    cursor: pointer;
}

/* Checkbox labels: inline so text sits next to the box */
.form-group label:has(input[type="checkbox"]) {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

/* Fallback for browsers without :has() — match the pattern used in HTML */
.form-group label > input[type="checkbox"] {
    flex-shrink: 0;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    font-size: var(--font-sm);
    color: var(--text-muted);
}

/* ============================================


/* ============================================
   CAPABILITY BADGES
   ============================================ */

.cap-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: var(--chat-xs);
    font-weight: 500;
    white-space: nowrap;
    line-height: 1.5;
}

.cap-badge.cap-yes {
    background: rgba(78, 201, 176, 0.15);
    color: var(--success);
    border: 1px solid rgba(78, 201, 176, 0.25);
}

.cap-badge.cap-no {
    background: rgba(241, 76, 76, 0.1);
    color: var(--error);
    border: 1px solid rgba(241, 76, 76, 0.2);
}

.cap-badge.cap-neutral {
    background: rgba(133, 133, 133, 0.1);
    color: var(--text-secondary);
    border: 1px solid rgba(133, 133, 133, 0.2);
}

/* Model selector enrichment */
.model-option-rich {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.model-badges-inline {
    font-size: var(--chat-xs);
    opacity: 0.7;
}

/* Status indicator for tool support in chat panel */
.model-status-bar {
    display: flex;
    gap: 0.35rem;
    padding: 2px 8px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    font-size: var(--chat-xs);
    color: var(--text-muted);
    overflow-x: auto;
    flex-wrap: nowrap;
    flex-shrink: 0;
}

/* Cost tracker bar */
/* ============================================


/* ============================================
   SETTINGS TABS
   ============================================ */

.settings-tabs-nav {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
    flex-shrink: 0;
    position: relative;
}

.settings-tabs-arrow {
    display: none;          /* hidden until JS shows them */
    align-items: center;
    justify-content: center;
    width: calc(var(--font-base) * 2);
    min-width: 24px;
    padding: 0;
    background: var(--bg-tertiary);
    border: none;
    color: var(--text-secondary);
    font-size: var(--font-xl);
    cursor: pointer;
    flex-shrink: 0;
    z-index: 1;
    transition: color 0.15s, background 0.15s;
}

.settings-tabs-arrow:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.settings-tabs-arrow.visible {
    display: flex;
}

/* Left arrow gets a right-side fade hint */
.settings-tabs-arrow-left {
    border-right: 1px solid var(--border);
}

.settings-tabs-arrow-right {
    border-left: 1px solid var(--border);
}

.settings-tabs {
    display: flex;
    flex: 1;
    overflow-x: hidden;     /* JS handles scrolling via buttons */
    overflow-y: hidden;
    scroll-behavior: smooth;
}

.settings-tab {
    padding: 0.6rem 0.75rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: var(--font-md);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}

.settings-tab:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.settings-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.settings-tab-content {
    display: none;
}

.settings-tab-content.active {
    display: block;
}

/* ============================================
   ROLE CARDS
   ============================================ */

.role-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.role-card {
    padding: 0.75rem;
    background: var(--bg-primary);
    border: 2px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.role-card:hover {
    border-color: var(--border-light);
    background: var(--bg-tertiary);
}

.role-card.active {
    border-color: var(--accent);
    background: rgba(14, 125, 202, 0.08);
}

.role-card-icon {
    font-size: var(--font-2xl);
    margin-bottom: 0.25rem;
}

.role-card-name {
    font-size: var(--font-md);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.15rem;
}

.role-card-desc {
    font-size: var(--font-xs);
    color: var(--text-muted);
    line-height: 1.3;
}

/* Role tool list */
.role-tool-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0;
    color: var(--text-secondary);
    font-size: var(--font-md);
}

.role-tool-item.enabled {
    color: var(--text-primary);
}

.role-tool-item.disabled {
    color: var(--text-muted);
    text-decoration: line-through;
    opacity: 0.5;
}

/* ============================================
   CONNECTION CARDS
   ============================================ */

.connection-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 0.5rem;
    transition: border-color 0.15s;
}

.connection-card:hover {
    border-color: var(--border-light);
}

.connection-card.disabled {
    opacity: 0.5;
}

.connection-card-icon {
    font-size: var(--font-2xl);
    flex-shrink: 0;
    width: 32px;
    text-align: center;
}

.connection-card-info {
    flex: 1;
    min-width: 0;
}

.connection-card-label {
    font-size: var(--font-md);
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.connection-card-meta {
    font-size: var(--font-xs);
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.connection-card-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.connection-card-actions button {
    background: none;
    border: 1px solid transparent;
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 6px;
    font-size: var(--font-sm);
    line-height: 1;
    transition: all 0.15s;
}

.connection-card-actions button:hover {
    background: var(--bg-hover);
    border-color: var(--border);
    color: var(--text-primary);
}

.connection-card-actions button.danger:hover {
    background: rgba(201, 58, 58, 0.15);
    border-color: var(--danger);
    color: var(--danger);
}

.connection-editor {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.connections-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
    font-size: var(--font-md);
}

.connections-empty-icon {
    font-size: var(--font-2xl);
    margin-bottom: 0.5rem;
    opacity: 0.5;
}


/* ============================================
   PLUGIN INSTALL UI
   ============================================ */

.plugin-section-header {
    font-weight: 600;
    font-size: var(--font-sm);
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.plugin-install-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.plugin-install-row input {
    flex: 1;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    font-size: var(--font-sm);
    font-family: var(--font-mono);
}

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

.plugin-install-row input::placeholder {
    color: var(--text-muted);
}

.plugin-install-status {
    margin-top: 0.35rem;
    font-size: var(--font-sm);
    min-height: 1.2em;
}

.plugin-install-hint {
    margin-top: 0.35rem;
    font-size: var(--font-xs);
    color: var(--text-muted);
}

.plugin-external-meta {
    word-break: break-all;
}

.plugin-badge-external {
    font-size: var(--font-xs);
    color: var(--text-muted);
}

.plugin-config-panel textarea {
    font-family: var(--font-mono);
    resize: vertical;
}

.plugin-install-title {
    font-weight: 600;
    font-size: var(--font-base);
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.plugin-config-panel {
    margin: -0.25rem 0 0.5rem 0;
    border-top: none;
    border-radius: 0 0 6px 6px;
}

.plugin-config-panel .form-group {
    margin-bottom: 0.5rem;
}


/* ============================================
   STANDALONE FORM CONTROLS (outside .form-group)
   ============================================ */

/* Themed select for use outside .form-group (e.g. merge strategy, inline controls) */
.select-inline {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    padding: 0.35rem 0.5rem;
    font-size: var(--font-sm);
    cursor: pointer;
}

.select-inline:focus {
    outline: none;
    border-color: var(--accent);
}

/* Inline checkbox label (merge controls, compact toggles) */
.label-inline-check {
    font-size: var(--font-sm);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
    user-select: none;
}

/* Markdown / code textarea used outside .form-group */
.textarea-mono {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    font-family: var(--font-mono);
    font-size: var(--font-sm);
    resize: vertical;
}

.textarea-mono:focus {
    outline: none;
    border-color: var(--accent);
}


/* ============================================
   STATE BADGES (PR, issue, CI)
   ============================================ */

.badge-state {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: var(--font-sm);
    font-weight: 500;
    line-height: 1.4;
}

.badge-state-open {
    background: var(--success);
    color: var(--bg-primary);
}

.badge-state-closed {
    background: var(--danger);
    color: white;
}

.badge-state-merged {
    background: #8957e5;
    color: white;
}


/* ============================================
   BUTTON SIZE VARIANTS
   ============================================ */

/* Extra-small button for inline/compact controls */
.btn-xs {
    font-size: var(--font-xs);
    padding: 0.15rem 0.4rem;
}

/* Small button for secondary actions */
.btn-sm {
    font-size: var(--font-sm);
    padding: 0.25rem 0.5rem;
}

/* Icon-only close/delete button (e.g. embedding delete, tag remove) */
.btn-icon-danger {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.1rem 0.3rem;
    font-size: var(--font-sm);
    color: var(--text-muted);
    border-radius: 3px;
    line-height: 1;
    transition: color 0.15s;
}

.btn-icon-danger:hover {
    color: var(--danger);
}


/* ============================================
   ERROR LOG TYPE BADGES
   ============================================ */

.error-type-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: var(--font-xs);
    font-weight: 600;
    letter-spacing: 0.03em;
    color: white;
}

.error-type-error {
    background: var(--danger);
}

.error-type-warn {
    background: var(--warning);
    color: var(--bg-primary);
}

.error-type-log {
    background: var(--text-muted);
}

.error-recovery-hint {
    margin-top: 0.4rem;
    padding: 0.4rem 0.6rem;
    background: rgba(14, 125, 202, 0.1);
    border-left: 2px solid var(--accent);
    border-radius: 2px;
    color: var(--text-secondary);
    font-size: var(--font-xs);
}


/* ============================================
   HELP / KEYBOARD SHORTCUTS MODAL
   ============================================ */

.help-shortcuts {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.help-group h3 {
    font-size: var(--font-md);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted, #888);
    margin: 0 0 0.5rem 0;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border, #333);
}

.help-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.3rem 0;
    font-size: var(--font-base);
    color: var(--text-primary, #e0e0e0);
}

.help-keys {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.help-keys kbd {
    display: inline-block;
    padding: 2px 7px;
    font-size: var(--font-sm);
    font-family: 'Consolas', 'Monaco', monospace;
    color: var(--text-primary, #e0e0e0);
    background: var(--bg-secondary, #2d2d2d);
    border: 1px solid var(--border, #444);
    border-radius: 3px;
    box-shadow: 0 1px 0 var(--border, #333);
    min-width: 20px;
    text-align: center;
}

/* Help tab content (reuses settings-tab-content pattern) */
.help-tab-content {
    display: none;
    padding: 1rem;
}
.help-tab-content.active {
    display: block;
}

/* Rendered markdown in help docs */
.help-doc-content {
    color: var(--text-primary);
    line-height: 1.6;
    font-size: var(--font-base);
}
.help-doc-content h1 { font-size: 1.4em; margin: 0 0 0.75rem; border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; }
.help-doc-content h2 { font-size: 1.2em; margin: 1.25rem 0 0.5rem; color: var(--accent); }
.help-doc-content h3 { font-size: 1.05em; margin: 1rem 0 0.35rem; }
.help-doc-content p { margin: 0.5rem 0; }
.help-doc-content code {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
    background: var(--bg-tertiary);
    padding: 1px 5px;
    border-radius: 3px;
}
.help-doc-content pre {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.75rem;
    overflow-x: auto;
    margin: 0.5rem 0;
}
.help-doc-content pre code {
    background: none;
    padding: 0;
}
.help-doc-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.5rem 0;
    font-size: var(--font-sm);
}
.help-doc-content th,
.help-doc-content td {
    border: 1px solid var(--border);
    padding: 0.35rem 0.5rem;
    text-align: left;
}
.help-doc-content th {
    background: var(--bg-tertiary);
    font-weight: 600;
}
.help-doc-content ul,
.help-doc-content ol {
    padding-left: 1.5rem;
    margin: 0.35rem 0;
}
.help-doc-loading {
    color: var(--text-muted);
    font-style: italic;
    padding: 2rem;
    text-align: center;
}
.help-doc-error {
    color: var(--error);
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: 4px;
    text-align: center;
}

@media (max-width: 768px) {
    .search-panel {
        padding: 10px;
    }
    .search-input-wrapper {
        min-width: 100%;
    }
    .search-options {
        width: 100%;
        flex-wrap: wrap;
    }
}

/* ============================================
   ZIP UPLOAD MODAL
   ============================================ */

.zip-drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1rem;
    border: 2px dashed var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.zip-drop-zone:hover,
.zip-drop-zone.drag-over {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.zip-drop-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.zip-drop-text {
    font-size: var(--font-base);
    font-weight: 600;
    color: var(--text-primary);
}

.zip-drop-hint {
    font-size: var(--font-sm);
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.zip-loading {
    font-size: var(--font-base);
    color: var(--text-secondary);
    padding: 1rem;
}

.zip-stats {
    font-size: var(--font-sm);
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.zip-select-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.zip-select-controls .btn-sm {
    font-size: var(--font-sm);
    padding: 2px 8px;
}

.zip-file-list {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 4px;
    margin-bottom: 0.75rem;
}

.zip-file-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 4px 8px;
    font-size: var(--font-sm);
    cursor: pointer;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
}

.zip-file-item:hover {
    background: var(--bg-secondary);
}

.zip-file-item:last-child {
    border-bottom: none;
}

.zip-file-binary {
    opacity: 0.5;
}

.zip-file-icon {
    flex-shrink: 0;
}

.zip-file-path {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
}

.zip-file-size {
    flex-shrink: 0;
    color: var(--text-muted);
    font-size: 11px;
}

.zip-file-badge {
    flex-shrink: 0;
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 3px;
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

.zip-badge-new {
    background: rgba(78, 201, 176, 0.2);
    color: var(--success, #4ec9b0);
}

.zip-badge-modified {
    background: rgba(220, 180, 60, 0.2);
    color: var(--warning, #dcb43c);
}

.zip-badge-unchanged {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    opacity: 0.6;
}

.zip-field {
    margin-bottom: 0.75rem;
}

.zip-field label {
    display: block;
    font-size: var(--font-sm);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.zip-field-hint {
    font-weight: 400;
    color: var(--text-muted);
}

.zip-field input[type="text"] {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: var(--font-sm);
    font-family: inherit;
}

.zip-field input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
}

.zip-progress {
    margin-top: 0.75rem;
}

.zip-progress-bar {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

.zip-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    width: 0%;
    transition: width 0.2s;
}

.zip-progress-text {
    font-size: var(--font-sm);
    color: var(--text-muted);
    margin-top: 0.35rem;
    text-align: center;
}

/* ── Resizable modals ── */
.modal-resizable {
    position: relative;
    resize: both;
    overflow: hidden;
    min-width: 360px;
    min-height: 300px;
    max-width: 90vw;
    max-height: 85vh;
    width: auto;
}

.modal-resizable .modal-body {
    flex: 1;
    overflow-y: auto;
}

/* Subtle resize grip hint */
.modal-resizable::after {
    content: '';
    position: absolute;
    bottom: 3px;
    right: 3px;
    width: 12px;
    height: 12px;
    border-right: 2px solid var(--text-muted);
    border-bottom: 2px solid var(--text-muted);
    opacity: 0.3;
    pointer-events: none;
}

/* ── Compact markdown in issue views ── */
.issue-focus-comment-body.preview-markdown h1,
.issue-focus-comment-body.preview-markdown h2,
.issue-focus-comment-body.preview-markdown h3 {
    font-size: 1.1em;
    margin: 0.3em 0;
    border: none;
    padding: 0;
}

.issue-focus-comment-body.preview-markdown p {
    margin: 0.3em 0;
}

.issue-focus-comment-body.preview-markdown pre {
    padding: 0.5rem;
    margin: 0.4rem 0;
}

#issueDetailComments .preview-markdown p,
.modal-comment-item .comment-body.preview-markdown p { margin: 0.3em 0; }
#issueDetailComments .preview-markdown pre,
.modal-comment-item .comment-body.preview-markdown pre { padding: 0.5rem; margin: 0.4rem 0; }

/* ── PR Detail file items ── */
.pr-file-item > div:first-child:hover {
    background: var(--bg-hover);
}

/* ============================================
   ISSUE & PR DETAIL MODAL POLISH
   ============================================ */

/* ── Shared meta row ── */
.modal-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.6rem;
    align-items: center;
    font-size: var(--font-md);
    line-height: 1;
}

.modal-meta-row .meta-sep {
    color: var(--border-light);
    font-size: var(--font-xs);
    user-select: none;
}

.modal-meta-item {
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

/* ── Shared section header (collapsible) ── */
.modal-section-header {
    cursor: pointer;
    font-weight: 600;
    font-size: var(--font-md);
    color: var(--text-secondary);
    user-select: none;
    padding: 0.4rem 0;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.modal-section-header:hover {
    color: var(--text-primary);
}

.modal-section-header .section-count {
    font-weight: normal;
    color: var(--text-muted);
}

.modal-section-header .section-chevron {
    font-size: 10px;
    transition: transform 0.15s;
    display: inline-block;
    color: var(--text-muted);
}

details[open] > .modal-section-header .section-chevron {
    transform: rotate(90deg);
}

/* ── Shared comment collapsible ── */
.modal-comment-item {
    border-left: 2px solid var(--border);
    padding-left: 0.6rem;
    margin-bottom: 0.5rem;
    transition: border-color 0.15s;
}

.modal-comment-item:hover {
    border-color: var(--border-light);
}

.modal-comment-item > summary {
    cursor: pointer;
    font-size: var(--font-md);
    color: var(--text-muted);
    padding: 0.2rem 0;
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.modal-comment-item > summary::-webkit-details-marker { display: none; }

.modal-comment-item > summary .comment-chevron {
    font-size: 10px;
    transition: transform 0.15s;
    display: inline-block;
    flex-shrink: 0;
}

.modal-comment-item[open] > summary .comment-chevron {
    transform: rotate(90deg);
}

.modal-comment-item > summary strong {
    color: var(--text-primary);
}

.modal-comment-item > summary .comment-preview {
    font-size: var(--font-xs);
    color: var(--text-muted);
    margin-left: auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 40%;
}

.modal-comment-item .comment-body {
    font-size: var(--font-md);
    max-height: 200px;
    overflow-y: auto;
    padding-top: 0.3rem;
}

/* ── Issue detail specific ── */
.issue-detail-section {
    border-top: 1px solid var(--border);
    padding-top: 0.3rem;
}

.issue-detail-section > summary {
    list-style: none;
}

.issue-detail-section > summary::-webkit-details-marker { display: none; }

.issue-detail-body {
    font-size: var(--font-base);
    line-height: 1.6;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.75rem;
    background: var(--bg-primary);
    min-height: 40px;
    max-height: 40vh;
    overflow-y: auto;
    margin-top: 0.3rem;
}

.issue-detail-comments {
    flex-shrink: 0;
    max-height: 40vh;
    overflow-y: auto;
    padding-top: 0.25rem;
}

.issue-detail-branch-info {
    display: none;
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: var(--font-md);
    flex-shrink: 0;
    border: 1px solid;
}

.issue-detail-branch-info.branch-create {
    background: color-mix(in srgb, var(--bg-secondary) 85%, var(--success));
    border-color: color-mix(in srgb, var(--border) 70%, var(--success));
    color: var(--text-primary);
}

.issue-detail-branch-info.branch-exists {
    background: color-mix(in srgb, var(--bg-secondary) 85%, var(--accent));
    border-color: color-mix(in srgb, var(--border) 70%, var(--accent));
    color: var(--text-primary);
}

.issue-detail-branch-info.branch-active {
    background: color-mix(in srgb, var(--bg-secondary) 85%, var(--success));
    border-color: color-mix(in srgb, var(--border) 60%, var(--success));
    color: var(--success);
}

/* ── PR detail specific ── */
.pr-detail-body {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.75rem;
    background: var(--bg-primary);
    min-height: 40px;
    max-height: 30%;
    overflow-y: auto;
    font-size: var(--font-base);
    line-height: 1.6;
}

.pr-detail-branches {
    font-size: var(--font-sm);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.pr-detail-branches code {
    background: var(--bg-primary);
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: var(--font-sm);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.pr-detail-branches .branch-arrow {
    color: var(--text-muted);
    font-size: var(--font-sm);
}

/* PR sections */
.pr-detail-section {
    border-top: 1px solid var(--border);
    padding-top: 0.5rem;
}

.pr-detail-section > summary {
    list-style: none;
}

.pr-detail-section > summary::-webkit-details-marker { display: none; }

/* PR comment add section */
.pr-add-comment {
    border-top: 1px solid var(--border);
    padding-top: 0.6rem;
}

.pr-add-comment label {
    font-size: var(--font-md);
    font-weight: 600;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 0.35rem;
}

.pr-add-comment .comment-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.4rem;
}

.pr-add-comment .comment-actions .btn {
    font-size: var(--font-sm);
}

/* PR merge controls (footer) */
.pr-merge-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* ── PR file diff improvements ── */
.pr-file-diff pre {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.5rem;
    overflow-x: auto;
    font-size: var(--font-xs);
    line-height: 1.5;
    max-height: 300px;
    overflow-y: auto;
    margin: 0;
}

/* ── Modal footer improvements ── */
.modal-footer-split {
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.modal-footer-left {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.modal-footer-right {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* ============================================
   ONBOARDING WIZARD
   ============================================ */

.onboard-overlay {
    z-index: 10000;
}

.onboard-modal {
    max-width: 520px;
    width: 90vw;
    padding: 2rem;
    text-align: center;
    max-height: 85vh;
    overflow-y: auto;
}

.onboard-dots {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.onboard-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-light);
    transition: all 0.2s;
}

.onboard-dot.active {
    background: var(--accent);
    transform: scale(1.3);
}

.onboard-dot.done {
    background: var(--success);
}

.onboard-step {
    display: none;
}

.onboard-step.active {
    display: block;
}

.onboard-step h2 {
    font-size: var(--font-2xl);
    font-weight: 600;
    margin: 0 0 0.5rem;
    color: var(--text-primary);
}

.onboard-hero {
    font-size: 48px;
    margin-bottom: 0.75rem;
    line-height: 1;
}

.onboard-subtitle {
    color: var(--text-secondary);
    font-size: var(--font-base);
    margin: 0 0 1.5rem;
    line-height: 1.5;
}

.onboard-subtitle a {
    color: var(--accent);
}

/* Welcome paths */
.onboard-paths {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.onboard-path {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    transition: all 0.15s;
}

.onboard-path:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
}

.onboard-path-icon {
    font-size: 24px;
    flex-shrink: 0;
    width: 36px;
    text-align: center;
}

.onboard-path-label {
    font-weight: 600;
    font-size: var(--font-base);
    color: var(--text-primary);
}

.onboard-path-desc {
    font-size: var(--font-md);
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Forms */
.onboard-form {
    text-align: left;
    margin-bottom: 1.25rem;
}

.onboard-form .form-group {
    margin-bottom: 0.75rem;
}

.onboard-form label {
    display: block;
    font-size: var(--font-md);
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.onboard-form input,
.onboard-form select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: var(--font-base);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    box-sizing: border-box;
}

.onboard-form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    justify-content: flex-end;
}

/* Status messages */
.onboard-status {
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: var(--font-md);
    text-align: left;
}

.onboard-status-success {
    background: rgba(78, 201, 176, 0.15);
    color: var(--success);
}

.onboard-status-error {
    background: rgba(241, 76, 76, 0.15);
    color: var(--error);
}

.onboard-status-info {
    background: rgba(14, 125, 202, 0.15);
    color: var(--accent);
}

/* Navigation */
.onboard-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
}

.onboard-skip,
.btn-link {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: var(--font-md);
    cursor: pointer;
    padding: 0.25rem;
    font-family: var(--font-sans);
}

.onboard-skip:hover,
.btn-link:hover {
    color: var(--text-primary);
}

/* Done step */
.onboard-next-steps {
    text-align: left;
    margin: 0 auto 1.5rem;
    max-width: 380px;
}

.onboard-next-item {
    padding: 0.5rem 0;
    font-size: var(--font-base);
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
}

.onboard-next-item:last-child {
    border-bottom: none;
}

.onboard-done-btn {
    padding: 0.6rem 2rem;
    font-size: var(--font-lg);
}

/* ============================================
   MARKDOWN VIEWER MODAL
   ============================================ */

.md-viewer-modal {
    max-width: min(90vw, 720px);
    max-height: 85vh;
}

#mdViewerOverlay {
    z-index: 10001;              /* above onboarding overlay (10000) */
}

.md-viewer-body {
    font-size: var(--font-base);
    line-height: 1.6;
    color: var(--text-primary);
}

.md-viewer-body h1,
.md-viewer-body h2,
.md-viewer-body h3,
.md-viewer-body h4 {
    color: var(--text-primary);
    font-weight: 600;
    margin: 1.2em 0 0.5em;
    line-height: 1.3;
}

.md-viewer-body h1 { font-size: 1.5em; border-bottom: 1px solid var(--border); padding-bottom: 0.3em; }
.md-viewer-body h2 { font-size: 1.3em; border-bottom: 1px solid var(--border); padding-bottom: 0.25em; }
.md-viewer-body h3 { font-size: 1.15em; }
.md-viewer-body h1:first-child { margin-top: 0; }

.md-viewer-body p {
    margin: 0.5em 0;
}

.md-viewer-body ul,
.md-viewer-body ol {
    padding-left: 1.5em;
    margin: 0.5em 0;
}

.md-viewer-body li { margin: 0.25em 0; }

.md-viewer-body table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.75em 0;
    font-size: 0.92em;
}

.md-viewer-body th,
.md-viewer-body td {
    border: 1px solid var(--border);
    padding: 0.4em 0.65em;
    text-align: left;
}

.md-viewer-body th {
    background: var(--bg-tertiary);
    font-weight: 600;
}

.md-viewer-body tr:hover td {
    background: var(--bg-hover);
}

.md-viewer-body code {
    background: var(--bg-primary);
    padding: 0.15em 0.4em;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.9em;
}

.md-viewer-body pre {
    background: var(--bg-primary);
    padding: 0.75em;
    border-radius: 4px;
    overflow-x: auto;
    margin: 0.5em 0;
    font-family: var(--font-mono);
    font-size: 0.9em;
    line-height: 1.4;
}

.md-viewer-body pre code {
    background: none;
    padding: 0;
}

.md-viewer-body hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5em 0;
}

.md-viewer-body strong { color: var(--text-primary); }

.md-viewer-body a {
    color: var(--accent);
    text-decoration: none;
}
.md-viewer-body a:hover { text-decoration: underline; }

.md-viewer-body blockquote {
    border-left: 3px solid var(--accent);
    padding: 0.25em 0.75em;
    margin: 0.5em 0;
    color: var(--text-secondary);
    background: var(--bg-primary);
    border-radius: 0 4px 4px 0;
}

/* ══════════════════════════════════════════════
   RELEASE MANAGER MODAL
   ══════════════════════════════════════════════ */

.modal-release {
    max-width: 680px;
    width: 90vw;
}

/* ── Compare row ── */
.release-compare-row {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.release-ref-picker {
    flex: 1;
    min-width: 140px;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.release-arrow {
    font-size: 1.3rem;
    color: var(--text-muted);
    padding-bottom: 0.2rem;
    flex-shrink: 0;
}

.release-select {
    width: 100%;
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: var(--font-base);
}

.release-label {
    font-size: var(--font-sm);
    font-weight: 600;
    color: var(--text-secondary);
}

/* ── Notes textarea ── */
.release-notes-section {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.release-textarea {
    width: 100%;
    min-height: 200px;
    max-height: 50vh;
    padding: 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-mono, 'Fira Code', monospace);
    font-size: var(--font-sm);
    line-height: 1.5;
    resize: vertical;
}

.release-textarea:focus {
    outline: none;
    border-color: var(--accent, #58a6ff);
    box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.2);
}

/* ── Meta row ── */
.release-meta-row {
    display: flex;
    gap: 0.75rem;
}

.release-field {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.release-input {
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: var(--font-base);
}

.release-input:focus {
    outline: none;
    border-color: var(--accent, #58a6ff);
}

/* ── Options ── */
.release-options-row {
    display: flex;
    gap: 1rem;
}

.release-checkbox {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: var(--font-sm);
    color: var(--text-secondary);
    cursor: pointer;
}

.release-checkbox input[type="checkbox"] {
    accent-color: var(--accent, #58a6ff);
}

/* ── Status ── */
.release-status {
    font-size: var(--font-sm);
    color: var(--text-muted);
    min-height: 1.2em;
}

.release-status a {
    color: var(--accent, #58a6ff);
    text-decoration: none;
}

.release-status a:hover {
    text-decoration: underline;
}

.release-status-error {
    color: var(--danger, #f85149);
}

/* ── Mobile ── */
@media (max-width: 768px) {
    .modal-release {
        max-width: 95vw;
    }

    .release-compare-row {
        flex-direction: column;
        align-items: stretch;
    }

    .release-arrow {
        text-align: center;
        padding: 0;
    }

    .release-meta-row {
        flex-direction: column;
    }
}
