/* Layout: шапка с инструментами, рабочая карточка инструмента сверху, пояснения и FAQ ниже. Системные шрифты — ради скорости. */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --ink: #141a22;
  --muted: #5d6673;
  --line: #dde1e7;
  --accent: #0e7a6d;
  --accent-ink: #ffffff;
  --accent-soft: #e3f3f0;
  --warn: #b42330;
  --warn-soft: #fbe9ea;
  --checker: #e9ecf0;
  --f-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --f-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --r: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216; --surface: #171b21; --ink: #e9edf1; --muted: #9aa4b0; --line: #2a313a;
    --accent: #35c2ad; --accent-ink: #062621; --accent-soft: #12302b; --warn: #ff8089; --warn-soft: #3a1b1f; --checker: #252b33;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--f-ui); }
img { max-width: 100%; }
a { color: var(--accent); }
.wrap { max-width: 1080px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

/* Header */
.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; gap: 8px 18px; flex-wrap: wrap; padding-block: 10px; }
.brand { font-weight: 800; font-size: 16px; color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 8px; margin-right: auto; letter-spacing: -0.01em; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); display: inline-grid; place-items: center; color: var(--accent-ink); font-size: 13px; }
.top nav { display: flex; flex-wrap: wrap; gap: 2px; }
.top nav a { color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 600; padding: 6px 10px; border-radius: 8px; }
.top nav a:hover { color: var(--ink); background: var(--bg); }
.top nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }

main { padding-block: 26px 40px; display: grid; gap: 22px; }
h1 { font-weight: 750; font-size: clamp(24px, 3.6vw, 34px); line-height: 1.15; margin: 0; letter-spacing: -0.02em; text-wrap: balance; }
h2 { font-weight: 700; font-size: 19px; margin: 0; letter-spacing: -0.01em; }
h3 { font-size: 15.5px; margin: 0; }
.lede { color: var(--muted); margin: 8px 0 0; max-width: 68ch; font-size: 16px; }
.free { display: inline-flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.pill { font-size: 12.5px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--ink); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: grid; gap: 14px; min-width: 0; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 760px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }

