/*
 * Аналіз графіка — у стилі «Нічний туман» (ті самі токени, що в Каспері / MINI):
 * чорнильно-фіолетова ніч, лавандовий туман, «вгору» світиться мʼятним, «вниз» — рожевим.
 */
@font-face {
  font-family: 'Onest';
  src: url('fonts/onest-var.woff2') format('woff2');
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Unbounded';
  src: url('fonts/unbounded-700.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --color-bg: #0b0a12;
  --color-surface: #13101c;
  --color-sunken: #0e0c16;
  --color-text: #efeafb;
  --color-secondary: #9c94b8;
  --color-muted: #6f6888;
  --color-border: #262036;
  --color-accent: #c9b8ff;
  --color-accent-strong: #e2d8ff;
  --color-accent-soft: rgba(201, 184, 255, 0.14);
  --color-accent-line: rgba(201, 184, 255, 0.28);
  --color-up: #5ef2b5;
  --color-up-soft: rgba(94, 242, 181, 0.12);
  --color-up-line: rgba(94, 242, 181, 0.32);
  --color-down: #ff7a93;
  --color-down-soft: rgba(255, 122, 147, 0.12);
  --color-down-line: rgba(255, 122, 147, 0.32);
  --color-warn: #ffd27a;
  --color-warn-soft: rgba(255, 210, 122, 0.1);
  --color-warn-line: rgba(255, 210, 122, 0.28);

  --effect-fog: radial-gradient(120% 55% at 50% 0%, rgba(201, 184, 255, 0.1), transparent 70%);
  --effect-card-sheen: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0) 45%);
  --effect-cta-fill: linear-gradient(180deg, #dccfff 0%, #a98bff 100%);
  --effect-cta-glow: 0 10px 30px -10px rgba(169, 139, 255, 0.7);
  --effect-icon-pill: 0 0 18px rgba(201, 184, 255, 0.25);
  --effect-drop: radial-gradient(70% 80% at 50% 0%, rgba(201, 184, 255, 0.12), rgba(201, 184, 255, 0) 70%);
  --effect-signal-up: radial-gradient(90% 55% at 50% 0%, rgba(94, 242, 181, 0.17), rgba(94, 242, 181, 0) 70%);
  --effect-signal-down: radial-gradient(90% 55% at 50% 0%, rgba(255, 122, 147, 0.17), rgba(255, 122, 147, 0) 70%);
  --effect-signal-flat: radial-gradient(90% 55% at 50% 0%, rgba(201, 184, 255, 0.13), rgba(201, 184, 255, 0) 70%);
  --effect-signal-glow-up: 0 24px 60px -24px rgba(94, 242, 181, 0.45);
  --effect-signal-glow-down: 0 24px 60px -24px rgba(255, 122, 147, 0.45);
  --effect-orb-up: radial-gradient(circle at 50% 30%, rgba(94, 242, 181, 0.32), rgba(94, 242, 181, 0.05) 70%);
  --effect-orb-down: radial-gradient(circle at 50% 30%, rgba(255, 122, 147, 0.32), rgba(255, 122, 147, 0.05) 70%);
  --effect-orb-flat: radial-gradient(circle at 50% 30%, rgba(201, 184, 255, 0.26), rgba(201, 184, 255, 0.04) 70%);
  --effect-halo-up: 0 0 44px rgba(94, 242, 181, 0.45), 0 0 100px rgba(94, 242, 181, 0.18);
  --effect-halo-down: 0 0 44px rgba(255, 122, 147, 0.45), 0 0 100px rgba(255, 122, 147, 0.18);
  --effect-halo-flat: 0 0 36px rgba(201, 184, 255, 0.3);
  --effect-text-glow-up: 0 0 26px rgba(94, 242, 181, 0.55);
  --effect-text-glow-down: 0 0 26px rgba(255, 122, 147, 0.55);
  --effect-text-glow: 0 0 30px rgba(201, 184, 255, 0.45);

  --font-family: 'Onest', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Unbounded', 'Onest', system-ui, -apple-system, sans-serif;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-pill: 999px;

  --safe-top: max(env(safe-area-inset-top, 0px), calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px)));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));

  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--color-bg);
  color: var(--color-text);
  font: 400 15px/1.4 var(--font-family);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.fog {
  position: fixed;
  inset: 0 0 auto 0;
  height: 460px;
  background: var(--effect-fog);
  pointer-events: none;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: calc(18px + var(--safe-top)) 16px calc(28px + var(--safe-bottom));
}

