/* ============================================
   GemID — Design System & Styles
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    /* Color Palette */
    --bg-primary: #0a0a0f;
    --bg-secondary: #111118;
    --bg-tertiary: #1a1a24;
    --bg-card: rgba(22, 22, 35, 0.7);
    --bg-card-hover: rgba(30, 30, 48, 0.85);
    --bg-glass: rgba(18, 18, 30, 0.65);
    --bg-glass-border: rgba(255, 255, 255, 0.06);

    --text-primary: #f0f0f5;
    --text-secondary: #9d9db5;
    --text-muted: #6b6b80;
    --text-accent: #a78bfa;

    --accent-primary: #818cf8;
    --accent-secondary: #a78bfa;
    --accent-tertiary: #c084fc;
    --accent-glow: rgba(129, 140, 248, 0.15);
    --accent-glow-strong: rgba(129, 140, 248, 0.3);

    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-active: rgba(129, 140, 248, 0.4);

    --danger: #f87171;
    --success: #34d399;
    --warning: #fbbf24;

    /* Gem color mapping */
    --gem-red: #ef4444;
    --gem-orange: #f97316;
    --gem-yellow: #eab308;
    --gem-green: #22c55e;
    --gem-blue: #3b82f6;
    --gem-violet: #8b5cf6;
    --gem-brown: #a3754e;
    --gem-white: #e2e8f0;
    --gem-gray: #6b7280;
    --gem-black: #1f2937;
    --gem-pink: #ec4899;

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 12px;
    --space-lg: 16px;
    --space-xl: 24px;
    --space-2xl: 32px;
    --space-3xl: 48px;

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 24px rgba(129, 140, 248, 0.15);

    /* Transitions */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --duration-fast: 150ms;
    --duration-normal: 250ms;
    --duration-slow: 400ms;

    /* Layout */
    --header-height: 64px;
    --filter-width: 340px;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

/* --- Ambient Background --- */
.ambient-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.ambient-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.4;
    animation: orbit 30s ease-in-out infinite;
}

.orb-1 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(129, 140, 248, 0.15), transparent 70%);
    top: -200px;
    right: -100px;
    animation-duration: 25s;
}

.orb-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(167, 139, 250, 0.1), transparent 70%);
    bottom: -150px;
    left: -100px;
    animation-duration: 35s;
    animation-delay: -10s;
}

.orb-3 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(192, 132, 252, 0.08), transparent 70%);
    top: 40%;
    left: 30%;
    animation-duration: 40s;
    animation-delay: -20s;
}

@keyframes orbit {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(40px, -30px) scale(1.05); }
    50% { transform: translate(-20px, 20px) scale(0.95); }
    75% { transform: translate(30px, 40px) scale(1.02); }
}

/* --- Header --- */
#app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    z-index: 100;
    background: rgba(10, 10, 15, 0.8);
    backdrop-filter: blur(20px) saturate(1.5);
    -webkit-backdrop-filter: blur(20px) saturate(1.5);
    border-bottom: 1px solid var(--border-subtle);
}

.header-inner {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 var(--space-xl);
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-group {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: gem-float 4s ease-in-out infinite;
}

@keyframes gem-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

.logo-text {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-tertiary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-subtitle {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    background: transparent;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--duration-fast) ease;
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-active);
    color: var(--text-primary);
}

a.btn-ghost {
    text-decoration: none;
}

.btn-tiny {
    padding: var(--space-xs) var(--space-md);
    font-size: 0.75rem;
}

.match-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    background: var(--accent-glow);
    border: 1px solid var(--border-active);
    border-radius: var(--radius-full);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-secondary);
    letter-spacing: 0.02em;
    transition: all var(--duration-normal) var(--ease-out);
}

/* --- Main Layout --- */
#app-main {
    display: flex;
    gap: var(--space-xl);
    max-width: 1600px;
    margin: 0 auto;
    padding: calc(var(--header-height) + var(--space-xl)) var(--space-xl) var(--space-xl);
    position: relative;
    z-index: 1;
}

