:root {
    --bg: #0b0b0d;
    --surface: #151518;
    --surface-2: #1d1d21;
    --border: #2a2a30;
    --text: #f4f4f5;
    --muted: #8b8b94;
    --accent: #f97316;
    --accent-ink: #1a0a00;
    --accent-soft: rgba(249, 115, 22, .14);
    --named: #ffbe15;
    --exotic: #ef4a3a;
    --danger: #f87171;
    --shadow: 0 12px 32px rgba(0, 0, 0, .5);
    color-scheme: dark;
}
:root[data-theme="light"] {
    --bg: #f5f5f6;
    --surface: #ffffff;
    --surface-2: #f0f0f2;
    --border: #e1e1e6;
    --text: #18181b;
    --muted: #6b6b75;
    --accent: #ea580c;
    --accent-ink: #ffffff;
    --accent-soft: rgba(234, 88, 12, .1);
    --named: #c98a00;
    --exotic: #d63a2b;
    --danger: #dc2626;
    --shadow: 0 12px 32px rgba(0, 0, 0, .14);
    color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
    margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
    font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.container { max-width: 72rem; margin: 0 auto; padding: 0 20px; }
main.container { padding-top: 20px; padding-bottom: 48px; }
#list-view { max-width: 46rem; margin: 0 auto; }
body.view-hub .controls-inner { max-width: 72rem; }
body.view-hub #reset-btn { display: none; }

/* Header */
.fixed-top { position: sticky; top: 0; z-index: 50; }
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.sync-status { font-size: 12px; color: var(--muted); }

/* Buttons */
.btn {
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
    padding: 7px 14px; font-size: 13px; font-weight: 600; transition: border-color .15s, background .15s;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .6; cursor: default; }
.btn { white-space: nowrap; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.btn.full { width: 100%; }
.icon-btn {
    display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px;
    background: transparent; border: 1px solid transparent; color: var(--muted);
}
.icon-btn:hover, .icon-btn[aria-expanded="true"] { background: var(--surface-2); color: var(--text); border-color: var(--border); }

/* Settings panel */
.settings { position: relative; z-index: 10; }
.panel {
    position: absolute; right: 0; top: calc(100% + 8px); width: 300px; max-width: calc(100vw - 32px);
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    box-shadow: var(--shadow); padding: 6px 16px; max-height: calc(100vh - 100px); overflow: auto;
}
.panel section { padding: 14px 0; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.panel section:last-child { border-bottom: 0; }
.panel h2 { margin: 0; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.panel p { margin: 0; font-size: 13px; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }
.segmented { display: flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 3px; gap: 3px; }
.segmented button { flex: 1; background: transparent; border: 0; border-radius: 6px; padding: 5px 0; font-size: 13px; color: var(--muted); }
.segmented button.active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.switch-row { display: flex; align-items: center; justify-content: space-between; font-size: 13px; cursor: pointer; }
.switch-row input { appearance: none; width: 38px; height: 22px; border-radius: 11px; background: var(--border); position: relative; cursor: pointer; transition: background .15s; }
.switch-row input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch-row input:checked { background: var(--accent); }
.switch-row input:checked::after { transform: translateX(16px); }

/* Tabs */
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.nav-icon { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 8px; background: var(--surface); color: var(--muted); }
.nav-icon .glyph { width: 24px; height: 18px; }
.nav-text { display: flex; flex-direction: column; gap: 5px; min-width: 0; flex: 1; }
.nav-label { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-progress { display: flex; align-items: center; gap: 8px; }
.nav-bar { flex: 1; height: 4px; border-radius: 2px; background: var(--border); overflow: hidden; }
.nav-bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.nav-match { font-size: 11px; font-weight: 700; color: var(--muted); }
.nav-count { font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--muted); }
.subbar { border-bottom: 1px solid var(--border); background: var(--bg); }
.subbar .tabs { padding-top: 12px; padding-bottom: 12px; gap: 8px; }
.subbar .tabs:empty { padding: 0; }
.sub-tab {
    display: flex; align-items: center; gap: 9px; flex: 0 0 auto; min-width: 142px;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
    padding: 7px 12px; text-align: left; color: var(--muted); transition: border-color .15s, background .15s, color .15s;
}
.sub-tab:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); color: var(--text); }
.sub-tab.active { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.sub-tab .nav-icon { width: 30px; height: 30px; color: var(--tone, var(--muted)); }
.sub-tab .nav-icon .glyph { width: 22px; height: 16px; }
.sub-tab.active .nav-icon { background: var(--accent); color: var(--accent-ink); }
.sub-tab .nav-label { font-size: 13px; }
.tab-count { margin-left: 5px; font-size: 12px; font-weight: 500; opacity: .65; font-variant-numeric: tabular-nums; }

/* Summary + toolbar */
.controls { background: var(--bg); border-bottom: 1px solid var(--border); }
.controls-inner { max-width: 46rem; margin: 0 auto; padding: 12px 20px 12px; }
.summary { margin-bottom: 10px; }
.summary-text { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
#summary-label { font-size: 14px; font-weight: 700; }
#summary-pct { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.bar { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.bar > div { height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width .25s; }
.toolbar { display: flex; gap: 10px; align-items: center; }
.search-wrap { position: relative; flex: 1 1 200px; color: var(--muted); }
.search-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.search-wrap input {
    width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    padding: 8px 12px 8px 36px; color: var(--text);
}
.search-wrap input::placeholder { color: var(--muted); }
.search-wrap input:focus { outline: none; border-color: var(--accent); }
.chip-toggle { cursor: pointer; }
.chip-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.chip-toggle span {
    display: inline-block; padding: 7px 14px; border-radius: 8px; white-space: nowrap; font-size: 13px;
    background: var(--surface); border: 1px solid var(--border); color: var(--muted); transition: all .15s;
}
.chip-toggle input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chip-toggle input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Color coding */
[data-tone="named"] { --tone: var(--accent); }
[data-tone="exotic"] { --tone: #ef4a3a; }
[data-tone="set"] { --tone: #3fb871; }
[data-tone="brand"] { --tone: var(--accent); }
.item-row[data-tone]:not([data-tone=""]) { border-left: 4px solid var(--tone); }
.item-row[data-tone]:not([data-tone=""]) .item-info span { color: var(--tone); }

/* Items */
#items-grid { display: flex; flex-direction: column; gap: 8px; }
.item-row {
    display: flex; align-items: center; gap: 14px; padding: 12px 16px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 10px; transition: border-color .15s;
}
.item-row:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.item-row.done { border-color: var(--accent); background: linear-gradient(90deg, var(--accent-soft), var(--surface) 60%); }
.compact .item-row { padding: 6px 14px; }
.compact #items-grid { gap: 4px; }

.check input {
    appearance: none; width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--border);
    background: var(--surface-2); display: grid; place-items: center; cursor: pointer; flex: none; margin: 0; transition: all .15s;
}
.check input:hover { border-color: var(--accent); }
.check input:checked { background: var(--accent); border-color: var(--accent); }
.check input:checked::after { content: ""; width: 5px; height: 10px; border: solid var(--accent-ink); border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }

.item-icon { display: grid; place-items: center; width: 52px; height: 40px; flex: none; border-radius: 8px; background: var(--surface-2); color: var(--tone, var(--muted)); }
.item-icon .glyph { width: 36px; height: 27px; }
.item-icon img { max-width: 100%; max-height: 100%; object-fit: contain; }
.item-row.done .item-icon { color: var(--accent); }
.compact .item-icon { width: 38px; height: 28px; }
.compact .item-icon .glyph { width: 26px; height: 20px; }
.item-info { flex: 1; min-width: 0; }
.item-info h3 { margin: 0; font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-info span { font-size: 12px; color: var(--muted); }
.item-row.done .item-info h3 { color: var(--accent); }
.item-row.named .item-info h3, .item-row.named.done .item-info h3 { color: var(--named); }
.item-row.named .item-icon { color: var(--named); }
.item-row.exotic .item-info h3, .item-row.exotic.done .item-info h3 { color: var(--exotic); }
.item-row.exotic .item-icon { color: var(--exotic); }

.rank-wrap { display: flex; align-items: center; gap: 12px; width: 210px; flex: none; }
.rank-value { width: 44px; text-align: right; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--muted); }
.rank-value b { color: var(--text); }
.item-row.done .rank-value b { color: var(--accent); }
.rank-slider {
    --pct: 0%; flex: 1; min-width: 0; height: 6px; border-radius: 3px; appearance: none; cursor: pointer; outline-offset: 6px;
    background: linear-gradient(to right, var(--accent) var(--pct), var(--surface-2) var(--pct));
}
.rank-slider::-webkit-slider-thumb { appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--accent); }
.rank-slider::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--accent); }

.empty { text-align: center; padding: 56px 0; color: var(--muted); border: 2px dashed var(--border); border-radius: 12px; }
.hint { margin: 18px 0 0; font-size: 12px; color: var(--muted); text-align: center; }
.hint b { color: var(--accent); }

.about p { font-size: 12px; line-height: 1.5; }

/* Home page cards */
.hub-section { margin-bottom: 28px; }
.hub-section h2 { margin: 0 0 10px; font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.hub-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.hub-card {
    position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px;
    min-height: 104px; padding: 14px 18px 18px; text-align: left; overflow: hidden;
    background: var(--surface); border: 1px solid var(--border); border-radius: 10px; color: var(--text);
    transition: background .15s, border-color .15s, color .15s, opacity .15s;
}
.hub-card:hover, .hub-card:focus-visible { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.hub-id { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 40%; max-width: 110px; flex: none; }
.hub-icon { display: grid; place-items: center; color: var(--tone, var(--text)); }
.hub-icon .glyph { width: 60px; height: 45px; }
.hub-label { font-size: 13px; font-weight: 700; text-align: center; line-height: 1.2; }
.hub-stat { display: flex; flex-direction: column; align-items: center; flex: 1; min-width: 0; }
.hub-stat small { font-size: 13px; color: var(--muted); }
.hub-stat b { font-size: 28px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.hub-card:hover .hub-icon, .hub-card:focus-visible .hub-icon, .hub-card:hover small, .hub-card:focus-visible small { color: var(--accent-ink); }
.hub-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--surface-2); }
.hub-bar i { display: block; height: 100%; background: var(--accent); }
.hub-card:hover .hub-bar i, .hub-card:focus-visible .hub-bar i { background: var(--accent-ink); }
.hub-card.complete .hub-stat b { color: var(--accent); }
.hub-card.complete:hover .hub-stat b { color: var(--accent-ink); }
.hub-card.has-match { border-color: var(--accent); }
.hub-card.no-match { opacity: .4; }
.back-btn {
    display: flex; align-items: center; gap: 6px; flex: none; background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: 10px; padding: 0 14px; font-size: 13px; font-weight: 600;
}
.back-btn:hover { border-color: var(--accent); }

@media (max-width: 640px) {
    .hub-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .hub-card { flex-direction: column; justify-content: center; gap: 6px; padding: 12px 8px 16px; min-height: 130px; }
    .hub-id { width: auto; max-width: none; }
    .hub-stat b { font-size: 22px; }
    .hub-stat small { font-size: 11px; }
    .hub-icon .glyph { width: 48px; height: 36px; }
    .nav-icon { width: 28px; height: 28px; }
    .nav-icon .glyph { width: 20px; height: 15px; }
    .subbar .tabs { padding-top: 6px; padding-bottom: 6px; gap: 6px; }
    .sub-tab { min-width: 124px; padding: 5px 10px; }
    .controls-inner { padding: 8px 14px; }
    .summary { margin-bottom: 8px; }
    .container { padding: 0 14px; }
    .brand h1 { font-size: 15px; }
    .sync-status { display: none; }
    .item-row { flex-wrap: wrap; row-gap: 10px; }
    .item-info { flex: 1 1 0; }
    .rank-wrap { width: 100%; }
}

/* Real item icons are white line art: invert them on the light theme so they stay visible. */
:root[data-theme="light"] .item-icon img { filter: invert(1); }

/* Real item icons are white line art: invert them on the light theme so they stay visible. */
:root[data-theme="light"] .item-icon img { filter: invert(1); }


/* Monogram badges for brands and gear sets */
.monogram { font-weight: 800; font-size: 15px; letter-spacing: .04em; line-height: 1; white-space: nowrap; }
.compact .monogram { font-size: 12px; }


/* ---------- Color: each section gets its own accent ---------- */
[data-sec="weapons"] { --sec: #e8a317; --sec-ink: #1c1300; --sec-soft: rgba(232, 163, 23, .15); }
[data-sec="gear"] { --sec: #ff6600; --sec-ink: #1a0a00; --sec-soft: rgba(255, 102, 0, .15); }
[data-sec="skills"] { --sec: #ffd700; --sec-ink: #1c1600; --sec-soft: rgba(255, 215, 0, .15); }
[data-sec="collections"] { --sec: #4ade80; --sec-ink: #031a0c; --sec-soft: rgba(74, 222, 128, .15); }
:root[data-theme="light"] [data-sec="weapons"] { --sec: #a8710a; --sec-ink: #fff; --sec-soft: rgba(168, 113, 10, .10); }
:root[data-theme="light"] [data-sec="gear"] { --sec: #e65c00; --sec-ink: #fff; --sec-soft: rgba(230, 92, 0, .10); }
:root[data-theme="light"] [data-sec="skills"] { --sec: #ca8a04; --sec-ink: #fff; --sec-soft: rgba(202, 138, 4, .12); }
:root[data-theme="light"] [data-sec="collections"] { --sec: #16a34a; --sec-ink: #fff; --sec-soft: rgba(22, 163, 74, .10); }
[data-sec] { --accent: var(--sec); --accent-ink: var(--sec-ink); --accent-soft: var(--sec-soft); }

/* Background and header */
body {
    background:
        radial-gradient(900px 640px at 4% 18%, rgba(255, 102, 0, .30), transparent 65%),
        radial-gradient(900px 620px at 98% 36%, rgba(255, 215, 0, .20), transparent 65%),
        radial-gradient(1000px 700px at 14% 104%, rgba(74, 222, 128, .20), transparent 65%),
        radial-gradient(800px 560px at 88% 100%, rgba(232, 163, 23, .18), transparent 65%),
        var(--bg);
    background-repeat: no-repeat; background-attachment: fixed;
}
:root[data-theme="light"] body {
    background:
        radial-gradient(900px 640px at 4% 18%, rgba(230, 92, 0, .22), transparent 65%),
        radial-gradient(900px 620px at 98% 36%, rgba(202, 138, 4, .18), transparent 65%),
        radial-gradient(1000px 700px at 14% 104%, rgba(22, 163, 74, .16), transparent 65%),
        radial-gradient(800px 560px at 88% 100%, rgba(184, 134, 11, .15), transparent 65%),
        var(--bg);
    background-repeat: no-repeat; background-attachment: fixed;
}
.site-header { border-image: linear-gradient(90deg, #e8a317, #ff6600 35%, #ffd700 70%, #4ade80) 1; border-bottom-width: 2px; }
body.view-hub #summary-bar { background: linear-gradient(90deg, #e8a317, #ff6600, #ffd700, #4ade80); }
#summary-pct { color: var(--accent); }

/* Home page cards */
.hub-section h2 { display: flex; align-items: center; gap: 12px; color: var(--accent); font-size: 12px; }
.hub-section h2::before { content: ""; width: 4px; height: 16px; border-radius: 2px; background: var(--accent); }
.hub-section h2::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 55%, transparent), transparent); }
.hub-card {
    background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 12%, var(--surface)), var(--surface) 62%);
    border-color: color-mix(in srgb, var(--accent) 26%, var(--border));
    box-shadow: inset 3px 0 0 var(--accent);
    transition: background .15s, border-color .15s, color .15s, opacity .15s, transform .15s, box-shadow .15s;
}
.hub-card:hover, .hub-card:focus-visible {
    transform: translateY(-2px); background: var(--accent); border-color: var(--accent);
    box-shadow: 0 10px 26px -8px var(--accent), inset 3px 0 0 var(--accent-ink);
}
.hub-icon { color: var(--accent); filter: drop-shadow(0 0 7px color-mix(in srgb, var(--accent) 50%, transparent)); }
.hub-card:hover .hub-icon, .hub-card:focus-visible .hub-icon { filter: none; }
.hub-bar { background: color-mix(in srgb, var(--accent) 14%, var(--surface-2)); }
.hub-bar i { background: var(--accent); }
.hub-card.started .hub-stat b { color: var(--accent); }
.hub-card.started:hover .hub-stat b { color: var(--accent-ink); }
.hub-card.complete { box-shadow: inset 3px 0 0 var(--accent), 0 0 18px -4px var(--accent); }
.hub-card.has-match { box-shadow: inset 3px 0 0 var(--accent), 0 0 16px -4px var(--accent); }

/* List view picks up the section color through --accent; give the nav and rows a little more life */
#list-nav { border-bottom-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
#list-nav .sub-tab.active { box-shadow: 0 0 18px -6px var(--accent); }
.item-row:hover { border-color: color-mix(in srgb, var(--accent) 60%, var(--border)); }
.controls[data-sec] { border-bottom-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }


/* Category switcher in the list view: small three-column cards like the home page (scrolls with the list) */
.subnav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
#sub-tabs-container .sub-tab { min-width: 0; width: 100%; padding: 8px 10px; }
#sub-tabs-container .sub-tab .nav-label { white-space: normal; overflow: visible; line-height: 1.15; font-size: 12.5px; }
.summary-text { gap: 10px; }
#summary-label { flex: 1; }
.summary-text .back-btn { padding: 0 10px; height: 28px; font-size: 12px; gap: 4px; }
@media (max-width: 640px) { .subnav { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Collapsible category switcher */
.nav-toggle {
    display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 12px; text-align: left;
    padding: 8px 12px; margin-bottom: 8px; color: var(--text);
    background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 12%, var(--surface)), var(--surface) 65%);
    border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border)); border-radius: 10px;
    box-shadow: inset 3px 0 0 var(--accent); transition: border-color .15s;
}
.nav-toggle:hover { border-color: var(--accent); }
.nav-toggle[aria-expanded="false"] { margin-bottom: 16px; }
.nav-toggle-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.nav-toggle .nav-icon { background: var(--accent); color: var(--accent-ink); width: 30px; height: 30px; }
.nav-toggle .nav-icon .glyph { width: 22px; height: 16px; }
.nav-toggle-label { font-weight: 700; font-size: 14px; }
.nav-toggle-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.nav-toggle-hint { display: flex; align-items: center; gap: 6px; flex: none; font-size: 12px; color: var(--muted); }
.nav-toggle svg { transition: transform .15s; }
.nav-toggle[aria-expanded="true"] .nav-toggle-hint svg { transform: rotate(180deg); }

/* Site name: emblem + gradient wordmark */
.brand { gap: 12px; }
.brand-emblem { width: 30px; height: 34px; flex: none; filter: drop-shadow(0 0 8px rgba(255, 140, 0, .55)); }
.brand h1 { display: flex; flex-direction: column; gap: 3px; margin: 0; line-height: 1; min-width: 0; font-weight: 400; }
.brand-name {
    font-size: 19px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; white-space: nowrap;
    background: linear-gradient(90deg, #ff6600, #ffd700); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-sub { font-size: 10.5px; font-weight: 600; letter-spacing: .36em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
:root[data-theme="light"] .brand-name { background-image: linear-gradient(90deg, #e65c00, #b8860b); }
:root[data-theme="light"] .brand-emblem { filter: none; }
@media (max-width: 640px) {
    .brand { gap: 9px; }
    .brand-emblem { width: 24px; height: 27px; }
    .brand-name { font-size: 15px; letter-spacing: .12em; }
    .brand-sub { font-size: 8.5px; letter-spacing: .26em; }
}

/* ---------- Background options (Settings > Appearance > Background) ---------- */
:root {
    --pat-bg: linear-gradient(120deg, #ff6600 0%, #e8a317 28%, #ffd700 52%, #4ade80 80%, #22c55e 100%);
    --pat-opacity: .2; --bg-blur: 0px; --bg-dim: .55;
}
:root[data-theme="light"] {
    --pat-bg: linear-gradient(120deg, #e65c00 0%, #b8860b 28%, #ca8a04 52%, #16a34a 80%, #15803d 100%);
    --pat-opacity: .24;
}
body::before {
    content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; display: none;
    background: var(--pat-bg); opacity: var(--pat-opacity);
    -webkit-mask-image: var(--pat-img); mask-image: var(--pat-img);
    -webkit-mask-size: var(--pat-size); mask-size: var(--pat-size);
}
:root[data-bg="grid"] { --pat-img: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48'%3E%3Cpath d='M0 .5H48M.5 0V48' fill='none' stroke='black' stroke-width='1'/%3E%3C/svg%3E"); --pat-size: 48px 48px; }
:root[data-bg="hex"] { --pat-img: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='34.641' height='60' viewBox='0 0 34.641 60'%3E%3Cpath d='M0.00 -20.00L17.32 -10.00L17.32 10.00L0.00 20.00L-17.32 10.00L-17.32 -10.00ZM34.64 -20.00L51.96 -10.00L51.96 10.00L34.64 20.00L17.32 10.00L17.32 -10.00ZM17.32 10.00L34.64 20.00L34.64 40.00L17.32 50.00L0.00 40.00L0.00 20.00ZM0.00 40.00L17.32 50.00L17.32 70.00L0.00 80.00L-17.32 70.00L-17.32 50.00ZM34.64 40.00L51.96 50.00L51.96 70.00L34.64 80.00L17.32 70.00L17.32 50.00Z' fill='none' stroke='black' stroke-width='1.2'/%3E%3C/svg%3E"); --pat-size: 34.641px 60px; }
:root[data-bg="grid"] body::before, :root[data-bg="hex"] body::before { display: block; }
:root[data-bg="none"] body, :root[data-bg="image"] body { background: var(--bg); }

/* Picture background (kept only in this browser) */
#bg-layer { position: fixed; inset: 0; z-index: -1; display: none; overflow: hidden; pointer-events: none; }
:root[data-bg="image"] #bg-layer { display: block; }
#bg-layer .bg-img { position: absolute; inset: -30px; background-size: cover; background-position: center; filter: blur(var(--bg-blur)); }
#bg-layer .bg-dim { position: absolute; inset: 0; background: var(--bg); opacity: var(--bg-dim); }
:root[data-bg="image"] .site-header { background: color-mix(in srgb, var(--surface) 80%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
:root[data-bg="image"] .controls { background: color-mix(in srgb, var(--bg) 78%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }

/* Settings controls */
.field-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
.segmented.five button { font-size: 12px; padding: 5px 0; }
#bg-image-controls { display: flex; flex-direction: column; gap: 10px; }
.range-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.range-row span { width: 36px; color: var(--muted); }
.range-row input { flex: 1; accent-color: var(--accent); }
.tiny { font-size: 11px !important; }

/* Keep the header (and the settings panel inside it) above the pinned controls */
.site-header { position: relative; z-index: 5; }

/* Brands and gear sets: three-column cards with the slider inside each card */
.order-switch { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin: -4px 0 12px; font-size: 12px; color: var(--muted); }
.segmented.small { width: 150px; }
.segmented.small button { font-size: 12px; padding: 4px 0; }
body.collection #list-view, body.collection .controls-inner { max-width: 60rem; }
#items-grid.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.item-card { flex-direction: column; align-items: stretch; gap: 12px; padding: 12px 14px; }
.card-top { display: flex; align-items: center; gap: 10px; min-width: 0; }
.card-top h3 { margin: 0; font-size: 14px; font-weight: 600; line-height: 1.2; min-width: 0; overflow-wrap: anywhere; }
.item-card.done .card-top h3 { color: var(--accent); }
.item-card .rank-wrap { width: 100%; }
.item-card .item-icon { width: 40px; height: 40px; }
@media (max-width: 860px) { #items-grid.cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { #items-grid.cards { grid-template-columns: 1fr; } }

/* ---------- Planner ---------- */
.mode-switch { display: flex; gap: 4px; padding: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
.mode-switch button { padding: 6px 16px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 700; }
.mode-switch button:hover { color: var(--text); }
.mode-switch button.active { background: #ff6600; color: #1a0a00; }
:root[data-theme="light"] .mode-switch button.active { background: #e65c00; color: #fff; }

.plan-hint { margin: 0 0 18px; font-size: 13px; color: var(--muted); }
.plan-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.plan-spacer { visibility: hidden; }
.plan-card {
    display: flex; align-items: center; gap: 14px; text-align: left; min-height: 96px; padding: 12px 16px; color: var(--text);
    background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 12%, var(--surface)), var(--surface) 62%);
    border: 1px solid color-mix(in srgb, var(--accent) 26%, var(--border)); border-radius: 10px;
    box-shadow: inset 3px 0 0 var(--accent); transition: transform .15s, border-color .15s, box-shadow .15s;
}
.plan-card:hover, .plan-card:focus-visible { transform: translateY(-2px); border-color: var(--accent); box-shadow: 0 10px 26px -10px var(--accent), inset 3px 0 0 var(--accent); }
.plan-icon { display: grid; place-items: center; flex: none; width: 64px; color: var(--accent); filter: drop-shadow(0 0 7px color-mix(in srgb, var(--accent) 45%, transparent)); }
.plan-icon .glyph { width: 56px; height: 42px; }
.plan-icon .monogram { font-size: 22px; }
.plan-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.plan-slot { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.plan-name { font-size: 15px; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.plan-name.named { color: var(--named); }
.plan-name.exotic { color: var(--exotic); }
.plan-meter { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.plan-bar { flex: 1; height: 6px; border-radius: 3px; overflow: hidden; background: color-mix(in srgb, var(--accent) 14%, var(--surface-2)); }
.plan-bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.plan-meter b { font-size: 13px; font-variant-numeric: tabular-nums; }
.plan-card.empty .plan-name { color: var(--muted); font-weight: 600; }
.plan-card.empty .plan-icon { opacity: .4; filter: none; }

body.view-planlist .toolbar, body.view-planlist .controls .bar, body.view-planlist #summary-pct,
body.view-plan #reset-btn, body.view-planlist #reset-btn { display: none; }

@media (max-width: 860px) { .plan-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .plan-spacer { display: none; } }
@media (max-width: 640px) {
    .header-inner { flex-wrap: wrap; height: auto; padding-top: 8px; padding-bottom: 8px; row-gap: 8px; }
    .mode-switch { order: 3; width: 100%; }
    .mode-switch button { flex: 1; }
}
@media (max-width: 520px) { .plan-grid { grid-template-columns: 1fr; } }

/* Small notes that sit straight on the background pattern: brighter text with a soft backing so lines don't cut through */
.plan-hint, .hint {
    color: var(--text); width: fit-content; max-width: 100%;
    padding: 8px 14px; border-radius: 8px;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.hint { margin-left: auto; margin-right: auto; }
.hint b, .plan-hint b { color: var(--accent); }
.order-switch > span { color: var(--text); opacity: .85; }

/* ---------- Header: colorful account chip and settings gear ---------- */
:root { --gear-a: #ff6600; --gear-b: #ffd700; }
:root[data-theme="light"] { --gear-a: #e65c00; --gear-b: #b8860b; }
#settings-btn svg { filter: drop-shadow(0 0 5px rgba(255, 140, 0, .5)); transition: transform .3s; }
:root[data-theme="light"] #settings-btn svg { filter: none; }
#settings-btn:hover svg { transform: rotate(45deg); }
.account-chip {
    display: inline-flex; align-items: center; gap: 8px; max-width: 260px; padding: 5px 13px; border-radius: 999px;
    font-size: 12px; font-weight: 700;
    border: 1px solid color-mix(in srgb, #ff8a3d 55%, var(--border));
    background: linear-gradient(90deg, rgba(255, 102, 0, .20), rgba(255, 215, 0, .10));
}
.sync-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--muted); color: var(--muted); box-shadow: 0 0 8px currentColor; }
.account-chip[data-state="ok"] .sync-dot { background: #4ade80; color: #4ade80; }
.account-chip[data-state="busy"] .sync-dot { background: #ff6600; color: #ff6600; }
.account-chip[data-state="failed"] .sync-dot { background: #ef4444; color: #ef4444; }
#account-email {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    background: linear-gradient(90deg, #ff8a3d, #ffd700); -webkit-background-clip: text; background-clip: text; color: transparent;
}
:root[data-theme="light"] #account-email { background-image: linear-gradient(90deg, #c2410c, #a16207); }
:root[data-theme="light"] .account-chip { background: linear-gradient(90deg, rgba(230, 92, 0, .12), rgba(184, 134, 11, .08)); }
:root[data-theme="light"] .account-chip[data-state="ok"] .sync-dot { background: #16a34a; color: #16a34a; }
@media (max-width: 640px) { .account-chip { max-width: 132px; padding: 4px 9px; gap: 6px; } }

/* Planner: hint + the 0/10 toggle on one row */
.plan-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.plan-tools .plan-hint { margin: 0; }

.chip-toggle { position: relative; }

/* Phones: keep logo, email chip and gear on one row; the Tracker/Planner switch gets its own row below */
@media (max-width: 640px) {
    .header-actions { margin-left: auto; gap: 6px; }
    .account-chip { max-width: 112px; }
    .brand h1 .brand-name { font-size: 14px; }
    .brand-sub { letter-spacing: .2em; }
}

.item-sub { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }
