/* ============================================================================
   PROBLEM BUILDER & ISSUES
   Rubric items, prompt issues panel, inline issues, grades
   ============================================================================ */

/* ============================================
   CSS VARIABLES FOR RUBRIC UI
   ============================================ */
:root {
    /* Strategy colors */
    --rb-strategy-llm: #8b5cf6;
    --rb-strategy-llm-bg: rgba(139, 92, 246, 0.15);
    --rb-strategy-markdown: #f59e0b;
    --rb-strategy-markdown-bg: rgba(245, 158, 11, 0.15);
    --rb-strategy-mcp: #3b82f6;
    --rb-strategy-mcp-bg: rgba(59, 130, 246, 0.15);
    --rb-strategy-default: #64748b;
    
    /* Z-index scale */
    --z-sticky: 10;
    --z-dropdown: 100;
    --z-modal: 200;
    
    /* Interactive row */
    --rb-row-height: 40px;
    --rb-row-height-touch: 44px;
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-default: 0.2s ease;
    
    /* Hover states */
    --rb-accent-hover: rgba(96, 165, 250, 0.1);
    
    /* Base colors (using existing palette) */
    --rb-bg-base: #0f172a;
    --rb-bg-surface: #1e293b;
    --rb-border-default: #334155;
    --rb-text-primary: #e2e8f0;
    --rb-text-secondary: #94a3b8;
    --rb-accent: #60a5fa;
}

/* ============================================
   COLLAPSED RUBRIC ROW STYLES
   ============================================ */

.rubric-row {
    display: flex;
    align-items: center;
    min-height: var(--rb-row-height-touch);
    padding: 8px 12px;
    border-bottom: 1px solid rgba(51, 65, 85, 0.5);
    cursor: pointer;
    transition: background var(--transition-default);
    background: transparent;
}

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

.rubric-row:hover {
    background: var(--rb-accent-hover);
}

.rubric-row:focus-visible {
    outline: 2px solid var(--rb-accent);
    outline-offset: -2px;
}

.rubric-row:first-child {
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
}

.rubric-row:last-child {
    border-bottom: none;
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
}

.rubric-row-number {
    width: 24px;
    color: var(--rb-accent);
    font-weight: 600;
    flex-shrink: 0;
    margin-right: 8px;
}

.rubric-row-criterion {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--rb-text-secondary);
    font-size: 0.85rem;
    padding-right: 16px;
    min-width: 0;
}

.rubric-row-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    min-width: 85px;
    white-space: nowrap;
    flex-shrink: 0;
    justify-content: flex-start;
    border: 2px solid transparent;
    transition: border-color 0.15s;
}

/* Validation state - red border for invalid badges */
.rubric-row-badge.badge-invalid {
    border-color: #ef4444;
}

.badge-warning-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    margin-left: 4px;
    background: #ef4444;
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 8px;
}

/* Tooltip warning styles */
.tooltip-warnings {
    background: rgba(239, 68, 68, 0.15);
    border-bottom: 1px solid rgba(239, 68, 68, 0.3);
    padding: 8px 10px;
    margin: -8px -10px 8px -10px;
    border-radius: 6px 6px 0 0;
}

.tooltip-warning {
    font-size: 0.75rem;
    color: #fca5a5;
    padding: 2px 0;
}

.tooltip-warning:first-child {
    padding-top: 0;
}

.tooltip-warning:last-child {
    padding-bottom: 0;
}

.rubric-row-badge.strategy-llm {
    background: var(--rb-strategy-llm-bg);
    color: var(--rb-strategy-llm);
}

.rubric-row-badge.strategy-markdown {
    background: var(--rb-strategy-markdown-bg);
    color: var(--rb-strategy-markdown);
}

.rubric-row-badge.strategy-mcp {
    background: var(--rb-strategy-mcp-bg);
    color: var(--rb-strategy-mcp);
}

.rubric-row-badge.strategy-default {
    background: rgba(100, 116, 139, 0.15);
    color: var(--rb-strategy-default);
}

.rubric-row-badge-icon {
    flex-shrink: 0;
}

.rubric-row-badge-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Badge wrapper for tooltip positioning */
.rubric-row-badge-wrapper {
    position: relative;
    flex-shrink: 0;
}

/* Badge tooltip */
.badge-tooltip {
    position: absolute;
    right: 0;
    min-width: 220px;
    max-width: 300px;
    padding: 10px 12px;
    background: #1e293b;
    border: 1px solid #475569;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    font-size: 0.8rem;
    color: #e2e8f0;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.15s ease;
    pointer-events: none;
    overflow: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Position below (default) */
.badge-tooltip.tooltip-below {
    top: calc(100% + 8px);
    bottom: auto;
    transform: translateY(-4px);
}

.badge-tooltip.tooltip-below::before {
    content: '';
    position: absolute;
    top: -6px;
    bottom: auto;
    right: 16px;
    width: 10px;
    height: 10px;
    background: #1e293b;
    border-left: 1px solid #475569;
    border-top: 1px solid #475569;
    border-right: none;
    border-bottom: none;
    transform: rotate(45deg);
}

/* Position above */
.badge-tooltip.tooltip-above {
    bottom: calc(100% + 8px);
    top: auto;
    transform: translateY(4px);
}

.badge-tooltip.tooltip-above::before {
    content: '';
    position: absolute;
    bottom: -6px;
    top: auto;
    right: 16px;
    width: 10px;
    height: 10px;
    background: #1e293b;
    border-right: 1px solid #475569;
    border-bottom: 1px solid #475569;
    border-left: none;
    border-top: none;
    transform: rotate(45deg);
}

/* Visible state */
.badge-tooltip.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.tooltip-title {
    font-weight: 600;
    color: var(--rb-accent);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--rb-border-default);
}

.tooltip-row {
    display: flex;
    gap: 6px;
    margin-bottom: 4px;
    line-height: 1.4;
    min-width: 0;
}

.tooltip-row:last-child {
    margin-bottom: 0;
}

.tooltip-label {
    color: var(--rb-text-secondary);
    flex-shrink: 0;
}

.tooltip-row > *:not(.tooltip-label) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.tooltip-empty {
    color: var(--rb-text-secondary);
    font-style: italic;
}

/* ============================================================================
   BADGE EDITOR FLYOUT - Full Panel Replacement
   ============================================================================ */

.badge-editor {
    position: fixed;
    width: 920px;
    height: 680px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 40px);
    background: #0f172a;
    border: 1px solid #475569;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transform: scale(0.95);
    transition: all 0.2s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.badge-editor.editor-below {
    transform-origin: top right;
}

.badge-editor.editor-above {
    transform-origin: bottom right;
}

.badge-editor.visible {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}

/* Header with strategy badge */
.badge-editor-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: #1e293b;
    border-bottom: 1px solid #334155;
}

.badge-editor-title {
    font-weight: 600;
    color: #e2e8f0;
    font-size: 0.95rem;
}

/* Criterion navigation dropdown */
.badge-editor-title-dropdown {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    margin: -4px -8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}

.badge-editor-title-dropdown:hover {
    background: #334155;
}

.badge-editor-title-dropdown .title-chevron {
    font-size: 0.7rem;
    color: #94a3b8;
    transition: transform 0.15s;
}

.badge-editor-title-dropdown:hover .title-chevron {
    color: #e2e8f0;
}

.criterion-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 8px;
    background: #1e293b;
    border: 1px solid #475569;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    min-width: 400px;
    max-width: 500px;
    max-height: 350px;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.15s;
    z-index: 10002;
}

.criterion-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.criterion-search {
    padding: 10px 12px;
    background: #0f172a;
    border: none;
    border-bottom: 1px solid #334155;
    border-radius: 8px 8px 0 0;
    color: #e2e8f0;
    font-size: 0.85rem;
    outline: none;
}

.criterion-search::placeholder {
    color: #64748b;
}

.criterion-options {
    overflow-y: auto;
    max-height: 280px;
    padding: 4px 0;
}

.criterion-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.1s;
}

.criterion-option:hover {
    background: #334155;
}

.criterion-option.active {
    background: #1e40af;
}

.criterion-option-num {
    min-width: 24px;
    font-weight: 600;
    color: #60a5fa;
    font-size: 0.8rem;
    text-align: center;
}

.criterion-option.active .criterion-option-num {
    color: #93c5fd;
}

.criterion-option-text {
    flex: 1;
    font-size: 0.8rem;
    color: #cbd5e1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.criterion-option.active .criterion-option-text {
    color: #e2e8f0;
}

.criterion-option-badge {
    flex-shrink: 0;
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 4px;
}

.criterion-option-warning {
    flex-shrink: 0;
    font-size: 0.7rem;
    opacity: 0.9;
}

.criterion-option.has-warning {
    background: rgba(239, 68, 68, 0.1);
}

.criterion-option.has-warning:hover {
    background: rgba(239, 68, 68, 0.2);
}

.badge-editor-strategy-badge {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #334155;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}

.badge-editor-strategy-badge:hover {
    background: #475569;
}

.badge-editor-strategy-badge .strategy-icon {
    font-size: 0.9rem;
}

.badge-editor-strategy-badge .strategy-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: #e2e8f0;
}

.badge-editor-strategy-badge .strategy-chevron {
    font-size: 0.7rem;
    color: #94a3b8;
    margin-left: 4px;
}

/* Strategy dropdown */
.strategy-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: #1e293b;
    border: 1px solid #475569;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    min-width: 180px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.15s;
    z-index: 100;
}

.strategy-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.strategy-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    font-size: 0.85rem;
    color: #e2e8f0;
    cursor: pointer;
    transition: background 0.1s;
}

.strategy-option:first-child {
    border-radius: 7px 7px 0 0;
}