/* --- Glass Panel (Filter Sidebar) --- */
.glass-panel {
    background: var(--bg-glass);
    backdrop-filter: blur(24px) saturate(1.2);
    -webkit-backdrop-filter: blur(24px) saturate(1.2);
    border: 1px solid var(--bg-glass-border);
    border-radius: var(--radius-lg);
}

#filter-panel {
    position: sticky;
    top: calc(var(--header-height) + var(--space-xl));
    width: var(--filter-width);
    min-width: var(--filter-width);
    height: fit-content;
    max-height: calc(100vh - var(--header-height) - var(--space-2xl) - var(--space-xl));
    overflow-y: auto;
    padding: var(--space-xl);
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
}

/* Custom scrollbar for filter panel */
#filter-panel::-webkit-scrollbar {
    width: 4px;
}
#filter-panel::-webkit-scrollbar-track {
    background: transparent;
}
#filter-panel::-webkit-scrollbar-thumb {
    background: var(--border-subtle);
    border-radius: var(--radius-full);
}

.panel-header h2 {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
}

/* --- Filter Sections --- */
.filter-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.filter-label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.label-text {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.label-range {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--accent-secondary);
}

/* --- Dual Range Slider --- */
.dual-range-container {
    position: relative;
    height: 32px;
    display: flex;
    align-items: center;
}

.range-track {
    position: absolute;
    width: 100%;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    pointer-events: none;
}

.range-fill {
    position: absolute;
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-tertiary));
    border-radius: var(--radius-full);
    transition: left var(--duration-fast) ease, width var(--duration-fast) ease;
}

.range-input {
    position: absolute;
    width: 100%;
    height: 32px;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    pointer-events: none;
    outline: none;
    margin: 0;
}

.range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--bg-primary);
    border: 2px solid var(--accent-primary);
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
    transition: all var(--duration-fast) ease;
    box-shadow: 0 0 8px rgba(129, 140, 248, 0.3);
}

.range-input::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 0 16px rgba(129, 140, 248, 0.5);
    border-color: var(--accent-tertiary);
}

.range-input::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--bg-primary);
    border: 2px solid var(--accent-primary);
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
    transition: all var(--duration-fast) ease;
    box-shadow: 0 0 8px rgba(129, 140, 248, 0.3);
}

.range-input::-moz-range-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 0 16px rgba(129, 140, 248, 0.5);
}

/* --- Number Inputs Row --- */
.range-inputs-row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.num-input {
    flex: 1;
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 500;
    text-align: center;
    outline: none;
    transition: border-color var(--duration-fast) ease;
    -moz-appearance: textfield;
}

.num-input::-webkit-inner-spin-button,
.num-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.num-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.range-separator {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
}

/* --- Chip Group (Optical Character) --- */
.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.chip {
    padding: 6px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--duration-fast) ease;
    letter-spacing: 0.02em;
}

.chip:hover {
    border-color: var(--border-active);
    color: var(--text-primary);
    background: rgba(129, 140, 248, 0.08);
}

.chip.active {
    background: var(--accent-glow);
    border-color: var(--accent-primary);
    color: var(--accent-secondary);
    box-shadow: 0 0 12px rgba(129, 140, 248, 0.15);
}

/* --- Search Input --- */
.search-wrapper {
    position: relative;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    outline: none;
    transition: all var(--duration-fast) ease;
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* --- Results Area --- */
#results-area {
    flex: 1;
    min-width: 0;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-lg);
    animation: fadeUp 0.5s var(--ease-out);
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Gem Card --- */
.gem-card {
    background: var(--bg-card);
    border: 1px solid var(--bg-glass-border);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out);
    position: relative;
    overflow: hidden;
}

.gem-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(129, 140, 248, 0.05), transparent 60%);
    opacity: 0;
    transition: opacity var(--duration-normal) ease;
}

.gem-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-active);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.gem-card:hover::before {
    opacity: 1;
}

.gem-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-lg);
    position: relative;
    z-index: 1;
}

