:root {
  --bg: #12150f;
  --panel: #1b2017;
  --panel-2: #232a1e;
  --line: #333c2b;
  --text: #e7eadf;
  --muted: #98a08a;
  --amber: #f2b33d;
  --amber-ink: #1a1405;
  --green: #7fc06a;
  --red: #ef6b5a;
  --blue: #6fb3e0;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { padding-bottom: env(safe-area-inset-bottom); }
button, input, select { font: inherit; color: inherit; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.brand { letter-spacing: .12em; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.brand b { color: var(--amber); font-weight: 700; }
.dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--amber); display: inline-block; }
.top select { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }

.tabs { display: flex; gap: 4px; padding: 8px 16px 0; max-width: 760px; margin: 0 auto; }
.tabs button {
  flex: 1; padding: 10px 0; background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--muted); font-weight: 600; letter-spacing: .05em; cursor: pointer;
}
.tabs button[aria-selected="true"] { color: var(--amber); border-color: var(--amber); }

main { max-width: 760px; margin: 0 auto; padding: 12px 16px 40px; }
.tab { display: grid; gap: 12px; }
.tab[hidden] { display: none; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card h2 { margin: 0 0 8px; font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 13px; }
.msg { min-height: 1.2em; margin: 6px 0 0; font-size: 14px; color: var(--muted); }
.msg.bad { color: var(--red); }
.msg.good { color: var(--green); }

.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.row > input { flex: 1 1 160px; min-width: 0; }
input, select {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; min-height: 44px;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }
.paste label { font-weight: 600; }
.paste input { font-size: 18px; }

button { cursor: pointer; border-radius: 8px; min-height: 44px; padding: 0 14px; border: 1px solid var(--line); background: var(--panel-2); }
button.primary { background: var(--amber); color: var(--amber-ink); border-color: var(--amber); font-weight: 700; }
button.primary .muted { color: #5b4510; font-size: 12px; }
button.ghost { background: transparent; }
button.link { background: none; border: 0; min-height: 0; padding: 4px 0; color: var(--amber); font-size: 13px; }
button.wide { width: 100%; margin-top: 8px; }

.xy { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.xy label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.xy input { font-size: 18px; width: 100%; }

.targets, .spots, .checks, .tips { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.targets li {
  display: grid; grid-template-columns: auto 1fr 1fr 1fr auto; gap: 6px; align-items: center;
  padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2);
}
.targets li.sel { border-color: var(--amber); box-shadow: inset 3px 0 0 var(--amber); }
.targets .tag { font-weight: 800; color: var(--amber); width: 34px; text-align: center; cursor: pointer; background: none; border: 0; padding: 0; }
.targets input { min-height: 38px; padding: 6px 8px; width: 100%; }
.targets .sum { grid-column: 2 / -1; font-size: 13px; color: var(--muted); }
.targets .del { min-height: 38px; padding: 0 10px; background: none; color: var(--muted); }
.targets .h { font-size: 12px; color: var(--muted); display: grid; gap: 2px; }

.solution { border-color: #4a4022; background: linear-gradient(180deg, #221f14, var(--panel)); }
.sol-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 700; }
.badge { font-size: 11px; letter-spacing: .08em; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.ok { color: var(--green); border-color: #3e5a33; }
.badge.warn { color: var(--amber); border-color: #6a5420; }
.badge.bad { color: var(--red); border-color: #6a2f28; }
.badge.on { color: var(--blue); border-color: #2f4f66; }
.big { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0 6px; }
.big > div { background: var(--panel-2); border-radius: 10px; padding: 10px 12px; }
.big small, .facts small { display: block; font-size: 11px; letter-spacing: .1em; color: var(--muted); }
.big strong { font-size: clamp(40px, 13vw, 64px); line-height: 1.05; font-variant-numeric: tabular-nums; color: var(--amber); }
.big em { font-style: normal; color: var(--muted); margin-left: 4px; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.facts span { font-size: 18px; font-variant-numeric: tabular-nums; }
.actions button { flex: 1 1 120px; }
.splash { margin-top: 10px; text-align: center; font-size: 22px; font-weight: 700; color: var(--amber); padding: 10px; border-radius: 10px; background: #2b2410; }
.splash.done { color: var(--green); background: #1d2a17; }

.adjust { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0; }
.adjust .amt { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.adjust .amt input { width: 90px; }

.plot-card canvas { width: 100%; display: block; border-radius: 8px; background: #0e110b; touch-action: manipulation; }

.toggle { display: flex; gap: 10px; align-items: center; color: var(--muted); padding: 4px 2px; }
.toggle input { min-height: 0; width: 20px; height: 20px; }

.checks li { padding: 8px 10px; border-radius: 8px; background: var(--panel-2); border-left: 3px solid var(--line); font-size: 15px; }
.checks li.ok { border-color: var(--green); }
.checks li.warn { border-color: var(--amber); }
.checks li.bad { border-color: var(--red); }
.tips li { font-size: 15px; line-height: 1.4; }

.spots li { padding: 10px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); display: grid; gap: 6px; }
.spots .s-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.spots .kind { font-size: 11px; letter-spacing: .08em; color: var(--amber); text-transform: uppercase; }
.spots .s-act { display: flex; gap: 6px; flex-wrap: wrap; }
.spots .s-act button { min-height: 36px; font-size: 13px; padding: 0 10px; }

.prose { line-height: 1.5; }
.prose ol { padding-left: 20px; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(80px);
  background: var(--amber); color: var(--amber-ink); font-weight: 700; padding: 10px 16px; border-radius: 999px;
  transition: transform .2s; pointer-events: none; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { transform: translateX(-50%) translateY(0); }

@media (max-width: 420px) {
  .paste .row > input { flex-basis: 100%; }
  .paste .row > button { flex: 1; }
  .targets li { grid-template-columns: auto 1fr 1fr auto; }
  .targets .h { grid-column: 2 / 4; grid-template-columns: auto 1fr; align-items: center; gap: 6px; }
  .facts span { font-size: 16px; }
}

/* ---------- map plot ---------- */
.plot-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.plot-bar h2 { margin: 0 auto 0 0; }
.seg { display: flex; align-items: center; gap: 4px; }
.seg .muted { margin-right: 2px; }
.seg button, button.icon { min-height: 36px; padding: 0 10px; font-size: 13px; }
.seg button[aria-pressed="true"] { background: var(--amber); color: var(--amber-ink); border-color: var(--amber); font-weight: 700; }
.plot-wrap { position: relative; }
.plot-wrap canvas { width: 100%; display: block; border-radius: 8px; background: #0e110b; touch-action: none; cursor: crosshair; }
.hud {
  position: absolute; left: 8px; top: 8px; right: 8px; pointer-events: none;
  background: rgba(14,17,11,.82); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px;
  font-weight: 700; font-variant-numeric: tabular-nums; color: var(--amber); font-size: 15px; width: fit-content; max-width: calc(100% - 16px);
}
.map-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.filebtn {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 8px;
  border: 1px dashed var(--amber); color: var(--amber); cursor: pointer; font-weight: 600; font-size: 14px;
}
.hint { margin: 6px 0 0; }
.cal { margin-top: 10px; padding: 12px; border-radius: 10px; background: #2a2412; border: 1px solid #6a5420; }
.cal p { margin: 0 0 8px; line-height: 1.4; }

.plot-card.full {
  position: fixed; inset: 0; z-index: 30; border-radius: 0; margin: 0;
  display: flex; flex-direction: column; padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
}
.plot-card.full .plot-wrap { flex: 1; min-height: 0; }
.plot-card.full canvas { height: 100% !important; }
.plot-card.full .hint, .plot-card.full > p.muted { display: none; }
body.noscroll { overflow: hidden; }
