/* StegoLab — «как обычный сервис»: светло-серый фон, белые карточки без рамок, крупные синие кнопки,
   вкладки-таблетки, поля на сером фоне, системный шрифт. */
:root {
  --bg: #F0F2F5;
  --paper: #FFFFFF;
  --ink: #1A1D24;
  --ink-2: #4B5160;
  --muted: #818796;
  --field: #F0F2F5;
  --field-hover: #E7EAEF;
  --hair: #E3E6EB;
  --brand: #2B6BFF;
  --brand-hover: #1F5CEB;
  --brand-soft: #E8EFFF;
  --ok: #1B9E57;
  --ok-soft: #E5F6EC;
  --warn: #C27700;
  --bad: #E0383E;
  --bad-soft: #FDECEC;
  --on-brand: #FFFFFF;
  --r: 20px;
  --r-sm: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", "Cascadia Mono", Consolas, monospace;
  /* для графика */
  --border: var(--hair); --text: var(--ink); --text-2: var(--ink-2); --surface-2: var(--field); --accent: var(--brand);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111317; --paper: #1C1F25; --ink: #EEF0F4; --ink-2: #BCC1CC; --muted: #8B91A0; --field: #262A31; --field-hover: #2E333B;
    --hair: #2E333B; --brand: #4C84FF; --brand-hover: #6595FF; --brand-soft: #1E2A47; --ok: #3DD17F; --ok-soft: #14301F;
    --warn: #F0A63A; --bad: #FF6067; --bad-soft: #3A1C1E; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111317; --paper: #1C1F25; --ink: #EEF0F4; --ink-2: #BCC1CC; --muted: #8B91A0; --field: #262A31; --field-hover: #2E333B;
  --hair: #2E333B; --brand: #4C84FF; --brand-hover: #6595FF; --brand-soft: #1E2A47; --ok: #3DD17F; --ok-soft: #14301F;
  --warn: #F0A63A; --bad: #FF6067; --bad-soft: #3A1C1E; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; font-weight: 700; text-wrap: balance; }
p { margin: 0; }
code, .mono { font-family: var(--mono); }

/* ---------- шапка ---------- */
.top { background: var(--paper); position: sticky; top: 0; z-index: 5; box-shadow: 0 1px 0 var(--hair); }
.top-in { max-width: 960px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-block: 12px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--brand); flex: none; position: relative; }
.brand-mark::after { content: ""; position: absolute; inset: 9px; border: 2.5px solid #fff; border-radius: 4px; }
.brand b { font-size: 18px; font-weight: 700; }
.brand span { font-size: 14px; color: var(--muted); }
.tabs { display: flex; gap: 6px; background: var(--field); padding: 4px; border-radius: 14px; overflow-x: auto; scrollbar-width: none; }
.tab { font: 600 15px var(--font); color: var(--ink-2); background: none; border: 0; border-radius: 10px; padding: 9px 16px; cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--ink); background: var(--field-hover); }
.tab.active { background: var(--paper); color: var(--brand); box-shadow: 0 1px 3px rgba(20, 30, 60, .12); }

