:root {
    --bg: #1a1a1a; --bg-2: #222; --bg-3: #262626;
    --fg: #e0e0e0; --accent: #c89b3c; --accent-dim: #8c6c2a;
    --muted: #888; --border: #333; --border-soft: #2a2a2a;
}
* { box-sizing: border-box; }
body {
    font-family: system-ui, -apple-system, sans-serif;
    background: var(--bg); color: var(--fg); margin: 0;
}
header { padding: 1rem; border-bottom: 1px solid var(--border); }
header a { color: var(--accent); text-decoration: none; font-weight: 600; }

/* Header dropdown menus */
.nav-menu { position: relative; display: inline-block; }
.nav-submenu {
    display: none;
    position: absolute;
    top: 100%; left: 0;
    min-width: 9rem;
    z-index: 100;
    padding-top: 0.25rem;
    background: transparent;
}
.nav-submenu-inner {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    padding: 0.25rem 0;
}
.nav-menu:hover > .nav-submenu,
.nav-menu:focus-within > .nav-submenu { display: block; }
.nav-submenu a {
    display: block;
    padding: 0.4rem 0.9rem;
    font-weight: 500;
    white-space: nowrap;
}
.nav-submenu a:hover { background: var(--bg-3); }
main { max-width: 1100px; margin: 0 auto; padding: 1rem; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--border); text-align: left; }
th { color: var(--muted); font-weight: 500; }
a { color: var(--accent); }
.search-box { width: 100%; max-width: 600px; padding: 0.6rem;
              background: #222; color: var(--fg); border: 1px solid var(--border);
              font-size: 1rem; }
