:root {
    color-scheme: dark;
    --bg: #0c0a07;
    --panel: #16120c;
    --panel-elevated: #211c14;
    --border: #3d3424;
    --text: #f3e6c8;
    --muted: #b5a278;
    --accent: #c9a227;
    --accent-hover: #e0b93a;
    --success: #7a9e62;
    --danger: #c45c4a;
    --focus: #e8d5a3;
    --link: #e8d5a3;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, sans-serif;
    background:
        radial-gradient(ellipse 80% 50% at 10% -10%, color-mix(in srgb, var(--accent) 35%, transparent), transparent 55%),
        radial-gradient(ellipse 60% 40% at 100% 0%, color-mix(in srgb, var(--panel) 55%, transparent), transparent 50%),
        var(--bg);
    color: var(--text);
    min-height: 100vh;
}

.topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: rgba(18, 16, 14, 0.82);
    backdrop-filter: blur(8px);
}

.topbar-brand {
    min-width: 0;
}

.topbar h1 {
    margin: 0;
    font-size: 1.35rem;
}

.subtitle {
    margin: 0.2rem 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.topbar-credit {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    text-align: center;
}

.credit-line {
    margin: 0;
    color: var(--muted);
    font-size: 0.88rem;
}

.credit-name-btn {
    appearance: none;
    border: 0;
    padding: 0;
    margin: 0;
    background: transparent;
    color: var(--accent);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 0.15em;
}

.credit-name-btn:hover {
    color: var(--accent-hover);
}

.credit-twitch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    color: var(--muted);
    text-decoration: none;
    border-radius: 6px;
    padding: 0.15rem;
}

.credit-twitch:hover {
    color: #bf94ff;
}

.credit-twitch-large {
    margin-top: 0.85rem;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    background: var(--panel-elevated);
    font-size: 0.9rem;
}

.credit-twitch-large:hover {
    border-color: #bf94ff;
    color: #bf94ff;
}

.credit-modal-card {
    max-width: 28rem;
}

.credit-modal-copy {
    margin: 0;
    color: var(--text);
    line-height: 1.55;
    font-size: 0.95rem;
}

.topbar-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    flex-wrap: wrap;
    align-items: center;
}

.privacy-link-btn {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 0.8rem;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
    padding: 0.25rem 0.15rem;
}

.privacy-link-btn:hover {
    color: var(--text);
}

.legal-link-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.purchase-tos-agree {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    margin: 0.85rem 0 0.35rem;
    font-size: 0.88rem;
    line-height: 1.4;
    color: var(--text);
    cursor: pointer;
}

.purchase-tos-agree input {
    margin-top: 0.2rem;
    flex-shrink: 0;
}

.purchase-tos-link {
    display: inline;
    padding: 0;
    font-size: inherit;
    vertical-align: baseline;
}

.privacy-modal-card {
    max-width: 36rem;
    max-height: min(85vh, 40rem);
    overflow: auto;
}

.privacy-copy {
    color: var(--text);
    font-size: 0.92rem;
    line-height: 1.55;
}

.privacy-copy h3 {
    margin: 1.15rem 0 0.4rem;
    font-size: 1rem;
}

.privacy-copy p,
.privacy-copy ul {
    margin: 0 0 0.75rem;
}

.privacy-copy ul {
    padding-left: 1.2rem;
}

.privacy-copy li {
    margin: 0.35rem 0;
}

.privacy-copy a {
    color: var(--accent);
}

.privacy-updated {
    color: var(--muted);
    font-size: 0.82rem;
}

.privacy-full-link {
    margin: 1rem 0 0;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}


.layout {
    display: grid;
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr) minmax(280px, 380px);
    height: calc(100vh - 76px);
    overflow: hidden;
}

.map-sidebar {
    border-left: 1px solid var(--border);
    padding: 1rem;
    min-height: 0;
    overflow-y: auto;
}

.map-sidebar .sidebar-tabs {
    margin-bottom: 0.85rem;
}

