:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #12130f;
  color: #f7f1d5;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

button {
  font: inherit;
}

.nicechunk-site-footer {
  display: none !important;
}

.forging-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  width: 100%;
  height: 100vh;
  background: #20221b;
}

.scene-pane {
  position: relative;
  display: grid;
  grid-template-rows: 52px minmax(0, 1fr);
  min-width: 0;
  border-right: 1px solid rgba(247, 241, 213, 0.14);
  overflow: hidden;
}

.scene-toolbar,
.scene-actions,
.panel-head,
.action-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.scene-toolbar {
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(18, 20, 15, 0.92);
  border-bottom: 1px solid rgba(247, 241, 213, 0.12);
}

.scene-toolbar strong {
  font-size: 15px;
  letter-spacing: 0;
}

.scene-actions {
  justify-content: flex-end;
}

button,
.language-trigger {
  min-height: 44px;
  border: 1px solid rgba(247, 241, 213, 0.18);
  background: #11150f;
  color: #fff8dc;
  padding: 8px 12px;
  cursor: pointer;
}

button:hover,
.language-trigger:hover {
  border-color: rgba(236, 181, 87, 0.72);
}

#forgeScene {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  background: #8fc8e8;
  touch-action: none;
  cursor: default;
}

.forge-status {
  position: absolute;
  left: 14px;
  bottom: 96px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: min(680px, calc(100% - 28px));
  color: #f7f1d5;
  pointer-events: none;
}

.tool-hotbar {
  position: absolute;
  left: 50%;
  bottom: 14px;
  z-index: 8;
  display: grid;
  grid-template-columns: repeat(9, 58px);
  gap: 7px;
  max-width: calc(100% - 28px);
  transform: translateX(-50%);
}

.tool-slot {
  position: relative;
  display: grid;
  grid-template-rows: 13px 25px 14px;
  justify-items: center;
  align-items: center;
  width: 58px;
  height: 58px;
  min-height: 58px;
  padding: 3px;
  border: 2px solid rgba(17, 18, 14, 0.88);
  background: rgba(18, 20, 15, 0.78);
  color: #fff8dc;
  box-shadow:
    inset 0 0 0 1px rgba(255, 248, 220, 0.08),
    0 4px 0 rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(4px);
}

.tool-slot.active {
  border-color: #f0c86a;
  background: rgba(211, 153, 67, 0.28);
}

.tool-slot:disabled {
  opacity: 0.42;
  cursor: default;
}

.tool-settings-menu {
  position: fixed;
  z-index: 40;
  display: grid;
  gap: 10px;
  width: 230px;
  border: 1px solid rgba(247, 241, 213, 0.22);
  background: rgba(17, 21, 15, 0.96);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.42);
  padding: 10px;
  color: #fff8dc;
}

.tool-settings-menu[hidden] {
  display: none;
}

.tool-settings-menu strong,
.tool-settings-menu section > span {
  display: block;
  overflow: hidden;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-settings-menu section > span {
  margin-bottom: 6px;
  color: #bfc9a3;
  font-size: 11px;
}

.tool-settings-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.tool-settings-row button {
  min-width: 0;
  min-height: 30px;
  padding: 5px 6px;
  overflow: hidden;
  font-size: 11px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-settings-row button.active {
  border-color: #f0c86a;
  background: #d39943;
  color: #17130b;
}

.paint-palette-row {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.tool-settings-row .paint-swatch {
  min-height: 28px;
  border-color: rgba(255, 248, 220, 0.18);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.24), rgba(0, 0, 0, 0.18)),
    var(--paint-color);
}

.tool-settings-row .paint-swatch.active {
  border-color: #f0c86a;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.38);
}

.tool-settings-row .paint-swatch.unavailable {
  filter: grayscale(0.9);
  opacity: 0.28;
}

.tool-settings-menu section > small {
  display: block;
  margin-top: 6px;
  color: #8f9a79;
  font-size: 10px;
}

.tool-settings-menu input[type="color"] {
  width: 100%;
  height: 34px;
  border: 1px solid rgba(247, 241, 213, 0.22);
  background: rgba(0, 0, 0, 0.3);
  padding: 2px;
}

.tool-hotkey {
  justify-self: start;
  color: #dfe8bc;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
}

.tool-name {
  width: 100%;
  overflow: hidden;
  font-size: 9px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
}

.tool-icon svg {
  display: block;
  width: 24px;
  height: 24px;
  overflow: visible;
}

.forge-status span {
  min-height: 30px;
  border: 1px solid rgba(17, 18, 14, 0.85);
  background: rgba(18, 20, 15, 0.74);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.24);
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 800;
  backdrop-filter: blur(4px);
}

.resource-pane {
  overflow: auto;
  padding: 16px;
  background: #171913;
}

