:root {
  --bg: #fafaf7;
  --card: #ffffff;
  --text: #16161a;
  --muted: #5b5b66;
  --border: #e3e3dc;
  --accent: #2f4fd8;
  --accent-ink: #ffffff;
  --accent-soft: #eef1fd;
  --good: #0e7a54;
  --bad: #b4410d;
  --warn-bg: #fff6e0;
  --warn-border: #f1d79a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 20, 30, .05), 0 8px 24px rgba(20, 20, 30, .06);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #171a21;
    --text: #ecedef;
    --muted: #a3a7b1;
    --border: #2a2e37;
    --accent: #7d97ff;
    --accent-ink: #0f1115;
    --accent-soft: #1c2235;
    --good: #4fd19a;
    --bad: #ff8a5c;
    --warn-bg: #2a2416;
    --warn-border: #5a4a22;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--card); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 16px; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

header.site {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-top: 18px; padding-bottom: 18px;
}
.brand { font-weight: 800; letter-spacing: -.01em; color: var(--text); text-decoration: none; font-size: 18px; }
.brand span { color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 18px; border-radius: 999px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 650;
  text-decoration: none; cursor: pointer;
}
.btn:hover { filter: brightness(1.06); }
.btn-small { min-height: 40px; padding: 8px 14px; font-size: 15px; }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-ghost:hover { background: var(--accent-soft); filter: none; }

.intro { padding: 24px 0 8px; max-width: 760px; }
h1 { font-size: clamp(30px, 5vw, 46px); line-height: 1.1; letter-spacing: -.02em; margin: 0 0 14px; }
.lede { font-size: 19px; color: var(--muted); margin: 0 0 10px; }
.meta { font-size: 14px; color: var(--muted); margin: 0; }

.calc {
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 24px;
  align-items: start; margin: 28px 0 56px;
}

.inputs, .results {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px;
}

fieldset { border: 0; margin: 0 0 26px; padding: 0; min-width: 0; }
fieldset:last-child { margin-bottom: 0; }
legend { font-weight: 750; font-size: 18px; margin-bottom: 6px; padding: 0; display: flex; align-items: center; gap: 10px; }
.step {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-size: 14px; font-weight: 800;
}

label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.hint { font-size: 13px; color: var(--muted); margin: 6px 0 0; }
.fineprint { font-size: 12.5px; color: var(--muted); margin: 14px 0 0; }

input[type="number"], input[type="text"], select {
  width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg); color: var(--text); font: inherit; font-variant-numeric: tabular-nums;
}
input:focus, select:focus { border-color: var(--accent); }