.map-sidebar .sidebar-tab {
    padding: 0.4rem 0.35rem;
    font-size: 0.78rem;
}

.converter-panel .settings-field,
.shop-search-panel .settings-field {
    margin-bottom: 0.75rem;
}

.converter-controls,
.shop-search-controls {
    margin-top: 0.35rem;
    margin-bottom: 0.75rem;
}

.converter-find-btn {
    width: 100%;
    margin-bottom: 0.85rem;
}

.scrap-panel h2,
.converter-panel h2,
.shop-search-panel h2 {
    margin-bottom: 0.5rem;
}

.shop-search-result {
    width: 100%;
    text-align: left;
    cursor: pointer;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.7rem;
    background: var(--bg);
    color: var(--text);
    font: inherit;
    font-size: 0.88rem;
}

.shop-search-result:hover {
    border-color: var(--accent);
}

.shop-search-result-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.shop-search-result-trade {
    color: var(--text);
    margin-bottom: 0.2rem;
}

.shop-search-result-meta {
    color: var(--muted);
    font-size: 0.8rem;
}

.shop-search-result.unavailable .shop-search-result-trade,
.shop-search-result.unavailable .shop-search-result-title {
    color: var(--muted);
}

.shop-search-advanced-wrap {
    margin-bottom: 0.85rem;
}

.shop-search-advanced-panel {
    margin-top: 0.35rem;
    padding-top: 0.35rem;
}

.shop-search-bag-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.65rem;
}

.shop-search-bag-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 4.5rem auto;
    gap: 0.4rem;
    align-items: center;
}

.shop-search-bag-row input[type='text'],
.shop-search-bag-row input[type='number'] {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 0.4rem 0.45rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
    font-size: 0.84rem;
}

.shop-search-bag-row input[type='number'] {
    text-align: right;
}

.shop-search-bag-remove {
    padding: 0.35rem 0.5rem;
    font-size: 0.78rem;
}

.shop-search-bag-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem;
    margin-bottom: 0.85rem;
}

.shop-search-bag-actions .btn {
    width: 100%;
}

.shop-search-seed-group {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    margin-bottom: 0.65rem;
    overflow: hidden;
}

.shop-search-seed-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    text-align: left;
    cursor: pointer;
    border: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    padding: 0.65rem 0.7rem;
}

.shop-search-seed-header:hover {
    color: var(--accent);
}

.shop-search-seed-meta {
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 500;
}

.shop-search-seed-body {
    padding: 0 0.7rem 0.7rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.shop-search-seed-body.collapsed {
    display: none;
}

.shop-search-route-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-bottom: 0.35rem;
}

.shop-search-route-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.12rem 0.35rem;
}

.shop-search-route-badge.shortest {
    color: var(--accent);
    border-color: var(--accent);
}

.shop-search-route-badge.efficiency {
    color: var(--text);
    border-color: var(--text);
}

.shop-search-more-btn {
    width: 100%;
    margin-top: 0.15rem;
}

.scrap-panel-hint {
    margin-bottom: 0.85rem;
}

.scrap-preset-row {
    margin-bottom: 0.85rem;
}

.scrap-preset-row .btn {
    width: 100%;
}

.scrap-override-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.scrap-shop-group {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.7rem;
    background: var(--bg);
}

.scrap-shop-header {
    margin-bottom: 0.55rem;
    padding-bottom: 0.45rem;
    border-bottom: 1px solid var(--border);
}

.scrap-listing-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.2rem 0.65rem;
    align-items: center;
    padding: 0.45rem 0;
}

.scrap-listing-row + .scrap-listing-row {
    border-top: 1px solid rgba(48, 54, 61, 0.65);
}

.scrap-listing-trade {
    font-size: 0.84rem;
    font-weight: 600;
    grid-column: 1;
}

.scrap-listing-payout {
    color: var(--accent);
    font-size: 0.88rem;
    font-weight: 700;
    grid-column: 1;
}