.panel-head {
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel-head p,
h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

.panel-head p {
  margin-bottom: 5px;
  color: #bfc9a3;
  font-size: 11px;
  font-weight: 900;
}

h1 {
  font-size: 20px;
}

h2 {
  margin-bottom: 10px;
  color: #e7deba;
  font-size: 13px;
}

.hammer-button {
  min-width: 92px;
  border-color: rgba(236, 181, 87, 0.5);
  background: rgba(236, 181, 87, 0.14);
  font-weight: 900;
}

.hammer-button.active {
  background: #d39943;
  color: #17130b;
}

.panel-section {
  padding: 14px 0;
  border-top: 1px solid rgba(247, 241, 213, 0.12);
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.section-title-row h2 {
  margin-bottom: 0;
}

.section-title-row button {
  min-height: 44px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 900;
}

.resource-grid {
  display: grid;
  gap: 10px;
}

.resource-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-items: center;
  width: 100%;
  min-height: 64px;
  text-align: left;
}

.resource-card strong,
.resource-card span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resource-card strong {
  color: #fff8dc;
  font-size: 13px;
}

.resource-card span:last-child {
  color: #bfc9a3;
  font-size: 12px;
}

.resource-card.dragging {
  border-color: #ecb557;
  background: rgba(236, 181, 87, 0.12);
}

.resource-card.used,
.resource-card:disabled {
  border-color: rgba(150, 154, 142, 0.34);
  background: rgba(42, 44, 38, 0.62);
  cursor: default;
  filter: grayscale(0.85);
  opacity: 0.48;
}

.resource-card.used .resource-swatch,
.resource-card:disabled .resource-swatch {
  border-color: rgba(230, 230, 218, 0.22);
  box-shadow: none;
}

.resource-card.empty,
.resource-card.loading,
.resource-card.error {
  cursor: default;
  opacity: 0.78;
}

.resource-card.empty strong,
.resource-card.loading strong,
.resource-card.error strong {
  grid-column: 1 / -1;
}

.resource-card.empty span,
.resource-card.loading span,
.resource-card.error span {
  grid-column: 1 / -1;
}

.resource-swatch {
  display: grid;
  grid-row: 1 / span 2;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 2px solid rgba(255, 248, 220, 0.52);
  box-shadow:
    inset -5px -5px 0 rgba(0, 0, 0, 0.25),
    inset 4px 4px 0 rgba(255, 255, 255, 0.14);
}

.resource-preview-swatch {
  overflow: hidden;
  border-color: rgba(142, 238, 255, 0.26);
  background: rgba(6, 12, 14, 0.32);
  box-shadow: inset 0 0 12px rgba(142, 238, 255, 0.08);
}

.resource-swatch-canvas {
  display: block;
  width: 34px;
  height: 34px;
  transform: scale(1.18);
}

.resource-swatch.iron {
  background: #9ca4a2;
}

.resource-swatch.copper {
  background: #b96d45;
}

.resource-swatch.tin {
  background: #c8cfbd;
}

.resource-swatch.handle {
  background: #7b5438;
}

.resource-swatch.coal {
  background: #2d2b28;
}

.stat-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.stat-list div {
  display: grid;
  grid-template-columns: 94px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 30px;
  border: 1px solid rgba(247, 241, 213, 0.1);
  background: rgba(10, 12, 9, 0.35);
  padding: 6px 8px;
}

dt,
dd {
  margin: 0;
}

dt {
  color: #bfc9a3;
  font-size: 12px;
}

dd {
  min-width: 0;
  overflow: hidden;
  color: #fff8dc;
  font-size: 12px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-row {
  margin-top: 12px;
  flex-wrap: wrap;
}

.action-row button {
  flex: 1 1 104px;
  min-width: 0;
}

.chain-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.58);
}

.chain-modal.open {
  display: flex;
}

.chain-dialog {
  display: grid;
  grid-template-rows: auto minmax(96px, 1fr) auto auto;
  width: min(720px, calc(100vw - 36px));
  max-height: min(560px, calc(100vh - 36px));
  min-width: 0;
  border: 1px solid rgba(247, 241, 213, 0.22);
  background: #11150f;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.48);
}

.chain-dialog-head,
.chain-dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 12px;
}

.chain-dialog-head {
  border-bottom: 1px solid rgba(247, 241, 213, 0.12);
}

.chain-dialog-head h2 {
  margin: 0;
}

#closeChainCode {
  position: relative;
  width: 34px;
  min-width: 34px;
  padding: 0;
}

#closeChainCode::before {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 2px;
  background: currentColor;
  content: "";
  transform: translate(-50%, -50%) rotate(45deg);
}

#closeChainCode::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 2px;
  background: currentColor;
  content: "";
  transform: translate(-50%, -50%) rotate(-45deg);
}

#chainCodeOutput {
  display: block;
  width: 100%;
  min-width: 0;
  height: 280px;
  min-height: 0;
  resize: none;
  overflow: auto;
  border: 0;
  border-bottom: 1px solid rgba(247, 241, 213, 0.12);
  outline: 0;
  background: rgba(6, 8, 6, 0.82);
  color: #d8f3cf;
  padding: 12px;
  font-family: "SFMono-Regular", Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: break-all;
  white-space: pre-wrap;
}

.chain-dialog-actions {
  align-items: flex-start;
  flex-wrap: wrap;
}