.gem-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}

.gem-group {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
    font-weight: 500;
}

.gem-optic-badge {
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    flex-shrink: 0;
}

.gem-optic-badge.sr {
    background: rgba(52, 211, 153, 0.12);
    color: #34d399;
    border: 1px solid rgba(52, 211, 153, 0.2);
}

.gem-optic-badge.dr {
    background: rgba(59, 130, 246, 0.12);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.gem-optic-badge.agg {
    background: rgba(251, 191, 36, 0.12);
    color: #fbbf24;
    border: 1px solid rgba(251, 191, 36, 0.2);
}

.gem-props {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm) var(--space-lg);
    position: relative;
    z-index: 1;
}

.gem-prop {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.gem-prop-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.gem-prop-value {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.gem-colors {
    display: flex;
    gap: 4px;
    margin-top: var(--space-md);
    position: relative;
    z-index: 1;
}

.color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.15);
    transition: transform var(--duration-fast) var(--ease-spring);
}

.color-dot:hover {
    transform: scale(1.4);
}

.gem-varieties {
    margin-top: var(--space-md);
    position: relative;
    z-index: 1;
}

.variety-tag {
    display: inline-block;
    padding: 2px 8px;
    margin: 2px 3px 2px 0;
    background: rgba(167, 139, 250, 0.08);
    border: 1px solid rgba(167, 139, 250, 0.15);
    border-radius: var(--radius-sm);
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--accent-secondary);
}

/* --- Empty State --- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--space-3xl) var(--space-xl);
    color: var(--text-muted);
    gap: var(--space-md);
}

.empty-icon {
    opacity: 0.4;
    margin-bottom: var(--space-md);
}

.empty-state h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.empty-state p {
    font-size: 0.85rem;
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--duration-normal) ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    width: 100%;
    max-width: 640px;
    max-height: 85vh;
    overflow-y: auto;
    padding: var(--space-2xl);
    position: relative;
    transform: translateY(20px) scale(0.97);
    transition: transform var(--duration-slow) var(--ease-out);
}

.modal-overlay.active .modal-content {
    transform: translateY(0) scale(1);
}

.modal-close {
    position: absolute;
    top: var(--space-lg);
    right: var(--space-lg);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--duration-fast) ease;
}

.modal-close:hover {
    background: rgba(248, 113, 113, 0.1);
    border-color: rgba(248, 113, 113, 0.3);
    color: var(--danger);
}

/* Modal content styling */
.modal-gem-title {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 4px;
    padding-right: 48px;
}

.modal-gem-group {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: var(--space-xl);
}

.modal-section {
    margin-bottom: var(--space-xl);
}

.modal-section-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border-subtle);
}

.modal-props-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: var(--space-lg);
}

.modal-prop {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.modal-prop .gem-prop-label {
    font-size: 0.6rem;
}

.modal-prop .gem-prop-value {
    font-size: 0.85rem;
}

.modal-colors-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.modal-color-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.modal-color-swatch {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-varieties-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.modal-variety-tag {
    padding: 4px 12px;
    background: rgba(167, 139, 250, 0.08);
    border: 1px solid rgba(167, 139, 250, 0.2);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--accent-secondary);
}

.modal-comments {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.7;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
}

/* --- Responsive --- */
@media (max-width: 1024px) {
    #app-main {
        flex-direction: column;
    }

    #filter-panel {
        position: static;
        width: 100%;
        min-width: unset;
        max-height: none;
    }

    .results-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    }
}

@media (max-width: 640px) {
    :root {
        --header-height: 56px;
    }

    .header-inner {
        padding: 0 var(--space-lg);
    }

    #app-main {
        padding: calc(var(--header-height) + var(--space-lg)) var(--space-lg) var(--space-lg);
    }

    .results-grid {
        grid-template-columns: 1fr;
    }

    .modal-props-grid {
        grid-template-columns: 1fr 1fr;
    }

    .modal-content {
        padding: var(--space-xl);
    }

    .logo-subtitle {
        display: none;
    }
}

