:root {
    color-scheme: dark;
    --bg: #101113;
    --panel: #151619;
    --panel-soft: #181a1d;
    --line: #33373d;
    --line-soft: rgba(255, 255, 255, 0.08);
    --text: #f2f0e8;
    --muted: #b9b4aa;
    --dim: #868176;
    --green: #8ebf9f;
    --cyan: #8fb6c8;
    --amber: #d7b56d;
    --orange: #c98a55;
    --red: #d66767;
    --blue: #85a9d8;
    --shadow: 0 20px 52px rgba(0, 0, 0, 0.42);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body.heat-sim {
    min-height: 100vh;
    font-family: "Outfit", Arial, sans-serif;
    font-size: 15px;
    background: linear-gradient(180deg, #131416 0%, #0f1012 100%);
    color: var(--text);
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

.sim-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: 74px;
    padding: 12px 18px;
    display: grid;
    grid-template-columns: auto auto minmax(180px, 1fr) auto;
    gap: 18px;
    align-items: center;
    border-bottom: 1px solid var(--line-soft);
    background: rgba(16, 17, 19, 0.94);
    backdrop-filter: blur(18px);
}

.page-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-button {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 0 14px;
    color: var(--text);
    background: #1b1d20;
    text-decoration: none;
    font-weight: 800;
}

.nav-button:hover {
    border-color: rgba(142, 191, 159, 0.62);
    background: #22262a;
}

.brand {
    color: var(--text);
    font-size: 1.3rem;
    font-weight: 800;
    text-decoration: none;
}

.tool-title {
    min-width: 0;
}

.tool-kicker,
.panel-kicker {
    display: block;
    color: var(--green);
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin: 0;
}

h1 {
    margin-top: 2px;
    font-size: 1.26rem;
}

h2 {
    margin-top: 2px;
    font-size: 1.08rem;
}

.sim-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 9px;
    flex-wrap: wrap;
}

.control-button,
.item-action,
.text-button {
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--text);
    background: #1b1d20;
    font-weight: 800;
}

.control-button {
    padding: 0 14px;
}

.control-button:hover,
.item-action:hover,
.text-button:hover {
    border-color: rgba(142, 191, 159, 0.7);
    background: #22262a;
}

.select-wrap,
.toggle-wrap,
.range-control {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: rgba(27, 29, 32, 0.92);
    padding: 0 10px;
}

.range-control.wide {
    min-width: 230px;
}

.select-wrap span,
.toggle-wrap span,
.range-control span {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
}

.range-control b {
    min-width: 86px;
    text-align: right;
    color: var(--text);
}

.range-control input {
    width: 100px;
    accent-color: var(--green);
}

.select-wrap select {
    min-width: 76px;
    border: 0;
    color: var(--text);
    background: #181a1d;
    outline: none;
}

.select-wrap option {
    color: var(--text);
    background: #141619;
}

.toggle-wrap input {
    accent-color: var(--green);
}

.sim-shell {
    height: calc(100vh - 74px);
    padding: 18px;
    display: grid;
    grid-template-columns: minmax(640px, 1fr) minmax(460px, 620px);
    gap: 18px;
}

.item-browser,
.player-stage {
    min-height: 0;
    overflow: hidden;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: rgba(24, 26, 29, 0.95);
    box-shadow: var(--shadow);
}

.item-browser {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.panel-head,
.stage-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.stage-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.surprise-button {
    min-width: 110px;
    border-color: rgba(143, 182, 200, 0.38);
    color: var(--cyan);
}

.clear-equipment-button {
    min-width: 86px;
    color: var(--muted);
}

.item-count,
.comfort-pill {
    min-width: 58px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    color: #101113;
    background: var(--green);
    padding: 0 12px;
    font-weight: 900;
}

.item-search {
    flex: 0 0 auto;
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 0 13px;
    color: var(--text);
    background: #111315;
    outline: none;
}

.item-search:focus {
    border-color: var(--green);
}

.category-tabs {
    flex: 0 0 auto;
    min-height: 34px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.category-tab {
    min-height: 30px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0 10px;
    color: var(--muted);
    background: #17191d;
    font-size: 0.84rem;
    font-weight: 800;
}

.category-tab.active {
    color: #101113;
    border-color: var(--green);
    background: var(--green);
}

.item-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    scrollbar-width: thin;
}

.item-table {
    width: 100%;
    min-width: 600px;
    border-collapse: separate;
    border-spacing: 0 6px;
}

.item-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 0 9px 8px;
    color: var(--dim);
    background: #151619;
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-align: left;
    text-transform: uppercase;
}

