*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Fix numbered and bulleted list alignment */
ol, ul {
    margin-left: 0;
    padding-left: 20px;
}

ol li, ul li {
    margin-left: 0;
    padding-left: 4px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
}

/* Top bar */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    z-index: 100;
}

.project-title {
    font-size: 16px;
    font-weight: 600;
}

.top-bar-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Stats Bar */
.stats-bar {
    display: flex;
    gap: 16px;
    align-items: center;
    padding: 4px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 12px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-value {
    color: var(--text-primary);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* Responsive stats - hide some on smaller screens */
@media (max-width: 768px) {
    .stats-bar {
        gap: 12px;
    }
    .stats-bar .stat-item:nth-child(3),
    .stats-bar .stat-item:nth-child(4) {
        display: none;
    }
}

@media (max-width: 600px) {
    .stats-bar .stat-item:nth-child(2),
    .stats-bar .stat-item:nth-child(5) {
        display: none;
    }
}

/* Buttons */
.btn {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.15s;
}

.btn:hover {
    background: var(--bg-hover);
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

.btn-warning {
    background: var(--warning);
    color: #fff;
    border-color: var(--warning);
}

.btn-icon {
    padding: 6px 10px;
    font-size: 16px;
    line-height: 1;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
}

/* Notification bell */
#notifications-btn {
    position: relative;
}

.notification-badge {
    position: absolute;
    top: 0;
    right: 0;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    font-size: 10px;
    font-weight: bold;
    line-height: 16px;
    text-align: center;
    color: #fff;
    background: #e53e3e;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

#notifications-btn.has-notifications .bell-icon {
    animation: bell-shake 0.5s ease-in-out;
}

@keyframes bell-shake {
    0%, 100% { transform: rotate(0); }
    25% { transform: rotate(10deg); }
    75% { transform: rotate(-10deg); }
}

/* Notification dialog */
.notification-list {
    max-height: 400px;
    overflow-y: auto;
    padding: 8px 0;
}

.notification-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 24px;
}

.notification-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
}

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

.notification-icon {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    color: #fff;
}

.notification-error .notification-icon {
    background: #e53e3e;
}

.notification-warning .notification-icon {
    background: #d69e2e;
}

.notification-info .notification-icon {
    background: #3182ce;
}

.notification-body {
    flex: 1;
    min-width: 0;
}

.notification-message {
    display: block;
    font-size: 13px;
    word-break: break-word;
}

.notification-meta {
    display: block;
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.notification-dismiss {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    padding: 0 4px;
    line-height: 1;
}

.notification-dismiss:hover {
    color: var(--text-primary);
}

.notification-action {
    display: inline-block;
    padding: 2px 8px;
    font-size: 0.75rem;
    border-radius: 4px;
    border: 1px solid var(--accent);
    background: transparent;
    color: var(--accent);
    cursor: pointer;
    vertical-align: middle;
}

.notification-action:hover {
    background: var(--accent);
    color: #fff;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

.btn-xs {
    padding: 2px 8px;
    font-size: 11px;
    border-radius: 3px;
}

/* Theme toggle icons — show only the icon matching the user preference */
.theme-icon-auto,
.theme-icon-light,
.theme-icon-dark {
    display: none;
}

[data-theme-preference="auto"] .theme-icon-auto {
    display: inline;
}

[data-theme-preference="light"] .theme-icon-light {
    display: inline;
}

[data-theme-preference="dark"] .theme-icon-dark {
    display: inline;
}

/* Spinner — top arc inherits the parent's text color so the spinner tints
   match status badges (Running=accent, Resolving conflicts/Reviewing=warning). */
.spinner {
    display: inline-block;
    width: 10px;
    height: 10px;
    border: 2px solid var(--text-muted);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Tooltips — use JS positioning to escape overflow containers */
.tooltip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-hover);
    border-radius: 50%;
    cursor: help;
    vertical-align: middle;
    margin-left: 4px;
}

.tooltip-popup {
    position: fixed;
    background: var(--text-primary);
    color: var(--bg-primary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 400;
    line-height: 1.5;
    white-space: pre-line;
    width: max-content;
    max-width: 340px;
    z-index: 10000;
    box-shadow: var(--shadow-lg);
    pointer-events: none;
}

.tooltip-popup pre {
    white-space: pre;
    overflow-x: auto;
}

.tooltip-popup b {
    font-weight: 600;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--text-secondary);
}

.form-group label.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-weight: 400;
}