.icon { width: 32px; height: 32px; vertical-align: middle; }
.icon-col { width: 40px; padding-right: 0; text-align: center; }
.kind-glyph {
    display: inline-grid; place-items: center;
    width: 32px; height: 32px;
    font-size: 1.2rem; line-height: 1;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--muted);
}
.kind-glyph.monster { color: #d88; border-color: #4a2a2a; }
.kind-glyph.npc     { color: #8bd; border-color: #1f3a4a; }
.kind-glyph.gather  { color: #9c8; border-color: #2a3d2a; }
.kind-glyph.skill   { color: #ca6; border-color: #4a3a1a; }
.kind-glyph.quest   { color: #b8d8b8; border-color: #2a3d2a; }
.kind-tag { display: inline-block; padding: 0.1rem 0.4rem;
            background: #333; border-radius: 3px; font-size: 0.85rem; color: var(--muted); }
.kind-tag.quest-item { background: #2a3d2a; color: #b8d8b8; }
.muted { color: var(--muted); }

/* List filter bar */
.filters {
    display: flex; flex-wrap: wrap; gap: 0.6rem 1rem;
    align-items: end;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    background: #222;
    border: 1px solid var(--border);
    border-radius: 4px;
}
.filters label {
    display: flex; flex-direction: column;
    font-size: 0.8rem; color: var(--muted); gap: 0.2rem;
}
.filters input[type="search"],
.filters input[type="number"],
.filters select {
    background: #1a1a1a; color: var(--fg);
    border: 1px solid var(--border); border-radius: 3px;
    padding: 0.3rem 0.4rem; font-size: 0.95rem;
}
.filters button {
    background: var(--accent); color: #1a1a1a;
    border: none; padding: 0.4rem 0.9rem; border-radius: 3px;
    font-weight: 600; cursor: pointer;
    align-self: end;
}
.filters button:hover { filter: brightness(1.1); }
.filters .reset {
    color: var(--muted); font-size: 0.85rem;
    align-self: end; padding-bottom: 0.4rem;
}

/* Pager */
.pager {
    display: flex; flex-wrap: wrap; align-items: center;
    justify-content: space-between; gap: 0.6rem 1rem;
    padding: 0.6rem 0.2rem;
    border-top: 1px solid var(--border);
    margin-top: 0.5rem;
    font-size: 0.92rem;
}
.pager a { margin: 0 0.25rem; text-decoration: none; }
.pager a:hover { text-decoration: underline; }
.pager .disabled { color: #555; margin: 0 0.25rem; }
.pager-pos { margin: 0 0.6rem; color: var(--muted); }
.pager-info strong { color: var(--fg); }
.pager-jump { display: inline-flex; gap: 0.4rem; align-items: center; margin: 0; }
.pager-jump input {
    background: #1a1a1a; color: var(--fg);
    border: 1px solid var(--border); border-radius: 3px;
    padding: 0.2rem 0.4rem;
}
.pager-jump button {
    background: #333; color: var(--fg);
    border: 1px solid var(--border); border-radius: 3px;
    padding: 0.2rem 0.6rem; cursor: pointer;
}

/* === Item detail page === */
.crumbs { color: var(--muted); font-size: 0.85rem; margin-bottom: 1rem; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent); }

.hero {
    display: flex; gap: 1.25rem; align-items: flex-start;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-soft);
    margin-bottom: 1.5rem;
}
.hero .icon-frame {
    width: 84px; height: 84px; flex-shrink: 0;
    background: radial-gradient(circle at 30% 25%, #2c2616 0%, #1a1a1a 70%);
    border: 1px solid var(--accent-dim);
    border-radius: 6px;
    display: grid; place-items: center;
    box-shadow: inset 0 0 24px rgba(200, 155, 60, 0.08),
                0 2px 8px rgba(0, 0, 0, 0.4);
    position: relative;
}
.hero .icon-frame::before {
    content: ""; position: absolute; inset: 4px;
    border: 1px solid rgba(200, 155, 60, 0.15);
    border-radius: 4px; pointer-events: none;
}
.hero .hero-icon { width: 64px; height: 64px; image-rendering: pixelated; }
.hero .icon-glyph {
    font-size: 2.4rem; color: var(--accent);
    filter: drop-shadow(0 0 6px rgba(200, 155, 60, 0.35));
}
.hero h1 {
    margin: 0 0 0.4rem;
    font-size: 1.8rem; font-weight: 600; letter-spacing: -0.01em;
}
.hero .meta { color: var(--muted); font-size: 0.85rem; margin-top: 0.5rem; }
.hero .meta strong { color: var(--fg); font-weight: 600; }
.hero .meta code {
    color: var(--fg); background: var(--bg-2);
    padding: 0.1rem 0.4rem; border-radius: 3px; font-size: 0.85em;
}
.kind-tag {
    display: inline-block; padding: 0.18rem 0.55rem;
    background: var(--bg-3); border: 1px solid var(--border);
    border-radius: 3px; font-size: 0.78rem;
    color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em;
    vertical-align: middle; margin-left: 0.5rem;
}

.layout-2col {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 2rem; align-items: start;
}
@media (max-width: 880px) {
    .layout-2col { grid-template-columns: 1fr; }
    .infobox { position: static !important; }
}

section h2 {
    margin: 1.75rem 0 0.75rem;
    font-size: 0.78rem;
    text-transform: uppercase; letter-spacing: 0.14em;
    color: var(--muted); font-weight: 600;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border-soft);
    display: flex; align-items: baseline; gap: 0.5rem;
}
section h2 .count {
    color: var(--accent); font-weight: 700;
    font-size: 0.85rem; text-transform: none; letter-spacing: 0.02em;
}

.stat-card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 0.9rem 1rem;
    margin-bottom: 0.75rem;
}
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.4rem 1.5rem;
}
.stat-row {
    display: flex; justify-content: space-between;
    padding: 0.25rem 0;
    border-bottom: 1px dashed var(--border-soft);
    font-size: 0.92rem;
}
.stat-row:last-child { border-bottom: 0; }
.stat-row .k { color: var(--muted); }
.stat-row .v {
    color: var(--fg); font-variant-numeric: tabular-nums; font-weight: 500;
}

.infobox {
    position: sticky; top: 1rem;
    background: linear-gradient(180deg, #232118 0%, #1c1c1c 100%);
    border: 1px solid var(--accent-dim);
    border-radius: 6px;
    padding: 1.1rem 1.1rem 0.6rem;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.3),
                inset 0 1px 0 rgba(200, 155, 60, 0.08);
}
.infobox::before {
    content: ""; display: block; width: 32px; height: 2px;
    background: var(--accent); margin-bottom: 0.7rem;
}
.infobox dl { margin: 0; }
.infobox .row {
    display: flex; justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border-soft);
    font-size: 0.88rem;
}
.infobox .row:last-child { border-bottom: 0; }
.infobox dt { color: var(--muted); }
.infobox dd {
    margin: 0; color: var(--fg);
    font-variant-numeric: tabular-nums; font-weight: 500;
}
.infobox dd.accent { color: var(--accent); }
.infobox .pdef-headline {
    font-size: 1.6rem; color: var(--accent);
    font-weight: 700; text-align: center;
    padding: 0.3rem 0 0.8rem;
    letter-spacing: -0.01em;
}
.infobox .pdef-headline small {
    display: block; font-size: 0.7rem; color: var(--muted);
    text-transform: uppercase; letter-spacing: 0.14em;
    font-weight: 500; margin-top: 0.2rem;
}

.prob {
    display: inline-flex; align-items: center; gap: 0.5rem;
    font-variant-numeric: tabular-nums;
}
.prob .bar {
    width: 60px; height: 6px;
    background: var(--bg-3); border-radius: 3px; overflow: hidden;
}
.prob .bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-dim), var(--accent));
}