.item-table th.numeric,
.item-table td.numeric {
    text-align: right;
}

.sort-button {
    min-height: 24px;
    border: 0;
    padding: 0;
    color: inherit;
    background: transparent;
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    cursor: pointer;
}

.sort-button.active {
    color: var(--green);
}

.item-row {
    --item-color: var(--green);
    cursor: grab;
}

.item-row td {
    padding: 8px 9px;
    border-top: 1px solid var(--line-soft);
    border-bottom: 1px solid var(--line-soft);
    background: #141619;
    vertical-align: middle;
}

.item-row td:first-child {
    border-left: 3px solid var(--item-color);
    border-radius: 8px 0 0 8px;
}

.item-row td:last-child {
    border-right: 1px solid var(--line-soft);
    border-radius: 0 8px 8px 0;
}

.item-identity {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.item-preview-box {
    position: relative;
    width: 62px;
    height: 58px;
    flex: 0 0 62px;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 1px solid rgba(185, 180, 170, 0.18);
    border-radius: 7px;
    background:
        radial-gradient(circle at 50% 42%, rgba(142, 191, 159, 0.13), transparent 60%),
        #0f1113;
}

.item-preview-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}

.item-preview-fallback {
    display: none;
    padding: 0 5px;
    color: var(--dim);
    font-size: 0.62rem;
    font-weight: 900;
    line-height: 1.05;
    text-align: center;
    text-transform: uppercase;
}

.item-preview-box.is-missing .item-preview-fallback {
    display: block;
}

.item-name strong,
.item-name span {
    display: block;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.item-name span {
    margin-top: 2px;
    color: var(--dim);
    font-size: 0.78rem;
}

.slot-tags {
    display: flex;
    justify-content: flex-start;
    gap: 4px;
    flex-wrap: wrap;
}

.slot-tag {
    border: 1px solid var(--line-soft);
    border-radius: 999px;
    padding: 2px 7px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.03);
    font-size: 0.74rem;
    font-weight: 800;
}

.item-action {
    min-height: 30px;
    padding: 0 10px;
    font-size: 0.84rem;
}

.player-stage {
    padding: 16px;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 14px;
}

.slot-grid {
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    display: grid;
    grid-template-columns: 1fr;
    align-content: start;
    gap: 6px;
    padding-right: 3px;
    scrollbar-width: thin;
}

.slot-card {
    min-height: 58px;
    display: grid;
    grid-template-columns: 108px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    border: 1px dashed rgba(142, 191, 159, 0.34);
    border-radius: 8px;
    padding: 8px 10px;
    background:
        linear-gradient(135deg, rgba(142, 191, 159, 0.06), transparent 52%),
        #141619;
}

.slot-card.drop-ok {
    border-color: var(--green);
    background:
        linear-gradient(135deg, rgba(142, 191, 159, 0.14), transparent 52%),
        #171b18;
}

.slot-card.drop-bad {
    border-color: rgba(214, 103, 103, 0.72);
}

.slot-head {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 2px;
    min-width: 0;
}

.slot-head h3 {
    font-size: 0.95rem;
    line-height: 1.05;
}

.slot-head span {
    color: var(--dim);
    font-size: 0.74rem;
    font-weight: 900;
}

.empty-slot {
    color: var(--dim);
    font-size: 0.84rem;
}

.equipped {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(218px, 42%);
    gap: 8px;
    align-items: center;
    min-width: 0;
}

.equipped-compact {
    grid-template-columns: 62px minmax(218px, 1fr);
}

.slot-preview-box {
    width: 54px;
    height: 50px;
    flex-basis: 54px;
    justify-self: start;
}

.equipped-preview-only .item-preview-fallback,
.equipped-preview-only.is-missing .item-preview-fallback {
    display: none;
}

.equipped strong,
.equipped span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.equipped span {
    color: var(--dim);
    font-size: 0.76rem;
}

.slot-controls {
    display: grid;
    grid-template-columns: minmax(108px, 1fr) 92px auto;
    gap: 4px;
    align-items: center;
}

.slot-controls label {
    min-width: 0;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 900;
}

