@keyframes ecHeroRise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes ecBookFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes ecGlint { from { background-position: 160% 0; } to { background-position: -60% 0; } }
@keyframes ecTreeIn { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }
@keyframes ecResultGlow {
  0%, 100% { filter: drop-shadow(0 0 6px rgba(167, 139, 250, .7)); }
  50% { filter: drop-shadow(0 0 18px rgba(167, 139, 250, 1)); }
}

:root {
  --xp: #7efc20;
  --xp-glow: rgba(126, 252, 32, .4);
  --frame: rgba(167, 139, 250, .14);
}

/* ---------- hero ---------- */
.ec-hero {
  text-align: center;
  padding: clamp(28px, 5vw, 52px) var(--gutter) clamp(18px, 3vw, 28px);
  background:
    radial-gradient(ellipse 70% 120% at 50% 0%, rgba(167, 139, 250, .1), transparent 70%),
    linear-gradient(#0d0f33, var(--bg));
}
.ec-hero > div { animation: ecHeroRise .7s ease-out both; }
.ec-hero h1 { font-size: clamp(25px, 4.6vw, 44px); font-weight: 900; letter-spacing: -.02em; line-height: 1.1; }
.ec-hero p { margin: 14px auto 0; max-width: 640px; font-size: 14px; line-height: 1.65; color: var(--muted); }
.ec-hero strong { color: var(--ink-2); }
.ec-hero-book {
  width: 42px; height: 42px; vertical-align: -8px; margin-right: 12px;
  filter: drop-shadow(0 0 16px rgba(167, 139, 250, .6));
  animation: ecBookFloat 3.2s ease-in-out infinite;
}

/* ---------- glint (enchanted item shimmer, masked to the sprite) ---------- */
.glint { position: relative; display: inline-block; line-height: 0; flex-shrink: 0; }
.glint img { width: 100%; height: 100%; }
.glint::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgba(196, 181, 253, .85) 47%, rgba(167, 139, 250, .4) 53%, transparent 65%) 0 0 / 250% 100% no-repeat;
  -webkit-mask: var(--src) center / 100% 100% no-repeat; mask: var(--src) center / 100% 100% no-repeat;
  mix-blend-mode: screen; animation: ecGlint 3.4s linear infinite;
}

/* ---------- tool frame ---------- */
.ec-tool { border-top: 1px solid rgba(167, 139, 250, .12); }
.ec-toolbar, .ec-grid, .ec-bar { max-width: var(--wrap); margin: 0 auto; }
.ec-toolbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px;
  padding: 10px 22px; border: 1px solid var(--frame); border-top: 0;
}
.ec-opt { display: flex; align-items: center; gap: 10px; }
.ec-opt .k, .ec-uses label, .ec-tree-head .ec-legend {
  font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--faint);
}
.ec-opt .seg button { padding: 7px 12px; min-height: 32px; font-size: 10.5px; }
.ec-toolbar-end { margin-left: auto; display: flex; gap: 6px; }
.btn.ec-small { min-height: 32px; padding: 7px 12px; font-size: 10.5px; }

