:root {
  --bg: #1a1d23;
  --panel: #242830;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --accent: #7cb3ff;
  --border: #3c424d;
  --leaf: #a8d4a8;
}

.item-icon {
  width: 16px;
  height: 16px;
  vertical-align: middle;
  margin-right: 4px;
  image-rendering: pixelated;
  flex-shrink: 0;
}

.icon-fallback {
  display: inline-block;
  border-radius: 2px;
}

.icon-raw     { background: #7a6840; }
.icon-semi    { background: #4a6478; }
.icon-product { background: #9a7d2a; }

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Microsoft JhengHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

header h1 {
  margin: 0 0 0.35rem;
  font-size: 1.25rem;
  font-weight: 600;
}

header p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
}

main {
  padding: 1.25rem 1.5rem;
  max-width: 56rem;
  margin: 0 auto;
}

label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

/* ── Queue input ─────────────────────────────────────────────── */
.queue-input-wrap {
  position: relative;
  max-width: 26rem;
}

.queue-input-group {
  display: flex;
  gap: 0.5rem;
}

#ac-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-top: none;
  border-radius: 0 0 6px 6px;
  max-height: 14rem;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
}

.ac-item {
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}

.ac-item:last-child {
  border-bottom: none;
}

.ac-item:hover,
.ac-item.ac-active {
  background: #2a3a50;
  color: var(--text);
}

mark.ac-highlight {
  background: transparent;
  color: var(--accent);
  font-weight: 700;
}

input[type="search"] {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  min-width: 0;
}

input[type="search"]::placeholder {
  color: var(--muted);
}

#btn-add {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  white-space: nowrap;
}

#btn-add:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Queue list ──────────────────────────────────────────────── */
#queue-list {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-width: 26rem;
}

.queue-empty {
  font-size: 0.85rem;
  color: var(--muted);
}

.queue-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.65rem;
}

.queue-name {
  flex: 1;
  font-size: 0.9rem;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.qty-group {
  display: flex;
  align-items: center;
}

.queue-qty {
  width: 3.5rem;
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px 0 0 4px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  text-align: right;
}

.btn-qty {
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--border);
  border-left: none;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
}

.btn-qty:last-child {
  border-radius: 0 4px 4px 0;
}

.btn-qty:hover {
  color: var(--accent);
  border-color: var(--accent);
  z-index: 1;
}

.btn-remove {
  padding: 0.1rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
}

.btn-remove:hover {
  border-color: #e57373;
  color: #e57373;
}

section {
  margin-top: 1.75rem;
}

section h2 {
  font-size: 1rem;
  margin: 0 0 0.75rem;
  color: var(--accent);
  font-weight: 600;
}

.tree-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.tree-tool-btn {
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.tree-tool-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.empty {
  color: var(--muted);
  font-size: 0.9rem;
}

/* ── Aggregate 2-col grid ────────────────────────────────────── */
#agg-grid {
  font-size: 0.9rem;
}

.agg-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1rem;
}

.agg-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border);
  gap: 0.5rem;
}

.agg-cell-name {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agg-cell-qty {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  flex-shrink: 0;
}

/* ── Tree blocks ─────────────────────────────────────────────── */
.tree-block {
  margin-bottom: 1.25rem;
}

.tree-block-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
  font-family: ui-monospace, monospace;
}

.tree {
  font-size: 0.9rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1rem 1rem 1.25rem;
}

.tree ul {
  margin: 0;
  list-style: none;
}

.tree li {
  margin: 0.35rem 0;
  position: relative;
}

.ref-note {
  margin-top: 1rem;
  font-size: 0.8rem;
  color: var(--muted);
}

footer {
  padding: 1rem 1.5rem 2rem;
  max-width: 56rem;
  margin: 0 auto;
  font-size: 0.75rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

#link-feedback {
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}

#link-feedback:hover {
  text-decoration: underline;
}

/* listree：暗色主題與字型 */
.tree ul.listree {
  margin: 0;
  padding-left: 0;
}

.tree ul.listree-submenu-items {
  border-left-color: var(--border) !important;
}

.tree .listree-submenu-heading {
  display: flex;
  align-items: center;
  color: var(--text);
  font-weight: 600;
  user-select: none;
}

.tree .listree-submenu-heading:hover {
  color: var(--accent);
}

.tree .tree-line {
  color: var(--text);
  font-weight: 500;
}

.tree .tree-line.tree-leaf {
  color: var(--leaf);
}

/* ── Owned-material checkbox ─────────────────────────────────── */
.own-chk {
  margin-left: auto;
  flex-shrink: 0;
  width: 0.85rem;
  height: 0.85rem;
  cursor: pointer;
  accent-color: var(--accent);
}

.agg-owned-suffix {
  margin-left: 0.2em;
  color: var(--muted);
  font-size: 0.85em;
}

/* ── NPC tag ─────────────────────────────────────────────────── */
.npc-tag {
  display: inline-block;
  margin-left: 0.45rem;
  padding: 0 0.35rem;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 400;
  background: #2a3a50;
  color: var(--accent);
  vertical-align: middle;
  pointer-events: none;
}

.npc-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  user-select: none;
}

.npc-toggle-label input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent);
}
