/* «Зал» — общая визуальная система с macOS-приложением.
   Токены совпадают с Theme.swift: те же цвета, радиусы и ритм. */

:root {
    color-scheme: light dark;

    --accent: #5c8c05;
    --accent-soft: #e6f5c7;
    --accent-contrast: #ffffff;
    --warning: #b8291a;
    --danger: #9e1424;
    --success: #1a7a47;

    --canvas: #f5f5f2;
    --surface: #ffffff;
    --surface-raised: #fcfcfa;
    --hairline: rgba(0, 0, 0, 0.09);

    --text-primary: rgba(0, 0, 0, 0.88);
    --text-secondary: rgba(0, 0, 0, 0.58);

    --radius-card: 18px;
    --radius-chip: 10px;

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-rounded: ui-rounded, "SF Pro Rounded", "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --accent: #c7f247;
        --accent-soft: #293806;
        --accent-contrast: #101204;
        --warning: #ff7360;
        --danger: #ff616f;
        --success: #59d98c;

        --canvas: #121213;
        --surface: #1f1f21;
        --surface-raised: #29292b;
        --hairline: rgba(255, 255, 255, 0.12);

        --text-primary: rgba(255, 255, 255, 0.92);
        --text-secondary: rgba(255, 255, 255, 0.62);

        --shadow: none;
    }
}

:root[data-theme="dark"] {
    --accent: #c7f247;
    --accent-soft: #293806;
    --accent-contrast: #101204;
    --warning: #ff7360;
    --danger: #ff616f;
    --success: #59d98c;

    --canvas: #121213;
    --surface: #1f1f21;
    --surface-raised: #29292b;
    --hairline: rgba(255, 255, 255, 0.12);

    --text-primary: rgba(255, 255, 255, 0.92);
    --text-secondary: rgba(255, 255, 255, 0.62);

    --shadow: none;
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--canvas);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent);
    text-decoration: none;
}

button {
    font: inherit;
    color: inherit;
}

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

/* MARK: Раскладка */

.shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 236px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 0;
    background: var(--surface);
    border-right: 1px solid var(--hairline);
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 22px 18px 26px;
}

.brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    background: var(--accent);
    color: var(--accent-contrast);
    display: grid;
    place-items: center;
    flex: none;
}

.brand-mark svg {
    width: 20px;
    height: 20px;
}

.brand-name {
    font-family: var(--font-rounded);
    font-size: 20px;
    font-weight: 700;
    line-height: 1.1;
}

.brand-tagline {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-top: 2px;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 10px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 9px;
    color: var(--text-secondary);
    font-size: 14.5px;
    position: relative;
}

.nav-link svg {
    width: 17px;
    height: 17px;
    flex: none;
}

.nav-link:hover {
    background: var(--surface-raised);
    color: var(--text-primary);
}

.nav-link[aria-current="page"] {
    background: var(--accent-soft);
    color: var(--text-primary);
    font-weight: 600;
}

.nav-link[aria-current="page"]::before {
    content: "";
    position: absolute;
    left: 4px;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 2px;
    background: var(--accent);
}

.sidebar-foot {
    margin-top: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.safety-note {
    border-radius: 10px;
    background: color-mix(in srgb, var(--warning) 8%, transparent);
    padding: 11px;
}

.safety-note b {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--warning);
    font-size: 11px;
    font-weight: 600;
}

.safety-note span {
    display: block;
    margin-top: 5px;
    font-size: 11px;
    color: var(--text-secondary);
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--hairline);
    border-radius: 9px;
    background: transparent;
    font-size: 12.5px;
    color: var(--text-secondary);
    cursor: pointer;
}

.theme-toggle:hover {
    color: var(--text-primary);
    background: var(--surface-raised);
}

.theme-toggle svg {
    width: 14px;
    height: 14px;
}

/* MARK: Контент */

.content {
    min-width: 0;
    padding: 30px 36px 64px;
}