/* ---------- страница ---------- */
main { max-width: 960px; margin: 0 auto; padding-block: 32px 64px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.panel { display: none; }
.panel.active { display: block; }
.page-head { margin-bottom: 24px; }
.eyebrow { display: none; }
.page-head h1 { font-size: 32px; line-height: 1.2; margin-bottom: 8px; }
.page-head p { font-size: 17px; color: var(--ink-2); max-width: 680px; }

.card { background: var(--paper); border-radius: var(--r); padding: 28px; margin-bottom: 16px; min-width: 0; }
.card h2 { font-size: 21px; margin-bottom: 20px; display: flex; align-items: center; gap: 12px; }
.card h3 { font-size: 15px; color: var(--muted); font-weight: 600; margin: 20px 0 8px; }
.step-no { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: var(--on-brand); font: 700 16px var(--font); flex: none; }
label .step-no { margin-right: 12px; vertical-align: middle; }
label:has(.step-no) { font-size: 21px; font-weight: 700; margin-top: 26px; }
label:has(.step-no) > input { font-size: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.grid-2 > .card { margin-bottom: 0; }
.empty { color: var(--muted); padding: 44px 0; text-align: center; }
.hint { font-size: 14.5px; color: var(--muted); margin-top: 12px; }
.plain { font-size: 16.5px; color: var(--ink-2); margin-bottom: 18px; }

/* успех / ошибка */
.big-verdict { display: flex; align-items: center; gap: 14px; font-size: 19px; font-weight: 700; background: var(--ok-soft); color: var(--ink);
  border-radius: var(--r-sm); padding: 16px 18px; margin-bottom: 14px; }
.big-verdict::before { content: ""; width: 30px; height: 30px; border-radius: 50%; flex: none; background: var(--ok)
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 18px no-repeat; }
.verdict { border-radius: var(--r-sm); padding: 14px 16px; font-weight: 600; }
.verdict.ok { background: var(--ok-soft); color: var(--ok); }
.verdict.bad { background: var(--bad-soft); color: var(--bad); }

/* ---------- формы ---------- */
label { display: block; font-size: 15px; font-weight: 600; color: var(--ink); margin: 18px 0 8px; }
label > input, label > select, label > textarea { margin-top: 8px; font-weight: 400; }
input, select, textarea { width: 100%; font: 16px var(--font); color: var(--ink); background: var(--field); border: 2px solid transparent;
  border-radius: var(--r-sm); padding: 13px 16px; transition: background .15s, border-color .15s; }
textarea { line-height: 1.55; resize: vertical; }
input:hover, select:hover, textarea:hover { background: var(--field-hover); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); background: var(--paper); }
button:focus-visible, summary:focus-visible { outline: 3px solid var(--brand-soft); outline-offset: 2px; }
select { appearance: none; cursor: pointer; padding-right: 44px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23818796' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 18px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
details { margin-top: 18px; background: var(--field); border-radius: var(--r-sm); padding: 14px 18px; }
details > *:not(summary) { margin-top: 4px; }
details label > input, details label > select { background: var(--paper); }
summary { cursor: pointer; font-weight: 600; color: var(--ink-2); list-style: none; display: flex; justify-content: space-between; align-items: center; }
summary::after { content: ""; width: 9px; height: 9px; border-right: 2.5px solid var(--muted); border-bottom: 2.5px solid var(--muted); transform: rotate(45deg) translate(-2px, -2px); transition: transform .15s; }
details[open] > summary::after { transform: rotate(-135deg) translate(-2px, -2px); }
summary::-webkit-details-marker { display: none; }

/* ---------- кнопки ---------- */
button { font: 600 16px var(--font); color: var(--brand); background: var(--brand-soft); border: 0; border-radius: var(--r-sm);
  padding: 13px 22px; cursor: pointer; transition: background .15s, color .15s; }
button:hover { background: #DCE6FF; }
button.primary { background: var(--brand); color: var(--on-brand); margin-top: 22px; }
button.primary:hover { background: var(--brand-hover); }
button.wide { width: 100%; padding: 17px 22px; font-size: 17px; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.small { padding: 8px 14px; font-size: 14px; }
.btns { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.btns .primary { margin-top: 0; }
.spinner { display: inline-block; width: 15px; height: 15px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: sp .7s linear infinite; margin-right: 10px; vertical-align: -2px; }
@keyframes sp { to { transform: rotate(360deg); } }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) button:not(.primary):hover { background: #26345A; } }

/* ---------- выбор файла ---------- */
.src-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: stretch; }
.drop { flex: 1; min-width: min(260px, 100%); margin: 0; border: 2px dashed #C3CAD6; border-radius: var(--r); padding: 30px 20px 26px; text-align: center;
  cursor: pointer; color: var(--ink-2); font-weight: 500; background: var(--field); transition: border-color .15s, background .15s; }
.drop::before { content: ""; display: block; width: 46px; height: 46px; margin: 0 auto 12px; border-radius: 14px; background: var(--brand-soft)
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232B6BFF' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 16V4M7 9l5-5 5 5M5 20h14'/%3E%3C/svg%3E") center / 22px no-repeat; }
.drop:hover, .drop.over { border-color: var(--brand); background: var(--brand-soft); }
.drop input { display: none; }
.src-row > button { align-self: center; }
.info { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.info span { font-size: 14px; font-weight: 500; color: var(--ink-2); background: var(--field); border-radius: 999px; padding: 6px 14px; }
#imgThumb canvas { display: block; margin-top: 16px; max-height: 180px; max-width: 100%; border-radius: var(--r-sm); }

.meter { height: 8px; border-radius: 4px; margin-top: 12px; background: var(--field); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--brand); width: 0; border-radius: 4px; transition: width .2s; }
.meter.over i { background: var(--bad); }
.count { font-size: 14px; color: var(--muted); margin-top: 8px; }

/* ---------- числа ---------- */
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin: 18px 0; }
.kv > div { background: var(--field); border-radius: var(--r-sm); padding: 16px 18px; }
.kv b { display: block; font-size: 24px; font-weight: 700; line-height: 1.2; }
.kv span { font-size: 14px; color: var(--muted); }
.grade { font-weight: 700; }
.grade.ok { color: var(--ok); } .grade.warn { color: var(--warn); } .grade.bad { color: var(--bad); }

/* ---------- картинки ---------- */
.pics { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 20px; }
.pic { min-width: 0; }
.pic .frame { background: var(--field); border-radius: var(--r-sm); padding: 10px; display: grid; place-items: center; min-height: 160px; }
.pic canvas { max-width: 100%; max-height: 380px; height: auto; display: block; border-radius: 8px; }
.pic .cap { font-size: 14.5px; color: var(--muted); margin-top: 10px; }
.pic .cap b { color: var(--ink); }
.zoom { cursor: zoom-in; }
.msgbox { font-size: 18px; line-height: 1.6; background: var(--field); border-radius: var(--r-sm); padding: 18px 20px; white-space: pre-wrap; word-break: break-word; }

/* ---------- таблица и график ---------- */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { text-align: left; padding: 12px; border-bottom: 1px solid var(--hair); }
th { font-size: 13.5px; font-weight: 600; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.legend { display: flex; flex-wrap: wrap; gap: 20px; font-size: 14.5px; color: var(--ink-2); margin: 4px 0 10px; }
.legend i { display: inline-block; width: 18px; height: 4px; border-radius: 2px; vertical-align: middle; margin-right: 8px; }
svg text { fill: var(--muted); font: 12.5px var(--font); }

/* ---------- как это работает ---------- */
.prose { max-width: 820px; }
.prose h2 { font-size: 22px; margin: 30px 0 14px; }
.prose h2:first-child { margin-top: 0; }
.prose p, .prose li { color: var(--ink-2); line-height: 1.7; }
.prose b { color: var(--ink); }
.plain-steps { list-style: none; counter-reset: ps; margin: 0; padding: 0; display: grid; gap: 10px; }
.plain-steps li { counter-increment: ps; position: relative; padding: 16px 18px 16px 62px; background: var(--field); border-radius: var(--r-sm); }
.plain-steps li::before { content: counter(ps); position: absolute; left: 16px; top: 15px; width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand); color: var(--on-brand); display: grid; place-items: center; font: 700 15px var(--font); }
.formula { font: 15px var(--mono); background: var(--field); border-radius: var(--r-sm); padding: 14px 18px; margin: 14px 0; overflow-x: auto; }

/* ---------- футер и уведомления ---------- */
.foot { max-width: 960px; margin: 0 auto; padding-block: 0 40px; font-size: 14px; color: var(--muted); text-align: center;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 16px); opacity: 0; visibility: hidden; background: var(--ink); color: var(--paper);
  padding: 14px 22px; border-radius: var(--r-sm); font-weight: 600; max-width: 90vw; box-shadow: 0 8px 24px rgba(20, 30, 60, .2);
  transition: opacity .2s, transform .2s, visibility .2s; z-index: 20; }
#toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }
#toast.err { background: var(--bad); color: #fff; }

@media (max-width: 820px) {
  .top-in { flex-direction: column; align-items: stretch; gap: 10px; }
  .tabs { justify-content: flex-start; }
  .grid-2, .pics, .row { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 26px; }
  .card { padding: 20px 18px; border-radius: 16px; }
  .src-row > button { width: 100%; }
  main { padding-block: 20px 48px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