.scrap-listing-meta {
    color: var(--muted);
    font-size: 0.76rem;
    grid-column: 1;
}

.scrap-listing-row .scrap-override-field {
    grid-column: 2;
    grid-row: 1 / span 2;
    margin-top: 0;
}

.scrap-override-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.7rem;
    background: var(--bg);
}

.scrap-override-title {
    font-size: 0.9rem;
    font-weight: 600;
}

.scrap-override-meta {
    color: var(--muted);
    font-size: 0.78rem;
    margin-top: 0.15rem;
}

.scrap-override-field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    margin-top: 0.55rem;
}

.scrap-override-field label {
    font-size: 0.82rem;
    color: var(--muted);
}

.scrap-override-field input {
    width: 5.5rem;
    padding: 0.35rem 0.5rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    font: inherit;
    text-align: right;
}

.scrap-override-empty {
    color: var(--muted);
    font-size: 0.85rem;
    line-height: 1.45;
}

.sidebar {
    border-right: 1px solid var(--border);
    padding: 1rem;
    min-height: 0;
    overflow-y: auto;
}

.sidebar-tabs {
    display: flex;
    gap: 0.35rem;
    margin-bottom: 0.85rem;
    padding: 0.25rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--panel);
}

.sidebar-tab {
    flex: 1;
    border: 0;
    border-radius: 7px;
    padding: 0.45rem 0.65rem;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 0.86rem;
    cursor: pointer;
}

.sidebar-tab:hover {
    color: var(--text);
}

.sidebar-tab.active {
    background: var(--panel-elevated);
    color: var(--text);
    font-weight: 600;
}

.sidebar-tab-panel.hidden {
    display: none;
}

.excluded-items-add {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.45rem;
    margin-bottom: 0.65rem;
}

.excluded-items-add input {
    padding: 0.45rem 0.6rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font: inherit;
    font-size: 0.88rem;
}

.excluded-presets {
    margin-bottom: 0.75rem;
}

.settings-panel {
    margin-top: 1rem;
}

.settings-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}

.settings-checkbox input {
    accent-color: var(--accent);
    width: 1rem;
    height: 1rem;
}

.settings-checkbox:has(input:disabled) {
    opacity: 0.65;
    cursor: not-allowed;
}

.settings-checkbox input:disabled {
    cursor: not-allowed;
}

.settings-field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.92rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.settings-field input {
    width: 5.5rem;
    padding: 0.4rem 0.55rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font: inherit;
    font-size: 0.88rem;
    text-align: right;
}

.arbitrage-results-summary {
    margin: 0 0 0.65rem;
    color: var(--muted);
    font-size: 0.82rem;
}

.settings-toggle-hint {
    margin: 0.35rem 0 0.85rem;
}

.scrap-maxxxing-hint {
    margin-top: 0.2rem;
    margin-bottom: 0.35rem;
    font-size: 0.75rem;
}

.trading-from-control {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.15rem;
}

.trading-from-control.hidden {
    display: none;
}

.trading-from-label {
    font-size: 0.82rem;
    color: var(--muted);
}

.trading-from-control .settings-toggle-hint {
    margin: 0;
    font-size: 0.75rem;
}

.smelting-recipes {
    margin-top: 0.65rem;
}

.route-hop-smelt {
    color: var(--accent);
}

.route-hop-recycle {
    color: var(--focus);
}

.excluded-items-list {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.excluded-items-list:not(:empty) + .excluded-items-empty {
    display: none;
}

.excluded-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.55rem 0.65rem;
    background: var(--bg);
}

.excluded-item-name {
    font-size: 0.88rem;
    font-weight: 600;
}

.excluded-item-id {
    color: var(--muted);
    font-size: 0.76rem;
    margin-top: 0.1rem;
}

.excluded-item-remove {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--muted);
    padding: 0.25rem 0.55rem;
    font: inherit;
    font-size: 0.78rem;
    cursor: pointer;
}