.chain-dialog-actions p {
  flex: 1 1 280px;
  min-width: 0;
  margin: 0;
  color: #bfc9a3;
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.chain-dialog-actions .chain-action-status {
  flex: 1 1 100%;
  order: 2;
  margin-top: 2px;
  border: 1px solid rgba(255, 183, 125, 0.22);
  border-radius: var(--forge-radius, 4px);
  background: rgba(255, 140, 0, 0.08);
  color: var(--forge-primary-soft, #ffb77d);
  padding: 8px 10px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.chain-dialog-actions .chain-action-status[data-tone="pending"] {
  border-color: rgba(255, 191, 0, 0.38);
  background: rgba(255, 191, 0, 0.12);
  color: var(--forge-secondary, #ffbf00);
}

.chain-dialog-actions .chain-action-status[data-tone="success"] {
  border-color: rgba(120, 255, 159, 0.34);
  background: rgba(80, 255, 130, 0.1);
  color: #9effb8;
}

.chain-dialog-actions .chain-action-status[data-tone="error"] {
  border-color: rgba(255, 90, 78, 0.42);
  background: rgba(255, 61, 48, 0.11);
  color: var(--forge-error, #ffb4ab);
}

.chain-dialog-actions button {
  order: 3;
  flex: 0 0 auto;
}

.draft-list {
  display: grid;
  gap: 6px;
  max-height: 168px;
  overflow: auto;
  min-width: 0;
}

.draft-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 1px solid rgba(247, 241, 213, 0.12);
  background: rgba(6, 8, 6, 0.44);
  text-align: left;
}

.draft-entry.active {
  border-color: rgba(236, 181, 87, 0.72);
  background: rgba(236, 181, 87, 0.14);
}

.draft-entry strong,
.draft-entry span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.draft-entry span {
  color: #bfc9a3;
  font-size: 12px;
}

.draft-empty {
  margin: 0;
  color: #bfc9a3;
  font-size: 12px;
}

.language-picker {
  position: relative;
}

.language-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 190px;
}

.language-current {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.language-caret {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
}

.language-menu {
  position: absolute;
  z-index: 10;
  top: calc(100% + 6px);
  right: 0;
  display: none;
  width: 220px;
  max-height: min(420px, calc(100vh - 90px));
  overflow: auto;
  border: 1px solid rgba(247, 241, 213, 0.18);
  background: #11150f;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.38);
}

.language-picker.open .language-menu {
  display: grid;
}

.language-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 0;
  border-bottom: 1px solid rgba(247, 241, 213, 0.08);
  background: transparent;
  text-align: left;
}

.language-option.active {
  background: rgba(236, 181, 87, 0.16);
}

.language-option:disabled {
  color: rgba(247, 241, 213, 0.38);
  cursor: not-allowed;
}

.language-option-native {
  color: #bfc9a3;
}

.language-option-status {
  grid-column: 2;
  color: rgba(236, 181, 87, 0.58);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

@media (max-width: 840px) {
  .forging-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 58vh) minmax(260px, 42vh);
  }

  .scene-pane {
    border-right: 0;
    border-bottom: 1px solid rgba(247, 241, 213, 0.14);
  }

  .resource-pane {
    padding: 12px;
  }

  .scene-toolbar {
    gap: 8px;
  }

  .scene-actions {
    gap: 6px;
  }

  .language-trigger {
    max-width: 132px;
  }

  .forge-status {
    bottom: 82px;
  }

  .tool-hotbar {
    grid-template-columns: repeat(9, minmax(34px, 1fr));
    gap: 4px;
    width: calc(100% - 18px);
  }

  .tool-slot {
    width: auto;
    height: 50px;
    min-height: 50px;
  }

  .tool-name {
    display: none;
  }
}

/* Stitch forging workstation redesign. */
:root {
  --forge-bg: #131313;
  --forge-bg-deep: #0e0e0e;
  --forge-surface-low: #1c1b1b;
  --forge-surface: #20201f;
  --forge-surface-high: #2a2a2a;
  --forge-surface-hot: #353535;
  --forge-text: #e5e2e1;
  --forge-muted: #ddc1ae;
  --forge-muted-dim: rgba(221, 193, 174, 0.62);
  --forge-outline: #564334;
  --forge-outline-bright: #a48c7a;
  --forge-primary: #ff8c00;
  --forge-primary-soft: #ffb77d;
  --forge-secondary: #ffbf00;
  --forge-tertiary: #9ab36f;
  --forge-error: #ffb4ab;
  --forge-radius: 4px;
  color-scheme: dark;
  font-family: "Hanken Grotesk", ui-sans-serif, system-ui, sans-serif;
  background: var(--forge-bg);
  color: var(--forge-text);
}

html,
body {
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(255, 140, 0, 0.03), transparent 22%, transparent 78%, rgba(255, 191, 0, 0.035)),
    radial-gradient(circle at 72% 12%, rgba(255, 140, 0, 0.08), transparent 28rem),
    var(--forge-bg);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.024) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.024) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.72), transparent 86%);
  content: "";
}

button,
.language-trigger {
  min-height: 44px;
  border: 1px solid var(--forge-outline);
  border-radius: var(--forge-radius);
  background: var(--forge-surface-high);
  color: var(--forge-text);
  padding: 8px 12px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease, filter 120ms ease, transform 120ms ease;
}

button:hover,
.language-trigger:hover {
  border-color: rgba(255, 183, 125, 0.72);
  background: rgba(255, 140, 0, 0.12);
}

button:active {
  transform: translateY(1px) scale(0.99);
}

.forging-app-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  height: 56px;
  padding: 0 24px;
  border-bottom: 1px solid var(--forge-outline);
  background: rgba(19, 19, 19, 0.96);
  backdrop-filter: blur(18px);
}

.forging-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.forging-brand-mark {
  position: relative;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255, 183, 125, 0.44);
  border-radius: var(--forge-radius);
  background:
    linear-gradient(135deg, rgba(255, 140, 0, 0.22), rgba(255, 191, 0, 0.08)),
    var(--forge-surface-low);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.035), 0 0 28px rgba(255, 140, 0, 0.14);
}

.forging-brand-mark::before,
.forging-brand-mark::after {
  position: absolute;
  background: var(--forge-primary);
  content: "";
}

.forging-brand-mark::before {
  left: 7px;
  top: 9px;
  width: 18px;
  height: 5px;
}

.forging-brand-mark::after {
  left: 13px;
  top: 14px;
  width: 5px;
  height: 12px;
  background: var(--forge-secondary);
}

.forging-brand strong,
.scene-toolbar strong {
  display: block;
  color: var(--forge-text);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1.1;
}

.forging-brand small,
.panel-build {
  display: block;
  margin-top: 2px;
  color: rgba(221, 193, 174, 0.58);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.2;
}

.scene-actions {
  gap: 8px;
}

.scene-actions #showChainCode,
.chain-dialog-actions #generateChainCode,
.chain-dialog-actions #copyChainCode {
  border-color: transparent;
  background: var(--forge-primary);
  color: #2f1500;
}

.forging-layout {
  grid-template-columns: minmax(0, 75fr) minmax(330px, 25fr);
  height: 100vh;
  padding-top: 56px;
  background: transparent;
}

.scene-pane {
  grid-template-rows: minmax(0, 1fr);
  border-right: 1px solid var(--forge-outline);
  background: #bdbfc2;
}

.scene-pane::before,
.scene-pane::after {
  content: none;
}

#forgeScene {
  background: #bdbfc2 !important;
}

.forge-scene-hud {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 6;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  max-width: min(560px, calc(100% - 32px));
  border: 1px solid rgba(86, 67, 52, 0.88);
  border-radius: var(--forge-radius);
  background: rgba(14, 14, 14, 0.72);
  padding: 8px 10px;
  color: var(--forge-muted);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  backdrop-filter: blur(10px);
}

.forge-scene-hud strong {
  color: var(--forge-primary-soft);
}

