/* ═══════════════════════════════════════════════════════════════════
   SPACTRA Studio — SpectraMatch v3.0.0
   ═══════════════════════════════════════════════════════════════════ */

/* ── Web App Fallback Variables (light, no data-theme) ── */
:root {
    --bg-app:           #f5f7fa;
    --bg-panel:         #ffffff;
    --bg-panel-header:  #f8fafc;
    --bg-input:         #f1f5f9;
    --bg-hover:         rgba(0,102,204,0.05);
    --bg-active:        rgba(0,102,204,0.08);
    --border:           #e2e8f0;
    --border-light:     #f1f5f9;
    --text:             #1a202c;
    --text-dim:         #64748b;
    --text-bright:      #0f172a;
    --accent:           #0066cc;
    --accent-hover:     #0052a3;
    --accent-active:    #004080;
    --success:          #16a34a;
    --success-bg:       rgba(22,163,74,0.08);
    --error:            #dc2626;
    --error-bg:         rgba(220,38,38,0.08);
    --viewer-bg:        #f8fafc;
}

/* ── Modal Overlay ── */
.alignment-studio-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
    direction: ltr;
}
[data-theme="light"] .alignment-studio-overlay {
    background: rgba(0, 0, 0, 0.5);
}
.alignment-studio-overlay.visible {
    display: flex;
    opacity: 1;
}
.alignment-studio-overlay.fade-in {
    animation: asFadeIn 0.25s ease forwards;
}
@keyframes asFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ── Main Container ── */
.as-container {
    width: 95vw;
    max-width: 1400px;
    height: 90vh;
    max-height: 900px;
    background: var(--bg-panel);
    border-radius: 0;
    border: 1px solid var(--border);
    box-shadow: 0 8px 32px rgba(0,0,0,0.6);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.97);
    animation: asScaleIn 0.2s ease forwards;
}
[data-theme="light"] .as-container {
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}
@keyframes asScaleIn {
    from { transform: scale(0.97); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* ── Header ── */
.as-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-panel-header);
    gap: 12px;
    flex-shrink: 0;
    height: 48px;
}
.as-header-icon {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
}
.as-header-icon svg { width: 16px; height: 16px; }
.as-header-text h2 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
    line-height: 1.2;
    font-family: 'Segoe UI', system-ui, sans-serif;
}
.as-header-text small {
    font-size: 11px;
    color: var(--text-dim);
}
.as-header-spacer { flex: 1; }
.as-close-btn {
    width: 28px;
    height: 28px;
    border-radius: 3px;
    border: none;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    font-size: 16px;
}
.as-close-btn:hover {
    background: var(--bg-hover);
    color: var(--text);
}

/* ── Body Layout ── */
.as-body {
    display: flex;
    flex-direction: row;
    flex: 1;
    overflow: hidden;
    direction: ltr;
}

