/* inkov.dev: цвета только через токены */
@layer reset, base, layout, components, utilities;

@font-face {
  font-family: "JetBrains Mono";
  src: url("/assets/fonts/jetbrains-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("/assets/fonts/jetbrains-mono-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  body, h1, h2, h3, p, ol, ul, dl, dd, figure { margin: 0; }
  ol[role="list"], ul[role="list"] { list-style: none; padding: 0; }
  img, svg, picture { display: block; max-inline-size: 100%; }
  img { block-size: auto; }
  button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
  code { font: inherit; }
}

@layer base {
  :root {
    color-scheme: light dark;

    /* цвета: светлая тема, темная тема */
    --bg: light-dark(#f5f6f8, #0e1116);
    --surface: light-dark(#ffffff, #151a21);
    --surface-2: light-dark(#edf0f4, #1b212a);
    --group-bg: light-dark(#eef3fc, #161e2c);
    --text: light-dark(#151a21, #e4e8ee);
    --muted: light-dark(#525c69, #98a2b0);
    --border: light-dark(#d6dbe2, #29303a);
    --border-strong: light-dark(#7c8694, #6a7482);
    --dot: light-dark(#d3d8df, #232a33);
    --accent: light-dark(#1f5bd6, #7ea6ff);
    --accent-hover: light-dark(#1a4db8, #a3c0ff);
    --on-accent: light-dark(#ffffff, #0e1116);
    --success: light-dark(#177337, #4cb870);
    --success-bg: light-dark(#e6f4ea, #132619);
    --running: light-dark(#08707f, #40b8c8);
    --running-bg: light-dark(#dff3f4, #0d2528);
    --queued: light-dark(#5f6975, #939ca9);
    --queued-bg: light-dark(#edf0f3, #1e232b);
    --failed: light-dark(#bf2630, #f0736d);
    --failed-bg: light-dark(#fbeaea, #2d1718);
    --upstream-failed: light-dark(#a04e00, #e39443);
    --upstream-failed-bg: light-dark(#fbefe3, #2b1e10);
    /* серии графиков: проверены на различимость при нарушениях цветового зрения */
    --chart-1: light-dark(#1f5bd6, #3987e5);
    --chart-2: light-dark(#a04e00, #d95926);
    --chart-3: light-dark(#00806a, #199e70);

    /* шрифты и шкала размеров */
    --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
    --fs-xs: 0.8125rem;
    --fs-sm: clamp(0.875rem, 0.8505rem + 0.1087vw, 0.9375rem);
    --fs-base: clamp(1rem, 0.9511rem + 0.2174vw, 1.125rem);
    --fs-lg: clamp(1.125rem, 1.0516rem + 0.3261vw, 1.3125rem);
    --fs-h3: clamp(1.25rem, 1.1522rem + 0.4348vw, 1.5rem);
    --fs-h2: clamp(1.625rem, 1.3804rem + 1.087vw, 2.25rem);
    --fs-h1: clamp(2.25rem, 1.663rem + 2.6087vw, 3.75rem);

    /* отступы, колонки, радиусы */
    --s-1: 0.25rem; --s-2: 0.5rem; --s-3: 0.75rem; --s-4: 1rem; --s-5: 1.5rem;
    --s-6: 2rem; --s-7: 3rem; --s-8: 4rem; --s-9: 6rem;
    --gutter: 1rem;
    --spine: 1.5rem;
    --photo: clamp(5rem, 25vw, 8rem);
    --section-pad: clamp(3.5rem, 2.1304rem + 6.087vw, 7rem);
    --r-chip: 4px; --r-node: 6px; --r-card: 8px;

    /* движение */
    --ease-out: cubic-bezier(0.2, 0, 0, 1);
    --dur-1: 120ms; --dur-2: 160ms; --dur-3: 240ms;
    --arrow: polygon(0 4px, calc(100% - 7px) 4px, calc(100% - 7px) 0, 100% 5px, calc(100% - 7px) 10px, calc(100% - 7px) 6px, 0 6px);
  }

  :root[data-theme="light"] { color-scheme: light; }
  :root[data-theme="dark"] { color-scheme: dark; }

  @media (width >= 40rem) { :root { --gutter: 1.5rem; --spine: 2.5rem; --photo: 12.5rem; } }
  @media (width >= 60rem) { :root { --gutter: 2rem; --photo: 16rem; } }
  @media (width >= 75rem) { :root { --photo: 20rem; } }

  /* статус: цвет и форма маркера */
  [data-state] { --m-w: 4px; --m-r: 2px; --m-t: currentColor; --m-e: currentColor; --m-b: currentColor; --m-s: currentColor; --m-x: none; }
  [data-state="success"] { --state: var(--success); --state-bg: var(--success-bg); }
  [data-state="running"] { --state: var(--running); --state-bg: var(--running-bg); --m-w: 2px; --m-r: 50%; --m-e: transparent; }
  [data-state="queued"] { --state: var(--queued); --state-bg: var(--queued-bg); --m-w: 1.5px; --m-r: 1px; }
  [data-state="failed"] { --state: var(--failed); --state-bg: var(--failed-bg); --m-w: 0; --m-r: 0; --m-x: ""; }
  [data-state="upstream_failed"] {
    --state: var(--upstream-failed); --state-bg: var(--upstream-failed-bg);
    --m-r: 0; --m-e: transparent; --m-b: transparent;
  }

  body { background: var(--bg); color: var(--text); font-family: var(--font-sans); font-size: var(--fs-base); line-height: 1.6; }
  h1, h2, h3 { font-weight: 600; text-wrap: balance; }
  h1 { font-size: var(--fs-h1); line-height: 1.05; letter-spacing: -0.02em; }
  h2 { font-size: var(--fs-h2); line-height: 1.15; letter-spacing: -0.01em; }
  h3 { font-size: var(--fs-h3); line-height: 1.25; }
  p { text-wrap: pretty; }
  a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
  a:hover { text-decoration-thickness: 2px; }
  :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  ::selection { background: var(--accent); color: var(--on-accent); }
  :target { scroll-margin-block-start: var(--s-5); }

  @media (width < 40rem) { p { hyphens: auto; } }
}

@layer layout {
  .container { inline-size: min(100% - 2 * var(--gutter), 75rem); margin-inline: auto; }
  .site-header { border-block-end: 1px solid var(--border); }
  .site-header__inner { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; min-block-size: 56px; padding-block: var(--s-2); }
  .site-header__controls { display: flex; align-items: center; gap: var(--s-2); margin-inline-start: auto; }

  /* hero: плитка профиля и плитки проектов на холсте */
  .hero {
    background: radial-gradient(var(--dot) 1px, transparent 1px) 0 0 / 24px 24px, var(--bg);
    padding-block: var(--s-4) var(--s-7);
  }
  .hero__inner { display: grid; gap: var(--s-5); }

  /* до 40rem фото рядом с именем, остальное под ними на всю ширину */
  .profile__body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--photo);
    grid-template-areas: "name photo" "role role" "meta meta" "lead lead" "cta cta";
    gap: var(--s-3) var(--s-4);
    padding: var(--s-4) var(--s-3) var(--s-5);
  }
  .profile__text { display: contents; }
  .profile__name { grid-area: name; align-self: center; }
  .profile__name > span { display: block; }
  .profile__role { grid-area: role; }
  .profile__meta { grid-area: meta; }
  .profile__lead { grid-area: lead; }
  .profile__cta { grid-area: cta; }
  .profile__photo { grid-area: photo; }

  /* 40-60rem: фото справа от имени, роли и опыта; пустая строка 1fr забирает лишнюю высоту фото */
  @media (width >= 40rem) {
    .profile__body {
      grid-template-rows: auto auto auto minmax(0, 1fr) auto auto;
      grid-template-areas: "name photo" "role photo" "meta photo" ". photo" "lead lead" "cta cta";
      column-gap: var(--s-6);
      padding: var(--s-5);
    }
    .profile__name { align-self: start; }
    .profile__name > span { display: inline; }
  }

  /* от 60rem: текст слева, фото справа */
  @media (width >= 60rem) {
    .hero { padding-block-start: var(--s-5); }
    .profile__body { grid-template-rows: none; grid-template-areas: "text photo"; align-items: center; padding: var(--s-5) var(--s-5) var(--s-5) var(--s-6); }
    .profile__text { display: block; grid-area: text; }
    .profile__role { margin-block-start: var(--s-2); }
    .profile__meta { margin-block-start: var(--s-3); }
    .profile__lead { margin-block-start: 1.25rem; }
    .profile__cta { margin-block-start: var(--s-5); }
  }

  /* плитки проектов: 1, 2 или 3 колонки по ширине блока */
  .showcase { container: showcase / inline-size; }
  .showcase__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); }
  .showcase__all { margin-inline-start: auto; }
  .tiles { display: grid; gap: var(--s-4); margin-block-start: var(--s-4); }
  .tiles > li { display: grid; min-inline-size: 0; }

  @container showcase (width >= 36rem) {
    .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    /* последняя плитка без пары занимает строку целиком */
    .tiles > li:nth-child(odd):last-child { grid-column: 1 / -1; }
  }

  @container showcase (width >= 54rem) {
    .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .tiles > li:nth-child(odd):last-child { grid-column: auto; }
  }

  /* хребет */
  .spine { position: relative; padding-inline-start: var(--spine); }
  .spine::before {
    content: "";
    position: absolute;
    inset-inline-start: calc(var(--spine) / 2 - 1px);
    inset-block: calc(var(--section-pad) + 11px) 5px;
    border-inline-start: 2px solid var(--border-strong);
  }
  .spine__end {
    display: block;
    inline-size: 10px;
    block-size: 10px;
    margin: var(--s-8) 0 0 calc(var(--spine) / -2 - 5px);
    border: 5px solid var(--border-strong);
  }

  .section { padding-block-start: var(--section-pad); }
  .section > h2, .contacts-layout__head > h2 { margin-block-start: 8px; }
  .section > h2 + *, .contacts-layout__intro { margin-block-start: 24px; }
  .about__text p, .contacts-layout__intro, .page__intro, .page-node__summary { max-inline-size: 62ch; }
  .about__text > p + p { margin-block-start: var(--s-4); }
  .about, .groups, .tasks, .contacts, .contacts-layout, .site-footer__inner { display: grid; }
  .about { gap: var(--s-6); }
  .groups, .tasks { gap: var(--s-4); }
  .tasks { grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); }
  .group--archived { grid-column: 1 / -1; }
  .contacts-layout { gap: var(--s-5) var(--s-6); }
  /* ячейка с кнопкой копирования выше соседней, контакт рядом не растягивается */
  .contacts { gap: var(--s-3); align-items: start; }

  @media (width >= 40rem) {
    .groups, .contacts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    /* нечетный последний контакт занимает всю строку */
    .contacts__cell:last-child:nth-child(odd) { grid-column: 1 / -1; }
  }

  @media (width >= 60rem) {
    .about { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); align-items: start; }
    .contacts-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); align-items: start; }
  }

  .site-footer { margin-block-start: var(--s-8); padding-block: 2rem; border-block-start: 1px solid var(--border); }
  .site-footer__inner { gap: var(--s-2); }
  .site-footer p { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); }

  @media (width < 40rem) {
    .site-footer p { flex-direction: column; align-items: flex-start; gap: var(--s-1); }
    .sep { display: none; }
  }

  /* внутренние страницы */
  .page { padding-block-start: var(--s-6); }
  .page__intro { margin-block-start: var(--s-5); }
  .page__back { margin-block-start: var(--s-7); }
  .page-node + .attrs { margin-block-start: var(--s-5); }
  .section > :is(p, ul) { max-inline-size: 62ch; }
  .section > .tasks { max-inline-size: none; }
  .section > .stats { max-inline-size: 46rem; }
  .section > :is(p, ul, .attrs, .log-panel, .diagram, .shots, .table-wrap) + :is(p, ul, .attrs, .log-panel, .diagram, .shots, .table-wrap) { margin-block-start: var(--s-4); }
  .section > h3 { margin-block-start: var(--s-6); font-size: var(--fs-lg); }
  .section > h3 + * { margin-block-start: var(--s-3); }
  .error-page { display: grid; justify-items: center; gap: var(--s-5); padding-block-start: var(--section-pad); text-align: center; }
  .error-page > p { max-inline-size: 36rem; }
  .error-page__links { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s-3); }
}

@layer components {
  /* общие приемы */
  .node__id, .eyebrow, .attrs__head, .log-panel__head, .shot__head, .profile__owner, .task__id,
  .group__id, .project-card__id, .contact__id, .page-node__id, .crumbs ol, .site-footer {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    line-height: 1.4;
    color: var(--muted);
  }
  .node, .attrs, .log-panel, .group, .chip, .project-card, .contact, .photo-node, .page-node, .shot,
  .profile, .task, .theme-toggle, .lang a, .btn { border: 1px solid var(--border-strong); }
  .attrs__head, .log-panel__head, .shot__head, .profile__head, .project-card__head {
    display: flex;
    align-items: center;
    min-block-size: 36px;
    padding-inline: 16px;
    border-block-end: 1px solid var(--border);
    background: var(--surface-2);
  }

  .skip-link {
    position: absolute;
    inset: 8px auto auto 8px;
    z-index: 10;
    padding: 8px 12px;
    border-radius: var(--r-node);
    background: var(--accent);
    color: var(--on-accent);
    font-weight: 600;
    text-decoration: none;
  }

  .logo {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    min-block-size: 44px;
    font: 700 var(--fs-sm) var(--font-mono);
    color: var(--text);
    text-decoration: none;
  }
  .logo__ring { inline-size: 8px; block-size: 8px; border: 2px solid var(--success); border-radius: 50%; }

  /* переключатель RU|EN */
  .lang { display: flex; }
  .lang a {
    display: grid;
    place-items: center;
    min-inline-size: 44px;
    min-block-size: 44px;
    font: 700 var(--fs-xs) var(--font-mono);
    color: var(--muted);
    text-decoration: none;
  }
  .lang a:first-child { border-start-start-radius: var(--r-node); border-end-start-radius: var(--r-node); }
  .lang a:last-child { margin-inline-start: -1px; border-start-end-radius: var(--r-node); border-end-end-radius: var(--r-node); }
  .lang a:hover { color: var(--text); }
  .lang a:focus-visible { position: relative; z-index: 1; }
  .lang a[aria-current="page"] {
    background: var(--surface-2);
    color: var(--text);
    text-decoration: underline 2px var(--accent);
    text-underline-offset: 0.3em;
  }

  /* кнопка темы: без JS скрыта */
  .theme-toggle:not([hidden]) { display: inline-flex; }
  .theme-toggle {
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    min-block-size: 44px;
    min-inline-size: 44px;
    padding: 0 12px;
    border-radius: var(--r-node);
  }
  .theme-toggle:hover { background: var(--surface-2); }
  .theme-toggle__icon { inline-size: 18px; block-size: 18px; flex: none; }
  .theme-toggle__text { min-inline-size: 13ch; font-family: var(--font-mono); font-size: var(--fs-xs); white-space: nowrap; }

  @media (width < 40rem) {
    .theme-toggle { padding: 0; }
  }

  /* кнопки */
  .btn:not([hidden]) { display: inline-flex; }
  .btn {
    align-items: center;
    justify-content: center;
    min-block-size: 44px;
    padding: 0 20px;
    border-radius: var(--r-node);
    font: 600 var(--fs-sm) / 1.2 var(--font-sans);
    text-align: center;
    text-decoration: none;
  }
  .btn--primary { background: var(--accent); border-color: transparent; color: var(--on-accent); }
  .btn--primary:hover { background: var(--accent-hover); }
  .btn--secondary { background: var(--bg); color: var(--text); }
  .btn--secondary:hover { border-color: var(--accent); color: var(--accent); }
  .btn:active { translate: 0 1px; }

  /* маркер статуса */
  .marker {
    position: relative;
    display: inline-block;
    flex: none;
    inline-size: 8px;
    block-size: 8px;
    color: var(--state);
    border: var(--m-w) solid;
    border-radius: var(--m-r);
    border-color: var(--m-t) var(--m-e) var(--m-b) var(--m-s);
  }
  .marker::before, .marker::after {
    content: var(--m-x);
    position: absolute;
    inset: 3px auto auto -1px;
    inline-size: 10px;
    border-block-start: 2px solid;
    rotate: 45deg;
  }
  .marker::after { rotate: -45deg; }

  .badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-block-size: 22px;
    padding: 0 8px;
    border-radius: var(--r-chip);
    background: var(--state-bg);
    color: var(--state);
    font: 700 var(--fs-xs) / 1 var(--font-mono);
    white-space: nowrap;
  }

  /* task-нода */
  .node {
    display: grid;
    align-content: start;
    gap: 4px;
    min-inline-size: 8.5rem;
    padding: 10px 12px;
    border-inline-start: 3px solid var(--state);
    border-radius: var(--r-node);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
  }
  .node__state { display: inline-flex; align-items: center; gap: 6px; }
  .node__state { font: var(--fs-xs) / 1.4 var(--font-mono); color: var(--state); }

  /* ETL-строка: маркер и id, между нодами ребро со стрелкой */
  .etl, .chain { display: flex; list-style: none; margin: 0; padding: 0; }
  .etl { --etl-bg: var(--bg); align-items: center; font: 700 var(--fs-sm) / 1.4 var(--font-mono); color: var(--text); }
  .etl > li { display: flex; align-items: center; flex: 1 1 auto; }
  .etl > li:first-child { flex: 0 0 auto; }
  .etl > li + li::before {
    content: "";
    flex: 1 0 1rem;
    block-size: 10px;
    margin-inline: 6px;
    background: var(--border-strong);
    clip-path: var(--arrow);
    transform-origin: left center;
  }
  .etl__node { display: inline-flex; align-items: center; gap: 6px; background: var(--etl-bg); }
  /* слой queued над success */
  .etl .marker::after {
    content: "";
    inset: -4px;
    inline-size: auto;
    border: 1.5px solid;
    border-radius: 1px;
    rotate: none;
    color: var(--queued);
    background: var(--etl-bg);
    opacity: 0;
  }

  /* плитка профиля: в шапке ETL-строка и владелец */
  .profile { overflow: hidden; border-radius: var(--r-card); background: var(--surface); }
  .profile__head { justify-content: space-between; gap: var(--s-4); padding-inline: 12px; }
  .profile__head .etl { --etl-bg: var(--surface-2); flex: 0 1 28rem; min-inline-size: 0; font-size: var(--fs-xs); }
  .profile__owner { display: none; white-space: nowrap; }
  .profile__role { font-size: var(--fs-lg); line-height: 1.4; text-wrap: balance; }
  .profile__meta { font: var(--fs-sm) / 1.5 var(--font-mono); color: var(--muted); hyphens: none; }
  .profile__lead { max-inline-size: 68ch; }
  .profile__cta { display: flex; flex-wrap: wrap; gap: var(--s-3); }
  .profile__photo img {
    inline-size: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-node);
  }

  @media (width >= 40rem) {
    .profile__head { padding-inline: 16px; }
    .profile__owner { display: inline; }
  }

  /* заголовок блока проектов на холсте */
  .showcase__title { font-size: var(--fs-h3); line-height: 1.25; }
  .showcase__title, .showcase__all { background: var(--bg); }
  .showcase__all { display: inline-flex; align-items: center; gap: 6px; min-block-size: 44px; font-size: var(--fs-sm); font-weight: 600; }
  .showcase__all svg { flex: none; inline-size: 12px; block-size: 12px; }
  .showcase__intro { inline-size: fit-content; max-inline-size: 62ch; margin-block-start: var(--s-2); background: var(--bg); font-size: var(--fs-sm); line-height: 1.5; color: var(--muted); }

  /* фото-нода: используется в макетах OG-картинок */
  .photo-node { inline-size: var(--photo); padding: 4px; border-radius: var(--r-node); background: var(--surface); }
  .photo-node img { inline-size: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 4px; }

  /* eyebrow и порт */
  .eyebrow { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); min-block-size: 22px; }
  .port {
    position: absolute;
    inset-inline-start: calc(var(--spine) / -2 - 6px);
    inset-block-start: calc(50% - 6px);
    inline-size: 12px;
    block-size: 12px;
    border: 2px solid var(--state, var(--border-strong));
    border-radius: 50%;
    background: var(--surface);
  }

  /* таблица атрибутов */
  .attrs { overflow: hidden; border-radius: var(--r-card); background: var(--surface); }
  .attrs dl > div {
    display: grid;
    grid-template-columns: minmax(0, 16ch) minmax(0, 1fr);
    gap: var(--s-3);
    padding: 10px 16px;
    font: var(--fs-sm) / 1.5 var(--font-mono);
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
  }
  .attrs dl > div + div { border-block-start: 1px solid var(--border); }
  .attrs dt { color: var(--muted); }

  @media (width < 40rem) {
    .attrs dl > div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  }

  /* лог-панель */
  .log-panel { max-inline-size: 60rem; overflow: hidden; border-radius: var(--r-node); background: var(--surface-2); }
  .log { display: grid; gap: var(--s-1); padding: var(--s-4) 16px; counter-reset: line; font: var(--fs-sm) / 1.6 var(--font-mono); }
  .log > li { display: grid; grid-template-columns: 2.5ch 5ch 10ch minmax(0, 1fr); gap: 12px; counter-increment: line; }
  .log > li::before {
    content: counter(line) / "";
    color: var(--muted);
    text-align: end;
    font-variant-numeric: tabular-nums;
    user-select: none;
  }
  .log__meta { display: contents; }
  .log__level { color: var(--success); }
  .log__level--error { color: var(--failed); }
  .log__msg { min-inline-size: 0; overflow-wrap: anywhere; }
  .log--plain > li { grid-template-columns: 2.5ch 5ch minmax(0, 1fr); }
  /* команда оболочки: вместо номера строки приглашение $, оно не копируется */
  .log--cmd > li { grid-template-columns: 1ch minmax(0, 1fr); }
  .log--cmd > li::before { content: "$" / ""; }
  .error-page .log-panel { inline-size: 100%; max-inline-size: 36rem; text-align: start; }

  @media (width < 30rem) {
    .log > li, .log--plain > li { grid-template-columns: 2.5ch minmax(0, 1fr); row-gap: 0; }
    .log__meta { display: flex; gap: 12px; }
    .log__msg { grid-column: 2; }
  }

  /* TaskGroup и чипы */
  .group { padding: 16px 20px; border-radius: var(--r-card); background: var(--group-bg); }
  .group__head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--s-1) var(--s-3);
    margin-block-end: var(--s-3);
  }
  .group__head h3 { font-size: var(--fs-sm); line-height: 1.5; }
  .chips { display: flex; flex-wrap: wrap; gap: 8px; }
  .chip {
    display: inline-flex;
    align-items: center;
    min-block-size: 28px;
    padding: 0 10px;
    border-radius: var(--r-chip);
    background: var(--surface);
    font: var(--fs-sm) / 1.3 var(--font-mono);
  }
  .group--archived .chip { border-style: dashed; color: var(--muted); }

  /* плитки задач */
  .task {
    display: grid;
    align-content: start;
    gap: var(--s-2);
    padding: 14px 18px 18px;
    border-inline-start: 3px solid var(--state);
    border-radius: var(--r-card);
    background: var(--surface);
  }
  .task__id { display: flex; align-items: center; gap: 6px; }
  .task__title { font-size: var(--fs-base); line-height: 1.35; }
  .task__text { font-size: var(--fs-sm); line-height: 1.55; }

  /* карточка проекта */
  .project-card {
    position: relative;
    display: grid;
    align-content: start;
    row-gap: var(--s-2);
    padding-block-end: 16px;
    overflow: hidden;
    border-inline-start: 3px solid var(--state);
    border-radius: var(--r-card);
    background: var(--surface);
  }
  .project-card > :not(.project-card__head) { padding-inline: 20px; }
  .project-card__head { flex-wrap: wrap; justify-content: space-between; gap: var(--s-2); margin-block-end: var(--s-2); }
  .project-card__title { font-size: var(--fs-h3); line-height: 1.25; letter-spacing: normal; }
  .project-card__title a { color: inherit; text-decoration: none; }
  .project-card__title a::after { content: ""; position: absolute; inset: 0; }
  .project-card__summary { font-size: var(--fs-sm); line-height: 1.5; }
  /* иконка приложения перед названием: размер от шрифта заголовка, центр на высоте прописных */
  .project-logo { display: inline-block; inline-size: 1.6em; block-size: 1.6em; margin-inline-end: 0.5em; vertical-align: -0.45em; }
  .project-card--queued { border-style: dashed; background: var(--bg); }
  .project-card--queued .project-card__summary { color: var(--muted); }
  .project-card:has(a):hover { border-block-color: var(--muted); border-inline-end-color: var(--muted); }
  .project-card:has(a:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

  @supports selector(:has(a)) {
    .project-card__title a:focus-visible { outline: none; }
  }

  /* разветвление: дерево с шиной слева */
  .projects-wrap { container: projects / inline-size; display: grid; }
  .projects-wrap__title { margin-block-start: var(--s-6); font-size: var(--fs-h3); line-height: 1.25; }
  .projects-wrap__intro { max-inline-size: 62ch; margin-block-start: var(--s-2); font-size: var(--fs-sm); line-height: 1.5; color: var(--muted); }
  .fanout {
    --tree-x: 1.5rem;
    --tree-arm: 1rem;
    position: relative;
    display: grid;
    gap: var(--s-4);
    margin-block-start: var(--s-4);
    padding-inline-start: calc(var(--tree-x) + var(--tree-arm));
  }
  .fanout > li { position: relative; min-inline-size: 0; }
  .fanout > li::before, .fanout > li:not(:last-child)::after {
    content: "";
    position: absolute;
    inset-inline-start: calc(-1 * var(--tree-arm) - 1px);
    border-inline-start: 2px solid var(--border-strong);
  }
  .fanout > li::before {
    inset-block-start: calc(-1 * var(--s-4));
    inline-size: calc(var(--tree-arm) + 1px);
    block-size: calc(var(--s-4) + 19px);
    border-block-end: 2px solid var(--border-strong);
    border-end-start-radius: 6px;
  }
  .fanout > li:not(:last-child)::after { inset-block: 12px calc(-1 * var(--s-4)); }

  /* карточка в /projects/ */
  @media (width >= 60rem) {
    .fanout--tree .project-card { grid-template-columns: 12rem minmax(0, 1fr); padding-block-end: 0; }
    .fanout--tree .project-card__head {
      grid-row: 1 / span 3;
      flex-direction: column;
      align-items: flex-start;
      justify-content: flex-start;
      margin: 0;
      padding: 16px;
      border-block-end: 0;
      border-inline-end: 1px solid var(--border);
    }
    /* длинный id переносится по <wbr> после подчеркиваний, без них - в любом месте */
    .fanout--tree .project-card__id { max-inline-size: 100%; overflow-wrap: anywhere; }
    .fanout--tree .project-card__title { padding-block-start: 16px; }
    .fanout--tree > li::before { block-size: calc(var(--s-4) + 27px); }
    .fanout--tree .project-card > :last-child { padding-block-end: 16px; }
  }

  /* контакт-нода */
  .contacts__cell { display: flex; flex-wrap: wrap; gap: 0.5rem; min-inline-size: 0; }
  .contact {
    flex: 1 1 100%;
    display: grid;
    grid-template: "id arrow" "value arrow" / minmax(0, 1fr) auto;
    align-content: center;
    align-items: center;
    column-gap: var(--s-3);
    min-inline-size: 0;
    min-block-size: 56px;
    padding: 8px 16px;
    border-radius: var(--r-node);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
  }
  .contact__id { grid-area: id; }
  .contact__value { grid-area: value; line-height: 1.4; overflow-wrap: anywhere; }
  .contact__arrow { grid-area: arrow; inline-size: 12px; block-size: 12px; color: var(--muted); }
  .contact:hover { border-color: var(--accent); }
  .contact:hover .contact__arrow { color: var(--accent); }
  .copy-status { min-block-size: 1lh; margin-block-start: var(--s-3); }

  /* хлебные крошки */
  .crumbs ol { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
  .crumbs li + li::before { content: "/" / ""; margin-inline-end: var(--s-2); }
  .crumbs a, footer a, dd a, .page__back a { display: inline-block; padding-block: 4px; }

  /* заголовок страницы */
  .page-node {
    display: grid;
    gap: var(--s-2);
    margin-block-start: var(--s-5);
    padding: 16px 20px;
    border-inline-start: 3px solid var(--state);
    border-radius: var(--r-node);
    background: var(--surface);
  }
  .page-node h1 { font-size: var(--fs-h2); line-height: 1.15; letter-spacing: -0.01em; }
  .page-node .badge { justify-self: start; }

  /* цепочка нод на 404 */
  .chain { flex-direction: column; align-items: center; }
  .chain > li { display: flex; flex-direction: column; align-items: center; }
  .chain .node { text-align: start; }
  .chain > li + li::before { content: ""; block-size: 1.5rem; border-inline-start: 2px dashed var(--border-strong); }

  @media (width >= 30rem) {
    .chain, .chain > li { flex-direction: row; }
    .chain > li + li::before { inline-size: 3rem; block-size: 0; border-inline-start: 0; border-block-start: 2px dashed var(--border-strong); }
  }

  .error-page h1 > span { display: block; margin-block-start: var(--s-2); font-size: var(--fs-h3); color: var(--muted); }

  /* скриншот проекта */
  .shots { display: grid; gap: var(--s-5); max-inline-size: 46rem; }
  .shot { overflow: hidden; border-radius: var(--r-node); background: var(--surface); }
  .shot__head { min-block-size: 32px; padding-inline: 12px; }
  .shot img { inline-size: 100%; }
  .shot figcaption { padding: 10px 16px; font-size: var(--fs-sm); color: var(--muted); }
  /* скриншоты телефона: узкие колонки, на мобильном две в ряд */
  .shots--phone { grid-template-columns: repeat(auto-fill, minmax(min(100% / 2 - var(--s-4), 13rem), 1fr)); gap: var(--s-4); }

  /* схема: inline SVG, цвета из токенов, на узком экране прокрутка внутри рамки */
  .diagram { max-inline-size: 46rem; overflow: hidden; border-radius: var(--r-node); background: var(--surface); border: 1px solid var(--border-strong); }
  .diagram__canvas { overflow-x: auto; }
  .diagram svg { display: block; inline-size: 100%; min-inline-size: 36rem; block-size: auto; }
  .diagram figcaption { padding: 10px 16px; border-block-start: 1px solid var(--border); font-size: var(--fs-sm); color: var(--muted); }
  .dg-box { fill: var(--surface); stroke: var(--border-strong); }
  .dg-box--core { fill: var(--surface-2); stroke: var(--accent); stroke-width: 1.5; }
  .dg-box--server { fill: var(--group-bg); stroke: var(--border-strong); }
  .dg-zone { fill: none; stroke: var(--border-strong); stroke-dasharray: 5 4; }
  .dg-life { stroke: var(--border-strong); stroke-dasharray: 4 4; }
  .dg-title { fill: var(--text); font: 600 15px var(--font-sans); }
  .dg-text { fill: var(--text); font: 13px var(--font-sans); }
  .dg-note { fill: var(--muted); font: 12px var(--font-sans); }
  .dg-mono { fill: var(--muted); font: 12px var(--font-mono); }
  .dg-line { fill: none; stroke: var(--muted); stroke-width: 1.5; }
  .dg-line--dashed { stroke-dasharray: 5 4; }
  .dg-head { fill: var(--muted); }
  .dg-badge, .dg-run { fill: var(--accent); }
  .dg-badge-text { fill: var(--on-accent); font: 700 11px var(--font-sans); }
  .dg-run-text { fill: var(--on-accent); font: 600 12px var(--font-sans); }

  /* график: та же рамка, что у схемы; точные значения в таблице под спойлером */
  .diagram__legend { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-4); padding: 12px 16px 0; font-size: var(--fs-sm); color: var(--muted); }
  .diagram__legend li { display: inline-flex; align-items: center; gap: var(--s-2); }
  .key { flex: none; inline-size: 12px; block-size: 12px; border-radius: 3px; background: var(--key); forced-color-adjust: none; }
  .key--line { inline-size: 18px; block-size: 3px; border-radius: 2px; }
  .key--1 { --key: var(--chart-1); }
  .key--2 { --key: var(--chart-2); }
  .key--3 { --key: var(--chart-3); }
  .diagram__data { border-block-start: 1px solid var(--border); }
  .diagram__data summary { padding: 10px 16px; font-size: var(--fs-sm); color: var(--muted); cursor: pointer; }
  .diagram__data summary:hover { color: var(--text); }
  .diagram__data .data { border-block-start: 1px solid var(--border); }
  .ch-grid { stroke: var(--border); }
  .ch-axis { stroke: var(--border-strong); }
  .ch-tick, .ch-title, .ch-sub { fill: var(--muted); font: 12px var(--font-sans); font-variant-numeric: tabular-nums; }
  .ch-label { fill: var(--text); font: 13px var(--font-sans); }
  .ch-value, .ch-zone-label, .ch-annot-text { fill: var(--text); font: 600 12px var(--font-sans); font-variant-numeric: tabular-nums; }
  .ch-seg { fill: var(--on-accent); font: 700 12px var(--font-sans); }
  .ch-zone--ok { fill: var(--success-bg); }
  .ch-zone--warn { fill: var(--upstream-failed-bg); }
  .ch-zone--bad { fill: var(--failed-bg); }
  .ch-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
  .ch-line--1 { stroke: var(--chart-1); }
  .ch-line--2 { stroke: var(--chart-2); }
  .ch-fill--1 { fill: var(--chart-1); }
  .ch-fill--2 { fill: var(--chart-2); }
  .ch-fill--3 { fill: var(--chart-3); }
  .ch-dot { stroke: var(--surface); stroke-width: 2; }
  .ch-annot { stroke: var(--muted); }
  .ch-annot-dot { fill: var(--muted); }
  /* прозрачная полоса над точкой графика: по ней браузер показывает подсказку из <title> */
  .ch-hit { fill: transparent; }

  /* таблица данных */
  .table-wrap { overflow-x: auto; }
  .section > .table-wrap { max-inline-size: 46rem; border: 1px solid var(--border-strong); border-radius: var(--r-node); background: var(--surface); }
  .data { inline-size: 100%; border-collapse: collapse; font-size: var(--fs-sm); line-height: 1.45; }
  .data :is(th, td) { padding: 8px 12px; text-align: start; vertical-align: top; }
  .data tbody tr { border-block-start: 1px solid var(--border); }
  .data th { background: var(--surface-2); font-weight: 600; color: var(--muted); }
  .data .num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }

  /* ключевые показатели: число и подпись, рамка слева по статусу */
  .stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 10rem), 1fr)); gap: var(--s-4); }
  .stat { display: grid; align-content: start; gap: 2px; padding-inline-start: 12px; border-inline-start: 3px solid var(--state, var(--border-strong)); }
  .stat__value { font-size: var(--fs-h3); font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }
  .stat__label { font-size: var(--fs-sm); line-height: 1.45; color: var(--muted); }

  /* сессия терминала: команда и вывод как есть, длинные строки прокручиваются */
  .term { overflow-x: auto; padding: var(--s-4) 16px; font: var(--fs-sm) / 1.6 var(--font-mono); white-space: pre; }
  .term__cmd { color: var(--text); font-weight: 700; }
  .term__out { color: var(--muted); }

  /* движение */
  @media (prefers-reduced-motion: no-preference) {
    html { scroll-behavior: smooth; }
    .project-card, .contact__arrow { transition: translate var(--dur-2) var(--ease-out); }
    .project-card:has(a):hover { translate: 0 -2px; }
    .contact:hover .contact__arrow { translate: 2px -2px; }

    /* запуск ETL-строки */
    .etl .marker::after { animation: etl-queued 150ms linear backwards; }
    .etl > li:nth-child(2) .marker::after { animation-delay: 400ms; }
    .etl > li:nth-child(3) .marker::after { animation-delay: 800ms; }
    .etl > li + li::before { animation: etl-edge 200ms var(--ease-out) backwards; }
    .etl > li:nth-child(2)::before { animation-delay: 200ms; }
    .etl > li:nth-child(3)::before { animation-delay: 600ms; }

    /* кольцо running у проекта в работе: 3 оборота */
    .tiles [data-state="running"] .marker { animation: spin 1.2s linear 1.2s 3; }
  }

  @keyframes etl-queued { from { opacity: 1; } }
  @keyframes etl-edge { from { scale: 0 1; } }
  @keyframes spin { to { rotate: 360deg; } }

  /* принудительные цвета */
  @media (forced-colors: active) {
    .etl > li + li::before { forced-color-adjust: none; background: CanvasText; }
    /* иначе running и upstream_failed теряют форму */
    .marker, .marker::before, .marker::after { forced-color-adjust: none; color: CanvasText; }
    .etl .marker::after { display: none; }
  }
}

@layer utilities {
  .visually-hidden, .skip-link:not(:focus) {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }

  @media (width < 40rem) {
    .theme-toggle__text { position: absolute; min-inline-size: 0; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); }
  }
}

/* переходы между страницами */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-group(root) { animation-duration: 200ms; }
}