.form-group label.checkbox-label input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.form-group select,
.form-group input,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
}

.form-group textarea {
    resize: vertical;
    font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
    font-size: 13px;
}

.form-group label:has(input[type="checkbox"]) {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.form-group label input[type="checkbox"] {
    margin-left: auto;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

.form-group select:focus,
.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 113, 227, 0.2);
}

/* Detail view */
.detail-body {
    padding: 20px;
    min-height: 200px;
    line-height: 1.7;
    overflow-y: auto;
    max-height: 60vh;
}

.detail-body h1, .detail-body h2, .detail-body h3 {
    margin-top: 16px;
    margin-bottom: 8px;
}

.detail-body p {
    margin-bottom: 12px;
}

.detail-body code {
    background: var(--bg-hover);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.9em;
}

.detail-body pre {
    background: var(--bg-hover);
    padding: 12px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin-bottom: 12px;
}

/* Diagram container — override .log-content pre / .detail-body pre styling
 * so the rendered SVG fills the available width on a transparent background. */
.mermaid {
    background: transparent;
    padding: 0;
    margin: 12px 0;
    overflow-x: auto;
    font-family: inherit;
    font-size: inherit;
    white-space: normal;
    min-height: 40px;
}

.mermaid svg {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    height: auto;
}

/* Fallback when mermaid parsing fails — show the raw source with a warning bar. */
.mermaid-failed {
    border-left: 3px solid var(--warning);
    padding-left: 8px;
    margin: 12px 0;
}

.mermaid-failed pre {
    margin: 0;
}

.detail-model-info {
    margin-top: 16px;
    padding: 8px 12px;
    background: var(--bg-hover);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--accent);
    font-size: 0.9em;
    color: var(--text-muted);
}

.provider-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 3px;
    vertical-align: middle;
    margin-left: 6px;
    letter-spacing: 0.3px;
}

.provider-badge-anthropic {
    background: rgba(204, 120, 50, 0.15);
    color: #cc7832;
}

.provider-badge-ollama {
    background: rgba(100, 180, 100, 0.15);
    color: #64b464;
}

