/* keyprint — інтерфейс прототипу.
   Ідея: вимірювальний прилад на світлому папері. Один акцент — синій слід ритму.
   Структура кодується лініями-волосинками, не картками й тінями. */

:root {
  --paper: #f4f6f8;
  --paper-2: #ffffff;
  --ink: #1a2330;
  --ink-2: #4a5563;
  --muted: #7a8694;
  --line: #d7dde4;
  --line-2: #eaeef2;
  --signal: #2b4acb;
  --signal-soft: #e3e8fb;
  --accept: #1f7a4d;
  --verify: #a86a0b;
  --deny: #b5362b;
  --accept-soft: #e1f1e8;
  --verify-soft: #f7ecd6;
  --deny-soft: #f6e1de;
  --sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Instrument Serif", Georgia, "Times New Roman", serif;
  --rail: 232px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.5 var(--sans);
  font-variant-numeric: tabular-nums;
  min-height: 100vh;
}
a { color: var(--signal); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

h1, h2, h3 { margin: 0; font-weight: 500; line-height: 1.15; }
h1 { font: 400 2.25rem/1.1 var(--serif); letter-spacing: -0.01em; }
h2 { font-size: 1.125rem; font-weight: 600; }
h3 { font-size: 0.95rem; font-weight: 600; color: var(--ink-2); }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- словомарка: слід ритму як підпис ---------- */
.wordmark {
  display: inline-flex; align-items: center; gap: 0.6rem;
  color: var(--ink); font-weight: 600; font-size: 1.05rem; letter-spacing: 0.01em;
}
.wordmark:hover { text-decoration: none; }
.wordmark svg { width: 54px; height: 18px; overflow: visible; }
.wordmark svg path { fill: none; stroke: var(--signal); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- сторінки входу та реєстрації ---------- */
.auth {
  max-width: 440px; margin: 0 auto; padding: 9vh 1.25rem 4rem;
}
.auth .top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 3.2rem; }
.auth nav a { color: var(--ink-2); margin-left: 1.25rem; font-size: 0.95rem; }
.auth nav a[aria-current] { color: var(--ink); border-bottom: 1.5px solid var(--ink); padding-bottom: 2px; }
.auth h1 { margin-bottom: 0.5rem; }
.auth .lede { color: var(--ink-2); max-width: 36ch; margin-bottom: 2.2rem; }

.field { display: block; margin-top: 1.1rem; }
.field > span { display: block; font-size: 0.9rem; color: var(--ink-2); margin-bottom: 0.35rem; }
.field input {
  width: 100%; padding: 0.7rem 0.8rem;
  font: 500 1.05rem var(--sans); letter-spacing: 0.02em;
  color: var(--ink); background: var(--paper-2);
  border: 1px solid var(--line); border-radius: 4px;
}
.field input:focus { border-color: var(--signal); outline: none; box-shadow: 0 0 0 3px var(--signal-soft); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.7rem 1.3rem; border-radius: 4px; cursor: pointer;
  font: 600 0.98rem var(--sans); border: 1px solid transparent;
  color: #fff; background: var(--signal);
}
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: 0.55; cursor: default; filter: none; }
.btn.quiet { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.quiet:hover { border-color: var(--ink-2); filter: none; }
.btn.danger { background: var(--deny); }
.actions { display: flex; gap: 0.6rem; align-items: center; margin-top: 1.4rem; flex-wrap: wrap; }

/* Слід ритму — головний елемент. Вісь часу зліва направо, висота піка = утримання клавіші. */
.trace {
  margin-top: 1.4rem; padding: 0.9rem 0 0.4rem;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.trace svg { display: block; width: 100%; height: 112px; overflow: visible; }
.trace .base { stroke: var(--line); stroke-width: 1; }
.trace .grid { stroke: var(--line-2); stroke-width: 1; }
.trace .spike { stroke: var(--signal); stroke-width: 2; stroke-linecap: round; fill: none; }
.trace .spike.correction { stroke: var(--deny); }
.trace .gap { stroke: var(--signal); stroke-width: 1; opacity: 0.45; }
.trace .hint { fill: var(--muted); font-size: 13px; }
.trace .axis { fill: var(--muted); font-size: 11px; }
.trace-caption { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.82rem; margin-top: 0.4rem; }

/* Шкала рішення на справжніх порогах моделі */
.meter { margin-top: 1.4rem; }
.meter .track { position: relative; height: 10px; border-radius: 5px; overflow: hidden; display: flex; }
.meter .track i { display: block; height: 100%; }
.meter .track .z-deny { background: var(--deny-soft); }
.meter .track .z-verify { background: var(--verify-soft); }
.meter .track .z-accept { background: var(--accept-soft); }
.meter .needle {
  position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink);
  transform: translateX(-1px); transition: left 0.45s ease;
}
.meter .ticks { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--muted); margin-top: 0.35rem; }
.meter .reading { margin-top: 0.3rem; font-size: 0.95rem; }

