:root {
    --bg-page: #f2f5f3;
    --surface: #ffffff;
    --surface-muted: #f4f7f5;
    --stage-bg: #ebeef0;
    --viewport-bg: #eef1ef;
    --border: #d5e0d9;
    --text: #152219;
    --muted: #5f6f66;
    --accent: #15803d;
    --accent-hover: #166534;
    --accent-soft: #dcfce7;
    --accent-rgb: 21, 128, 61;
    --white-rgb: 255, 255, 255;
    --danger: #dc2626;
    --danger-rgb: 220, 38, 38;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(21, 34, 25, 0.04);
    --shadow: 0 4px 24px rgba(21, 34, 25, 0.06);
    --header-h: 52px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

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

html {
    height: 100%;
    -webkit-tap-highlight-color: transparent;
}

body.app {
    margin: 0;
    min-height: 100%;
    min-height: 100dvh;
    color: var(--text);
    background: var(--bg-page);
    display: flex;
    flex-direction: column;
}

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

.app-header {
    flex-shrink: 0;
    min-height: var(--header-h);
    padding: 0.45rem 0.75rem 0.45rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.app-header__brand {
    min-width: 0;
    flex: 1;
}

.app-header__actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.45rem;
    justify-content: flex-end;
}

.btn-a2hs {
    display: none;
    align-items: center;
    gap: 0.35rem;
    padding: 0.38rem 0.65rem;
    border-radius: 999px;
    border: 1px solid rgba(var(--accent-rgb), 0.35);
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.72rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.btn-a2hs:not([hidden]) {
    display: inline-flex;
}

.btn-a2hs:hover {
    background: var(--surface);
    border-color: var(--accent);
}

.btn-a2hs:active {
    transform: scale(0.98);
}

.btn-a2hs__icon {
    flex-shrink: 0;
    opacity: 0.9;
}

.app-brand-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.45rem 0.55rem;
    min-width: 0;
}

.app-brand {
    font-size: clamp(0.92rem, 2.9vw, 1.06rem);
    font-weight: 600;
    letter-spacing: -0.028em;
    line-height: 1.2;
    color: #141414;
}

.app-badge {
    flex-shrink: 0;
    display: none;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-family: inherit;
    border-radius: 999px;
    text-transform: uppercase;
}

.app-badge--admin {
    padding: 0.3rem 0.65rem;
    font-size: 0.58rem;
    font-weight: 800;
    letter-spacing: 0.11em;
    color: #ffffff;
    background: var(--accent);
    border: 1px solid rgba(0, 0, 0, 0.12);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.22) inset,
        0 2px 6px rgba(21, 34, 25, 0.12);
}

body.app--admin .app-badge--admin {
    display: inline-flex;
}

.app-tabs {
    display: flex;
    padding: 3px;
    background: var(--surface-muted);
    border-radius: 999px;
    border: 1px solid var(--border);
}

.app-tab {
    padding: 0.35rem 0.9rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    border-radius: 999px;
    transition: color 0.15s, background 0.15s;
}

.app-tab:hover {
    color: var(--text);
}

.app-tab--active {
    color: var(--accent);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    font-weight: 700;
}

.app-main {
    flex: 1;
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 1rem 1rem calc(1rem + var(--safe-bottom));
}

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

.admin-guide {
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-muted);
}

.admin-guide__summary {
    cursor: pointer;
    list-style: none;
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--text);
    user-select: none;
}

.admin-guide__summary::-webkit-details-marker {
    display: none;
}

.admin-guide__body {
    padding: 0 1rem 1rem;
    border-top: 1px solid var(--border);
}

.admin-guide__list {
    margin: 0.75rem 0 0;
    padding-left: 1.2rem;
    font-size: 0.82rem;
    line-height: 1.55;
    color: var(--text);
}

.admin-guide__list li {
    margin-bottom: 0.6rem;
}

.admin-guide__list li:last-child {
    margin-bottom: 0;
}

.admin-guide__list strong {
    color: var(--accent);
    font-weight: 700;
}