.strategy-option:last-child {
    border-radius: 0 0 7px 7px;
}

.strategy-option:hover {
    background: #334155;
}

.strategy-option.active {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

.badge-editor-close {
    margin-left: auto;
    width: 28px;
    height: 28px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    font-size: 1.2rem;
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s;
}

.badge-editor-close:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* Body: nav + content */
.badge-editor-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
    min-height: 0; /* Important for flex scrolling */
}

/* Left nav sidebar */
.badge-editor-nav {
    width: 140px;
    flex-shrink: 0;
    background: #1e293b;
    border-right: 1px solid #334155;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.badge-editor-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 6px;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s;
}

.badge-editor-nav-item .nav-icon {
    font-size: 1rem;
}

.badge-editor-nav-item .nav-label {
    font-size: 0.85rem;
    color: #94a3b8;
    font-weight: 500;
}

.badge-editor-nav-item:hover {
    background: rgba(96, 165, 250, 0.1);
}

.badge-editor-nav-item:hover .nav-label {
    color: #e2e8f0;
}

.badge-editor-nav-item.active {
    background: rgba(59, 130, 246, 0.15);
}

.badge-editor-nav-item.active .nav-label {
    color: #60a5fa;
}

/* Main content area */
.badge-editor-content {
    flex: 1;
    padding: 16px 20px;
    overflow-y: auto;
    min-height: 0; /* Important for flex scrolling */
}

/* Sliding parameter drawer */
.badge-editor-drawer {
    position: absolute;
    top: 0;
    right: 0;
    width: 320px;
    height: 100%;
    background: #0f172a;
    border-left: 1px solid #475569;
    transform: translateX(100%);
    transition: transform 0.25s ease, visibility 0s 0.25s;
    z-index: 10;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    visibility: hidden;
}

.badge-editor-drawer.open {
    transform: translateX(0);
    visibility: visible;
    transition: transform 0.25s ease, visibility 0s 0s;
}

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: #1e293b;
    border-bottom: 1px solid #334155;
}

.drawer-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: #e2e8f0;
}

.drawer-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.drawer-close:hover {
    color: #ef4444;
}

.drawer-tool-info {
    padding: 10px 16px;
    background: rgba(96, 165, 250, 0.1);
    border-bottom: 1px solid #334155;
}

.drawer-tool-info code {
    font-size: 0.8rem;
    color: #60a5fa;
}

.drawer-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
}

.drawer-params {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.drawer-param-field label {
    display: block;
    font-size: 0.8rem;
    color: #94a3b8;
    margin-bottom: 6px;
}

.drawer-param-field label .required {
    color: #ef4444;
}

.drawer-param-field .panel-input {
    width: 100%;
}

/* Tool config button */
.tool-config-btn {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.8rem;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}

.tool-config-btn:hover:not(:disabled) {
    background: #334155;
    border-color: #60a5fa;
    color: #e2e8f0;
}

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

.tool-config-btn-sm {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 0.75rem;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
    margin-left: 8px;
}

.tool-config-btn-sm:hover {
    background: #334155;
    border-color: #60a5fa;
    color: #e2e8f0;
}

/* Tool config row - tool selector + params button */
.tool-config-row {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.tool-config-main {
    flex: 1;
}

.tool-config-main label,
.tool-config-side label {
    display: block;
    font-size: 0.8rem;
    color: #94a3b8;
    margin-bottom: 6px;
}

.tool-config-side {
    flex-shrink: 0;
}

.badge-editor-panel {
    display: none;
    overflow: visible;
    height: 100%;
}

.badge-editor-panel.active {
    display: flex;
    flex-direction: column;
    overflow: visible;
}

/* Panel that fills available space */
.panel-flex-fill {
    display: flex;
    flex-direction: column;
    height: 100%;
    flex: 1;
}

.panel-field-grow {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.panel-textarea-fill {
    flex: 1;
    min-height: 250px;
    resize: vertical;
}

/* Panel form elements */
.panel-field {
    margin-bottom: 16px;
}

.panel-field:last-child {
    margin-bottom: 0;
}

.panel-field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: #94a3b8;
    margin-bottom: 6px;
}

.panel-field label .required {
    color: #ef4444;
}

.panel-input,
.panel-textarea,
.panel-select {
    width: 100%;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 0.9rem;
    color: #e2e8f0;
    font-family: inherit;
    box-sizing: border-box;
}

.panel-input:focus,
.panel-textarea:focus,
.panel-select:focus {
    outline: none;
    border-color: #60a5fa;
}

.panel-input::placeholder,
.panel-textarea::placeholder {
    color: #64748b;
}

.panel-textarea {
    resize: vertical;
    line-height: 1.5;
}

.panel-hint {
    display: block;
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 4px;
}

.panel-row {
    display: flex;
    gap: 12px;
}

.panel-field-half {
    flex: 1;
}

.panel-tool-btn {
    width: 100%;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 0.9rem;
    color: #e2e8f0;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s;
}

.panel-tool-btn:hover {
    border-color: #60a5fa;
}

.panel-tool-btn.placeholder {
    color: #64748b;
}

/* Toggle buttons */
.panel-toggle-group {
    display: flex;
    gap: 8px;
}

.panel-toggle {
    flex: 1;
    padding: 8px 12px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    font-size: 0.85rem;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.15s;
}

.panel-toggle:hover {
    border-color: #475569;
    color: #e2e8f0;
}

.panel-toggle.active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: white;
}

/* Info box */
.panel-info {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 0.85rem;
    color: #c4b5fd;
    line-height: 1.4;
}

.panel-info .info-icon {
    flex-shrink: 0;
}

.panel-empty {
    padding: 24px;
    text-align: center;
    color: #64748b;
    font-size: 0.9rem;
    background: rgba(30, 41, 59, 0.5);
    border: 1px dashed #334155;
    border-radius: 8px;
}

/* Parameters grid */
.panel-params-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

/* List items */
.panel-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.panel-list-item {
    display: flex;
    gap: 8px;
}

.panel-list-item .panel-input {
    flex: 1;
}

.panel-list-remove,
.panel-row-remove {
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    border: 1px solid #334155;
    border-radius: 4px;
    color: #64748b;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.15s;
    flex-shrink: 0;
}

.panel-list-remove:hover,
.panel-row-remove:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: #ef4444;
    color: #ef4444;
}

.panel-add-btn {
    padding: 8px 12px;
    background: transparent;
    border: 1px dashed #475569;
    border-radius: 6px;
    font-size: 0.85rem;
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s;
}

.panel-add-btn:hover {
    border-color: #60a5fa;
    color: #60a5fa;
}

/* Chain steps section */
.panel-chain-section {
    margin-bottom: 12px;
    overflow: visible;
}

.panel-chain-section > label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: #94a3b8;
    margin-bottom: 8px;
}

/* Chain step card - accordion style */
.chain-step-card {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    margin-bottom: 6px;
    overflow: visible;
}

.chain-step-card.expanded {
    border-color: #475569;
}

.chain-step-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.15s;
}

.chain-step-header:hover {
    background: rgba(96, 165, 250, 0.05);
}

.chain-step-num {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #475569;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #e2e8f0;
    flex-shrink: 0;
}

.chain-step-tool-name {
    flex: 1;
    font-size: 0.85rem;
    font-weight: 500;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chain-step-summary {
    font-size: 0.75rem;
    color: #64748b;
    white-space: nowrap;
}

.chain-step-chevron {
    font-size: 0.7rem;
    color: #64748b;
    transition: transform 0.15s;
}

/* Small icon buttons */
.btn-icon-sm {
    width: 26px;
    height: 26px;
    padding: 0;
    background: transparent;
    border: 1px solid #334155;
    border-radius: 4px;
    color: #64748b;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.15s;
    flex-shrink: 0;
}

.btn-icon-sm:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: #ef4444;
    color: #ef4444;
}

.btn-icon-xs {
    width: 20px;
    height: 20px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 3px;
    color: #64748b;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.15s;
}

.btn-icon-xs:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* Chain step config area (shown when expanded) */
.chain-step-config {
    border-top: 1px solid #334155;
    padding: 14px;
    background: #0f172a;
    overflow: visible;
}

.chain-config-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.chain-config-row:last-child {
    margin-bottom: 0;
}

.chain-config-row > label {
    width: 100px;
    flex-shrink: 0;
    font-size: 0.8rem;
    color: #94a3b8;
}

.chain-config-row > .panel-select,
.chain-config-row > .panel-input {
    flex: 1;
}

.chain-config-section {
    margin-bottom: 14px;
}

.chain-config-section > label {
    display: block;
    font-size: 0.8rem;
    color: #94a3b8;
    margin-bottom: 8px;
}

/* Chain params table - all parameters with source selector */
.chain-params-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    margin-bottom: 10px;
}

.chain-params-table th {
    text-align: left;
    padding: 6px 8px;
    font-weight: 500;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
    border-bottom: 1px solid #334155;
}

.chain-params-table td {
    padding: 6px 8px;
    vertical-align: middle;
    border-bottom: 1px solid #1e293b;
}

.chain-params-table tbody tr:hover {
    background: rgba(96, 165, 250, 0.05);
}

.chain-params-table code {
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    font-size: 0.8rem;
    color: #60a5fa;
}

.chain-params-table .required {
    color: #ef4444;
    margin-left: 4px;
}

.param-name-col {
    width: 30%;
    white-space: nowrap;
}

.param-source-col {
    width: 120px;
}

.param-value-col {
    width: auto;
}

.source-select {
    width: 100%;
    min-width: 95px;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 4px;
    padding: 5px 8px;
    font-size: 0.8rem;
    color: #e2e8f0;
    cursor: pointer;
}

