:root {
    --bg-color: #0b0f19;
    --panel-bg: rgba(22, 33, 62, 0.7);
    --panel-border: rgba(255, 255, 255, 0.1);
    --text-main: #e0e6ed;
    --text-muted: #8b9bb4;
    --accent: #f0c040;
    --accent-hover: #ffcf54;
    --action-reset: #2d8a4e;
    --action-cut: #6a6a20;
    --action-fuse: #5b3a8c;
    --action-ignore: #5a2020;
    --font-main: 'Inter', sans-serif;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(at 0% 0%, rgba(32, 45, 90, 0.5) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(80, 40, 100, 0.4) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    padding: 2rem;
}

/* Loader */
.loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 80vh;
}
.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--panel-border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}
@keyframes spin { 100% { transform: rotate(360deg); } }

/* Layout */
header {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin-bottom: 3rem;
    text-align: center;
}
.header-content {
    flex: 1;
}
header h1 {
    font-size: 2.5rem;
    color: var(--accent);
    margin-bottom: 0.5rem;
    font-weight: 700;
    text-shadow: 0 0 20px rgba(240, 192, 64, 0.3);
}
header p {
    color: var(--text-muted);
    font-size: 1.1rem;
}
.glossary-btn {
    position: absolute;
    right: 0;
    background: rgba(240,192,64,0.12);
    border: 1px solid rgba(240,192,64,0.35);
    color: var(--accent);
    padding: 0.55rem 1.1rem;
    border-radius: 10px;
    font-family: var(--font-main);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: background 0.2s, transform 0.15s;
}
.glossary-btn:hover {
    background: rgba(240,192,64,0.25);
    transform: translateY(-1px);
}
.glossary-btn span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1.5px solid var(--accent);
    font-size: 0.8rem;
    font-weight: 700;
}

main {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Glassmorphism Panels */
.glass {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

.panel {
    padding: 1.5rem 2rem;
}

/* Controls */
.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    align-items: center;
    justify-content: space-between;
}
.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
    min-width: 250px;
}
.control-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Inputs */
select {
    appearance: none;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--panel-border);
    color: white;
    padding: 0.8rem 1rem;
    border-radius: 8px;
    font-size: 1rem;
    font-family: var(--font-main);
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}
select:focus {
    border-color: var(--accent);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 200px;
    height: 44px;
}
.toggle-switch input {
    display: none;
}
.toggle-switch label {
    display: block;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--panel-border);
    border-radius: 22px;
    cursor: pointer;
    position: relative;
    transition: all 0.3s;
}
.toggle-label {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 600;
    z-index: 2;
    transition: color 0.3s;
}
.toggle-label::after {
    content: attr(data-off);
}
.toggle-switch input:checked + label .toggle-label::after {
    content: attr(data-on);
}
.toggle-switch label::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: calc(100% - 4px);
    height: calc(100% - 4px);
    background: var(--accent);
    border-radius: 20px;
    opacity: 0.2;
    transition: all 0.3s;
}
.toggle-switch input:checked + label::before {
    background: #a470ff;
}

/* Range Slider */
.bl-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.25rem;
}
.bl-badge {
    background: rgba(240,192,64,0.15);
    border: 1px solid rgba(240,192,64,0.4);
    color: var(--accent);
    font-weight: 700;
    font-size: 1rem;
    padding: 0.15rem 0.6rem;
    border-radius: 6px;
    min-width: 2rem;
    text-align: center;
}
.range-slider {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 6px;
    outline: none;
    cursor: pointer;
    background-image: linear-gradient(
        to right,
        var(--accent) 0%,
        var(--accent) var(--pct, 0%),
        rgba(255,255,255,0.15) var(--pct, 0%),
        rgba(255,255,255,0.15) 100%
    );
    border: none;
}
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 0 3px rgba(240,192,64,0.3), 0 2px 6px rgba(0,0,0,0.5);
    transition: box-shadow 0.2s, transform 0.15s;
}
input[type=range]::-webkit-slider-thumb:hover {
    box-shadow: 0 0 0 6px rgba(240,192,64,0.25), 0 2px 8px rgba(0,0,0,0.5);
    transform: scale(1.2);
}
input[type=range]::-moz-range-thumb {
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: none;
    box-shadow: 0 0 0 3px rgba(240,192,64,0.3);
}
input[type=range]::-moz-range-track {
    height: 6px;
    background: rgba(255,255,255,0.15);
    border-radius: 6px;
}
/* Tick marks */
.slider-ticks {
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: 0;
}
.slider-tick {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
    flex: 1;
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
    line-height: 1;
}
.slider-tick:hover { color: var(--text-main); }
.slider-tick.active {
    color: var(--accent);
    font-weight: 700;
}

