:root {
  color-scheme: light;
  --bg: #f3f6f7;
  --surface: #ffffff;
  --surface-muted: #f8fafb;
  --border: #d6dee2;
  --border-strong: #b9c7cd;
  --text: #172126;
  --text-muted: #64737b;
  --accent: #28744e;
  --accent-hover: #1f6241;
  --accent-soft: #e6f3eb;
  --blue: #2f6f91;
  --blue-soft: #e8f2f7;
  --amber: #8a5a00;
  --amber-soft: #fff2d7;
  --danger: #a33a3a;
  --shadow: 0 10px 30px rgba(28, 44, 52, 0.12);
  font-family: "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(47, 111, 145, 0.25);
  outline-offset: 1px;
}

.app-header {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

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

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid #9bb8a8;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 24px;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 17px;
  line-height: 1.2;
}

.pack-meta {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 12px;
}

.header-stats {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--text-muted);
  font-size: 12px;
}

.header-actions {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 18px;
}

.wiki-home-link {
  flex: 0 0 auto;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.wiki-home-link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.header-stat strong {
  display: block;
  color: var(--text);
  font-size: 14px;
  text-align: right;
}

.app-layout {
  height: calc(100% - 58px);
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
}

.item-sidebar {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.search-wrap {
  position: relative;
  margin: 14px 14px 8px;
}

.search-wrap input {
  width: 100%;
  height: 40px;
  padding: 0 36px 0 38px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

.search-wrap input:focus {
  border-color: var(--blue);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 8px;
  color: var(--text-muted);
  font-size: 22px;
  line-height: 1;
  pointer-events: none;
}

.icon-button {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--text-muted);
}

.icon-button:hover {
  border-color: var(--border);
  background: var(--surface-muted);
  color: var(--text);
}

.search-clear {
  position: absolute;
  right: 4px;
  top: 4px;
  font-size: 20px;
}

.sidebar-status {
  min-height: 28px;
  padding: 3px 16px 8px;
  color: var(--text-muted);
  font-size: 12px;
}

.item-results {
  min-height: 0;
  overflow: auto;
  scrollbar-gutter: stable;
  padding: 0 8px 12px;
}

.sidebar-pager {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 7px 10px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
}

.pager-button {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-muted);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
}

.pager-button:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.pager-button:disabled {
  cursor: default;
  opacity: 0.35;
}

.item-result {
  width: 100%;
  min-height: 58px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  text-align: left;
}

.item-result:hover {
  background: var(--surface-muted);
  border-color: var(--border);
}

.item-result.is-selected {
  background: var(--accent-soft);
  border-color: #a9ccb8;
}

.item-result-copy {
  min-width: 0;
}

.item-result-name,
.item-result-id {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-result-name {
  font-weight: 600;
  font-size: 14px;
}

.item-result-id {
  margin-top: 3px;
  color: var(--text-muted);
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 11px;
}

.item-result-counts {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  color: var(--text-muted);
  font-size: 10px;
}

.item-icon,
.category-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  overflow: hidden;
  background: #edf1f3;
  border: 1px solid #cad5da;
  border-radius: 4px;
}

.item-icon {
  width: var(--icon-size, 38px);
  height: var(--icon-size, 38px);
}

.item-icon img,
.category-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.item-icon-fallback {
  color: #50636c;
  font-weight: 700;
  font-size: calc(var(--icon-size, 38px) * 0.34);
  user-select: none;
}

.workspace {
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: scroll;
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
  background: var(--bg);
}

.empty-state {
  min-height: 100%;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 8px;
  color: var(--text-muted);
}

.empty-state strong {
  color: var(--text);
  font-size: 18px;
}

.empty-icon {
  color: #90a4ad;
  font-size: 52px;
  line-height: 1;
}

.item-workspace {
  min-width: 0;
  min-height: 100%;
}

.is-hidden {
  display: none !important;
}

.item-heading {
  min-height: 92px;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 16px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.selected-icon .item-icon {
  --icon-size: 56px;
}

.selected-copy {
  min-width: 0;
}

.selected-copy h2 {
  overflow-wrap: anywhere;
  font-size: 20px;
  line-height: 1.3;
}

.selected-id {
  margin-top: 4px;
  color: var(--text-muted);
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.selected-counts {
  display: flex;
  gap: 8px;
}

.count-badge {
  min-width: 72px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-muted);
  color: var(--text-muted);
  text-align: center;
  font-size: 11px;
}

.count-badge strong {
  display: block;
  color: var(--text);
  font-size: 15px;
}

.view-tabs {
  height: 45px;
  display: flex;
  align-items: end;
  gap: 4px;
  padding: 0 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.view-tab {
  height: 44px;
  padding: 0 16px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
}

.view-tab:hover {
  color: var(--text);
}

.view-tab.is-active {
  border-bottom-color: var(--accent);
  color: var(--accent);
}

.recipe-view,
.tree-view {
  padding: 18px 22px 40px;
}

.view-toolbar,
.tree-toolbar {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.view-toolbar strong,
.tree-summary strong {
  font-size: 16px;
}

.view-toolbar span,
.tree-summary span,
.load-status {
  margin-left: 7px;
  color: var(--text-muted);
  font-size: 12px;
}

.recipe-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 430px), 1fr));
  gap: 12px;
  align-items: start;
}