.source-select:focus {
    outline: none;
    border-color: #60a5fa;
}

.param-empty {
    color: #475569;
    font-style: italic;
    font-size: 0.75rem;
}

/* Mapping table (legacy) */
.chain-mapping-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    margin-bottom: 10px;
}

.chain-mapping-table th {
    text-align: left;
    padding: 6px 8px;
    font-weight: 500;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
    border-bottom: 1px solid #334155;
}

.chain-mapping-table td {
    padding: 6px 8px;
    vertical-align: middle;
}

.chain-mapping-table tbody tr:not(.add-row) {
    background: #1e293b;
}

.chain-mapping-table tbody tr:not(.add-row):hover {
    background: #334155;
}

.chain-mapping-table code {
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    font-size: 0.8rem;
    color: #60a5fa;
    background: none;
    padding: 0;
}

.table-input {
    width: 100%;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 0.8rem;
    color: #e2e8f0;
}

.table-input:focus {
    outline: none;
    border-color: #60a5fa;
}

.table-input.mono {
    font-family: 'SF Mono', Monaco, Consolas, monospace;
}

.table-select {
    width: 100%;
    background: transparent;
    border: 1px dashed #475569;
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 0.8rem;
    color: #64748b;
    cursor: pointer;
}

.table-select:hover {
    border-color: #60a5fa;
    color: #94a3b8;
}

.table-select:focus {
    outline: none;
    border-color: #60a5fa;
}

.add-row td {
    padding-top: 8px;
}

/* Response path row */
.chain-extract-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 10px;
    border-top: 1px solid #334155;
}

.chain-extract-row label {
    font-size: 0.75rem;
    color: #64748b;
    white-space: nowrap;
}

.chain-extract-row input {
    flex: 1;
}

/* Mono font helper */
.mono {
    font-family: 'SF Mono', Monaco, Consolas, monospace;
}

.panel-input.mono {
    font-family: 'SF Mono', Monaco, Consolas, monospace;
}

.panel-link-btn {
    background: none;
    border: none;
    padding: 4px 8px;
    font-size: 0.8rem;
    color: #60a5fa;
    cursor: pointer;
    transition: color 0.15s;
}

.panel-link-btn:hover {
    color: #93c5fd;
}

/* Tool selector container - positioned for flyout */
.tool-selector-container {
    position: relative;
}

/* Override panel overflow to allow flyout to show */
.panel-field-tool {
    flex: 2;
    overflow: visible;
}

.panel-field-path {
    flex: 1;
}

/* Tool select button (triggers flyout) */
.tool-select-btn {
    width: 100%;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 0.85rem;
    color: #e2e8f0;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tool-select-btn:hover {
    border-color: #60a5fa;
    background: #334155;
}

.tool-select-btn.placeholder {
    color: #64748b;
}

/* Table */
.panel-table-wrap {
    border: 1px solid #334155;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 8px;
}

.panel-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

/* Panel header row with help text */
.panel-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 12px;
}

.panel-help-text {
    font-size: 0.7rem;
    color: #64748b;
    white-space: nowrap;
    padding-top: 2px;
}

/* Editable table with column management */
.panel-table-editable th {
    padding: 6px 8px;
    vertical-align: top;
}

.col-header {
    display: flex;
    align-items: center;
    gap: 4px;
}

.col-key-btn {
    background: none;
    border: none;
    padding: 2px 4px;
    cursor: pointer;
    font-size: 0.75rem;
    opacity: 0.25;
    filter: grayscale(100%);
    transition: opacity 0.15s, filter 0.15s;
}

.col-key-btn:hover {
    opacity: 0.6;
    filter: grayscale(50%);
}

.col-key-btn.active {
    opacity: 1;
    filter: grayscale(0%);
}

.col-name-input {
    flex: 1;
    min-width: 60px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 3px;
    padding: 4px 6px;
    font-size: 0.8rem;
    font-weight: 500;
    color: #e2e8f0;
}

.col-name-input:hover {
    border-color: #334155;
}

.col-name-input:focus {
    outline: none;
    border-color: #60a5fa;
    background: #0f172a;
}

.col-remove-btn {
    background: none;
    border: none;
    color: #64748b;
    padding: 2px 4px;
    cursor: pointer;
    font-size: 0.9rem;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}

.col-header:hover .col-remove-btn {
    opacity: 1;
}

.col-remove-btn:hover {
    color: #ef4444;
}

.col-add-cell {
    width: 40px;
    text-align: center;
    vertical-align: middle;
}

.col-add-btn {
    background: #1e293b;
    border: 1px dashed #334155;
    border-radius: 4px;
    color: #64748b;
    width: 28px;
    height: 28px;
    padding: 0;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.col-add-btn:hover {
    border-color: #60a5fa;
    color: #60a5fa;
    background: rgba(96, 165, 250, 0.1);
}

.panel-table-empty {
    text-align: center;
    color: #64748b;
    font-style: italic;
    padding: 20px !important;
}

.panel-table th {
    background: #1e293b;
    padding: 8px 10px;
    text-align: left;
    font-weight: 500;
    color: #94a3b8;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.panel-table td {
    padding: 4px;
    border-top: 1px solid #334155;
}

.panel-table td input {
    width: 100%;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 6px 8px;
    color: #e2e8f0;
    font-size: 0.85rem;
}

.panel-table td input:focus {
    outline: none;
    border-color: #60a5fa;
    background: #0f172a;
}

/* Main panel - contains the full StrategyPanels content */
.badge-editor-main .strategy-panel {
    border: none;
    background: transparent;
    margin: 0;
    padding: 0;
}

/* Override ALL strategy panel styles inside badge editor for cohesive look */
.badge-editor .strategy-section,
.badge-editor .strategy-panel {
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
}

/* Section headers inside strategy panel */
.badge-editor .rubric-edit-section {
    padding: 16px 18px;
    border-bottom: 1px solid #334155;
    background: transparent;
}

.badge-editor .rubric-edit-section:last-child {
    border-bottom: none;
}

.badge-editor .rubric-edit-section-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(100, 116, 139, 0.3);
}

.badge-editor .rubric-edit-section-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #64748b;
    font-weight: 600;
}

/* Data type toggle buttons */
.badge-editor .data-type-toggle {
    display: flex;
    gap: 8px;
}

.badge-editor .data-type-btn {
    flex: 1;
    padding: 10px 16px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    font-size: 0.85rem;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.15s ease;
}

.badge-editor .data-type-btn:hover {
    border-color: #475569;
    color: #e2e8f0;
}

.badge-editor .data-type-btn.active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: white;
}

/* Inputs inside strategy panel */
.badge-editor .strategy-input,
.badge-editor .strategy-textarea,
.badge-editor .strategy-select {
    width: 100%;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 0.9rem;
    color: #e2e8f0;
    font-family: inherit;
    box-sizing: border-box;
}

.badge-editor .strategy-input:focus,
.badge-editor .strategy-textarea:focus,
.badge-editor .strategy-select:focus {
    outline: none;
    border-color: #60a5fa;
}

.badge-editor .strategy-input::placeholder,
.badge-editor .strategy-textarea::placeholder {
    color: #64748b;
}

/* Help text */
.badge-editor .strategy-helper,
.badge-editor .rubric-edit-hint {
    display: block;
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 6px;
    line-height: 1.4;
}

/* Tool selector button */
.badge-editor .strategy-tool-btn,
.badge-editor .tool-selector-btn {
    width: 100%;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 0.9rem;
    color: #e2e8f0;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s;
}

.badge-editor .strategy-tool-btn:hover,
.badge-editor .tool-selector-btn:hover {
    border-color: #60a5fa;
}

.badge-editor .strategy-tool-btn.placeholder,
.badge-editor .tool-selector-btn.placeholder {
    color: #64748b;
}

/* Expected rows table */
.badge-editor .expected-rows-table-container {
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #334155;
}

.badge-editor .expected-rows-table {
    background: #1e293b;
}

.badge-editor .expected-rows-table th {
    background: #0f172a;
    padding: 10px 12px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
}

.badge-editor .expected-rows-table td {
    padding: 8px;
    border-top: 1px solid #334155;
}

.badge-editor .expected-rows-table input {
    background: #0f172a;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 6px 8px;
    color: #e2e8f0;
    font-size: 0.85rem;
    width: 100%;
}

.badge-editor .expected-rows-table input:focus {
    outline: none;
    border-color: #60a5fa;
}

/* Empty state */
.badge-editor .expected-rows-empty,
.badge-editor .expected-list-empty {
    background: rgba(30, 41, 59, 0.5);
    border: 1px dashed #334155;
    border-radius: 6px;
    padding: 20px;
    text-align: center;
    color: #64748b;
    font-size: 0.85rem;
}

/* LLM note styling */
.badge-editor .strategy-llm-note {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 8px;
    padding: 14px 16px;
    margin-top: 8px;
}

.badge-editor .strategy-llm-note-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.badge-editor .strategy-llm-note-text {
    font-size: 0.85rem;
    color: #c4b5fd;
    line-height: 1.5;
}

/* Chain steps container */
.badge-editor .chain-steps-container {
    border: 1px solid #334155;
    border-radius: 8px;
    overflow: visible;
}

.badge-editor .chain-step {
    padding: 12px 14px;
    border-bottom: 1px solid #334155;
    background: #1e293b;
}

.badge-editor .chain-step:last-child {
    border-bottom: none;
}

/* Add row / Add step buttons */
.badge-editor .expected-rows-add-btn,
.badge-editor .chain-add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 10px;
    background: transparent;
    border: 1px dashed #475569;
    border-radius: 6px;
    font-size: 0.85rem;
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s;
    margin-top: 10px;
}