/* --- Card enter animation --- */
.gem-card {
    animation: cardEnter var(--duration-slow) var(--ease-out) both;
}

@keyframes cardEnter {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ============================================
   SPECTROSCOPY FILTER — Spectrum Bar & Controls
   ============================================ */

/* Collapsible spectroscopy section header */
.spectro-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    padding: 2px 0 6px;
}
.spectro-section-header .label-text {
    display: flex;
    align-items: center;
    gap: 6px;
}
.spectro-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 7px;
    background: rgba(99, 102, 241, 0.18);
    border: 1px solid rgba(99, 102, 241, 0.35);
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: 600;
    color: #a5b4fc;
    letter-spacing: 0.03em;
    font-family: var(--font-mono);
}
.spectro-badge.has-active {
    background: rgba(99, 102, 241, 0.35);
    border-color: rgba(129, 140, 248, 0.6);
    color: #c7d2fe;
}
.spectro-chevron {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    transition: transform var(--duration-fast) var(--ease-out);
    flex-shrink: 0;
}
.spectro-chevron.open {
    transform: rotate(180deg);
}

/* Interactive spectrum bar (gradient 700nm→400nm) */
.spectro-filter-body {
    overflow: hidden;
    transition: max-height var(--duration-normal) var(--ease-out),
                opacity var(--duration-normal) ease;
    max-height: 0;
    opacity: 0;
}
.spectro-filter-body.open {
    max-height: 500px;
    opacity: 1;
}

.spectrum-nm-labels {
    display: flex;
    justify-content: space-between;
    font-size: 9px;
    font-family: var(--font-mono);
    color: var(--text-muted);
    margin-bottom: 4px;
    padding: 0 1px;
}

.spectrum-bar-interactive {
    position: relative;
    height: 44px;
    border-radius: var(--radius-md);
    background: linear-gradient(to right,
        #7f0000 0%,
        #ff0000 10%,
        #ff7f00 25%,
        #ffff00 40%,
        #008000 55%,
        #0000ff 75%,
        #4b0082 90%,
        #2e0854 100%
    );
    cursor: crosshair;
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 2px 12px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.06);
    overflow: hidden;
    transition: box-shadow var(--duration-fast);
}
.spectrum-bar-interactive:hover {
    box-shadow: 0 2px 20px rgba(129,140,248,0.25), inset 0 1px 0 rgba(255,255,255,0.08);
}

/* Cursor preview line that follows mouse — dark hairline crosshair */
.spectrum-bar-interactive .preview-line {
    position: absolute;
    top: 0;
    width: 2px;
    height: 100%;
    background: #000;
    box-shadow: 0 0 1px rgba(255,255,255,0.4);
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--duration-fast);
    transform: translateX(-50%);
}
.spectrum-bar-interactive:hover .preview-line {
    opacity: 1;
}

/* Absorption line markers (placed on the bar) — crisp dark absorption hairline */
.spectro-line-marker {
    position: absolute;
    top: 0;
    width: 2px;
    height: 100%;
    background: #000;
    box-shadow: 0 0 1px rgba(0,0,0,0.9);
    transform: translateX(-50%);
    cursor: pointer;
    transition: width var(--duration-fast), box-shadow var(--duration-fast);
    pointer-events: all;
    z-index: 3;
}
.spectro-line-marker::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    border-left: 3px solid transparent;
    border-right: 3px solid transparent;
    border-top: 5px solid rgba(255,255,255,0.85);
    pointer-events: none;
}
.spectro-line-marker::before {
    content: attr(data-nm);
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    font-size: 9px;
    font-family: var(--font-mono);
    font-weight: 700;
    color: #fff;
    background: rgba(0,0,0,0.85);
    padding: 1px 4px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity var(--duration-fast);
    pointer-events: none;
}
.spectro-line-marker:hover::before {
    opacity: 1;
}
.spectro-line-marker:hover {
    width: 3.5px;
    box-shadow: 0 0 3px rgba(0,0,0,1);
}