.view {
    max-width: 940px;
}

.mobile-head {
    display: none;
}

.section-head {
    margin-bottom: 24px;
}

.section-title {
    font-family: var(--font-rounded);
    font-size: 34px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0 0 6px;
}

.section-sub {
    margin: 0;
    font-size: 15px;
    color: var(--text-secondary);
    max-width: 62ch;
}

.block-title {
    font-family: var(--font-rounded);
    font-size: 24px;
    font-weight: 600;
    margin: 0;
}

/* MARK: Карточки */

.card {
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-card);
    padding: 16px;
    box-shadow: var(--shadow);
}

.card + .card {
    margin-top: 12px;
}

.card-pad-l {
    padding: 24px;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.stack-s {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.card-head {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 14px;
}

.card-head svg {
    width: 15px;
    height: 15px;
    flex: none;
}

.card-head h2 {
    font-size: 17px;
    font-weight: 600;
    margin: 0;
}

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

.secondary {
    color: var(--text-secondary);
}

/* MARK: Поиск и фильтры */

.search {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 13px;
    border: 1px solid var(--hairline);
    border-radius: 11px;
    background: var(--surface);
}

.search svg {
    width: 15px;
    height: 15px;
    color: var(--text-secondary);
    flex: none;
}

.search input {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    outline: none;
}

.search input::placeholder {
    color: var(--text-secondary);
}

.search-clear {
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0 2px;
    font-size: 15px;
    line-height: 1;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: 999px;
    border: 1px solid var(--hairline);
    background: var(--surface);
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1.2;
    cursor: pointer;
    white-space: nowrap;
}

.chip svg {
    width: 13px;
    height: 13px;
}

.chip:hover {
    border-color: color-mix(in srgb, var(--accent) 40%, var(--hairline));
}

.chip[aria-pressed="true"] {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-contrast);
    font-weight: 600;
}

.chip.tone-neutral {
    background: var(--surface-raised);
    color: var(--text-secondary);
}

.chip.tone-accent {
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    border-color: color-mix(in srgb, var(--accent) 30%, transparent);
    color: var(--accent);
    font-weight: 500;
}

.meta-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.count-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 12.5px;
    color: var(--text-secondary);
}

.link-button {
    border: 0;
    background: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 12.5px;
    padding: 0;
}

/* MARK: Сетка каталога */

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
    gap: 16px;
}

.item-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    border-radius: var(--radius-card);
    border: 1px solid var(--hairline);
    background: var(--surface);
    color: inherit;
    text-align: left;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.item-card:hover {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--hairline));
}

.item-card:active {
    transform: scale(0.997);
}

.item-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.item-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent);
    display: grid;
    place-items: center;
    flex: none;
}

.item-icon svg {
    width: 19px;
    height: 19px;
}

.item-name {
    font-family: var(--font-rounded);
    font-size: 17px;
    font-weight: 600;
    line-height: 1.25;
    margin: 0;
}

.item-tagline {
    margin: 0;
    font-size: 12.5px;
    color: var(--text-secondary);
}

.badge {
    font-size: 10.5px;
    font-weight: 500;
    padding: 3px 7px;
    border-radius: 999px;
    white-space: nowrap;
}

.badge.tone-success {
    color: var(--success);
    background: color-mix(in srgb, var(--success) 12%, transparent);
}

.badge.tone-warning {
    color: var(--warning);
    background: color-mix(in srgb, var(--warning) 12%, transparent);
}

.badge.tone-danger {
    color: var(--danger);
    background: color-mix(in srgb, var(--danger) 12%, transparent);
}

/* MARK: Детали снаряда */

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--accent);
    margin-bottom: 18px;
}

.back-link svg {
    width: 14px;
    height: 14px;
}

.detail-title {
    font-family: var(--font-rounded);
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 10px 0 6px;
    line-height: 1.15;
}

