/*
 * Lanibo Docs. In the family of lanibo.com and Lanibo Studio: Nunito, the dark ground, the teal
 * roof, warm paper, pill buttons. Every colour a token, redefined for dark mode.
 * Layout: a dark header, then the archive tree beside one reading column (tree hidden on phones).
 * Fonts are served from here (SIL Open Font License): no third-party requests.
 */
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url('fonts/nunito-latin.woff2') format('woff2');
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url('fonts/nunito-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-weight: 400;
  font-display: swap;
  src: url('fonts/ibm-plex-mono-400.woff2') format('woff2');
}

:root {
  --ground: #111827;
  --ground-text: #ffffff;
  --ground-muted: #a8b3c7;
  --roof: #5eead4;
  --coral: #fb7185;

  --bg: #fbf8f3;
  --surface: #ffffff;
  --sunken: #f4efe6;
  --text: #111827;
  --muted: #4b5563;
  --line: #e9e2d6;
  --link: #0f766e;
  --primary: #111827;
  --primary-text: #ffffff;
  --danger: #b42318;
  --ok: #0f766e;
  --shadow: 0 1px 2px rgb(17 24 39 / 0.04), 0 8px 24px rgb(17 24 39 / 0.06);

  --font: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --radius: 22px;
  --radius-sm: 14px;
  --column: 46rem;
  --wide: 76rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --surface: #141c2f;
    --sunken: #10182a;
    --text: #f3f4f6;
    --muted: #a8b3c7;
    --line: #243049;
    --link: #5eead4;
    --primary: #5eead4;
    --primary-text: #0b1120;
    --danger: #fda29b;
    --ok: #5eead4;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px rgb(0 0 0 / 0.25);
    color-scheme: dark;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 1.0625rem/1.65 var(--font);
  overflow-wrap: break-word;
}
a {
  color: var(--link);
  text-underline-offset: 0.18em;
}
code,
pre {
  font-family: var(--mono);
  font-size: 0.9em;
}
:focus-visible {
  outline: 3px solid var(--roof);
  outline-offset: 2px;
}
[hidden] {
  display: none !important;
}

/* ---- Header ---- */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--ground);
  color: var(--ground-text);
}
.top-in {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 0 16px;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.125rem;
  white-space: nowrap;
}
.brand b {
  color: var(--roof);
  font-weight: 800;
}
.top-nav {
  display: flex;
  gap: 4px;
}
.top-nav a {
  color: var(--ground-muted);
  text-decoration: none;
  font-weight: 700;
  padding: 10px 14px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
}
.top-nav a:hover {
  color: var(--ground-text);
  background: rgb(255 255 255 / 0.08);
}
@media (max-width: 420px) {
  .top-nav a {
    padding: 10px 12px;
  }
  .brand img {
    width: 28px;
    height: 28px;
  }
}
.top-nav a[aria-current='page'] {
  color: var(--ground);
  background: var(--roof);
}

/* ---- Layout ---- */
.layout {
  max-width: var(--wide);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}
.side {
  display: none;
}
.main {
  width: 100%;
  max-width: var(--column);
  margin: 0 auto;
  padding: 20px 16px 72px;
  min-width: 0;
}
@media (min-width: 960px) {
  .layout {
    grid-template-columns: 17rem minmax(0, 1fr);
    gap: 32px;
    padding: 0 16px;
  }
  .side {
    display: block;
    position: sticky;
    top: 60px;
    align-self: start;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    padding: 28px 0 40px;
  }
  .layout .main {
    margin: 0;
    padding: 28px 0 80px;
  }
  .main.solo {
    padding-top: 40px;
  }
}

.page-title {
  font-size: clamp(1.75rem, 5vw, 2rem);
  line-height: 1.2;
  font-weight: 800;
  margin: 8px 0 4px;
}
.lead {
  color: var(--muted);
  margin: 0 0 24px;
}
.muted {
  color: var(--muted);
}

/* ---- Card, buttons, fields, notices ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 20px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: 700 1rem/1 var(--font);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition:
    transform 120ms ease,
    opacity 120ms ease;
}
.btn:hover {
  border-color: var(--muted);
}
.btn:active {
  transform: scale(0.96);
}
.btn:disabled {
  opacity: 0.6;
  cursor: progress;
}
.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-text);
}
.btn.danger {
  color: var(--danger);
}
.btn.danger:hover {
  border-color: var(--danger);
}
.field {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--sunken);
  color: var(--text);
  font: 400 0.95rem var(--font);
}
.notice {
  margin: 12px 0 0;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--sunken);
  font-size: 0.95rem;
}
.notice.error {
  color: var(--danger);
}
.notice.ok {
  color: var(--ok);
}
.empty {
  padding: 28px 24px;
  text-align: center;
}
.empty h1,
.empty h2 {
  margin: 0 0 8px;
  font-size: 1.375rem;
}
.empty p {
  margin: 0 0 16px;
  color: var(--muted);
}
.empty p:last-child {
  margin-bottom: 0;
}

/* ---- Tree (home page and the side) ---- */
.tree ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.tree ul ul {
  padding-left: 14px;
  margin-left: 10px;
  border-left: 1px solid var(--line);
}
.tree summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  cursor: pointer;
  font-weight: 800;
  list-style: none;
  border-radius: 10px;
  padding: 0 8px;
}
.tree summary::-webkit-details-marker {
  display: none;
}
.tree summary::before {
  content: '';
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 150ms ease;
  flex: none;
}
.tree details[open] > summary::before {
  transform: rotate(45deg);
}
.tree summary:hover {
  background: var(--sunken);
}
.count {
  margin-left: auto;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--sunken);
  border-radius: 999px;
  padding: 1px 9px;
}
.tree .file a {
  display: flex;
  flex-direction: column;
  padding: 8px 10px;
  min-height: 40px;
  justify-content: center;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
}
.tree .file a:hover {
  background: var(--sunken);
}
.tree .file a[aria-current='page'] {
  background: var(--sunken);
  box-shadow: inset 3px 0 0 var(--roof);
}
.file-name {
  font-weight: 700;
}
.file-title {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.4;
}
.card.tree {
  padding: 12px;
}
.side .tree {
  font-size: 0.95rem;
}