/* Tolerance band shading around each marker */
.spectro-tolerance-band {
    position: absolute;
    top: 0;
    height: 100%;
    background: rgba(0, 0, 0, 0.32);
    border-left: 1px dashed rgba(255, 255, 255, 0.25);
    border-right: 1px dashed rgba(255, 255, 255, 0.25);
    pointer-events: none;
    transform: none;
}

/* Controls below the spectrum bar */
.spectro-controls-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}
.spectro-nm-input {
    width: 72px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 12px;
    padding: 5px 8px;
    outline: none;
    transition: border-color var(--duration-fast);
}
.spectro-nm-input:focus {
    border-color: var(--border-active);
}
.spectro-add-btn {
    padding: 5px 10px;
    background: var(--accent-primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--duration-fast), transform var(--duration-fast);
    white-space: nowrap;
}
.spectro-add-btn:hover {
    background: var(--accent-secondary);
    transform: translateY(-1px);
}
.spectro-add-btn:active {
    transform: translateY(0);
}

.spectro-tolerance-select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 11px;
    padding: 5px 6px;
    outline: none;
    cursor: pointer;
    flex-shrink: 0;
}
.spectro-tolerance-select:focus {
    border-color: var(--border-active);
}

/* Active bands list */
.spectro-active-bands {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
    min-height: 0;
}
.spectro-band-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px 3px 10px;
    border-radius: var(--radius-full);
    font-size: 10px;
    font-family: var(--font-mono);
    font-weight: 600;
    color: #fff;
    cursor: default;
    border: 1px solid rgba(255,255,255,0.15);
    animation: chipIn 200ms var(--ease-spring) both;
}
@keyframes chipIn {
    from { transform: scale(0.7); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
.spectro-band-chip .chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: rgba(0,0,0,0.25);
    cursor: pointer;
    font-size: 9px;
    line-height: 1;
    color: rgba(255,255,255,0.8);
    transition: background var(--duration-fast);
    flex-shrink: 0;
    border: none;
}
.spectro-band-chip .chip-remove:hover {
    background: rgba(0,0,0,0.5);
    color: #fff;
}

/* Match ALL / ANY toggle */
.spectro-match-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-subtle);
}
.spectro-match-label {
    font-size: 11px;
    color: var(--text-muted);
}
.spectro-match-toggle {
    display: flex;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    padding: 2px;
    border: 1px solid var(--border-subtle);
    gap: 2px;
}
.spectro-match-btn {
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: background var(--duration-fast), color var(--duration-fast);
    background: transparent;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}
.spectro-match-btn.active {
    background: var(--accent-primary);
    color: #fff;
    box-shadow: 0 1px 4px rgba(129,140,248,0.4);
}

/* Preset buttons */
.spectro-presets {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    margin-top: 8px;
}
.spectro-preset-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-size: 10px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--duration-fast), border-color var(--duration-fast), color var(--duration-fast);
    text-align: left;
}
.spectro-preset-btn:hover {
    background: rgba(129,140,248,0.1);
    border-color: rgba(129,140,248,0.3);
    color: var(--text-primary);
}
.spectro-preset-btn .preset-nm {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--text-muted);
}

/* Clear all link */
.spectro-clear-btn {
    background: none;
    border: none;
    font-size: 10px;
    color: var(--danger);
    cursor: pointer;
    padding: 0;
    opacity: 0.7;
    transition: opacity var(--duration-fast);
}
.spectro-clear-btn:hover { opacity: 1; }

/* ============================================
   MINI SPECTRUM ON GEM CARDS
   ============================================ */