.card-model-badge {
    font-size: 10px;
    color: var(--text-muted);
    padding: 1px 5px;
    background: var(--bg-hover);
    border-radius: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.ollama-status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

.ollama-status-dot.connected { background: #4caf50; }
.ollama-status-dot.disconnected { background: #f44336; }
.ollama-status-dot.checking { background: #ff9800; animation: pulse 1s infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.detail-git-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-info-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.sha-text {
    font-family: var(--font-mono, 'SF Mono', 'Menlo', 'Monaco', monospace);
    font-size: 0.85em;
    padding: 1px 5px;
    background: var(--bg-main);
    border-radius: 3px;
    user-select: all;
}

.copy-sha-btn {
    background: none;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    cursor: pointer;
    padding: 3px 4px;
    line-height: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    color: var(--text-secondary, #666);
    opacity: 0.6;
    transition: opacity 0.15s;
}

.copy-sha-btn:hover {
    opacity: 1;
    background: var(--bg-hover);
}

.detail-log {
    border-top: 1px solid var(--border-light);
    padding: 12px 20px;
    max-height: 400px;
    overflow-y: auto;
    font-size: 13px;
    color: var(--text-secondary);
}

.detail-resume-form {
    border-top: 1px solid var(--border-light);
    padding: 12px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.detail-resume-form label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.detail-resume-form textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 8px;
    font-family: inherit;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text);
    resize: vertical;
}

.detail-resume-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.log-entry {
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
}

.log-entry:last-child {
    border-bottom: none;
}

.log-meta {
    font-family: monospace;
    font-size: 11px;
    color: var(--text-muted);
}

.log-content {
    margin-top: 4px;
    color: var(--text-primary);
    line-height: 1.6;
}

.log-content p {
    margin-bottom: 8px;
}

.log-content pre {
    background: var(--bg-hover);
    padding: 8px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-size: 12px;
}

.log-content code {
    background: var(--bg-hover);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.9em;
}

/* Thinking entries */
.log-entry-thinking .log-content {
    color: var(--text-secondary);
    font-style: italic;
    border-left: 3px solid var(--accent);
    padding-left: 10px;
}

/* Tool use entries */
.log-entry-tool_use .log-content {
    font-family: monospace;
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-hover);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
}

/* System entries */
.log-entry-system .log-content {
    color: var(--text-muted);
    font-size: 12px;
}

/* YOLO command entries */
.log-entry-yolo_command {
    border-left: 3px solid var(--warning);
    padding-left: 8px;
}

.log-entry-yolo_command .log-meta {
    color: var(--warning);
}

.log-entry-yolo_command .log-content {
    font-family: monospace;
    font-size: 12px;
    color: var(--warning);
    background: color-mix(in srgb, var(--warning) 8%, var(--bg-primary));
    padding: 6px 10px;
    border-radius: var(--radius-sm);
}

/* Error entries */
.log-entry-error .log-content {
    color: var(--danger);
}

/* Attachments */
.attachments-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.attachment-card {
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.attachment-img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    cursor: pointer;
    display: block;
}

.attachment-img:hover {
    opacity: 0.85;
}

.attachment-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.attachment-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachments-actions {
    margin-top: 12px;
}

/* Annotation canvas */
.annotate-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 20px;
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap;
}

.annotate-tools {
    display: flex;
    gap: 4px;
}

.annotate-tool {
    min-width: 32px;
    text-align: center;
    font-size: 16px;
    padding: 4px 8px;
}

.annotate-tool.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.annotate-options {
    display: flex;
    gap: 8px;
    align-items: center;
}

.annotate-options input[type="color"] {
    width: 30px;
    height: 28px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: var(--bg-input);
}

.annotate-options select {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 12px;
}

.annotate-fill-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
}

.annotate-fill-toggle input[type="checkbox"] {
    margin: 0;
}

.annotate-fill-toggle input[type="color"] {
    width: 22px;
    height: 22px;
    padding: 1px;
    border: 1px solid var(--border);
    border-radius: 3px;
    cursor: pointer;
    background: transparent;
}

.annotate-separator {
    width: 1px;
    height: 18px;
    background: var(--border-color);
    margin: 0 4px;
}

.annotate-layer-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
}

.annotate-layer-toggle input[type="checkbox"] {
    margin: 0;
}

.annotate-layer-toggle:has(input:checked) {
    color: var(--accent);
    font-weight: 600;
}

.annotate-text-editor {
    box-sizing: border-box;
    line-height: 1.3;
}

.annotate-hint {
    color: var(--text-muted);
    font-size: 12px;
    margin-left: auto;
}

/* Fix for annotation text rendering overlaps */
.annotate-canvas-wrap canvas {
    /* Additional properties to prevent rendering artifacts */
    backface-visibility: hidden;
    perspective: 1000;
}

/* Prevent text selection conflicts with canvas drawing */
.annotate-canvas-wrap {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.annotate-canvas-wrap {
    padding: 12px 20px;
    overflow: auto;
    max-height: 60vh;
    position: relative;
    z-index: 1;
    background: var(--bg-primary); /* Ensure clean background */
}

.annotate-canvas-wrap canvas {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: block;
    cursor: crosshair;
    position: relative;
    z-index: 10; /* Increased z-index to prevent overlap */
    /* Prevent canvas scaling issues that cause misalignment */
    image-rendering: -moz-crisp-edges;
    image-rendering: -webkit-crisp-edges;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    /* Ensure crisp rendering without blur */
    transform: translateZ(0);
}

/* Clarification dialog */
.clarify-prompt {
    background: var(--bg-hover);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--accent);
    line-height: 1.6;
    margin-top: 4px;
    max-height: 400px;
    overflow-y: auto;
}