/* ── Header ─────────────────────────────────────────────── */
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.brand {
  display: grid; place-items: center;
  width: 44px; height: 44px; flex: none;
  border-radius: 14px;
  background: var(--color-accent-soft);
  border: 1px solid var(--color-accent-line);
  color: var(--color-accent);
  box-shadow: var(--effect-icon-pill);
}
.brand svg { width: 24px; height: 24px; }
.top-text { flex: 1; min-width: 0; }
h1 {
  margin: 0;
  font: 700 20px/1.15 var(--font-display);
  letter-spacing: -0.01em;
}
.sub { margin: 4px 0 0; color: var(--color-secondary); font-size: 13px; }
.badge-demo {
  font-size: 11px; font-weight: 600; letter-spacing: .08em;
  padding: 4px 9px; border-radius: var(--radius-pill);
  color: var(--color-warn); background: var(--color-warn-soft); border: 1px solid var(--color-warn-line);
}
.notice {
  margin-bottom: 14px; padding: 11px 13px; border-radius: var(--radius-md);
  color: var(--color-warn); background: var(--color-warn-soft); border: 1px solid var(--color-warn-line);
  font-size: 13.5px;
}

/* ── Card + fields ──────────────────────────────────────── */
.card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 16px;
  background-color: var(--color-surface);
  background-image: var(--effect-card-sheen);
  margin-bottom: 12px;
}
.field + .field { margin-top: 16px; }
.label { font-size: 13px; font-weight: 600; margin-bottom: 9px; color: var(--color-text); }
.hint { font-weight: 400; color: var(--color-muted); }
.muted { color: var(--color-secondary); font-size: 13.5px; margin: 8px 2px 0; }

.chip {
  min-height: 40px; padding: 0 4px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-sunken);
  color: var(--color-secondary);
  font-size: 13px; font-weight: 600; white-space: nowrap;
  font-variant-numeric: tabular-nums;
  transition: background-color .15s, border-color .15s, color .15s;
}
.chip:active { opacity: .6; }
.chip[aria-checked="true"] {
  color: var(--color-text);
  background: var(--color-accent-soft);
  border-color: var(--color-accent-line);
  box-shadow: var(--effect-icon-pill);
}

/* Пара і таймфрейм: два тихі рядки над сценою */
.pickers { display: flex; flex-direction: column; gap: 14px; margin-bottom: 14px; }
.picker .label { margin-left: 2px; }
.scroller {
  display: flex; gap: 6px; overflow-x: auto; scroll-snap-type: x proximity;
  margin: 0 -16px; padding: 2px 16px 4px; scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 16px, #000 calc(100% - 24px), transparent 100%);
          mask-image: linear-gradient(90deg, transparent 0, #000 16px, #000 calc(100% - 24px), transparent 100%);
}
.scroller::-webkit-scrollbar { display: none; }
.chip.pair { flex: none; scroll-snap-align: start; min-height: 42px; padding: 0 13px; border-radius: var(--radius-pill); font-size: 14px; }
.chip.pair b { font-weight: 600; color: var(--color-text); }
.chip.pair span { font-weight: 400; color: var(--color-muted); }
.chip.pair[aria-checked="true"] span { color: var(--color-secondary); }
.chip.pair.other { color: var(--color-accent-strong); border-style: dashed; border-color: var(--color-accent-line); }
.chip.pair.other[aria-checked="true"] { border-style: solid; }
/* Мишка (Telegram Desktop, браузер): усі пари видно одразу, без гортання вбік */
@media (pointer: fine) {
  .scroller { flex-wrap: wrap; margin: 0; padding: 0; overflow: visible; -webkit-mask-image: none; mask-image: none; }
}

.seg {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px;
  padding: 3px; border-radius: var(--radius-md);
  border: 1px solid var(--color-border); background: var(--color-sunken);
}
.seg .chip { min-height: 34px; border: 0; border-radius: 9px; background: transparent; font-size: 12.5px; }
.seg .chip[aria-checked="true"] { background: var(--color-accent-soft); box-shadow: none; color: var(--color-accent-strong); }
@media (max-width: 370px) { .seg .chip { font-size: 11.5px; } }

.input {
  width: 100%; margin-top: 8px; min-height: 44px; padding: 0 13px;
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
  background: var(--color-sunken); font-size: 16px; text-transform: uppercase;
}
.input::placeholder { text-transform: none; color: var(--color-muted); }
.input:focus { outline: none; border-color: var(--color-accent-line); }
.input.invalid { border-color: var(--color-down-line); }

/* ── Сцена: видошукач для графіка ───────────────────────── */
.stage {
  --corner: var(--color-accent-line);
  position: relative; overflow: hidden;
  border-radius: 22px;
  border: 1px solid var(--color-border);
  background-color: var(--color-sunken);
  transition: border-color .3s, box-shadow .3s;
}
.stage.drag, .stage[data-state="empty"]:focus-within { border-color: var(--color-accent-line); }
.stage[data-dir="up"] { border-color: var(--color-up-line); box-shadow: var(--effect-signal-glow-up); }
.stage[data-dir="down"] { border-color: var(--color-down-line); box-shadow: var(--effect-signal-glow-down); }

/* Порожня сцена: кутові мітки видошукача замість пунктирної рамки */
.stage-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 236px; padding: 28px 22px; text-align: center; cursor: pointer; user-select: none;
  background:
    linear-gradient(var(--corner), var(--corner)) 14px 14px / 22px 2px no-repeat,
    linear-gradient(var(--corner), var(--corner)) 14px 14px / 2px 22px no-repeat,
    linear-gradient(var(--corner), var(--corner)) calc(100% - 14px) 14px / 22px 2px no-repeat,
    linear-gradient(var(--corner), var(--corner)) calc(100% - 14px) 14px / 2px 22px no-repeat,
    linear-gradient(var(--corner), var(--corner)) 14px calc(100% - 14px) / 22px 2px no-repeat,
    linear-gradient(var(--corner), var(--corner)) 14px calc(100% - 14px) / 2px 22px no-repeat,
    linear-gradient(var(--corner), var(--corner)) calc(100% - 14px) calc(100% - 14px) / 22px 2px no-repeat,
    linear-gradient(var(--corner), var(--corner)) calc(100% - 14px) calc(100% - 14px) / 2px 22px no-repeat,
    var(--effect-drop);
}
.stage-empty:active { --corner: var(--color-accent); }
.stage-plus {
  display: grid; place-items: center; width: 60px; height: 60px; margin-bottom: 6px;
  border-radius: 18px; color: var(--color-accent);
  background: var(--color-accent-soft); border: 1px solid var(--color-accent-line); box-shadow: var(--effect-icon-pill);
}
.stage-plus svg { width: 30px; height: 30px; }
.stage-title { font: 700 17px/1.25 var(--font-display); letter-spacing: -0.005em; }
.stage-sub { color: var(--color-secondary); font-size: 13.5px; max-width: 300px; text-wrap: balance; }