.slot-controls select {
    width: 100%;
    min-width: 0;
    min-height: 30px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 6px;
    color: var(--text);
    background: #111315;
    font-size: 0.84rem;
}

.wetness-select {
    border-color: rgba(143, 182, 200, 0.36) !important;
    color: var(--cyan) !important;
}

.remove-slot {
    min-width: 26px;
    min-height: 28px;
    border: 1px solid rgba(214, 103, 103, 0.5);
    border-radius: 6px;
    color: var(--red);
    background: transparent;
    font-weight: 900;
}

.comfort-panel {
    min-height: 170px;
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    grid-template-rows: auto auto;
    gap: 12px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    padding: 14px;
    background: #141619;
}

.comfort-hud {
    --heat-color: var(--text);
    grid-row: 1 / 3;
    display: grid;
    grid-template-rows: 28px 70px 28px;
    justify-items: center;
    align-items: center;
    color: var(--heat-color);
}

.heat-icon {
    width: 48px;
    height: 70px;
    overflow: visible;
    filter: drop-shadow(0 1px 1px #000) drop-shadow(0 0 10px color-mix(in srgb, var(--heat-color) 45%, transparent));
}

.heat-icon-outline {
    fill: none;
    stroke: currentColor;
    stroke-width: 5.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.heat-icon-outline.thin {
    stroke-width: 3.4;
    opacity: 0.78;
}

.heat-icon-fill {
    fill: currentColor;
    opacity: 0.78;
}

.heat-arrows {
    min-height: 18px;
    display: flex;
    flex-direction: column;
    gap: 1px;
    opacity: 0;
}

.heat-arrows.active {
    opacity: 1;
}

.heat-chevron {
    position: relative;
    width: 22px;
    height: 8px;
    flex: 0 0 8px;
    filter: drop-shadow(0 0 5px color-mix(in srgb, currentColor 55%, transparent));
}

.heat-chevron::before,
.heat-chevron::after {
    content: "";
    position: absolute;
    top: 2px;
    width: 13px;
    height: 4px;
    border-radius: 999px;
    background: currentColor;
}

.heat-arrows.up .heat-chevron::before {
    left: 0;
    transform: rotate(-28deg);
    transform-origin: right center;
}

.heat-arrows.up .heat-chevron::after {
    right: 0;
    transform: rotate(28deg);
    transform-origin: left center;
}

.heat-arrows.down .heat-chevron::before {
    left: 0;
    transform: rotate(28deg);
    transform-origin: right center;
}

.heat-arrows.down .heat-chevron::after {
    right: 0;
    transform: rotate(-28deg);
    transform-origin: left center;
}

.comfort-readout span,
.comfort-metrics span {
    display: block;
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.comfort-readout strong {
    display: block;
    margin-top: 2px;
    font-size: 2rem;
    line-height: 1;
}

.comfort-readout p {
    margin-top: 6px;
    color: var(--dim);
    font-size: 0.84rem;
}

.comfort-narrative {
    max-width: 680px;
    color: var(--muted) !important;
    line-height: 1.35;
}

.comfort-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.comfort-metrics div {
    border: 1px solid var(--line-soft);
    border-radius: 7px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.03);
}

.comfort-metrics strong {
    display: block;
    margin-top: 4px;
    font-size: 1rem;
}

.loading,
.empty-list {
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    padding: 16px;
    color: var(--muted);
    background: #141619;
}

@media (max-width: 1080px) {
    .sim-topbar {
        grid-template-columns: auto 1fr;
    }

    .page-nav {
        grid-column: 1 / -1;
        justify-content: flex-start;
    }

    .sim-controls {
        grid-column: 1 / -1;
        justify-content: flex-start;
    }

    .sim-shell {
        height: auto;
        grid-template-columns: 1fr;
    }

    .player-stage {
        min-height: 720px;
    }
}

@media (max-width: 760px) {
    .sim-topbar {
        position: static;
        grid-template-columns: 1fr;
    }

    .sim-shell {
        padding: 12px;
    }

    .slot-grid,
    .comfort-metrics {
        grid-template-columns: 1fr;
    }

    .slot-card,
    .equipped,
    .slot-controls {
        grid-template-columns: 1fr;
    }

    .equipped.equipped-compact {
        grid-template-columns: 58px minmax(0, 1fr);
    }

    .comfort-panel {
        grid-template-columns: 1fr;
    }

    .comfort-hud {
        grid-row: auto;
    }
}