.status { margin-top: 1.4rem; padding: 0.9rem 1rem; border-left: 3px solid var(--muted); background: var(--paper-2); border-radius: 0 4px 4px 0; }
.status.accept { border-left-color: var(--accept); }
.status.verify { border-left-color: var(--verify); }
.status.deny { border-left-color: var(--deny); }
.status b { display: block; font-weight: 600; }
.status p { color: var(--ink-2); font-size: 0.92rem; margin-top: 0.15rem; }

/* Дві шкали оцінювача пароля */
.scales { margin-top: 1.3rem; display: grid; gap: 0.8rem; }
.scale .row { display: flex; justify-content: space-between; font-size: 0.9rem; color: var(--ink-2); }
.scale .row b { color: var(--ink); font-weight: 600; }
.scale .bar { height: 6px; margin-top: 0.35rem; background: var(--line-2); border-radius: 3px; overflow: hidden; }
.scale .bar i { display: block; height: 100%; background: var(--signal); transition: width 0.35s ease; }
.scale.guess .bar i { background: var(--ink-2); }
.scale .note { font-size: 0.82rem; color: var(--muted); margin-top: 0.3rem; }

/* Зразки реєстрації — п'ять мініатюр сліду */
.samples { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.6rem; margin-top: 1.4rem; }
.sample { height: 48px; border: 1px dashed var(--line); border-radius: 4px; background: var(--paper-2); }
.sample.filled { border-style: solid; border-color: var(--signal); }
.sample svg { width: 100%; height: 100%; display: block; }
.sample svg path { fill: none; stroke: var(--signal); stroke-width: 1.5; stroke-linecap: round; }
.samples-caption { color: var(--muted); font-size: 0.85rem; margin-top: 0.4rem; }

/* ---------- застосунок з лівою рейкою ---------- */
.app { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100vh; }
.rail {
  padding: 1.6rem 1.4rem; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 2rem; position: sticky; top: 0; height: 100vh;
}
.rail nav { display: flex; flex-direction: column; gap: 0.15rem; }
.rail nav a {
  color: var(--ink-2); padding: 0.45rem 0.6rem; border-radius: 4px; font-size: 0.95rem;
}
.rail nav a:hover { background: var(--line-2); text-decoration: none; color: var(--ink); }
.rail nav a[aria-current] { color: var(--ink); background: var(--paper-2); border: 1px solid var(--line); }
.rail .foot { margin-top: auto; font-size: 0.85rem; color: var(--muted); display: grid; gap: 0.3rem; }
.rail .foot a { color: var(--ink-2); }
main.content { padding: 2rem 2.4rem 4rem; max-width: 1100px; min-width: 0; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1.6rem; flex-wrap: wrap; }
.page-head h1 { font-size: 2rem; }
.page-head .meta { color: var(--muted); font-size: 0.9rem; }

