:root {
    --tk-bg: #0d0e0f;
    --tk-surface: #121314;
    --tk-surface-raised: #151617;
    --tk-surface-hover: #191a1b;
    --tk-text: #f0efec;
    --tk-text-secondary: #b6b3ad;
    --tk-text-muted: #85827c;
    --tk-line: rgba(255, 255, 255, 0.105);
    --tk-line-soft: rgba(255, 255, 255, 0.065);
    --tk-accent: #ff5a2f;
    --tk-focus: rgba(255, 90, 47, 0.38);
}

* { box-sizing: border-box; }

html {
    color-scheme: dark;
    scroll-behavior: smooth;
    overflow-x: clip;
    background: var(--tk-bg);
}

body.tokens-page {
    min-width: 0;
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
    background:
        linear-gradient(var(--tk-line-soft) 1px, transparent 1px),
        linear-gradient(90deg, var(--tk-line-soft) 1px, transparent 1px),
        var(--tk-bg);
    background-size: 96px 96px;
    background-position: center 65px;
    color: var(--tk-text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body.tokens-page::before {
    position: fixed;
    z-index: -1;
    inset: 65px 0 auto;
    height: 360px;
    background: radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.025), transparent 67%);
    content: '';
    pointer-events: none;
}

.tokens-page a { color: inherit; }

.tk-skip {
    position: fixed;
    z-index: 20;
    top: 10px;
    left: 12px;
    padding: 9px 13px;
    border: 1px solid var(--tk-accent);
    border-radius: 6px;
    background: var(--tk-bg);
    color: var(--tk-text);
    transform: translateY(-150%);
    transition: transform 150ms cubic-bezier(.23, 1, .32, 1);
}

.tk-skip:focus { transform: translateY(0); }

.tk-topbar {
    position: sticky;
    z-index: 10;
    top: 0;
    border-bottom: 1px solid var(--tk-line);
    background: rgba(13, 14, 15, 0.94);
    backdrop-filter: blur(16px);
}

.tk-topbar-inner {
    display: grid;
    grid-template-columns: 205px minmax(0, 1fr) auto;
    min-height: 66px;
    align-items: stretch;
}

.tk-back,
.tk-page-name,
.tk-usage-link {
    display: flex;
    align-items: center;
}

.tk-back {
    gap: 9px;
    padding: 0 24px;
    border-right: 1px solid var(--tk-line);
    color: var(--tk-text-secondary);
    font-size: 14px;
    text-decoration: none;
    transition: color 150ms ease, background-color 150ms ease;
}

.tk-back:hover { background: rgba(255, 255, 255, 0.025); color: var(--tk-text); }
.tk-back svg { flex: 0 0 auto; }

.tk-page-name {
    padding: 0 24px;
    color: var(--tk-text);
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.tk-usage-link {
    align-self: center;
    min-height: 38px;
    margin-right: 18px;
    padding: 0 18px;
    border: 1px solid var(--tk-line);
    border-radius: 7px;
    color: var(--tk-text);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: border-color 150ms ease, background-color 150ms ease, transform 120ms ease;
}

.tk-usage-link:hover { border-color: rgba(255, 255, 255, 0.22); background: rgba(255, 255, 255, 0.035); }
.tk-usage-link:active { transform: scale(.97); }

.tk-main {
    width: min(1168px, calc(100% - 48px));
    margin: 0 auto;
    padding: 34px 0 56px;
}

.tk-intro { margin-bottom: 18px; }

.tk-intro h1 {
    max-width: 900px;
    margin: 0 0 5px;
    color: var(--tk-text);
    font-size: clamp(28px, 2.6vw, 36px);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.045em;
    text-wrap: balance;
}

.tk-lead {
    max-width: 1010px;
    margin: 0;
    color: var(--tk-text-secondary);
    font-size: 14px;
    line-height: 1.6;
    text-wrap: pretty;
}

.tk-hint {
    display: flex;
    gap: 9px;
    align-items: center;
    margin: 7px 0 0;
    color: var(--tk-text-muted);
    font-size: 13px;
}

.tk-hint svg { flex: 0 0 auto; }

.tk-example,
.tk-rule,
.tk-faq {
    border: 1px solid var(--tk-line);
    background: rgba(18, 19, 20, 0.92);
}

.tk-example {
    overflow: hidden;
    border-radius: 8px;
}

.tk-example > h2,
.tk-faq > h2 {
    margin: 0;
    color: var(--tk-text);
    font-size: 17px;
    font-weight: 650;
    letter-spacing: -0.025em;
}

.tk-example > h2 { padding: 16px 24px 3px; }

.tk-example-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(360px, .96fr);
}