.badge-editor .expected-rows-add-btn:hover,
.badge-editor .chain-add-btn:hover {
    border-color: #60a5fa;
    color: #60a5fa;
    background: rgba(96, 165, 250, 0.05);
}

.badge-editor .rubric-edit-section-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
}

/* Make inputs full width in badge editor */
.badge-editor .strategy-input,
.badge-editor .strategy-textarea,
.badge-editor .strategy-select {
    width: 100%;
}

/* Overlay backdrop */
.badge-editor-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
}

.badge-editor-backdrop.visible {
    opacity: 1;
    visibility: visible;
}

.badge-editor-note {
    font-size: 0.85rem;
    color: #64748b;
    margin: 0;
    font-style: italic;
}

.rubric-row-indicators {
    display: flex;
    gap: 8px;
    margin-left: 12px;
    font-size: 0.8rem;
    color: var(--rb-text-secondary);
    flex-shrink: 0;
}

.rubric-row-indicator {
    display: flex;
    align-items: center;
    gap: 2px;
}

/* Delete button on rubric row */
.rubric-row-delete {
    width: 24px;
    height: 24px;
    padding: 0;
    margin-left: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    color: var(--rb-text-secondary);
    cursor: pointer;
    opacity: 0;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.rubric-row:hover .rubric-row-delete {
    opacity: 1;
}

.rubric-row-delete:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.rubric-row-delete:focus-visible {
    opacity: 1;
    outline: 2px solid var(--rb-accent);
    outline-offset: 1px;
}

/* Add criterion button (green plus) */
.rubric-add-btn {
    width: 32px;
    height: 32px;
    margin-left: auto;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #22c55e;
    border: none;
    border-radius: 50%;
    font-size: 1.25rem;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.rubric-add-btn:hover {
    background: #16a34a;
    transform: scale(1.05);
}

.rubric-add-btn:focus-visible {
    outline: 2px solid #22c55e;
    outline-offset: 2px;
}

/* Rubric list container */
.rubric-list-container {
    border: none;
    border-radius: 6px;
    background: #0f172a;
    overflow: visible;
}

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

.rubric-list-empty-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.rubric-list-empty-title {
    font-weight: 600;
    color: var(--rb-text-primary);
    margin-bottom: 4px;
}

/* ============================================
   EXPANDED EDIT PANEL STYLES (Phase 2)
   ============================================ */

.rubric-edit-panel {
    background: var(--rb-bg-surface);
    border: 1px solid var(--rb-border-default);
    border-radius: 6px;
    animation: slideIn var(--transition-default);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.rubric-edit-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--rb-bg-base);
    border-bottom: 1px solid var(--rb-border-default);
    border-radius: 6px 6px 0 0;
}

.rubric-edit-panel-back {
    background: transparent;
    border: 1px solid var(--rb-border-default);
    color: var(--rb-accent);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}

.rubric-edit-panel-back:hover {
    background: var(--rb-accent-hover);
    border-color: var(--rb-accent);
}

.rubric-edit-panel-back:focus-visible {
    outline: 2px solid var(--rb-accent);
    outline-offset: 2px;
}

.rubric-edit-panel-title {
    font-weight: 600;
    color: var(--rb-text-primary);
    font-size: 0.95rem;
}

.rubric-edit-panel-remove {
    background: #991b1b;
    color: #fecaca;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background var(--transition-fast);
}

.rubric-edit-panel-remove:hover {
    background: #7f1d1d;
}

.rubric-edit-panel-remove:focus-visible {
    outline: 2px solid #f87171;
    outline-offset: 2px;
}

.rubric-edit-panel-body {
    padding: 16px;
}

/* ============================================
   SECTION DIVIDERS WITH LABELS (Phase 5)
   ============================================ */

.rubric-edit-section {
    margin-bottom: 16px;
}

.rubric-edit-section:last-child {
    margin-bottom: 0;
}

.rubric-edit-section-divider {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    margin-top: 8px;
}

.rubric-edit-section-divider::before,
.rubric-edit-section-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--rb-border-default);
}

.rubric-edit-section-divider::before {
    margin-right: 12px;
}

.rubric-edit-section-divider::after {
    margin-left: 12px;
}

.rubric-edit-section-label {
    color: var(--rb-text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

/* ============================================
   RUBRIC EDIT FIELDS (Phase 5 Polish)
   ============================================ */

.rubric-edit-field {
    margin-bottom: 8px;
}

.rubric-edit-field:last-child {
    margin-bottom: 0;
}

.rubric-edit-label {
    display: block;
    font-weight: 500;
    color: var(--rb-text-primary);
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.rubric-edit-label .required {
    color: #f87171;
}

.rubric-edit-field textarea,
.rubric-edit-field input[type="text"],
.rubric-edit-field select {
    width: 100%;
    background: var(--rb-bg-base);
    border: 1px solid var(--rb-border-default);
    color: var(--rb-text-primary);
    padding: 10px 12px;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: border-color var(--transition-fast);
}

.rubric-edit-field textarea:focus,
.rubric-edit-field input[type="text"]:focus,
.rubric-edit-field select:focus {
    outline: none;
    border-color: var(--rb-accent);
}

.rubric-edit-field textarea:focus-visible,
.rubric-edit-field input[type="text"]:focus-visible,
.rubric-edit-field select:focus-visible {
    outline: 2px solid var(--rb-accent);
    outline-offset: 1px;
}

.rubric-edit-field-description {
    display: block;
    font-size: 0.8rem;
    color: var(--rb-text-secondary);
    margin-top: 6px;
    line-height: 1.4;
}

/* Help text below inputs (Phase 5) */
.rubric-edit-help-text {
    display: block;
    font-size: 0.8rem;
    color: var(--rb-text-secondary);
    margin-top: 6px;
    line-height: 1.4;
}

/* Ensure full-width inputs in edit panel body (Phase 5) */
.rubric-edit-panel-body input[type="text"],
.rubric-edit-panel-body input[type="number"],
.rubric-edit-panel-body textarea,
.rubric-edit-panel-body select {
    width: 100%;
    box-sizing: border-box;
}

.rubric-edit-field-note {
    padding: 12px 16px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 4px;
    color: var(--rb-text-secondary);
    font-size: 0.85rem;
    line-height: 1.5;
}

.rubric-edit-field-placeholder {
    padding: 12px 16px;
    background: rgba(100, 116, 139, 0.1);
    border: 1px solid rgba(100, 116, 139, 0.2);
    border-radius: 4px;
    color: var(--rb-text-secondary);
    font-size: 0.85rem;
    font-style: italic;
}

.rubric-edit-strategy-fields {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--rb-border-default);
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .rubric-row,
    .tool-flyout,
    .rubric-edit-panel {
        transition: none !important;
        animation: none !important;
    }
}

/* Responsive: stack on mobile */
@media (max-width: 640px) {
    .rubric-row {
        flex-wrap: wrap;
        padding: 8px 12px;
        min-height: auto;
        gap: 8px;
    }
    
    .rubric-row-criterion {
        flex: 1 1 100%;
        order: 1;
        padding-right: 0;
    }
    
    .rubric-row-number {
        order: 0;
    }
    
    .rubric-row-badge {
        order: 2;
        max-width: none;
    }
    
    .rubric-row-indicators {
        order: 3;
        margin-left: auto;
    }
}

/* Builder Section Layout - 50/50 split */
.builder-section {
    margin-top: 1.5rem;
}

.builder-section-row {
    display: flex;
    gap: 1.5rem;
}

.builder-section-main {
    flex: 1;
    min-width: 0;
}

.builder-section-issues {
    flex: 1;
    min-width: 0;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    position: sticky;
    top: 1rem;
    align-self: flex-start;
}

.builder-section-issues:empty {
    display: none;
}

/* When issues panel is empty, main takes full width */
.builder-section-row:has(.builder-section-issues:empty) .builder-section-main {
    flex: 1;
}

/* Issues Panel Styling */
.issues-panel {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    overflow: hidden;
}

.issues-panel-header {
    padding: 0.75rem 1rem;
    background: #0f172a;
    border-bottom: 1px solid #334155;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.issues-panel-title {
    font-weight: 600;
    color: #e2e8f0;
    font-size: 0.9rem;
}

.issues-panel-count {
    background: #dc2626;
    color: white;
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-weight: 600;
}

.issues-panel-count.warning {
    background: #d97706;
}

.issues-panel-content {
    padding: 0.75rem;
}

/* Issue Card in Panel */
.issue-card {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
}

.issue-card:last-child {
    margin-bottom: 0;
}

.issue-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.issue-card-icon {
    font-size: 0.9rem;
}

.issue-card-name {
    font-weight: 600;
    color: #e2e8f0;
    font-size: 0.85rem;
}

.issue-card-message {
    color: #94a3b8;
    font-size: 0.8rem;
    line-height: 1.5;
}

.issue-card-quote {
    margin-top: 0.5rem;
    background: #1e293b;
    border-left: 2px solid #475569;
    padding: 0.5rem;
    font-family: monospace;
    font-size: 0.75rem;
    color: #94a3b8;
}

/* Rubric Issue Card - links to specific item */
.rubric-issue-card {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 6px;
    margin-bottom: 0.75rem;
}

.rubric-issue-card:last-child {
    margin-bottom: 0;
}

.rubric-issue-header {
    padding: 0.5rem 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid #334155;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.rubric-issue-index {
    color: #60a5fa;
    font-weight: 600;
    font-size: 0.8rem;
}

.rubric-issue-criterion {
    color: #94a3b8;
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.rubric-issue-body {
    padding: 0.75rem;
}

.rubric-issue-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid #334155;
}

.rubric-issue-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.rubric-issue-item:first-child {
    padding-top: 0;
}

/* Rubric Item Row - 50/50 layout for criterion + issues */
.rubric-item-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.75rem;
    align-items: flex-start;
}

/* Rubric Items */
.rubric-item {
    flex: 1;
    min-width: 0;
    background: #0f172a;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid #334155;
    position: relative;
    display: flex;
    gap: 0.75rem;
}

.rubric-item-number {
    color: #60a5fa;
    font-weight: 600;
    flex-shrink: 0;
    padding-top: 0.25rem;
}

.rubric-item-content {
    flex: 1;
    min-width: 0;
}

/* Issues panel next to each criterion */
.rubric-item-issues-panel {
    flex: 1;
    min-width: 0;
}

.rubric-item-issues-panel:empty {
    display: none;
}

/* When issues panel is empty, item takes full width (default) */
.rubric-item-row:has(.rubric-item-issues-panel:empty) .rubric-item {
    flex: 1;
}

/* When container has issues, ALL items stay at 50% width for consistency */
#rubric-items-container.has-issues .rubric-item-row .rubric-item {
    flex: 0 0 50%;
}