.admin-guide__footer {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.admin-guide__signoff {
    margin: 0 0 0.85rem;
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--muted);
    font-style: italic;
}

.admin-guide__signoff-name {
    font-style: normal;
    font-weight: 600;
    color: var(--text);
}

.admin-guide__help-label {
    margin: 0 0 0.45rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.admin-guide__tg {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem 0.5rem;
    padding: 0.55rem 0.85rem;
    border-radius: 999px;
    border: 1px solid rgba(36, 161, 222, 0.45);
    background: #f0f9ff;
    color: #0369a1;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.admin-guide__tg:hover {
    background: #e0f2fe;
    border-color: #0284c7;
    color: #0c4a6e;
}

.admin-guide__tg:active {
    transform: scale(0.99);
}

.admin-guide__tg-icon {
    flex-shrink: 0;
}

.admin-guide__tg-text {
    font-weight: 600;
}

.admin-guide__tg-user {
    font-weight: 700;
    opacity: 0.95;
}

.admin-guide__anim-wrap {
    margin: 0.85rem 0 0;
}

.admin-guide__anim-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.5rem 0.9rem;
    border-radius: 999px;
    border: 1px solid rgba(var(--accent-rgb), 0.35);
    background: var(--surface);
    color: var(--accent);
    font-size: 0.82rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.admin-guide__anim-btn:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
}

.admin-guide__anim-btn:active {
    transform: scale(0.98);
}

.admin-guide__anim-icon {
    flex-shrink: 0;
    opacity: 0.9;
}

.editor-import {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.btn-camera {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    min-height: 92px;
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    cursor: pointer;
    border: 2px solid rgba(0, 0, 0, 0.08);
    background: var(--accent);
    color: #ffffff;
    box-shadow: var(--shadow-sm);
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
    text-align: center;
    font-family: inherit;
}

.btn-camera:hover {
    background: var(--accent-hover);
    box-shadow: var(--shadow);
}

.btn-camera:active {
    transform: scale(0.99);
}

.btn-camera:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn-camera__icon {
    flex-shrink: 0;
    opacity: 0.95;
    margin-bottom: 0.15rem;
}

.btn-camera__text {
    font-size: 1.02rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.btn-camera__hint {
    font-size: 0.72rem;
    font-weight: 500;
    opacity: 0.92;
    max-width: 300px;
    line-height: 1.4;
}

.drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: 100px;
    padding: 1.25rem;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-muted);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.drop-zone:hover,
.drop-zone:focus-within {
    border-color: rgba(var(--accent-rgb), 0.45);
    background: var(--surface);
}

.drop-zone__label {
    font-size: 0.9rem;
    font-weight: 600;
}

.drop-zone__sub {
    font-size: 0.75rem;
    color: var(--muted);
}

.drop-zone--secondary {
    min-height: 78px;
    padding: 0.9rem 1rem;
}

.editor-wrap {
    display: none;
}

.editor-wrap.visible {
    display: block;
}

.stage-wrap {
    border-radius: var(--radius-sm);
    overflow: auto;
    max-height: min(62vh, 520px);
    background: var(--stage-bg);
    border: 1px solid var(--border);
}

.stage {
    position: relative;
    display: inline-block;
    min-width: 100%;
    vertical-align: top;
}

.stage img#photoPreview {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    vertical-align: top;
}

.caption-overlay {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: max(8px, 2%);
    z-index: 1;
    max-width: 92%;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    background: rgba(21, 34, 25, 0.78);
    color: #ffffff;
    border: none;
    font-size: clamp(0.72rem, 2.6vw, 1rem);
    font-weight: 600;
    text-align: center;
    word-break: break-word;
    line-height: 1.25;
    pointer-events: none;
    box-shadow: var(--shadow-sm);
}

.logo-box {
    position: absolute;
    z-index: 2;
    width: 120px;
    cursor: grab;
    user-select: none;
    touch-action: none;
    /* drop-shadow на .logo-overlay: иначе filter+transform на одном узле ломают rotate в Safari */
}