.tk-breakdown,
.tk-result { min-width: 0; padding: 18px 24px 20px; }

.tk-result {
    position: relative;
    padding-left: 48px;
    border-left: 1px solid var(--tk-line);
}

.tk-section-label {
    margin: 0 0 9px;
    color: var(--tk-text-secondary);
    font-size: 13px;
    font-weight: 500;
}

.tk-rows {
    width: 100%;
    border-collapse: collapse;
    color: var(--tk-text-secondary);
    font-size: 14px;
}

.tk-rows td {
    height: 38px;
    padding: 0;
    border-bottom: 1px solid var(--tk-line-soft);
}

.tk-rows td:first-child { padding-right: 20px; }

.tk-rows td:last-child {
    color: var(--tk-text);
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

.tk-caption {
    margin: 9px 0 0;
    color: var(--tk-text-muted);
    font-size: 12px;
    line-height: 1.5;
}

.tk-subtotal {
    margin-top: -1px;
    color: var(--tk-text);
    font-size: 31px;
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.04em;
    font-variant-numeric: tabular-nums;
}

.tk-calculation {
    position: relative;
    margin: 17px 0 23px;
    padding-left: 34px;
}

.tk-flow-arrow {
    position: absolute;
    top: -11px;
    bottom: -16px;
    left: 0;
    width: 22px;
    color: var(--tk-accent);
}

.tk-flow-arrow span {
    position: absolute;
    top: 0;
    bottom: 11px;
    left: 10px;
    width: 1px;
    background: var(--tk-accent);
}

.tk-flow-arrow svg { position: absolute; bottom: 0; left: 1px; }

.tk-multiplier {
    display: flex;
    min-height: 47px;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    border-top: 1px solid var(--tk-line);
    border-bottom: 1px solid var(--tk-line);
    color: var(--tk-text-secondary);
    font-size: 13px;
}

.tk-multiplier strong {
    color: var(--tk-text);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.tk-charged { color: var(--tk-accent); }
.tk-charged > span { display: block; margin-bottom: 5px; font-size: 13px; font-weight: 500; }

.tk-charged strong {
    display: block;
    font-size: clamp(30px, 3vw, 38px);
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.045em;
    font-variant-numeric: tabular-nums;
}

.tk-charged small { font-size: .72em; font-weight: 650; letter-spacing: -0.025em; }

.tk-rules {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.tk-rule {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    min-height: 84px;
    gap: 12px;
    align-items: center;
    padding: 15px 18px;
    border-radius: 8px;
    transition: border-color 160ms ease, background-color 160ms ease, transform 160ms cubic-bezier(.23, 1, .32, 1);
}

.tk-rule:hover { border-color: rgba(255, 255, 255, 0.17); background: var(--tk-surface-raised); transform: translateY(-1px); }

.tk-rule-icon {
    display: flex;
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    color: #bbb9b4;
}

.tk-rule h3 {
    margin: 0 0 3px;
    color: var(--tk-text);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.015em;
}

.tk-rule p {
    margin: 0;
    color: var(--tk-text-muted);
    font-size: 12px;
    line-height: 1.45;
    text-wrap: pretty;
}

.tk-faq {
    margin-top: 10px;
    overflow: hidden;
    border-radius: 8px;
}

.tk-faq > h2 { padding: 14px 24px; }

.tk-question,
.tk-formula-disclosure { border-top: 1px solid var(--tk-line-soft); }

.tk-question summary,
.tk-formula-disclosure summary {
    list-style: none;
    cursor: pointer;
    transition: background-color 150ms ease, color 150ms ease;
}

.tk-question summary::-webkit-details-marker,
.tk-formula-disclosure summary::-webkit-details-marker { display: none; }

.tk-question summary {
    display: flex;
    min-height: 43px;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 0 24px;
    color: var(--tk-text-secondary);
    font-size: 13px;
    font-weight: 500;
}

.tk-question summary:hover { background: rgba(255, 255, 255, 0.025); color: var(--tk-text); }
.tk-question summary svg { flex: 0 0 auto; transition: transform 180ms cubic-bezier(.23, 1, .32, 1); }
.tk-question[open] summary { color: var(--tk-text); }
.tk-question[open] summary svg { transform: rotate(180deg); }

.tk-answer {
    max-width: 900px;
    padding: 0 54px 16px 24px;
    color: var(--tk-text-muted);
    font-size: 13px;
    line-height: 1.65;
    text-wrap: pretty;
}

.tk-formula-disclosure summary {
    padding: 13px 24px 14px;
    color: var(--tk-accent);
    font-size: 12px;
    font-weight: 600;
    text-align: right;
}

.tk-formula-disclosure summary:hover { background: rgba(255, 90, 47, 0.045); color: #ff7350; }

.tk-formula {
    margin: 0 24px 22px;
    padding: 16px 18px;
    border: 1px solid var(--tk-line-soft);
    border-radius: 6px;
    background: #0a0b0c;
    color: var(--tk-text-secondary);
    font-size: 12px;
}

.tk-formula > div {
    display: grid;
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 18px;
    padding: 6px 0;
}

.tk-formula span { color: var(--tk-text-muted); }

.tk-formula code {
    overflow-wrap: anywhere;
    color: var(--tk-text);
    font-family: 'JetBrains Mono', 'Cascadia Code', monospace;
    font-size: 11px;
}

.tk-formula p { margin: 10px 0 0 100px; color: var(--tk-text-muted); }

.tk-support {
    margin: 16px 0 0;
    color: var(--tk-text-muted);
    font-size: 12px;
}

.tk-support a {
    color: var(--tk-text-secondary);
    text-decoration-color: var(--tk-accent);
    text-underline-offset: 3px;
}

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

.tk-footer {
    padding: 22px 24px 30px;
    border-top: 1px solid var(--tk-line-soft);
    color: var(--tk-text-muted);
}

.tk-footer nav {
    display: flex;
    width: min(1168px, 100%);
    flex-wrap: wrap;
    gap: 8px 22px;
    margin: 0 auto;
}

.tk-footer a { font-size: 11px; text-decoration: none; }
.tk-footer a:hover { color: var(--tk-text-secondary); }

.tokens-page a:focus-visible,
.tokens-page summary:focus-visible {
    outline: 2px solid var(--tk-focus);
    outline-offset: 3px;
}

@media (max-width: 900px) {
    .tk-topbar-inner { grid-template-columns: 170px minmax(0, 1fr) auto; }
    .tk-main { width: min(100% - 36px, 760px); }
    .tk-example-grid { grid-template-columns: 1fr; }
    .tk-result { padding-left: 24px; border-top: 1px solid var(--tk-line); border-left: 0; }
}

@media (max-width: 680px) {
    body.tokens-page { background-size: 72px 72px; background-position: center 57px; }
    .tk-topbar-inner { min-height: 58px; grid-template-columns: minmax(0, 1fr) auto; }
    .tk-back { padding: 0 16px 0 max(16px, env(safe-area-inset-left)); border-right: 0; }
    .tk-page-name { display: none; }
    .tk-usage-link { min-height: 44px; margin-right: max(12px, env(safe-area-inset-right)); padding: 0 12px; }
    .tk-main { width: calc(100% - 28px); padding: 25px 0 42px; }
    .tk-intro { margin-bottom: 16px; }
    .tk-intro h1 { margin-bottom: 8px; font-size: 28px; line-height: 1.12; }
    .tk-lead { font-size: 13px; }
    .tk-hint { align-items: flex-start; font-size: 12px; }
    .tk-example > h2 { padding: 15px 16px 2px; }
    .tk-breakdown, .tk-result { padding: 16px; }
    .tk-result { padding-top: 18px; }
    .tk-rows { font-size: 12px; }
    .tk-rows td { height: 37px; }
    .tk-rows td:first-child { padding-right: 10px; }
    .tk-rules { grid-template-columns: 1fr; }
    .tk-rule { min-height: 80px; padding: 14px 15px; }
    .tk-faq > h2 { padding: 14px 16px; }
    .tk-question summary { min-height: 48px; padding: 0 16px; }
    .tk-answer { padding: 0 44px 16px 16px; }
    .tk-formula-disclosure summary { padding-right: 16px; }
    .tk-formula { margin: 0 12px 16px; padding: 13px; }
    .tk-formula > div { grid-template-columns: 1fr; gap: 1px; }
    .tk-formula p { margin-left: 0; }
    .tk-footer { padding-right: max(14px, env(safe-area-inset-right)); padding-left: max(14px, env(safe-area-inset-left)); padding-bottom: max(24px, env(safe-area-inset-bottom)); }
    .tk-footer a { min-height: 40px; display: inline-flex; align-items: center; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .tk-skip,
    .tk-usage-link,
    .tk-rule,
    .tk-question summary,
    .tk-question summary svg { transition: none; }
}

/* Правовые ссылки в шапке — как на остальных страницах сайта.
   Добавлено 2026-08-05 по просьбе владельца: он искал их сверху, потому что
   везде они там, а здесь были только в подвале. */
.tk-legal-nav { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; letter-spacing: .02em; }
.tk-legal-nav a { color: var(--tk-muted, rgba(255,255,255,.55)); text-decoration: none; white-space: nowrap; }
.tk-legal-nav a:hover { color: var(--tk-text, #fff); }
.tk-legal-nav a.is-current { color: var(--tk-accent, #ff5c1a); }
@media (max-width: 900px) { .tk-legal-nav { display: none; } }

/* Таблица «модель × тариф → токенов в неделю». Собирается сервером из конфига,
   см. _model_quota_table_html: числа биллинга в разметке разъехались бы молча. */
.tk-quota-block { margin: 32px 0; }
.tk-quota-scroll { max-width: 100%; }
.tk-quota-hint { display: none; }
.tk-quota { width: 100%; border-collapse: collapse; margin: 18px 0 10px; font-size: 14px; }
.tk-quota th, .tk-quota td { padding: 10px 12px; text-align: right; border-bottom: 1px solid rgba(255,255,255,.08); }
.tk-quota thead th { text-align: right; font-weight: 500; opacity: .6; font-size: 12px; letter-spacing: .02em; }
.tk-quota th[scope="row"], .tk-quota thead th:first-child { text-align: left; font-weight: 500; opacity: 1; }
.tk-quota tbody tr:last-child th, .tk-quota tbody tr:last-child td { border-bottom: 0; }
.tk-quota td { font-variant-numeric: tabular-nums; }
@media (max-width: 700px) {
    .tk-quota-scroll {
        overflow-x: auto;
        overscroll-behavior-inline: contain;
        touch-action: pan-x pan-y;
        scrollbar-width: thin;
        scrollbar-color: var(--tk-accent) transparent;
    }
    .tk-quota-scroll:focus-visible { outline: 2px solid var(--tk-focus); outline-offset: 3px; }
    .tk-quota { min-width: 520px; }
    .tk-quota-hint { display: block; margin: -2px 0 10px; color: var(--tk-text-muted); font-size: 11px; }
}
