:root {
  --bg: #f7f5ef;
  --panel: #ffffff;
  --ink: #2c2c2a;
  --muted: #6b6a64;
  --line: #e2dfd6;
  --accent: #b8860b;
  --now: #0f6e56;
  --next: #185fa5;
  --later: #5f5e5a;
  --done: #3b7d23;
  --bar: #e9e6dc;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1b19;
    --panel: #252523;
    --ink: #f1efe8;
    --muted: #a9a79f;
    --line: #3a3936;
    --accent: #e0b24a;
    --now: #5dcaa5;
    --next: #85b7eb;
    --later: #b4b2a9;
    --done: #8fcf6b;
    --bar: #3a3936;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.wrap { max-width: 1200px; margin: 0 auto; padding: 24px 16px 48px; }
h1 { font-size: 22px; margin: 0 0 4px; }
h1 span { color: var(--accent); }
.sub { color: var(--muted); margin: 0 0 20px; }

form.controls {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: end;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px;
}
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
input[type=text], select {
  font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; min-width: 160px;
}
.drop {
  flex: 1 1 260px; border: 1.5px dashed var(--line); border-radius: 8px; padding: 10px 12px;
  color: var(--muted); cursor: pointer; text-align: center;
}
.drop.over { border-color: var(--accent); color: var(--ink); }
.drop strong { color: var(--ink); }
.drop input { display: none; }
.check { flex-direction: row; align-items: center; gap: 6px; color: var(--ink); font-size: 13px; }
button {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 6px; padding: 8px 16px;
  border: 1px solid var(--accent); background: var(--accent); color: #1b1b19;
}
button:disabled { opacity: .5; cursor: default; }
button.ghost { background: transparent; color: var(--ink); border-color: var(--line); font-weight: 500; padding: 3px 8px; font-size: 12px; }

.msg { margin: 12px 0 0; padding: 8px 12px; border-radius: 6px; background: var(--panel); border-left: 3px solid var(--accent); }
.msg.err { border-left-color: #c0392b; }
.meta { color: var(--muted); font-size: 13px; margin: 14px 0 0; }

section.tier { margin-top: 28px; }
section.tier > header { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
section.tier h2 { font-size: 17px; margin: 0; }
section.tier p { margin: 0; color: var(--muted); font-size: 13px; }
.t-now h2 { color: var(--now); }
.t-next h2 { color: var(--next); }
.t-later h2 { color: var(--later); }
.t-done h2 { color: var(--done); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; flex-wrap: wrap; }
.tabs button {
  background: transparent; color: var(--muted); border: 1px solid transparent; border-bottom: none;
  border-radius: 8px 8px 0 0; padding: 8px 14px; font-weight: 600; margin-bottom: -1px;
}
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--now); background: var(--panel); border-color: var(--line); border-bottom: 1px solid var(--panel); }
.tabs .count { font-weight: 500; font-size: 12px; color: var(--muted); margin-left: 4px; }
.tier .blurb { margin: 0 0 10px; color: var(--muted); font-size: 13px; }
.raid-pick { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.raid-pick .small b { color: var(--next); }
.needs { margin: -4px 0 12px; font-size: 13px; color: var(--muted); }
.needs b { color: var(--next); font-weight: 600; }
.raid-self { margin-bottom: 14px; }
.small-btn { padding: 6px 12px; font-size: 13px; }
.modal.wide { width: min(1000px, 100%); max-height: min(88vh, 900px); }
.modal .modal-sub { margin: 6px 0 0; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.modal .modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; flex-wrap: wrap; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 6px; position: relative;
}
.card .top { display: flex; justify-content: space-between; gap: 8px; align-items: start; }
.card h3 { font-size: 15px; margin: 0; }
.card h3 a { color: inherit; text-decoration: none; }
.card h3 a:hover { text-decoration: underline; }
.rank { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 4px; }
.tag {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap;
  border-radius: 4px; padding: 1px 6px; border: 1px solid currentColor;
}
.tags { display: flex; gap: 4px; flex: none; }
.tag.farm { color: var(--now); }
.tag.raid { color: #8e44ad; }
@media (prefers-color-scheme: dark) { .tag.raid { color: #c39bd3; } }
.tag.make { color: var(--accent); }
.tag.quest { color: var(--next); }
.tag.train { color: var(--next); }
.tag.blocked { color: var(--later); }
.tag.done { color: var(--done); }
.small { font-size: 12px; color: var(--muted); }
.note { font-size: 12px; color: var(--muted); font-style: italic; }
ul.drops { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
ul.drops li { display: flex; align-items: center; gap: 8px; font-size: 13px; }
ul.drops li span { flex: 1; }
ul.drops li:has(> button) { display: grid; grid-template-columns: 1fr 56px 24px; gap: 8px; align-items: center; }
.bar.none { visibility: hidden; }
button.link {
  font: inherit; font-weight: inherit; text-align: left; padding: 0; border: 0; background: none; color: inherit;
  cursor: pointer; text-decoration: underline dotted var(--muted); text-underline-offset: 3px;
}
button.link:hover { color: var(--accent); text-decoration-color: var(--accent); }

.backdrop {
  position: fixed; inset: 0; z-index: 10; background: rgba(0, 0, 0, .45);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal {
  background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 12px;
  width: min(520px, 100%); max-height: min(80vh, 720px); overflow-y: auto; padding: 16px 18px;
  display: flex; flex-direction: column; gap: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, .3);
}
.modal header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.modal h3 { margin: 0; font-size: 17px; }
.modal p { margin: 0; }
.buttons { display: flex; gap: 8px; flex-wrap: wrap; }
button.secondary { background: transparent; color: var(--ink); border-color: var(--accent); }

.chart-backdrop { align-items: stretch; }
.chart-modal {
  background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 12px;
  width: 100%; display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; min-height: 0;
}
.chart-modal header { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.chart-modal h3 { margin: 0; font-size: 17px; }
.chart-modal header .ghost { margin-left: auto; }
.chart-modal p { margin: 0; }
.legend { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend b { color: var(--ink); font-weight: 600; margin-left: 10px; }
.legend b:first-child { margin-left: 0; }
.legend .sw { width: 14px; height: 14px; border-radius: 3px; background: var(--f); border: 1px solid var(--line); margin-left: 6px; }
.legend .ring { width: 14px; height: 14px; border-radius: 3px; border: 1.5px solid var(--s-line); margin-left: 6px; }
.legend .ready-key { width: 5px; height: 14px; border-radius: 2px; background: var(--ready); margin-left: 6px; }
.legend .ring.s-unknown { border-style: dashed; }
.legend .dash { width: 24px; border-top: 2px dashed var(--muted); margin-left: 10px; }
.chart-scroll { flex: 1; min-height: 0; overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.chart-scroll svg { display: block; }

/* Fill = node type */
.k-boss { --f: #f9dcd8; }
.k-activity { --f: #e2ecd5; }
.k-raid { --f: #ead9f4; }
.k-quest { --f: #fbefc4; }
.k-drop { --f: #a3a198; }
.k-craft { --f: #d9f2ef; }
.k-other { --f: #ecebe6; }
/* Border = status */
.chart-modal { --s-line: #a3a198; --ready: #2e9d55; --progress: #e08e0b; }
@media (prefers-color-scheme: dark) {
  .k-boss { --f: #4a1c17; }
  .k-activity { --f: #2a3a1c; }
  .k-raid { --f: #3a1d47; }
  .k-quest { --f: #3d3310; }
  .k-drop { --f: #6f6d66; }
  .k-craft { --f: #0f3a36; }
  .k-other { --f: #2f2f2c; }
  .chart-modal { --s-line: #6f6d66; --ready: #5ccf86; --progress: #f2b13c; }
}
.cnode { cursor: pointer; transition: opacity .15s; }
/* Status: one neutral outline (dashed until a plan exists); ready adds a bar on the left. */
.cnode rect { fill: var(--f); stroke: var(--s-line); stroke-width: 1.5; }
.cnode.s-unknown rect:first-of-type { stroke-dasharray: 5 3; }
.cnode rect.ready-bar { fill: var(--ready); stroke: none; }
.cnode.pin rect:first-of-type { stroke-width: 4; }
.cnode rect.prog { fill: var(--progress); stroke: none; opacity: .8; }
.cnode .ct { font-size: 12px; font-weight: 600; fill: var(--ink); }
.cnode .ck { font-size: 10px; fill: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.cnode.k-drop .ck { fill: var(--ink); opacity: .75; }
.cnode.ghost-ref rect { fill: var(--panel); fill-opacity: .7; stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.cnode.ghost-ref .ct { fill: var(--muted); font-weight: 600; }
.cnode.ghost-ref .ck { text-transform: none; letter-spacing: 0; }
.legend .ghost-key { font-size: 13px; border: 1px dashed var(--muted); border-radius: 3px; padding: 0 3px; margin-left: 10px; line-height: 14px; }
.cnode.dim { opacity: .18; }
/* Boss cards: drops as rows under the header. */
.focus-pick { flex-direction: row; align-items: center; gap: 6px; color: var(--ink); font-size: 13px; }
.focus-pick select { min-width: 200px; }
.legend .dot-key { width: 8px; height: 8px; border-radius: 50%; background: var(--drop-dot); margin-left: 6px; }
.chart-modal { --drop-dot: #8a8880; }
.cnode .row-rule { stroke: var(--line); stroke-width: 1; }
.crow { cursor: pointer; }
.crow .row-hit { fill: transparent; stroke: none; }
.crow:hover .row-hit, .crow.hot .row-hit { fill: var(--ink); fill-opacity: .07; }
.crow .dot { fill: var(--drop-dot); }
.crow .dot.member { fill: none; stroke: var(--drop-dot); stroke-width: 1.5; }
.crow .dot.member.ready { fill: var(--ready); stroke: var(--ready); }
.crow .rt { font-size: 11px; fill: var(--ink); }
.crow.hot .rt, .crow.pin .rt { font-weight: 700; }
.crow.ghost .rt { fill: var(--muted); font-style: italic; }
.crow .prog { fill: var(--progress); stroke: none; opacity: .8; }
.edge { fill: none; stroke: var(--muted); stroke-width: 1.1; opacity: .55; transition: opacity .15s; }
.edge.or { stroke-dasharray: 5 4; }
.edge.dim { opacity: .06; }
.edge.hot { stroke: var(--accent); opacity: 1; stroke-width: 1.6; }

.step-group h4 { margin: 6px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.step-group ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.step-group li { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.step-group .step-row, .step-group ul.leads li { display: flex; flex-direction: row; align-items: center; gap: 8px; }
.step-group ul.leads { padding-left: 14px; gap: 3px; }
.step-group ul.leads .arrow { color: var(--muted); }
.step-group li .tag { min-width: 44px; text-align: center; }
.step-group li .small { margin-left: auto; color: var(--now); }
.bar { width: 56px; height: 6px; background: var(--bar); border-radius: 3px; overflow: hidden; flex: none; }
.bar i { display: block; height: 100%; background: var(--accent); }
.bar.seg { display: flex; gap: 2px; background: none; }
.bar.seg i { flex: 1; background: var(--bar); border-radius: 2px; }
.bar.seg i.held { background: var(--accent); }
.blocked { font-size: 13px; }
.blocked b { color: var(--next); font-weight: 600; }
button.tick { padding: 0 5px; margin-left: 4px; font-size: 11px; line-height: 16px; }
ul.drops li button.ghost { padding: 0 5px; font-size: 11px; line-height: 16px; }
.foot { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 4px; gap: 8px; }
details summary { cursor: pointer; font-size: 12px; color: var(--muted); }
.empty { color: var(--muted); }

/* Search bar: sticks to the top while you scroll the plan. */
.toolbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; margin-top: 16px; padding: 8px 0;
  background: var(--bg);
}
.search { display: flex; align-items: center; gap: 8px; }
.search input {
  flex: 1; font: inherit; color: var(--ink); background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; min-width: 0;
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Unblock first */
.blockers { margin-top: 24px; }
.blockers h2 { font-size: 17px; margin: 0; color: var(--accent); }
.blockers > .small { margin: 2px 0 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px;
  background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px;
}
.chip .small { font-weight: 400; }
.chip.open, .chip:hover { border-color: var(--accent); }
.ready-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--now); flex: none; }
.frees { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: baseline; font-size: 13px; }

/* Compact Next / Later rows */
.section-toggle { display: flex; align-items: baseline; gap: 6px; background: none; border: 0; padding: 0; color: inherit; }
.section-toggle .chev { color: var(--muted); font-size: 13px; width: 12px; }
.rows { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.row-item + .row-item { border-top: 1px solid var(--line); }
.row-main { display: flex; align-items: baseline; gap: 10px; padding: 8px 12px; flex-wrap: wrap; }
.row-main .chev { padding: 0 6px; font-size: 11px; }
.row-name { font-weight: 600; color: var(--ink); text-decoration: none; }
.row-name:hover { text-decoration: underline; }
.row-needs { flex: 1; min-width: 200px; font-size: 13px; color: var(--muted); }
.row-needs b { color: var(--next); font-weight: 600; }
.row-opens { white-space: nowrap; }
.row-unlocks { padding: 0 12px 10px 46px; }
.row-unlocks b { color: var(--ink); font-weight: 600; }
.chev-space { display: inline-block; width: 22px; }

/* Marked done */
.marked { position: relative; display: inline-block; margin-left: 8px; }
.marked > .ghost { font-size: 12px; }
.marked-list {
  position: absolute; z-index: 6; top: calc(100% + 4px); left: 0; min-width: 240px; max-height: 300px; overflow: auto;
  list-style: none; margin: 0; padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .15);
}
.marked-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 4px 6px; font-size: 13px; color: var(--ink); }

/* Bank export help */
.help-toggle { flex-basis: 100%; font-size: 13px; color: var(--muted); }
.help { margin-top: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 18px; }
.help h2 { font-size: 16px; margin: 0 0 6px; }
.help p { margin: 6px 0; }
.help ol { margin: 8px 0; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; }
.help code { font-size: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; word-break: break-all; }
.help li code { display: inline-block; margin: 3px 0; }
