/* =================== Основа =================== */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-padding-top: calc(var(--topbar-h) + 12px);
}

body {
    margin: 0;
    min-height: 100dvh;
    font-family: var(--font-ui);
    font-size: var(--text-md);
    line-height: 1.5;
    color: var(--fg);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: none;
}

h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
a { color: inherit; text-decoration: none; }
kbd { font-family: var(--font-mono); }

::selection { background: color-mix(in srgb, var(--accent) 34%, transparent); }

/* Клавиатурный фокус виден везде: единая обводка акцентом читается на любом фоне */
:focus { outline: none; }
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}

.muted { color: var(--fg-mute); }

.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: fixed;
    left: 12px; top: 12px;
    z-index: var(--z-toast);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: var(--accent-fg);
    font-weight: 500;
    transform: translateY(-200%);
    transition: transform var(--dur) var(--ease);
}
.skip-link:focus-visible { transform: none; }

.noscript { padding: 40px; text-align: center; }

/* Полосы прокрутки в тон теме */
@media (hover: hover) and (pointer: fine) {
    * { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
}

/* =================== Значки =================== */
.icon {
    width: 20px; height: 20px;
    flex-shrink: 0;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}
.icon-sm { width: 16px; height: 16px; }
.icon-fill { fill: currentColor; stroke: none; }
span[data-icon] { display: inline-flex; }

/* =================== Загрузка =================== */
.spinner {
    width: 26px; height: 26px;
    border: 2.5px solid var(--border-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 56px 16px;
    color: var(--fg-mute);
}

.skeleton {
    display: block;
    background: linear-gradient(100deg, var(--skeleton) 30%, var(--skeleton-hi) 50%, var(--skeleton) 70%);
    background-size: 300% 100%;
    animation: shimmer 1.4s ease-in-out infinite;
    border-radius: var(--radius-xs);
}
.skeleton-line { height: 12px; margin: 8px 0; }
.skeleton-line.short { width: 60%; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