.field { margin-top: 16px; }
.prefix { position: relative; }
.prefix .cur { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.prefix input { padding-left: 28px; }

.currency { display: flex; align-items: center; gap: 10px; margin: 10px 0 14px; }
.currency label { margin: 0; }
.currency select { width: auto; min-width: 120px; }

.tools { display: grid; gap: 10px; }
.tool-row {
  display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(0, 1.25fr) minmax(0, .75fr) 44px; gap: 8px; align-items: end;
  padding: 12px; border: 1px solid var(--border); border-radius: 12px;
}
.tool-row label { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool-row .custom-name { grid-column: 1 / -1; }
.remove {
  min-height: 44px; width: 44px; border-radius: 10px; border: 1px solid var(--border); background: transparent;
  color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer;
}
.remove:hover { color: var(--bad); border-color: var(--bad); }

.results { position: sticky; top: 16px; }
.results h2 { margin: 0 0 14px; font-size: 20px; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.kpi-main { grid-column: 1 / -1; background: var(--accent-soft); border-color: transparent; }
.kpi-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 26px; font-weight: 800; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.kpi-main .kpi-value { font-size: 34px; }
.kpi-sub { font-size: 13px; color: var(--muted); }
.good { color: var(--good); }
.bad { color: var(--bad); }

.breakeven { font-size: 14.5px; margin: 14px 0 0; }

.flags { display: grid; gap: 8px; margin-top: 14px; }
.flag { background: var(--warn-bg); border: 1px solid var(--warn-border); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.flag strong { display: block; margin-bottom: 2px; }

.results h3 { font-size: 16px; margin: 18px 0 8px; }
.moves { margin: 0; padding-left: 20px; font-size: 14.5px; }
.moves li { margin-bottom: 8px; }
.moves li::marker { font-weight: 800; color: var(--accent); }

.result-actions { display: flex; gap: 10px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.copied { font-size: 13px; color: var(--good); }

.cta { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
.cta-title { font-weight: 800; font-size: 17px; margin: 0 0 4px; }
.cta-text { font-size: 14px; color: var(--muted); margin: 0 0 12px; }

.content { max-width: 760px; padding-bottom: 40px; }
.content h2 { font-size: 26px; letter-spacing: -.01em; margin: 40px 0 10px; }
.content h3 { font-size: 18px; margin: 24px 0 6px; }
.content p, .content li { color: var(--text); }
.content ol, .content ul { padding-left: 22px; }
.content li { margin-bottom: 6px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--card); }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; min-width: 560px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 650; }
tr:last-child td { border-bottom: 0; }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

.cta-band {
  margin: 40px 0 0; padding: 22px; border-radius: var(--radius); background: var(--accent-soft);
  display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap;
}
.cta-band p { margin: 0; }
.cta-band .cta-title { margin-bottom: 2px; }

footer.site { border-top: 1px solid var(--border); padding: 24px 0 40px; font-size: 14px; color: var(--muted); }
footer.site p { margin: 0 0 6px; }

.scan-label { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.scan-input {
  width: 100%; min-height: 300px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--bg); color: var(--text); font: 14.5px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; resize: vertical;
}
.scan-input:focus { border-color: var(--accent); }

.verdict { border-radius: 12px; padding: 14px 16px; border: 1px solid var(--border); }
.verdict strong { display: block; font-size: 19px; margin-bottom: 4px; }
.verdict p { margin: 0; font-size: 14.5px; }
.verdict.red { background: #fdecec; border-color: #f3b4b4; color: #7a1414; }
.verdict.amber { background: var(--warn-bg); border-color: var(--warn-border); }
.verdict.green { background: #e7f6ee; border-color: #a9dcc0; color: #0b5a3e; }
@media (prefers-color-scheme: dark) {
  .verdict.red { background: #2d1717; border-color: #6b2b2b; color: #ffb4b4; }
  .verdict.green { background: #13261d; border-color: #2a5a43; color: #8fe0b8; }
}

.found { display: grid; gap: 8px; margin-top: 12px; }
.found-row { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: grid; gap: 2px; }
.found-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.found-name { font-weight: 700; font-size: 14.5px; }
.found-example { font-size: 13px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; }
.risk { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.risk-high { background: #fdecec; color: #9b1c1c; }
.risk-medium { background: var(--warn-bg); color: #7a5a00; }
.risk-low { background: var(--accent-soft); color: var(--accent); }
@media (prefers-color-scheme: dark) {
  .risk-high { background: #3a1c1c; color: #ffb4b4; }
  .risk-medium { color: #f1d79a; }
}

.clean {
  white-space: pre-wrap; overflow-wrap: anywhere; max-height: 280px; overflow: auto; margin: 8px 0 0;
  padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg);
  font: 13.5px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.clean mark { background: var(--accent-soft); color: var(--accent); font-weight: 700; border-radius: 4px; padding: 0 2px; }

.answer-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px; margin: 24px 0 8px; max-width: 760px;
}
.answer-card p { margin: 0 0 10px; }
.answer-verdict { font-size: 20px; font-weight: 800; }

.tool-list { padding-left: 22px; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin: 28px 0 40px; }
.tool-card {
  display: flex; flex-direction: column; gap: 6px; padding: 20px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--border); box-shadow: var(--shadow);
  color: var(--text); text-decoration: none;
}
.tool-card:hover { border-color: var(--accent); }
.tool-card-name { font-weight: 800; font-size: 18px; color: var(--accent); }
.tool-card-text { color: var(--muted); font-size: 15px; }

.mobile-sum { display: none; }

.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 880px) {
  .calc { grid-template-columns: 1fr; }
  .results { position: static; scroll-margin-top: 12px; }
  .mobile-sum:not([hidden]) {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 5;
    padding: 12px 16px; border-radius: 14px; background: var(--text); color: var(--bg);
    text-decoration: none; font-size: 15px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
  }
  .mobile-sum .ms-label { opacity: .75; }
  .mobile-sum .ms-link { font-weight: 700; white-space: nowrap; }
  footer.site { padding-bottom: 96px; }
}

@media (max-width: 520px) {
  .inputs, .results { padding: 16px; }
  .tool-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 44px; }
  .tool-row .tool-pick { grid-column: 1 / -1; }
  .kpi-value { font-size: 22px; }
  .kpi-main .kpi-value { font-size: 30px; }
  .lede { font-size: 17px; }
}

.label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.optional { font-weight: 400; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; margin: 0; padding: 9px 14px; min-height: 44px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--bg); font-size: 14.5px; font-weight: 500; cursor: pointer;
}
.chip:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.chip input { accent-color: var(--accent); }
#moves-form input[type="text"] { width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); font: inherit; }
#get-moves { margin-top: 20px; width: 100%; }
#get-moves:disabled { opacity: .6; cursor: progress; }
.note-error { color: var(--bad); font-weight: 600; }
.moves-status { font-size: 14.5px; color: var(--muted); margin: 0 0 12px; }
.move-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.move-card { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.move-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.level { font-size: 12px; font-weight: 750; padding: 3px 10px; border-radius: 999px; }
.level-starter { background: #e7f6ee; color: #0b5a3e; }
.level-getting-good { background: var(--accent-soft); color: var(--accent); }
.level-power-move { background: #fdeee6; color: #9a3412; }
@media (prefers-color-scheme: dark) {
  .level-starter { background: #13261d; color: #8fe0b8; }
  .level-power-move { background: #2d1c12; color: #ffb38a; }
}
.move-minutes { font-size: 13px; color: var(--muted); }
.move-title { font-size: 17px; margin: 8px 0 4px; }
.move-why { margin: 0 0 8px; font-size: 14.5px; color: var(--muted); }
.move-try { margin: 0 0 6px; font-size: 14.5px; }
.move-source { margin: 0; font-size: 13px; }
