:root {
  color-scheme: light;
  --ink: #0f172a;
  --text: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --soft: #f8fafc;
  --blue: #1d4ed8;
  --blue-soft: #eff6ff;
  --red: #dc2626;
  --green: #16a34a;
  --yellow: #eab308;
  --gray: #94a3b8;
  --radius: 14px;
  --pad: clamp(16px, 4vw, 24px);
  accent-color: var(--blue);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
  background: #fff;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; }
main { max-width: 960px; margin: 0 auto; padding: 0 var(--pad) 40px; }
h1, h2 { text-wrap: balance; letter-spacing: -0.02em; }
.muted { color: var(--muted); }
b { font-weight: 650; }

/* icons */
.ic { inline-size: 1.1em; block-size: 1.1em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.18em; }
.dot { display: inline-block; inline-size: 10px; block-size: 10px; border-radius: 50%; flex: none; }
.c-cut { background: var(--red); } .c-win { background: var(--green); } .c-test { background: var(--yellow); } .c-keep { background: var(--gray); }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; max-width: 960px; margin: 0 auto; padding: 16px var(--pad); }
.brand { display: flex; gap: 10px; align-items: center; font-weight: 800; font-size: 1.05rem; color: var(--ink); text-decoration: none; }
.free { font-size: .8rem; font-weight: 600; color: var(--blue); background: var(--blue-soft); padding: 4px 10px; border-radius: 99px; }

/* hero */
.hero { text-align: center; padding: clamp(16px, 5vw, 40px) 0 8px; }
.hero h1 { font-size: clamp(1.9rem, 6vw, 3.2rem); line-height: 1.08; margin: 0 0 14px; }
.lead { font-size: clamp(1rem, 2.6vw, 1.15rem); color: var(--text); max-width: 620px; margin: 0 auto 18px; text-wrap: pretty; }
.badges { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; list-style: none; padding: 0; margin: 0 0 24px; }
.badges li { display: inline-flex; align-items: center; gap: 6px; font-size: .88rem; color: var(--text); border: 1px solid var(--line); padding: 5px 12px; border-radius: 99px; }
.badges .ic { color: var(--green); }
.badges li:last-child .ic { color: var(--blue); }

.drop { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: clamp(28px, 6vw, 44px) 20px; border: 2px dashed #cbd5e1; border-radius: 20px; background: var(--soft); cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop:focus-visible, .drop.over { border-color: var(--blue); background: var(--blue-soft); outline: none; }
.drop strong { font-size: clamp(1.05rem, 3vw, 1.25rem); }
.drop-icon { display: grid; place-items: center; inline-size: 52px; block-size: 52px; border-radius: 50%; background: #fff; color: var(--blue); border: 1px solid var(--line); margin-bottom: 4px; }
.drop-icon .ic { inline-size: 24px; block-size: 24px; }
.sample { margin: 14px 0 0; color: var(--muted); }
.error { color: var(--red); font-weight: 600; }
.how-export { max-width: 660px; margin: 20px auto 0; text-align: left; color: var(--text); }
.how-export summary { cursor: pointer; color: var(--blue); font-weight: 600; text-align: center; }

/* controls */
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--blue); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 600; border: 1px solid #cbd5e1; background: #fff; color: var(--ink); padding: 9px 16px; border-radius: 10px; cursor: pointer; min-block-size: 42px; }
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: #1e40af; }
.btn[data-copied] { background: var(--green); border-color: var(--green); }
.btn[data-failed] { background: var(--red); border-color: var(--red); }
.lbl { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 6px; }

/* results */
.filebar { display: flex; justify-content: space-between; align-items: center; gap: 8px 16px; flex-wrap: wrap; padding: 4px 0 14px; border-bottom: 1px solid var(--line); }
.fileinfo { display: inline-flex; align-items: center; gap: 8px; min-inline-size: 0; }
.fileinfo b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-inline-size: 50vw; }
.fileinfo .ic { color: var(--muted); }