#rubric-items-container.has-issues .rubric-item-issues-panel:empty {
    display: block;
    flex: 1;
}

.rubric-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid #334155;
}

.rubric-item-title {
    color: #60a5fa;
    font-weight: 600;
    font-size: 1rem;
}

.remove-btn {
    background: #991b1b;
    color: #fecaca;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
}

.remove-btn:hover {
    background: #7f1d1d;
}

/* Rubric Item Issue Indicators */
.rubric-item.has-fail-issue {
    border-left: 3px solid #dc2626;
}

.rubric-item.has-warning-issue {
    border-left: 3px solid #d97706;
}

/* Rubric Item Issues Container */
.rubric-item-issues {
    margin-top: 8px;
}

/* Hidden by filter */
.rubric-item-row.hidden-by-filter {
    display: none !important;
}

/* ============================================
   INLINE RUBRIC ISSUES
   Issues displayed directly below rubric items
   ============================================ */

/* Inline Issue Card */
.rubric-inline-issue {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 8px;
}

.rubric-inline-issue:last-child {
    margin-bottom: 0;
}

/* Issue Header */
.rubric-inline-issue-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.rubric-inline-issue-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: #e2e8f0;
}

.rubric-inline-issue-icon {
    font-size: 0.9rem;
}

/* Issue Message */
.rubric-inline-issue-message {
    color: #cbd5e1;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Evidence Block */
.rubric-inline-issue-evidence {
    margin-top: 8px;
    background: #0f172a;
    border-left: 3px solid #475569;
    padding: 8px 12px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.8rem;
    color: #94a3b8;
    border-radius: 0 4px 4px 0;
}

.rubric-inline-issue-evidence-label {
    color: #64748b;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
    font-family: inherit;
}

/* ============================================
   RUBRIC ISSUES FILTER
   ============================================ */

.rubric-filter-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.2);
    transition: background 0.2s;
}

.rubric-filter-toggle:hover {
    background: rgba(0, 0, 0, 0.3);
}

.rubric-filter-toggle input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
    accent-color: #3b82f6;
}

/* ============================================
   PROMPT ISSUES PANEL
   Collapsible panel for displaying task prompt analysis results
   ============================================ */

/* Button styling */
.btn-warning {
    background: #d97706;
    color: #fff;
}

.btn-warning:hover {
    background: #b45309;
}

/* Collapsible Status Bar (compact, always visible after check) */
.prompt-issues-status-bar {
    margin-top: 8px;
    padding: 12px 16px;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
}

.prompt-issues-status-bar:hover {
    filter: brightness(1.1);
}

.prompt-issues-status-bar.status-ready {
    background: #065f46;
    border: 1px solid #059669;
}

.prompt-issues-status-bar.status-minor {
    background: #854d0e;
    border: 1px solid #d97706;
}

.prompt-issues-status-bar.status-major {
    background: #991b1b;
    border: 1px solid #dc2626;
}

.prompt-issues-status-text {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: #fff;
}

.prompt-issues-status-icon {
    font-size: 1.1rem;
}

.prompt-issues-toggle {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    gap: 4px;
}

.prompt-issues-toggle-arrow {
    transition: transform 0.2s;
}

.prompt-issues-toggle-arrow.expanded {
    transform: rotate(180deg);
}

/* Full Issues Panel (expandable) */
.prompt-issues-panel {
    margin-top: 8px;
    background: #1e293b;
    border-radius: 8px;
    border: 1px solid #334155;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.2s ease;
}

.prompt-issues-panel.expanded {
    max-height: 2000px;
    opacity: 1;
}

/* Issue Category Groups */
.prompt-issues-group {
    padding: 16px 20px;
    border-bottom: 1px solid #334155;
}

.prompt-issues-group:last-child {
    border-bottom: none;
}

.prompt-issues-group-title {
    color: #94a3b8;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Individual Issue Card */
.prompt-issue-card {
    background: #0f172a;
    border-radius: 6px;
    border: 1px solid #334155;
    margin-bottom: 12px;
    overflow: hidden;
}

.prompt-issue-card:last-child {
    margin-bottom: 0;
}

.prompt-issue-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid #334155;
}

.prompt-issue-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: #e2e8f0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.prompt-issue-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.prompt-issue-dot.severity-fail {
    background: #dc2626;
}

.prompt-issue-dot.severity-warning {
    background: #d97706;
}

/* Severity Badges */
.prompt-issue-severity {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.prompt-issue-severity.severity-fail {
    background: #dc2626;
    color: #fff;
}

.prompt-issue-severity.severity-warning {
    background: #d97706;
    color: #fff;
}

/* Issue Content */
.prompt-issue-body {
    padding: 14px;
}

.prompt-issue-message {
    color: #cbd5e1;
    font-size: 0.9rem;
    line-height: 1.6;
}

.prompt-issue-quote {
    margin-top: 12px;
    background: #1e293b;
    border-left: 3px solid #475569;
    padding: 10px 14px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.85rem;
    color: #94a3b8;
    border-radius: 0 4px 4px 0;
}

/* Not Run State */
.prompt-issues-not-run {
    margin-top: 16px;
    padding: 24px;
    background: #1e293b;
    border: 1px dashed #475569;
    border-radius: 8px;
    text-align: center;
    color: #64748b;
}

.prompt-issues-not-run-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.prompt-issues-not-run-title {
    font-size: 1rem;
    font-weight: 600;
    color: #94a3b8;
    margin-bottom: 4px;
}

.prompt-issues-not-run-instruction {
    font-size: 0.85rem;
}

.prompt-issues-not-run code {
    background: #0f172a;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Courier New', monospace;
    color: #60a5fa;
}

/* All Pass State (inside expanded panel) */
.prompt-issues-all-pass {
    padding: 24px;
    text-align: center;
}

.prompt-issues-all-pass-icon {
    font-size: 2.5rem;
    margin-bottom: 8px;
}

.prompt-issues-all-pass-text {
    color: #d1fae5;
    font-weight: 600;
}

/* ============================================
   GRADES TAB CONTROLS
   ============================================ */

.grade-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.grade-run-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 200px;
}

.grade-run-selector label {
    color: #94a3b8;
    font-weight: 500;
    white-space: nowrap;
}

.grade-run-selector select {
    flex: 1;
    background: #0f172a;
    border: 1px solid #334155;
    color: #e2e8f0;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    min-width: 250px;
}

.grade-run-selector select:focus {
    outline: none;
    border-color: #60a5fa;
}

.grade-buttons {
    display: flex;
    gap: 8px;
}

.grade-buttons .btn {
    padding: 8px 16px;
    font-size: 0.9rem;
}

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

.grade-status {
    color: #94a3b8;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.grade-status.grading {
    color: #60a5fa;
}

.grade-status.error {
    color: #ef4444;
}

.grade-status.success {
    color: #10b981;
}

/* ============================================
   MINIMALIST SECTION STYLES
   Modern, clean form sections
   ============================================ */

.mini-section {
    margin-bottom: 16px;
    padding: 12px 14px;
    background: rgba(30, 41, 59, 0.5);
    border-radius: 8px;
    transition: background 0.2s;
}

.mini-section:hover {
    background: rgba(30, 41, 59, 0.7);
}

.mini-section:focus-within {
    background: rgba(30, 41, 59, 0.8);
}

.mini-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0;
    margin-bottom: 10px;
}

.mini-section-header.clickable {
    cursor: pointer;
    border-radius: 4px;
    padding: 8px 10px;
    margin: 0 -10px 8px -10px;
    border-bottom: none;
    transition: background 0.15s;
}

.mini-section-header.clickable:hover {
    background: #1e293b;
}

.mini-section-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 6px;
}

.mini-info {
    position: relative;
    font-size: 0.7rem;
    color: #475569;
    cursor: help;
    text-transform: none;
    letter-spacing: 0;
}

.mini-info::after {
    content: attr(data-tooltip);
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 10px;
    background: #1e293b;
    color: #e2e8f0;
    font-size: 0.75rem;
    font-weight: 400;
    white-space: nowrap;
    border-radius: 4px;
    border: 1px solid #334155;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.1s ease, visibility 0.1s ease;
    pointer-events: none;
    z-index: 1000;
}

.mini-info:hover::after {
    opacity: 1;
    visibility: visible;
    transition-delay: 0.1s;
}

.collapse-icon {
    font-size: 0.65rem;
    transition: transform 0.2s;
    opacity: 0.6;
}

.mini-section.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.mini-section.collapsed .mini-section-body {
    display: none;
}

.mini-section.collapsed .mini-section-header {
    margin-bottom: 0;
}