.excluded-item-remove:hover {
    color: var(--danger);
    border-color: var(--danger);
}

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.panel h2 {
    margin: 0 0 0.75rem;
    font-size: 1rem;
}

.panel-header h2 {
    margin-bottom: 0;
}

.btn {
    border: 0;
    border-radius: 8px;
    padding: 0.55rem 0.9rem;
    font-size: 0.92rem;
    cursor: pointer;
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn.primary {
    background: var(--accent);
    color: var(--bg);
    font-weight: 600;
    width: 100%;
}

.btn.primary:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn.secondary {
    background: var(--panel-elevated);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn.secondary:hover:not(:disabled) {
    border-color: var(--muted);
}

.icon-btn {
    background: transparent;
    border: 0;
    color: var(--muted);
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
}

.status-list {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin-bottom: 0.9rem;
    max-height: 180px;
    overflow: auto;
}

.status-item {
    font-size: 0.85rem;
    color: var(--muted);
}

.status-item.success {
    color: var(--success);
}

.status-item.error {
    color: var(--danger);
}

.setup-steps {
    margin: 1rem 0 0;
    padding-left: 1.2rem;
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.5;
}

.account-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.account-panel-header h2 {
    margin: 0;
}

.account-section-title {
    margin: 1.15rem 0 0.55rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

.access-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 0.22rem 0.55rem;
    border-radius: 999px;
    border: 1px solid var(--border);
}

.access-badge.access-demo {
    color: var(--accent);
    border-color: #8a3f18;
    background: rgba(210, 153, 34, 0.12);
}

.access-badge.access-full {
    color: var(--success);
    border-color: #4f7a4b;
    background: rgba(63, 185, 80, 0.12);
}

.access-badge.access-unknown {
    color: var(--muted);
}

.access-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.85rem 0.9rem;
    background: rgba(13, 17, 23, 0.55);
    margin-bottom: 0.25rem;
}

.access-summary {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.45;
}

.access-limits {
    margin: 0.65rem 0 0;
    padding-left: 1.15rem;
    color: var(--muted);
    font-size: 0.85rem;
    line-height: 1.45;
}

.access-actions {
    margin-top: 0.85rem;
}

.access-meta {
    margin: 0.65rem 0 0;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: grid;
    place-items: center;
    padding: 1rem;
}

.modal.legal-modal {
    z-index: 1300;
}

.modal.hidden {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(1, 4, 9, 0.72);
}

.modal-card {
    position: relative;
    z-index: 1;
    width: min(34rem, 100%);
    max-height: min(90vh, 44rem);
    overflow: auto;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.1rem 1.15rem;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
}

.modal-header {
    margin-bottom: 0.35rem;
}

.modal-intro {
    margin: 0 0 0.9rem;
}

.plan-compare {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

@media (max-width: 560px) {
    .plan-compare {
        grid-template-columns: 1fr;
    }
}

.plan-compare-col {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.75rem 0.85rem;
    background: rgba(13, 17, 23, 0.45);
}

.plan-compare-full {
    border-color: #4f7a4b;
    background: rgba(63, 185, 80, 0.08);
}

.plan-compare-col h3 {
    margin: 0 0 0.45rem;
    font-size: 0.95rem;
}

.plan-compare-col ul {
    margin: 0;
    padding-left: 1.1rem;
    color: var(--muted);
    font-size: 0.85rem;
    line-height: 1.45;
}

.pricing-block h3 {
    margin: 0 0 0.65rem;
    font-size: 0.95rem;
}

.pricing-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.7rem 0;
    border-top: 1px solid var(--border);
}

.pricing-label {
    font-size: 0.82rem;
    color: var(--muted);
}

.pricing-amount {
    font-size: 1.15rem;
    font-weight: 650;
}

.pricing-period {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--muted);
    margin-left: 0.15rem;
}

.pricing-note {
    margin: 0.35rem 0 0;
    padding-top: 0.65rem;
    border-top: 1px solid var(--border);
}

