/* file-library — токени й компоненти. Див. DESIGN.md: порядок там, тут реалізація.
   Один файл, без CDN, без фреймворків. CSP без 'unsafe-inline' — інлайн-стилів
   у шаблонах немає й бути не може. */

:root {
  /* Колір: теплий нейтральний + один синій акцент. Більше не додавати. */
  --paper:        oklch(0.985 0.004 90);
  --paper-sunken: oklch(0.965 0.005 90);
  --ink:          oklch(0.22 0.012 90);
  --ink-soft:     oklch(0.46 0.010 90);
  --ink-faint:    oklch(0.50 0.008 90);   /* було 0.62 — не проходило 4.5:1 */
  --line:         oklch(0.90 0.006 90);
  --accent:       oklch(0.52 0.13 250);
  --accent-ink:   oklch(0.32 0.10 250);
  --warn-bg:      oklch(0.97 0.03 85);
  --warn-line:    oklch(0.82 0.07 85);
  --danger:       oklch(0.52 0.16 25);

  --font-prose: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace;

  --text-xs: 0.8125rem;  --lh-xs: 1.4;
  --text-s:  0.9375rem;  --lh-s:  1.5;
  --text-m:  1.0625rem;  --lh-m:  1.6;
  --text-l:  1.5rem;     --lh-l:  1.25;
  --text-xl: 2rem;       --lh-xl: 1.15;

  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;

  --r1: 4px;  --r2: 8px;
  --w: 62rem;
  --w-narrow: 34rem;
}

/* ---------- база ---------- */

*, *::before, *::after { box-sizing: border-box; }


html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: var(--text-m)/var(--lh-m) var(--font-prose);
  text-rendering: optimizeLegibility;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
a:hover { color: var(--accent-ink); }

/* Фокус видимий завжди — це не оздоблення, це доступність. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r1);
}

code, kbd, samp, .mono { font-family: var(--font-mono); font-size: 0.9285em; }

h1, h2, h3 { line-height: var(--lh-l); margin: 0 0 var(--s3); font-weight: 600; }
h1 { font-size: var(--text-l); }
h2 { font-size: var(--text-m); }
p { margin: 0 0 var(--s3); }

/* ---------- екран входу ---------- */

.auth { display: grid; place-items: center; min-height: 100vh; padding: var(--s5); }

.auth__card {
  width: 100%;
  max-width: var(--w-narrow);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r2);
  padding: var(--s7) var(--s6);
}

.auth__title { font-size: var(--text-xl); letter-spacing: -0.02em; }
.auth__lead { color: var(--ink-soft); margin-bottom: var(--s6); }

.auth__button {
  display: block;
  text-align: center;
  padding: var(--s3) var(--s5);
  background: var(--accent);
  color: oklch(0.99 0 0);
  border: 0;
  border-radius: var(--r1);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.auth__button:hover { background: var(--accent-ink); color: oklch(0.99 0 0); }

.auth__note { margin-top: var(--s5); font-size: var(--text-xs); line-height: var(--lh-xs); color: var(--ink-faint); }
.auth__code { font-family: var(--font-mono); font-size: var(--text-s); }
.auth__link { display: inline-block; margin-top: var(--s4); }

/* ---------- каркас бібліотеки ---------- */

.shell { max-width: var(--w); margin: 0 auto; padding: var(--s5) var(--s5) var(--s8); }

.topbar {
  display: flex;
  align-items: center;
  gap: var(--s4);
  padding-bottom: var(--s4);
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--s5);
}
.topbar__brand { font-weight: 600; text-decoration: none; color: var(--ink); }
.topbar__user { margin-left: auto; font-size: var(--text-xs); color: var(--ink-faint); }

.searchbar { display: flex; gap: var(--s2); margin-bottom: var(--s5); }
.searchbar__input {
  flex: 1;
  min-width: 0;
  padding: var(--s2) var(--s3);
  font: inherit;
  color: inherit;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r1);
}
.searchbar__input::placeholder { color: var(--ink-faint); }
.searchbar__submit {
  padding: var(--s2) var(--s4);
  font: inherit;
  color: var(--ink);
  background: var(--paper-sunken);
  border: 1px solid var(--line);
  border-radius: var(--r1);
  cursor: pointer;
}
.searchbar__submit:hover { border-color: var(--ink-faint); }

/* ---------- список ---------- */

.list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }

.list__row { border-bottom: 1px solid var(--line); }

.list__link {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--s1) var(--s4);
  align-items: baseline;
  padding: var(--s3) var(--s2);
  color: inherit;
  text-decoration: none;
}
.list__link:hover { background: var(--paper-sunken); color: inherit; }

