/* Анонімізатор для телефона: вигляд у дусі iOS, ті самі кольори знахідок, що й у ПК-версії. */
:root {
  color-scheme: light dark;
  --bg: #f2f2f7;
  --card: #ffffff;
  --card2: #f7f7fa;
  --fg: #1c1c1e;
  --muted: #6e6e73;
  --faint: #8e8e93;
  --line: #e3e3e8;
  --line2: #c7c7cc;
  --press: #e9e9ee;
  --accent: #2563eb;
  --accent-press: #1d4ed8;
  --accent-soft: #e6eeff;
  --on-accent: #ffffff;
  --crit-bg: #fde4e2; --crit-fg: #a8200d;
  --warn-bg: #fff1c2; --warn-fg: #7a4a00;
  --tip-bg: #e6eeff;  --tip-fg: #1d4ed8;
  --ok-bg: #dcf5e4;   --ok-fg: #13692c;
  --idle-bg: #eceef2; --idle-fg: #5b6472;
  --tok-bg: #e3e9fb;  --tok-fg: #1e3a8a;
  --focus: #ffd84d;
  --seg: #e4e4e9;
  --seg-on: #ffffff;
  --toast: rgba(30, 30, 32, .92);
  --shadow: 0 1px 2px rgba(0, 0, 0, .06);
  --bar: rgba(249, 249, 251, .86);
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --card2: #232326;
    --fg: #f2f2f7;
    --muted: #a1a1a8;
    --faint: #7c7c82;
    --line: #2e2e31;
    --line2: #48484a;
    --press: #2c2c2e;
    --accent: #4f8cff;
    --accent-press: #3b78ec;
    --accent-soft: #15284d;
    --crit-bg: #3d1714; --crit-fg: #ff8f80;
    --warn-bg: #3a2d08; --warn-fg: #ffd36e;
    --tip-bg: #14254a;  --tip-fg: #9dbcff;
    --ok-bg: #0e2e1a;   --ok-fg: #74dd93;
    --idle-bg: #232326; --idle-fg: #a1a1a8;
    --tok-bg: #1f2d57;  --tok-fg: #c0d0ff;
    --focus: #b38b00;
    --seg: #2c2c2e;
    --seg-on: #5a5a5f;
    --toast: rgba(72, 72, 76, .97);
    --shadow: none;
    --bar: rgba(22, 22, 24, .86);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 17px/1.4 var(--font);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
[hidden] { display: none !important; }
.i { width: 22px; height: 22px; flex: none; }

/* ── верхня панель */
.topbar {
  position: sticky; top: 0; z-index: 20;
  padding-top: env(safe-area-inset-top);
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: .5px solid var(--line);
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 760px; margin: 0 auto;
  padding: 8px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
}
h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: .2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.level-chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; border-radius: 999px; padding: 6px 10px 6px 6px;
  background: var(--card); box-shadow: var(--shadow);
  font-size: 14px; color: var(--muted); white-space: nowrap;
}
.level-chip:active { background: var(--press); }
.level-chip .i { width: 18px; height: 18px; color: var(--accent); }
.level-num {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 13px;
}
@media (max-width: 370px) { #level-name { display: none; } }

.engine, .update {
  max-width: 760px; margin: 0 auto; padding: 0 16px 8px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 13px; color: var(--muted);
}
.engine-bar { flex-basis: 100%; height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; }
.engine-bar > div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.update button { border: 0; background: none; color: var(--accent); font-weight: 600; padding: 4px 0; }

/* ── сторінки */
main {
  max-width: 760px; margin: 0 auto;
  padding: 14px max(16px, env(safe-area-inset-right)) calc(96px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.lead { margin: 0 4px 14px; font-size: 15px; color: var(--muted); }
.section-label { margin: 22px 16px 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }

/* ── нижня панель розділів */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center;
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: .5px solid var(--line);
}
.tabbar button {
  flex: 1; max-width: 150px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: 0; background: none; padding: 7px 2px 6px;
  font-size: 10.5px; font-weight: 500; color: var(--faint);
}
.tabbar button .i { width: 26px; height: 26px; }
.tabbar button[aria-current="page"] { color: var(--accent); }

/* ── картки */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 14px; overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px 4px; font-size: 15px; font-weight: 600; }
.card-head .i { width: 18px; height: 18px; color: var(--muted); }
.card-sub { margin-left: auto; font-size: 13px; font-weight: 400; color: var(--muted); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-body { padding: 4px 14px 14px; }
.toolbar {
  display: flex; flex-wrap: wrap; gap: 0 2px; padding: 4px 6px;
  border-top: .5px solid var(--line);
}
.toolbar .spacer { flex: 1; }
.tbtn {
  display: inline-flex; align-items: center; gap: 5px; flex: none;
  border: 0; border-radius: 9px; background: none;
  padding: 8px 9px; font-size: 15px; color: var(--accent); white-space: nowrap;
}
.tbtn .i { width: 20px; height: 20px; }
.tbtn:active { background: var(--press); }
.tbtn:disabled { color: var(--faint); opacity: .55; }
.tbtn.strong { font-weight: 600; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  min-height: 50px; border: 0; border-radius: 12px; padding: 12px 16px;
  font-size: 17px; font-weight: 600;
  background: var(--accent); color: var(--on-accent);
}
.btn:active { background: var(--accent-press); }
.btn:disabled { opacity: .5; }
.btn.secondary { background: var(--card); color: var(--accent); box-shadow: var(--shadow); }
.btn.secondary:active { background: var(--press); }
.btn.danger { background: var(--card); color: var(--crit-fg); box-shadow: var(--shadow); }
.btn .i { width: 22px; height: 22px; }
.action-row { margin: 0 0 8px; }
.status { min-height: 20px; margin: 6px 6px 14px; font-size: 14px; color: var(--muted); }

.spinner {
  display: inline-block; width: 16px; height: 16px; flex: none;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin .8s linear infinite;
}
.btn .spinner { width: 18px; height: 18px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── текст і підсвітка */
.docview { position: relative; }
.doc-area {
  display: block; width: 100%; min-height: 32vh; max-height: 60vh;
  border: 0; outline: none; resize: none;
  padding: 10px 14px 12px; background: transparent;
  font-size: 16px; line-height: 1.5;
}
.doc-area::placeholder { color: var(--faint); }
.doc-text {
  min-height: 96px; max-height: 58vh; overflow: auto;
  padding: 10px 14px 12px;
  font-size: 16px; line-height: 1.55;
  white-space: pre-wrap; overflow-wrap: anywhere;
  -webkit-user-select: text; user-select: text;
}
.doc-text.is-empty { color: var(--faint); }
.docview .doc-text { display: block; }
.docview .doc-area { display: none; }
.docview.editing .doc-text { display: none; }
.docview.editing .doc-area { display: block; }
.tok { background: var(--tok-bg); color: var(--tok-fg); border-radius: 4px; }
.m-crit { background: var(--crit-bg); color: var(--crit-fg); text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 2px; border-radius: 3px; }
.m-warn { background: var(--warn-bg); border-radius: 3px; }
.m-tip { background: var(--tip-bg); border-radius: 3px; }
.m-focus { background: var(--focus) !important; color: #1c1c1e !important; border-radius: 3px; box-shadow: 0 0 0 2px var(--focus); }
@media (prefers-color-scheme: dark) { .m-focus { color: #fff !important; } }

/* ── висновок перевірки */
.report { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 14px; }
.verdict { display: flex; gap: 10px; padding: 12px 14px; border-left: 4px solid; font-size: 15px; font-weight: 600; line-height: 1.35; }
.verdict .i { width: 22px; height: 22px; margin-top: 1px; }
.verdict.crit { background: var(--crit-bg); color: var(--crit-fg); border-color: var(--crit-fg); }
.verdict.warn { background: var(--warn-bg); color: var(--warn-fg); border-color: var(--warn-fg); }
.verdict.ok { background: var(--ok-bg); color: var(--ok-fg); border-color: var(--ok-fg); }
.verdict.tip { background: var(--tip-bg); color: var(--tip-fg); border-color: var(--tip-fg); }
.verdict.idle { background: var(--idle-bg); color: var(--idle-fg); border-color: var(--line2); font-weight: 500; }
.counts { display: flex; gap: 6px; padding: 10px 14px 2px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 3px 9px 3px 6px; font-size: 13px; font-weight: 600; }
.chip .i { width: 16px; height: 16px; }
.chip.crit { background: var(--crit-bg); color: var(--crit-fg); }
.chip.warn { background: var(--warn-bg); color: var(--warn-fg); }
.chip.tip { background: var(--tip-bg); color: var(--tip-fg); }
.chip.done { background: var(--idle-bg); color: var(--idle-fg); }
.hint { padding: 8px 14px 4px; font-size: 13px; color: var(--muted); }
.issues { list-style: none; margin: 0; padding: 0; }
.issue { border-top: .5px solid var(--line); }
.issue-row {
  display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; align-items: start;
  width: 100%; border: 0; background: none; text-align: left; padding: 10px 14px;
}
.issue-row:active { background: var(--press); }
.issue-row .i { width: 20px; height: 20px; margin-top: 1px; }
.issue.crit .issue-row > .i { color: var(--crit-fg); }
.issue.warn .issue-row > .i { color: var(--warn-fg); }
.issue.tip .issue-row > .i { color: var(--tip-fg); }
.issue.done .issue-row > .i { color: var(--ok-fg); }
.issue.done .issue-title { color: var(--muted); }
.issue-title { font-size: 15px; font-weight: 600; line-height: 1.3; }
.issue-frag { font-size: 14px; color: var(--muted); margin-top: 1px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.issue-where { font-size: 12px; color: var(--faint); padding-top: 2px; white-space: nowrap; }
.issue-detail { padding: 0 14px 12px 46px; font-size: 14px; color: var(--fg); }
.issue-detail p { margin: 0 0 8px; }
.issue-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  border: 0; border-radius: 999px; padding: 7px 12px;
  background: var(--accent-soft); color: var(--accent); font-size: 14px; font-weight: 600;
}
.pill .i { width: 17px; height: 17px; }
.pill:active { filter: brightness(.95); }
.pill.neutral { background: var(--seg); color: var(--fg); }
.checks { padding: 10px 14px 12px; border-top: .5px solid var(--line); font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.checks b { font-weight: 600; }
.checks .good { color: var(--ok-fg); }
.checks .found { color: var(--warn-fg); font-weight: 600; }
.more { width: 100%; border: 0; border-top: .5px solid var(--line); background: none; color: var(--accent); padding: 11px; font-size: 15px; }

/* ── підказки */
.callout { display: flex; gap: 10px; border-radius: 12px; padding: 11px 12px; margin-bottom: 14px; font-size: 14px; line-height: 1.4; }
.callout .i { width: 20px; height: 20px; margin-top: 1px; }
.callout.crit { background: var(--crit-bg); color: var(--crit-fg); }
.callout.warn { background: var(--warn-bg); color: var(--warn-fg); }
.callout.tip { background: var(--tip-bg); color: var(--tip-fg); }
.callout.ok { background: var(--ok-bg); color: var(--ok-fg); }

/* ── списки налаштувань */
.rows { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 14px; }
.row { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 8px 14px; border-top: .5px solid var(--line); }
.row:first-child { border-top: 0; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-size: 16px; }
.row-sub { font-size: 13px; color: var(--muted); margin-top: 1px; }
.row select {
  max-width: 55%; border: 0; background: none; color: var(--muted); font-size: 16px; text-align: right; text-align-last: right;
  -webkit-appearance: none; appearance: none; padding: 4px 0;
}
button.row { width: 100%; border-left: 0; border-right: 0; border-bottom: 0; background: none; text-align: left; }
button.row:active { background: var(--press); }
button.row .i { color: var(--faint); width: 18px; height: 18px; }
.row.danger .row-title { color: var(--crit-fg); }

.switch { -webkit-appearance: none; appearance: none; position: relative; width: 51px; height: 31px; flex: none; margin: 0; border-radius: 999px; background: var(--seg); transition: background .2s; cursor: pointer; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .2); transition: transform .2s; }
.switch:checked { background: #34c759; }
.switch:checked::after { transform: translateX(20px); }
.switch:disabled { opacity: .5; }

.seg { display: flex; gap: 2px; padding: 2px; border-radius: 9px; background: var(--seg); margin: 0 0 12px; }
.seg button { flex: 1; border: 0; border-radius: 7px; background: none; padding: 7px 6px; font-size: 14px; font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--seg-on); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); font-weight: 600; }

.levels { display: grid; gap: 8px; margin-bottom: 14px; }
.level {
  display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: start;
  border: 1.5px solid transparent; border-radius: var(--radius); padding: 12px 14px;
  background: var(--card); box-shadow: var(--shadow); text-align: left; width: 100%;
}
.level[aria-checked="true"] { border-color: var(--accent); }
.level .dot { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line2); margin-top: 1px; display: grid; place-items: center; }
.level[aria-checked="true"] .dot { border-color: var(--accent); }
.level[aria-checked="true"] .dot::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.level-title { font-size: 16px; font-weight: 600; }
.level-hint { font-size: 13.5px; color: var(--muted); margin-top: 2px; }
.level-more { font-size: 13px; color: var(--muted); margin-top: 6px; line-height: 1.4; }

/* ── файли */
.file { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: .5px solid var(--line); }
.file:first-child { border-top: 0; }
.file-icon { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; flex: none; font-size: 10px; font-weight: 700; color: #fff; background: #2b579a; }
.file-icon.txt { background: #8e8e93; }
.file-main { flex: 1; min-width: 0; }
.file-name { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-sub { font-size: 13px; color: var(--muted); }
.file .x { border: 0; background: none; color: var(--faint); padding: 6px; }
.empty { padding: 22px 16px; text-align: center; color: var(--faint); font-size: 15px; }
.result { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 14px; border: 0; border-top: .5px solid var(--line); background: none; text-align: left; }
.result:first-child { border-top: 0; }
.result[aria-selected="true"] { background: var(--accent-soft); }
.badge { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 2px 8px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.crit { background: var(--crit-bg); color: var(--crit-fg); }
.badge.warn { background: var(--warn-bg); color: var(--warn-fg); }
.badge.ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge .i { width: 14px; height: 14px; }
.log { margin: 0; padding: 12px 14px; font: 12.5px/1.45 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted); }

/* ── шари: аркуш знизу, діалог, сповіщення */
.backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .38); animation: fade .18s ease-out; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51;
  max-width: 760px; margin: 0 auto; max-height: calc(100dvh - env(safe-area-inset-top) - 24px);
  display: flex; flex-direction: column;
  background: var(--bg); border-radius: 14px 14px 0 0;
  box-shadow: 0 -4px 30px rgba(0, 0, 0, .18);
  animation: up .24s cubic-bezier(.2, .8, .2, 1);
}
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px 10px; }
.sheet-head h2 { flex: 1; margin: 0; font-size: 19px; font-weight: 700; }
.sheet-close { border: 0; background: var(--seg); color: var(--muted); border-radius: 50%; width: 30px; height: 30px; display: grid; place-items: center; }
.sheet-close .i { width: 18px; height: 18px; }
.sheet-body { overflow: auto; padding: 4px 16px calc(20px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }
.sheet-body textarea.plain { width: 100%; min-height: 40vh; border: 0; border-radius: var(--radius); padding: 12px 14px; background: var(--card); font-size: 16px; line-height: 1.45; resize: vertical; }
table.repl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.repl td { padding: 9px 12px; border-top: .5px solid var(--line); vertical-align: top; overflow-wrap: break-word; }
table.repl tr:first-child td { border-top: 0; }
table.repl td:first-child { width: 44%; color: var(--tok-fg); font-weight: 600; }
table.repl .cat { margin-top: 2px; color: var(--muted); font-size: 12.5px; font-weight: 400; }

.dialog-wrap { position: fixed; inset: 0; z-index: 61; display: grid; place-items: center; padding: 24px; }
.dialog {
  width: min(300px, 100%); border-radius: 14px; overflow: hidden;
  background: var(--card); box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
  animation: pop .18s ease-out; text-align: center;
}
.dialog-body { padding: 18px 16px 14px; }
.dialog h3 { margin: 0 0 4px; font-size: 17px; font-weight: 600; }
.dialog p { margin: 0; font-size: 13.5px; line-height: 1.38; white-space: pre-line; }
.dialog-buttons { display: flex; flex-direction: column; border-top: .5px solid var(--line); }
.dialog-buttons.two { flex-direction: row; }
.dialog-buttons button { flex: 1; border: 0; background: none; padding: 12px; font-size: 17px; color: var(--accent); border-top: .5px solid var(--line); }
.dialog-buttons button:first-child { border-top: 0; }
.dialog-buttons.two button + button { border-left: .5px solid var(--line); border-top: 0; }
.dialog-buttons button.default { font-weight: 600; }
.dialog-buttons button.danger { color: var(--crit-fg); }
.dialog-buttons button:active { background: var(--press); }

.toast {
  position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 70;
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  max-width: calc(100% - 40px); width: max-content;
  border-radius: 12px; padding: 10px 14px;
  background: var(--toast); color: #fff; font-size: 14px; line-height: 1.35; text-align: center;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.veil { position: fixed; inset: 0; z-index: 90; display: none; place-items: center; background: var(--bg); }
.veil-logo { width: 84px; height: 84px; }
body.veiled .veil { display: grid; }
body.veiled .app { filter: blur(24px); }

@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40%); opacity: .4; } }
@keyframes pop { from { transform: scale(1.08); opacity: 0; } }

/* ── довідка */
.help-sec { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 10px; overflow: hidden; }
.help-sec summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 14px; font-weight: 600; font-size: 16px; cursor: pointer; }
.help-sec summary::-webkit-details-marker { display: none; }
.help-sec summary .i { margin-left: auto; width: 18px; height: 18px; color: var(--faint); transition: transform .2s; }
.help-sec[open] summary .i { transform: rotate(90deg); }
.help-body { padding: 0 14px 12px; font-size: 15px; line-height: 1.5; }
.help-body p { margin: 0 0 10px; }
.help-body ul, .help-body ol { margin: 0 0 10px; padding-left: 20px; }
.help-body li { margin-bottom: 7px; }
.about { text-align: center; color: var(--faint); font-size: 13px; margin: 18px 0 8px; }
.about .veil-logo { width: 56px; height: 56px; display: block; margin: 0 auto 8px; }

@media (min-width: 700px) {
  h1 { font-size: 30px; }
  .doc-text, .doc-area { font-size: 16.5px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
