:root {
    --bg: #0f1319;
    --card: #171d26;
    --ink: #f3f7ff;
    --muted: #a0afc7;
    --line: #2d3747;
    --brand: #ff8a3d;
    --brand-alt: #ffd166;
    --shadow: 0 16px 42px rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    background: radial-gradient(circle at 85% 10%, #2b1f13 0%, transparent 40%), var(--bg);
    font-family: "Space Grotesk", sans-serif;
    min-height: 100vh;
}

a {
    color: inherit;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.2rem;
    border-bottom: 1px solid var(--line);
    background: rgba(23, 29, 38, 0.92);
    backdrop-filter: blur(8px);
}

.brand {
    text-decoration: none;
}

.brand-title {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.top-nav {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.nav-link,
.icon-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 999px;
    text-decoration: none;
    background: var(--card);
    color: var(--ink);
}

.nav-link {
    font-size: 0.9rem;
    padding: 0.45rem 0.85rem;
}

.icon-link {
    width: 2rem;
    height: 2rem;
}

.icon-link svg {
    width: 1rem;
    height: 1rem;
    fill: currentColor;
}

.icon-link.blizzard-disconnected {
    opacity: 0.35;
}

.blizzard-icon {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.blizzard-refresh-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--brand, #60a5fa);
    vertical-align: middle;
    padding: 0;
    margin-left: 0.5rem;
}
.blizzard-refresh-btn .blizzard-icon {
    width: 1.2rem;
    height: 1.2rem;
}
.blizzard-refresh-btn.disabled {
    opacity: 0.25;
    cursor: not-allowed;
    pointer-events: none;
}

.button-reset {
    cursor: pointer;
}

.content-shell {
    width: min(1100px, calc(100% - 2rem));
    margin: 1.2rem auto 2.5rem;
}

.content-shell-wide {
    width: calc(100% - 2rem);
    max-width: none;
}

.content-center {
    display: grid;
    place-items: center;
    min-height: 86vh;
}

.hero {
    margin-bottom: 1.2rem;
}

.hero h1 {
    margin: 0 0 0.45rem;
    font-size: clamp(1.5rem, 4vw, 2.3rem);
}

.hero p {
    margin: 0;
    color: var(--muted);
}

.hero-small h1 {
    font-size: clamp(1.3rem, 3vw, 1.9rem);
}

.card-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.card-grid-main {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.card-grid-thirds {
    grid-template-columns: repeat(3, 1fr);
}

.home-section-heading {
    font-size: 1.1rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 2rem 0 0.5rem;
}

.stack {
    display: grid;
    gap: 1rem;
}

.card {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--card);
    box-shadow: var(--shadow);
    padding: 1rem 1.1rem;
}

.card h2 {
    margin: 0 0 0.7rem;
    font-size: 1.1rem;
}

.card h3 {
    margin: 0;
    font-size: 1rem;
}

.profession-card {
    padding: 0;
    overflow: hidden;
}

.profession-card__summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    padding: 0.75rem 1.1rem;
    cursor: pointer;
    list-style: none;
}

.profession-card__summary::-webkit-details-marker {
    display: none;
}

.profession-card__summary h2 {
    margin: 0;
    line-height: 1.2;
}

.profession-card__summary:hover {
    background: rgba(255, 255, 255, 0.03);
}

.profession-card__chevron {
    display: block;
    width: 0.7rem;
    height: 0.7rem;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(45deg);
    transition: transform 0.16s ease;
    flex-shrink: 0;
    margin-right: 0;
    align-self: center;
    position: relative;
    top: 1px;
}

.profession-card[open] .profession-card__chevron {
    transform: rotate(225deg);
}

/* ── Collapsible category / slot groups ─────────────────────────────── */
.category-collapse {
    margin: 0.4rem 0 0;
}
.category-collapse__summary {
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 600;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0;
    user-select: none;
}
.category-collapse__summary::-webkit-details-marker { display: none; }
.category-collapse__summary::before {
    content: "▸";
    display: inline-block;
    font-size: 0.75rem;
    transition: transform 0.15s ease;
}
.category-collapse[open] > .category-collapse__summary::before {
    transform: rotate(90deg);
}
.category-collapse[open] > .stack {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.4rem 0.6rem;
}

.profession-card__body {
    padding: 0 1.1rem 1rem;
}

.slot-title {
    margin: 0.85rem 0 0.5rem;
    font-size: 0.95rem;
    color: var(--brand-alt);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.slot-section + .slot-section {
    margin-top: 1.15rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}

.card-link {
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card-link:hover {
    transform: translateY(-3px);
}

.item-list {
    margin: 0;
    padding-left: 1rem;
    display: grid;
    gap: 0.35rem;
}

.item-title {
    font-weight: 600;
}

.item-meta {
    display: block;
    color: var(--muted);
    font-size: 0.92rem;
}

.muted {
    color: var(--muted);
}

.tool-block + .tool-block {
    border-top: 1px solid var(--line);
    margin-top: 0.8rem;
    padding-top: 0.8rem;
}

.stat-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.stat-list li {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px dashed var(--line);
    padding: 0.5rem 0;
}

.stat-list li:last-child {
    border-bottom: 0;
}

.login-card {
    width: min(440px, 100%);
}

.form-stack {
    display: grid;
    gap: 0.55rem;
}

.form-stack input {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.55rem 0.7rem;
    font: inherit;
    background: #0f1319;
    color: var(--ink);
}

.btn-primary {
    margin-top: 0.35rem;
    border: 0;
    border-radius: 10px;
    padding: 0.65rem 0.8rem;
    background: linear-gradient(90deg, var(--brand), var(--brand-alt));
    color: #fff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.error-text {
    color: #a60000;
}

.bg-shape {
    position: fixed;
    z-index: -1;
    filter: blur(22px);
    opacity: 0.55;
}

.bg-shape-a {
    width: 220px;
    height: 220px;
    background: #8f3d17;
    left: -50px;
    top: 20%;
}

.bg-shape-b {
    width: 240px;
    height: 240px;
    background: #5a4518;
    right: -60px;
    bottom: 10%;
}

@media (max-width: 740px) {
    .site-header {
        flex-wrap: wrap;
        gap: 0.6rem;
    }
}

.item-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.wowhead-item-link {
    text-decoration: none;
}

.wowhead-item-link:hover .item-title {
    text-decoration: underline;
}

.item-icon {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 1px solid var(--line);
    vertical-align: middle;
}

.item-icon-fallback {
    display: inline-block;
    background: #0f1319;
}

.item-meta-inline {
    color: var(--muted);
    margin-right: 0.25rem;
}

.table-wrap {
    overflow-x: auto;
}

.roster-filter-box {
    margin-bottom: 0.85rem;
}

.roster-filter-actions {
    margin: 0.1rem 0 0.9rem;
}

.roster-table {
    width: 100%;
    border-collapse: collapse;
    min-width: max-content;
    font-size: 0.92rem;
}

.roster-table th,
.roster-table td {
    text-align: left;
    border-bottom: 1px solid var(--line);
    padding: 0.5rem 0.45rem;
    vertical-align: top;
    white-space: nowrap;
}

.roster-table th {
    color: var(--brand-alt);
    font-weight: 700;
    letter-spacing: 0.04em;
}

.roster-table tr:last-child td {
    border-bottom: 0;
}

.class-pill {
    font-weight: 700;
}

.level-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.faction-icon {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid var(--line);
}

.roster-character-link {
    font-weight: 700;
    text-decoration: none;
}

.roster-character-link:hover,
.roster-prof-link:hover {
    text-decoration: underline;
}

.roster-prof-link {
    color: var(--brand-alt);
    text-decoration: none;
}

.local-tooltip-trigger {
    border-bottom: 1px dashed rgba(255, 209, 102, 0.45);
    cursor: help;
}

.sort-link {
    color: inherit;
    text-decoration: none;
}

.sort-link.active {
    color: var(--brand-alt);
}

.sort-link:hover {
    text-decoration: underline;
}

.local-tooltip {
    position: fixed;
    z-index: 1000;
    max-width: 420px;
    background: rgba(14, 19, 28, 0.96);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.45rem 0.6rem;
    font-family: "Space Grotesk", sans-serif;
    font-size: 0.88rem;
    line-height: 1.3;
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.45);
    pointer-events: none;
    opacity: 0;
    transform: translateY(2px);
    transition: opacity 0.08s ease, transform 0.08s ease;
}

.local-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

.detail-grid {
    display: grid;
    gap: 0.5rem 1rem;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.detail-grid p {
    margin: 0;
}

.action-row {
    display: flex;
    gap: 0.6rem;
    margin-top: 1rem;
    align-items: center;
}

.btn-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.form-grid {
    display: grid;
    gap: 0.45rem;
}

.form-vertical {
    display: grid;
    gap: 0.8rem;
    max-width: 760px;
}

.form-row {
    display: grid;
    gap: 0.35rem;
}

.form-row label {
    font-weight: 600;
}

.recap-char-link {
    text-decoration: none;
    font-weight: 600;
}

.recap-char-link:hover {
    text-decoration: underline;
}

.recap-line {
    white-space: nowrap;
    overflow-x: auto;
    margin: 0;
}

.form-grid input,
.form-grid select,
.form-grid textarea,
.form-vertical input,
.form-vertical select,
.form-vertical textarea {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.55rem 0.7rem;
    font: inherit;
    background: #0f1319;
    color: var(--ink);
    width: 100%;
}

/* Wowhead source link icon next to profession name */
.wowhead-source-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: rgba(255, 138, 61, 0.1);
    color: var(--brand);
    text-decoration: none;
    vertical-align: middle;
    margin-left: 0.4rem;
    flex-shrink: 0;
    transition: background 0.12s ease;
}

.wowhead-source-link:hover {
    background: rgba(255, 138, 61, 0.28);
}

.wowhead-source-link svg {
    width: 0.72rem;
    height: 0.72rem;
    fill: currentColor;
}

/* ── Profession Matrix ─────────────────────────────────────────────────── */

.matrix-wrap {
    overflow-x: auto;
    margin-top: 0.8rem;
}

.matrix-table {
    border-collapse: collapse;
    font-size: 0.82rem;
    min-width: max-content;
}

.matrix-table th,
.matrix-table td {
    border: 1px solid var(--line);
    padding: 0;
}

/* Corner cell (top-left label) */
.matrix-corner {
    min-width: 140px;
    font-size: 0.72rem;
    color: var(--muted);
    padding: 0.35rem 0.5rem;
    vertical-align: bottom;
    white-space: nowrap;
}

/* Column header: horizontal text */
.matrix-col-head {
    vertical-align: bottom;
    text-align: center;
    padding: 0.4rem 0.25rem;
}

.matrix-col-head a {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--brand-alt);
    text-decoration: none;
    white-space: nowrap;
}

.matrix-col-head a:hover {
    text-decoration: underline;
}

.matrix-col-head.gathering a {
    font-style: italic;
}

/* Row header */
.matrix-row-head {
    white-space: nowrap;
    padding: 0.25rem 0.55rem;
    vertical-align: middle;
    min-width: 140px;
    position: sticky;
    left: 0;
    z-index: 2;
    /* background set per-stripe rule below */
}

.matrix-row-head a {
    font-weight: 600;
    font-size: 0.82rem;
    text-decoration: none;
    color: var(--brand-alt);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.matrix-row-head a:hover {
    text-decoration: underline;
}

.matrix-row-head.gathering a {
    font-style: italic;
}

/* Alternating row stripes — sticky header cell background must match */
.matrix-table tbody tr:nth-child(odd) {
    background: #1d2434;
}
.matrix-table tbody tr:nth-child(even) {
    background: #131820;
}
.matrix-table tbody tr:nth-child(odd) .matrix-row-head {
    background: #1d2434;
}
.matrix-table tbody tr:nth-child(even) .matrix-row-head {
    background: #131820;
}

/* Data cells */
.matrix-cell {
    padding: 5px;
    text-align: center;
    vertical-align: middle;
}

.matrix-cell.has-items {
    background: rgba(255, 138, 61, 0.06);
}

.matrix-cell-icons {
    display: inline-grid;
    grid-template-columns: repeat(2, 36px);
    grid-template-rows: repeat(2, 36px);
    gap: 4px;
    align-items: start;
}

/* Item icon inside matrix cell */
.matrix-icon-link {
    display: inline-flex;
    flex-shrink: 0;
    border-radius: 4px;
    transition: transform 0.1s ease, filter 0.1s ease;
}

.matrix-icon-link:hover {
    transform: scale(1.2);
    filter: brightness(1.2);
    z-index: 10;
    position: relative;
}

.matrix-icon {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    border: 1px solid;
    display: block;
}

.matrix-icon--learned {
    border-width: 3px;
}

.matrix-icon--unlearned {
    opacity: 0.3;
    filter: grayscale(1);
}

.matrix-icon.fallback {
    background: #0f1319;
}

/* ── Character Tags ──────────────────────────────────────────────────────── */

.tag-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.12rem 0.45rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    border: 1px solid rgba(255, 255, 255, 0.15);
    transition: opacity 0.12s ease;
}

.tag-pill:hover {
    opacity: 0.85;
}

.tag-pill-dimmed {
    opacity: 0.3;
}

.tag-pill-dimmed:hover {
    opacity: 0.55;
}

.profession-filter-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.16rem 0.5rem;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 209, 102, 0.16);
    color: var(--ink);
    font-size: 0.76rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: opacity 0.12s ease, border-color 0.12s ease;
}