.cleeng-checkout-mount {
    margin-top: 0.85rem;
    min-height: 12rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.35rem;
    background: rgba(13, 17, 23, 0.55);
}

.cleeng-checkout-mount.hidden {
    display: none;
}

.modal-card:has(.cleeng-checkout-mount:not(.hidden)) {
    width: min(42rem, 100%);
    max-height: min(92vh, 52rem);
}

.help-list {
    margin: 0.5rem 0 0;
    padding-left: 1.2rem;
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.5;
}

.map-section {
    position: relative;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    min-height: 0;
    overflow-y: auto;
}

.map-empty {
    flex: 1;
    display: grid;
    place-items: center;
    border: 1px dashed var(--border);
    border-radius: 12px;
    color: var(--muted);
    min-height: 420px;
}

.map-container {
    position: relative;
    width: min(900px, 100%);
    margin: 0 auto;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: var(--panel);
}

.map-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--border);
    background: rgba(22, 27, 34, 0.95);
}

.map-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.88rem;
    color: var(--text);
    cursor: pointer;
    user-select: none;
}

.map-toggle input {
    accent-color: var(--accent);
}

.map-zoom-controls {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.map-btn {
    min-width: 2rem;
    padding: 0.35rem 0.55rem;
}

.btn.icon.map-btn {
    font-size: 1.1rem;
    line-height: 1;
    font-weight: 700;
}

.zoom-level {
    min-width: 3.2rem;
    text-align: center;
    font-size: 0.82rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.map-body {
    position: relative;
}

.map-viewport {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    max-height: min(900px, 70vh);
    overflow: hidden;
    cursor: grab;
    touch-action: none;
    contain: strict;
}

.shop-popup {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    bottom: 0.75rem;
    z-index: 30;
    display: flex;
    flex-direction: column;
    width: min(320px, calc(100% - 1.5rem));
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(22, 27, 34, 0.97);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(8px);
    pointer-events: auto;
}

.shop-popup-header h2 {
    margin: 0;
    font-size: 0.95rem;
}

.shop-popup .shop-meta {
    margin-bottom: 0.65rem;
}

.shop-popup-listings {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 0.15rem;
}

.map-viewport.dragging {
    cursor: grabbing;
}

.map-stage {
    position: absolute;
    left: 0;
    top: 0;
    transform-origin: 0 0;
    will-change: transform;
}

.map-frame {
    position: relative;
    display: block;
    line-height: 0;
}

.map-frame img {
    display: block;
    image-rendering: auto;
}

.grid-layer,
.marker-layer {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.grid-layer {
    opacity: 0.85;
}

.grid-layer.hidden {
    display: none;
}

.grid-layer line {
    stroke: rgba(255, 255, 255, 0.34);
    stroke-width: 1.5;
    vector-effect: non-scaling-stroke;
}

.grid-layer text {
    fill: rgba(255, 255, 255, 0.82);
    font-family: "Segoe UI", system-ui, sans-serif;
    font-weight: 600;
    paint-order: stroke fill;
    stroke: rgba(0, 0, 0, 0.75);
    stroke-width: 3px;
    pointer-events: none;
}

.shop-marker {
    position: absolute;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    border-style: solid;
    border-color: #1a1512;
    cursor: pointer;
    pointer-events: auto;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.shop-marker.in-stock {
    background: var(--success);
}

.shop-marker.out-stock {
    background: var(--danger);
}

.shop-marker:hover,
.shop-marker.selected {
    transform: translate(-50%, -50%) scale(1.25);
    box-shadow: 0 0 0 4px rgba(210, 153, 34, 0.35);
}

.map-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
    justify-content: center;
    align-items: center;
    color: var(--muted);
    font-size: 0.85rem;
}

.map-hint {
    opacity: 0.75;
}

.dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 0.35rem;
    vertical-align: middle;
}

.dot.in-stock {
    background: var(--success);
}

.dot.out-stock {
    background: var(--danger);
}

.shop-meta {
    color: var(--muted);
    font-size: 0.88rem;
    margin: 0 0 0.75rem;
}

.arbitrage-controls {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    margin-bottom: 0.75rem;
}

.route-excess {
    color: var(--muted);
    font-size: 0.84rem;
    margin: 0 0 0.55rem;
}

.route-excess strong {
    color: var(--text);
    font-weight: 600;
}

.route-trade-size {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.route-trade-size label {
    font-size: 0.82rem;
    color: var(--muted);
}

.route-trade-size-controls {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.route-trade-size-controls button {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font: inherit;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}

.route-trade-size-controls button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.route-trade-size-value {
    min-width: 1.5rem;
    text-align: center;
    font-size: 0.92rem;
    font-weight: 600;
}

.route-trade-size-hint {
    font-size: 0.78rem;
    color: var(--muted);
}

.arbitrage-sort {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0;
}

.arbitrage-sort label {
    font-size: 0.82rem;
    color: var(--muted);
}

.arbitrage-sort select {
    flex: 1;
    min-width: 0;
    padding: 0.4rem 0.55rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font: inherit;
    font-size: 0.84rem;
}

.listing-list,
.arbitrage-list {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.listing-card,
.route-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.7rem;
    background: var(--bg);
    font-size: 0.88rem;
}

.listing-card.unavailable {
    opacity: 0.55;
}

.listing-trade {
    font-weight: 600;
}

.listing-meta {
    color: var(--muted);
    margin-top: 0.25rem;
    font-size: 0.8rem;
}

.route-profit {
    color: var(--success);
    font-weight: 700;
    margin-bottom: 0.35rem;
}

.route-steps {
    margin: 0.45rem 0;
    padding: 0.45rem 0.55rem;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.03);
}

.route-step {
    color: var(--text);
    font-size: 0.82rem;
    line-height: 1.45;
}

.route-hop {
    color: var(--muted);
    margin-top: 0.45rem;
}

.route-hop-title {
    font-weight: 600;
    color: var(--text);
    line-height: 1.35;
}

.route-shop-link {
    background: none;
    border: 0;
    padding: 0;
    margin: 0;
    color: var(--accent);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    text-decoration: underline;
    text-underline-offset: 0.12em;
}

.route-shop-link:hover {
    color: var(--accent-hover);
}

.route-hop-detail {
    margin-top: 0.1rem;
    line-height: 1.4;
}

.btn.danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
    width: 100%;
    margin-top: 0.5rem;
}

.btn.danger:hover:not(:disabled) {
    background: rgba(248, 81, 73, 0.12);
}

.button-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.help-box {
    margin: 0.85rem 0;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
}

.help-box summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.92rem;
}

.field-label {
    display: block;
    font-size: 0.82rem;
    color: var(--muted);
    margin: 0.55rem 0 0.2rem;
}

.token-recovery h3 {
    margin: 0 0 0.35rem;
    font-size: 0.95rem;
}

.token-recovery code {
    font-size: 0.82rem;
    color: var(--accent);
}

.token-recovery {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.token-recovery.hidden {
    display: none;
}

.bookmarklet-link {
    display: inline-block;
    margin-left: 0.35rem;
    padding: 0.2rem 0.55rem;
    border-radius: 6px;
    border: 1px dashed var(--accent);
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.bookmarklet-link:hover {
    background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.advanced-steam {
    margin-top: 0.85rem;
}

#helperStatus {
    margin: 0.5rem 0 0.75rem;
}

.token-recovery input,
.token-recovery textarea {
    width: 100%;
    margin: 0.5rem 0;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font: inherit;
}

.token-recovery textarea {
    resize: vertical;
    min-height: 6rem;
}

.hint {
    color: var(--muted);
    font-size: 0.85rem;
    line-height: 1.45;
    margin: 0.35rem 0;
}

.calc-progress {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: grid;
    gap: 0.35rem;
    padding: 0.55rem 0.85rem 0.7rem;
    background: rgba(13, 17, 23, 0.96);
    border-top: 1px solid var(--border);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.25);
}

.calc-progress-track {
    height: 0.35rem;
    border-radius: 999px;
    background: var(--panel-elevated);
    overflow: hidden;
}

.calc-progress-bar {
    height: 100%;
    width: 0%;
    border-radius: inherit;
    background: linear-gradient(90deg, #8a3f18, var(--accent));
    transition: width 0.18s ease-out;
}

.calc-progress-label {
    color: var(--muted);
    font-size: 0.78rem;
    letter-spacing: 0.01em;
}

.hidden {
    display: none !important;
}

@media (max-width: 1100px) {
    .layout {
        grid-template-columns: minmax(280px, 360px) 1fr;
        height: auto;
        min-height: calc(100vh - 76px);
        overflow: visible;
    }

    .sidebar,
    .map-sidebar,
    .map-section {
        max-height: none;
        overflow-y: visible;
    }

    .map-sidebar {
        border-left: 0;
        border-top: 1px solid var(--border);
        grid-column: 1 / -1;
    }
}

@media (max-width: 900px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }
}

/* —— Theme customizer —— */
.theme-menu {
    position: relative;
}

.theme-menu-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.55rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--panel-elevated);
    color: var(--text);
    cursor: pointer;
    font: inherit;
    font-size: 0.82rem;
}