/* Скриншот на сцені */
.shot { position: relative; }
.shot img {
  display: block; width: 100%; aspect-ratio: var(--shot-ratio, 4 / 3); max-height: 58vh; min-height: 200px;
  object-fit: contain; background: #07060c;
  transition: filter .35s;
}
.stage[data-state="scanning"] .shot img { filter: brightness(.72) saturate(.85); }
.stage[data-state="verdict"] .shot img { filter: brightness(.82); }

.shot-grid {
  position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s;
  background:
    repeating-linear-gradient(90deg, rgba(201, 184, 255, .09) 0 1px, transparent 1px 44px),
    repeating-linear-gradient(0deg, rgba(201, 184, 255, .07) 0 1px, transparent 1px 44px);
}
.stage[data-state="scanning"] .shot-grid { opacity: 1; }

/* Промінь іде зліва направо і довше тримається біля правого краю: там «зараз» на графіку */
.shot-beam {
  position: absolute; top: 0; bottom: 0; left: 0; width: 34%; pointer-events: none; opacity: 0;
  background: linear-gradient(90deg, rgba(201, 184, 255, 0) 0%, rgba(201, 184, 255, .16) 70%, rgba(226, 216, 255, .55) 98%, rgba(226, 216, 255, 0) 100%);
}
.stage[data-state="scanning"] .shot-beam { opacity: 1; animation: sweep 1.7s cubic-bezier(.45, .05, .35, 1) infinite; }
@keyframes sweep {
  0% { transform: translateX(-100%); }
  70% { transform: translateX(195%); }
  100% { transform: translateX(195%); opacity: 0; }
}

.clock {
  position: absolute; top: 12px; left: 12px; display: flex; align-items: baseline; gap: 6px;
  padding: 7px 12px 7px 11px; border-radius: var(--radius-pill);
  background: rgba(11, 10, 18, .78); border: 1px solid var(--color-border);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  font-size: 12.5px; color: var(--color-secondary); opacity: 0; transition: opacity .2s;
}
.clock b { font: 700 15px/1 var(--font-display); color: var(--color-text); font-variant-numeric: tabular-nums; }
.stage[data-state="scanning"] .clock, .clock.done { opacity: 1; }
.stage[data-state="empty"] .clock, .stage[data-state="ready"] .clock:not(.done) { opacity: 0; }
.stage[data-state="scanning"] .clock::before {
  content: ''; align-self: center; width: 7px; height: 7px; border-radius: 50%;
  background: var(--color-accent); box-shadow: 0 0 10px var(--color-accent); animation: blink 1s ease-in-out infinite;
}
@keyframes blink { 50% { opacity: .25; } }