/* Dashboard */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 1rem;
}
.dashboard-header h2 {
    font-weight: 600;
}
.legend {
    display: flex;
    gap: 0.5rem;
}
.badge {
    padding: 0.3rem 0.8rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}
.badge-reset { background: var(--action-reset); }
.badge-cut { background: var(--action-cut); }
.badge-fuse { background: var(--action-fuse); }
.badge-ignore { background: var(--action-ignore); }

/* Gems Grid */
.gems-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.gem-card {
    background: rgba(22, 33, 62, 0.4);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}
.gem-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.4);
    border-color: rgba(255,255,255,0.2);
}

/* Rarity Styles */
.gem-card.rarity-uncommon { border-top: 3px solid #4ade80; }
.gem-card.rarity-rare { border-top: 3px solid #60a5fa; }
.gem-card.rarity-epic { border-top: 3px solid #c084fc; }

.rarity-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 8px;
}
.rarity-dot-uncommon { background-color: #4ade80; box-shadow: 0 0 8px rgba(74, 222, 128, 0.6); }
.rarity-dot-rare { background-color: #60a5fa; box-shadow: 0 0 8px rgba(96, 165, 250, 0.6); }
.rarity-dot-epic { background-color: #c084fc; box-shadow: 0 0 8px rgba(192, 132, 252, 0.6); }


.gem-header {
    padding: 0.8rem 1rem;
    background: rgba(0,0,0,0.3);
    border-bottom: 1px solid var(--panel-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.gem-title {
    font-weight: 600;
    font-size: 1.1rem;
}
.gem-ev {
    font-size: 0.85rem;
    color: var(--accent);
}

.gem-buckets {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.bucket-row {
    display: flex;
    align-items: center;
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
}
.bucket-label { width: 40px; color: rgba(255,255,255,0.7); }
.bucket-val { flex: 1; text-align: right; }
.bucket-pct { width: 50px; text-align: right; font-size: 0.8rem; opacity: 0.8; }
.bucket-icon { width: 24px; text-align: right; font-size: 1.1rem; }

/* Colors based on action */
.action-reset { background: linear-gradient(90deg, rgba(45,138,78,0.3), rgba(45,138,78,0.6)); border-left: 3px solid #4ade80; }
.action-cut { background: linear-gradient(90deg, rgba(106,106,32,0.3), rgba(106,106,32,0.6)); border-left: 3px solid #facc15; }
.action-fuse { background: linear-gradient(90deg, rgba(91,58,140,0.3), rgba(91,58,140,0.6)); border-left: 3px solid #c084fc; }
.action-ignore { background: linear-gradient(90deg, rgba(90,32,32,0.3), rgba(90,32,32,0.6)); border-left: 3px solid #f87171; opacity: 0.6; }

/* Pipeline Summary */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}
.stat-box {
    background: rgba(0,0,0,0.3);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--panel-border);
    text-align: center;
}
.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}
.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
}
.stat-value.highlight { color: #80d0ff; }
.stat-value.fast { color: #4ade80; }
.stat-value.slow { color: #f87171; }

@media (max-width: 768px) {
    .controls { flex-direction: column; align-items: stretch; }
    .control-group { min-width: 100%; }
    .glossary-btn { position: static; margin-top: 1rem; }
    header { flex-direction: column; }
}

/* ---- Glossary Modal ---- */
.glossary-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem 1rem;
    overflow-y: auto;
}
.glossary-overlay.open {
    display: flex;
}
.glossary-modal {
    width: 100%;
    max-width: 720px;
    margin: auto;
    padding: 0;
    overflow: hidden;
}
.glossary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.2rem 1.8rem;
    border-bottom: 1px solid var(--panel-border);
    background: rgba(0,0,0,0.25);
}
.glossary-header h2 {
    color: var(--accent);
    font-size: 1.3rem;
}
.glossary-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.8rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 0.2rem;
    transition: color 0.2s;
}
.glossary-close:hover { color: white; }
.glossary-body {
    padding: 1.5rem 1.8rem;
    display: flex;
    flex-direction: column;
    gap: 1.8rem;
    max-height: 75vh;
    overflow-y: auto;
}
.glossary-section h3 {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent);
    margin-bottom: 0.8rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid rgba(240,192,64,0.2);
}
dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.4rem 1rem;
    align-items: start;
}
dt {
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--text-main);
    padding-top: 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}
.icon-dt { align-items: center; }
dd {
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.6;
    padding-top: 0.4rem;
    border-top: 1px solid rgba(255,255,255,0.04);
}
/* Gem bucket tags */
.gl-tag {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 700;
}
.tag-2d  { background: rgba(45,138,78,0.4);  color: #4ade80; border: 1px solid #2d8a4e; }
.tag-op  { background: rgba(106,106,32,0.4); color: #facc15; border: 1px solid #6a6a20; }
.tag-sub { background: rgba(80,70,20,0.4);  color: #d4b060; border: 1px solid #5a4a20; }
.tag-no  { background: rgba(90,32,32,0.4);  color: #f87171; border: 1px solid #5a2020; }
/* Color swatches */
.gl-color {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
}
.gl-reset  { background: #2d8a4e; }
.gl-cut    { background: #6a6a20; }
.gl-ignore { background: #5a2020; }
.gl-fuse   { background: #5b3a8c; }
.gl-reset-icon { color: #4ade80; font-size: 1.1rem; }
/* Weeks badges */
.gl-weeks {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 700;
    margin: 0 0.2rem;
}
.gl-weeks.fast { background: #1b4332; color: #90ee90; }
.gl-weeks.med  { background: #3d3200; color: #f0c040; }
.gl-weeks.slow { background: #4a1515; color: #ff9090; }

/* ---- Scanner Panel ---- */
.scanner-panel {
    border-color: rgba(99, 179, 237, 0.25);
}
.scanner-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.scanner-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}
.scanner-subtitle {
    color: var(--text-muted);
    font-size: 0.88rem;
}
.scanner-actions {
    display: flex;
    gap: 0.6rem;
    flex-shrink: 0;
}
.scan-btn {
    background: rgba(99,179,237,0.15);
    border: 1px solid rgba(99,179,237,0.4);
    color: #90cdf4;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-family: var(--font-main);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: background 0.2s, transform 0.15s;
}
.scan-btn:hover:not(:disabled) {
    background: rgba(99,179,237,0.28);
    transform: translateY(-1px);
}
.scan-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.scan-stop {
    background: rgba(248,113,113,0.15);
    border-color: rgba(248,113,113,0.4);
    color: #fca5a5;
}
.scan-stop:hover {
    background: rgba(248,113,113,0.28) !important;
}
.scanner-status {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--panel-border);
}
.scanner-progress {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}
/* Bookmarklet Styles */
.bookmarklet-panel {
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.4), rgba(15, 23, 42, 0.4));
    border-left: 3px solid #80d0ff;
}
#bookmarklet-btn {
    text-decoration: none;
    background: linear-gradient(135deg, rgba(128, 208, 255, 0.2), rgba(128, 208, 255, 0.35));
    border: 1px solid rgba(128, 208, 255, 0.5);
    color: #80d0ff;
    cursor: grab;
}
#bookmarklet-btn:active {
    cursor: grabbing;
}
#bookmarklet-btn:hover {
    background: linear-gradient(135deg, rgba(128, 208, 255, 0.35), rgba(128, 208, 255, 0.5));
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(128, 208, 255, 0.2);
}
