:root {
  color-scheme: dark;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  background: #0d0f0e;
  color: #ece8e2;
  --bg: #0d0f0e;
  --panel: #141715;
  --panel-2: #1b201d;
  --slot: #20251f;
  --slot-empty: #171a18;
  --border: #343a35;
  --border-strong: #4b534c;
  --muted: #9a9f99;
  --accent: #c67a4a;
  --accent-hover: #dc8a56;
  --danger: #dc6f6f;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; background: var(--bg); color: #ece8e2; }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.shell {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0 64px;
}

.hero { margin-bottom: 24px; }
.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
}
h1 { margin: 0; font-size: clamp(30px, 5vw, 48px); line-height: 1.05; }
.lede { margin: 12px 0 0; color: var(--muted); max-width: 760px; line-height: 1.55; }

.panel {
  margin-top: 16px;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--border);
}
.panel[hidden] { display: none; }

.fields {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
label { display: flex; flex-direction: column; gap: 7px; font-weight: 700; }
label span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
}
input {
  width: 100%;
  min-width: 0;
  padding: 12px 13px;
  color: inherit;
  background: #0f1210;
  border: 1px solid var(--border);
  outline: none;
}
input:hover { border-color: var(--border-strong); }
input:focus { border-color: var(--accent); }

.actions, .section-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.actions { margin-top: 16px; }
.section-heading { justify-content: space-between; }
.section-heading > span { color: var(--muted); font-size: 11px; }

button {
  padding: 10px 14px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: inherit;
  cursor: pointer;
}
button:hover { border-color: var(--accent); }
button:active { transform: translateY(1px); }
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #130c08;
  font-weight: 800;
}
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.alerts:empty { display: none; }
.alert { margin-bottom: 14px; padding: 10px 12px; border: 1px solid var(--border); background: var(--panel-2); }
.alert.success { border-color: var(--accent); }
.alert.danger { border-color: var(--danger); color: #ffd6d6; }

.summary {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 10px;
  margin-bottom: 22px;
}
.summary > div {
  padding: 14px 16px;
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.summary span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.summary strong { display: block; margin-top: 7px; font-size: clamp(18px, 3vw, 24px); }

h2 { margin: 18px 0 12px; font-size: 14px; letter-spacing: .02em; }

.inventory {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 7px;
  padding: 10px;
  background: #0f1210;
  border: 1px solid var(--border);
}
.tc-slot {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  overflow: hidden;
  background: var(--slot);
  border: 1px solid var(--border-strong);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .018);
}
.tc-slot--empty { background: var(--slot-empty); border-color: #2b302c; }
.tc-slot__image {
  position: absolute;
  inset: 10% 10% 12%;
  width: 80%;
  height: 78%;
  object-fit: contain;
  user-select: none;
}
.tc-slot__quantity {
  position: absolute;
  right: 5px;
  bottom: 4px;
  z-index: 2;
  padding: 2px 4px;
  background: rgba(7, 9, 8, .78);
  color: #fff;
  font-size: clamp(9px, 1.5vw, 12px);
  font-weight: 800;
  line-height: 1;
}

.totals {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.tc-total {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.tc-total__image { width: 44px; height: 44px; flex: 0 0 44px; object-fit: contain; }
.tc-total__copy { min-width: 0; }
.tc-total__label {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}
.tc-total__value { display: block; margin-top: 4px; font-size: 16px; font-weight: 800; }

.output-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.output-grid > div { min-width: 0; }
pre {
  min-height: 170px;
  max-height: 420px;
  overflow: auto;
  margin: 0;
  padding: 14px;
  white-space: pre-wrap;
  background: #0f1210;
  border: 1px solid var(--border);
  color: #ddd9d3;
  font: inherit;
  font-size: 12px;
  line-height: 1.55;
}

@media (max-width: 760px) {
  .shell { width: min(100% - 20px, 1040px); padding: 28px 0 48px; }
  .panel { padding: 14px; }
  .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary { grid-template-columns: 1fr 1fr; }
  .inventory { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; padding: 6px; }
  .tc-slot__quantity { right: 3px; bottom: 3px; padding: 2px 3px; font-size: 9px; }
  .totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .output-grid { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .tc-total__image { width: 36px; height: 36px; flex-basis: 36px; }
}