.shot-x {
  position: absolute; top: 10px; right: 10px; display: grid; place-items: center;
  width: 36px; height: 36px; padding: 0; border-radius: 50%;
  border: 1px solid var(--color-border); background: rgba(11, 10, 18, .78); color: var(--color-secondary);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.shot-x svg { width: 16px; height: 16px; }
.shot-x:active { opacity: .6; }

/* Вердикт ставиться просто на графік */
.verdict {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px;
  padding: 44px 16px 16px;
  background: linear-gradient(180deg, rgba(11, 10, 18, 0) 0%, rgba(11, 10, 18, .82) 38%, rgba(11, 10, 18, .96) 100%);
}
.v-arrow { display: grid; place-items: center; width: 58px; height: 58px; border-radius: 50%; }
.v-arrow svg { width: 28px; height: 28px; }
.verdict.up .v-arrow { color: var(--color-up); background: var(--effect-orb-up); border: 1.5px solid var(--color-up-line); box-shadow: var(--effect-halo-up); }
.verdict.down .v-arrow { color: var(--color-down); background: var(--effect-orb-down); border: 1.5px solid var(--color-down-line); box-shadow: var(--effect-halo-down); }
.verdict.flat .v-arrow { color: var(--color-accent); background: var(--effect-orb-flat); border: 1.5px solid var(--color-accent-line); box-shadow: var(--effect-halo-flat); }
.v-text { min-width: 0; }
.v-word { font: 700 38px/1 var(--font-display); letter-spacing: -0.02em; }
.verdict.up .v-word { color: var(--color-up); text-shadow: var(--effect-text-glow-up); }
.verdict.down .v-word { color: var(--color-down); text-shadow: var(--effect-text-glow-down); }
.verdict.flat .v-word { color: var(--color-accent-strong); text-shadow: var(--effect-text-glow); font-size: 26px; letter-spacing: 0; }
.v-cap { margin-top: 6px; font-size: 13px; color: var(--color-secondary); line-height: 1.3; }

.ring { position: relative; width: 64px; height: 64px; }
.ring svg { width: 64px; height: 64px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 5; }
.ring-track { stroke: rgba(255, 255, 255, .08); }
.ring-fill { stroke: var(--color-accent); stroke-linecap: round; }
.ring.up .ring-fill { stroke: var(--color-up); }
.ring.down .ring-fill { stroke: var(--color-down); }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font: 700 17px/1 var(--font-display); font-variant-numeric: tabular-nums; }

.verdict.stamp { animation: stamp-in .42s cubic-bezier(.2, .9, .25, 1.15) both; }
.verdict.stamp .ring-fill { animation: ring-in .9s .12s cubic-bezier(.3, .7, .2, 1) both; }
@keyframes stamp-in {
  0% { opacity: 0; transform: translateY(18px) scale(1.06); }
  100% { opacity: 1; transform: none; }
}
@keyframes ring-in { from { stroke-dasharray: 0 999; } }

@media (max-width: 360px) {
  .verdict { gap: 10px; padding-left: 12px; padding-right: 12px; }
  .v-arrow { width: 48px; height: 48px; }
  .v-word { font-size: 32px; }
}

/* ── Кнопки ─────────────────────────────────────────────── */
.actions { display: flex; gap: 8px; margin-top: 12px; }
.actions .btn-primary { flex: 1; }
.actions .btn-soft { flex: none; min-height: 52px; padding: 0 16px; border-radius: var(--radius-lg); font-size: 14px; }
.btn-primary {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 52px; border: 0; border-radius: var(--radius-lg);
  background-color: var(--color-accent); background-image: var(--effect-cta-fill);
  color: var(--color-bg); font-size: 16px; font-weight: 600;
  box-shadow: var(--effect-cta-glow);
}
.btn-primary:active:not(:disabled) { opacity: .6; }
.btn-primary:disabled { opacity: .35; box-shadow: none; cursor: default; }
.btn-primary.is-cancel { background: var(--color-surface); color: var(--color-secondary); border: 1px solid var(--color-border); box-shadow: none; }
.btn-soft {
  min-height: 34px; padding: 0 12px; border-radius: var(--radius-md);
  border: 1px solid var(--color-accent-line); background: var(--color-accent-soft);
  font-size: 13px; font-weight: 600;
}
.btn-icon {
  display: grid; place-items: center; width: 34px; height: 34px; padding: 0;
  border: 0; border-radius: var(--radius-pill); background: transparent; color: var(--color-secondary);
}
.btn-icon svg { width: 18px; height: 18px; }
.btn-soft:active, .btn-icon:active { opacity: .6; }
.btn-soft:disabled, .btn-icon:disabled { opacity: .35; }
.btn-link {
  border: 0; background: none; padding: 4px 0; font-size: 13px; font-weight: 600;
  color: var(--color-secondary); text-decoration: underline; text-underline-offset: 3px;
}

