:root {
  --bg: #f1f4f9;
  --card: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e8ef;
  --soft: #f6f8fb;
  --blue: #5b8def;
  --green: #4fc98a;
  --orange: #f2a347;
  --purple: #8b5cf6;
  --pink: #e8578f;
  --good: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --m-bad: #fde2e2;
  --m-warn: #fef0cc;
  --shadow: 0 1px 2px rgba(17, 24, 39, .04), 0 6px 24px rgba(17, 24, 39, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116; --card: #161a21; --ink: #e8ebf1; --muted: #8b93a3; --line: #262c36; --soft: #1b2029;
    --m-bad: #4a1f24; --m-warn: #45361a; --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font: 15px/1.55 Inter, system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--ink);
  display: grid; grid-template-columns: 280px 1fr; min-height: 100vh;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--blue); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.bad-text { color: var(--bad); }

/* --- sidebar --- */
.side { padding: 24px 18px; border-right: 1px solid var(--line); background: var(--card); position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.brand { display: flex; gap: 12px; align-items: center; padding: 0 8px 22px; }
.brand b { display: block; font-size: 17px; letter-spacing: -.01em; }
.brand span:not(.tile) { font-size: 12px; color: var(--muted); }
.tile { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; flex: none; color: #fff; }
.tile svg { width: 22px; height: 22px; fill: currentColor; }
.t-detect { background: var(--blue); }
.t-human { background: var(--green); }
.t-plag { background: var(--orange); }
.t-hist { background: var(--purple); }
nav { display: grid; gap: 4px; }
nav button { display: flex; gap: 12px; align-items: center; border: 0; background: none; padding: 10px; border-radius: 12px; text-align: left; }
nav button b { display: block; font-weight: 600; }
nav button small { color: var(--muted); font-size: 12.5px; }
nav button:hover { background: var(--soft); }
nav button.active { background: var(--soft); box-shadow: inset 0 0 0 1px var(--line); }
.side-foot { margin-top: auto; font-size: 12px; color: var(--muted); padding: 0 8px; }

/* --- main --- */
main { padding: 32px 36px 60px; min-width: 0; }
.page-head h1 { margin: 0 0 4px; font-size: 28px; letter-spacing: -.02em; }
.page-head p { margin: 0 0 22px; }
.grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 20px; align-items: start; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.input-card { display: flex; flex-direction: column; position: sticky; top: 24px; }
textarea { border: 0; resize: vertical; min-height: 380px; padding: 20px; font: inherit; background: none; color: inherit; outline: none; border-radius: 18px 18px 0 0; }
.input-card.drag { outline: 2px dashed var(--blue); outline-offset: -8px; }
.input-foot { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); }
.input-foot .muted { margin-right: auto; }
.primary { background: var(--ink); color: var(--card); border: 0; border-radius: 11px; padding: 10px 20px; font-weight: 600; }
.primary:disabled { opacity: .55; cursor: progress; }
.ghost { background: none; border: 1px solid var(--line); border-radius: 11px; padding: 9px 14px; }
.upload { cursor: pointer; font-size: 14px; }
.opts { padding: 14px 16px; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.opt-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.opt-row label { width: 44px; font-size: 13px; color: var(--muted); }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; background: var(--soft); padding: 4px; border-radius: 11px; }
.seg button { border: 0; background: none; padding: 5px 11px; border-radius: 8px; font-size: 13.5px; }
.seg button.on { background: var(--card); box-shadow: 0 1px 3px rgba(0,0,0,.1); font-weight: 600; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13.5px; }

/* --- result --- */
.result-card { padding: 22px; min-height: 440px; }
.empty { height: 400px; display: grid; place-content: center; justify-items: center; color: var(--muted); }
.empty-ico { width: 64px; height: 64px; border-radius: 18px; background: var(--soft); display: grid; place-items: center; }
.empty-ico svg { width: 30px; fill: var(--muted); }
.loading { height: 400px; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--muted); text-align: center; }
.spinner { width: 38px; height: 38px; border: 3px solid var(--line); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.res-head { display: flex; gap: 22px; align-items: center; margin-bottom: 18px; }
.gauge { --c: var(--good); width: 128px; height: 128px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: conic-gradient(var(--c) calc(var(--v) * 1%), var(--soft) 0); }
.gauge.warn { --c: var(--warn); } .gauge.bad { --c: var(--bad); }
.gauge-in { width: 100px; height: 100px; border-radius: 50%; background: var(--card); display: grid; place-content: center; text-align: center; }
.gauge-in b { font-size: 26px; letter-spacing: -.02em; line-height: 1.1; }
.gauge-in span { font-size: 11px; color: var(--muted); max-width: 80px; line-height: 1.2; }
.verdict { font-weight: 700; font-size: 17px; margin-bottom: 8px; }
.verdict.good, .good-text { color: var(--good); } .verdict.warn { color: var(--warn); } .verdict.bad { color: var(--bad); }
.kv { display: grid; grid-template-columns: auto auto; gap: 3px 16px; font-size: 13.5px; }
.kv span { color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 5px; }
.hl-text, .out-text { white-space: pre-wrap; background: var(--soft); border-radius: 12px; padding: 16px; line-height: 1.7; max-height: 480px; overflow: auto; }
.out-text { background: none; border: 1px solid var(--line); max-height: none; }
mark { color: inherit; border-radius: 3px; padding: 1px 0; }
.m-bad { background: var(--m-bad); } .m-warn { background: var(--m-warn); }
mark sup { font-size: 10px; font-weight: 700; margin-left: 2px; }
.src-0 { --s: 91,141,239; } .src-1 { --s: 242,163,71; } .src-2 { --s: 139,92,246; } .src-3 { --s: 232,87,143; }
.src-4 { --s: 79,201,138; } .src-5 { --s: 14,165,233; } .src-6 { --s: 234,88,12; } .src-7 { --s: 100,116,139; }
mark.src, .legend i[class^="src"] { background: rgba(var(--s), .22); }
mark.src.partial, .legend i.partial { background: none; box-shadow: inset 0 -2px rgb(var(--s)); }
mark.src sup { color: rgb(var(--s)); }
h4 { margin: 22px 0 8px; font-size: 14px; }
.reasons { margin: 0; padding-left: 20px; } .reasons li { margin: 4px 0; }
.signals { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.sig-top { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.bar { height: 6px; background: var(--soft); border-radius: 3px; margin: 5px 0 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--good); } .bar i.warn { background: var(--warn); } .bar i.bad { background: var(--bad); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--m-warn); border-radius: 20px; padding: 2px 10px; font-size: 12.5px; }
.sources { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.sources li { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; }
.sources li > div { flex: 1; min-width: 0; }
.sources li a, .sources li .muted { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; background: rgb(var(--s)); flex: none; }
details { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.before-after { display: flex; align-items: center; gap: 18px; margin-bottom: 14px; }
.before-after > div:not(.arrow) { display: grid; justify-items: center; gap: 4px; }
.before-after .gauge { width: 96px; height: 96px; } .before-after .gauge-in { width: 74px; height: 74px; }
.before-after .gauge-in b { font-size: 20px; }
.arrow { font-size: 26px; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.actions a, .actions button { text-decoration: none; color: var(--ink); background: none; border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px; font-size: 13.5px; }
.error { color: var(--bad); background: var(--m-bad); padding: 14px; border-radius: 12px; }

/* --- history --- */
.filters { margin-bottom: 16px; }
.hlist { display: grid; gap: 8px; }
.hrow { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto auto; gap: 14px; align-items: center; padding: 12px 16px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; text-decoration: none; color: inherit; }
.hrow:hover { border-color: var(--muted); }
.hrow .tile { width: 34px; height: 34px; border-radius: 9px; font-size: 11px; font-weight: 700; }
.hrow > div { min-width: 0; }
.hrow p { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hscore { font-weight: 700; font-size: 17px; text-align: right; }
.hdel { border: 0; background: none; color: var(--muted); font-size: 18px; padding: 4px 8px; border-radius: 8px; }
.hdel:hover { background: var(--m-bad); color: var(--bad); }

.login { position: fixed; inset: 0; background: var(--bg); display: grid; place-items: center; z-index: 10; }
.login form { padding: 28px; width: min(340px, 90vw); display: grid; gap: 12px; }
.login h2 { margin: 0; }
.login input { font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--soft); color: inherit; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--card); padding: 10px 18px; border-radius: 12px; font-size: 14px; z-index: 20; }

@media (max-width: 1100px) {
  .grid { grid-template-columns: 1fr; }
  .input-card { position: static; }
  textarea { min-height: 240px; }
}
@media (max-width: 760px) {
  body { grid-template-columns: 1fr; align-content: start; }
  .side { position: sticky; height: auto; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--line); z-index: 5; }
  .brand, .side-foot { display: none; }
  nav { grid-template-columns: repeat(4, 1fr); }
  nav button { flex-direction: column; gap: 4px; padding: 6px 2px; text-align: center; }
  nav button small { display: none; } nav button b { font-size: 11.5px; font-weight: 600; }
  .tile { width: 32px; height: 32px; } .tile svg { width: 18px; height: 18px; }
  main { padding: 20px 16px 40px; }
  .input-foot { flex-wrap: wrap; }
  .input-foot .muted { width: 100%; }
  .input-foot .primary { flex: 1; }
  .page-head h1 { font-size: 23px; }
  .res-head { flex-direction: column; align-items: flex-start; }
  .hrow { grid-template-columns: 30px minmax(0, 1fr) auto; } .hrow .hdel { display: none; }
}

/* --- печать отчёта --- */
.report { max-width: 860px; margin: 0 auto; padding: 36px 24px 60px; }
body.report-body { display: block; }
.report-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.report-head h1 { margin: 0; font-size: 26px; }
@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .hl-text, .out-text { max-height: none; overflow: visible; }
  details { display: block; } details > * { display: block; }
  .report { padding: 0; }
}