.theme-menu-btn:hover,
.theme-menu-btn[aria-expanded="true"] {
    border-color: var(--focus);
}

.theme-menu-swatch {
    position: relative;
    width: 1.15rem;
    height: 1.15rem;
    border-radius: 50%;
    overflow: hidden;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.theme-swatch-accent,
.theme-swatch-panel,
.theme-swatch-bg {
    position: absolute;
    inset: 0;
}

.theme-swatch-bg {
    background: var(--bg);
}

.theme-swatch-panel {
    background: var(--panel);
    clip-path: polygon(50% 0, 100% 0, 100% 100%, 50% 100%);
}

.theme-swatch-accent {
    background: var(--accent);
    clip-path: polygon(0 0, 50% 0, 50% 100%, 0 100%);
}

.theme-menu-label {
    color: var(--muted);
    max-width: 5.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.theme-menu-panel {
    position: absolute;
    top: calc(100% + 0.45rem);
    right: 0;
    z-index: 80;
    width: min(17.5rem, calc(100vw - 1.5rem));
    padding: 0.85rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--panel);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.theme-menu-title {
    margin: 0 0 0.65rem;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

.theme-preset-list {
    display: grid;
    gap: 0.35rem;
    margin-bottom: 0.85rem;
}

.theme-preset-btn {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    padding: 0.45rem 0.55rem;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font: inherit;
    font-size: 0.88rem;
    text-align: left;
}

.theme-preset-btn:hover {
    background: var(--panel-elevated);
}

.theme-preset-btn.active {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 14%, transparent);
}

.theme-preset-dots {
    display: flex;
    width: 1.35rem;
    height: 1.35rem;
    border-radius: 50%;
    overflow: hidden;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.theme-preset-dots span {
    flex: 1;
}

.theme-custom-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem;
    margin-bottom: 0.75rem;
    padding-top: 0.65rem;
    border-top: 1px solid var(--border);
}

.theme-color-field {
    display: grid;
    gap: 0.25rem;
    font-size: 0.78rem;
    color: var(--muted);
}

.theme-color-field input[type="color"] {
    width: 100%;
    height: 2rem;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    cursor: pointer;
}

.theme-reset-btn {
    width: 100%;
    font-size: 0.85rem;
}

@media (max-width: 640px) {
    .theme-menu-label {
        display: none;
    }

    .topbar {
        grid-template-columns: 1fr;
        justify-items: stretch;
    }

    .topbar-credit {
        order: 3;
        padding-top: 0.15rem;
    }

    .topbar-actions {
        justify-content: flex-start;
    }
}