.status { margin: 12px 2px 0; color: var(--color-secondary); font-size: 13.5px; }
.error {
  margin-top: 12px; padding: 12px 13px; border-radius: var(--radius-md);
  color: var(--color-down); background: var(--color-down-soft); border: 1px solid var(--color-down-line); font-size: 14px;
}

/* ── Розбір ─────────────────────────────────────────────── */
.result {
  margin-top: 16px; padding: 16px;
  border: 1px solid var(--color-border); border-radius: var(--radius-xl);
  background-color: var(--color-surface); background-image: var(--effect-card-sheen);
}
.r-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding-bottom: 14px; border-bottom: 1px solid var(--color-border); }
.r-pill { display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px 5px 8px; border-radius: var(--radius-pill); font-size: 12.5px; font-weight: 600; }
.r-pill svg { width: 14px; height: 14px; }
.r-pill.up { color: var(--color-up); background: var(--color-up-soft); border: 1px solid var(--color-up-line); }
.r-pill.down { color: var(--color-down); background: var(--color-down-soft); border: 1px solid var(--color-down-line); }
.r-pill.flat { color: var(--color-accent-strong); background: var(--color-accent-soft); border: 1px solid var(--color-accent-line); }
.r-head-title { font: 700 16px/1.2 var(--font-display); }
.r-head-meta { order: 9; flex-basis: 100%; color: var(--color-muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.r-head-conf { margin-left: auto; color: var(--color-muted); font-size: 12.5px; }
.r-head-conf b { font: 700 16px/1 var(--font-display); color: var(--color-text); font-variant-numeric: tabular-nums; }

.r-note {
  margin-top: 14px; padding: 10px 12px; border-radius: var(--radius-md); font-size: 13.5px;
  color: var(--color-warn); background: var(--color-warn-soft); border: 1px solid var(--color-warn-line);
}
.r-note ul { margin: 4px 0 0; padding-left: 18px; }

.r-section { margin-top: 18px; }
.r-section h3 { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--color-secondary); }
.r-section p { margin: 0; }
.r-lead { font-size: 15.5px; line-height: 1.55; max-width: 62ch; }

/* Рівні — як на графіку: опір зверху, підтримка знизу */
.r-levels { display: flex; flex-direction: column; gap: 6px; }
.lv { padding: 10px 12px 10px 14px; border-radius: var(--radius-md); background: var(--color-sunken); border: 1px solid var(--color-border); border-left-width: 3px; }
.lv h4 { margin: 0 0 4px; font-size: 12.5px; font-weight: 600; }
.lv-res { border-left-color: var(--color-down); }
.lv-res h4 { color: var(--color-down); }
.lv-sup { border-left-color: var(--color-up); }
.lv-sup h4 { color: var(--color-up); }
.lv .r-list { font-size: 14px; }
.lv .muted { margin: 0; }

.r-list { margin: 0; padding: 0; list-style: none; }
.r-list li { position: relative; padding-left: 14px; }
.r-list li::before { content: ""; position: absolute; left: 0; top: .62em; width: 6px; height: 6px; border-radius: 50%; background: var(--color-accent); opacity: .7; }
.r-list li + li { margin-top: 5px; }
.r-quality { display: flex; gap: 9px; align-items: baseline; }
.q-tag { flex: none; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: var(--radius-pill); }
.q-good { color: var(--color-up); background: var(--color-up-soft); border: 1px solid var(--color-up-line); }
.q-fair { color: var(--color-warn); background: var(--color-warn-soft); border: 1px solid var(--color-warn-line); }
.q-poor { color: var(--color-down); background: var(--color-down-soft); border: 1px solid var(--color-down-line); }
.q-text { color: var(--color-secondary); font-size: 14px; }

details.r-details { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--color-border); }
details.r-details summary { display: flex; justify-content: space-between; cursor: pointer; list-style: none; font-weight: 600; font-size: 14px; }
details.r-details summary::-webkit-details-marker { display: none; }
details.r-details summary::after { content: "+"; color: var(--color-muted); font-size: 18px; line-height: 1; }
details.r-details[open] summary::after { content: "−"; }
.r-dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 14px; margin: 12px 0 0; font-size: 14px; }
.r-dl dt { color: var(--color-muted); }
.r-dl dd { margin: 0; }
.r-conf-note { margin: 14px 0 0; font-size: 12px; color: var(--color-muted); }
.r-foot { margin-top: 6px; font-size: 11.5px; color: var(--color-muted); font-variant-numeric: tabular-nums; }