.recipe-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
}

.recipe-card-header {
  min-height: 45px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
}

.recipe-category {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.category-icon {
  width: 28px;
  height: 28px;
}

.recipe-category span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recipe-reference {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 10px;
}

.recipe-card-body {
  display: grid;
  grid-template-columns: minmax(150px, 44%) minmax(0, 1fr);
  min-height: 170px;
}

.recipe-preview-wrap {
  min-width: 0;
  min-height: 170px;
  display: grid;
  place-items: center;
  padding: 12px;
  border-right: 1px solid var(--border);
  background-color: #eef2f4;
  background-image:
    linear-gradient(45deg, #e2e8eb 25%, transparent 25%),
    linear-gradient(-45deg, #e2e8eb 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e2e8eb 75%),
    linear-gradient(-45deg, transparent 75%, #e2e8eb 75%);
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
  background-size: 12px 12px;
}

.recipe-preview-button {
  max-width: 100%;
  max-height: 300px;
  padding: 0;
  border: 0;
  background: transparent;
}

.recipe-preview {
  display: block;
  max-width: 100%;
  max-height: 300px;
  object-fit: contain;
  image-rendering: pixelated;
}

.recipe-no-image {
  color: var(--text-muted);
  font-size: 12px;
}

.recipe-io {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  padding: 12px;
}

.io-section {
  min-width: 0;
}

.io-label {
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
}

.ingredient-groups {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.ingredient-group {
  min-width: 42px;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
}

.ingredient-group.has-alternatives {
  border-color: #c6b27e;
  background: #fffaf0;
}

.ingredient-button {
  position: relative;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
}

.ingredient-button:hover {
  background: var(--accent-soft);
}

.ingredient-button .item-icon {
  --icon-size: 34px;
  border: 0;
  background: transparent;
}

.ingredient-count {
  position: absolute;
  right: 0;
  bottom: -1px;
  min-width: 16px;
  padding: 0 2px;
  border-radius: 3px;
  background: rgba(20, 29, 34, 0.86);
  color: #fff;
  font-size: 10px;
  line-height: 15px;
  text-align: center;
}

.alternative-count {
  padding: 0 4px 0 2px;
  color: var(--amber);
  font-size: 10px;
  font-weight: 700;
}

.recipe-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.recipe-flag {
  padding: 3px 6px;
  border-radius: 4px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 10px;
}

.recipe-flag.is-warning {
  background: var(--amber-soft);
  color: var(--amber);
}

.load-more-wrap,
.recipe-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding-top: 16px;
}

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

.recipe-pager .command-button {
  min-width: 82px;
}

.recipe-pager .command-button:disabled {
  cursor: default;
  opacity: 0.4;
}

.command-button {
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid #9db9aa;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-weight: 600;
}

.command-button:hover {
  border-color: var(--accent);
  background: #dceee4;
}

.command-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.tree-toolbar {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.tree-summary {
  min-width: 180px;
  margin-right: auto;
}

.depth-control {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
  font-size: 12px;
}

.depth-control select,
.tree-recipe-select,
.tree-alternative-select {
  height: 34px;
  max-width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
}

.depth-control select {
  width: 72px;
  padding: 0 7px;
}

.toolbar-icon {
  border-color: var(--border);
  background: var(--surface);
  font-size: 18px;
}

.tree-status {
  min-height: 24px;
  color: var(--text-muted);
  font-size: 12px;
}

.graph-workspace {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 12px;
  align-items: stretch;
}

.graph-viewport {
  position: relative;
  min-width: 0;
  height: max(520px, calc(100vh - 260px));
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: #eef2f3;
}

.graph-viewport.is-dragging {
  cursor: grabbing;
}

.graph-stage {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.graph-edges,
.graph-nodes {
  position: absolute;
  inset: 0;
}

.graph-edges {
  overflow: visible;
  pointer-events: none;
}

.graph-edge {
  fill: none;
  stroke: #91a5ad;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.graph-node {
  position: absolute;
  width: 188px;
  height: 142px;
  display: grid;
  grid-template-rows: 48px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid #b9c7cd;
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 4px 14px rgba(35, 53, 62, 0.1);
  cursor: pointer;
  user-select: none;
}

.graph-node:hover {
  border-color: #7da18d;
}

.graph-node.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(40, 116, 78, 0.18), 0 5px 16px rgba(35, 53, 62, 0.14);
}

.graph-node.is-cycle {
  border-color: #c49745;
}

.graph-node-header {
  min-width: 0;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  padding: 6px 7px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
}

.graph-node-header .item-icon {
  --icon-size: 32px;
}

.graph-node-title {
  min-width: 0;
}

.graph-node-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
}

.graph-node-amount {
  margin-top: 1px;
  overflow: hidden;
  color: var(--text-muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
}

.graph-node-action {
  width: 27px;
  height: 27px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--accent);
  line-height: 1;
}

.graph-node-action:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.graph-node-action:disabled {
  color: var(--text-muted);
  opacity: 0.6;
}

.graph-node-body {
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 6px;
  background: #edf1f3;
}

.graph-node-body img {
  display: block;
  max-width: 174px;
  max-height: 80px;
  object-fit: contain;
  image-rendering: pixelated;
}

.graph-node-category,
.graph-node-state {
  max-width: 100%;
  overflow: hidden;
  color: var(--text-muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
}

.graph-node-preview {
  min-width: 0;
  display: grid;
  justify-items: center;
  gap: 3px;
}

.graph-controls {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 3px 12px rgba(35, 53, 62, 0.12);
}

.graph-controls span {
  min-width: 48px;
  color: var(--text-muted);
  text-align: center;
  font-size: 11px;
}

.graph-control-button {
  border-color: var(--border);
  background: var(--surface-muted);
  color: var(--text);
  font-size: 18px;
}

.graph-inspector {
  height: max(520px, calc(100vh - 260px));
  min-width: 0;
  overflow: auto;
  scrollbar-gutter: stable;
  border: 1px solid #26343b;
  border-radius: 7px;
  background: #1f292e;
  color: #eef4f1;
}

.inspector-section {
  padding: 13px;
  border-bottom: 1px solid #3a484f;
}

.inspector-section:last-child {
  border-bottom: 0;
}

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

.inspector-heading strong {
  font-size: 13px;
}

.inspector-muted {
  color: #aebdc4;
  font-size: 11px;
}

.inspector-item {
  min-width: 0;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
}

.inspector-item .item-icon {
  --icon-size: 38px;
}

.inspector-item-name,
.inspector-item-id {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inspector-item-name {
  font-weight: 700;
}

.inspector-item-id {
  margin-top: 2px;
  color: #aebdc4;
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 10px;
}

.inspector-select {
  width: 100%;
  height: 36px;
  margin-top: 10px;
  padding: 0 30px 0 9px;
  border: 1px solid #6d8088;
  border-radius: 5px;
  background: #2a363c;
  color: #f6faf8;
}

.inspector-button {
  width: 100%;
  min-height: 34px;
  margin-top: 10px;
  border: 1px solid #65a07e;
  border-radius: 5px;
  background: #244d37;
  color: #dff4e7;
  font-weight: 600;
}

.material-summary-list {
  display: grid;
  gap: 5px;
}

.material-summary-item {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 5px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: inherit;
  text-align: left;
}

.material-summary-item:hover {
  border-color: #52666f;
  background: #29363c;
}

.material-summary-item .item-icon {
  --icon-size: 28px;
  border-color: #52666f;
}

.material-summary-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}

.material-summary-count {
  color: #7fd39d;
  font-weight: 700;
  font-size: 11px;
}

.tree-canvas {
  min-width: 0;
  padding: 8px 0 40px;
}

.tree-branch {
  min-width: 0;
}

.tree-node-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(220px, 340px) minmax(220px, 1fr);
  gap: 12px;
  align-items: start;
  padding: 8px 0;
}

.tree-node-main {
  min-width: 0;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.tree-node-main .item-icon {
  --icon-size: 42px;
}

.tree-node-copy {
  min-width: 0;
}

.tree-node-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.tree-node-amount,
.tree-node-id {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 11px;
}

.tree-node-id {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: Consolas, "Cascadia Mono", monospace;
}

.tree-expand-button {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-muted);
  color: var(--accent);
  font-size: 18px;
}

.tree-expand-button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.tree-expand-button:disabled {
  cursor: default;
  color: var(--text-muted);
  opacity: 0.7;
}

.tree-node-recipe {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 9px;
  align-items: center;
  padding: 7px 9px;
  border-left: 3px solid #9db9aa;
  background: rgba(255, 255, 255, 0.72);
}

.tree-recipe-select {
  width: 100%;
  padding: 0 28px 0 9px;
}

.tree-recipe-thumb {
  width: 96px;
  height: 56px;
  object-fit: contain;
  background: #edf1f3;
  image-rendering: pixelated;
}

.tree-children {
  margin-left: 28px;
  padding-left: 18px;
  border-left: 2px solid #c8d4d9;
}

.tree-alternative-select {
  grid-column: 1 / -1;
  width: 100%;
  height: 28px;
  margin-top: 5px;
  padding: 0 24px 0 7px;
  font-size: 11px;
}

.tree-cycle,
.tree-leaf {
  padding: 5px 8px;
  border-radius: 4px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 11px;
}

.tree-leaf {
  background: var(--blue-soft);
  color: var(--blue);
}

.error-panel,
.no-results {
  padding: 28px 16px;
  color: var(--text-muted);
  text-align: center;
}

.error-panel strong {
  display: block;
  margin-bottom: 6px;
  color: var(--danger);
}

.image-dialog {
  width: min(92vw, 1100px);
  height: min(88vh, 820px);
  padding: 44px 20px 20px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: #20272b;
  box-shadow: var(--shadow);
}

.image-dialog::backdrop {
  background: rgba(13, 18, 21, 0.72);
}

.image-dialog img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.dialog-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border: 1px solid #63727a;
  border-radius: 5px;
  background: #303b41;
  color: #fff;
  font-size: 22px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 36px));
  padding: 10px 13px;
  border: 1px solid #9db9aa;
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.page-scroll-controls {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 15;
  display: grid;
  gap: 5px;
  padding: 5px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.page-scroll-button {
  width: 34px;
  height: 34px;
  border-color: var(--border);
  background: var(--surface-muted);
  color: var(--text);
  font-size: 18px;
}

.page-scroll-button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

@media (max-width: 900px) {
  html,
  body {
    overflow: auto;
  }

  .app-header {
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .header-stats {
    display: none;
  }

  .app-layout {
    height: auto;
    min-height: calc(100vh - 58px);
    grid-template-columns: 1fr;
  }

  .item-sidebar {
    height: 340px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .workspace {
    min-height: 650px;
    overflow: visible;
  }

  .graph-workspace {
    grid-template-columns: 1fr;
  }

  .graph-viewport,
  .graph-inspector {
    height: 560px;
  }

  .graph-inspector {
    height: auto;
    max-height: 440px;
  }

  .recipe-card-body,
  .tree-node-row {
    grid-template-columns: 1fr;
  }

  .recipe-preview-wrap {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .tree-node-recipe {
    margin-left: 18px;
  }
}

@media (max-width: 560px) {
  .app-header {
    padding: 0 10px;
  }

  .header-actions {
    gap: 8px;
  }

  .wiki-home-link {
    font-size: 12px;
  }

  h1 {
    max-width: 240px;
  }

  .item-heading {
    grid-template-columns: 52px minmax(0, 1fr);
    padding: 13px 14px;
  }

  .selected-counts {
    grid-column: 1 / -1;
    justify-content: stretch;
  }

  .count-badge {
    flex: 1;
  }

  .view-tabs {
    padding: 0 10px;
  }

  .view-tab {
    flex: 1;
    padding: 0 8px;
  }

  .recipe-view,
  .tree-view {
    padding: 14px 10px 32px;
  }

  .recipe-list {
    grid-template-columns: 1fr;
  }

  .graph-viewport {
    height: 500px;
  }

  .tree-children {
    margin-left: 12px;
    padding-left: 10px;
  }
}