.mini-badge {
    font-size: 0.65rem;
    font-weight: 500;
    color: #94a3b8;
    background: #1e293b;
    padding: 2px 8px;
    border-radius: 10px;
}

.mini-section-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.mini-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 0.7rem;
    font-weight: 500;
    color: #94a3b8;
    background: transparent;
    border: 1px solid #334155;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
}

.mini-btn:hover {
    background: #1e293b;
    color: #e2e8f0;
    border-color: #475569;
}

.mini-btn-icon {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: #94a3b8;
    background: transparent;
    border: 1px solid #334155;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
}

.mini-btn-icon:hover {
    background: #1e293b;
    color: #e2e8f0;
    border-color: #475569;
}

.mini-section-body {
    padding: 0;
}

.mini-input {
    padding: 6px 10px;
    font-size: 0.8rem;
    color: #e2e8f0;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 4px;
    outline: none;
    transition: border-color 0.15s;
}

.mini-input:focus {
    border-color: #3b82f6;
}

.mini-textarea {
    width: 100%;
    min-height: 140px;
    padding: 12px;
    font-size: 0.85rem;
    font-family: 'Monaco', 'Menlo', monospace;
    color: #e2e8f0;
    background: #0f172a;
    border: 1px solid transparent;
    border-radius: 6px;
    resize: vertical;
    outline: none;
    transition: border-color 0.15s, background 0.15s;
}

.mini-textarea:hover {
    background: #0c1322;
}

.mini-textarea:focus {
    border-color: #3b82f6;
    background: #0c1322;
}

.mini-preview {
    max-height: 150px;
    overflow-y: auto;
    background: #0f172a;
    border-radius: 6px;
    padding: 12px;
}

.mini-empty {
    font-size: 0.8rem;
    color: #64748b;
    font-style: italic;
}

.mini-code {
    font-size: 0.75rem;
    font-family: 'Monaco', 'Menlo', monospace;
    color: #94a3b8;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
}

.mini-section.collapsible.highlight-sync {
    animation: mini-highlight 1.5s ease;
}

@keyframes mini-highlight {
    0%, 100% { background: transparent; }
    25% { background: rgba(59, 130, 246, 0.1); }
}

/* ============================================
   COMMAND RUNNER UI
   Check Issues panel and other command forms
   ============================================ */

.command-runner-container {
    margin-bottom: 8px;
}

.command-panel {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.command-form {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
}

.command-label {
    color: #64748b;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.command-arg {
    background: #0f172a;
    border: 1px solid #334155;
    color: #e2e8f0;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    min-width: 70px;
}

.command-arg:focus {
    outline: none;
    border-color: #3b82f6;
}

.command-form .run-btn {
    background: transparent;
    color: #94a3b8;
    border: 1px solid #334155;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.command-form .run-btn:hover {
    background: #1e293b;
    color: #e2e8f0;
    border-color: #475569;
}

.command-form .run-btn:hover {
    background: #2563eb;
}

.command-form .run-btn:disabled {
    background: #475569;
    cursor: not-allowed;
}

/* Command Status Panel */
.command-status {
    margin-top: 8px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 12px;
}

.status-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-indicator.running {
    background: #3b82f6;
    animation: pulse 1.5s infinite;
}

.status-indicator.completed {
    background: #10b981;
}

.status-indicator.error {
    background: #ef4444;
}

.status-indicator.warning {
    background: #f59e0b;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.status-text {
    flex: 1;
    color: #94a3b8;
    font-size: 0.85rem;
}

.status-text.success {
    color: #10b981;
}

.status-text.error {
    color: #ef4444;
}

.status-text.warning {
    color: #f59e0b;
}

.cancel-btn {
    background: transparent;
    border: 1px solid #475569;
    color: #94a3b8;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cancel-btn:hover {
    background: #334155;
    color: #e2e8f0;
}

/* Command Output Steps */
.command-output-container {
    max-height: 200px;
    overflow-y: auto;
}

.step-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 4px 0;
    font-size: 0.85rem;
    color: #94a3b8;
}

.step-item.current {
    color: #60a5fa;
}

.step-item.completed {
    color: #64748b;
}

.step-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-top: 6px;
    flex-shrink: 0;
    background: currentColor;
}

.step-text {
    line-height: 1.4;
}


.chain-display {
    margin-top: 1rem;
    padding: 0.75rem;
    background: #1e293b;
    border-radius: 0.5rem;
    border: 1px solid #334155;
}

.chain-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.chain-icon {
    font-size: 1rem;
}

.chain-title {
    font-weight: 500;
    color: #f1f5f9;
}

.chain-readonly-badge {
    font-size: 0.7rem;
    padding: 0.125rem 0.375rem;
    background: #78350f;
    color: #fbbf24;
    border-radius: 0.25rem;
    margin-left: auto;
}

.chain-steps {
    list-style: none;
    padding: 0;
    margin: 0;
}

.chain-step {
    display: flex;
    gap: 0.75rem;
    padding: 0.5rem;
    background: #0f172a;
    border-radius: 0.375rem;
}

.step-number {
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #3b82f6;
    color: white;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

.step-content {
    flex: 1;
    min-width: 0;
}

.step-tool {
    font-family: monospace;
    font-weight: 500;
    color: #f1f5f9;
    word-break: break-all;
}

.step-path {
    font-size: 0.8rem;
    color: #94a3b8;
    margin-top: 0.125rem;
}

.step-mappings {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.25rem;
}

.step-mappings code {
    font-size: 0.7rem;
    padding: 0.125rem 0.375rem;
    background: #1e293b;
    border-radius: 0.25rem;
    color: #a5b4fc;
}

.chain-arrow {
    text-align: center;
    color: #64748b;
    font-size: 0.8rem;
    margin: 0.25rem 0;
    list-style: none;
}

/* Responsive */
@media (max-width: 600px) {
    .chain-step {
        flex-direction: column;
        gap: 0.5rem;
    }

    .step-number {
        align-self: flex-start;
    }
}

.chain-section {
    margin-top: 1rem;
    border: 1px solid #334155;
    border-radius: 0.5rem;
    overflow: hidden;
}

.chain-section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: #1e293b;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease;
}

.chain-section-header:hover {
    background: #263548;
}

.chain-section-header:focus {
    outline: 2px solid #3b82f6;
    outline-offset: -2px;
}

.chain-section-header:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: -2px;
}

.chain-section-header:focus:not(:focus-visible) {
    outline: none;
}

.chain-section-icon {
    font-size: 1rem;
}

.chain-section-title {
    font-weight: 500;
    color: #f1f5f9;
    flex: 1;
}

.chain-toggle-arrow {
    color: #94a3b8;
    font-size: 0.8rem;
}

.chain-section-content {
    padding: 0.75rem;
    background: #0f172a;
}

.chain-step-editor {
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: #1e293b;
    border-radius: 0.375rem;
    border: 1px solid #334155;
}

.chain-step-editor:last-of-type {
    margin-bottom: 0.75rem;
}

.step-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.step-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.125rem 0.5rem;
    background: #3b82f6;
    color: white;
    border-radius: 0.25rem;
}

.step-tool-select {
    margin-bottom: 0.5rem;
}

.step-tool-select label {
    display: block;
    font-size: 0.8rem;
    color: #94a3b8;
    margin-bottom: 0.25rem;
}

.step-tool-select select {
    width: 100%;
    background: #0f172a;
    border: 1px solid #334155;
    color: #e2e8f0;
    padding: 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.85rem;
    transition: border-color 0.15s ease;
}

.step-tool-select select:focus {
    outline: none;
    border-color: #3b82f6;
}

.step-tool-select select:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 1px;
}

.step-param-mapping {
    margin-bottom: 0.5rem;
}

.step-param-mapping>label {
    display: block;
    font-size: 0.8rem;
    color: #94a3b8;
    margin-bottom: 0.25rem;
}

.step-param-mapping>label small {
    color: #64748b;
}

.step-response-path label {
    display: block;
    font-size: 0.8rem;
    color: #94a3b8;
    margin-bottom: 0.25rem;
}

.step-response-path input {
    width: 100%;
    background: #0f172a;
    border: 1px solid #334155;
    color: #e2e8f0;
    padding: 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.85rem;
    transition: border-color 0.15s ease;
}

.step-response-path input:focus {
    outline: none;
    border-color: #3b82f6;
}

.step-response-path input:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 1px;
}

.param-mapping-entries {
    margin-bottom: 0.5rem;
}

.param-mapping-entry {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.25rem;
    flex-wrap: wrap;
}

.param-mapping-entry .param-key,
.param-mapping-entry .param-value {
    flex: 1;
    min-width: 100px;
    background: #0f172a;
    border: 1px solid #334155;
    color: #e2e8f0;
    padding: 0.375rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.85rem;
    transition: border-color 0.15s ease;
}

.param-mapping-entry .param-key:focus,
.param-mapping-entry .param-value:focus {
    outline: none;
    border-color: #3b82f6;
}

.param-mapping-entry .param-key:focus-visible,
.param-mapping-entry .param-value:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 1px;
}

.mapping-separator {
    color: #64748b;
    font-weight: 500;
}

.no-mappings {
    color: #64748b;
    font-size: 0.85rem;
    font-style: italic;
    padding: 0.5rem;
}

/* Icon buttons (remove step, remove mapping) */
.btn-icon {
    background: transparent;
    border: 1px solid #475569;
    color: #94a3b8;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 0.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    transition: all 0.15s;
}

.btn-icon:hover {
    background: #334155;
    color: #f1f5f9;
    border-color: #64748b;
}

.btn-icon:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 1px;
}

.btn-icon:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 1px;
}

.btn-icon:focus:not(:focus-visible) {
    outline: none;
}

/* Small buttons */
.btn-xs {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.85rem;
}