details.raw {
    margin-top: 2rem;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 5px;
}
details.raw summary {
    padding: 0.7rem 1rem; cursor: pointer;
    color: var(--muted); font-size: 0.82rem;
    text-transform: uppercase; letter-spacing: 0.12em;
    user-select: none;
}
details.raw[open] summary {
    border-bottom: 1px solid var(--border); color: var(--fg);
}
details.raw .raw-body { padding: 0.5rem 1rem 1rem; }
details.raw table { font-size: 0.84rem; }

/* === Weapon / armor in-game tooltip === */
.layout-tooltip-side {
    display: grid;
    grid-template-columns: minmax(0, 480px) 1fr;
    gap: 1.5rem; align-items: start;
    margin-bottom: 2rem;
}
@media (max-width: 960px) {
    .layout-tooltip-side { grid-template-columns: 1fr; }
}
.ig-stage { display: flex; }
.ig-stage.left { justify-content: flex-start; }

.ig-tooltip {
    position: relative;
    width: 100%;
    max-width: 460px;
    padding: 14px 18px;
    color: #ffffff;
    font: 14px/1.55 "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
    background: #161616;
    border: 1px solid #2a2a2a;
    border-radius: 4px;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.4);
}

.ig-title {
    color: var(--accent);
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    display: flex; align-items: center; gap: 0.5rem;
    flex-wrap: wrap;
}
.ig-title-icon {
    width: 28px; height: 28px;
    image-rendering: pixelated;
    border: 1px solid var(--accent-dim);
    border-radius: 3px;
    background: #0d0d0d;
}
.ig-title .kind-tag { margin-left: auto; }