.clarify-context {
    background: var(--bg-secondary);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--text-muted);
    line-height: 1.6;
    margin-top: 4px;
    max-height: 320px;
    overflow-y: auto;
    font-size: 0.95em;
    color: var(--text-secondary);
}

.clarify-context p { margin: 0 0 8px 0; }
.clarify-context p:last-child { margin-bottom: 0; }
.clarify-context strong { color: var(--text-primary); }
.clarify-context code {
    background: var(--bg-hover);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.9em;
}
.clarify-context pre {
    background: var(--bg-hover);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 8px 0;
}
.clarify-context ul, .clarify-context ol {
    margin: 4px 0 8px 0;
    padding-left: 20px;
}
.clarify-context li { margin-bottom: 4px; }

.clarify-prompt p {
    margin: 0 0 8px 0;
}

.clarify-prompt p:last-child {
    margin-bottom: 0;
}

.clarify-prompt strong {
    color: var(--text-primary);
}

.clarify-prompt code {
    background: var(--bg-secondary);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.9em;
}

.clarify-prompt pre {
    background: var(--bg-secondary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 8px 0;
}

.clarify-prompt ul, .clarify-prompt ol {
    margin: 4px 0 8px 0;
    padding-left: 20px;
}

.clarify-prompt li {
    margin-bottom: 4px;
}

.clarify-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 0 8px 0;
}

/* Diff viewer */
.diff-empty {
    color: var(--text-muted);
    padding: 20px;
    text-align: center;
}

.diff-file {
    margin-bottom: 8px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.diff-file-header {
    padding: 8px 12px;
    background: var(--bg-hover);
    font-family: monospace;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}

.diff-file-header:hover {
    background: var(--border-light);
}

.diff-file-body {
    overflow-x: auto;
}

.diff-line {
    padding: 1px 12px;
    font-family: monospace;
    font-size: 12px;
    white-space: pre;
    line-height: 1.5;
}

.diff-add {
    background: rgba(52, 199, 89, 0.15);
    color: var(--success);
}

.diff-del {
    background: rgba(255, 59, 48, 0.15);
    color: var(--danger);
}

.diff-hunk {
    color: var(--accent);
    background: rgba(0, 113, 227, 0.08);
}

/* Changed files list */
.changed-files-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.file-badge {
    font-family: monospace;
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--bg-hover);
    border: 1px solid var(--border-light);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.file-badge:hover {
    background: var(--bg-tertiary, var(--bg-hover));
    border-color: var(--text-muted);
}

.file-added {
    color: var(--success);
    background: rgba(52, 199, 89, 0.1);
    border-color: rgba(52, 199, 89, 0.3);
}

.file-deleted {
    color: var(--danger);
    background: rgba(255, 59, 48, 0.1);
    border-color: rgba(255, 59, 48, 0.3);
}

.file-modified {
    color: var(--accent);
    background: rgba(0, 113, 227, 0.08);
    border-color: rgba(0, 113, 227, 0.2);
}

/* Review dialog */
.review-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-light);
    padding: 0 20px;
}

.review-tab {
    padding: 8px 16px;
    border: none;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.review-tab:hover {
    color: var(--text-primary);
}

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

/* Ensure count badges inside tabs don't overlap with tab borders */
.review-tab .column-count {
    position: static;
    z-index: auto;
    vertical-align: middle;
    margin-left: 4px;
}

.review-content {
    padding: 20px;
    overflow-y: auto;
    max-height: 60vh;
}

.review-actions {
    display: flex;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-light);
    justify-content: flex-end;
}

/* Review file browser */
.review-file-browser {
    display: grid;
    grid-template-columns: minmax(220px, 280px) 1fr;
    height: 62vh;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    overflow: hidden;
}

.rfb-tree-panel {
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
}

.rfb-tree-header {
    padding: 8px;
    border-bottom: 1px solid var(--border-light);
}

