/* toolbox — спокойная тема без внешних шрифтов и CDN.
   Всё локальное: CSP не приходится ослаблять. */

:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --bg-soft: #eef1f4;
  --surface: #ffffff;
  --text: #16191d;
  --muted: #5d6673;
  --border: #dfe3e8;
  --accent: #1a5fd0;
  --accent-soft: #e8f0fe;
  --on-accent: #ffffff;
  --code-bg: #f2f4f7;
  --ok: #1a7f37;
  --error: #b3261e;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 18px 40px -32px rgba(16, 24, 40, 0.4);
  --radius: 12px;
  --measure: 64rem;
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1216;
  --bg-soft: #141920;
  --surface: #161a20;
  --text: #e6e9ee;
  --muted: #9aa4b2;
  --border: #262c34;
  --accent: #7db0ff;
  --accent-soft: #182333;
  --on-accent: #0b1220;
  --code-bg: #0b0e12;
  --ok: #7ee2a8;
  --error: #ff9d94;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 18px 40px -32px rgba(0, 0, 0, 0.9);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1216;
    --bg-soft: #141920;
    --surface: #161a20;
    --text: #e6e9ee;
    --muted: #9aa4b2;
    --border: #262c34;
    --accent: #7db0ff;
    --accent-soft: #182333;
    --on-accent: #0b1220;
    --code-bg: #0b0e12;
    --ok: #7ee2a8;
    --error: #ff9d94;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 18px 40px -32px rgba(0, 0, 0, 0.9);
  }
}

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

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--accent);
  color: var(--on-accent);
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

p {
  margin: 0 0 1em;
}

.shell {
  width: min(100% - 2.5rem, var(--measure));
  margin-inline: auto;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 100;
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.85rem;
  text-decoration: none;
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 1rem;
}

/* Шапка */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.85rem 0;
}

.brand {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  text-decoration: none;
  white-space: nowrap;
}

.brand__path {
  color: var(--accent);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  margin-left: auto;
  font-size: 0.9rem;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.15rem 0;
  border-bottom: 1px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.site-nav a:hover {
  color: var(--text);
}

.site-nav a[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.theme-toggle {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.theme-toggle__icon::before {
  content: "☾";
}

:root[data-theme="dark"] .theme-toggle__icon::before {
  content: "☀";
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle__icon::before {
    content: "☀";
  }
}

/* Основная колонка */

main {
  padding: clamp(2rem, 5vw, 3.25rem) 0 4.5rem;
}

.eyebrow {
  margin: 0 0 0.7rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero h1,
.page-head h1,
.error-page h1 {
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.1;
  text-wrap: balance;
}

.hero h1 {
  margin: 0 0 1rem;
  font-size: clamp(2rem, 5vw, 2.8rem);
  max-width: 24ch;
}

.lead {
  max-width: 68ch;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.6;
}

.page-head {
  margin-bottom: 1.75rem;
}

.page-head h1 {
  margin: 0 0 0.6rem;
  font-size: clamp(1.8rem, 4.2vw, 2.35rem);
}

.page-head--tool .lead {
  max-width: 60ch;
}

/* Поиск инструментов */

.home-search {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin: 1.8rem 0 1.4rem;
}

.home-search .text-input {
  flex: 1 1 auto;
  min-width: 0;
}

.home-search__count {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--muted);
  white-space: nowrap;
}

/* Поля */

.text-input,
.code-input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.94rem;
}

.code-input {
  min-height: 13rem;
  padding: 0.75rem 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  line-height: 1.55;
  resize: vertical;
  tab-size: 2;
}

.code-input--tall {
  min-height: 17rem;
}

.text-input::placeholder,
.code-input::placeholder {
  color: var(--muted);
  opacity: 0.8;
}

.text-input:focus,
.code-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.file-input {
  padding: 0.42rem 0.5rem;
  font-size: 0.82rem;
}

select.text-input {
  cursor: pointer;
}

.field-label {
  display: block;
  margin-bottom: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Кнопки */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: filter 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.button:hover {
  filter: brightness(1.07);
}

.button--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.button--ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
  filter: none;
}

.tool-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.85rem;
}

.tool-status {
  min-height: 1.3em;
  margin: 0.7rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.tool-status--ok {
  color: var(--ok);
}

.tool-status--error {
  color: var(--error);
}

/* Сетка инструментов */

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr));
  gap: 0.9rem;
}

.tool-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1.05rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.tool-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.tool-card__icon {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.4rem;
  margin-bottom: 0.15rem;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
}