/* ---- Breadcrumbs and the share bar ---- */
.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 14px;
}
.crumbs a {
  color: var(--muted);
  font-weight: 700;
}
.crumbs .sep {
  opacity: 0.5;
}
.share {
  padding: 14px 14px 14px 18px;
  margin-bottom: 28px;
}
.share-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.share-state {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 0.95rem;
}
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.5;
  flex: none;
}
.share.on .dot {
  background: var(--roof);
  opacity: 1;
  box-shadow: 0 0 0 4px rgb(94 234 212 / 0.25);
}
.share-on,
.link-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.share-url {
  flex: 1 1 16rem;
  min-width: 0;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--sunken);
  color: var(--text);
  font: 400 0.9rem var(--mono);
}
.share-actions {
  display: flex;
  gap: 8px;
}

/* ---- Shared links page ---- */
.links {
  display: grid;
  gap: 14px;
}
.link-card {
  padding: 18px;
}
.link-card h2 {
  margin: 0;
  font-size: 1.125rem;
  line-height: 1.35;
}
.link-card h2 a {
  color: var(--text);
  text-decoration: none;
}
.link-card h2 a:hover {
  text-decoration: underline;
}
.link-meta {
  margin: 2px 0 0;
  font-size: 0.875rem;
  color: var(--muted);
}
.link-card.missing {
  border-color: var(--coral);
}
.link-card.missing .link-meta {
  color: var(--danger);
}
.move-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.move-row .field {
  flex: 1 1 16rem;
  width: auto;
}

/* ---- The note itself ---- */
.doc {
  font-size: 1.0625rem;
}
.doc > :first-child {
  margin-top: 0;
}
.doc h1 {
  font-size: clamp(1.625rem, 5vw, 2rem);
  line-height: 1.2;
  font-weight: 800;
  margin: 0 0 20px;
  letter-spacing: -0.01em;
}
.doc h2 {
  font-size: 1.4rem;
  line-height: 1.3;
  font-weight: 800;
  margin: 40px 0 12px;
}
.doc h3 {
  font-size: 1.15rem;
  font-weight: 800;
  margin: 28px 0 8px;
}
.doc h4,
.doc h5,
.doc h6 {
  font-size: 1rem;
  font-weight: 800;
  margin: 24px 0 8px;
}
.doc [id] {
  scroll-margin-top: 76px;
}
.doc p,
.doc ul,
.doc ol {
  margin: 0 0 16px;
}
.doc ul,
.doc ol {
  padding-left: 1.4em;
}
.doc li + li {
  margin-top: 4px;
}
.doc blockquote {
  margin: 0 0 16px;
  padding: 10px 18px;
  border-left: 4px solid var(--roof);
  background: var(--sunken);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--muted);
}
.doc blockquote > :last-child {
  margin-bottom: 0;
}
.doc hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 32px 0;
}
.doc :not(pre) > code {
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.05em 0.35em;
}
.doc pre {
  background: var(--ground);
  color: #e5e7eb;
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  line-height: 1.5;
  margin: 0 0 16px;
}
.doc strong {
  font-weight: 800;
}
.doc .link-off {
  text-decoration: underline dotted;
  text-decoration-color: var(--muted);
  text-underline-offset: 0.18em;
}
.table-wrap {
  overflow-x: auto;
  margin: 0 0 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.doc table {
  border-collapse: collapse;
  font-size: 0.9rem;
  line-height: 1.45;
  min-width: 100%;
}
.doc th,
.doc td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  min-width: 7rem;
}
.doc th {
  background: var(--sunken);
  font-weight: 800;
  white-space: nowrap;
}
.doc tr:last-child td {
  border-bottom: 0;
}

/* ---- Public page ---- */
.foot {
  max-width: var(--column);
  margin: 0 auto;
  padding: 24px 16px 40px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.875rem;
}
.foot p {
  margin: 0;
}

/* ---- Motion: alive, never in the way ---- */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}
.share-on:not([hidden]),
.notice:not([hidden]) {
  animation: rise 220ms ease-out;
}
.link-card {
  animation: rise 260ms ease-out backwards;
}
@keyframes pulse {
  50% {
    transform: scale(1.04);
  }
}
.btn.done {
  animation: pulse 300ms ease;
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
.page-title + .card {
  margin-top: 20px;
}
