/* ============ Мини-апп «Прядівський Кримінал» — modern dark ============ */
:root {
    --bg: #0e1116;
    --bg-elevated: #161b23;
    --bg-card: #1a202b;
    --line: rgba(255, 255, 255, 0.07);
    --text: #eef1f6;
    --text-muted: #8b94a5;
    --accent: #4f8cff;
    --accent-soft: rgba(79, 140, 255, 0.14);
    --success: #34c77b;
    --success-soft: rgba(52, 199, 123, 0.14);
    --danger: #ff5d6c;
    --danger-soft: rgba(255, 93, 108, 0.14);
    --warning: #f7b955;
    --warning-soft: rgba(247, 185, 85, 0.16);
    --radius: 16px;
    --radius-sm: 12px;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 1px; }

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--tg-theme-bg-color, var(--bg));
    color: var(--text);
    min-height: 100vh;
    min-height: var(--tg-viewport-stable-height, 100vh);
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: none;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; }
[hidden] { display: none !important; }

.app-shell {
    max-width: 560px;
    margin: 0 auto;
    padding: calc(var(--safe-top) + 14px) 14px calc(var(--safe-bottom) + 28px);
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* ---------- Состояния ---------- */
.state-panel {
    min-height: 60vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-align: center;
    color: var(--text-muted);
    padding: 24px;
}

.state-panel h2 { color: var(--text); font-size: 18px; }

.loader {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid var(--line);
    border-top-color: var(--accent);
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.state-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 24px;
    font-weight: 700;
    color: var(--danger);
    background: var(--danger-soft);
}

/* ---------- Профиль ---------- */
.profile-card {
    background: linear-gradient(160deg, var(--bg-card), var(--bg-elevated));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 16px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.profile-card__row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 52px;
    height: 52px;
    flex: none;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), #7a5cff);
}

.profile-card__meta { flex: 1; min-width: 0; }

.profile-card__meta h1 {
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.role-badge {
    display: inline-block;
    margin-top: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-soft);
}

.icon-button {
    width: 44px;
    height: 44px;
    flex: none;
    border-radius: var(--radius-sm);
    display: grid;
    place-items: center;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line);
    transition: background 0.15s, color 0.15s, transform 0.1s;
}
.icon-button:active { transform: scale(0.94); color: var(--text); }

/* ---------- Статистика ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 8px;
}
.stats-grid:empty { display: none; }

.stat-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 12px 10px;
    text-align: center;
}

.stat-card__value,
.stat-card strong,
.stat-card b {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

.stat-card__label,
.stat-card span,
.stat-card small {
    display: block;
    margin-top: 2px;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ---------- Секции ---------- */
.section-heading {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.section-heading h2 { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }

.count-badge {
    min-width: 24px;
    padding: 2px 8px;
    border-radius: 999px;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-soft);
}

/* ---------- Фильтры ---------- */
.filter-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    margin-bottom: 12px;
    scrollbar-width: none;
}
.filter-row::-webkit-scrollbar { display: none; }

.filter-chip {
    flex: none;
    padding: 10px 16px;
    min-height: 40px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line);
    transition: all 0.15s;
}
.filter-chip.is-active {
    color: #fff;
    background: var(--accent);
    border-color: var(--accent);
}

/* ---------- Списки карточек ---------- */
.card-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.submission-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
    text-align: left;
    width: 100%;
    transition: border-color 0.15s, transform 0.1s;
}
.submission-card:active { transform: scale(0.985); border-color: var(--accent); }

.submission-card__top,
.submission-card header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.submission-card__title,
.submission-card h3 {
    font-size: 15px;
    font-weight: 600;
}

.submission-card__meta,
.submission-card p,
.submission-card small {
    font-size: 13px;
    color: var(--text-muted);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.empty-card {
    background: var(--bg-elevated);
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    padding: 32px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

/* ---------- Статусы ---------- */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.06);
}
.status-badge--pending { color: var(--warning); background: var(--warning-soft); }
.status-badge--processing { color: var(--accent); background: var(--accent-soft); }
.status-badge--published, .status-badge--approved { color: var(--success); background: var(--success-soft); }
.status-badge--rejected, .status-badge--error, .status-badge--banned { color: var(--danger); background: var(--danger-soft); }

/* ---------- Detail sheet ---------- */
.detail-sheet {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    animation: sheet-in 0.22s ease-out;
}

/* Пока медиа грузится — блюр, спиннер и блокировка действий */
.detail-sheet.is-loading .detail-sheet__body {
    overflow: hidden;
    pointer-events: none;
    filter: blur(10px);
    opacity: 0.55;
    transition: none;
}
.detail-sheet .detail-sheet__body {
    transition: filter 0.25s ease, opacity 0.25s ease;
}
.detail-sheet.is-loading::after {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 3px solid var(--line);
    border-top-color: var(--accent);
    animation: spin 0.8s linear infinite;
    z-index: 3;
}
@keyframes sheet-in {
    from { transform: translateY(24px); opacity: 0; }
    to { transform: none; opacity: 1; }
}