.btn-secondary {
    background: #334155;
    color: #e2e8f0;
    border: 1px solid #475569;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.btn-secondary:hover {
    background: #475569;
}

.btn-secondary:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 1px;
}

.btn-secondary:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 1px;
}

.btn-secondary:focus:not(:focus-visible) {
    outline: none;
}

/* ============================================
   TOOL FLYOUT STYLES (Phase 3)
   Searchable dropdown for MCP tool selection
   ============================================ */

.tool-selector-container {
    position: relative;
    width: 100%;
}

.tool-selector-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: var(--rb-bg-base);
    border: 1px solid var(--rb-border-default);
    color: var(--rb-text-primary);
    padding: 10px 12px;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast);
    text-align: left;
}

.tool-selector-trigger:hover {
    border-color: var(--rb-accent);
    background: rgba(96, 165, 250, 0.05);
}

.tool-selector-trigger:focus {
    outline: none;
    border-color: var(--rb-accent);
}

.tool-selector-trigger:focus-visible {
    outline: 2px solid var(--rb-accent);
    outline-offset: 1px;
}

.tool-selector-trigger.placeholder .tool-selector-trigger-text {
    color: var(--rb-text-secondary);
}

.tool-selector-trigger-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tool-selector-trigger-arrow {
    margin-left: 8px;
    color: var(--rb-text-secondary);
    flex-shrink: 0;
    transition: transform var(--transition-fast);
}

.tool-selector-trigger[aria-expanded="true"] .tool-selector-trigger-arrow {
    transform: rotate(180deg);
}

/* Flyout container */
.tool-flyout {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    min-width: 300px;
    max-width: min(400px, 90vw);
    max-height: 400px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    background: var(--rb-bg-base);
    border: 1px solid var(--rb-border-default);
    border-radius: 6px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    z-index: 10001; /* Must be higher than badge-editor (10000) */
    margin-top: 4px;
    
    /* Entrance animation */
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity var(--transition-fast), transform var(--transition-fast);
    pointer-events: none;
    visibility: hidden;
}

.tool-flyout.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    visibility: visible;
}

/* Flip direction when near bottom of viewport */
.tool-flyout.flip-up {
    top: auto;
    bottom: 100%;
    margin-top: 0;
    margin-bottom: 4px;
    transform: translateY(8px);
}

.tool-flyout.flip-up.open {
    transform: translateY(0);
}

/* Search section */
.tool-flyout-search {
    position: sticky;
    top: 0;
    padding: 8px 12px;
    background: var(--rb-bg-base);
    border-bottom: 1px solid var(--rb-border-default);
    z-index: 1;
}

.tool-flyout-search input {
    width: 100%;
    background: var(--rb-bg-surface);
    border: 1px solid var(--rb-border-default);
    color: var(--rb-text-primary);
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: border-color var(--transition-fast);
}

.tool-flyout-search input:focus {
    outline: none;
    border-color: var(--rb-accent);
}

.tool-flyout-search input:focus-visible {
    outline: 2px solid var(--rb-accent);
    outline-offset: 1px;
}

.tool-flyout-search input::placeholder {
    color: var(--rb-text-secondary);
}

/* Inline search input (replaces trigger when flyout is open) */
.tool-flyout-inline-search {
    width: 100%;
    background: var(--rb-bg-surface);
    border: 1px solid var(--rb-accent);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 0.9rem;
    color: var(--rb-text-primary);
    font-family: inherit;
    box-sizing: border-box;
}

.tool-flyout-inline-search:focus {
    outline: none;
    border-color: var(--rb-accent);
    box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.2);
}

.tool-flyout-inline-search::placeholder {
    color: var(--rb-text-secondary);
}

/* Dropdown-only flyout (no internal search bar) */
.tool-flyout.tool-flyout-dropdown-only {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    margin-top: -1px;
}

/* Tool list container */
.tool-flyout-list {
    padding: 4px 0;
}

/* Service group */
.tool-flyout-group {
    margin-bottom: 2px;
}

.tool-flyout-group:last-child {
    margin-bottom: 0;
}

/* Group header */
.tool-flyout-group-header {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: var(--rb-bg-surface);
    cursor: pointer;
    font-weight: 500;
    color: var(--rb-text-primary);
    transition: background var(--transition-fast);
    user-select: none;
}

.tool-flyout-group-header:hover {
    background: rgba(96, 165, 250, 0.1);
}

.tool-flyout-group-header:focus {
    outline: none;
    background: rgba(96, 165, 250, 0.15);
}

.tool-flyout-group-header:focus-visible {
    outline: 2px solid var(--rb-accent);
    outline-offset: -2px;
}

.tool-flyout-group-arrow {
    width: 16px;
    color: var(--rb-text-secondary);
    flex-shrink: 0;
    font-size: 0.8rem;
}

.tool-flyout-group-name {
    flex: 1;
}

.tool-flyout-group-count {
    color: var(--rb-text-secondary);
    font-size: 0.85rem;
    font-weight: 400;
}

/* Tool item */
.tool-flyout-item {
    display: flex;
    align-items: center;
    padding: 6px 12px 6px 24px;
    cursor: pointer;
    color: var(--rb-text-primary);
    transition: background var(--transition-fast);
}

.tool-flyout-item:hover {
    background: rgba(59, 130, 246, 0.15);
}

.tool-flyout-item:focus {
    background: rgba(59, 130, 246, 0.15);
    outline: none;
}

.tool-flyout-item.highlighted {
    background: rgba(59, 130, 246, 0.2);
}

.tool-flyout-item.selected {
    background: rgba(59, 130, 246, 0.25);
}

.tool-flyout-item[aria-selected="true"] {
    background: rgba(59, 130, 246, 0.25);
}

.tool-flyout-item-check {
    width: 20px;
    color: var(--rb-accent);
    font-weight: 600;
    flex-shrink: 0;
}

.tool-flyout-item-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.85rem;
}

/* Loading state */
.tool-flyout-loading {
    padding: 24px;
    text-align: center;
    color: var(--rb-text-secondary);
}

/* Empty state */
.tool-flyout-empty {
    padding: 16px 24px;
    text-align: center;
    color: var(--rb-text-secondary);
    font-size: 0.9rem;
}

/* Responsive: full-width on mobile */
@media (max-width: 480px) {
    .tool-flyout {
        position: fixed;
        left: 5vw;
        right: 5vw;
        width: auto;
        max-width: none;
        max-height: 60vh;
    }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .tool-flyout,
    .tool-selector-trigger,
    .tool-selector-trigger-arrow {
        transition: none !important;
    }
}

/* ============================================
   STRATEGY-SPECIFIC PANEL STYLES (Phase 4)
   Different UI layouts for each grading strategy
   ============================================ */

/* Base strategy panel */
.strategy-panel {
    margin-top: 8px;
}

/* Strategy-specific classes for styling hooks */
.strategy-panel.strategy-llm {
    /* LLM: Simple, minimal styling - placeholder for future customization */
    display: block;
}

.strategy-panel.strategy-markdown {
    /* Markdown: Medium complexity - placeholder for future customization */
    display: block;
}

.strategy-panel.strategy-mcp {
    /* MCP Tool Call: Complex - placeholder for future customization */
    display: block;
}

.strategy-panel.strategy-unknown {
    border-left: 3px solid #f59e0b;
}

/* Strategy panel note (informational text) */
.strategy-panel-note {
    padding: 12px 16px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 4px;
    color: var(--rb-text-secondary);
    font-size: 0.85rem;
    line-height: 1.5;
    margin: 0;
}

/* Strategy sections (both class names for backward compatibility) */
.strategy-section,
.rubric-edit-section {
    margin-bottom: 16px;
}

.strategy-section:last-child,
.rubric-edit-section:last-child {
    margin-bottom: 0;
}

.strategy-section-label {
    display: block;
    font-weight: 500;
    color: var(--rb-text-primary);
    margin-bottom: 6px;
    font-size: 0.9rem;
}

/* Strategy inputs */
.strategy-input {
    width: 100%;
    background: var(--rb-bg-base);
    border: 1px solid var(--rb-border-default);
    color: var(--rb-text-primary);
    padding: 10px 12px;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: border-color var(--transition-fast);
}

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

.strategy-input:focus-visible {
    outline: 2px solid var(--rb-accent);
    outline-offset: 1px;
}

.strategy-input-help {
    display: block;
    font-size: 0.8rem;
    color: var(--rb-text-secondary);
    margin-top: 6px;
    line-height: 1.4;
}

/* Strategy textarea */
.strategy-textarea {
    width: 100%;
    background: var(--rb-bg-base);
    border: 1px solid var(--rb-border-default);
    color: var(--rb-text-primary);
    padding: 10px 12px;
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: 'Monaco', 'Courier New', monospace;
    resize: vertical;
    min-height: 80px;
    transition: border-color var(--transition-fast);
}

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

.strategy-textarea:focus-visible {
    outline: 2px solid var(--rb-accent);
    outline-offset: 1px;
}