.gem-mini-spectrum {
    margin-top: 8px;
    position: relative;
    height: 18px;
    border-radius: 4px;
    background: linear-gradient(to right,
        #7f0000 0%,
        #ff0000 10%,
        #ff7f00 25%,
        #ffff00 40%,
        #008000 55%,
        #0000ff 75%,
        #4b0082 90%,
        #2e0854 100%
    );
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.06);
}
.gem-mini-spectrum .mini-absorption {
    position: absolute;
    top: 0;
    height: 100%;
    background: linear-gradient(to right,
        rgba(0,0,0,0) 0%,
        rgba(0,0,0,0.62) 18%,
        rgba(0,0,0,0.88) 50%,
        rgba(0,0,0,0.62) 82%,
        rgba(0,0,0,0) 100%
    );
    pointer-events: none;
}
.gem-mini-spectrum .mini-line {
    position: absolute;
    top: 0;
    width: 1.5px;
    height: 100%;
    background: rgba(0,0,0,0.85);
    box-shadow: 0 0 1px rgba(0,0,0,0.9);
    transform: translateX(-50%);
    pointer-events: none;
}
.gem-mini-spectrum .mini-line.mini-line-match {
    width: 2.5px;
    background: #000;
    box-shadow: 0 0 2px rgba(0,0,0,1);
    z-index: 2;
}
.gem-spectrum-label {
    font-size: 9px;
    font-family: var(--font-mono);
    color: var(--text-muted);
    margin-top: 3px;
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}
.gem-spectrum-nm {
    color: #a5b4fc;
    font-weight: 600;
}
.gem-spectrum-nm.matched-nm {
    color: #e0e7ff;
    font-weight: 800;
    text-shadow: 0 0 6px rgba(129, 140, 248, 0.7);
}
.gem-mini-spectrum.gem-spectrum-match-highlight {
    border-color: rgba(129, 140, 248, 0.45);
    box-shadow: 0 0 8px rgba(129, 140, 248, 0.2);
}

/* Spectroscopy section in modal */
.modal-spectrum-container {
    margin-bottom: 8px;
}
.modal-spectrum-bar {
    position: relative;
    height: 36px;
    border-radius: var(--radius-sm);
    background: linear-gradient(to right,
        #7f0000 0%,
        #ff0000 10%,
        #ff7f00 25%,
        #ffff00 40%,
        #008000 55%,
        #0000ff 75%,
        #4b0082 90%,
        #2e0854 100%
    );
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 6px;
}
.modal-spectrum-bar .modal-abs-band {
    position: absolute;
    top: 0;
    height: 100%;
    background: linear-gradient(to right,
        rgba(0,0,0,0) 0%,
        rgba(0,0,0,0.65) 18%,
        rgba(0,0,0,0.92) 50%,
        rgba(0,0,0,0.65) 82%,
        rgba(0,0,0,0) 100%
    );
    pointer-events: none;
    transition: opacity var(--duration-fast);
}
.modal-spectrum-bar .modal-abs-line {
    position: absolute;
    top: 0;
    width: 2px;
    height: 100%;
    background: #000;
    box-shadow: 0 0 1px rgba(0,0,0,0.95);
    transform: translateX(-50%);
    cursor: pointer;
    transition: width var(--duration-fast), box-shadow var(--duration-fast);
}
.modal-spectrum-bar .modal-abs-line:hover {
    width: 3.5px;
    box-shadow: 0 0 3px rgba(0,0,0,1);
}
.modal-spectrum-nm-labels {
    display: flex;
    justify-content: space-between;
    font-size: 9px;
    font-family: var(--font-mono);
    color: var(--text-muted);
    margin-bottom: 8px;
}
.modal-spectro-lines-list {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 6px;
}
.modal-spectro-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 10px;
    font-family: var(--font-mono);
    font-weight: 600;
    border: 1px solid rgba(255,255,255,0.12);
    color: #fff;
}
.modal-spectro-band-detail {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 8px;
    line-height: 1.6;
}
.modal-spectro-band-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    margin-bottom: 4px;
}
.modal-spectro-band-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
    margin-top: 2px;
}
.modal-spectro-meta {
    display: flex;
    gap: 12px;
    margin-top: 8px;
    font-size: 10px;
    color: var(--text-muted);
    flex-wrap: wrap;
}
.modal-spectro-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}
.modal-spectro-meta strong {
    color: var(--text-secondary);
}

