:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #11140f;
  color: #edf2df;
  --bg: #11140f;
  --panel: #1b2017;
  --line: #3e4a34;
  --line-bright: #758b5b;
  --grass: #6faa3f;
  --redstone: #e35a49;
  --gold: #f2c14e;
  --water: #5fb7d3;
  --text-soft: #b8c4ad;
  --shadow: rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    var(--bg);
  background-size: 32px 32px;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  min-height: 100vh;
}

.tab-rail {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100vh;
  padding: 12px 8px;
  border-right: 2px solid #090b08;
  background: #151911;
  box-shadow: 8px 0 24px var(--shadow);
}

.app-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 48px;
  margin: 0 auto 8px;
  border: 2px solid #0b0d09;
  background: linear-gradient(135deg, #5d8f32, #293521 55%, #725237);
  font-weight: 950;
}

.rail-button {
  display: grid;
  place-items: center;
  gap: 5px;
  min-height: 58px;
  padding: 8px 4px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
}

.rail-icon {
  font-size: 11px;
  font-weight: 950;
}

.rail-label {
  width: 100%;
  overflow: hidden;
  font-size: 10px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rail-button:hover,
.rail-button.active {
  border-color: var(--line-bright);
  background: #26311f;
  color: #ffffff;
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  padding: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 8px 10px;
  border: 1px solid rgba(117, 139, 91, 0.5);
  border-bottom-color: #0a0d08;
  background:
    linear-gradient(90deg, rgba(13, 18, 11, 0.78), rgba(13, 18, 11, 0.34) 54%, rgba(13, 18, 11, 0.82)),
    url("./title-dirt.png") repeat-x center top;
  background-size: auto 106px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05), 0 8px 20px rgba(0, 0, 0, 0.22);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 8px;
  font-size: clamp(24px, 5vw, 36px);
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
}

h3 {
  margin-bottom: 8px;
  font-size: 16px;
}

.status-pill,
.result-count {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #202619;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 800;
}

.panel {
  border: 2px solid #0c0f0a;
  background: linear-gradient(180deg, var(--panel), #151912);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05), 0 14px 30px var(--shadow);
}

.tool-grid,
.commands-layout,
.recipe-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

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

.section-heading p {
  margin: 3px 0 0;
  color: var(--text-soft);
  font-size: 13px;
}

.editor-panel,
.output-panel,
.wiki-panel,
.command-form-panel,
.command-list-panel,
.list-panel,
.recipe-detail,
.login-panel {
  padding: 14px;
}

.swatch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(62px, 1fr));
  gap: 7px;
  margin-bottom: 10px;
}

.swatch-button,
.format-row button,
.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #20271a;
  color: #eef5e5;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.swatch-button {
  justify-content: flex-start;
  padding: 6px;
  font-size: 12px;
}

.swatch-button span {
  width: 18px;
  height: 18px;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.format-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 10px;
}

.format-row button:first-child {
  font-weight: 950;
}

.format-row button:nth-child(2) {
  font-style: italic;
}

.format-row button:nth-child(3) {
  text-decoration: underline;
}

.format-row button:nth-child(4) {
  text-decoration: line-through;
}

textarea,
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
  background: #0f120d;
  color: #ffffff;
}

textarea:focus,
input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(242, 193, 78, 0.18);
}

textarea {
  min-height: 162px;
  padding: 12px;
  resize: vertical;
}

.minecraft-preview {
  min-height: 96px;
  margin-bottom: 12px;
  padding: 14px;
  border: 2px solid #080a07;
  background: #111;
  font-family: "Courier New", monospace;
  font-size: 20px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.output-label {
  display: block;
  margin-bottom: 7px;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.code-output {
  min-height: 86px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0f120d;
  color: #f9f8d4;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.primary-button {
  border-color: #8acb54;
  background: linear-gradient(180deg, var(--grass), #47782b);
  color: #071005;
}

.secondary-button {
  padding: 0 10px;
  border-color: var(--water);
}

.ghost-button {
  padding: 0 10px;
  background: #20271a;
}

.danger-button {
  background: #3a1e1a;
  color: #ffd4ce;
}

.icon-only {
  width: 42px;
  padding: 0;
  font-size: 11px;
}

.recipe-list,
.command-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 210px);
  overflow: auto;
  padding-right: 2px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0f120d;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 850;
}

.search-box input {
  min-height: 42px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.search-box.large input {
  min-height: 50px;
}

.recipe-row {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #20271a;
  color: #eef5e5;
  text-align: left;
  cursor: pointer;
}

.recipe-row.active {
  border-color: var(--gold);
  background: #2b3323;
}

.recipe-row small,
.empty-state {
  color: var(--text-soft);
}

.crafting-stage {
  display: grid;
  grid-template-columns: minmax(156px, 1fr) 34px minmax(76px, 0.5fr);
  align-items: center;
  gap: 12px;
}

.crafting-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(44px, 1fr));
  gap: 6px;
  aspect-ratio: 1;
}