.profession-filter-pill:hover {
    border-color: rgba(255, 255, 255, 0.45);
}

.profession-filter-pill-dimmed {
    opacity: 0.35;
}

.profession-filter-pill-dimmed:hover {
    opacity: 0.6;
}

.tag-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    align-items: center;
}

.icon-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.5rem 0;
}

.icon-option {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--line);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.15s;
    font-size: 1.1rem;
    color: var(--muted);
}

.icon-option:hover {
    border-color: var(--muted);
}

.icon-option.selected {
    border-color: var(--brand);
    background: rgba(255, 138, 61, 0.08);
}

.tag-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    gap: 0.5rem;
}

.profession-card .tag-list-item {
    border: none;
    border-radius: 0;
    padding: 0.35rem 0;
}

.tag-list-item-editing {
    border-color: var(--brand);
    background: rgba(255, 138, 61, 0.04);
}

.tag-actions {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    flex-shrink: 0;
}

.btn-sm {
    font-size: 0.82rem;
    padding: 0.28rem 0.6rem;
    border-radius: 8px;
    text-decoration: none;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    font: inherit;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    transition: border-color 0.12s;
}

.btn-sm:hover {
    border-color: var(--muted);
}

.btn-danger {
    border-color: #6b1a1a;
    color: #ff8080;
}