/* Drop zone */
.drop { border: 2px dashed var(--line); border-radius: var(--r); padding: 30px 16px; text-align: center; cursor: pointer; background: var(--bg); transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop strong { display: block; font-size: 17px; margin-bottom: 4px; }
.drop span { color: var(--muted); font-size: 13.5px; }
.drop input { display: none; }

/* Controls */
.controls { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: end; }
.field { display: grid; gap: 4px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--muted); }
select, input[type="text"], input[type="url"], input[type="number"], textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; min-width: 0; max-width: 100%;
}
input[type="url"], input[type="text"].wide { width: 100%; }
input[type="range"] { accent-color: var(--accent); }
.field > .seg { justify-self: start; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; flex-wrap: wrap; }
.seg button { border: 0; background: var(--surface); color: var(--muted); font: 600 13.5px var(--f-ui); padding: 8px 12px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.btn { font: 600 14px var(--f-ui); border-radius: 9px; padding: 9px 15px; cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; }
@media (max-width: 520px) { .inline-form { flex-direction: column; } }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.msg { border-radius: 9px; padding: 9px 12px; margin: 0; font-size: 14px; background: var(--accent-soft); }
.msg.err { background: var(--warn-soft); color: var(--warn); }
.msg:empty { display: none; }
.hint { color: var(--muted); font-size: 13.5px; margin: 0; }

/* Results */
.results { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.res { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); display: grid; min-width: 0; }
.res .pic { aspect-ratio: 3 / 4; background: repeating-conic-gradient(var(--checker) 0 25%, transparent 0 50%) 0 0 / 16px 16px; display: grid; place-items: center; overflow: hidden; }
.res .pic img { width: 100%; height: 100%; object-fit: contain; display: block; }
.res .meta { padding: 8px 10px; display: grid; gap: 4px; font-size: 12.5px; }
.res .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.res .size { color: var(--muted); font-variant-numeric: tabular-nums; }
.res .size b { color: var(--accent); }
.res .err { color: var(--warn); }
.res a { font-weight: 600; font-size: 13px; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.summary { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; }
.summary .stat { font-variant-numeric: tabular-nums; color: var(--muted); }
.summary .stat b { color: var(--ink); }

/* Home */
.tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.tool { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; text-decoration: none; color: var(--ink); display: grid; gap: 6px; align-content: start; }
.tool:hover { border-color: var(--accent); }
.tool .ic { width: 38px; height: 38px; border-radius: 10px; background: var(--accent-soft); display: grid; place-items: center; font-size: 19px; }
.tool p { margin: 0; color: var(--muted); font-size: 14px; }
.tool .vs { font-size: 12.5px; color: var(--accent); font-weight: 600; }

/* QR + links */
.qr-out { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 560px) { .qr-out { grid-template-columns: minmax(0, 1fr); } }
.qr-out img { width: 200px; height: 200px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.copy-line { display: flex; gap: 8px; align-items: center; background: var(--bg); border-radius: 9px; padding: 8px 10px; min-width: 0; }
.copy-line code { font: 600 14px var(--f-mono); overflow-wrap: anywhere; flex: 1; min-width: 0; }
.mylinks { width: 100%; border-collapse: collapse; font-size: 14px; }
.mylinks th, .mylinks td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.mylinks th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.mylinks td.num { font-variant-numeric: tabular-nums; text-align: right; }
.mylinks .target { color: var(--muted); overflow-wrap: anywhere; font-size: 13px; }
.table-scroll { overflow-x: auto; }

/* Stats */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { background: var(--bg); border-radius: 10px; padding: 12px; display: grid; gap: 2px; }
.kpi b { font-size: 24px; font-variant-numeric: tabular-nums; }
.kpi span { font-size: 12.5px; color: var(--muted); }
.bars { display: grid; grid-template-columns: repeat(30, minmax(0, 1fr)); gap: 3px; align-items: end; height: 140px; padding-top: 8px; border-bottom: 1px solid var(--line); }
.bars i { display: block; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; }
.bars-x { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.breakdown { display: grid; gap: 6px; }
.breakdown div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; font-size: 14px; position: relative; padding: 4px 8px; border-radius: 6px; overflow: hidden; }
.breakdown div::before { content: ""; position: absolute; inset: 0; width: var(--w); background: var(--accent-soft); z-index: 0; }
.breakdown span, .breakdown b { position: relative; z-index: 1; font-variant-numeric: tabular-nums; }
.breakdown span { overflow-wrap: anywhere; }

/* Labels */
.label-preview { background: #fff; color: #000; border: 1px solid var(--line); border-radius: 6px; aspect-ratio: 58 / 40; width: min(290px, 100%); padding: 8px; display: grid; grid-template-rows: auto auto minmax(0, 1fr); text-align: center; font: 11px/1.25 var(--f-ui); overflow: hidden; min-height: 0; }
.label-preview b { font-size: 12px; }
.label-preview img { width: 100%; height: 100%; object-fit: contain; min-height: 0; }

/* Article */
.prose { max-width: 72ch; display: grid; gap: 10px; }
.prose p, .prose ul, .prose ol { margin: 0; }
.prose li + li { margin-top: 4px; }
details.faq { border-top: 1px solid var(--line); padding: 12px 0; }
details.faq summary { cursor: pointer; font-weight: 600; }
details.faq p { margin: 8px 0 0; }

footer.site { border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
footer.site .wrap { padding-block: 18px 28px; display: flex; flex-wrap: wrap; gap: 8px 22px; justify-content: space-between; }
footer.site nav { display: flex; flex-wrap: wrap; gap: 6px 14px; }
footer.site a { color: var(--muted); }
@media (max-width: 760px) {
  .top nav { flex-wrap: nowrap; overflow-x: auto; width: 100%; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .top nav::-webkit-scrollbar { display: none; }
  .top nav a { white-space: nowrap; }
}
