:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --ink: #17212b;
  --muted: #66717d;
  --line: #d8e0e6;
  --panel: #ffffff;
  --panel-soft: #f0f4f7;
  --teal: #087f8c;
  --teal-dark: #075d66;
  --gold: #b7791f;
  --rose: #b83280;
  --shadow: 0 12px 36px rgba(19, 35, 51, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    system-ui,
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

.prod-shell {
  width: min(1720px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 18px 0 28px;
}

.prod-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1.1;
}

h2 {
  font-size: 17px;
}

h3 {
  font-size: 15px;
}

.top-actions,
.item-title,
.meta-line,
.panel-head,
.material-row,
.check-row {
  display: flex;
  align-items: center;
}

.top-actions {
  gap: 8px;
}

.ghost,
.chip,
.primary {
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
}

.ghost,
.chip {
  background: var(--panel);
}

.primary {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
  font-weight: 800;
}

.primary:hover {
  background: var(--teal-dark);
}

.ghost {
  padding: 9px 12px;
}

.ghost.compact {
  padding: 6px 9px;
  font-size: 13px;
}

.danger {
  border: 1px solid #b42318;
  border-radius: 8px;
  background: #b42318;
  color: #fff;
  cursor: pointer;
  padding: 9px 12px;
}

.chip {
  padding: 8px 12px;
}

.chip.active {
  border-color: var(--teal);
  background: #e8f6f7;
  color: var(--teal-dark);
  font-weight: 700;
}

.search-band {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 12px 18px;
  align-items: end;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.search-box {
  display: grid;
  gap: 7px;
}

.search-actions {
  display: flex;
  align-items: end;
  gap: 10px;
  align-self: end;
}

.search-submit {
  min-height: 47px;
  width: 86px;
  padding: 10px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  font-weight: 800;
}

.search-box span,
.field-label {
  color: var(--muted);
  font-size: 13px;
}

.search-box input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  outline: none;
  background: #fbfcfd;
}

.search-box input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(8, 127, 140, 0.12);
}

.status {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 13px;
}

.status a {
  color: var(--teal-dark);
  font-weight: 800;
}

.prod-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 380px);
  gap: 16px;
  margin-top: 16px;
  align-items: start;
}

.detail-panel,
.check-panel {
  min-height: 280px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.check-panel {
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 24px);
  overflow: hidden;
}

