/* МОБИЛЬНЫЙ ИНТЕРФЕЙС. Меняйте отступы, размеры и нижнюю панель здесь.
   Основное оформление компьютера находится в styles.css. */
html {
    -webkit-text-size-adjust: 100%;
}
body {
    min-height: 100svh;
}
img {
    max-width: 100%;
}
.mobile-tabs,
.menu-toggle {
    display: none;
}
a,
button,
summary {
    -webkit-tap-highlight-color: rgba(8, 108, 196, 0.12);
    touch-action: manipulation;
}
.install-app {
    display: none;
    max-width: 100%;
    margin-top: 16px;
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: white;
    color: var(--blue-dark);
    font: inherit;
    cursor: pointer;
}
.install-hint {
    max-width: 36rem;
    font-size: 14px;
}
@media (max-width: 900px) {
    html {
        scroll-padding-top: 100px;
    }
    body {
        padding-bottom: calc(82px + env(safe-area-inset-bottom, 0px));
    }
    .wrap {
        width: auto;
        margin-left: max(16px, env(safe-area-inset-left, 0px));
        margin-right: max(16px, env(safe-area-inset-right, 0px));
    }
    .top {
        top: max(8px, env(safe-area-inset-top, 0px));
        gap: 10px;
        padding: 8px 10px;
        border-radius: 16px;
    }
    .brand {
        min-width: 0;
        gap: 8px;
        font-size: clamp(11px, 3.1vw, 14px);
        letter-spacing: 0;
        min-height: 44px;
    }
    .brand img {
        width: 30px;
        height: 34px;
        flex-shrink: 0;
    }
    .mobile-ui .menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex: 0 0 44px;
        min-height: 44px;
        border: 1px solid var(--line);
        border-radius: 12px;
        background: #f1f7fe;
        color: var(--ink);
        cursor: pointer;
    }
    .menu-toggle svg {
        width: 22px;
        height: 22px;
    }
    .mobile-ui .top:not(.menu-open) .nav {
        display: none;
    }
    .mobile-ui .top .nav {
        position: absolute;
        top: calc(100% + 8px);
        left: 0;
        right: 0;
        width: auto;
        display: grid;
        gap: 2px;
        padding: 8px;
        white-space: normal;
        overflow-y: auto;
        max-height: calc(100dvh - 185px - env(safe-area-inset-bottom, 0px));
        border: 1px solid var(--line);
        border-radius: 16px;
        background: #f8fbff;
        box-shadow: 0 16px 36px #143d6726;
    }
    .top .nav a {
        display: flex;
        align-items: center;
        min-height: 48px;
        padding: 10px 14px;
        font-size: 16px;
        border-radius: 10px;
    }
    .top .nav a:active,
    .top .nav a.active {
        background: #e5f2ff;
    }
    /* Нижняя панель остаётся под большим пальцем и учитывает полоску жестов iPhone. */
    .mobile-tabs {
        position: fixed;
        z-index: 30;
        bottom: 0;
        left: 0;
        right: 0;
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        padding: 7px max(8px, env(safe-area-inset-right, 0px))
            calc(7px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
        background: rgba(248, 252, 255, 0.97);
        border-top: 1px solid #cbdff1;
        box-shadow: 0 -4px 24px #1739590d;
        backdrop-filter: blur(14px);
        -webkit-backdrop-filter: blur(14px);
    }
    .mobile-tabs a {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        min-height: 54px;
        padding: 5px 2px;
        border-radius: 12px;
        font-size: 11px;
        font-weight: 700;
        color: #526b87;
    }
    .mobile-tabs svg {
        width: 23px;
        height: 23px;
    }
    .mobile-tabs a[aria-current] {
        color: #075fae;
        background: #e5f2ff;
    }
    .hero {
        gap: 22px;
        padding: 28px 0 48px;
        min-height: auto;
        grid-template-columns: minmax(0, 1fr);
    }
    .hero-mark {
        width: 100%;
        max-width: 290px;
        order: -1;
        justify-self: center;
        animation: none;
    }
    .split,
    .article-grid {
        grid-template-columns: minmax(0, 1fr);
    }
    h1 {
        font-size: clamp(34px, 9.2vw, 52px);
        line-height: 1.09;
        letter-spacing: -0.045em;
        margin-top: 14px;
    }
    h2 {
        font-size: clamp(27px, 7.5vw, 38px);
    }
    .lead {
        font-size: 17px;
        line-height: 1.65;
    }
    p {
        overflow-wrap: anywhere;
    }
    .section {
        padding: 46px 0;
        scroll-margin-top: 95px;
    }
    .contact {
        padding: 42px 0;
        scroll-margin-top: 95px;
    }
    .button {
        width: 100%;
        min-height: 52px;
        padding: 15px 20px;
        border-radius: 14px;
        font-size: 16px;
    }
    .button:hover {
        transform: none;
    }
    .article,
    .mini,
    .empty {
        padding: 22px;
        border-radius: 18px;
    }
    .article h2 {
        font-size: 25px;
    }
    .article summary,
    .read-more {
        display: flex;
        align-items: center;
        min-height: 48px;
        font-size: 16px;
    }
    .article[id] {
        scroll-margin-top: 100px;
    }
    .work-track {
        gap: 14px;
        scroll-padding-inline: 8px;
        overscroll-behavior-x: contain;
    }
    .work-card {
        flex-basis: min(72vw, 260px);
    }
    .work-title {
        opacity: 1;
        transform: none;
        font-size: 16px;
    }
    .work-cover {
        border-radius: 20px;
    }
    .works-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }
    .works-grid .work-title {
        padding: 34px 10px 12px;
        font-size: 13px;
        line-height: 1.35;
    }
    .carousel-controls button,
    .gallery-close {
        min-height: 48px;
        min-width: 48px;
        font-size: 16px;
        border-radius: 12px;
    }
    .foot {
        padding-bottom: 20px;
    }
    /* Полноэкранная галерея: кнопка закрытия остаётся видна при прокрутке. */
    .gallery {
        width: 100%;
        max-width: 100%;
        height: 100dvh;
        max-height: 100dvh;
        margin: 0;
        overscroll-behavior: contain;
        background: #f8fbff;
    }
    .gallery-panel {
        min-height: 100%;
        padding: max(12px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px))
            max(24px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
        border-radius: 0;
    }
    .gallery-close {
        position: sticky;
        top: max(0px, env(safe-area-inset-top, 0px));
        z-index: 2;
        box-shadow: 0 4px 16px #12335414;
        margin-bottom: 14px;
    }
    .gallery-media > img {
        height: clamp(200px, 45svh, 500px);
    }
    .gallery-media .carousel-controls {
        flex-wrap: nowrap;
        justify-content: space-between;
    }
    .gallery-description h2 {
        font-size: 26px;
    }
    .gallery-layout {
        gap: 16px;
    }
    .thumbnails {
        scroll-snap-type: x proximity;
        overscroll-behavior-x: contain;
    }
    .thumbnail {
        scroll-snap-align: center;
        min-height: 64px;
    }
    /* Во время ввода на экранной клавиатуре панель не перекрывает поля. */
    body.keyboard-open .mobile-tabs {
        visibility: hidden;
        pointer-events: none;
    }
}
@media (max-width: 359px) {
    .wrap {
        margin-left: 12px;
        margin-right: 12px;
    }
    .brand {
        font-size: 10px;
    }
    .works-grid {
        gap: 10px;
    }
    .works-grid .work-title {
        font-size: 12px;
    }
}

@media (max-width: 900px) { .mobile-tabs { grid-template-columns: repeat(auto-fit, minmax(64px, 1fr)); } }

/* Кнопка установки доступна только на мобильных экранах. */
@media (max-width: 900px) and (pointer: coarse) {
    .install-app {
        display: block;
    }
}