.logo-box:active {
    cursor: grabbing;
}

.logo-overlay {
    display: block;
    width: 100%;
    height: auto;
    pointer-events: none;
    vertical-align: top;
    filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.45));
}

.logo-resize-handle {
    position: absolute;
    right: -5px;
    bottom: -5px;
    width: 18px;
    height: 18px;
    background: var(--accent);
    border: 2px solid var(--surface);
    border-radius: 5px;
    cursor: nwse-resize;
    pointer-events: auto;
}

.editor-chrome {
    position: relative;
    z-index: 2;
}

.editor-chrome .editor-toolbar {
    margin-top: 0.85rem;
}

.editor-toolbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border);
}

.caption-row {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.caption-row label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.caption-input {
    width: 100%;
    padding: 0.55rem 0.75rem;
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.caption-input::placeholder {
    color: var(--muted);
}

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

.scale-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

.scale-row label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    flex-shrink: 0;
}

.scale-row input[type='range'] {
    flex: 1;
    min-width: 80px;
    accent-color: var(--accent);
}

.scale-value {
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
    color: var(--muted);
    width: 2.5rem;
    text-align: right;
}

.scale-value--angle {
    width: auto;
    min-width: 3rem;
}

.btn-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

.btn-row--split {
    gap: 0.5rem;
}

.btn-row--split .btn {
    flex: 1;
    min-width: 0;
}

.btn-secondary {
    flex: 1;
    min-width: 120px;
    padding: 0.6rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: var(--radius-sm);
    cursor: pointer;
    touch-action: manipulation;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    transition: transform 0.1s, opacity 0.15s, background 0.15s, border-color 0.15s;
}

.btn-secondary:hover:not(:disabled) {
    background: var(--surface-muted);
    border-color: rgba(var(--accent-rgb), 0.35);
}

.btn-secondary:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-secondary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}


.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.6rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    transition: transform 0.1s, opacity 0.15s, background 0.15s;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    flex: 1;
    min-width: 140px;
    background: var(--accent);
    color: #ffffff;
    transition: transform 0.1s, opacity 0.15s, background 0.15s;
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-ghost {
    padding: 0.55rem;
    min-width: 44px;
    min-height: 44px;
    background: var(--surface-muted);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--surface);
    border-color: rgba(var(--accent-rgb), 0.35);
}

.toast {
    margin-top: 0.65rem;
    font-size: 0.8rem;
    min-height: 1.2em;
    color: var(--muted);
}

.toast--error {
    color: var(--danger);
}

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

.gallery-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.gallery-head__text {
    flex: 1;
    min-width: 0;
}

.gallery-head h2 {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}

.gallery-head__hint {
    margin: 0.35rem 0 0;
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: var(--muted);
    line-height: 1.35;
}

.gallery-daydivider {
    grid-column: 1 / -1;
    margin: 0.5rem 0 0.2rem;
    padding-bottom: 0.15rem;
    border-bottom: 1px solid var(--border);
}

.gallery-daydivider:first-child {
    margin-top: 0;
}

.gallery-daydivider__title {
    margin: 0;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    color: var(--text);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
}

.gallery-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.gallery-card:hover {
    border-color: rgba(var(--accent-rgb), 0.35);
    box-shadow: var(--shadow);
}

.gallery-card__media {
    position: relative;
    overflow: hidden;
    background: var(--stage-bg);
}