.tool-card__name {
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.tool-card__text {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.tool-grid--related {
  margin-top: 0.9rem;
}

/* Страница инструмента */

.tool {
  display: grid;
  gap: 1rem;
  align-items: start;
}

.tool--split {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.tool-panel {
  min-width: 0;
  padding: clamp(0.9rem, 2.4vw, 1.25rem);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tool-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.tool-row .field {
  flex: 0 1 auto;
  min-width: 8rem;
}

.tool-row .field--grow {
  flex: 1 1 12rem;
}

.tool-row .field--end {
  margin-left: auto;
}

.result-card {
  grid-column: 1 / -1;
  padding: clamp(0.9rem, 2.4vw, 1.25rem);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
}

.result-card__title {
  margin: 0 0 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.result-card__subtitle {
  margin: 1.2rem 0 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.kv {
  margin: 0;
}

.kv > div {
  display: grid;
  grid-template-columns: minmax(8rem, 13rem) minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0.4rem 0;
  border-bottom: 1px dashed var(--border);
}

.kv > div:last-child {
  border-bottom: 0;
}

.kv dt {
  color: var(--muted);
  font-size: 0.82rem;
}

.kv dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  overflow-wrap: anywhere;
}

.kv--compact > div {
  padding: 0.3rem 0;
  grid-template-columns: minmax(6rem, 9rem) minmax(0, 1fr);
}

/* JWT */

.jwt-part + .jwt-part {
  margin-top: 1rem;
}

.jwt-part__title {
  margin: 0 0 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.code-block {
  min-height: 5rem;
  max-height: 18rem;
  margin: 0;
  padding: 0.75rem 0.85rem;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--code-bg);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.55;
  white-space: pre;
  tab-size: 2;
}

[data-role="claims"] {
  margin-top: 1rem;
}

/* Пояснения */

.tool-notes {
  margin-top: 2rem;
  padding: 1.1rem 1.35rem;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--surface);
}

.tool-notes h2 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.tool-notes p {
  color: var(--muted);
  font-size: 0.92rem;
}

.tool-notes ul {
  margin: 0.6rem 0 0;
  padding-left: 1.2rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.tool-notes li {
  margin: 0.3rem 0;
}

.tool-notes li::marker {
  color: var(--accent);
}

/* Секции и текст */

.section {
  margin-top: clamp(2.5rem, 6vw, 3.5rem);
}

.section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.6rem;
  margin-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

.section__head h2 {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.section__link {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  text-decoration: none;
}

a.section__link:hover {
  color: var(--accent);
}

.empty {
  padding: 2.5rem 0;
  color: var(--muted);
  font-style: italic;
}

.prose {
  max-width: 62ch;
}

.prose h2 {
  margin: 2em 0 0.6em;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
}

.prose ul {
  margin: 0 0 1.2em;
  padding-left: 1.25rem;
}

.prose li {
  margin: 0.35rem 0;
}

.prose li::marker {
  color: var(--accent);
}

.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.prose a:hover {
  color: var(--text);
}

/* Ошибки */

.error-page {
  padding: 2rem 0;
}

.error-page__code {
  margin: 0 0 0.5rem;
  font-family: var(--font-mono);
  font-size: clamp(3.5rem, 10vw, 5.5rem);
  line-height: 1;
  color: var(--accent);
}

.error-page h1 {
  margin: 0 0 0.9rem;
  font-size: clamp(1.6rem, 4vw, 2.1rem);
}

.arrow-link {
  display: inline-block;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.84rem;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
  padding-bottom: 0.1rem;
}

.arrow-link:hover {
  color: var(--text);
}

/* Подвал */

.site-footer {
  padding: 1.6rem 0 3rem;
  border-top: 1px solid var(--border);
  font-size: 0.83rem;
  color: var(--muted);
}

.site-footer p {
  margin: 0 0 0.4rem;
}

.site-footer a {
  color: var(--muted);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.site-footer a:hover {
  color: var(--accent);
}

.site-footer__note {
  font-size: 0.78rem;
}

/* Мобильная версия */

@media (max-width: 860px) {
  .tool--split {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 1.8rem, var(--measure));
  }

  .site-header__inner {
    gap: 0.8rem;
  }

  .site-nav {
    gap: 0.85rem;
    font-size: 0.85rem;
  }

  .home-search {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .home-search__count {
    order: 2;
    text-align: right;
  }

  .kv > div {
    grid-template-columns: 1fr;
    gap: 0.1rem;
  }

  .tool-row .field--end {
    margin-left: 0;
    width: 100%;
  }

  .tool-row .field--end .button {
    width: 100%;
  }

  .tool-actions .button {
    flex: 1 1 auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition: none !important;
  }
}

@media print {
  .site-header,
  .site-footer,
  .theme-toggle,
  .tool-actions,
  .home-search {
    display: none;
  }

  body {
    background: #fff;
    color: #000;
  }
}