.rfb-filter-input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 12px;
    outline: none;
    box-sizing: border-box;
}

.rfb-filter-input:focus {
    border-color: var(--accent);
}

.rfb-tree {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}

.rfb-tree-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-primary);
    white-space: nowrap;
    user-select: none;
}

.rfb-tree-item:hover {
    background: var(--bg-hover);
}

.rfb-tree-item.active {
    background: rgba(0, 113, 227, 0.1);
    color: var(--accent);
}

.rfb-tree-item.focused {
    outline: 1px solid var(--accent);
    outline-offset: -1px;
}

.rfb-tree-item .tree-arrow {
    font-size: 8px;
    transition: transform 0.15s;
    color: var(--text-muted);
    width: 12px;
    text-align: center;
    flex-shrink: 0;
}

.rfb-tree-item .tree-arrow.expanded {
    transform: rotate(90deg);
}

.rfb-tree-item .tree-icon {
    font-size: 14px;
    flex-shrink: 0;
}

.rfb-tree-item .tree-name {
    overflow: hidden;
    text-overflow: ellipsis;
}

.rfb-tree-children {
    display: none;
}

.rfb-tree-children.expanded {
    display: block;
}

/* Changed file indicators in the tree */
.rfb-tree-item .rfb-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-left: auto;
}

.rfb-status-dot.status-M { background: var(--accent); }
.rfb-status-dot.status-A { background: var(--success); }
.rfb-status-dot.status-D { background: var(--danger); }

.rfb-tree-item.rfb-changed-file .tree-name {
    font-weight: 600;
}

/* Viewer panel */
.rfb-viewer-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-secondary);
}

.rfb-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-light);
    overflow-x: auto;
    min-height: 0;
    flex-shrink: 0;
}

.rfb-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 12px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    flex-shrink: 0;
}

.rfb-tab:hover { background: var(--bg-hover); }

.rfb-tab.active {
    color: var(--text-primary);
    border-bottom-color: var(--accent);
    background: var(--bg-primary);
}

.rfb-tab .rfb-tab-close {
    font-size: 14px;
    line-height: 1;
    opacity: 0.5;
    cursor: pointer;
}

.rfb-tab .rfb-tab-close:hover { opacity: 1; }

.rfb-tab .rfb-tab-status {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.rfb-breadcrumb {
    padding: 4px 12px;
    font-size: 11px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-light);
    display: none;
    flex-shrink: 0;
}

.rfb-breadcrumb.visible { display: block; }

.rfb-breadcrumb .separator {
    margin: 0 3px;
    opacity: 0.5;
}

.rfb-breadcrumb .crumb {
    cursor: pointer;
}

.rfb-breadcrumb .crumb:hover {
    color: var(--accent);
    text-decoration: underline;
}

.rfb-content {
    flex: 1;
    overflow: auto;
    padding: 0;
}

.rfb-content .file-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    gap: 8px;
}

.rfb-content .file-empty-icon {
    font-size: 40px;
}

.rfb-content .file-code-viewer {
    margin: 0;
    border-radius: 0;
}

/* Diff view within file browser */
.rfb-content .rfb-inline-diff {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 12px;
    padding: 0;
}

.rfb-content .rfb-inline-diff .diff-line {
    padding: 0 12px;
    white-space: pre;
    line-height: 1.5;
}

.rfb-content .rfb-inline-diff .diff-add {
    background: rgba(52, 199, 89, 0.12);
    color: var(--text-primary);
}

.rfb-content .rfb-inline-diff .diff-del {
    background: rgba(255, 59, 48, 0.12);
    color: var(--text-primary);
}

.rfb-content .rfb-inline-diff .diff-hunk {
    background: rgba(0, 113, 227, 0.08);
    color: var(--accent);
    padding: 4px 12px;
    margin: 4px 0;
    font-style: italic;
}

/* View mode toggle in file browser */
.rfb-view-toggle {
    display: inline-flex;
    gap: 0;
    margin: 8px 12px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    overflow: hidden;
    flex-shrink: 0;
}

.rfb-view-toggle button {
    padding: 4px 12px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
}

