:root {
    color-scheme: light;
    --ink: #282b25;
    --panel: #cbc9bb;
    --edge: #171914;
    --slot: #77786e;
    --green: #416735;
    font-family: ui-monospace, "Courier New", monospace;
    color: var(--ink);
    background: #24281f;
}

* { box-sizing: border-box; }
body { margin: 0; }
header, main { width: min(100% - 32px, 1200px); margin-inline: auto; }
header { padding: 30px 0 19px; color: #eeeade; }
h1 { margin: 0; font-size: clamp(2rem, 6vw, 3.2rem); letter-spacing: -.06em; text-shadow: 3px 4px #11150e; }
h2 { margin: 0 0 18px; font-size: 1.25rem; }
h3 { font-size: 1rem; margin: 22px 0 10px; }
.site-disclaimer { margin: 10px 0 0; color: #ccc9b8; font-size: .8rem; }
.tool-nav { margin-top: 14px; }
.tool-nav-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.tool-tab {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 7px;
    height: 100%;
    padding: 7px 10px;
    border: 2px solid var(--edge);
    background: #404439;
    box-shadow: inset 1px 1px #696e5f, inset -2px -2px #2b2e25;
    color: #e0dfd2;
    font-size: .8125rem;
    line-height: 1.25;
    text-decoration: none;
}
.tool-tab small { color: #c3c6b8; font-size: .6875rem; }
.tool-tab[aria-disabled="true"] { cursor: default; }
.tool-tab[aria-current="page"] {
    background: var(--green);
    box-shadow: inset 2px 2px #80a16b, inset -2px -2px #293e22;
    color: white;
    font-weight: bold;
}
a.tool-tab:hover { background: #527e42; }
a.tool-tab:focus-visible { outline: 2px solid #d5f191; outline-offset: 2px; }
@media (max-width: 600px) {
    .tool-nav-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tool-tab { flex-direction: column; justify-content: center; padding: 6px 8px; }
}
main { padding-bottom: 24px; }
.workbench { display: grid; grid-template-columns: 1.05fr 1fr; gap: 14px; }
.panel {
    min-width: 0;
    padding: 20px;
    border: 3px solid var(--edge);
    background: var(--panel);
    box-shadow: inset 2px 2px #f4f0df, inset -3px -3px #88877a, 0 4px #181b16;
}
button, input, select { font: inherit; color: inherit; }
button {
    border: 2px solid #33362d;
    background: #aaa99c;
    box-shadow: inset 2px 2px #e2e0d1, inset -2px -2px #747669;
    font-weight: bold;
    padding: 8px 10px;
    cursor: pointer;
}
button:hover:enabled { background: #d5d6c3; }
button:disabled { opacity: .55; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
    outline: 3px solid #266e2b;
    outline-offset: 2px;
}
input, select { border: 2px solid #65675c; background: #efedde; padding: 8px; min-width: 0; }
#item-search { width: 100%; }
.item-results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 76px), 1fr));
    gap: 4px;
    margin: 12px 0;
}
.slot {
    position: relative;
    display: grid;
    place-items: center;
    min-width: 0;
    padding: 0;
    aspect-ratio: 1;
    background: var(--slot);
    border: 0;
    box-shadow: inset 2px 2px #42453d, inset -2px -2px #e9e7d7;
}
.item-slot:hover:enabled { background: #9b9e88; }
.item-slot[aria-pressed="true"] { box-shadow: inset 0 0 0 3px #d5f191, inset 0 0 0 5px #3a5929; }
.item-icon { width: 28px; height: 28px; object-fit: contain; image-rendering: pixelated; flex: none; vertical-align: middle; }
.slot .item-icon { width: 74%; height: 74%; }
.item-slot {
    height: 76px;
    aspect-ratio: auto;
    grid-template-rows: minmax(0, 1fr) auto;
}
.item-slot-label {
    width: 100%;
    padding: 0 4px;
    margin-bottom: 5px;
    overflow: hidden;
    color: white;
    font-size: .625rem;
    line-height: 1.15;
    text-align: center;
    text-overflow: ellipsis;
    text-shadow: 1px 1px #171914;
    white-space: nowrap;
}
.item-slot:has(.item-slot-label) > .icon-fallback-label {
    visibility: hidden;
}
.icon-fallback { color: #fff; background: #494b42; padding: 1px 5px; font-weight: bold; }
.pagination, .actions, .quantity-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.pagination { justify-content: space-between; font-size: .85rem; }
#selected-item { font-weight: bold; overflow-wrap: anywhere; }
#quantity { width: 6rem; }
.crafting-preview { display: flex; align-items: center; justify-content: center; gap: clamp(6px, 2vw, 20px); margin-top: 18px; }
#ingredient-grid { flex: 0 1 196px; min-width: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.crafting-arrow { font-size: clamp(1.6rem, 5vw, 2.75rem); color: #4c5144; text-shadow: 1px 2px #efedde; }
.output-slot { flex: 0 1 82px; }
.slot-count {
    position: absolute;
    right: 4px;
    bottom: 2px;
    max-width: calc(100% - 6px);
    text-align: right;
    overflow-wrap: anywhere;
    color: white;
    font-weight: bold;
    font-size: clamp(.64rem, 2vw, .95rem);
    line-height: .95;
    text-shadow: 1px 2px #161713, -1px -1px #161713;
}
#crafting-status { font-size: .82rem; min-height: 2.4em; }
button.primary { color: white; background: var(--green); box-shadow: inset 2px 2px #80a16b, inset -2px -2px #293e22; }
button.primary:hover:enabled { background: #527e42; }
#error-message, #project-error { color: #7e241d; margin-bottom: 0; }
#error-message:empty, #project-error:empty { display: none; }
.drawer { margin-top: 14px; }
summary { cursor: pointer; }
.drawer > summary { font-size: 1.1rem; font-weight: bold; }
.drawer[open] > summary { margin-bottom: 15px; }
.project-item-row, .material-row, .recipe-option-row, .project-recipe-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    border-bottom: 1px solid #a29f91;
    padding: 6px 0;
}
.project-item-name { flex: 1; }
.project-item-quantity { width: 6rem; }
#project-items { margin-bottom: 12px; }
.material-stacks { margin-left: auto; font-size: .8rem; }
.tree-node, .tree-material { margin: 4px 0 4px 10px; padding-left: 8px; border-left: 1px solid #909084; }
.tree-node .item-icon, .tree-material .item-icon { margin-right: 6px; }
.recipe-select, .project-recipe-select { max-width: 100%; }
@media (max-width: 700px) {
    .workbench { grid-template-columns: 1fr; }
    .panel { padding: 14px; }
}

@media (prefers-reduced-motion: no-preference) {
    .item-slot:hover:enabled .item-icon { transform: translateY(-1px); }
}

@media (max-width: 390px) {
    #quantity { width: 4rem; }
}

#search-suggestion, #open-recipe-options { margin-top: 8px; text-align: left; }
#recipes-section { scroll-margin-top: 16px; }
#recipes-section[open] { padding-bottom: 30px; }
.recipe-option-row, .project-recipe-row {
    display: grid;
    grid-template-columns: minmax(9rem, 1fr) minmax(0, 3fr);
    gap: 6px 16px;
    padding: 14px 0;
}
.recipe-select, .project-recipe-select { width: 100%; }
.recipe-description {
    grid-column: 2;
    margin: 0;
    font-size: .875rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
}
@media (max-width: 600px) {
    .recipe-option-row, .project-recipe-row { grid-template-columns: minmax(0, 1fr); }
    .recipe-description { grid-column: 1; }
}

.slot > .icon-fallback-label { min-width: 0; line-height: 1.1; }
.slot:has(> .slot-count) > .icon-fallback-label {
    align-self: start;
    margin: 3px 3px 15px;
    font-size: .625rem;
}
.icon-fallback-label {
    max-width: 100%;
    font-size: .72rem;
    overflow-wrap: anywhere;
}


[hidden] { display: none !important; }
#smelting-selected { font-weight: bold; }
.smelting-control {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    margin-block: 8px;
}
.smelting-control select { max-width: 100%; }
#smelting-quantity { width: min(100%, 9rem); }
.furnace-preview {
    display: grid;
    grid-template-columns: minmax(0, 62px) auto minmax(0, 82px);
    grid-template-areas: "input . ." "flame arrow output" "fuel . .";
    align-items: center;
    justify-content: center;
    gap: 4px clamp(10px, 3vw, 24px);
    margin: 16px 0;
}
#furnace-input { grid-area: input; }
#furnace-fuel { grid-area: fuel; }
#furnace-output { grid-area: output; }
.furnace-arrow { grid-area: arrow; }
.furnace-flame {
    grid-area: flame;
    justify-self: center;
    width: 22px;
    height: 21px;
    background: #bd5922;
    clip-path: polygon(0 100%, 0 60%, 15% 60%, 15% 40%, 30% 40%, 30% 60%, 44% 60%, 44% 20%, 60% 20%, 60% 0, 76% 0, 76% 42%, 88% 42%, 88% 62%, 100% 62%, 100% 100%);
    box-shadow: inset 0 -6px #f1b44b;
}
#smelting-fuel-capacity, #smelting-search-status, #smelting-status { font-size: .875rem; }
#smelting-requirements .smelting-fuel-total { font-weight: bold; background: #b4bf9f; padding-inline: 6px; }
#smelting-details { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 8px; }
#smelting-details:empty { display: none; }
#smelting-details dd { margin: 0; overflow-wrap: anywhere; }

/* Force uniform inventory cells */
.item-results {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)) !important;
    grid-auto-rows: 100px !important;
    gap: 5px !important;
    align-items: stretch !important;
}

.item-results > button,
.item-results .item-slot {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    width: 100% !important;
    height: 100px !important;
    min-height: 100px !important;
    max-height: 100px !important;
    min-width: 0 !important;
    padding: 5px !important;
    gap: 4px !important;
    aspect-ratio: auto !important;
    overflow: hidden !important;
    font-size: 9px !important;
    line-height: 1.1 !important;
    color: white !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
}

/* Uniform artwork dimensions */
.item-results img {
    width: 36px !important;
    height: 36px !important;
    flex-shrink: 0 !important;
    object-fit: contain !important;
    image-rendering: pixelated !important;
}

/* Fix all inventory text */
.item-results button span,
.item-results .item-slot-label {
    font-size: 9px !important;
    line-height: 1.1 !important;
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    color: white !important;
    text-align: center !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
}
.schematic-drop {
    display: grid;
    justify-items: start;
    gap: 8px;
    padding: 12px;
    border: 2px dashed var(--slot);
}
.schematic-drop.schematic-dragging { border-color: var(--green); background: #b4bf9f; }
.schematic-drop p { margin: 0; overflow-wrap: anywhere; }
#schematic-filename { margin-bottom: 8px; font-weight: bold; }
#schematic-formats, .schematic-text-row, .schematic-collection { font-size: .875rem; }
.schematic-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
    gap: 6px 12px;
    margin-bottom: 0;
}
.schematic-summary dd { margin: 0; overflow-wrap: anywhere; }
.schematic-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.schematic-actions input, .schematic-actions select { max-width: 100%; }
.schematic-subsection { margin-top: 12px; }
.schematic-text-row { margin: 6px 0; overflow-wrap: anywhere; }
.schematic-collection { flex-basis: 100%; }
#schematic-tree { overflow-wrap: anywhere; }