.detail-tagline {
    margin: 0;
    font-size: 15px;
    color: var(--text-secondary);
}

.muscle-lines {
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.muscle-line {
    display: grid;
    grid-template-columns: 132px 1fr;
    gap: 8px;
    align-items: start;
}

.muscle-line dt {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-secondary);
}

.muscle-line dd {
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.tag {
    font-size: 11.5px;
    font-weight: 500;
    padding: 3px 7px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    color: var(--accent);
}

.tag.muted {
    background: var(--surface-raised);
    color: var(--text-secondary);
}

.steps {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.step {
    display: grid;
    grid-template-columns: 22px 1fr;
    gap: 12px;
    align-items: start;
}

.step-num {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-contrast);
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 700;
    font-family: var(--font-rounded);
}

.step-title {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 2px;
}

.step-text {
    margin: 0;
    font-size: 13.5px;
    color: var(--text-secondary);
}

.breath {
    display: grid;
    grid-template-columns: 14px 1fr;
    gap: 9px;
    margin-top: 14px;
    padding: 11px;
    border-radius: 11px;
    background: var(--surface-raised);
    font-size: 13px;
    color: var(--text-secondary);
}

.breath svg {
    width: 14px;
    height: 14px;
    color: var(--accent);
    margin-top: 2px;
}

.dose {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.dose-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 10px;
    background: var(--surface-raised);
}

.dose-value {
    font-family: var(--font-rounded);
    font-size: 21px;
    font-weight: 700;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

.dose-label {
    font-size: 12.5px;
    color: var(--text-secondary);
    text-align: right;
}

.note {
    margin: 0 0 10px;
    font-size: 13px;
    color: var(--text-secondary);
}

.mistake {
    display: grid;
    grid-template-columns: 6px 1fr;
    gap: 11px;
    align-items: start;
}

.mistake + .mistake {
    margin-top: 12px;
}

.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--warning);
    margin-top: 7px;
}

.mistake-problem {
    margin: 0;
    font-size: 13.5px;
    font-weight: 500;
}

.mistake-fix {
    margin: 2px 0 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.safety-line {
    display: grid;
    grid-template-columns: 14px 1fr;
    gap: 9px;
    font-size: 13.5px;
}

.safety-line + .safety-line {
    margin-top: 9px;
}

.safety-line svg {
    width: 14px;
    height: 14px;
    color: var(--danger);
    margin-top: 2px;
}

/* MARK: Правила и публикации */

.rule + .rule {
    margin-top: 12px;
}

.rule-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.rule-head h3 {
    font-size: 17px;
    font-weight: 600;
    margin: 0;
}

.confidence {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 10.5px;
    color: var(--text-secondary);
    white-space: nowrap;
    padding-top: 3px;
}

.confidence i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-secondary);
}

.confidence.high i {
    background: var(--success);
}

.confidence.moderate i {
    background: var(--warning);
}

.rule-text {
    margin: 0;
    font-size: 15px;
}

.rule-action {
    display: grid;
    grid-template-columns: 13px 1fr;
    gap: 9px;
    margin: 10px 0 12px;
    padding: 11px;
    border-radius: 11px;
    background: var(--surface-raised);
    font-size: 14px;
    color: var(--text-secondary);
}

.rule-action svg {
    width: 13px;
    height: 13px;
    color: var(--accent);
    margin-top: 3px;
}

.source-row {
    display: grid;
    grid-template-columns: 34px 1fr;
    gap: 14px;
    align-items: start;
}

.source-icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: var(--accent-soft);
    color: var(--accent);
    display: grid;
    place-items: center;
}

.source-icon svg {
    width: 17px;
    height: 17px;
}

.source-cite {
    margin: 0;
    font-size: 13.5px;
    font-weight: 500;
}

.source-meta {
    margin: 4px 0 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 12.5px;
    color: var(--text-secondary);
}

.source-meta a {
    text-decoration: underline;
}