.rfb-view-toggle button:not(:last-child) {
    border-right: 1px solid var(--border-light);
}

.rfb-view-toggle button.active {
    background: var(--accent);
    color: white;
}

.rfb-view-toggle button:hover:not(.active) {
    background: var(--bg-hover);
}

/* GitHub-style inline diff (full file view) */
.inline-diff-outer {
    position: relative;
    height: 100%;
    overflow: hidden;
}

.rfb-inline-diff-full {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 12px;
    overflow: auto;
    height: 100%;
    /* Hide native scrollbar — minimap replaces it */
    scrollbar-width: none; /* Firefox */
}
.rfb-inline-diff-full::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Edge */
}

/* Scrollbar minimap — change location overlay on right edge */
.inline-diff-minimap {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 14px;
    cursor: pointer;
    background: transparent;
    z-index: 2;
    pointer-events: auto;
}

.inline-diff-minimap-marker {
    position: absolute;
    right: 0;
    width: 100%;
    min-height: 2px;
    border-radius: 1px;
}

.inline-diff-minimap-add {
    background: rgba(52, 199, 89, 0.85);
}

.inline-diff-minimap-del {
    background: rgba(255, 59, 48, 0.85);
}

.inline-diff-minimap-viewport {
    position: absolute;
    right: 0;
    width: 100%;
    background: var(--minimap-thumb, rgba(0, 0, 0, 0.4));
    border-radius: 2px;
    pointer-events: auto;
    cursor: grab;
    transition: top 0.05s linear, height 0.05s linear;
}
.inline-diff-minimap-viewport:hover {
    background: var(--minimap-thumb-hover, rgba(0, 0, 0, 0.55));
}
.inline-diff-minimap-viewport.dragging {
    background: var(--minimap-thumb-active, rgba(0, 0, 0, 0.65));
    cursor: grabbing;
    transition: none;
}

.inline-diff-table {
    min-width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
}

.inline-diff-table td {
    padding: 0;
    vertical-align: top;
    line-height: 20px;
}

.inline-diff-gutter {
    width: 50px;
    min-width: 50px;
    max-width: 50px;
    padding: 0 8px 0 0 !important;
    text-align: right;
    color: var(--text-muted);
    opacity: 0.6;
    font-size: 11px;
    user-select: none;
    background: var(--bg-primary);
    border-right: 1px solid var(--border-light);
    box-sizing: border-box;
}

.inline-diff-marker {
    width: 20px;
    min-width: 20px;
    max-width: 20px;
    text-align: center;
    color: var(--text-muted);
    user-select: none;
    font-weight: 600;
}

.inline-diff-content {
    padding: 0 12px 0 4px !important;
    white-space: pre;
}

.inline-diff-content code {
    background: none;
    padding: 0;
    font-size: inherit;
    font-family: inherit;
    color: inherit;
}

/* Row type styles */
.inline-diff-row.inline-diff-add {
    background: rgba(52, 199, 89, 0.12);
}

.inline-diff-row.inline-diff-add .inline-diff-gutter {
    background: rgba(52, 199, 89, 0.2);
    color: var(--success);
    opacity: 1;
}

.inline-diff-row.inline-diff-add .inline-diff-marker {
    color: var(--success);
}

.inline-diff-row.inline-diff-del {
    background: rgba(255, 59, 48, 0.12);
}

.inline-diff-row.inline-diff-del .inline-diff-gutter {
    background: rgba(255, 59, 48, 0.2);
    color: var(--danger);
    opacity: 1;
}

.inline-diff-row.inline-diff-del .inline-diff-marker {
    color: var(--danger);
}

.inline-diff-row.inline-diff-context {
    background: transparent;
}

/* Separator / expand row */
.inline-diff-row.inline-diff-separator td {
    background: var(--bg-hover);
    border-top: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
}

.inline-diff-expand {
    padding: 4px 0 !important;
    text-align: center;
    color: var(--text-muted);
    font-size: 11px;
    user-select: none;
}

.inline-diff-expand-icon {
    opacity: 0.6;
    letter-spacing: 2px;
}