.forge-scene-hud small {
  color: #b8d1c0;
  font-size: inherit;
  font-weight: 900;
  letter-spacing: inherit;
}

.forge-precision-hud {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 7;
  display: grid;
  gap: 4px;
  width: min(330px, calc(100% - 32px));
  border: 1px solid rgba(255, 183, 125, 0.68);
  border-radius: var(--forge-radius);
  background: rgba(14, 14, 14, 0.82);
  padding: 9px 11px;
  color: var(--forge-text);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  pointer-events: none;
  contain: layout paint;
}

.forge-precision-hud[hidden] {
  display: none;
}

.forge-precision-hud header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--forge-primary-soft);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.forge-precision-hud strong,
.forge-precision-hud > span,
.forge-precision-hud small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.forge-precision-hud strong {
  color: #fff8dc;
  font-size: 12px;
}

.forge-precision-hud > span,
.forge-precision-hud small {
  color: #cfc2b7;
  font-size: 10px;
  font-weight: 700;
}

.forge-axis-legend {
  display: flex;
  gap: 4px;
}

.forge-axis-legend b {
  min-width: 18px;
  border: 1px solid currentColor;
  padding: 1px 4px;
  text-align: center;
}

.forge-axis-legend .axis-x { color: #ff6b63; }
.forge-axis-legend .axis-y { color: #65d77c; }
.forge-axis-legend .axis-z { color: #5f9dff; }

.forge-status {
  left: 16px;
  bottom: 88px;
  z-index: 7;
  gap: 6px;
}

.forge-status span {
  min-height: 28px;
  border: 1px solid rgba(86, 67, 52, 0.9);
  border-radius: var(--forge-radius);
  background: rgba(14, 14, 14, 0.74);
  box-shadow: none;
  color: var(--forge-text);
  padding: 7px 9px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.tool-hotbar {
  bottom: 14px;
  z-index: 8;
  grid-template-columns: repeat(9, 54px);
  gap: 6px;
  border: 1px solid rgba(86, 67, 52, 0.8);
  border-radius: var(--forge-radius);
  background: rgba(14, 14, 14, 0.62);
  padding: 6px;
  backdrop-filter: blur(12px);
}

.tool-slot {
  width: 54px;
  height: 54px;
  min-height: 54px;
  border: 1px solid #333;
  border-radius: 2px;
  background: rgba(32, 32, 31, 0.94);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
  color: var(--forge-text);
}

.tool-slot.active {
  border-color: var(--forge-primary);
  background: rgba(255, 140, 0, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255, 140, 0, 0.82), 0 0 24px rgba(255, 140, 0, 0.12);
}

.tool-hotkey,
.tool-name {
  color: var(--forge-muted-dim);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 10px;
}

.resource-pane {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  border-left: 1px solid rgba(164, 140, 122, 0.18);
  background: var(--forge-surface);
  scrollbar-color: rgba(255, 140, 0, 0.45) transparent;
}

.panel-head {
  flex: 0 0 auto;
  justify-content: space-between;
  margin: 0;
  padding: 14px 12px;
  border-bottom: 1px solid var(--forge-outline);
  background: var(--forge-surface-high);
}

.panel-head p {
  margin-bottom: 5px;
  color: var(--forge-primary);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
.panel-head h1 {
  color: var(--forge-text);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.15;
}

.hammer-button {
  min-width: 88px;
  border-color: rgba(255, 183, 125, 0.42);
  background: rgba(255, 140, 0, 0.08);
  color: var(--forge-primary-soft);
}

.hammer-button.active {
  border-color: transparent;
  background: var(--forge-primary);
  color: #2f1500;
}

.panel-tabs {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  border-bottom: 1px solid var(--forge-outline);
  background: rgba(20, 20, 19, 0.88);
}

.panel-tab {
  min-width: 0;
  min-height: 44px;
  border: 0;
  border-right: 1px solid var(--forge-outline);
  background: transparent;
  color: var(--forge-muted-dim);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.panel-tab:last-child {
  border-right: 0;
}

.panel-tab.active {
  background: rgba(255, 140, 0, 0.14);
  color: var(--forge-primary-soft);
  box-shadow: inset 0 -2px 0 var(--forge-primary);
}

.panel-section {
  padding: 12px;
  border-top: 0;
  border-bottom: 1px solid var(--forge-outline);
}

.panel-tab-panel {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.panel-tab-panel[hidden] {
  display: none;
}

.section-title-row {
  margin-bottom: 12px;
}

.section-title-row h2,
.panel-section > h2 {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  color: var(--forge-muted);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
}

.panel-icon {
  position: relative;
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 1px solid currentColor;
  color: var(--forge-primary-soft);
  opacity: 0.9;
}

.panel-icon.inventory::before,
.panel-icon.drafts::before,
.panel-icon.workpiece::before {
  position: absolute;
  inset: 3px;
  background: currentColor;
  content: "";
}

.panel-icon.drafts {
  transform: rotate(45deg);
}

.panel-icon.workpiece {
  border-radius: 50%;
}

.draft-actions {
  display: flex;
  gap: 6px;
}

.draft-actions button {
  width: 34px;
  min-width: 34px;
  height: 30px;
  min-height: 30px;
  overflow: hidden;
  padding: 0;
  text-indent: 999px;
  white-space: nowrap;
}

.draft-actions button::before {
  display: block;
  color: currentColor;
  font-size: 16px;
  line-height: 30px;
  text-align: center;
  text-indent: 0;
}

#saveDraft::before {
  content: "S";
}

#saveDraftAsNew {
  border-color: transparent;
  background: var(--forge-primary);
  color: #2f1500;
}

#saveDraftAsNew::before {
  content: "+";
}

.resource-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  align-items: start;
}

.resource-card {
  grid-template-columns: 1fr;
  grid-template-rows: minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1;
  border: 1px solid var(--forge-outline);
  border-radius: var(--forge-radius);
  background: var(--forge-surface-low);
  padding: 6px;
  color: var(--forge-text);
  text-align: center;
  transition: border-color 120ms ease, background 120ms ease, filter 120ms ease, opacity 120ms ease;
}

.resource-card:hover:not(.used):not(:disabled) {
  border-color: rgba(255, 183, 125, 0.54);
  background: rgba(255, 140, 0, 0.08);
}

.resource-card strong {
  align-self: end;
  color: var(--forge-text);
  font-family: "Hanken Grotesk", ui-sans-serif, system-ui, sans-serif;
  font-size: 10px;
  font-weight: 900;
  line-height: 1.05;
}

.resource-card span:last-child {
  color: var(--forge-muted-dim);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.resource-card.material-slot {
  position: relative;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

.resource-card.material-slot span:not(.resource-swatch):not(.material-slot-count) {
  display: none;
}

.resource-card.material-slot.dragging {
  border-color: rgba(255, 191, 0, 0.94);
  background: rgba(255, 140, 0, 0.22);
  cursor: grabbing;
}

.resource-card.selected {
  border-color: rgba(255, 191, 0, 0.82);
  background: rgba(255, 140, 0, 0.14);
  box-shadow: inset 0 0 0 1px rgba(255, 191, 0, 0.24);
}

.resource-card.used,
.resource-card:disabled {
  border-color: rgba(86, 67, 52, 0.44);
  background: rgba(28, 27, 27, 0.55);
  cursor: default;
  filter: grayscale(0.92);
  opacity: 0.48;
}

.resource-card.empty,
.resource-card.loading,
.resource-card.error {
  grid-column: 1 / -1;
  grid-template-rows: auto auto;
  aspect-ratio: auto;
  min-height: 74px;
  padding: 12px;
  text-align: left;
}

.resource-swatch {
  justify-self: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(164, 140, 122, 0.64);
  border-radius: var(--forge-radius);
  background: var(--forge-surface-hot);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.035);
}

.resource-swatch-canvas {
  width: 40px;
  height: 40px;
  transform: scale(1.08);
}

.material-slot-count {
  position: absolute;
  right: 4px;
  bottom: 4px;
  min-width: 22px;
  border: 1px solid rgba(255, 248, 220, 0.18);
  border-radius: 999px;
  background: rgba(10, 10, 10, 0.74);
  color: var(--forge-text);
  padding: 1px 5px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 9px;
  font-weight: 900;
  line-height: 1.35;
  text-align: center;
}

.material-drag-ghost {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 140;
  display: grid;
  width: 48px;
  height: 48px;
  overflow: hidden;
  place-items: center;
  border: 1px solid rgba(255, 183, 125, 0.72);
  border-radius: var(--forge-radius);
  background: rgba(32, 32, 31, 0.94);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.38);
  opacity: 0.86;
  pointer-events: none;
  user-select: none;
  will-change: transform;
}

.material-drag-ghost .resource-swatch-canvas {
  width: 44px;
  height: 44px;
  transform: none;
}

.material-drag-ghost.over-forge {
  border-color: var(--forge-secondary);
  background: rgba(255, 140, 0, 0.24);
  box-shadow:
    inset 0 0 0 1px rgba(255, 191, 0, 0.42),
    0 12px 30px rgba(0, 0, 0, 0.4),
    0 0 22px rgba(255, 140, 0, 0.2);
  opacity: 1;
}

.material-detail-panel,
.draft-panel {
  margin-top: 12px;
  border-top: 1px solid var(--forge-outline);
  padding-top: 12px;
}

.material-detail-head {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.material-detail-head strong,
.detail-empty-state strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: var(--forge-text);
  font-size: 14px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.material-detail-head span,
.detail-empty-state span {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: var(--forge-muted-dim);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.detail-stat-grid div,
.detail-composition,
.detail-empty-state {
  min-width: 0;
  border: 1px solid var(--forge-outline);
  border-radius: var(--forge-radius);
  background: rgba(14, 14, 14, 0.48);
  padding: 8px;
}

.detail-stat-grid span,
.detail-composition span {
  display: block;
  margin-bottom: 5px;
  color: var(--forge-muted-dim);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.detail-stat-grid b,
.detail-composition b {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: var(--forge-primary-soft);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-composition {
  margin-top: 8px;
}

.draft-list {
  gap: 8px;
  max-height: 152px;
}

.draft-entry {
  border: 1px solid var(--forge-outline);
  border-radius: var(--forge-radius);
  background: var(--forge-surface-low);
  color: var(--forge-text);
  padding: 10px;
}

.draft-entry.active {
  border-color: rgba(255, 140, 0, 0.72);
  background: rgba(255, 140, 0, 0.12);
}

.draft-entry strong {
  color: var(--forge-text);
  font-size: 13px;
  font-weight: 900;
}

.draft-entry small {
  display: block;
  min-width: 0;
  max-width: 100%;
  margin-top: 3px;
  overflow: hidden;
  color: var(--forge-muted-dim);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 9px;
  font-weight: 700;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.draft-entry span,
.draft-empty {
  color: var(--forge-muted-dim);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 10px;
}

.stat-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
  margin-bottom: 14px;
}

.stat-list div {
  display: block;
  min-height: 62px;
  border: 1px solid var(--forge-outline);
  border-radius: var(--forge-radius);
  background: rgba(14, 14, 14, 0.48);
  padding: 9px;
}

.stat-list dt {
  margin-bottom: 7px;
  color: var(--forge-muted-dim);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stat-list dd {
  color: var(--forge-text);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 13px;
  font-weight: 800;
}

#materialValue {
  color: var(--forge-tertiary);
}

#heatValue {
  color: var(--forge-primary-soft);
}

.attribute-panel {
  border: 1px solid rgba(255, 199, 106, 0.18);
  border-radius: var(--forge-radius-lg);
  background:
    linear-gradient(135deg, rgba(255, 199, 106, 0.09), transparent 42%),
    rgba(10, 10, 10, 0.42);
  padding: 10px;
}

.attribute-panel-head,
.attribute-grid div,
.attribute-breakdown div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.attribute-panel-head {
  margin-bottom: 9px;
}

.attribute-panel-head strong {
  color: var(--forge-text);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.attribute-panel-head span,
.attribute-grid span,
.attribute-breakdown span {
  color: var(--forge-muted-dim);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 9px;
  font-weight: 800;
}

.attribute-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.attribute-grid div,
.attribute-breakdown div {
  min-height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
  padding: 6px 8px;
}

.attribute-grid b,
.attribute-breakdown b {
  color: var(--forge-primary-soft);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
  font-weight: 900;
  text-align: right;
  white-space: nowrap;
}

.attribute-breakdown {
  display: grid;
  gap: 5px;
  margin-top: 8px;
}

.capacity-diagnostics-panel[hidden] {
  display: none;
}

.capacity-diagnostics-panel {
  flex: 0 0 auto;
  display: grid;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--forge-outline);
  background:
    linear-gradient(135deg, rgba(255, 199, 106, 0.08), transparent 46%),
    rgba(10, 10, 10, 0.28);
}

.capacity-diagnostics-head {
  display: grid;
  gap: 5px;
}

.capacity-diagnostics-head h2 {
  color: var(--forge-text);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1.25;
  text-transform: uppercase;
}

.capacity-diagnostics-head p {
  color: var(--forge-muted);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.45;
}

.capacity-diagnostics-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.capacity-diagnostics-meta div {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--forge-radius);
  background: rgba(255, 255, 255, 0.035);
  padding: 7px;
}

.capacity-diagnostics-meta dt {
  margin-bottom: 4px;
  color: var(--forge-muted-dim);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1.25;
  text-transform: uppercase;
}

.capacity-diagnostics-meta dd {
  min-width: 0;
  overflow: hidden;
  color: var(--forge-primary-soft);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 10px;
  font-weight: 900;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.capacity-diagnostics-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0 6px;
  color: var(--forge-text);
  font-family: "JetBrains Mono", ui-monospace, monospace;
}

.capacity-diagnostics-table th,
.capacity-diagnostics-table td {
  min-width: 0;
  padding: 7px 6px;
  text-align: left;
  vertical-align: middle;
}

.capacity-diagnostics-table thead th {
  color: var(--forge-muted-dim);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.06em;
  line-height: 1.2;
  text-transform: uppercase;
}

.capacity-diagnostics-table tbody th,
.capacity-diagnostics-table tbody td {
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.035);
  font-size: 10px;
  font-weight: 900;
  line-height: 1.3;
}

.capacity-diagnostics-table tbody th {
  border-left: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--forge-radius) 0 0 var(--forge-radius);
}

.capacity-diagnostics-table tbody td:last-child {
  border-right: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 0 var(--forge-radius) var(--forge-radius) 0;
}

.capacity-diagnostics-table th:first-child {
  width: 35%;
}

.capacity-diagnostics-table th:nth-child(2),
.capacity-diagnostics-table th:nth-child(3) {
  width: 20%;
}

.capacity-diagnostics-table th:last-child {
  width: 25%;
}

.capacity-check-label,
.capacity-check-badge,
.capacity-diagnostics-table small {
  display: block;
  min-width: 0;
}

.capacity-check-label,
.capacity-diagnostics-table td {
  overflow-wrap: anywhere;
}

.capacity-progress-bar {
  position: relative;
  display: block;
  width: 100%;
  height: 6px;
  margin-top: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.capacity-progress-bar span {
  display: block;
  width: var(--capacity-progress);
  height: 100%;
  border-radius: inherit;
  background: var(--forge-error);
}

.capacity-diagnostics-table tr[data-state="pass"] .capacity-progress-bar span {
  background: #69d391;
}

.capacity-check-badge {
  width: max-content;
  max-width: 100%;
  border: 1px solid rgba(255, 180, 171, 0.35);
  border-radius: 999px;
  color: var(--forge-error);
  padding: 2px 6px;
  font-size: 8px;
  line-height: 1.2;
  text-transform: uppercase;
}

.capacity-diagnostics-table tr[data-state="pass"] .capacity-check-badge {
  border-color: rgba(105, 211, 145, 0.38);
  color: #69d391;
}

.capacity-diagnostics-table small {
  margin-top: 4px;
  color: var(--forge-muted-dim);
  font-size: 8px;
  font-weight: 800;
  line-height: 1.25;
}

.action-row {
  gap: 8px;
  margin-top: 10px;
}

.action-row button {
  flex: 1 1 100%;
  min-height: 34px;
}

#castPiece {
  border-color: transparent;
  background: var(--forge-primary);
  color: #2f1500;
}

#clearPiece {
  border-color: rgba(255, 180, 171, 0.32);
  background: transparent;
  color: var(--forge-error);
}

.forging-primary-action {
  flex: 0 0 auto;
  padding: 12px;
  border-top: 1px solid var(--forge-outline);
  background: rgba(53, 53, 53, 0.34);
}

.forging-primary-action button {
  width: 100%;
  height: 48px;
  border-color: transparent;
  background: var(--forge-secondary);
  color: #261a00;
  font-size: 11px;
  box-shadow: 0 0 28px rgba(255, 191, 0, 0.12);
}

.forging-primary-action button::before {
  margin-right: 8px;
  content: "⚡";
}

.chain-modal {
  z-index: 100;
  background: rgba(14, 14, 14, 0.82);
  backdrop-filter: blur(10px);
}

.chain-dialog {
  width: min(720px, calc(100vw - 32px));
  max-height: min(680px, calc(100vh - 32px));
  border-color: var(--forge-primary);
  border-radius: 8px;
  background: var(--forge-surface);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.56);
  overflow: auto;
}

.chain-dialog-head {
  border-bottom: 0;
  background: var(--forge-primary);
  color: #2f1500;
  padding: 14px 16px;
}

.chain-dialog-head h2 {
  color: #2f1500;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 20px;
  font-weight: 800;
}

#closeChainCode {
  border: 0;
  background: rgba(47, 21, 0, 0.12);
  color: #2f1500;
}