.btn-danger:hover {
    background: rgba(255, 107, 107, 0.1);
    border-color: #ff6b6b;
}

.btn-active {
    border-color: #4caf7a;
    color: #4caf7a;
    background: rgba(76, 175, 122, 0.1);
}

.btn-active:hover {
    background: rgba(76, 175, 122, 0.2);
}

.btn-need {
    border-color: var(--line);
    color: var(--ink);
}

.btn-need:hover {
    background: rgba(145, 156, 173, 0.08);
    border-color: var(--muted);
}

.btn-need-active {
    border-color: #4caf7a;
    color: #4caf7a;
    background: rgba(76, 175, 122, 0.12);
}

.btn-need-active:hover {
    background: rgba(76, 175, 122, 0.2);
}

.need-icon {
    color: #8f97a8;
    transition: color 0.12s;
}

.btn-need-active .need-icon {
    color: #4caf7a;
}

.btn-fav {
    border-color: var(--line);
    color: #888;
}

.btn-fav:hover {
    background: rgba(231, 76, 139, 0.08);
    border-color: #e74c8b;
    color: #e74c8b;
}

.btn-fav-active {
    border-color: #e74c8b;
    color: #e74c8b;
    background: rgba(231, 76, 139, 0.12);
}

.btn-fav-active:hover {
    background: rgba(231, 76, 139, 0.2);
}

.alert-msg {
    padding: 0.6rem 0.9rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    border: 1px solid var(--line);
}

.alert-success {
    background: rgba(40, 167, 69, 0.1);
    border-color: #1a5c2a;
    color: #5dd87d;
}

.alert-error {
    background: rgba(220, 53, 69, 0.1);
    border-color: #6b1a1a;
    color: #ff8080;
}

.color-picker-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