.ec-grid {
  display: grid; grid-template-columns: minmax(340px, 440px) minmax(0, 1fr);
  border-left: 1px solid var(--frame); border-right: 1px solid var(--frame);
}
.ec-left { border-right: 1px solid var(--frame); min-width: 0; }
.ec-block { padding: 18px 22px 20px; }
.ec-block + .ec-block { border-top: 1px solid rgba(167, 139, 250, .12); }
.ec-block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.ec-block-head h2 { font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.ec-picked { font-size: 12.5px; font-weight: 700; color: var(--ink); }
.ec-count { font: 11px var(--mono); color: var(--faint); }
.ec-hint { margin: 0 0 12px; font-size: 12px; color: var(--faint); line-height: 1.5; }

.ec-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 4px; }
.ec-item {
  height: 46px; display: flex; align-items: center; justify-content: center; padding: 0;
  background: var(--bg); border: 1px solid rgba(167, 139, 250, .1); cursor: pointer;
  transition: border-color .15s, background .15s;
}
.ec-item:hover { background: #11143a; border-color: var(--line-2); }
.ec-item[aria-checked="true"] { background: rgba(167, 139, 250, .14); border-color: var(--accent); box-shadow: inset 0 0 14px rgba(167, 139, 250, .25); }
.ec-item img, .ec-item .glint { width: 30px; height: 30px; }
.ec-uses { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; }
.ec-uses .select { min-height: 34px; padding-top: 7px; padding-bottom: 7px; }
.ec-uses[hidden] { display: none; }

.ec-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.ec-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 5px 9px; min-height: 30px;
  font: 700 11.5px/1.2 var(--sans); color: var(--ink-2); background: var(--bg);
  border: 1px solid var(--line); cursor: pointer; transition: border-color .15s, background .15s, color .15s;
}
.ec-chip:hover:not(:disabled) { border-color: var(--accent); color: var(--ink); }
.ec-chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.ec-chip:disabled { text-decoration: line-through; opacity: .4; cursor: not-allowed; }
.ec-chip.curse:not([aria-pressed="true"]) { color: #fca5a5; }
.ec-chip .tr { width: 5px; height: 5px; background: var(--amber); transform: rotate(45deg); flex-shrink: 0; }
.ec-chip[aria-pressed="true"] .tr { background: var(--accent-ink); }
.ec-chips .none { font-size: 12px; color: var(--faint); }
.ec-quick { display: flex; gap: 6px; margin-top: 12px; }

.ec-picks { margin-top: 14px; display: flex; flex-direction: column; gap: 4px; }
.ec-pick {
  display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 8px;
  background: var(--bg); border: 1px solid rgba(167, 139, 250, .12);
}
.ec-pick .glint { width: 18px; height: 18px; }
.ec-pick .nm { flex: 1; min-width: 0; font-size: 12.5px; font-weight: 700; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ec-pick .nm small { font: 400 10.5px var(--mono); color: var(--faint); margin-left: 6px; }
.ec-lvls { display: flex; gap: 2px; }
.ec-lvl {
  min-width: 28px; height: 26px; padding: 0 4px; font: 700 11px var(--mono);
  color: var(--faint); background: transparent; border: 1px solid rgba(167, 139, 250, .14); cursor: pointer;
}
.ec-lvl:hover { color: var(--ink); border-color: var(--accent); }
.ec-lvl[aria-pressed="true"] { color: var(--ink); border-color: var(--accent); background: rgba(167, 139, 250, .16); }
.ec-rm {
  width: 26px; height: 26px; font: 700 14px/1 var(--mono); color: var(--faint);
  background: transparent; border: 1px solid transparent; cursor: pointer;
}
.ec-rm:hover { color: var(--red); border-color: rgba(248, 113, 113, .35); }

/* right column: tree + steps */
.ec-right {
  position: relative; min-width: 0; display: flex; flex-direction: column;
  background: radial-gradient(ellipse at 50% 26%, rgba(76, 29, 149, .32) 0%, rgba(6, 7, 26, 0) 62%), #070820;
}
.ec-tree-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 18px 22px 0; }
.ec-tree-head h2 { font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.ec-legend { display: inline-flex; align-items: center; gap: 6px; }
.ec-legend i { display: inline-block; width: 14px; height: 2px; margin-left: 6px; }
.ec-legend .lg-l { background: var(--accent-2); }
.ec-legend .lg-r { background: repeating-linear-gradient(90deg, var(--accent) 0 4px, transparent 4px 7px); }
.ec-tree { flex: 1; min-height: 240px; display: flex; align-items: center; justify-content: safe center; overflow-x: auto; padding: 14px 18px 10px; }
.ec-tree svg { display: block; flex-shrink: 0; overflow: visible; }
.ec-tree svg text { font-family: var(--sans); }
.ec-tree .mono { font-family: var(--mono); }
.ec-tree .n { animation: ecTreeIn .45s ease-out both; }
.ec-tree .res-icon { animation: ecResultGlow 2.6s ease-in-out infinite; }
.ec-tree .empty { text-align: center; color: var(--faint); font-size: 13px; max-width: 320px; }
.ec-tree .empty img { width: 48px; height: 48px; opacity: .35; display: block; margin: 0 auto 10px; }

.ec-steps { list-style: none; margin: 0; padding: 4px 22px 18px; display: flex; flex-direction: column; gap: 4px; }
.ec-steps:empty { display: none; }
.ec-step {
  display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 6px 12px; align-items: center;
  padding: 8px 12px 10px 8px; background: rgba(6, 7, 26, .7); border: 1px solid rgba(167, 139, 250, .1);
}
.ec-step .num {
  width: 26px; height: 26px; display: flex; align-items: center; justify-content: center;
  font: 700 12px var(--mono); color: var(--accent-ink); background: var(--accent);
}
.ec-step .kind { font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
.ec-step .cost { text-align: right; font: 700 15px/1.2 var(--mono); color: var(--xp); white-space: nowrap; }
.ec-step .cost.hot { color: var(--amber); }
.ec-step .cost small { display: block; font: 400 10px var(--mono); color: var(--faint); }
.ec-step .ops { grid-column: 2 / -1; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.ec-step .op { display: flex; align-items: flex-start; gap: 8px; min-width: 0; font-size: 12.5px; color: var(--ink); line-height: 18px; }
.ec-step .op img, .ec-step .op .glint { width: 18px; height: 18px; }
.ec-step .op > span:last-child { min-width: 0; }
.ec-step .op small { display: block; font: 10.5px/1.5 var(--mono); color: var(--faint); }
.ec-step .side {
  flex-shrink: 0; width: 42px; text-align: center; padding: 1px 0; margin-top: 1px;
  font: 700 9px/14px var(--sans); letter-spacing: .1em; text-transform: uppercase;
}
.ec-step .side.l { color: var(--accent-2); border: 1px solid rgba(196, 181, 253, .45); }
.ec-step .side.r { color: var(--accent); border: 1px dashed rgba(167, 139, 250, .55); }

/* bottom bar */
.ec-bar {
  position: relative; z-index: 2;
  background: var(--bg-2); border: 1px solid rgba(167, 139, 250, .22);
  padding: 12px 24px; display: flex; align-items: center; gap: 12px 18px; flex-wrap: wrap;
}
.ec-bar .k { font-size: 10px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--faint); }
.ec-total { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.ec-total img { width: 22px; height: 22px; }
.ec-total .row { display: flex; align-items: baseline; gap: 8px; }
.ec-total .big { font: 700 24px/1 var(--mono); color: var(--xp); text-shadow: 0 0 14px var(--xp-glow); }
.ec-total .big.bad { color: var(--red); text-shadow: none; }
.ec-total .sub { font: 10.5px var(--mono); color: var(--faint); }
.ec-divider { width: 1px; align-self: stretch; background: rgba(167, 139, 250, .15); flex-shrink: 0; }
.ec-maxstep { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 220px; }
.ec-maxstep .row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.ec-maxstep .v { font: 700 12px var(--mono); color: var(--ink-2); }
.ec-maxstep .v span { color: var(--faint); font-weight: 400; }
.ec-meter { position: relative; height: 12px; background: var(--bg); border: 1px solid var(--line-2); }
.ec-meter i { position: absolute; top: 0; bottom: 0; left: 0; width: 0; background: var(--ok); transition: width .35s ease, background .35s; }
.ec-meter i.mid { background: var(--amber); }
.ec-meter i.bad { background: var(--red); }
.ec-meter b { position: absolute; top: -3px; bottom: -3px; left: 86.67%; width: 2px; background: var(--red); }
.ec-verdict { flex: 1.2; min-width: 220px; font-size: 12px; line-height: 1.55; color: var(--muted); }
.ec-verdict strong { color: var(--ink); }
.ec-verdict .ok { color: var(--ok); }
.ec-verdict .mid { color: var(--amber); }
.ec-verdict .bad { color: var(--red); }
.ec-bar-note { flex-basis: 100%; margin: 0; border-top: 1px solid rgba(167, 139, 250, .12); padding-top: 10px; font-size: 11.5px; line-height: 1.55; color: var(--faint); }

@media (max-width: 900px) {
  .ec-grid { grid-template-columns: 1fr; }
  .ec-left { border-right: 0; border-bottom: 1px solid var(--frame); }
}
@media (max-width: 640px) {
  .ec-toolbar { padding: 10px var(--gutter); }
  .ec-block { padding-left: var(--gutter); padding-right: var(--gutter); }
  .ec-tree-head, .ec-steps { padding-left: var(--gutter); padding-right: var(--gutter); }
  .ec-bar { padding: 12px var(--gutter); }
  .ec-divider { display: none; }
  .ec-maxstep, .ec-verdict { flex-basis: 100%; min-width: 0; }
  .ec-toolbar-end { margin-left: 0; }
}

/* ---------- enchanting table ---------- */
.ec-section { padding-top: 48px; padding-bottom: 56px; }
.ec-section > h2 { margin-bottom: 18px; }
.ec-table-grid { display: grid; grid-template-columns: minmax(0, 1fr) 430px; gap: 28px; align-items: start; }
.ec-prose { font-size: 14px; line-height: 1.75; display: flex; flex-direction: column; gap: 14px; }
.ec-prose p { margin: 0; }
.ec-prose strong { color: var(--ink); }
.ec-shelf { padding: 22px; }
.ec-ring { display: grid; grid-template-columns: repeat(5, 30px); gap: 3px; justify-content: center; margin-bottom: 14px; }
.ec-ring span { width: 30px; height: 30px; display: block; }
.ec-ring img { width: 30px; height: 30px; display: block; transition: opacity .15s, filter .15s; }
.ec-ring .off img { opacity: .14; filter: grayscale(1); }
.ec-ring .air { background: rgba(167, 139, 250, .03); border: 1px dashed rgba(167, 139, 250, .1); }
.ec-ring .door { border: 1px dashed rgba(167, 139, 250, .22); }
.ec-ring .tbl img { filter: drop-shadow(0 0 10px rgba(167, 139, 250, .7)); }
.ec-shelf-label { display: block; text-align: center; font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); margin-bottom: 6px; }
.ec-shelf-label span { color: var(--accent); font-family: var(--mono); }
#ec-shelves { width: 100%; accent-color: var(--accent); cursor: pointer; }
.ec-slots { margin-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.ec-slot .row { display: flex; justify-content: space-between; gap: 10px; font-size: 11.5px; margin-bottom: 5px; }
.ec-slot .lbl { display: inline-flex; align-items: center; gap: 6px; color: var(--faint); white-space: nowrap; }
.ec-slot .lbl img { width: 13px; height: 13px; }
.ec-slot .rng { font-family: var(--mono); color: var(--ink-2); text-align: right; }
.ec-slot .rng em { font-style: normal; color: var(--amber); }
.ec-strip { display: grid; grid-template-columns: repeat(30, 1fr); gap: 1px; height: 10px; background: rgba(255, 255, 255, .03); border: 1px solid rgba(167, 139, 250, .14); }
.ec-strip i { display: block; background: var(--accent); opacity: 0; transition: opacity .25s; }
.ec-scale { display: flex; justify-content: space-between; font: 9.5px var(--mono); color: var(--faint); margin-top: 3px; }
.ec-fine { margin: 14px 0 0; font-size: 11px; color: var(--faint); line-height: 1.6; }
@media (max-width: 900px) {
  .ec-table-grid { grid-template-columns: 1fr; }
}

/* ---------- reference ---------- */
.ec-ref-band { background: #080a22; border-top: 1px solid rgba(167, 139, 250, .12); border-bottom: 1px solid rgba(167, 139, 250, .12); }
.ec-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.ec-search {
  width: 100%; background: var(--bg-2); border: 1px solid var(--line); color: var(--ink);
  padding: 13px 16px; font: 14px var(--sans); outline: none; border-radius: 0;
}
.ec-search::placeholder { color: var(--faint); }
.ec-search:focus { border-color: var(--accent); }
.ec-search:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.ec-filters { display: flex; flex-wrap: wrap; gap: 5px; margin: 12px 0 10px; }
.ec-filter {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; min-height: 32px;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--muted);
  font: 700 11px var(--sans); letter-spacing: .04em; text-transform: uppercase; cursor: pointer;
}
.ec-filter:hover { border-color: var(--line-2); color: var(--ink); }
.ec-filter[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.ec-filter img { width: 14px; height: 14px; }
.ec-shown { margin: 0 0 14px; font: 11px var(--mono); color: var(--faint); }
.ec-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 12px; }
.ec-card { background: var(--bg-2); border: 1px solid var(--line); padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.ec-card header { display: flex; align-items: center; gap: 12px; }
.ec-card header .glint { width: 32px; height: 32px; }
.ec-card h3 { font-size: 15.5px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.ec-card h3 .max { font: 700 12px var(--mono); color: var(--accent); }
.ec-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.ec-badge { font: 700 9.5px var(--sans); letter-spacing: .1em; text-transform: uppercase; padding: 2px 6px; border: 1px solid var(--line-2); color: var(--accent-2); }
.ec-badge.tr { border-color: rgba(251, 191, 36, .4); color: var(--amber); }
.ec-badge.cu { border-color: rgba(248, 113, 113, .4); color: var(--red); }
.ec-card .desc { margin: 0; font-size: 13px; line-height: 1.6; color: var(--ink-2); }
.ec-meta { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; margin: 0; font-size: 12px; }
.ec-meta dt { color: var(--faint); }
.ec-meta dd { margin: 0; color: var(--ink-2); }
.ec-meta dd.mono { font-size: 11.5px; }
.ec-on { display: flex; flex-wrap: wrap; gap: 3px; margin-top: auto; padding-top: 4px; border-top: 1px solid rgba(167, 139, 250, .08); }
.ec-on span { width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; background: var(--bg); border: 1px solid rgba(167, 139, 250, .1); }
.ec-on span.anvil { border-style: dashed; border-color: rgba(251, 191, 36, .35); }
.ec-on img { width: 18px; height: 18px; }
.ec-card .note { margin: 0; font-size: 11px; color: var(--faint); }
.ec-card .note b { color: var(--amber); font-weight: 700; }
.ec-cards .none { color: var(--faint); font-size: 13px; }

/* ---------- article ---------- */
.ec-article { max-width: 880px; margin: 0 auto; padding: 64px var(--gutter) 24px; }
.ec-article h2 { margin: 0 0 16px; }
.ec-article h2 ~ h2 { margin-top: 48px; }
.ec-article p { margin: 0 0 16px; line-height: 1.75; font-size: 14.5px; }
.ec-article strong { color: var(--ink); }
.ec-formula { margin: 0 0 24px; border-left: 3px solid var(--accent); background: var(--bg-2); padding: 18px 22px; color: var(--ink-2); line-height: 1.75; font-size: 14.5px; }
.ec-ptable { border: 1px solid var(--line); overflow-x: auto; margin-bottom: 24px; }
.ec-ptable > div { display: grid; grid-template-columns: 170px repeat(7, minmax(44px, 1fr)); min-width: 520px; font: 12px var(--mono); }
.ec-ptable > div + div span { border-top: 1px solid rgba(167, 139, 250, .1); }
.ec-ptable span { padding: 10px 8px; text-align: center; color: var(--ink); }
.ec-ptable > div:first-child span { background: var(--bg-3); }
.ec-ptable span[role="rowheader"] { text-align: left; padding-left: 14px; font: 700 10.5px var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.ec-ptable > div + div span[role="rowheader"] { font: 12.5px var(--sans); letter-spacing: 0; text-transform: none; color: var(--muted); }
.ec-ptable .ok { color: var(--ok); }
.ec-ptable .mid { color: var(--amber); }
.ec-ptable .bad { color: var(--red); }
.ec-mtable { border: 1px solid var(--line); margin-bottom: 24px; display: grid; grid-template-columns: 76px 76px minmax(0, 1fr); font-size: 12.5px; }
.ec-mtable span { padding: 10px 14px; border-top: 1px solid rgba(167, 139, 250, .1); }
.ec-mtable .th { background: var(--bg-3); border-top: 0; color: var(--accent); font-weight: 700; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; }
.ec-mtable .x { font-family: var(--mono); color: var(--ink); }
.ec-mtable .names { color: var(--muted); line-height: 1.6; }
.ec-tips { margin: 0; padding: 0; list-style: none; counter-reset: t; display: flex; flex-direction: column; gap: 12px; }
.ec-tips li { counter-increment: t; line-height: 1.75; font-size: 14.5px; }
.ec-tips li::before { content: counter(t) ". "; color: var(--accent); font-weight: 800; }
.ec-faq { display: flex; flex-direction: column; gap: 24px; }
.ec-faq h3 { margin: 0 0 8px; font-size: 16px; font-weight: 700; }
.ec-faq p { margin: 0; }
@media (max-width: 560px) {
  .ec-mtable { grid-template-columns: 56px 56px minmax(0, 1fr); }
  .ec-mtable span { padding: 9px 10px; }
}

/* arriving at the calculator: it slides in over the previous page from the right */
::view-transition-old(root) { animation: vt-to-left-dim .45s cubic-bezier(.2, .8, .25, 1) both; }
::view-transition-new(root) { animation: vt-from-right .45s cubic-bezier(.2, .8, .25, 1) both; box-shadow: -16px 0 48px rgba(0, 0, 0, .55); }