#chainCodeOutput {
  height: auto;
  min-height: 72px;
  max-height: 280px;
  border: 1px solid var(--forge-outline);
  border-radius: var(--forge-radius);
  background: var(--forge-bg-deep);
  color: var(--forge-primary-soft);
  margin: 12px 18px;
  width: calc(100% - 36px);
  font-family: "JetBrains Mono", ui-monospace, monospace;
}

.chain-dialog-actions {
  padding: 0 18px 18px;
}

.chain-dialog-actions p {
  color: var(--forge-muted-dim);
}

.chain-dialog-actions .chain-action-status {
  color: var(--forge-primary-soft);
}

.language-menu {
  border-color: var(--forge-outline);
  border-radius: var(--forge-radius);
  background: var(--forge-surface-low);
}

@media (max-width: 980px) {
  .forging-app-bar {
    height: auto;
    min-height: 56px;
    padding: 8px 10px;
  }

  .forging-brand small {
    display: none;
  }

  .scene-actions {
    gap: 6px;
  }

  .scene-actions button,
  .language-trigger {
    min-height: 44px;
    padding: 8px 10px;
    font-size: 11px;
  }

  .forging-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 58vh) minmax(270px, 42vh);
    padding-top: 56px;
  }

  .scene-pane {
    border-right: 0;
    border-bottom: 1px solid var(--forge-outline);
  }

  .forge-scene-hud {
    top: 10px;
    left: 10px;
    padding: 8px 10px;
    font-size: 10px;
  }

  .forge-precision-hud {
    top: 102px;
    right: 10px;
    width: min(330px, calc(100% - 20px));
  }

  .forge-status {
    left: 10px;
    right: 10px;
    bottom: 74px;
  }

  .tool-hotbar {
    bottom: 8px;
    grid-template-columns: repeat(9, 48px);
    grid-template-rows: 48px;
    gap: 4px;
    width: max-content;
    max-width: calc(100% - 16px);
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    touch-action: pan-x;
  }

  .tool-hotbar::-webkit-scrollbar {
    display: none;
  }

  .tool-slot {
    width: auto;
    height: 48px;
    min-height: 48px;
    min-width: 44px;
    padding: 2px;
  }

  .tool-name {
    display: none;
  }

  .resource-pane {
    border-left: 0;
  }

  .panel-head,
  .panel-section,
  .forging-primary-action {
    padding: 10px;
  }

  .resource-pane {
    overflow-y: auto;
  }

  .resource-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .resource-card {
    min-height: 0;
    padding: 7px;
  }

  .resource-card strong {
    font-size: 12px;
  }

  .draft-list {
    max-height: 118px;
  }

  .stat-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .forging-app-bar {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .scene-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
  }

  .scene-actions button,
  .scene-actions .language-picker,
  .language-trigger {
    flex: initial;
    min-width: 0;
  }

  #refreshMaterials {
    min-height: 44px;
    padding: 8px 10px;
  }

  .language-picker {
    width: 100%;
  }

  .language-menu {
    right: 0;
    left: auto;
    width: min(280px, calc(100vw - 20px));
  }

  .language-option {
    grid-template-columns: minmax(0, 1fr);
    min-height: 44px;
  }

  .language-option-native,
  .language-option-status {
    grid-column: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .forging-layout {
    grid-template-rows: minmax(0, 52vh) minmax(320px, 48vh);
    padding-top: 112px;
  }

  .resource-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .resource-card.empty,
  .resource-card.loading,
  .resource-card.error {
    grid-column: 1 / -1;
  }

  .panel-head h1 {
    font-size: 18px;
  }

  .hammer-button {
    min-width: 72px;
  }
}

