/*
 * Публичная страница «Поделиться» (/share/<токен>) и окно со ссылкой в истории
 * сервисов. Цвета - из web_theme.css.
 */

body.ws-page {
    margin: 0;
    min-height: 100dvh;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--web-bg);
    color: var(--web-text);
}

.ws-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--web-border-subtle, var(--web-border));
    background: var(--web-bg-header, var(--web-bg-card));
}

.ws-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--web-text);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.05rem;
}

.ws-brand img { border-radius: 50%; }

.ws-theme {
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    background: var(--web-ghost-bg);
    color: var(--web-ghost-fg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.ws-theme svg { width: 18px; height: 18px; }

.ws-wrap {
    max-width: 760px;
    margin: 0 auto;
    padding: 16px;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-sizing: border-box;
}

.ws-card {
    border: 1px solid var(--web-border);
    border-radius: 12px;
    background: var(--web-bg-card);
    padding: 16px;
}

.ws-service {
    display: inline-block;
    margin-bottom: 8px;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--web-ghost-bg);
    color: var(--web-ghost-fg);
    font-size: 0.78rem;
    font-weight: 600;
}

/* игроки и победитель - одним шрифтом, как в истории */
.ws-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.ws-title--winner,
.ws-title--line { margin-top: 2px; }

.ws-file {
    margin-top: 4px;
    font-size: 0.85rem;
    color: var(--web-text-muted);
    overflow-wrap: anywhere;
}

.ws-subtitle { margin: 0 0 10px; font-size: 1rem; }

.ws-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.ws-btn {
    display: inline-flex;
    align-items: center;
    padding: 9px 14px;
    border-radius: 8px;
    background: var(--web-ghost-bg);
    color: var(--web-ghost-fg);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
}

.ws-btn:hover { background: var(--web-ghost-hover); color: var(--web-text); }

.ws-btn--accent { background: var(--web-accent); color: #fff; }

.ws-btn--accent:hover { background: var(--web-accent); color: #fff; filter: brightness(1.08); }

/* --- окно со ссылкой в истории сервисов --- */

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

.ws-modal {
    position: fixed;
    inset: 0;
    z-index: 250000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.ws-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

.ws-modal__box {
    position: relative;
    width: min(480px, 100%);
    background: var(--web-bg-card);
    color: var(--web-text);
    border: 1px solid var(--web-border);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
    box-sizing: border-box;
}

.ws-modal__box h3 { margin: 0 0 6px; font-size: 1.05rem; }

.ws-modal__box p {
    margin: 0 0 12px;
    font-size: 0.88rem;
    color: var(--web-text-muted);
    line-height: 1.4;
}

.ws-link-row {
    display: flex;
    gap: 8px;
}

.ws-link-row input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 9px 10px;
    border: 1px solid var(--web-input-border);
    border-radius: 8px;
    background: var(--web-input-bg);
    color: var(--web-text);
    font: inherit;
    font-size: 0.85rem;
}

.ws-modal .ws-copy,
.ws-modal .ws-close {
    border: 0;
    border-radius: 8px;
    padding: 9px 14px;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.ws-modal .ws-copy { background: var(--web-accent); color: #fff; }

.ws-modal .ws-close { background: var(--web-ghost-bg); color: var(--web-ghost-fg); }

.ws-modal__status {
    min-height: 1.2em;
    margin-top: 8px;
    font-size: 0.82rem;
    color: var(--web-link);
}

.ws-modal__foot {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
}

/* --- обложка страницы: текст, картинка, голосовое --- */

.ws-block { margin: 0; }

.ws-text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.5;
    font-size: 0.98rem;
}

.ws-image img {
    display: block;
    width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 12px;
    background: var(--web-bg-sunken);
}

.ws-audio audio { display: block; width: 100%; }

.ws-actions--flush { margin-top: 0; }

/* --- окно «Поделиться»: редактор обложки --- */

.ws-composer {
    width: min(620px, 100%);
    max-height: calc(100dvh - 32px);
    overflow-x: hidden;
    overflow-y: auto;
}

.ws-composer__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.ws-composer__head h3 { margin: 0; }

.ws-x {
    border: 0;
    background: none;
    color: var(--web-text-muted);
    font-size: 1.5rem;
    line-height: 1;
    padding: 0 4px;
    cursor: pointer;
}

.ws-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

.ws-tabs button {
    border: 0;
    border-radius: 8px;
    padding: 7px 14px;
    background: var(--web-ghost-bg);
    color: var(--web-ghost-fg);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.ws-tabs button.is-active { background: var(--web-accent); color: #fff; }

.ws-hint {
    margin: 0 0 10px;
    font-size: 0.85rem;
    color: var(--web-text-muted);
}

.ws-field {
    border: 1px solid var(--web-border);
    border-radius: 12px;
    padding: 10px;
    background: var(--web-bg-sunken);
    transition: border-color 0.15s, background-color 0.15s;
}

.ws-field.is-dragover {
    border-color: var(--web-accent);
    background: color-mix(in srgb, var(--web-accent) 10%, var(--web-bg-sunken));
}

.ws-field textarea {
    width: 100%;
    min-height: 90px;
    padding: 10px;
    border: 1px solid var(--web-input-border);
    border-radius: 8px;
    background: var(--web-input-bg);
    color: var(--web-text);
    font: inherit;
    font-size: 0.92rem;
    line-height: 1.45;
    resize: vertical;
    overflow-x: hidden;
    white-space: pre-wrap;
    box-sizing: border-box;
}

.ws-counter {
    margin: 4px 2px 8px;
    text-align: right;
    font-size: 0.75rem;
    color: var(--web-text-muted);
}

.ws-counter.is-over { color: #ef5350; }

/* как зона загрузки файлов на страницах сервисов */
.ws-drop {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 18px 12px;
    border: 2px dashed var(--web-border);
    border-radius: 10px;
    color: var(--web-text-muted);
    font-size: 0.88rem;
    text-align: center;
    cursor: pointer;
}

.ws-drop:hover,
.ws-drop:focus-visible { border-color: var(--web-accent); color: var(--web-text); outline: none; }

.ws-drop small { font-size: 0.75rem; }

.ws-drop[hidden],
.ws-image-box[hidden] { display: none; }

.ws-image-box {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.ws-image-box img {
    width: 140px;
    max-height: 140px;
    object-fit: cover;
    border-radius: 8px;
    background: var(--web-bg-card);
}

.ws-image-box__actions { display: flex; flex-direction: column; gap: 6px; }

.ws-small {
    border: 0;
    border-radius: 8px;
    padding: 7px 12px;
    background: var(--web-ghost-bg);
    color: var(--web-ghost-fg);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.ws-small:hover { background: var(--web-ghost-hover); }

.ws-small--danger { color: #ef5350; }

.ws-voice {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 10px;
    padding: 10px;
    border: 1px solid var(--web-border);
    border-radius: 12px;
    background: var(--web-bg-sunken);
}

.ws-mic {
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    border: 0;
    border-radius: 50%;
    background: var(--web-accent);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.ws-mic svg { width: 22px; height: 22px; }

.ws-mic[hidden] { display: none; }

.ws-mic.is-recording {
    background: #c62828;
    animation: ws-pulse 1.2s ease-in-out infinite;
}

@keyframes ws-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(198, 40, 40, 0.5); }
    50% { box-shadow: 0 0 0 8px rgba(198, 40, 40, 0); }
}

.ws-voice__body { flex: 1 1 200px; min-width: 0; }

.ws-voice__body audio { display: block; width: 100%; }

.ws-voice__status { font-size: 0.88rem; color: var(--web-text-muted); }

.ws-voice__actions { display: flex; gap: 6px; }

/* предпросмотр: блоки страницы с ручкой для перетаскивания */
.ws-preview {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    border-radius: 12px;
    background: var(--web-bg);
}

.ws-pv-item {
    border: 1px dashed transparent;
    border-radius: 12px;
    transition: border-color 0.15s, opacity 0.15s;
}

.ws-pv-item:hover { border-color: var(--web-border); }

.ws-pv-item.is-dragging { opacity: 0.6; border-color: var(--web-accent); }

.ws-preview.is-sorting { user-select: none; }

.ws-pv-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    font-size: 0.78rem;
    color: var(--web-text-muted);
}

.ws-pv-handle,
.ws-pv-name {
    cursor: grab;
    touch-action: none;
}

.ws-pv-handle { font-size: 1rem; line-height: 1; }

.ws-pv-name { flex: 1 1 auto; font-weight: 600; }

.ws-pv-move {
    width: 26px;
    height: 26px;
    border: 0;
    border-radius: 6px;
    background: var(--web-ghost-bg);
    color: var(--web-ghost-fg);
    cursor: pointer;
}

.ws-pv-move:disabled { opacity: 0.35; cursor: default; }

.ws-pv-empty {
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--web-bg-card);
    color: var(--web-text-muted);
    font-size: 0.82rem;
}

.ws-pv-item.is-empty { opacity: 0.7; }

/* в предпросмотре кнопки просмотра не кликаются */
.ws-preview .ws-btn { cursor: default; }

.ws-ok {
    margin-bottom: 8px;
    color: var(--web-link);
    font-weight: 600;
    font-size: 0.9rem;
}

.ws-ok.is-muted { color: var(--web-text-muted); font-weight: 500; }

.ws-modal__status.is-error { color: #ef5350; }

.ws-composer__foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 12px;
}

.ws-composer__foot .ws-copy:disabled { opacity: 0.55; cursor: default; }

.ws-expires {
    margin-top: 6px;
    font-size: 0.78rem;
    color: var(--web-text-muted);
}

.ws-expires:empty { display: none; }

/* имя файла матча - серое; по ссылке скачивается сам .mat */
.ws-file--download {
    display: inline-block;
    margin-top: 6px;
    color: var(--web-text-muted);
    text-decoration: none;
    border-bottom: 1px dashed currentColor;
}

a.ws-file--download:hover { color: var(--web-text); }

/* окно с готовой ссылкой - поверх редактора */
.ws-modal--top { z-index: 250001; }

.ws-modal--top .ws-modal__box { width: min(460px, 100%); }
