/* PoE2 Build Assistant — dark, gold-accented theme */
:root {
  --bg: #0e0e12;
  --bg-2: #15151c;
  --panel: #1b1b24;
  --panel-2: #20202b;
  --border: #2c2c3a;
  --border-soft: #24242f;
  --text: #e8e6e0;
  --muted: #8b8a99;
  --gold: #c8a857;
  --gold-bright: #e6c878;
  --green: #6cc070;
  --green-soft: #8ed98e;
  --red: #e0695a;
  --red-soft: #f0978a;
  --amber: #e0a83a;
  --blue: #6aa6e0;
  --shadow: 0 8px 28px rgba(0,0,0,.45);
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
/* Ensure [hidden] wins over component display rules (e.g. .modal-overlay flex). */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  background:
    radial-gradient(1200px 600px at 80% -10%, #1a1726 0%, transparent 55%),
    radial-gradient(900px 500px at -10% 110%, #14202a 0%, transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  display: flex; flex-direction: column;  /* header / layout / footer rows */
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 14px 22px;
  background: linear-gradient(180deg, rgba(30,28,40,.85), rgba(20,20,28,.6));
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(6px);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { color: var(--gold); font-size: 18px; text-shadow: 0 0 12px rgba(200,168,87,.5); }
.brand-name { font-size: 16px; letter-spacing: .3px; color: #d8d6cf; }
.brand-name b { color: var(--gold-bright); font-weight: 600; }

.build-chip {
  margin-left: 8px; padding: 6px 14px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--border);
  display: flex; flex-direction: column; line-height: 1.2;
}
.chip-name { color: var(--gold-bright); font-weight: 600; font-size: 13px; }
.chip-sub { color: var(--muted); font-size: 11px; }

.stage-select {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; font-size: 12px; font-family: inherit; cursor: pointer; max-width: 240px;
}
.stage-select:hover { border-color: #3a3a4c; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.ai-status { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12.5px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #555; box-shadow: 0 0 0 3px rgba(255,255,255,.03); }
.dot.on { background: var(--green); box-shadow: 0 0 10px rgba(108,192,112,.7); }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
  padding: 9px 16px; border-radius: 9px; cursor: pointer; font-size: 13px;
  transition: all .15s ease; font-family: inherit;
}
.btn:hover { border-color: #3a3a4c; background: #262633; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.sm { padding: 7px 12px; font-size: 12.5px; }
.btn.primary { background: linear-gradient(180deg,#2a3a52,#23314a); border-color: #335; color: #d9e6f5; }
.btn.primary:hover { background: linear-gradient(180deg,#33455f,#2a3a52); }
.btn.accent {
  background: linear-gradient(180deg, var(--gold), #b8923f); color: #1a1407;
  border-color: #8a6e2f; font-weight: 600;
}
.btn.accent:hover { background: linear-gradient(180deg, var(--gold-bright), var(--gold)); }
.btn.ghost { background: transparent; }

/* ---------- Layout ---------- */
.layout {
  display: grid; grid-template-columns: 340px 1fr; gap: 18px;
  padding: 18px 22px; flex: 1 1 auto; min-height: 0; overflow: hidden;
}
.col-left { display: flex; flex-direction: column; gap: 18px; overflow-y: auto; padding-right: 4px; }
.col-main { overflow-y: auto; }

.card {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-title { font-size: 13px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--gold); font-weight: 600; margin-bottom: 12px; }
.card-head .card-title { margin-bottom: 0; }
.muted { color: var(--muted); }
.sm { font-size: 12px; }
.empty-hint { color: var(--muted); font-size: 12.5px; padding: 10px 0; font-style: italic; }

/* ---------- Character stats ---------- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.stat {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; background: var(--panel-2); border: 1px solid var(--border-soft);
  border-radius: 8px;
}
.stat .s-label { color: var(--muted); font-size: 11.5px; }
.stat .s-val { font-weight: 600; font-variant-numeric: tabular-nums; }
.stat.es .s-val { color: var(--blue); }
.stat.res .s-val { color: var(--amber); }
.stat.crit .s-val { color: var(--gold-bright); }

/* ---------- Gear ---------- */
.gear-list { display: flex; flex-direction: column; gap: 7px; }
.gear {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px;
  background: var(--panel-2); border: 1px solid var(--border-soft);
  border-radius: 8px; cursor: default;
}
.gear .g-slot {
  font-size: 10px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); width: 64px; flex-shrink: 0;
}
.gear .g-name { font-size: 12.5px; color: #d6d3ca; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gear.rarity-rare .g-name { color: var(--gold-bright); }
.gear.rarity-unique .g-name { color: #d08a4a; }
.gear.rarity-magic .g-name { color: #8aa0e0; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.tab {
  background: none; border: none; color: var(--muted); cursor: pointer;
  padding: 10px 18px; font-size: 13px; font-family: inherit; letter-spacing: .3px;
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all .15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--gold-bright); border-bottom-color: var(--gold); }

/* ---------- Data bar / sync / credit ---------- */
.data-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; padding: 8px 12px; background: var(--panel-2); border: 1px solid var(--border-soft); border-radius: 9px; }
.data-info { font-size: 12px; color: var(--muted); }
.data-info b { color: #c8b88a; font-weight: 600; }
.data-info .stale { color: var(--amber); }
.credit { margin-top: 16px; padding: 10px 2px; font-size: 11px; color: #6b6a78; text-align: center; line-height: 1.5; }
.bd-mod .m-tag.unknown { background: rgba(224,168,58,.14); color: var(--amber); }
.bd-mod .m-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.m-roll { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-variant-numeric: tabular-nums; min-width: 130px; }
.m-tier { font-size: 10px; color: var(--muted); font-weight: 600; letter-spacing: .3px; }
.m-range { font-size: 10.5px; color: #9a9aa8; font-variant-numeric: tabular-nums; }
.m-grade {
  display: inline-flex; align-items: center; justify-content: center;
  width: 17px; height: 17px; border-radius: 4px; font-weight: 800; font-size: 11px;
  border: 1px solid transparent;
}
.m-grade.g-S { background: linear-gradient(180deg,#e6c878,#caa34a); color: #2a1f06; border-color: #e6c878; box-shadow: 0 0 8px rgba(230,200,120,.45); }
.m-grade.g-A { background: rgba(108,192,112,.22); color: #8ed98e; border-color: rgba(108,192,112,.5); }
.m-grade.g-B { background: rgba(166,200,106,.20); color: #b8d98e; border-color: rgba(166,200,106,.45); }
.m-grade.g-C { background: rgba(224,168,58,.18); color: var(--amber); border-color: rgba(224,168,58,.45); }
.m-grade.g-D { background: rgba(224,140,90,.18); color: #e0a06a; border-color: rgba(224,140,90,.4); }
.m-grade.g-F { background: rgba(224,105,90,.20); color: var(--red-soft); border-color: rgba(224,105,90,.45); }
.rq-bar { width: 38px; height: 5px; border-radius: 3px; background: #2a2a36; overflow: hidden; }
.rq-fill { display: block; height: 100%; border-radius: 3px; }
.m-roll.excellent { color: #7ed07e; } .m-roll.excellent .rq-fill { background: #6cc070; }
.m-roll.good { color: #b8d98e; } .m-roll.good .rq-fill { background: #a6c86a; }
.m-roll.average { color: var(--amber); } .m-roll.average .rq-fill { background: var(--amber); }
.m-roll.low { color: var(--red-soft); } .m-roll.low .rq-fill { background: var(--red); }
.m-src {
  font-size: 9px; text-transform: uppercase; letter-spacing: .4px; font-weight: 600;
  padding: 1px 6px; border-radius: 4px; margin-right: 8px; vertical-align: 1px;
}
.m-src.rune { background: rgba(106,166,224,.18); color: #8fb8e8; }
.m-src.enchant { background: rgba(200,168,87,.18); color: var(--gold-bright); }
.m-src.desecrated { background: rgba(160,90,200,.20); color: #c08ad8; }
.m-src.crafted { background: rgba(108,192,112,.16); color: var(--green-soft); }

/* ---------- Build Breakdown ---------- */
.bd-totals { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.bd-chip {
  display: flex; align-items: baseline; gap: 7px; padding: 7px 12px; border-radius: 8px;
  background: var(--panel-2); border: 1px solid var(--border-soft);
}
.bd-chip.prio { border-color: rgba(200,168,87,.4); background: rgba(200,168,87,.08); }
.bd-chip .c-val { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--gold-bright); }
.bd-chip .c-label { font-size: 12px; color: var(--muted); }
.bd-chip.prio .c-label { color: #d6cfb8; }

.bd-section-label { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin: 12px 0 7px; }
.bd-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.bd-pill { padding: 4px 10px; border-radius: 999px; font-size: 12px; background: var(--panel-2); border: 1px solid var(--border-soft); color: #cfc7b3; }
.bd-pill.key { border-color: rgba(208,138,74,.5); color: #e0a86a; }
.bd-note { margin-top: 10px; padding: 11px 13px; border-radius: 8px; background: rgba(106,166,224,.06); border: 1px solid rgba(106,166,224,.25); color: #bcd; font-size: 12.5px; }

/* breakdown item cards */
.bd-item { background: var(--panel-2); border: 1px solid var(--border-soft); border-radius: 9px; margin-bottom: 8px; overflow: hidden; }
.bd-item-head { display: flex; align-items: center; gap: 10px; padding: 11px 13px; cursor: pointer; user-select: none; }
.bd-item-head:hover { background: #262633; }
.bd-item-head .g-slot { font-size: 10px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); width: 70px; flex-shrink: 0; }
.bd-item-head .bd-name { font-size: 13px; color: #d6d3ca; flex: 1; }
.bd-item-head.rarity-rare .bd-name { color: var(--gold-bright); }
.bd-item-head.rarity-unique .bd-name { color: #d08a4a; }
.bd-item-head .bd-served { font-size: 11px; color: var(--green-soft); }
.bd-item-head .caret { color: var(--muted); transition: transform .15s; }
.bd-item.open .caret { transform: rotate(90deg); }
.bd-item-body { padding: 4px 13px 12px; border-top: 1px solid var(--border-soft); }
.bd-base { font-size: 11.5px; color: var(--muted); margin: 8px 0; line-height: 1.5; }
.bd-base b { color: #c8b88a; font-weight: 600; }
.bd-mod { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 0; font-size: 12.5px; border-bottom: 1px solid rgba(255,255,255,.03); }
.bd-mod .m-text { color: #c4c1b8; }
.bd-mod.serves .m-text { color: #e6e3d8; }
.bd-mod .m-tag { font-size: 10.5px; padding: 2px 8px; border-radius: 999px; white-space: nowrap; background: #2a2a36; color: var(--muted); }
.bd-mod.serves .m-tag { background: rgba(200,168,87,.16); color: var(--gold-bright); }

/* ---------- Analysis input ---------- */
.item-input {
  width: 100%; min-height: 130px; resize: vertical;
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 9px; padding: 12px 14px; font-family: "Consolas", monospace;
  font-size: 12.5px; line-height: 1.5;
}
.item-input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(200,168,87,.12); }
.seg { display: flex; gap: 8px; }

/* ---------- Result ---------- */
.result { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 16px; }
.result-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; }
.result-item { font-size: 15px; color: var(--gold-bright); font-weight: 600; margin-bottom: 4px; }
.verdict { font-size: 22px; font-weight: 700; }
.verdict.upgrade { color: var(--green-soft); }
.verdict.sidegrade { color: var(--amber); }
.verdict.downgrade { color: var(--red-soft); }
.score-badge {
  font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums;
  padding: 8px 16px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--border);
}
.score-badge.pos { color: var(--green-soft); border-color: rgba(108,192,112,.4); }
.score-badge.neg { color: var(--red-soft); border-color: rgba(224,105,90,.4); }

.proscons { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.proscons h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.pros h3 { color: var(--green); }
.cons h3 { color: var(--red); }
.proscons ul { list-style: none; display: flex; flex-direction: column; gap: 5px; }
.proscons li {
  font-size: 12.5px; padding: 6px 10px; border-radius: 7px;
  background: var(--panel-2); display: flex; justify-content: space-between; gap: 8px;
  font-variant-numeric: tabular-nums;
}
.pros li { border-left: 2px solid var(--green); }
.cons li { border-left: 2px solid var(--red); }
.proscons li .li-val { color: var(--text); font-weight: 600; }
.pros li .li-val { color: var(--green-soft); }
.cons li .li-val { color: var(--red-soft); }

/* PoB-verified upgrade panel (real DPS/EHP diff) */
.pob-verify { margin-top: 12px; padding: 12px 14px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--border); }
.pob-verdict { font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.pob-verdict.upgrade { color: var(--green-soft); }
.pob-verdict.sidegrade { color: var(--amber); }
.pob-verdict.tradeoff { color: var(--amber); }
.pob-verdict.downgrade { color: var(--red-soft); }
.pob-rows { list-style: none; display: flex; flex-direction: column; gap: 5px; }
.pob-rows li { font-size: 12.5px; padding: 6px 10px; border-radius: 7px;
  background: var(--panel); display: flex; justify-content: space-between; gap: 8px;
  font-variant-numeric: tabular-nums; }
.pob-rows .li-val.pos { color: var(--green-soft); }
.pob-rows .li-val.neg { color: var(--red-soft); }
.pob-rows .li-val.muted { color: var(--muted); }
.pob-rows .li-val em { font-style: normal; opacity: .8; }

.recommend {
  margin-top: 16px; padding: 12px 14px; border-radius: 9px;
  background: rgba(200,168,87,.06); border: 1px solid rgba(200,168,87,.22);
  color: #ddd6c4; font-size: 13px; line-height: 1.5;
}

/* ---------- AI block ---------- */
.ai-block { margin-top: 16px; }
.ai-output {
  margin-top: 12px; padding: 14px 16px; border-radius: 9px;
  background: var(--bg-2); border: 1px solid var(--border);
  font-size: 13px; line-height: 1.6; white-space: pre-wrap; color: #d8d6cf;
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(5,5,8,.6);
  display: flex; align-items: center; justify-content: center; z-index: 50;
  backdrop-filter: blur(3px);
}
.modal {
  position: relative; width: 440px; max-width: 92vw;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--border); border-radius: 14px; padding: 26px 26px 20px;
  box-shadow: var(--shadow);
}
/* Site footer — license/attribution disclaimer (MIT notices + GGG fan-tool stance) */
.site-foot {
  flex: none; width: 100%; padding: 8px 22px;
  border-top: 1px solid var(--border); background: rgba(0,0,0,.15);
  display: flex; flex-wrap: wrap; gap: 2px 16px;
  align-items: baseline; font-size: 10.5px; line-height: 1.5; color: var(--muted);
}
.site-foot a { color: var(--muted); text-decoration: underline; }
.site-foot a:hover { color: var(--text); }
.site-foot b { color: #b9b6ad; font-weight: 600; }

.modal h2 { color: var(--gold-bright); font-size: 18px; margin-bottom: 6px; }
/* "Best accuracy" callout in the import modal — promotes PoB code / pobb.in links */
.import-best {
  margin-top: 10px; padding: 11px 13px; border-radius: 10px;
  background: rgba(108,192,112,.08); border: 1px solid rgba(108,192,112,.35);
  display: flex; gap: 11px; align-items: flex-start;
}
.best-badge {
  flex: none; font-size: 10.5px; font-weight: 700; letter-spacing: .4px; white-space: nowrap;
  text-transform: uppercase; color: #0e1a10; background: var(--green-soft);
  padding: 3px 8px; border-radius: 6px; margin-top: 1px;
}
.best-body { font-size: 12.5px; line-height: 1.5; color: #cfe6cf; }
.best-body b { color: var(--green-soft); font-weight: 700; }
.import-fallback { margin-top: 10px; opacity: .8; line-height: 1.5; }
.modal-close {
  position: absolute; top: 14px; right: 16px; background: none; border: none;
  color: var(--muted); font-size: 22px; cursor: pointer; line-height: 1;
}
.modal-close:hover { color: var(--text); }
.connect-option { margin-top: 16px; }
.connect-option h3 { font-size: 14px; margin-bottom: 4px; color: #d6d3ca; }
.connect-option p { margin-bottom: 10px; }
.key-row { display: flex; gap: 8px; }
.key-row input {
  flex: 1; background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 12px; color: var(--text); font-family: "Consolas", monospace; font-size: 12.5px;
}
.key-row input:focus { outline: none; border-color: var(--gold); }
.divider { display: flex; align-items: center; gap: 12px; margin: 20px 0 4px; color: var(--muted); font-size: 11px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.modal-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 20px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  padding: 11px 18px; border-radius: 10px; box-shadow: var(--shadow); z-index: 60;
  font-size: 13px; max-width: 60vw;
}
.toast.err { border-color: rgba(224,105,90,.5); color: var(--red-soft); }
.toast.ok { border-color: rgba(108,192,112,.5); }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2a2a38; border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #353548; }
::-webkit-scrollbar-track { background: transparent; }

.spin { display: inline-block; width: 13px; height: 13px; border: 2px solid rgba(255,255,255,.25);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