section.block { padding: 1.4rem 0; border-top: 1px solid var(--line); }
section.block:first-of-type { border-top: 0; padding-top: 0; }
.block-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: 0.9rem; flex-wrap: wrap; }
.block-head .legend { display: flex; gap: 1rem; font-size: 0.85rem; color: var(--muted); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
@media (max-width: 760px) { .two-col { grid-template-columns: 1fr; } }

/* Показники — рядок чисел із підписами, розділений лініями */
.stats { display: flex; flex-wrap: wrap; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-bottom: 1.6rem; }
.stat { flex: 1 1 140px; padding: 0.9rem 1rem 0.9rem 0; border-right: 1px solid var(--line-2); margin-right: 1rem; }
.stat:last-child { border-right: 0; margin-right: 0; }
.stat b { display: block; font: 400 1.9rem/1.1 var(--serif); }
.stat span { color: var(--muted); font-size: 0.85rem; }
.stat .accept { color: var(--accept); } .stat .verify { color: var(--verify); } .stat .deny { color: var(--deny); }

/* Чіпи рішень: колір + слово, ніколи лише колір */
.chip { display: inline-block; padding: 0.08rem 0.5rem; border-radius: 3px; font-size: 0.8rem; font-weight: 600; }
.chip.accept { background: var(--accept-soft); color: var(--accept); }
.chip.verify, .chip.step_up { background: var(--verify-soft); color: var(--verify); }
.chip.deny { background: var(--deny-soft); color: var(--deny); }
.chip.neutral { background: var(--line-2); color: var(--ink-2); }

/* Таблиці — пласкі */
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th { text-align: left; font-weight: 500; color: var(--muted); padding: 0.5rem 0.6rem 0.5rem 0; border-bottom: 1px solid var(--line); }
td { padding: 0.5rem 0.6rem 0.5rem 0; border-bottom: 1px solid var(--line-2); vertical-align: top; }
td.num, th.num { text-align: right; }
tr.hl td { background: var(--signal-soft); }

/* Графіки */
.chart svg { width: 100%; height: auto; display: block; }
.chart text { font-family: var(--sans); font-size: 11px; fill: var(--muted); }
.chart .axis-line { stroke: var(--line); }
.chart .thr { stroke: var(--ink-2); stroke-dasharray: 3 4; }
.empty { color: var(--muted); font-size: 0.92rem; padding: 0.8rem 0; }

.hbar { display: grid; grid-template-columns: 200px 1fr auto; align-items: center; gap: 0.8rem; margin: 0.45rem 0; font-size: 0.9rem; }
.hbar .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { height: 8px; background: var(--line-2); border-radius: 4px; overflow: hidden; display: flex; }
.hbar .track i { display: block; height: 100%; background: var(--signal); }
.hbar .val { text-align: right; min-width: 3.5rem; white-space: nowrap; }
.hbar.win .label { color: var(--accept); font-weight: 600; }
.hbar.win .track i { background: var(--accept); }
@media (max-width: 640px) { .hbar { grid-template-columns: 1fr auto; } .hbar .label { grid-column: 1 / -1; } }

.alert { padding: 0.6rem 0.8rem; margin: 0.3rem 0; border-radius: 4px; font-size: 0.9rem; border-left: 3px solid; }
.alert.alert { background: var(--deny-soft); border-color: var(--deny); }
.alert.warn { background: var(--verify-soft); border-color: var(--verify); }
.alert.ok { background: var(--accept-soft); border-color: var(--accept); }

/* Перемикач моделей — сегментований, не кнопки-картки */
.segmented { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; background: var(--paper-2); }
.segmented button {
  padding: 0.5rem 0.9rem; border: 0; border-right: 1px solid var(--line); background: transparent;
  font: 500 0.9rem var(--sans); color: var(--ink-2); cursor: pointer;
}
.segmented button:last-child { border-right: 0; }
.segmented button.on { background: var(--signal); color: #fff; }
.segmented button:hover:not(.on) { background: var(--line-2); }

/* Форми керування симуляцією */
.controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.9rem 1.2rem; }
.controls .field { margin-top: 0; }
.controls select, .controls input {
  width: 100%; padding: 0.5rem 0.6rem; font: 500 0.95rem var(--sans);
  color: var(--ink); background: var(--paper-2); border: 1px solid var(--line); border-radius: 4px;
}
fieldset.group { border: 1px solid var(--line); border-radius: 4px; padding: 0.6rem 0.9rem 0.7rem; margin: 0; }
fieldset.group legend { font-size: 0.85rem; color: var(--muted); padding: 0 0.3rem; }
fieldset.group label { display: inline-flex; align-items: center; gap: 0.4rem; margin: 0.2rem 1rem 0.2rem 0; font-size: 0.92rem; }
fieldset.group input[type="checkbox"] { accent-color: var(--signal); }
.groups { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-start; margin-top: 1rem; }
.ticker { font-size: 0.9rem; }
.ticker .row { padding: 0.35rem 0; border-bottom: 1px solid var(--line-2); display: flex; gap: 0.6rem; align-items: baseline; flex-wrap: wrap; }
.ticker .row .i { color: var(--muted); min-width: 3.2rem; }
.note { color: var(--ink-2); font-size: 0.9rem; margin-top: 0.8rem; max-width: 70ch; }

.tooltip {
  position: fixed; z-index: 10; max-width: 260px; padding: 0.5rem 0.7rem;
  font-size: 0.82rem; line-height: 1.4; background: var(--ink); color: #fff; border-radius: 4px; pointer-events: none;
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 1rem; border-right: 0; border-bottom: 1px solid var(--line); padding: 1rem 1.25rem; }
  .rail nav { flex-direction: row; flex-wrap: wrap; }
  .rail .foot { margin-top: 0; margin-left: auto; }
  main.content { padding: 1.4rem 1.25rem 3rem; }
  .samples { grid-template-columns: repeat(5, 1fr); }
}
