*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg:           #111;
    --surface:      #1a1a1a;
    --surface-2:    #222;
    --surface-3:    #2a2a2a;
    --border:       rgba(255,255,255,0.08);
    --border-mid:   rgba(255,255,255,0.14);
    --border-hi:    rgba(255,255,255,0.24);
    --text:         #e2e0dc;
    --text-muted:   #777;
    --text-faint:   #444;
    --accent:       #c89a3c;
    --accent-dim:   rgba(200,154,60,0.15);
    --green:        #3c8c5a;
    --green-bg:     rgba(60,140,90,0.12);
    --green-text:   #5fcf88;
    --red:          #8c3c3c;
    --red-bg:       rgba(140,60,60,0.12);
    --red-text:     #cf6060;
    --radius:       8px;
    --radius-lg:    12px;
    --font:         -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --mono:         'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 17px;
    line-height: 1.5;
}

.app {
    max-width: 1300px;
    margin: 0 auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 21px;
}

/* ── Top bar ── */

.top-bar {
    display: flex;
    align-items: center;
    gap: 16px;
}

.top-label {
    font-size: 15px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    white-space: nowrap;
}

.top-bar select {
    flex: 1;
    max-width: 425px;
}

/* Advanced mode checkbox label */
.advanced-mode-label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 14px;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    flex-shrink: 0;
}

.advanced-mode-label input[type="checkbox"] {
    appearance: none;
    width: 15px;
    height: 15px;
    border: 0.5px solid var(--border-mid);
    border-radius: 3px;
    background: var(--surface-2);
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: border-color 0.12s, background 0.12s;
}

.advanced-mode-label input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
}

.advanced-mode-label input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 3px;
    top: 1px;
    width: 5px;
    height: 8px;
    border: 1.5px solid #000;
    border-top: none;
    border-left: none;
    transform: rotate(45deg);
}

.advanced-mode-label:hover input[type="checkbox"]:not(:checked) {
    border-color: var(--border-hi);
}

.gh-link {
    margin-left: auto;
    display: flex;
    align-items: center;
    color: var(--text-muted);
    text-decoration: none;
    padding: 8px;
    border-radius: var(--radius);
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
}

.gh-link:hover {
    color: var(--text);
    background: var(--surface-2);
}

/* ── Main layout ── */

.main {
    display: grid;
    grid-template-columns: 293px 1fr;
    gap: 27px;
    align-items: start;
}