/* ── Left: Technique Panel ── */
.as-techniques-panel {
    width: 220px;
    min-width: 200px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-app);
}
.as-techniques-header {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-panel-header);
}
.as-techniques-header h3 {
    font-size: 11px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-family: 'Segoe UI', system-ui, sans-serif;
}
.as-techniques-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* ── Technique Card ── */
.as-technique-card {
    border-radius: 3px;
    border: 1px solid var(--border-light);
    background: var(--bg-panel);
    padding: 6px 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
    overflow: hidden;
}
.as-technique-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: transparent;
    transition: background 0.15s;
}
.as-technique-card:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
}
.as-technique-card.active {
    border-color: var(--accent);
    background: var(--bg-active);
}
.as-technique-card.active::before {
    background: var(--accent);
}
.as-technique-card.tested {
    border-color: var(--success);
}
.as-technique-card.tested::before {
    background: var(--success);
}
.as-technique-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.as-technique-icon {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.as-technique-icon.baseline { background: rgba(148,163,184,0.15); color: #64748b; }
.as-technique-icon.registration { background: rgba(0,120,212,0.15); color: #0078d4; }
.as-technique-icon.ai { background: rgba(78,201,176,0.15); color: #16825d; }
[data-theme="dark"] .as-technique-icon.baseline { background: rgba(148,163,184,0.12); color: #94a3b8; }
[data-theme="dark"] .as-technique-icon.registration { background: rgba(0,120,212,0.15); color: #6cb6ff; }
[data-theme="dark"] .as-technique-icon.ai { background: rgba(78,201,176,0.15); color: #4ec9b0; }
.as-technique-icon svg { width: 12px; height: 12px; }
.as-technique-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
    font-family: 'Segoe UI', system-ui, sans-serif;
}
.as-technique-desc {
    font-size: 10px;
    color: var(--text-dim);
    line-height: 1.35;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.as-technique-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-bottom: 4px;
}
.as-badge {
    font-size: 9px;
    padding: 1px 5px;
    border-radius: 8px;
    background: rgba(128,128,128,0.15);
    color: var(--text-dim);
    white-space: nowrap;
}
.as-badge.rotation { background: rgba(59,130,246,0.15); color: #2563eb; }
.as-badge.scale { background: rgba(34,197,94,0.15); color: #16a34a; }
.as-badge.translation { background: rgba(234,179,8,0.15); color: #ca8a04; }
.as-badge.perspective { background: rgba(239,68,68,0.15); color: #dc2626; }
.as-badge.lighting { background: rgba(168,85,247,0.15); color: #9333ea; }
.as-badge.shear { background: rgba(6,182,212,0.15); color: #0891b2; }
.as-badge.cropping { background: rgba(6,182,212,0.15); color: #0891b2; }
[data-theme="dark"] .as-badge.rotation { background: rgba(59,130,246,0.12); color: #60a5fa; }
[data-theme="dark"] .as-badge.scale { background: rgba(34,197,94,0.12); color: #4ade80; }
[data-theme="dark"] .as-badge.translation { background: rgba(234,179,8,0.12); color: #facc15; }
[data-theme="dark"] .as-badge.perspective { background: rgba(239,68,68,0.12); color: #f87171; }
[data-theme="dark"] .as-badge.lighting { background: rgba(168,85,247,0.12); color: #c084fc; }
[data-theme="dark"] .as-badge.shear { background: rgba(6,182,212,0.12); color: #22d3ee; }
[data-theme="dark"] .as-badge.cropping { background: rgba(6,182,212,0.12); color: #22d3ee; }

/* ── Technique Action Buttons ── */
.as-technique-actions {
    display: flex;
    gap: 8px;
}
.as-btn {
    flex: 1;
    padding: 5px 8px;
    border-radius: 3px;
    border: 1px solid transparent;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    position: relative;
    overflow: hidden;
    font-family: 'Segoe UI', system-ui, sans-serif;
}
.as-btn svg { width: 12px; height: 12px; }
.as-btn-test {
    background: rgba(0,102,204,0.08);
    color: #0066cc;
    border-color: rgba(0,102,204,0.2);
}
.as-btn-test:hover {
    background: rgba(0,102,204,0.15);
    color: #004c99;
    border-color: #0066cc;
}
[data-theme="dark"] .as-btn-test {
    background: rgba(0,120,212,0.12);
    color: #6cb6ff;
    border-color: rgba(0,120,212,0.2);
}
[data-theme="dark"] .as-btn-test:hover {
    background: rgba(0,120,212,0.2);
    color: #a5d6ff;
    border-color: #0078d4;
}

/* Button processing animation */
.as-btn.processing {
    pointer-events: none;
    position: relative;
}
.as-btn.processing::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    animation: asShimmer 1.2s infinite;
}
@keyframes asShimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ── Right: Preview Panel ── */
.as-preview-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.as-preview-toolbar {
    display: flex;
    align-items: center;
    padding: 10px 18px;
    border-bottom: 1px solid var(--border);
    gap: 8px;
    flex-shrink: 0;
}
.as-preview-tab {
    padding: 6px 14px;
    border-radius: 3px;
    border: none;
    background: var(--bg-input);
    color: var(--text-dim);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.as-preview-tab:hover {
    background: var(--bg-hover);
    color: var(--text);
}
.as-preview-tab.active {
    background: var(--accent);
    color: #fff;
}
.as-preview-spacer { flex: 1; }

/* ── Image Preview Area ── */
.as-preview-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow: auto;
    position: relative;
}
.as-preview-empty {
    text-align: center;
    color: var(--text-dim);
}
.as-preview-empty svg {
    width: 64px;
    height: 64px;
    opacity: 0.3;
    margin-bottom: 16px;
}
.as-preview-empty p {
    font-size: 14px;
    margin: 0 0 4px;
    color: var(--text);
}
.as-preview-empty small {
    font-size: 12px;
    opacity: 0.6;
    color: var(--text-dim);
}

/* Side by side images */
.as-preview-images {
    display: flex;
    gap: 12px;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
}
.as-preview-pane {
    flex: 1;
    max-width: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.as-preview-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    padding: 4px 12px;
    border-radius: 6px;
    background: var(--bg-input);
}
.as-preview-label.ref { color: #2563eb; background: rgba(59,130,246,0.15); }
.as-preview-label.sample { color: #ea580c; background: rgba(249,115,22,0.15); }
.as-preview-label.aligned { color: #16a34a; background: rgba(34,197,94,0.15); }
.as-preview-label.overlay { color: #9333ea; background: rgba(168,85,247,0.15); }
.as-preview-label.diff { color: #dc2626; background: rgba(239,68,68,0.15); }
[data-theme="dark"] .as-preview-label.ref { color: #60a5fa; background: rgba(59,130,246,0.1); }
[data-theme="dark"] .as-preview-label.sample { color: #f97316; background: rgba(249,115,22,0.1); }
[data-theme="dark"] .as-preview-label.aligned { color: #4ade80; background: rgba(34,197,94,0.1); }
[data-theme="dark"] .as-preview-label.overlay { color: #c084fc; background: rgba(168,85,247,0.1); }
[data-theme="dark"] .as-preview-label.diff { color: #f87171; background: rgba(239,68,68,0.1); }

.as-preview-img-wrap {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--viewer-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    max-height: calc(92vh - 240px);
}
.as-preview-img-wrap img {
    max-width: 100%;
    max-height: calc(92vh - 240px);
    object-fit: contain;
    display: block;
}

/* Single centered preview */
.as-preview-single {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
    height: 100%;
    justify-content: center;
}
.as-preview-single img {
    max-width: 90%;
    max-height: calc(92vh - 240px);
    object-fit: contain;
    border-radius: 8px;
    border: 1px solid var(--border);
}

/* ── Metrics Bar ── */
.as-metrics-bar {
    padding: 12px 18px;
    border-top: 1px solid var(--border);
    background: var(--bg-panel-header);
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    flex-shrink: 0;
    min-height: 48px;
}
.as-metric {
    display: flex;
    align-items: center;
    gap: 6px;
}
.as-metric-label {
    font-size: 11px;
    color: var(--text-dim);
    white-space: nowrap;
}
.as-metric-value {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    font-family: 'Cascadia Code', 'Consolas', monospace;
}
.as-metric-value.good { color: #16a34a; }
.as-metric-value.warn { color: #ca8a04; }
.as-metric-value.bad { color: #dc2626; }
[data-theme="dark"] .as-metric-value.good { color: #4ade80; }
[data-theme="dark"] .as-metric-value.warn { color: #facc15; }
[data-theme="dark"] .as-metric-value.bad { color: #f87171; }
.as-metric-sep {
    width: 1px;
    height: 16px;
    background: var(--border);
}
.as-metrics-spacer { flex: 1; }
.as-metric-status {
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.as-metric-status.applied { background: var(--success-bg); color: var(--success); }
.as-metric-status.not-applied { background: rgba(148,163,184,0.15); color: #64748b; }
[data-theme="dark"] .as-metric-status.applied { background: rgba(34,197,94,0.15); color: #4ade80; }
[data-theme="dark"] .as-metric-status.not-applied { background: rgba(148,163,184,0.1); color: #94a3b8; }

/* ── Processing Overlay ── */
.as-processing-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
    z-index: 10;
    border-radius: 8px;
}
.as-processing-overlay.visible {
    display: flex;
    animation: asFadeIn 0.2s ease;
}
.as-processing-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(99,102,241,0.2);
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: asSpin 0.8s linear infinite;
}
@keyframes asSpin {
    to { transform: rotate(360deg); }
}
.as-processing-text {
    font-size: 13px;
    color: #a5b4fc;
    font-weight: 500;
}

/* ── Footer ── */
.as-footer {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-panel-header);
    gap: 10px;
    flex-shrink: 0;
    height: 48px;
}
.as-footer-info {
    font-size: 10px;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: 'Segoe UI', system-ui, sans-serif;
}
.as-footer-info svg { width: 12px; height: 12px; opacity: 0.6; }
.as-footer-spacer { flex: 1; }
.as-btn-footer {
    padding: 6px 16px;
    border-radius: 3px;
    border: 1px solid var(--border);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: 'Segoe UI', system-ui, sans-serif;
}
.as-btn-footer svg { width: 14px; height: 14px; }
.as-btn-cancel {
    background: var(--bg-input);
    color: var(--text);
    border-color: var(--border);
}
.as-btn-cancel:hover {
    background: var(--bg-hover);
    color: var(--text-bright);
    border-color: var(--text-dim);
}
.as-btn-confirm {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.as-btn-confirm:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}
.as-btn-confirm:active {
    background: var(--accent-active);
}
.as-btn-confirm.confirmed {
    background: var(--success);
    border-color: var(--success);
}

/* Light theme handled by CSS variables - no overrides needed */

/* ── Inline alignment mode selector in settings ── */
.alignment-mode-section {
    margin-top: 8px;
}
.alignment-mode-row {
    display: flex;
    align-items: center;
    gap: 12px;
}
.alignment-mode-select {
    flex: 1;
    max-width: 260px;
}
.btn-alignment-studio {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    border-radius: 6px;
    border: 1px solid rgba(0,102,204,0.3);
    background: rgba(0,102,204,0.07);
    color: #0066cc;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.btn-alignment-studio:hover {
    background: rgba(0,102,204,0.13);
    border-color: rgba(0,102,204,0.55);
    color: #004c99;
    box-shadow: 0 1px 6px rgba(0,102,204,0.15);
}
.btn-alignment-studio svg {
    width: 14px;
    height: 14px;
}
[data-theme="dark"] .btn-alignment-studio {
    border-color: rgba(108,182,255,0.25);
    background: rgba(0,120,212,0.1);
    color: #6cb6ff;
}
[data-theme="dark"] .btn-alignment-studio:hover {
    background: rgba(0,120,212,0.18);
    border-color: rgba(108,182,255,0.5);
    color: #a5d6ff;
}



/* Desktop-specific alignment controls */
.prop-alignment-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.prop-btn-studio {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: 5px;
    border: 1px solid rgba(99,102,241,0.3);
    background: rgba(99,102,241,0.08);
    color: #818cf8;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: auto;
    justify-content: center;
}
.prop-btn-studio:hover {
    background: rgba(99,102,241,0.15);
    border-color: rgba(99,102,241,0.5);
}
.prop-btn-studio svg { width: 12px; height: 12px; }

/* ── Scrollbar for techniques list ── */
.as-techniques-list::-webkit-scrollbar {
    width: 8px;
}
.as-techniques-list::-webkit-scrollbar-track {
    background: var(--bg-panel);
    border-radius: 4px;
}
.as-techniques-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
    min-height: 32px;
}
.as-techniques-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-dim);
}
.as-techniques-list::-webkit-scrollbar-corner {
    background: var(--bg-panel);
}

/* ── Success pulse animation ── */
@keyframes asSuccessPulse {
    0% { box-shadow: 0 0 0 0 rgba(34,197,94,0.4); }
    70% { box-shadow: 0 0 0 8px rgba(34,197,94,0); }
    100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}
.as-technique-card.success-pulse {
    animation: asSuccessPulse 0.8s ease;
}

/* ── Saved Card Highlight ── */
.as-technique-card.saved {
    border-color: var(--success);
    background: var(--success-bg);
}
.as-technique-card.saved::before {
    background: var(--success);
}

/* ── Technique Info Layout ── */
.as-technique-info {
    flex: 1;
    min-width: 0;
}
.as-technique-status {
    margin-top: 2px;
}
.as-mini-metric {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.as-mini-metric svg { width: 10px; height: 10px; flex-shrink: 0; }
.as-mini-metric.success { background: var(--success-bg); color: var(--success); }
.as-mini-metric.neutral { background: var(--bg-input); color: var(--text-dim); }

/* ── Transform Indicator Overlay ── */
.as-transform-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 5;
    display: flex;
    flex-direction: column;
    gap: 4px;
    pointer-events: none;
}
.as-indicator-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(4px);
    border: 1px solid var(--border);
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    animation: asIndicatorSlideIn 0.4s ease backwards;
    white-space: nowrap;
}
[data-theme="light"] .as-indicator-item {
    background: rgba(255,255,255,0.95);
    color: var(--accent);
}
.as-indicator-item svg { width: 12px; height: 12px; }
.as-indicator-item:nth-child(2) { animation-delay: 0.1s; }
.as-indicator-item:nth-child(3) { animation-delay: 0.2s; }
@keyframes asIndicatorSlideIn {
    from { opacity: 0; transform: translateX(10px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ── VS Arrow Between Panes ── */
.as-preview-vs {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    flex-shrink: 0;
    color: var(--text-dim);
    opacity: 0.5;
}
.as-preview-vs svg { width: 20px; height: 20px; }

/* ── Aligned Image Wrap ── */
.as-aligned-wrap { position: relative; }
.as-aligned-img { display: block; max-width: 100%; max-height: calc(92vh - 240px); object-fit: contain; }

/* ── Processing Progress Bar ── */
.as-processing-step {
    font-size: 11px;
    color: var(--text-dim);
    min-height: 16px;
    transition: opacity 0.2s;
}
.as-processing-bar {
    width: 200px;
    height: 3px;
    border-radius: 2px;
    background: var(--bg-input);
    overflow: hidden;
    margin-top: 4px;
}
.as-processing-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.35s ease;
}

/* ── Saved Indicator in Header ── */
.as-saved-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    background: var(--bg-input);
    white-space: nowrap;
}
.as-saved-indicator svg { width: 14px; height: 14px; }
.as-saved-indicator.active {
    background: var(--success-bg);
    color: var(--success);
}

/* ── Slide-in / Fade-in Animations ── */
.as-fade-in {
    animation: asFadeIn 0.35s ease;
}
.as-slide-in {
    animation: asSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes asSlideIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
.as-img-reveal {
    animation: asImgReveal 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes asImgReveal {
    0% { opacity: 0; transform: scale(0.97); filter: blur(4px); }
    100% { opacity: 1; transform: scale(1); filter: blur(0); }
}

/* ── Metric Reason ── */
.as-metric-reason {
    font-style: italic;
    opacity: 0.7;
}

/* ── BESTCH Similarity Popup ── */
.as-similarity-popup {
    position: absolute;
    inset: 0;
    z-index: 20;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
}
[data-theme="light"] .as-similarity-popup {
    background: rgba(0, 0, 0, 0.5);
}
.as-similarity-popup.visible {
    display: flex;
    animation: asFadeIn 0.3s ease;
}
.as-similarity-popup-inner {
    background: var(--bg-panel);
    border: 1px solid var(--error);
    border-radius: 16px;
    padding: 32px;
    max-width: 480px;
    width: 90%;
    text-align: center;
    box-shadow: 0 24px 64px rgba(0,0,0,0.5);
    animation: asScaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
[data-theme="light"] .as-similarity-popup-inner {
    box-shadow: 0 24px 64px rgba(0,0,0,0.15);
}
.as-similarity-popup-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: var(--error-bg);
    color: var(--error);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}
.as-similarity-popup-icon svg { width: 28px; height: 28px; }
.as-similarity-popup-inner h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--error);
    margin: 0 0 10px;
}
.as-similarity-popup-msg {
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.6;
    margin: 0 0 20px;
}
.as-similarity-popup-details {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 24px;
}
.as-similarity-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
}
.as-similarity-detail-row + .as-similarity-detail-row {
    border-top: 1px solid var(--border);
}
.as-similarity-detail-label {
    font-size: 12px;
    color: var(--text-dim);
}
.as-similarity-detail-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    font-family: 'Cascadia Code', 'Consolas', monospace;
}
.as-similarity-detail-value.as-sim-bad { color: var(--error); }
.as-similarity-popup-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}
.as-similarity-popup-actions .as-btn-footer {
    flex: 1;
    justify-content: center;
}
.as-btn-proceed {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid var(--error);
}
.as-btn-proceed:hover {
    background: var(--error-bg);
    color: var(--error);
    border-color: var(--error);
    opacity: 0.8;
}

/* ── Red Calibration Button ── */
.as-btn-calibration {
    background: var(--error);
    color: #fff;
    border-color: var(--error);
}
.as-btn-calibration:hover {
    background: var(--error);
    border-color: var(--error);
    opacity: 0.85;
}
.as-btn-calibration:active {
    opacity: 0.7;
}
.as-btn-calibration svg { width: 16px; height: 16px; }
.as-btn-calibration.processing {
    opacity: 0.7;
    pointer-events: none;
    animation: as-pulse-glow 1.5s ease-in-out infinite;
}
@keyframes as-pulse-glow {
    0%, 100% { box-shadow: 0 2px 8px var(--error-bg); }
    50% { box-shadow: 0 4px 20px var(--error-bg); }
}

/* ── Download Calibration Report Button ── */
.as-btn-download-calibration {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
}
.as-btn-download-calibration:hover {
    background: var(--success);
    border-color: var(--success);
    opacity: 0.85;
    transform: translateY(-1px);
}
.as-btn-download-calibration:active {
    transform: translateY(0);
}
.as-btn-download-calibration svg { width: 16px; height: 16px; }
.as-btn-download-calibration.processing {
    opacity: 0.7;
    pointer-events: none;
}

/* ── Cropping Badge ── */
[data-theme="dark"] .as-badge.cropping { background: rgba(245,158,11,0.12); color: #fbbf24; }
[data-theme="light"] .as-badge.cropping { background: rgba(245,158,11,0.15); color: #d97706; }

/* Light theme handled by CSS variables */

/* ── Responsive ── */
@media (max-width: 900px) {
    .as-body { flex-direction: column; }
    .as-techniques-panel {
        width: 100%;
        min-width: auto;
        max-height: 250px;
        border-right: none;
        border-bottom: 1px solid rgba(255,255,255,0.06);
    }
    .as-techniques-list {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
    }
    .as-technique-card {
        min-width: 220px;
        flex-shrink: 0;
    }
    .as-preview-pane { max-width: 100%; }
}