.gallery-card img.gallery-card__thumb {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    display: block;
    cursor: zoom-in;
    transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.gallery-card:hover .gallery-card__thumb {
    transform: scale(1.05);
}

.gallery-card__meta {
    padding: 0.4rem 0.55rem 0.35rem;
    border-top: 1px solid var(--border);
    background: var(--surface-muted);
}

.gallery-card__meta time {
    display: block;
    font-size: 0.68rem;
    font-weight: 650;
    letter-spacing: 0.03em;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.gallery-card .card-actions {
    padding: 0.55rem 0.5rem 0.6rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: stretch;
    background: var(--surface);
    border-top: 1px solid var(--border);
}

.gallery-card .btn-gallery {
    flex: 1 1 calc(33.33% - 0.4rem);
    min-width: 5.5rem;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.45rem 0.55rem;
    font-size: 0.74rem;
    letter-spacing: 0.01em;
    color: var(--text);
    font-family: inherit;
    font-weight: 650;
    border-radius: 999px;
    cursor: pointer;
    touch-action: manipulation;
    border: 1px solid var(--border);
    background: var(--surface-muted);
    transition: transform 0.12s, border-color 0.15s, background 0.15s;
}

.gallery-card .btn-gallery:hover {
    border-color: rgba(var(--accent-rgb), 0.4);
    background: var(--surface);
}

.gallery-card .btn-gallery:active {
    transform: scale(0.97);
}

.gallery-card .btn-gallery--accent {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
}

.gallery-card .btn-gallery--accent:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.gallery-lightbox {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(0.75rem, env(safe-area-inset-top)) max(0.75rem, env(safe-area-inset-right))
        max(0.75rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
    pointer-events: none;
}

.gallery-lightbox[hidden] {
    display: none !important;
}

.gallery-lightbox--open {
    pointer-events: auto;
}

.gallery-lightbox__backdrop {
    position: absolute;
    inset: 0;
    cursor: pointer;
    background: rgba(21, 34, 25, 0.35);
    opacity: 0;
    transition: opacity 0.28s ease;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.gallery-lightbox--open .gallery-lightbox__backdrop {
    opacity: 1;
}

.gallery-lightbox__shell {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: min(100%, 1100px);
    max-height: min(94dvh, 920px);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: hidden;
    opacity: 0;
    transform: scale(0.94) translateY(12px);
    transition:
        opacity 0.3s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.34s cubic-bezier(0.22, 1, 0.36, 1);
}

.gallery-lightbox--open .gallery-lightbox__shell {
    opacity: 1;
    transform: scale(1) translateY(0);
}

.gallery-lightbox__header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem 0.55rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.gallery-lightbox__filename {
    margin: 0;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.gallery-lightbox__header-btn {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--surface-muted);
    color: var(--muted);
    cursor: pointer;
    transition: background 0.15s, transform 0.12s, color 0.15s;
}

.gallery-lightbox__header-btn:hover {
    background: rgba(var(--danger-rgb), 0.1);
    color: var(--danger);
}

.gallery-lightbox__header-btn:active {
    transform: scale(0.94);
}

.gallery-lightbox__viewport {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1rem;
    background: var(--viewport-bg);
}

.gallery-lightbox__img {
    display: block;
    max-width: 100%;
    max-height: min(72dvh, 720px);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    user-select: none;
    -webkit-user-drag: none;
}

.gallery-lightbox__footer {
    flex-shrink: 0;
    display: flex;
    gap: 0.65rem;
    padding: 0.75rem 1rem max(0.85rem, env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.gallery-lightbox__action {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 48px;
    padding: 0.55rem 1rem;
    font-size: 0.9rem;
    font-weight: 650;
    font-family: inherit;
    color: #ffffff;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    touch-action: manipulation;
    background: var(--accent);
    transition: transform 0.12s, background 0.15s;
}

.gallery-lightbox__action:hover {
    background: var(--accent-hover);
}

.gallery-lightbox__action:active {
    transform: scale(0.98);
}

.gallery-lightbox__action--secondary {
    flex: 1;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: none;
}

.gallery-lightbox__action--secondary:hover {
    background: var(--surface-muted);
    border-color: rgba(var(--accent-rgb), 0.35);
}

.gallery-lightbox__icon {
    flex-shrink: 0;
    opacity: 0.95;
}

.gallery-lightbox__grab {
    display: none;
}

/* Мобильный просмотр: полноэкранная шторка снизу, крупные кнопки */
@media (max-width: 560px) {
    .gallery-lightbox {
        padding: 0;
        align-items: flex-end;
        justify-content: stretch;
    }

    .gallery-lightbox__shell {
        width: 100%;
        max-width: none;
        max-height: 100dvh;
        height: 100dvh;
        margin: 0;
        border-radius: 22px 22px 0 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
        box-shadow: 0 -8px 32px rgba(21, 34, 25, 0.12);
        transform: translate3d(0, 105%, 0);
        opacity: 1;
        transition:
            transform 0.34s cubic-bezier(0.32, 0.72, 0, 1),
            opacity 0.22s ease;
    }

    .gallery-lightbox--open .gallery-lightbox__shell {
        transform: translate3d(0, 0, 0);
        opacity: 1;
    }

    .gallery-lightbox__grab {
        display: block;
        width: 40px;
        height: 5px;
        margin: 10px auto 6px;
        border-radius: 999px;
        background: var(--border);
        flex-shrink: 0;
    }

    .gallery-lightbox__header {
        padding: 0.35rem 0.75rem 0.6rem;
        padding-top: max(0.35rem, env(safe-area-inset-top, 0px));
        border-bottom: 1px solid var(--border);
    }

    .gallery-lightbox__filename {
        font-size: 0.88rem;
        line-height: 1.25;
        white-space: nowrap;
    }

    .gallery-lightbox__header-btn {
        width: 48px;
        height: 48px;
        min-width: 48px;
        min-height: 48px;
        border-radius: 14px;
        background: var(--surface-muted);
    }

    .gallery-lightbox__viewport {
        flex: 1 1 auto;
        min-height: 0;
        padding: 0.5rem 0.65rem;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    .gallery-lightbox__img {
        max-width: 100%;
        max-height: min(68dvh, calc(100dvh - 220px));
        width: auto;
        margin: 0 auto;
        border-radius: 14px;
    }

    .gallery-lightbox__footer {
        flex-direction: column;
        gap: 0.55rem;
        padding: 0.85rem 0.85rem;
        padding-bottom: max(1rem, calc(0.75rem + env(safe-area-inset-bottom, 0px)));
        border-top: 1px solid var(--border);
        background: var(--surface-muted);
    }

    .gallery-lightbox__action,
    .gallery-lightbox__action--secondary {
        width: 100%;
        min-height: 54px;
        padding: 0.7rem 1.1rem;
        font-size: 1rem;
        font-weight: 700;
        border-radius: 16px;
        gap: 0.65rem;
        letter-spacing: 0.02em;
    }

    .gallery-lightbox__action {
        box-shadow: none;
        order: -1;
    }

    .gallery-lightbox__action--secondary {
        min-height: 52px;
        order: 0;
    }

    .gallery-lightbox__icon {
        width: 22px;
        height: 22px;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
        gap: 0.65rem;
    }

    .gallery-card .btn-gallery {
        min-height: 44px;
        font-size: 0.78rem;
    }
}

@media (min-width: 561px) and (max-width: 900px) {
    .gallery-lightbox__shell {
        width: min(100%, 720px);
    }

    .gallery-lightbox__footer {
        padding-bottom: max(0.85rem, env(safe-area-inset-bottom, 0px));
    }
}

.gallery-card .filename {
    display: none;
}

.empty-gallery {
    text-align: center;
    padding: 2.5rem 1rem;
    font-size: 0.9rem;
    color: var(--muted);
}

.gallery-toast {
    font-size: 0.8rem;
    min-height: 1.2em;
    margin-bottom: 0.5rem;
    color: var(--muted);
}

.gallery-toast--error {
    color: var(--danger);
}

.a2hs-modal {
    position: fixed;
    inset: 0;
    z-index: 3100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(0.75rem, env(safe-area-inset-top)) max(0.75rem, env(safe-area-inset-right))
        max(0.75rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
}

.a2hs-modal[hidden] {
    display: none !important;
}

.a2hs-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(21, 34, 25, 0.38);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.a2hs-modal__panel {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    max-height: min(88dvh, 560px);
    overflow: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.a2hs-modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.a2hs-modal__title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
}

.a2hs-modal__close {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--surface-muted);
    color: var(--muted);
    cursor: pointer;
}

.a2hs-modal__close:hover {
    background: var(--border);
    color: var(--text);
}

.a2hs-modal__body {
    padding: 1rem;
    font-size: 0.84rem;
    line-height: 1.55;
    color: var(--text);
}

.a2hs-steps {
    margin: 0;
    padding-left: 1.2rem;
}

.a2hs-steps li {
    margin-bottom: 0.65rem;
}

.a2hs-steps li:last-child {
    margin-bottom: 0;
}

.a2hs-steps strong {
    color: var(--accent);
}

.a2hs-hint {
    color: var(--muted);
    font-weight: 500;
    font-size: 0.8em;
}

.a2hs-note {
    margin: 0.85rem 0 0;
    padding: 0.65rem 0.75rem;
    border-radius: var(--radius-sm);
    background: var(--surface-muted);
    border: 1px solid var(--border);
    font-size: 0.78rem;
    color: var(--muted);
}

@keyframes tut-ring {
    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.45);
    }
    55% {
        box-shadow: 0 0 0 12px rgba(var(--accent-rgb), 0);
    }
}

@keyframes tut-tap {
    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }
    35% {
        transform: translate(3px, 10px) scale(0.9);
    }
}

.tut-modal {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(0.75rem, env(safe-area-inset-top)) max(0.75rem, env(safe-area-inset-right))
        max(0.75rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
}

.tut-modal[hidden] {
    display: none !important;
}

.tut-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(21, 34, 25, 0.38);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.tut-modal__panel {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 520px;
    max-height: min(92dvh, 720px);
    overflow: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.tut-modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.tut-modal__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

.tut-modal__close {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--surface-muted);
    color: var(--muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.tut-modal__close:hover {
    background: var(--border);
    color: var(--text);
}

.tut-modal__scene-wrap {
    padding: 0.85rem 1rem 0.5rem;
}

.tut-modal__scene {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    position: relative;
    min-height: 200px;
}

.tut-demo {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    padding: 0.55rem;
    background: var(--surface-muted);
    transition:
        opacity 0.45s ease,
        filter 0.45s ease;
}

.tut-demo__label {
    margin: 0 0 0.4rem;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--muted);
}

.tut-demo__screen {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.tut-fake {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.55rem;
    border-radius: var(--radius-sm);
    font-size: 0.72rem;
    font-weight: 650;
    line-height: 1.25;
    color: var(--text);
    border: 1px solid var(--border);
    background: var(--surface);
    transition: box-shadow 0.2s;
}

.tut-fake__ico {
    flex-shrink: 0;
    opacity: 0.85;
}

.tut-fake--cam {
    background: var(--accent-soft);
    border-color: rgba(var(--accent-rgb), 0.35);
    color: var(--accent);
}

.tut-fake--gal {
    border-style: dashed;
}

.tut-demo__screen--pc {
    gap: 0.5rem;
}

.tut-pc__tabs {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.tut-pc__tab {
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 600;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--muted);
}

.tut-pc__tab--hot {
    background: var(--accent-soft);
    border-color: rgba(var(--accent-rgb), 0.4);
    color: var(--accent);
    font-weight: 700;
}

.tut-pc__card {
    padding: 0.45rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
}

.tut-pc__thumb {
    aspect-ratio: 4 / 3;
    border-radius: 6px;
    background: var(--stage-bg);
    margin-bottom: 0.45rem;
}

.tut-pc__row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.tut-pc__pill {
    padding: 0.28rem 0.45rem;
    border-radius: 999px;
    font-size: 0.58rem;
    font-weight: 650;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    color: var(--text);
}

.tut-pc__pill--print {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
    font-weight: 700;
}

.tut-pointer {
    position: absolute;
    z-index: 4;
    width: 36px;
    height: 36px;
    margin-top: -6px;
    margin-left: -6px;
    pointer-events: none;
    color: var(--accent);
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.18));
    opacity: 0;
    transition:
        top 0.55s cubic-bezier(0.22, 0.82, 0.28, 1),
        left 0.55s cubic-bezier(0.22, 0.82, 0.28, 1),
        opacity 0.35s ease;
}

.tut-modal__scene[data-step='camera'] .tut-pointer,
.tut-modal__scene[data-step='gallery'] .tut-pointer,
.tut-modal__scene[data-step='pc-tab'] .tut-pointer,
.tut-modal__scene[data-step='pc-print'] .tut-pointer {
    opacity: 1;
    animation: tut-tap 1.1s ease-in-out infinite;
}

.tut-modal__scene[data-step='intro'] .tut-pointer,
.tut-modal__scene[data-step='bridge'] .tut-pointer {
    animation: none;
    opacity: 0;
}

.tut-modal__scene[data-step='camera'] .tut-pointer {
    top: 42%;
    left: 28%;
}

.tut-modal__scene[data-step='gallery'] .tut-pointer {
    top: 68%;
    left: 28%;
}

.tut-modal__scene[data-step='pc-tab'] .tut-pointer {
    top: 18%;
    left: 78%;
}

.tut-modal__scene[data-step='pc-print'] .tut-pointer {
    top: 72%;
    left: 82%;
}

.tut-modal__scene[data-step='camera'] .tut-demo--pc,
.tut-modal__scene[data-step='gallery'] .tut-demo--pc {
    opacity: 0.4;
    filter: grayscale(0.2);
}

.tut-modal__scene[data-step='pc-tab'] .tut-demo--phone,
.tut-modal__scene[data-step='pc-print'] .tut-demo--phone {
    opacity: 0.4;
    filter: grayscale(0.2);
}

.tut-modal__scene[data-step='bridge'] .tut-demo {
    opacity: 0.88;
}

.tut-modal__scene[data-step='camera'] .tut-fake--cam {
    animation: tut-ring 1.85s ease-out infinite;
}

.tut-modal__scene[data-step='gallery'] .tut-fake--gal {
    animation: tut-ring 1.85s ease-out infinite;
}

.tut-modal__scene[data-step='pc-tab'] .tut-pc__tab--hot {
    animation: tut-ring 1.85s ease-out infinite;
}

.tut-modal__scene[data-step='pc-print'] .tut-pc__pill--print {
    animation: tut-ring 1.85s ease-out infinite;
}

.tut-modal__caption {
    margin: 0;
    padding: 0.65rem 1rem 0.35rem;
    font-size: 0.84rem;
    line-height: 1.5;
    color: var(--text);
    min-height: 3.2em;
}

.tut-modal__dots {
    display: flex;
    justify-content: center;
    gap: 0.35rem;
    padding: 0 1rem 0.5rem;
}

.tut-modal__dot {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: var(--border);
    transition:
        transform 0.2s,
        background 0.2s;
}

.tut-modal__dot--active {
    background: var(--accent);
    transform: scale(1.2);
}

.tut-modal__foot {
    padding: 0.35rem 1rem 1rem;
}

@media (max-width: 520px) {
    .tut-modal__scene {
        grid-template-columns: 1fr;
    }

    .tut-modal__scene[data-step='camera'] .tut-pointer {
        top: 28%;
        left: 42%;
    }

    .tut-modal__scene[data-step='gallery'] .tut-pointer {
        top: 52%;
        left: 42%;
    }

    .tut-modal__scene[data-step='pc-tab'] .tut-pointer {
        top: 14%;
        left: 55%;
    }

    .tut-modal__scene[data-step='pc-print'] .tut-pointer {
        top: 68%;
        left: 58%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tut-pointer,
    .tut-fake--cam,
    .tut-fake--gal,
    .tut-pc__tab--hot,
    .tut-pc__pill--print {
        animation: none !important;
    }

    .tut-pointer {
        transition: none;
    }
}

@media print {
    body.app {
        background: #fff;
        color: #000;
    }

    .app-header,
    .no-print,
    .gallery-card .card-actions {
        display: none !important;
    }

    .gallery-card img {
        aspect-ratio: auto;
        max-height: none;
    }
}