.detail-sheet__header {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: calc(var(--safe-top) + 12px) 14px 12px;
    background: rgba(14, 17, 22, 0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
}
.detail-sheet__header h2 {
    flex: 1;
    font-size: 17px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.detail-sheet__body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px 14px calc(var(--safe-bottom) + 32px);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ---------- Медиа ---------- */
.media-gallery {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.media-gallery:empty { display: none; }

.media-frame {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    background: #000;
}
.media-frame img,
.media-frame video {
    display: block;
    width: 100%;
    max-height: 62vh;
    object-fit: contain;
    background: #000;
}

/* --- Кастомный видео-плеер (Telegram-style) --- */
.video-player { cursor: pointer; -webkit-tap-highlight-color: transparent; }

.vp-play {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: rgba(20, 24, 32, 0.65);
    backdrop-filter: blur(8px);
    color: #fff;
    transition: opacity 0.2s, transform 0.15s;
    pointer-events: none;
}
.vp-play svg { margin-left: 3px; }
.video-player.is-playing .vp-play { opacity: 0; transform: scale(0.8); }

.vp-bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 18px 12px 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.65));
    opacity: 0;
    transition: opacity 0.2s;
}
.video-player.is-playing .vp-bar,
.video-player.is-started .vp-bar { opacity: 1; }

.vp-time {
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    color: rgba(255, 255, 255, 0.9);
    flex: none;
}

.vp-track {
    position: relative;
    flex: 1;
    height: 16px;
    display: flex;
    align-items: center;
}
.vp-track::before {
    content: "";
    display: block;
    width: 100%;
    height: 3px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.25);
}
.vp-progress {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 3px;
    border-radius: 999px;
    background: #fff;
    pointer-events: none;
}

.vp-mute {
    flex: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
}

/* ---------- Инфо ---------- */
.info-card {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 6px 16px;
}
.info-card:empty { display: none; }

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
}
.info-row:last-child { border-bottom: 0; }
.info-row span:first-child,
.info-row .label { color: var(--text-muted); flex: none; }
.info-row span:last-child,
.info-row .value { text-align: right; word-break: break-word; }

/* ---------- Панель действий ---------- */
.action-panel {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.wm-block { display: flex; flex-direction: column; gap: 10px; }
.wm-block__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 600;
}

.switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    min-height: 44px;
}
.switch input {
    appearance: none;
    width: 44px;
    height: 26px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    position: relative;
    transition: background 0.2s;
    flex: none;
}
.switch input::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s;
}
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(18px); }

.wm-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    aspect-ratio: 16 / 9;
    max-height: 140px;
    border-radius: var(--radius-sm);
    padding: 6px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--line);
}

.wm-cell {
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid transparent;
    position: relative;
    transition: all 0.15s;
}
.wm-cell::after {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    opacity: 0.5;
}
.wm-cell.is-active { background: var(--accent-soft); border-color: var(--accent); }
.wm-cell.is-active::after { background: var(--accent); opacity: 1; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-muted); }
.field input {
    min-height: 48px;
    padding: 0 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    outline: none;
    transition: border-color 0.15s;
}
.field input:focus { border-color: var(--accent); }
.field input::placeholder { color: var(--text-muted); }

.action-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.button {
    min-height: 50px;
    padding: 0 18px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s, opacity 0.15s;
}
.button:active { transform: scale(0.97); }
.button:disabled { opacity: 0.5; pointer-events: none; }

.button--primary { background: var(--accent); color: #fff; }

.submit-cta {
    width: 100%;
    min-height: 54px;
    margin-bottom: 10px;
    gap: 8px;
    font-size: 16px;
    background: linear-gradient(135deg, var(--accent), #7a5cff);
    box-shadow: 0 6px 18px rgba(79, 140, 255, 0.35);
}

.game-cta {
    width: 100%;
    min-height: 54px;
    margin-bottom: 18px;
    gap: 8px;
    font-size: 16px;
    color: var(--text);
    background: linear-gradient(135deg, rgba(247, 185, 85, 0.18), rgba(255, 93, 108, 0.14));
    border: 1px solid rgba(247, 185, 85, 0.35);
    position: relative;
}

.soon-badge {
    position: absolute;
    top: -8px;
    right: 12px;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #1b1405;
    background: var(--warning);
}
.button--success { background: var(--success); color: #06251a; }
.button--danger { background: var(--danger-soft); color: var(--danger); border: 1px solid rgba(255, 93, 108, 0.35); }
.button--ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--line); }

.action-hint {
    font-size: 13px;
    text-align: center;
    color: var(--warning);
    background: var(--warning-soft);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}

/* ---------- Таймлайн ---------- */
.timeline {
    display: flex;
    flex-direction: column;
}
.timeline:empty { display: none; }

.timeline-item {
    position: relative;
    padding: 0 0 16px 22px;
    font-size: 13px;
    color: var(--text-muted);
}
.timeline-item::before {
    content: "";
    position: absolute;
    left: 4px;
    top: 5px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
}
.timeline-item::after {
    content: "";
    position: absolute;
    left: 7px;
    top: 16px;
    bottom: 0;
    width: 2px;
    background: var(--line);
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item:last-child::after { display: none; }
.timeline-item strong, .timeline-item b { color: var(--text); }

/* ---------- Планшет и шире ---------- */
@media (min-width: 640px) {
    .app-shell { padding-left: 0; padding-right: 0; }
    .detail-sheet { max-width: 560px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

.wm-video-note {
    font-size: 13px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}