.right {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.jewel-svg {
    width: 293px;
    height: 293px;
    background: #0e0e0e;
    border: 0.5px solid var(--border-mid);
    border-radius: var(--radius-lg);
    display: block;
}

select {
    padding: 9px 37px 9px 13px;
    background: var(--surface-2);
    border: 0.5px solid var(--border-mid);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 17px;
    font-family: var(--font);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%23666' d='M5 7L0 2h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    cursor: pointer;
}

select:focus { outline: none; border-color: var(--border-hi); }

/* ── Slot headers ── */

.slot-headers {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.slot-card {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 12px 16px;
    background: var(--surface);
    border: 0.5px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.12s, background 0.12s;
    user-select: none;
    min-width: 0;
    overflow: hidden;
}

.slot-card:hover { border-color: var(--border-mid); }

.slot-card.active {
    border-color: rgba(255,255,255,0.28);
    background: rgba(255,255,255,0.05);
}

.slot-num {
    width: 29px;
    height: 29px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 500;
    flex-shrink: 0;
    background: var(--surface-3);
    color: var(--text-muted);
    border: 0.5px solid var(--border-mid);
}

.slot-num.active {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
}

.slot-content {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.slot-icon {
    width: 37px;
    height: 37px;
    flex-shrink: 0;
    border-radius: 5px;
    background: var(--surface-3);
    display: block;
}

.slot-text { flex: 1; min-width: 0; }

.slot-name {
    font-size: 17px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.slot-meta {
    font-size: 15px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
    overflow: hidden;
}

.slot-meta-text {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.slot-empty {
    font-size: 16px;
    color: var(--text-faint);
    font-style: italic;
}

.slot-clear {
    background: none;
    border: none;
    color: var(--text-faint);
    cursor: pointer;
    font-size: 16px;
    padding: 3px 5px;
    border-radius: 4px;
    flex-shrink: 0;
    line-height: 1;
}

.slot-clear:hover { color: var(--text); background: var(--surface-3); }

/* ── Highlight bar ── */

.picker-top-bar {
    padding: 4px 0 2px;
    min-height: 0;
}

.highlight-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
}

.hl-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 3px;
    border: 0.5px solid;
    cursor: pointer;
    background: none;
    font-family: var(--font);
    white-space: nowrap;
    transition: opacity 0.12s, transform 0.1s;
    user-select: none;
    line-height: 1.5;
}

.hl-tag:hover { opacity: 0.8; transform: translateY(-1px); }

.hl-tag--active {
    box-shadow: 0 0 0 1.5px currentColor;
    font-weight: 600;
}

/* ── Picker panes ── */

.picker-panes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 13px;
}

.picker-card {
    background: var(--surface);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

/* ── Pane header — shared visual style for both div and input ── */

.pane-header,
.pane-header-input {
    display: block;
    width: 100%;
    padding: 11px 16px;
    font-size: 13px;
    font-family: var(--font);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    border-bottom: 0.5px solid var(--border);
    line-height: 1.5;
    /* reset all input chrome */
    background: transparent;
    border-top: none;
    border-left: none;
    border-right: none;
    border-radius: 0;
    outline: none;
    box-shadow: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: text;
}

/* When the input has content, brighten slightly to hint it's active */
.pane-header-input:not(:placeholder-shown) {
    color: var(--text);
}

/* Subtle focus indicator — just a slightly brighter bottom border */
.pane-header-input:focus {
    border-bottom-color: var(--border-mid);
    color: var(--text);
}

/* Placeholder looks identical to the original static label */
.pane-header-input::placeholder {
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 1;
}

/* ── Notable items ── */

.notable-list {
    display: flex;
    flex-direction: column;
}

.notable-item {
    display: flex;
    align-items: flex-start;
    padding: 9px 14px;
    border-bottom: 0.5px solid var(--border);
    transition: background 0.1s, opacity 0.15s;
}

.notable-item:last-child { border-bottom: none; }

.notable-item.clickable { cursor: pointer; }
.notable-item.clickable:hover { background: var(--surface-2); }

.notable-item.in-window { background: var(--green-bg); }
.notable-item.in-window:hover { background: rgba(60,140,90,0.2); }

.notable-item.is-selected {
    background: rgba(255,255,255,0.06);
    border-left: 2px solid rgba(255,255,255,0.25);
}

.notable-item.is-selected.is-undesired {
    border-left: 2px solid rgba(140,60,180,0.6);
}

.notable-item.is-used    { opacity: 0.4; }
.notable-item.is-blocked { opacity: 0.35; }
.notable-item.tag-dimmed { opacity: 0.2; }

/* ── Notable body ── */

.ni-main {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    gap: 4px;
}

.ni-top-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
}

.ni-name {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.ni-right {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
    margin-left: auto;
}

.ni-id {
    font-size: 12px;
    font-family: var(--mono);
    color: var(--text-faint);
    min-width: 44px;
    text-align: right;
}


/* Advanced-mode cluster type row — between name and tags */
.ni-cluster-row {
    font-size: 11px;
    font-family: var(--mono);
    color: var(--text-faint);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.ni-bottom-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

/* ── Notable inline tags ── */

.ni-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 3px;
    border: 0.5px solid;
    white-space: nowrap;
    font-family: var(--font);
    flex-shrink: 0;
    line-height: 1.4;
}

.ni-tag--ilvl { font-weight: 600; }

/* ── Status tags ── */

.undesired-tag {
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 3px;
    background: rgba(140,60,180,0.12);
    color: #c07af0;
    border: 0.5px solid rgba(140,60,180,0.3);
    white-space: nowrap;
}

.notable-item.is-undesired { opacity: 0.7; }

.variant-tag {
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 3px;
    background: rgba(60,100,180,0.12);
    color: #7aacf0;
    border: 0.5px solid rgba(100,140,220,0.3);
    white-space: nowrap;
}

.desired-tag {
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 3px;
    background: var(--green-bg);
    color: var(--green-text);
    border: 0.5px solid var(--green);
    white-space: nowrap;
}

.blocked-tag {
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 3px;
    background: var(--red-bg);
    color: var(--red-text);
    white-space: nowrap;
}

.used-tag {
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 3px;
    background: var(--surface-3);
    color: var(--text-muted);
    white-space: nowrap;
}

/* ── Slot icon wrap ── */

.slot-icon-wrap {
    position: relative;
    width: 37px;
    height: 37px;
    flex-shrink: 0;
    align-self: center;
}

.pos-dot {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: 1.5px solid var(--surface);
}

/* ── Locked / fractured / imprinted ── */

.slot-card.locked {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.slot-locked {
    font-size: 16px;
    color: var(--text-faint);
    font-style: italic;
}

.slot-card.fractured {
    border-color: #b8965a;
    background: rgba(184,150,90,0.08);
}

.slot-card.fractured.active {
    border-color: #c8a86a;
    background: rgba(184,150,90,0.14);
}

.fractured-tag {
    display: inline-block;
    flex-shrink: 0;
    font-size: 9px;
    padding: 1px 5px;
    border-radius: 3px;
    background: rgba(184,150,90,0.18);
    color: #c8a86a;
    border: 0.5px solid rgba(184,150,90,0.4);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.slot-card.imprinted {
    border-color: #5ab8b0;
    background: rgba(90,184,176,0.08);
}

.slot-card.imprinted.active {
    border-color: #6ac8c0;
    background: rgba(90,184,176,0.14);
}

.imprint-tag {
    display: inline-block;
    flex-shrink: 0;
    font-size: 9px;
    padding: 1px 5px;
    border-radius: 3px;
    background: rgba(90,184,176,0.18);
    color: #6ac8c0;
    border: 0.5px solid rgba(90,184,176,0.4);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ── Tooltip ── */

.ni-tooltip {
    display: none;
    position: absolute;
    z-index: 9999;
    background: #0d0d0d;
    border: 0.5px solid rgba(200,154,60,0.5);
    border-radius: var(--radius);
    padding: 10px 14px;
    min-width: 180px;
    max-width: 320px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.7);
    pointer-events: none;
}

.ni-tooltip-line {
    font-family: var(--font);
    font-size: 13px;
    color: #c8b99a;
    line-height: 1.55;
    text-align: center;
}

.ni-tooltip-line + .ni-tooltip-line {
    margin-top: 3px;
}

select:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ── Responsive ── */

@media (max-width: 820px) {
    .advanced-mode-label span { display: none; }
}

@media (max-width: 620px) {
    .app {
        padding: 1rem;
        gap: 12px;
    }

    .top-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .top-bar select {
        max-width: none;
        flex: 1;
        min-width: 0;
    }

    .top-label { display: none; }

    .main {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .jewel-aside {
        display: flex;
        justify-content: center;
    }

    .jewel-svg {
        width: 100%;
        height: auto;
        aspect-ratio: 1;
    }

    .notable-list {
        max-height: none;
        overflow-y: visible;
    }

    .picker-panes {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .ni-right { flex-wrap: wrap; }
    .ni-id { display: none; }
    .blocked-tag { display: none; }
    .desired-tag { display: none; }
}