.settings { display: grid; grid-template-columns: minmax(200px, 260px) 1fr; gap: 18px 28px; align-items: start; padding: 18px 0; }
.payout small { display: block; margin-top: 4px; font-size: .8rem; }
.money { display: flex; align-items: center; border: 1px solid #cbd5e1; border-radius: 10px; padding: 0 12px; background: #fff; min-block-size: 46px; }
.money:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.money #cur { color: var(--muted); font-weight: 600; }
.money input { border: 0; outline: 0; font: inherit; font-size: 1.1rem; font-weight: 600; padding: 8px 6px; inline-size: 100%; min-inline-size: 0; background: transparent; }

.seg { border: 0; padding: 0; margin: 0; min-inline-size: 0; }
.seg legend { padding: 0; }
.seg-row { display: grid; grid-template-columns: repeat(3, 1fr); background: #f1f5f9; border-radius: 12px; padding: 4px; gap: 4px; }
.seg label { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 7px 6px; border-radius: 9px; cursor: pointer; color: var(--text); line-height: 1.25; min-block-size: 46px; }
.seg input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.seg b { font-size: .95rem; }
.seg small { font-size: .75rem; color: var(--muted); }
.seg label:has(:checked) { background: #fff; color: var(--blue); box-shadow: 0 1px 3px rgb(15 23 42 / .12); }
.seg label:has(:focus-visible) { outline: 2px solid var(--blue); outline-offset: 1px; }

.cols { grid-column: 1 / -1; color: var(--muted); font-size: .9rem; }
.cols summary { cursor: pointer; }
.cols-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-top: 10px; }
.cols-grid label { display: grid; gap: 3px; font-size: .85rem; color: var(--ink); font-weight: 600; }
.cols-grid select, #fmt { font: inherit; font-size: .9rem; padding: 0 10px; min-block-size: 42px; border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; color: var(--ink); }

.headline { text-align: center; padding: clamp(20px, 5vw, 30px) var(--pad); border-radius: 20px; background: var(--soft); border: 1px solid var(--line); }
.headline .kicker { margin: 0 0 4px; font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.headline .big { margin: 0; font-size: clamp(2.8rem, 12vw, 5.2rem); font-weight: 900; letter-spacing: -0.04em; line-height: 1; color: var(--green); font-variant-numeric: tabular-nums; }
.headline .big.zero { color: var(--ink); }
.headline .sub { font-size: clamp(1rem, 2.8vw, 1.12rem); color: var(--text); margin: 12px auto 0; max-width: 560px; text-wrap: balance; }

.split { display: flex; height: 14px; border-radius: 99px; overflow: hidden; margin: 22px 0 10px; background: var(--line); gap: 2px; }
.split span { display: block; transition: flex-basis .6s ease; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 20px; list-style: none; padding: 0; margin: 0 0 26px; font-size: .88rem; color: var(--text); }
.legend li { display: inline-flex; align-items: center; gap: 7px; }
.legend .v { font-variant-numeric: tabular-nums; color: var(--muted); }

.tabs { display: grid; grid-template-columns: repeat(4, auto) 1fr; border-bottom: 1px solid var(--line); }
.tabs button { display: inline-flex; align-items: center; gap: 8px; font: inherit; font-weight: 600; background: none; border: 0; border-bottom: 3px solid transparent; margin-bottom: -1px; padding: 12px 16px 10px; cursor: pointer; color: var(--muted); white-space: nowrap; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected='true'] { color: var(--ink); border-bottom-color: var(--blue); }
.tabs .n { font-weight: 600; font-size: .8rem; background: #f1f5f9; color: var(--text); padding: 1px 8px; border-radius: 99px; font-variant-numeric: tabular-nums; }

.panel { padding-top: 16px; }
.panel-bar { display: flex; gap: 12px; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.panel-note { margin: 0; color: var(--text); flex: 1 1 260px; }
.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row[hidden] { display: none; }
.copy { position: relative; }
.tip { position: absolute; inset-block-end: calc(100% + 6px); inset-inline-end: 0; background: var(--ink); color: #fff; font-size: .8rem; padding: 3px 8px; border-radius: 6px; opacity: 0; transition: opacity .15s; pointer-events: none; white-space: nowrap; }
.tip:not(:empty) { opacity: 1; }
.list-text { margin: 12px 0; padding: 10px 12px; background: var(--soft); border: 1px solid var(--line); border-radius: 10px; font: .82rem/1.55 ui-monospace, 'JetBrains Mono', Consolas, monospace; color: var(--text); max-block-size: 6.5em; overflow: auto; white-space: pre-wrap; word-break: break-all; }
.list-text:empty { display: none; }

.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table { border-collapse: collapse; inline-size: 100%; font-size: .92rem; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--soft); white-space: nowrap; }
td.zone { font-family: ui-monospace, 'JetBrains Mono', Consolas, monospace; font-size: .88rem; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.why { color: var(--text); }
tbody tr:last-child td { border-bottom: 0; }
.neg { color: var(--red); } .pos { color: var(--green); }
#more { margin-top: 12px; }
.dl { margin: 24px 0 0; }

.explain { margin-top: 48px; padding-top: 28px; border-top: 1px solid var(--line); color: var(--text); }
.explain h2 { color: var(--ink); font-size: 1.4rem; }
.rules { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin: 0 0 18px; }
.rules div { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.rules dt { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink); margin-bottom: 4px; }
.rules dd { margin: 0; font-size: .93rem; }
.privacy { display: flex; gap: 10px; align-items: flex-start; color: var(--muted); }
.privacy .ic { color: var(--blue); margin-top: 3px; }
.foot { text-align: center; color: var(--muted); padding: 28px var(--pad) 40px; font-size: .9rem; }
.foot a { color: var(--blue); }

/* ---------- tablet ---------- */
@media (max-width: 760px) {
  .settings { grid-template-columns: 1fr; gap: 16px; }
  .payout { display: grid; grid-template-columns: 1fr; }
  .money { max-inline-size: 220px; }
  .tabs { grid-template-columns: repeat(4, 1fr); }
  .tabs button { flex-direction: column; gap: 4px; padding: 10px 4px 8px; font-size: .9rem; }
  .tabs .dot { display: none; }
  .tabs .t::before { content: ''; display: inline-block; inline-size: 8px; block-size: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; background: currentColor; }
  .tabs [data-tab='cut'] .t::before { background: var(--red); }
  .tabs [data-tab='win'] .t::before { background: var(--green); }
  .tabs [data-tab='test'] .t::before { background: var(--yellow); }
  .tabs [data-tab='keep'] .t::before { background: var(--gray); }
}

/* ---------- phone: rows become cards ---------- */
@media (max-width: 640px) {
  .copy-row { inline-size: 100%; }
  .copy-row #fmt { flex: 1; }
  .copy-row .copy { flex: 1; }
  .copy-row .btn { inline-size: 100%; }
  .legend { gap: 6px 14px; }

  .table-wrap { border: 0; border-radius: 0; overflow: visible; }
  table, tbody { display: block; }
  thead { display: none; }
  tbody tr { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-areas: 'zone zone profit' 'why why why' 'spent conv rev'; gap: 4px 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; }
  td { padding: 0; border: 0; }
  td.zone { grid-area: zone; font-weight: 600; font-size: .9rem; align-self: center; white-space: normal; word-break: break-all; }
  td.profit { grid-area: profit; font-weight: 700; align-self: center; }
  td.why { grid-area: why; font-size: .88rem; }
  td.spent { grid-area: spent; } td.conv { grid-area: conv; } td.rev { grid-area: rev; }
  td.spent, td.conv, td.rev { text-align: left; font-size: .82rem; color: var(--muted); display: flex; flex-direction: column; padding-top: 6px; border-top: 1px dashed var(--line); margin-top: 4px; }
  td.spent::before, td.conv::before, td.rev::before { content: attr(data-l); font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--gray); }
  .dl .btn { inline-size: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .split span { transition: none; }
}
