:root {
  --bg: #12100d;
  --panel: #1c1914;
  --panel-2: #241f18;
  --line: #352e24;
  --text: #ece4d4;
  --muted: #a39780;
  --gold: #d4a73c;
  --gold-soft: rgba(212, 167, 60, 0.14);
  --pos: #7fc56b;
  --neg: #e07a6a;
  --warn: #e3b55a;
  --q1: #ece4d4;
  --q2: #4fd65c;
  --q3: #5aa2ff;
  --q4: #b86cff;
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 ui-sans-serif, -apple-system, "Segoe UI", Inter, system-ui, sans-serif;
  padding: 0 16px 48px;
}

a { color: var(--gold); }
.muted { color: var(--muted); }

.top {
  max-width: 1240px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 0 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.coin {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #f3d27a, var(--gold) 55%, #8e6a1f);
  color: #2a1f08; font: 700 18px Georgia, serif;
  box-shadow: 0 0 0 2px #3a2c10, 0 4px 14px rgba(212, 167, 60, 0.25);
}
h1 { margin: 0; font: 600 22px Georgia, "Times New Roman", serif; letter-spacing: 0.2px; }
.realm { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }
button:disabled { opacity: 0.6; cursor: progress; }

button.ghost {
  background: transparent; color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 14px; font: inherit; cursor: pointer;
}
button.ghost:hover, button.ghost[aria-expanded="true"] { border-color: var(--gold); color: var(--gold); }

.refresh, .controls, .highlights, main { max-width: 1240px; margin: 0 auto; }

.refresh {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 18px; margin-bottom: 16px;
}
.refresh h2 { margin: 0 0 6px; font-size: 15px; }
.refresh ol { margin: 0 0 8px; padding-left: 20px; }
.refresh li { margin: 6px 0; }
.bookmarklet {
  display: inline-block; padding: 3px 10px; border-radius: 6px;
  background: var(--gold); color: #24190a; font-weight: 600; text-decoration: none; cursor: grab;
}

.controls {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px 18px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 16px;
}
.group { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.group.grow { flex: 1 1 200px; }
.group.wide { flex: 1 1 100%; }
.label { font-size: 12px; color: var(--muted); }
select, input[type="search"], input[type="number"] {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 7px;
  padding: 7px 9px; font: inherit; min-width: 0;
}
input[type="number"] { width: 72px; }
select:focus, input:focus, button:focus-visible, .chip:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.skills { display: flex; gap: 10px; flex-wrap: wrap; }
.skill { display: flex; align-items: center; gap: 6px; font-size: 13px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--muted);
  border-radius: 999px; padding: 6px 12px; font: inherit; cursor: pointer;
}
.chip[aria-pressed="true"] { border-color: var(--gold); color: var(--text); background: var(--gold-soft); }
.chip-actions { display: inline-flex; align-items: center; gap: 2px; margin-left: 4px; }
button.link {
  background: none; border: 0; padding: 6px 8px; font: inherit; font-size: 13px;
  color: var(--gold); cursor: pointer; border-radius: 6px;
}
button.link:hover { text-decoration: underline; }
button.link:disabled { color: var(--muted); opacity: 0.5; cursor: default; text-decoration: none; }

.toggle { display: flex; align-items: center; gap: 8px; padding-bottom: 7px; cursor: pointer; }
.toggle input { accent-color: var(--gold); width: 16px; height: 16px; }

.highlights {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px; margin-bottom: 18px;
}
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px;
}
.card .k { font-size: 12px; color: var(--muted); }
.card .v { font-size: 16px; font-weight: 600; margin: 4px 0 2px; }
.card .s { font-size: 12.5px; color: var(--muted); }

.count { color: var(--muted); margin: 0 0 8px; font-size: 13px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--panel-2); position: sticky; top: 0; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr.row { cursor: pointer; }
tbody tr.row:hover { background: rgba(255, 255, 255, 0.025); }
tbody tr.row[aria-expanded="true"] { background: var(--gold-soft); }
td.rank { color: var(--muted); width: 36px; }

.recipe { display: flex; align-items: center; gap: 10px; }
.icon {
  width: 28px; height: 28px; border-radius: 5px; flex: none;
  background: var(--panel-2); border: 1px solid #000; box-shadow: 0 0 0 1px var(--line);
  object-fit: cover;
}
.rname { font-weight: 600; }
.q1 { color: var(--q1); } .q2 { color: var(--q2); } .q3 { color: var(--q3); } .q4 { color: var(--q4); }
.sub { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.tag {
  display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); margin-left: 6px; vertical-align: 1px;
}
.tag.soon { border-color: rgba(227, 181, 90, 0.5); color: var(--warn); }

.pos { color: var(--pos); font-weight: 600; }
.neg { color: var(--neg); font-weight: 600; }
.vol { display: block; font-size: 11.5px; color: var(--muted); }

tr.detail td { background: var(--panel-2); white-space: normal; padding: 12px 16px 14px 60px; }
.reagents { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px 24px; margin: 0; padding: 0; list-style: none; }
.reagents li { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.detail-meta { margin-top: 10px; font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 18px; }

.confirm {
  max-width: 1240px; margin: 0 auto 16px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px;
  background: var(--panel); border: 1px solid var(--gold); border-radius: var(--radius);
  padding: 14px 18px;
}
.confirm h2 { margin: 0 0 4px; font-size: 15px; }
.confirm p { margin: 2px 0; }
.confirm-actions { display: flex; gap: 8px; }
button.primary {
  background: var(--gold); color: #24190a; border: 1px solid var(--gold);
  border-radius: 8px; padding: 8px 16px; font: inherit; font-weight: 600; cursor: pointer;
}
button.primary:hover { filter: brightness(1.08); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--gold); color: var(--text);
  padding: 10px 16px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  max-width: calc(100vw - 32px);
}
.toast.error { border-color: var(--neg); }

.empty { text-align: center; color: var(--muted); padding: 32px 0; }
.foot { font-size: 12px; margin-top: 14px; }

@media (max-width: 720px) {
  .hide-sm { display: none; }
  tr.detail td { padding-left: 16px; }
  .top { flex-wrap: wrap; }
}