.ig-line {
    color: #ffffff;
    font-size: 0.9rem;
    line-height: 1.5;
}
.ig-line.ig-meta {
    color: var(--muted);
    font-size: 0.78rem;
    margin-bottom: 0.4rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid #222;
}
.ig-line.ig-meta code {
    background: #0d0d0d;
    padding: 0.05rem 0.3rem; border-radius: 2px;
    font-size: 0.95em;
}
.ig-line.ig-subtype { color: #ffffff; opacity: 0.95; }
.ig-line.ig-special { color: var(--accent); margin-top: 0.4rem; }
.ig-line.ig-bonus   { color: #6cd1ff; }
.ig-line.ig-origin  { color: #6dd66d; margin-top: 0.2rem; }
.ig-line.ig-fail    { color: #ff5c5c; }

/* === Addons side panel === */
.addons-panel {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 5px;
    overflow: hidden;
    max-height: 80vh;
    display: flex; flex-direction: column;
}
.addons-tabs {
    display: flex; border-bottom: 1px solid var(--border);
    background: #1c1c1c;
    flex-shrink: 0;
}
.addons-tabs .tab {
    flex: 1;
    padding: 0.7rem 1rem;
    background: transparent;
    border: none; border-right: 1px solid var(--border);
    color: var(--muted);
    font: inherit; font-size: 0.88rem; font-weight: 600;
    cursor: pointer;
}
.addons-tabs .tab:last-child { border-right: 0; }
.addons-tabs .tab:hover { color: var(--fg); }
.addons-tabs .tab.active {
    background: var(--bg-2);
    color: var(--accent);
    box-shadow: inset 0 -2px 0 var(--accent);
}

.addons-body {
    padding: 0.9rem 1rem 1rem;
    overflow-y: auto;
    flex: 1 1 auto;
}
.tab-pane { display: none; }
.tab-pane.active { display: block; }

.addons-section + .addons-section { margin-top: 1.1rem; }
.addons-section-title {
    color: var(--accent);
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}
.addons-meta {
    font-size: 0.8rem; color: var(--muted);
    margin-bottom: 0.4rem;
}
.addon-list {
    list-style: none; padding: 0; margin: 0;
    font-size: 0.88rem;
}
.addon-list li {
    display: flex; gap: 0.75rem;
    padding: 0.18rem 0;
    align-items: baseline;
    border-bottom: 1px dashed var(--border-soft);
}
.addon-list li:last-child { border-bottom: 0; }
.addon-list .a-text {
    flex: 1;
    color: var(--fg);
    line-height: 1.4;
}
.addon-list .a-text.muted { color: var(--muted); }
.addon-list .a-text a { color: #6cd1ff; }
.addon-list .a-pct {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    font-size: 0.84rem;
    flex-shrink: 0;
    text-align: right;
    min-width: 4rem;
}
.refine-table { width: 100%; font-size: 0.85rem; }

/* Refine selector list (Refine tab on equipment cards) */
.refine-levels {
    list-style: none;
    margin: 0; padding: 0;
    display: grid;
    grid-template-columns: 1fr;
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
}
.refine-levels .refine-row {
    position: relative;
    display: flex; justify-content: space-between; align-items: baseline;
    gap: 0.6rem;
    padding: 0.32rem 1.4rem 0.32rem 0.7rem;
    font-size: 0.88rem;
    cursor: pointer;
    background: var(--bg-2);
    border-bottom: 1px solid var(--border-soft);
    user-select: none;
    transition: background 80ms linear, padding-left 80ms linear;
}
.refine-levels .refine-row:last-child { border-bottom: 0; }
/* Subtle right-edge chevron hints that the row is clickable. */
.refine-levels .refine-row::after {
    content: "›";
    position: absolute; right: 0.6rem; top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    opacity: 0.35;
    font-size: 1rem;
    transition: opacity 80ms linear, color 80ms linear, transform 80ms linear;
}
.refine-levels .refine-row:hover {
    background: #2c2820;
    padding-left: 0.95rem;
}
.refine-levels .refine-row:hover::after {
    color: var(--accent);
    opacity: 0.95;
    transform: translateY(-50%) translateX(2px);
}
.refine-levels .refine-row.active {
    background: linear-gradient(90deg, rgba(200,155,60,0.18), transparent 80%);
    box-shadow: inset 3px 0 0 var(--accent);
}
.refine-levels .refine-row.active::after {
    content: "✓";
    color: var(--accent);
    opacity: 0.9;
    transform: translateY(-50%);
}
.refine-levels .r-lvl {
    color: var(--accent); font-weight: 600;
    font-variant-numeric: tabular-nums;
    min-width: 2.5rem;
}
.refine-levels .r-bonus {
    color: var(--fg);
    font-variant-numeric: tabular-nums;
}
.refine-levels .r-bonus.muted { color: var(--muted); }

/* Recipe cards (item detail "Crafted via") */
.recipe-card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.6rem;
}
.recipe-head {
    display: flex; flex-wrap: wrap;
    align-items: baseline; gap: 0.5rem 1rem;
    margin-bottom: 0.4rem;
}
.recipe-name {
    color: var(--accent);
    font-weight: 600;
    font-size: 0.98rem;
}
.recipe-meta {
    color: var(--muted);
    font-size: 0.85rem;
}
.recipe-meta strong { color: var(--fg); }
.materials {
    width: 100%;
    font-size: 0.88rem;
    margin-top: 0.2rem;
}
.materials .icon {
    width: 20px; height: 20px;
    vertical-align: middle;
    margin-right: 0.35rem;
}