.list__title { font-weight: 600; overflow-wrap: anywhere; }
.list__desc {
  grid-column: 1 / -1;
  font-size: var(--text-s);
  line-height: var(--lh-s);
  color: var(--ink-soft);
  /* Два рядки в списку: більше — це вже сторінка файлу */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.list__meta { font-size: var(--text-xs); color: var(--ink-faint); white-space: nowrap; }

/* ---------- бейджі ---------- */

.badge {
  display: inline-block;
  padding: 1px var(--s2);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.5;
  color: var(--ink-soft);
  background: var(--paper-sunken);
  border: 1px solid var(--line);
  border-radius: var(--r1);
  white-space: nowrap;
}
.badge--kind { text-transform: uppercase; letter-spacing: 0.04em; }
.badge + .badge { margin-left: var(--s1); }

/* ---------- сторінка файлу ---------- */

.file__head { margin-bottom: var(--s5); }
.file__title { font-size: var(--text-l); letter-spacing: -0.01em; }
.file__desc { color: var(--ink-soft); max-width: 46rem; }

.downloads { display: flex; flex-wrap: wrap; gap: var(--s2); margin: var(--s5) 0; }

.button {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  min-height: 44px;              /* ціль для дотику/мишки, не «на око» */
  padding: var(--s2) var(--s4);
  font: inherit;
  color: oklch(0.99 0 0);
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: var(--r1);
  text-decoration: none;
  cursor: pointer;
}
.button:hover { background: var(--accent-ink); color: oklch(0.99 0 0); }
.button--quiet {
  color: var(--ink);
  background: var(--paper);
  border-color: var(--line);
}
.button--quiet:hover { background: var(--paper-sunken); color: var(--ink); border-color: var(--ink-faint); }

/* Інструкції власника: ДАНІ, не генерація. Тому окремий блок і моноширинність
   для команд — щоб не зливалось із текстом інтерфейсу. */
.notes {
  margin: var(--s6) 0;
  padding: var(--s4) var(--s5);
  background: var(--paper-sunken);
  border: 1px solid var(--line);
  border-radius: var(--r2);
}
.notes__label {
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: var(--s3);
}
.notes pre {
  margin: 0;
  overflow-x: auto;
  font-size: var(--text-s);
  line-height: var(--lh-s);
}

/* Попередження: факт, не лякалка. */
.warn {
  margin: var(--s5) 0;
  padding: var(--s3) var(--s4);
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-left-width: 3px;
  border-radius: var(--r1);
  font-size: var(--text-s);
  line-height: var(--lh-s);
}
.warn__title { font-weight: 600; display: block; margin-bottom: var(--s1); }

.hash {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
  margin-top: var(--s2);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--ink-soft);
}
.hash__value { overflow-wrap: anywhere; }
.hash__copy {
  padding: var(--s1) var(--s2);
  font: inherit;
  font-family: var(--font-prose);
  color: var(--ink-soft);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r1);
  cursor: pointer;
}
.hash__copy:hover { color: var(--ink); border-color: var(--ink-faint); }

dl.meta { display: grid; grid-template-columns: max-content 1fr; gap: var(--s1) var(--s4); margin: var(--s5) 0; font-size: var(--text-s); }
dl.meta dt { color: var(--ink-faint); }
dl.meta dd { margin: 0; }

/* ---------- стани ---------- */

.empty {
  padding: var(--s7) var(--s5);
  text-align: center;
  color: var(--ink-soft);
  border: 1px dashed var(--line);
  border-radius: var(--r2);
}
.empty__title { font-weight: 600; color: var(--ink); display: block; margin-bottom: var(--s2); }

/* Один оркестрований момент на сторінку: поява рядків. */
@media (prefers-reduced-motion: no-preference) {
  .list__row { animation: rise 220ms ease-out both; }
  .list__row:nth-child(2) { animation-delay: 30ms; }
  .list__row:nth-child(3) { animation-delay: 60ms; }
  .list__row:nth-child(4) { animation-delay: 90ms; }
  .list__row:nth-child(n+5) { animation-delay: 110ms; }
  @keyframes rise {
    from { opacity: 0; transform: translateY(3px); }
    to   { opacity: 1; transform: none; }
  }
}

@media (max-width: 40rem) {
  .shell { padding: var(--s4) var(--s3) var(--s7); }
  .auth__card { padding: var(--s5) var(--s4); }
  .list__meta { display: none; }   /* на вузькому екрані метадані є на сторінці файлу */
}

/* Підпис для скрінрідера, невидимий візуально. Не display:none — інакше
   поле втрачає accessible name. */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