/* Каркас, поки доходить обґрунтування */
.result.loading .r-head { border-bottom: 0; padding-bottom: 10px; }
.result.loading .r-head-title { font: 600 14px/1.3 var(--font-family); color: var(--color-secondary); }
.skel { height: 12px; margin-top: 10px; border-radius: 6px; background: linear-gradient(90deg, var(--color-sunken) 0%, #1c1729 50%, var(--color-sunken) 100%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.skel.w90 { width: 90%; } .skel.w75 { width: 75%; } .skel.w60 { width: 60%; }
.skel-row { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; }
.skel.box { height: 46px; margin: 0; border-radius: var(--radius-md); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Історія ────────────────────────────────────────────── */
.history { margin-top: 26px; }
.history-head { display: flex; justify-content: space-between; align-items: center; padding: 0 2px; }
h2 { margin: 0; font: 700 15px/1.2 var(--font-display); }
.history-list {
  list-style: none; margin: 10px 0 0; padding: 0; overflow: hidden;
  border: 1px solid var(--color-border); border-radius: var(--radius-xl);
  background-color: var(--color-surface); background-image: var(--effect-card-sheen);
}
.history-list:empty { display: none; }
.history-list li + li { border-top: 1px solid var(--color-border); }
.h-item {
  display: grid; grid-template-columns: 34px 1fr auto auto; gap: 12px; align-items: center;
  width: 100%; min-height: 58px; padding: 10px 14px;
  border: 0; background: transparent; text-align: left;
}
.h-item:active { opacity: .6; }
.h-item.active { background: var(--color-accent-soft); }
.h-dir { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; }
.h-dir svg { width: 16px; height: 16px; }
.h-dir.up { color: var(--color-up); background: var(--color-up-soft); border: 1px solid var(--color-up-line); }
.h-dir.down { color: var(--color-down); background: var(--color-down-soft); border: 1px solid var(--color-down-line); }
.h-dir.flat { color: var(--color-secondary); background: var(--color-sunken); border: 1px solid var(--color-border); }
.h-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.h-main b { font-size: 14.5px; font-weight: 600; }
.h-main span { color: var(--color-muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.h-conf { font: 700 14px/1 var(--font-display); font-variant-numeric: tabular-nums; color: var(--color-secondary); }
.h-item.up .h-conf { color: var(--color-up); }
.h-item.down .h-conf { color: var(--color-down); }
.h-time { color: var(--color-muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.disclaimer { margin: 22px 2px 0; color: var(--color-muted); font-size: 11.5px; line-height: 1.5; }

@media (prefers-reduced-motion: reduce) {
  .stage[data-state="scanning"] .shot-beam { animation: none; opacity: .5; transform: translateX(195%); }
  .verdict.stamp, .verdict.stamp .ring-fill, .skel, .stage[data-state="scanning"] .clock::before { animation: none; }
}

/* ── Desktop: дві колонки ───────────────────────────────── */
@media (min-width: 920px) {
  .app { max-width: 1080px; padding-top: calc(32px + var(--safe-top)); }
  .layout { display: grid; grid-template-columns: 480px 1fr; gap: 28px; align-items: start; }
  .col-input { position: sticky; top: 20px; }
  .result { margin-top: 0; }
  .scroller { flex-wrap: wrap; margin: 0; padding: 0; -webkit-mask-image: none; mask-image: none; }
}

/* ══ Вкладки, «Статистика», адмінка ═══════════════════════════ */
body.has-tabbar .app { padding-bottom: calc(96px + var(--safe-bottom)); }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 2px 12px; }
.view-title { margin: 0; font: 700 18px/1.2 var(--font-display); }
.view-intro { margin: 0 2px 14px; color: var(--color-secondary); white-space: pre-line; }
.center { text-align: center; }
.small { font-size: 12.5px; }
.block { display: block; margin-top: 2px; }
.pad { padding: 16px; margin: 0; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center; gap: 4px;
  padding: 8px max(12px, env(safe-area-inset-right, 0px)) calc(8px + var(--safe-bottom)) max(12px, env(safe-area-inset-left, 0px));
  background: rgba(11, 10, 18, 0.92); border-top: 1px solid var(--color-border);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.tabbar button {
  flex: 1; max-width: 160px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-height: 52px; padding: 6px 4px; border: 0; border-radius: var(--radius-lg); background: transparent;
  color: var(--color-muted); font-size: 12px; font-weight: 600;
}
.tabbar svg { width: 22px; height: 22px; }
.tabbar button[aria-current="page"] { color: var(--color-accent-strong); background: var(--color-accent-soft); }
.tabbar button:active { opacity: .6; }

/* Без доступу до аналізу */
.locked { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 26px 18px; }
.locked h2 { margin: 4px 0 0; font: 700 18px/1.25 var(--font-display); text-wrap: balance; }
.locked p { margin: 0 0 6px; color: var(--color-secondary); white-space: pre-line; max-width: 380px; }
.locked-icon { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 999px; color: var(--color-accent); background: var(--color-accent-soft); box-shadow: var(--effect-icon-pill); }
.locked-icon svg { width: 26px; height: 26px; }
.locked .btn-soft { min-height: 44px; padding: 0 18px; }
.limit-note { margin: 0 2px 12px; padding: 9px 12px; border-radius: var(--radius-md); font-size: 13.5px; color: var(--color-secondary); background: var(--color-surface); border: 1px solid var(--color-border); }
.limit-note.empty { color: var(--color-warn); background: var(--color-warn-soft); border-color: var(--color-warn-line); }

/* Пости «Статистики» */
.posts { display: flex; flex-direction: column; gap: 12px; }
.post { margin: 0; display: flex; flex-direction: column; gap: 10px; }
.post-photo { margin: -16px -16px 2px; border-radius: var(--radius-xl) var(--radius-xl) 0 0; overflow: hidden; min-height: 120px; background: var(--color-sunken); }
.post-photo img { display: block; width: 100%; height: auto; }
.post-title { margin: 0; font: 700 17px/1.3 var(--font-display); text-wrap: balance; }
.post-body { margin: 0; white-space: pre-line; color: var(--color-text); font-size: 15px; line-height: 1.55; overflow-wrap: anywhere; }
.inline-link { color: var(--color-accent); text-underline-offset: 3px; }
.post-btn { min-height: 46px; font-size: 15px; }
.post-admin { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 10px; border-top: 1px solid var(--color-border); }
.post-admin .muted { margin: 0; }

.pill { display: inline-block; align-self: flex-start; padding: 2px 9px; margin-left: 6px; border-radius: var(--radius-pill); font-size: 11.5px; font-weight: 600; color: var(--color-accent); background: var(--color-accent-soft); border: 1px solid var(--color-accent-line); vertical-align: 1px; }
.post > .pill { margin-left: 0; }
.pill.warn { color: var(--color-warn); background: var(--color-warn-soft); border-color: var(--color-warn-line); }
.pill.up { color: var(--color-up); background: var(--color-up-soft); border-color: var(--color-up-line); }
.pill.down { color: var(--color-down); background: var(--color-down-soft); border-color: var(--color-down-line); }

/* Форми (редактор поста, тексти, налаштування) */
.editor { display: flex; flex-direction: column; gap: 14px; }
.editor-head { display: flex; justify-content: space-between; align-items: center; }
.editor-head h3 { margin: 0; font: 700 16px/1.2 var(--font-display); }
.f { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.card > .f { margin-top: 14px; }
.f-label { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; font-weight: 600; }
.f-count, .f-meta { color: var(--color-muted); font-weight: 400; font-variant-numeric: tabular-nums; white-space: nowrap; }
.f-state { color: var(--color-muted); }
.f-input {
  width: 100%; min-height: 44px; padding: 10px 13px;
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
  background: var(--color-sunken); color: var(--color-text); font: inherit; font-size: 16px;
}
.f-input:focus { outline: none; border-color: var(--color-accent-line); }
.f-area { resize: vertical; min-height: 96px; line-height: 1.45; }
.f-num { max-width: 140px; }
.f .btn-link { align-self: flex-start; }
.f-row { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 520px) { .f-row { grid-template-columns: 1fr 1fr; align-items: end; } }
.f-photo { display: flex; flex-direction: column; gap: 10px; }
.f-photo img { display: block; width: 100%; max-height: 260px; object-fit: contain; border-radius: var(--radius-lg); background: var(--color-sunken); border: 1px solid var(--color-border); }
.f-photo-actions { display: flex; align-items: center; gap: 14px; }
.btn-danger { min-height: 44px; border-radius: var(--radius-lg); border: 1px solid var(--color-down-line); background: var(--color-down-soft); color: var(--color-down); font-weight: 600; }
.btn-soft.wide { width: 100%; min-height: 46px; margin-top: 10px; }
#view-admin .btn-primary { margin-top: 4px; }

.switch, .radio { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; }
.switch-input, .radio-input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-ui { flex: none; position: relative; width: 46px; height: 28px; border-radius: 999px; background: var(--color-border); transition: background .15s; }
.switch-ui::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--color-secondary); transition: transform .15s, background .15s; }
.switch-input:checked + .switch-ui { background: var(--color-accent); }
.switch-input:checked + .switch-ui::after { transform: translateX(18px); background: var(--color-bg); }
.switch-input:focus-visible + .switch-ui, .radio-input:focus-visible + .radio-ui { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.radio { padding: 12px 0; }
.radio + .radio { border-top: 1px solid var(--color-border); }
.radio-ui { flex: none; width: 22px; height: 22px; margin-top: 1px; border-radius: 50%; border: 2px solid var(--color-muted); }
.radio-input:checked + .radio-ui { border: 7px solid var(--color-accent); }

/* Адмінка */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; min-height: 38px; padding: 0 14px; border-radius: var(--radius-pill); border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-secondary); font-size: 14px; font-weight: 600; }
.tab[aria-selected="true"] { color: var(--color-bg); background: var(--color-accent); border-color: var(--color-accent); }
.seg-3 { grid-template-columns: repeat(3, 1fr); margin-bottom: 16px; }
.block-title { margin: 18px 2px 10px; font: 700 14px/1.3 var(--font-display); letter-spacing: .01em; }
.card > .block-title:first-child { margin-top: 0; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
@media (min-width: 640px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.tile { padding: 12px 14px; border-radius: var(--radius-lg); background: var(--color-surface); border: 1px solid var(--color-border); min-width: 0; }
.tile b { display: block; font: 700 22px/1.1 var(--font-display); font-variant-numeric: tabular-nums; }
.tile span { display: block; margin-top: 5px; font-size: 12.5px; color: var(--color-secondary); line-height: 1.3; }
.tile.accent { background: var(--color-accent-soft); border-color: var(--color-accent-line); }
.tile.accent b { color: var(--color-accent-strong); }
.hbars { display: flex; flex-direction: column; gap: 9px; }
.hbar { display: grid; grid-template-columns: minmax(70px, 38%) 1fr auto; align-items: center; gap: 10px; font-size: 13.5px; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--color-secondary); }
.hbar-track { height: 8px; border-radius: 8px; background: var(--color-sunken); overflow: hidden; }
.hbar-fill { display: block; height: 100%; border-radius: 8px; background: var(--color-accent); }
.hbar-fill.up { background: var(--color-up); }
.hbar-fill.down { background: var(--color-down); }
.hbar-value { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; }
.vchart { display: flex; align-items: stretch; gap: 4px; height: 150px; padding-top: 4px; }
.vcol { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; }
.vbar { width: 100%; max-width: 28px; min-height: 2px; border-radius: 5px 5px 2px 2px; background: linear-gradient(180deg, var(--color-accent), rgba(201, 184, 255, .35)); }
.vval { font-size: 11px; color: var(--color-secondary); font-variant-numeric: tabular-nums; }
.vday { font-size: 10.5px; color: var(--color-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.card.flush { padding: 0; overflow: hidden; }
.person + .person { border-top: 1px solid var(--color-border); }
.person-head { display: flex; flex-direction: column; gap: 4px; width: 100%; padding: 13px 16px; border: 0; background: transparent; text-align: left; }
.person-head:active { background: var(--color-sunken); }
.person-name { font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
.person-nick { color: var(--color-secondary); font-weight: 400; }
.person-facts { color: var(--color-muted); font-size: 12.5px; line-height: 1.4; }
.person-more { padding: 0 16px 14px; }
.person-more .r-dl { margin-top: 0; font-size: 13px; }
.person-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.person-actions .btn-soft { min-height: 40px; }

.toast {
  position: fixed; left: 50%; bottom: calc(86px + var(--safe-bottom)); transform: translateX(-50%); z-index: 30;
  max-width: calc(100vw - 32px); padding: 11px 16px; border-radius: var(--radius-lg);
  background: #241e35; border: 1px solid var(--color-accent-line); color: var(--color-text); font-size: 14px; font-weight: 600;
  box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .8);
}
.toast.error { border-color: var(--color-down-line); color: var(--color-down); }
@media (min-width: 920px) {
  #view-stats, #view-admin { max-width: 640px; margin: 0 auto; }
}