.panel-head {
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.panel-head span {
  color: var(--muted);
  font-size: 13px;
}

.recipe-list,
.check-list {
  max-height: calc(100vh - 88px);
  overflow: auto;
  padding: 8px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px;
  max-height: none;
  padding: 8px 0 0;
}

.inline-head {
  padding: 0 0 10px;
  border-bottom: 1px solid var(--line);
}

.recipe-button {
  width: 100%;
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 10px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.recipe-button:hover,
.recipe-button.active {
  border-color: var(--line);
  background: var(--panel-soft);
}

.recipe-button.active {
  border-color: var(--teal);
}

.item-img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef3f5;
}

.recipe-name,
.material-name {
  overflow-wrap: anywhere;
  font-weight: 700;
}

.recipe-meta,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.recipe-detail {
  padding: 18px;
}

.hero-item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.hero-item .item-img {
  width: 72px;
  height: 72px;
}

.simulator-jump {
  align-self: center;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid rgba(8, 127, 140, 0.35);
  border-radius: 999px;
  background: #e8f6f7;
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.hero-actions {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.simulator-jump:hover {
  border-color: rgba(8, 127, 140, 0.58);
  background: #dff2f3;
}

.meta-line {
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #edf2f7;
  color: #2d3748;
  font-size: 12px;
}

.pill.gold {
  background: #fff6df;
  color: var(--gold);
}

.pill.rose {
  background: #fff0f7;
  color: var(--rose);
}

.section-block {
  padding: 16px 0 0;
}

.progress-recipe-box {
  display: grid;
  grid-template-columns: minmax(120px, 160px) minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.progress-recipe-box label {
  display: grid;
  gap: 5px;
}

.progress-recipe-box label span {
  color: var(--muted);
  font-size: 12px;
}

.craft-runs-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 9px;
}

.material-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.material-row {
  gap: 10px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

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

.material-row.craftable {
  border-color: rgba(8, 127, 140, 0.35);
}

.material-main {
  min-width: 0;
  flex: 1;
}

.material-count {
  color: var(--teal-dark);
  font-weight: 800;
}

.recipe-variants {
  display: grid;
  gap: 12px;
}

.variant-block {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.variant-block h4 {
  margin: 0;
  color: var(--teal-dark);
  font-size: 13px;
}

.alt-line {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.skill-line {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 22px;
  color: var(--muted);
  font-size: 12px;
}

.skill-img {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  object-fit: contain;
  border-radius: 6px;
  background: #eef3f5;
}

.pill .skill-img {
  width: 18px;
  height: 18px;
  margin-right: 5px;
}

.track-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 0 0 auto;
  border: 1px solid rgba(8, 127, 140, 0.35);
  border-radius: 8px;
  min-width: 34px;
  min-height: 34px;
  padding: 6px 9px;
  background: #e8f6f7;
  color: var(--teal-dark);
  cursor: pointer;
  font-weight: 700;
}

.primary-track {
  min-width: auto;
  padding: 8px 12px;
}

.icon-track {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 999px;
}

.track-icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-size: 20px;
  font-weight: 800;
}

.icon-remove {
  width: 28px;
  min-height: 28px;
  padding: 0;
  border-radius: 999px;
  font-size: 18px;
  line-height: 1;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.tree {
  margin-top: 12px;
  padding-left: 0;
}

.tree details {
  min-width: 0;
}

.tree summary {
  list-style: none;
  cursor: pointer;
}

.tree summary::-webkit-details-marker {
  display: none;
}

.tree summary::before {
  content: "›";
  display: inline-flex;
  width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  margin-right: 4px;
  border-radius: 999px;
  color: var(--teal-dark);
  background: #e8f6f7;
  font-weight: 900;
  transition: transform 0.15s ease;
}

.tree details[open] > summary::before {
  transform: rotate(90deg);
}

.tree ul {
  margin: 8px 0 0 18px;
  padding: 0;
  border-left: 1px solid var(--line);
}

.tree li {
  margin: 0;
  padding: 0 0 9px 13px;
  list-style: none;
}

.tree-node {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 4px 8px;
  border-radius: 8px;
  background: #f8fafb;
  max-width: 100%;
}

.checklist-tree .tree-node {
  display: flex;
  width: 100%;
  align-items: flex-start;
  padding: 5px 6px;
}

.checklist-tree ul {
  margin-left: 12px;
}

.checklist-tree li {
  padding-left: 9px;
}

.tree-node .item-img {
  width: 28px;
  height: 28px;
}

.checklist-tree .item-img {
  width: 24px;
  height: 24px;
}

.checklist-tree .skill-img {
  width: 18px;
  height: 18px;
}

.tree-main {
  display: grid;
  gap: 2px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.tree-node.done {
  color: var(--muted);
}

.tree-node.done .tree-main > span:first-child {
  text-decoration: line-through;
}

.progress-check {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  accent-color: var(--teal);
}

.tracked-group {
  position: relative;
  margin: 8px;
  padding: 6px 38px 6px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  border-bottom: 1px solid var(--line);
}

.tracked-group .checklist-tree {
  margin-top: 0;
}

.floating-remove {
  position: absolute;
  top: 8px;
  right: 8px;
}

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

.checklist-tree {
  margin-top: 8px;
}

.material-summary {
  margin: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fafb;
}

.detail-summary {
  margin: 18px 0 0;
}

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

.summary-list {
  display: grid;
  gap: 7px;
  margin-top: 9px;
}

.summary-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.summary-row[draggable="true"] {
  cursor: grab;
}

.summary-row[draggable="true"]:active {
  cursor: grabbing;
}

.summary-row .item-img {
  width: 26px;
  height: 26px;
}

.pricing-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.pricing-row label {
  display: grid;
  gap: 5px;
  min-width: 190px;
}

.pricing-row span {
  color: var(--muted);
  font-size: 12px;
}

.summary-table-wrap {
  margin-top: 10px;
  overflow-x: auto;
}

.summary-table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
  font-size: 13px;
}

.summary-table th,
.summary-table td {
  border-bottom: 1px solid var(--line);
  padding: 8px;
  vertical-align: middle;
  text-align: left;
}

.summary-table th {
  color: var(--muted);
  font-weight: 700;
  background: var(--panel-soft);
}

.summary-table tr[draggable="true"] {
  cursor: grab;
}

.summary-item-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 170px;
}

.item-img.tiny {
  width: 26px;
  height: 26px;
}

.summary-num,
.summary-select {
  width: 100%;
  min-width: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 8px;
  background: #fbfcfd;
  color: var(--ink);
}

.compact-num {
  max-width: 92px;
}

.summary-hint {
  min-width: 86px;
  color: var(--teal-dark);
  font-weight: 700;
}

body.night-mode .search-band,
body.night-mode .detail-panel,
body.night-mode .check-panel {
  background: #0f2c33;
}

body.night-mode .progress-recipe-box,
body.night-mode .material-row,
body.night-mode .tree-node,
body.night-mode .variant-block,
body.night-mode .tracked-group,
body.night-mode .material-summary,
body.night-mode .summary-row,
body.night-mode .summary-table th {
  border-color: #2f6971;
  background: #12343b;
  color: #e9fffb;
}

body.night-mode .summary-num,
body.night-mode .summary-select {
  border-color: #2f6971;
  background: #0f2c33;
  color: #e9fffb;
}

body.night-mode .summary-hint {
  color: #9be7df;
}

body.night-mode .status a {
  color: #9be7df;
}

body.night-mode .checklist-tree .tree-node,
body.night-mode .tracked-group {
  background: #143a42;
}

body.night-mode .tree-node.done {
  color: #8fb8b8;
}

body.night-mode .item-img,
body.night-mode .skill-img {
  border-color: #3f7880;
  background: #eaf3f3;
}

body.night-mode .pill {
  background: #173e46;
  color: #c5f3ef;
}

body.night-mode .pill.gold {
  background: #423616;
  color: #ffdf7e;
}

body.night-mode .pill.rose {
  background: #3c2238;
  color: #ff9ed0;
}

body.night-mode .simulator-jump {
  border-color: #4d8990;
  background: #173e46;
  color: #d8fffb;
}

.custom-total-box {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.summary-add {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px;
}

.summary-add span {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
}

.summary-add input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 9px;
  outline: none;
}

.check-row {
  gap: 9px;
  padding: 9px 6px;
  border-bottom: 1px solid var(--line);
}

.check-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
}

.check-row.done {
  color: var(--muted);
  text-decoration: line-through;
}

.empty-state {
  color: var(--muted);
  line-height: 1.6;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
  border-radius: 8px;
  background: #17212b;
  color: white;
  padding: 10px 13px;
  box-shadow: var(--shadow);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(23, 33, 43, 0.38);
  z-index: 20;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-card {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 18px;
  box-shadow: var(--shadow);
}

.modal-card p {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

@media (max-width: 1180px) {
  .prod-layout {
    grid-template-columns: 1fr;
  }

  .check-panel {
    grid-column: 1 / -1;
    position: static;
    max-height: none;
  }

  .check-list {
    max-height: none;
  }
}

@media (max-width: 760px) {
  .prod-shell {
    width: min(100vw - 18px, 720px);
    padding-top: 8px;
  }

  .prod-topbar,
  .search-band {
    display: grid;
  }

  .top-actions,
  .search-band,
  .prod-layout {
    grid-template-columns: 1fr;
  }

  .search-actions {
    align-items: stretch;
  }

  .search-actions > * {
    flex: 1;
  }

  .result-panel,
  .check-panel {
    position: static;
    max-height: none;
  }

  .recipe-list {
    max-height: 360px;
  }

  .hero-item {
    grid-template-columns: 56px minmax(0, 1fr);
  }

  .hero-item .item-img {
    width: 56px;
    height: 56px;
  }

  .simulator-jump {
    justify-self: stretch;
  }

  .hero-actions {
    grid-column: 1 / -1;
    justify-self: stretch;
  }

  .hero-actions > * {
    flex: 1 1 auto;
  }
}