/* Deleted file placeholder */
.rfb-deleted-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--danger);
    gap: 8px;
}

.rfb-deleted-placeholder .rfb-deleted-icon {
    font-size: 40px;
}

/* Link styles for better readability in both light and dark themes */
a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-color: rgba(0, 113, 227, 0.3);
    transition: color 0.15s, text-decoration-color 0.15s;
}

a:hover {
    color: var(--accent-hover);
    text-decoration-color: var(--accent-hover);
}

a:visited {
    color: rgba(0, 113, 227, 0.8);
    text-decoration-color: rgba(0, 113, 227, 0.2);
}

a:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 2px;
}

/* Dark theme link overrides for better contrast */
[data-theme="dark"] a {
    color: #409cff;
    text-decoration-color: rgba(64, 156, 255, 0.4);
}

[data-theme="dark"] a:hover {
    color: #66b3ff;
    text-decoration-color: #66b3ff;
}

[data-theme="dark"] a:visited {
    color: rgba(64, 156, 255, 0.8);
    text-decoration-color: rgba(64, 156, 255, 0.3);
}

/* Auto theme dark mode overrides */
@media (prefers-color-scheme: dark) {
    [data-theme="auto"] a {
        color: #409cff;
        text-decoration-color: rgba(64, 156, 255, 0.4);
    }

    [data-theme="auto"] a:hover {
        color: #66b3ff;
        text-decoration-color: #66b3ff;
    }

    [data-theme="auto"] a:visited {
        color: rgba(64, 156, 255, 0.8);
        text-decoration-color: rgba(64, 156, 255, 0.3);
    }
}

/* ===== Shortcuts Bar ===== */
.shortcuts-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-light);
    gap: 8px;
    min-height: 40px;
}

.shortcuts-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.shortcut-btn {
    padding: 4px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.shortcut-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

.shortcut-btn.shortcut-running {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
    animation: shortcut-pulse 1.5s ease-in-out infinite;
}

.shortcut-btn.shortcut-failed {
    border-color: var(--danger);
    color: var(--danger);
    box-shadow: 0 0 0 1px var(--danger);
}

.shortcut-btn.shortcut-done {
    border-color: var(--success, #4caf50);
    color: var(--success, #4caf50);
}

@keyframes shortcut-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

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

.shortcut-action-btn {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.shortcut-action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Floating add button when bar is hidden */
.shortcuts-add-floating {
    position: fixed;
    bottom: 12px;
    right: 16px;
    z-index: 89;
    padding: 4px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 11px;
    cursor: pointer;
    opacity: 0.5;
    transition: all 0.15s ease;
}

.shortcuts-add-floating:hover {
    opacity: 1;
    border-color: var(--accent);
    color: var(--text-primary);
}

/* Progress dialog content */
.shortcut-cmd-display {
    font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
    font-size: 12px;
    color: var(--text-secondary);
    padding: 6px 10px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    margin-bottom: 8px;
}

.shortcut-status {
    font-size: 13px;
    font-weight: 500;
    padding: 4px 0;
    margin-bottom: 8px;
}

.shortcut-status-running {
    color: var(--accent);
}

.shortcut-status-failed {
    color: var(--danger);
}

.shortcut-status-done {
    color: var(--success, #4caf50);
}

.shortcut-output {
    font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
    font-size: 12px;
    line-height: 1.5;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 12px;
    max-height: 400px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    margin: 0;
}

/* Manage dialog */
.shortcut-manage-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
    gap: 12px;
}

.shortcut-manage-row:last-child {
    border-bottom: none;
}

.shortcut-manage-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.shortcut-manage-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.shortcut-manage-cmd {
    font-size: 12px;
    color: var(--text-secondary);
    font-family: "SF Mono", "Fira Code", monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.shortcut-manage-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* Adjust board layout when shortcuts bar is visible */
body.has-shortcuts .board {
    min-height: calc(100vh - 56px - 40px);
}

body.has-shortcuts .column {
    max-height: calc(100vh - 80px - 40px);
}