/* Strategy select dropdown */
.strategy-select {
    width: 100%;
    background: var(--rb-bg-base);
    border: 1px solid var(--rb-border-default);
    color: var(--rb-text-primary);
    padding: 10px 12px;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

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

.strategy-select:focus-visible {
    outline: 2px solid var(--rb-accent);
    outline-offset: 1px;
}

/* Data type toggle buttons */
.data-type-toggle {
    display: flex;
    gap: 4px;
}

.data-type-btn {
    flex: 1;
    padding: 8px 12px;
    background: var(--rb-bg-base);
    border: 1px solid var(--rb-border-default);
    color: var(--rb-text-secondary);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all var(--transition-fast);
}

.data-type-btn:hover {
    background: var(--rb-accent-hover);
    border-color: var(--rb-accent);
}

.data-type-btn.active {
    background: var(--rb-strategy-mcp-bg);
    border-color: var(--rb-accent);
    color: var(--rb-accent);
    font-weight: 500;
}

.data-type-btn:focus-visible {
    outline: 2px solid var(--rb-accent);
    outline-offset: 1px;
}

/* Expected rows editor */
.expected-rows-editor {
    background: var(--rb-bg-base);
    border: 1px solid var(--rb-border-default);
    border-radius: 4px;
    padding: 12px;
}

.expected-rows-empty {
    text-align: center;
    color: var(--rb-text-secondary);
    padding: 16px;
}

.expected-rows-empty p {
    margin: 0 0 12px 0;
}

.expected-rows-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.row-count {
    color: var(--rb-text-primary);
    font-weight: 500;
}

.key-fields-indicator {
    font-size: 0.8rem;
    color: var(--rb-strategy-markdown);
}

.expected-rows-table-placeholder {
    background: var(--rb-bg-surface);
    border-radius: 4px;
    padding: 12px;
}

.placeholder-note {
    color: var(--rb-text-secondary);
    font-size: 0.8rem;
    font-style: italic;
    margin: 0 0 8px 0;
}

.expected-data-preview {
    margin: 8px 0 0 0;
    padding: 8px;
    background: var(--rb-bg-base);
    border-radius: 4px;
    font-size: 0.75rem;
    overflow-x: auto;
    max-height: 150px;
    overflow-y: auto;
}

/* Tool selector trigger button (in strategy panel) */
.tool-selector-trigger {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--rb-bg-base);
    border: 1px solid var(--rb-border-default);
    color: var(--rb-text-primary);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    text-align: left;
    transition: border-color var(--transition-fast);
}

.tool-selector-trigger:hover {
    border-color: var(--rb-accent);
}

.tool-selector-trigger:focus-visible {
    outline: 2px solid var(--rb-accent);
    outline-offset: 1px;
}

.dropdown-arrow {
    color: var(--rb-text-secondary);
    font-size: 0.8rem;
}

/* Tool params editor */
.tool-params-editor {
    background: var(--rb-bg-base);
    border: 1px solid var(--rb-border-default);
    border-radius: 4px;
    padding: 12px;
}

.params-empty-state,
.params-placeholder {
    text-align: center;
    color: var(--rb-text-secondary);
    padding: 8px;
}

.params-empty-state p,
.params-placeholder p {
    margin: 0;
}

.params-summary {
    margin-bottom: 8px;
}

.params-count {
    color: var(--rb-text-primary);
    font-weight: 500;
}

.params-preview {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
}

.param-preview-item {
    display: flex;
    gap: 8px;
    padding: 4px 8px;
    background: var(--rb-bg-surface);
    border-radius: 4px;
    font-size: 0.85rem;
}

.param-key {
    color: var(--rb-accent);
    font-weight: 500;
}

.param-value {
    color: var(--rb-text-secondary);
    font-family: 'Monaco', 'Courier New', monospace;
}

/* Chain steps editor */
.chain-steps-editor {
    background: var(--rb-bg-base);
    border: 1px solid var(--rb-border-default);
    border-radius: 4px;
    padding: 12px;
}

.chain-empty-state {
    text-align: center;
    color: var(--rb-text-secondary);
    padding: 8px;
}

.chain-empty-state p {
    margin: 0 0 12px 0;
}

.chain-count-badge {
    display: inline-block;
    padding: 2px 6px;
    background: var(--rb-strategy-mcp-bg);
    color: var(--rb-strategy-mcp);
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 6px;
}

.chain-steps-list {
    margin-bottom: 12px;
}

.chain-step-card {
    background: var(--rb-bg-surface);
    border: 1px solid var(--rb-border-default);
    border-radius: 6px;
    overflow: visible;
}

.chain-step-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--rb-border-default);
}

.chain-step-badge {
    padding: 2px 8px;
    background: var(--rb-strategy-mcp);
    color: white;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.chain-step-tool {
    flex: 1;
    color: var(--rb-text-primary);
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.85rem;
}

.btn-remove-chain-step {
    background: transparent;
    border: 1px solid transparent;
    color: var(--rb-text-secondary);
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.btn-remove-chain-step:hover {
    background: rgba(220, 38, 38, 0.2);
    border-color: rgba(220, 38, 38, 0.3);
    color: #f87171;
}

.chain-step-body {
    padding: 12px;
}

.chain-step-mappings {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.mapping-entry {
    padding: 2px 8px;
    background: var(--rb-bg-base);
    border-radius: 4px;
    font-size: 0.8rem;
    color: #a5b4fc;
}

.no-mappings {
    color: var(--rb-text-secondary);
    font-size: 0.85rem;
    font-style: italic;
}

.chain-step-response {
    font-size: 0.85rem;
    color: var(--rb-text-secondary);
}

.chain-step-response .label {
    font-weight: 500;
}

.chain-step-response code {
    padding: 2px 6px;
    background: var(--rb-bg-base);
    border-radius: 4px;
    font-family: 'Monaco', 'Courier New', monospace;
    color: var(--rb-accent);
}

.chain-arrow {
    text-align: center;
    color: var(--rb-text-secondary);
    font-size: 0.9rem;
    padding: 4px 0;
}

.chain-add-btn {
    width: 100%;
}

/* ============================================
   PARAMS FORM STYLES (Phase 5)
   ============================================ */

.params-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.param-field {
    margin-bottom: 8px;
}

.param-field:last-child {
    margin-bottom: 0;
}

.param-input {
    width: 100%;
}

/* Chain step body improvements (Phase 5) */
.chain-step-body .rubric-edit-field {
    margin-bottom: 12px;
}

.chain-step-body .rubric-edit-field:last-child {
    margin-bottom: 0;
}

.chain-step-body .rubric-edit-label {
    font-size: 0.85rem;
    margin-bottom: 4px;
}

/* Make tool selector trigger full width inside chain steps */
.chain-step-body .tool-selector-trigger {
    width: 100%;
}

/* Responsive adjustments for strategy panels */
@media (max-width: 640px) {
    .data-type-toggle {
        flex-direction: column;
    }

    .data-type-btn {
        flex: none;
    }

    .expected-rows-summary {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .chain-step-header {
        flex-wrap: wrap;
    }

    .chain-step-tool {
        flex: 1 1 100%;
        order: 10;
        margin-top: 4px;
    }
}

/* ============================================================================
   EXPECTED DATA EDITORS (Table/List/Text)
   ============================================================================ */

/* Expected rows table */
.expected-rows-table-container {
    overflow-x: auto;
    margin-bottom: 8px;
}

.expected-rows-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.expected-rows-table th,
.expected-rows-table td {
    padding: 6px 8px;
    border: 1px solid var(--rb-border-default);
    text-align: left;
}

.expected-rows-table th {
    background: var(--rb-bg-surface);
    font-weight: 500;
    color: var(--rb-text-secondary);
    white-space: nowrap;
}

.expected-rows-table td:last-child {
    width: 32px;
    text-align: center;
    padding: 4px;
}

.strategy-input-compact {
    width: 100%;
    background: var(--rb-bg-base);
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 0.85rem;
    color: var(--rb-text-primary);
    transition: border-color var(--transition-fast);
}

.strategy-input-compact:hover {
    border-color: var(--rb-border-default);
}

.strategy-input-compact:focus {
    outline: none;
    border-color: var(--rb-accent);
    background: var(--rb-bg-surface);
}

/* Expected list items */
.expected-list-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.expected-list-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.expected-list-item .strategy-input {
    flex: 1;
}

.expected-list-empty,
.expected-rows-empty {
    padding: 1rem;
    background: var(--rb-bg-surface);
    border: 1px dashed var(--rb-border-default);
    border-radius: 6px;
    text-align: center;
    color: var(--rb-text-secondary);
}

.expected-list-empty p,
.expected-rows-empty p {
    margin: 0 0 12px 0;
}

/* Small danger icon button */
.btn-icon.btn-danger-icon {
    width: 24px;
    height: 24px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    color: var(--rb-text-secondary);
    font-size: 1rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-icon.btn-danger-icon:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

/* Column header styling */
.expected-col-header {
    padding: 4px !important;
}

.col-header-content {
    display: flex;
    align-items: center;
    gap: 4px;
}

.col-key-toggle {
    width: 24px;
    height: 24px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--rb-text-secondary);
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.col-key-toggle:hover {
    background: rgba(96, 165, 250, 0.1);
    border-color: rgba(96, 165, 250, 0.3);
}

.col-key-toggle.is-key {
    color: #fbbf24;
}

.col-name-input {
    flex: 1;
    min-width: 60px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--rb-text-primary);
    transition: all var(--transition-fast);
}

.col-name-input:hover {
    border-color: var(--rb-border-default);
    background: var(--rb-bg-base);
}

.col-name-input:focus {
    outline: none;
    border-color: var(--rb-accent);
    background: var(--rb-bg-base);
}

.col-remove-btn {
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.col-header-content:hover .col-remove-btn {
    opacity: 1;
}

/* Add column button in header */
.expected-col-add {
    width: 36px;
    padding: 4px !important;
    text-align: center;
}

.col-add-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px dashed var(--rb-border-default);
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    color: var(--rb-text-secondary);
    transition: all var(--transition-fast);
}

.col-add-btn:hover {
    background: rgba(96, 165, 250, 0.1);
    border-color: var(--rb-accent);
    border-style: solid;
    color: var(--rb-accent);
}

/* Expected rows actions */
.expected-rows-actions {
    margin-top: 8px;
    display: flex;
    gap: 8px;
}