.crafting-slot,
.result-slot {
  display: grid;
  place-items: center;
  border: 2px solid #070907;
  background: linear-gradient(135deg, #3c4435, #171c14);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.06);
  color: #f4efd3;
  font-weight: 950;
}

.crafting-slot span,
.result-slot span {
  max-width: 100%;
  overflow: hidden;
  padding: 2px;
  font-size: 13px;
  text-overflow: ellipsis;
}

.crafting-arrow {
  color: var(--gold);
  font-size: 20px;
  font-weight: 900;
  text-align: center;
}

.result-slot {
  aspect-ratio: 1;
  background: linear-gradient(135deg, #5d4424, #1e2119);
}

.ingredient-list,
.quick-links,
.backup-actions,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.ingredient-list span {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #20271a;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 800;
}

.quick-links {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.quick-links a {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #20271a;
  color: #eef5e5;
  font-weight: 850;
  text-decoration: none;
}

.disabled-link {
  opacity: 0.42;
  pointer-events: none;
}

.login-panel {
  display: grid;
  justify-items: start;
  gap: 12px;
  max-width: 440px;
}

.login-icon {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--gold);
  font-weight: 950;
}

.login-panel form,
.command-form {
  display: grid;
  gap: 9px;
  width: 100%;
}

.login-panel input,
.command-form input,
.command-form textarea {
  min-height: 42px;
  padding: 10px;
}

.command-form textarea {
  min-height: 118px;
}

.command-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #20271a;
}

.command-item code {
  display: block;
  margin-bottom: 8px;
  color: #f9f8d4;
  overflow-wrap: anywhere;
}

.command-item p {
  margin-bottom: 0;
  color: var(--text-soft);
  white-space: pre-wrap;
}

.item-actions {
  display: grid;
  align-content: start;
  gap: 7px;
}

.file-button {
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.error-text {
  margin: 10px 0 0;
  color: #ffb1a7;
}

@media (min-width: 900px) {
  .tool-grid,
  .commands-layout,
  .recipe-layout {
    grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  }
}

@media (max-width: 520px) {
  .app-shell {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .workspace {
    padding: 10px;
  }

  .rail-label {
    display: none;
  }

  .rail-button {
    min-height: 48px;
  }

  .app-mark {
    width: 44px;
  }

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

  .crafting-stage {
    grid-template-columns: 1fr;
  }
}

img {
  image-rendering: pixelated;
}

.login-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 18px;
}

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

.login-note {
  margin: 0;
  color: var(--text-soft);
  font-size: 13px;
}

.app-logo {
  display: grid;
  place-items: center;
  width: 70px;
  height: 54px;
  margin: 0 auto 10px;
  padding: 0;
  border: 0;
  background: transparent;
  filter: drop-shadow(0 9px 12px rgba(0, 0, 0, 0.38));
}

.app-logo.large {
  width: 160px;
  height: 104px;
  margin: 0 0 14px;
}

.app-logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.logo-pixel {
  display: block;
  border: 1px solid rgba(0, 0, 0, 0.55);
  box-shadow: inset 3px 3px 0 rgba(255, 255, 255, 0.12), inset -3px -3px 0 rgba(0, 0, 0, 0.2);
}

.logo-pixel.dirt {
  background: #6b4b32;
}

.logo-pixel.grass {
  background: linear-gradient(#69ad3d 0 38%, #7a5434 39%);
}

.logo-pixel.stone {
  background: #7f8582;
}

.logo-pixel.gold {
  background: #f2c14e;
}

.logo-pixel.redstone {
  background: #c83c34;
}

.logo-pixel.diamond {
  background: #50d7cf;
}

.rail-icon {
  font-size: 10px;
}

.swatch-button {
  min-width: 0;
}

.swatch-button small {
  min-width: 0;
  overflow: hidden;
  color: var(--text-soft);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.format-row {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.format-row button:first-child {
  font-weight: 800;
}

.format-row button:nth-child(2) {
  font-style: normal;
  font-weight: 950;
}

.format-row button:nth-child(3) {
  font-style: italic;
  text-decoration: none;
}

.format-row button:nth-child(4) {
  text-decoration: underline;
}

.format-row button:nth-child(5) {
  text-decoration: line-through;
}

.recipe-row {
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 3px 9px;
  align-items: center;
}

.recipe-row small {
  grid-column: 2;
}

.recipe-row .item-icon,
.recipe-row .icon-fallback {
  grid-row: span 2;
}

.process-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px minmax(112px, 0.7fr);
  align-items: center;
  gap: 12px;
}

.crafting-slot .item-icon,
.result-slot .item-icon,
.crafting-slot .icon-fallback,
.result-slot .icon-fallback {
  width: 30px;
  height: 30px;
}

.item-icon {
  display: block;
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.icon-fallback {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #11150f;
  color: var(--gold);
  font-size: 10px;
  font-weight: 950;
}

.hidden {
  display: none !important;
}

.ingredient-cloud,
.source-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 0;
}

.ingredient-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #20271a;
  color: #eef5e5;
  font-size: 12px;
  font-weight: 800;
}

.source-strip {
  margin-bottom: 12px;
}

.source-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #20271a;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 850;
  text-decoration: none;
}

.source-pill.ok {
  border-color: var(--grass);
  color: #d8f2c6;
}

.source-pill.error {
  border-color: var(--redstone);
  color: #ffb1a7;
}

.wiki-results {
  display: grid;
  gap: 9px;
}

.wiki-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #20271a;
}

.wiki-card h3 {
  margin-bottom: 6px;
}

.wiki-card p {
  margin-bottom: 8px;
  color: var(--text-soft);
}

.wiki-card small {
  color: var(--gold);
}

@media (max-width: 520px) {
  .app-logo {
    width: 50px;
    height: 42px;
  }

  .app-logo.large {
    width: 142px;
    height: 92px;
  }

  .topbar {
    background-size: auto 92px;
  }

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

  .crafting-stage,
  .process-stage,
  .wiki-card,
  .command-item {
    grid-template-columns: minmax(0, 1fr);
  }
}