.source-takeaway {
    margin: 6px 0 0;
    font-size: 12.5px;
    color: var(--text-secondary);
}

/* MARK: Мышцы и мой зал */

.banner {
    display: grid;
    grid-template-columns: 18px 1fr;
    gap: 12px;
    padding: 16px;
    border-radius: 14px;
    background: var(--accent-soft);
    font-size: 15px;
    color: var(--text-secondary);
}

.banner svg {
    width: 18px;
    height: 18px;
    color: var(--accent);
    margin-top: 1px;
}

.group-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.group-head h2 {
    font-size: 17px;
    font-weight: 600;
    margin: 0;
}

.group-note {
    font-size: 10.5px;
    color: var(--text-secondary);
}

.hint {
    margin: 10px 0 0;
    font-size: 12.5px;
    color: var(--text-secondary);
}

/* MARK: Пустое состояние */

.empty {
    text-align: center;
    padding: 32px 16px;
}

.empty svg {
    width: 26px;
    height: 26px;
    color: var(--text-secondary);
}

.empty h2 {
    margin: 8px 0 4px;
    font-size: 17px;
    font-weight: 600;
}

.empty p {
    margin: 0;
    font-size: 12.5px;
    color: var(--text-secondary);
}

/* MARK: Нижняя навигация (телефон) */

.tabbar {
    display: none;
}

@media (max-width: 900px) {
    .shell {
        display: block;
    }

    .sidebar {
        display: none;
    }

    .content {
        padding: 16px 16px calc(72px + env(safe-area-inset-bottom));
    }

    .mobile-head {
        display: flex;
        align-items: center;
        gap: 10px;
        margin-bottom: 18px;
    }

    .mobile-head .brand-mark {
        width: 30px;
        height: 30px;
        border-radius: 9px;
    }

    .mobile-head .brand-mark svg {
        width: 17px;
        height: 17px;
    }

    .mobile-head .brand-name {
        font-size: 17px;
    }

    .mobile-head .theme-toggle {
        margin-left: auto;
    }

    .section-title {
        font-size: 28px;
    }

    .detail-title {
        font-size: 26px;
    }

    .grid {
        grid-template-columns: 1fr;
    }

    .muscle-line {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .tabbar {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        padding-bottom: env(safe-area-inset-bottom);
        background: var(--surface);
        border-top: 1px solid var(--hairline);
        z-index: 10;
    }

    .tabbar a {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 3px;
        padding: 9px 0 7px;
        color: var(--text-secondary);
        font-size: 10px;
        font-weight: 500;
    }

    .tabbar svg {
        width: 18px;
        height: 18px;
    }

    .tabbar a[aria-current="page"] {
        color: var(--accent);
        font-weight: 600;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}

@media print {
    .sidebar,
    .tabbar,
    .mobile-head,
    .theme-toggle {
        display: none !important;
    }

    body {
        background: #fff;
    }
}

/* MARK: Дополнения веб-версии */

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

.toolbar {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.results-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 22px 0 12px;
    font-size: 12.5px;
    color: var(--text-secondary);
}

.stack > .card + .card {
    margin-top: 0;
}

.card-head .icon-danger {
    color: var(--danger);
}

.search-clear {
    display: grid;
    place-items: center;
    padding: 2px;
    color: var(--text-secondary);
}

.search-clear[hidden] {
    display: none;
}

.banner b {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 3px;
}

.banner p {
    margin: 0;
}

.gym-chip[aria-pressed="true"] {
    background: var(--accent-soft);
    border-color: color-mix(in srgb, var(--accent) 35%, transparent);
    color: var(--accent);
    font-weight: 600;
}

.sources-heading {
    margin: 30px 0 14px;
}

@media (max-width: 900px) {
    .results-meta {
        margin: 18px 0 10px;
    }

    .sources-heading {
        margin: 24px 0 12px;
    }
}