/* Gloves context menu: object rotation moved out of the side panel. */
.forge-context-menu {
  position: fixed;
  z-index: 120;
  display: grid;
  gap: 6px;
  width: 178px;
  border: 1px solid rgba(255, 140, 0, 0.58);
  border-radius: var(--forge-radius, 4px);
  background: rgba(20, 19, 18, 0.96);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.48), 0 0 28px rgba(255, 140, 0, 0.1);
  padding: 8px;
  color: var(--forge-text, #e5e2e1);
  backdrop-filter: blur(14px);
}

.forge-context-menu[hidden] {
  display: none !important;
}

.forge-context-menu strong {
  display: block;
  padding: 3px 4px 7px;
  border-bottom: 1px solid rgba(255, 183, 125, 0.18);
  color: var(--forge-primary-soft, #ffb77d);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
}

.forge-context-menu button {
  justify-content: start;
  width: 100%;
  min-height: 32px;
  border-color: rgba(86, 67, 52, 0.88);
  background: rgba(32, 32, 31, 0.92);
  text-align: left;
}

.forge-context-menu button:hover {
  border-color: rgba(255, 183, 125, 0.72);
  background: rgba(255, 140, 0, 0.16);
}

.forge-context-menu button.danger {
  margin-top: 2px;
  border-color: rgba(255, 180, 171, 0.28);
  color: var(--forge-error, #ffb4ab);
}

.forge-context-menu button.danger:hover {
  border-color: rgba(255, 180, 171, 0.72);
  background: rgba(255, 180, 171, 0.12);
}

.chain-proof-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0 18px 14px;
}

.chain-proof-grid > div {
  min-width: 0;
  border: 1px solid rgba(255, 183, 125, 0.18);
  background: rgba(15, 16, 14, 0.72);
  padding: 9px 10px;
}

.chain-proof-grid dt {
  color: var(--forge-muted, #aaa7a5);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.chain-proof-grid dd {
  margin: 5px 0 0;
  overflow: hidden;
  color: var(--forge-primary-soft, #ffb77d);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 560px) {
  .chain-proof-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Explicit forge editing states and legacy material inheritance details. */
.forge-edit-modes {
  position: absolute;
  top: 64px;
  left: 16px;
  z-index: 7;
  display: flex;
  align-items: center;
  gap: 4px;
  border: 1px solid rgba(86, 67, 52, 0.88);
  border-radius: var(--forge-radius);
  background: rgba(14, 14, 14, 0.74);
  padding: 4px;
  backdrop-filter: blur(10px);
}

.forge-edit-modes > span {
  padding: 0 7px;
  color: var(--forge-muted-dim);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.forge-edit-modes button {
  min-height: 30px;
  padding: 5px 8px;
}

.forge-edit-modes button.active {
  border-color: var(--forge-primary);
  background: rgba(255, 140, 0, 0.2);
  color: var(--forge-primary-soft);
}

.forge-history-divider {
  flex: 0 0 1px;
  width: 1px;
  height: 22px;
  margin: 0 2px;
  background: rgba(255, 183, 125, 0.22);
}

.forge-edit-modes button:disabled {
  border-color: rgba(86, 67, 52, 0.5);
  background: rgba(32, 32, 31, 0.5);
  color: rgba(221, 193, 174, 0.32);
  cursor: default;
  transform: none;
}

.material-attribute-section {
  margin-top: 10px;
}

.material-attribute-section > strong,
.attribute-subtitle,
.component-editor-subtitle {
  display: block;
  margin: 0 0 7px;
  color: var(--forge-muted);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.material-attribute-grid,
.inherited-attribute-grid {
  margin-top: 0;
}

.detail-composition b {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

.workpiece-physical-grid,
.inherited-attribute-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.attribute-subtitle {
  margin-top: 12px;
}

.inheritance-breakdown {
  margin-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 10px;
}

.inheritance-rule {
  margin: 0 0 8px;
  color: var(--forge-muted-dim);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 9px;
  font-weight: 700;
  line-height: 1.45;
}

.physics-advisory-note {
  margin: 8px 0 0;
  border-left: 2px solid rgba(126, 196, 255, 0.55);
  color: var(--forge-muted-dim);
  padding-left: 8px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 9px;
  font-weight: 700;
  line-height: 1.45;
}

.inheritance-source {
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--forge-radius);
  background: rgba(255, 255, 255, 0.025);
}

.inheritance-source summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 34px;
  padding: 7px 8px;
  cursor: pointer;
  list-style-position: inside;
}

.inheritance-source summary span,
.inheritance-source summary b {
  min-width: 0;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 9px;
  line-height: 1.35;
}

.inheritance-source summary span {
  overflow: hidden;
  color: var(--forge-text);
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inheritance-source summary b {
  color: var(--forge-primary-soft);
  font-weight: 800;
  text-align: right;
}

.inheritance-source-attributes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  padding: 8px;
}

.inheritance-source-attributes > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--forge-radius);
  background: rgba(255, 255, 255, 0.025);
  padding: 5px 6px;
}

.inheritance-source-attributes span,
.inheritance-source-attributes b {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 8px;
}

.inheritance-source-attributes span {
  color: var(--forge-muted-dim);
}

.inheritance-source-attributes b {
  color: var(--forge-primary-soft);
}

.component-editor {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  border: 1px solid rgba(255, 183, 125, 0.18);
  border-radius: var(--forge-radius);
  background: rgba(14, 14, 14, 0.42);
  padding: 10px;
}

.component-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.component-editor-head strong {
  color: var(--forge-text);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
}

.component-editor-head span,
.component-editor p {
  color: var(--forge-muted-dim);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 9px;
  font-weight: 800;
}

.component-editor p {
  margin: 0;
  line-height: 1.45;
}

.component-editor .selected-face-value {
  color: var(--forge-primary-soft);
}

.component-editor-subtitle {
  margin-top: 4px;
  margin-bottom: 0;
}

.component-editor-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}

.component-editor-actions button {
  min-width: 0;
  min-height: 34px;
  padding: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.component-editor-actions button.danger {
  border-color: rgba(255, 180, 171, 0.32);
  color: var(--forge-error);
}

@media (max-width: 980px) {
  .forge-edit-modes {
    top: 54px;
    left: 10px;
  }
}

@media (max-width: 520px) {
  .forge-precision-hud {
    top: 100px;
    gap: 2px;
    border-color: rgba(255, 183, 125, 0.56);
    background: rgba(14, 14, 14, 0.68);
    padding: 6px 8px;
  }

  .forge-precision-hud header {
    justify-content: flex-end;
  }

  .forge-precision-hud header > span:first-child {
    display: none;
  }

  .forge-precision-hud strong {
    font-size: 10px;
  }

  .forge-precision-hud > span,
  .forge-precision-hud small {
    font-size: 9px;
  }

  .forge-edit-modes {
    right: 8px;
    left: auto;
    width: 184px;
    max-width: calc(100vw - 16px);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .forge-edit-modes::-webkit-scrollbar {
    display: none;
  }

  .forge-edit-modes > span {
    display: none;
  }

  .forge-edit-modes button {
    flex: 1 0 auto;
    min-height: 34px;
  }

  .workpiece-physical-grid,
  .inherited-attribute-grid,
  .inheritance-source-attributes {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Short mobile viewports need a real work area instead of compressing the
   forge canvas between the fixed app bar and resource inspector. */
@media (max-width: 980px) and (max-height: 700px) {
  html {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }

  body {
    height: auto;
    min-height: 100svh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .forging-app-bar {
    position: sticky;
    top: 0;
  }

  .forging-layout {
    height: auto;
    min-height: 600px;
    padding-top: 0;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(280px, 46svh) minmax(320px, auto);
  }

  .scene-pane {
    min-height: 280px;
  }

  .resource-pane {
    min-height: 320px;
    overflow: visible;
  }

  .forge-edit-modes button,
  .component-editor-actions button,
  .tool-settings-row button,
  .forge-context-menu button,
  .inheritance-source summary {
    min-height: 44px;
  }
}

@media (max-width: 520px) {
  .scene-actions > [data-i18n-language-menu],
  .scene-actions .language-picker,
  .scene-actions .language-trigger {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .scene-actions > button,
  .scene-actions .language-trigger {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .language-current {
    min-width: 0;
    text-overflow: ellipsis;
  }

  .forge-edit-modes {
    top: 72px;
  }

  .forge-edit-modes button,
  .component-editor-actions button,
  .tool-settings-row button,
  .forge-context-menu button,
  .inheritance-source summary {
    min-height: 44px;
  }
}
