/* Каркас страниц Студии и редактора ролика: верхняя полоса, полоса этапов, рабочая область на всё окно.
   ТЗ: Tasks/WBChess_TZ_studio_redesign.md, §5. Шапка и подвал сайта на этих страницах скрыты: в них остаются
   только скрипты и переключатель темы (#themeToggle), которые нужны странице.

   Цвета берутся из палитры сайта (--c-*, css/theme.css): тёмная тема переключает их сама. */

body.st-focus {
    margin: 0;
    overflow: hidden;
}

body.st-focus .u-header,
body.st-focus .u-footer,
body.st-focus .u-backlink,
body.st-focus .footer-userid {
    display: none;
}

.st-shell {
    max-width: none;
    margin: 0;
    padding: 0;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: var(--c-bg, #f5f7fb);
    color: var(--c-text, #1d2740);
    font-family: inherit;
}

.st-shell .st-narrow {
    padding: 40px 20px;
}

.ss-app {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto minmax(0, 1fr);
    height: 100%;
    min-height: 0;
    gap: 0;
    align-items: stretch;
    align-content: stretch;
}

.ss-app[hidden] { display: none; }

/* Полоса сообщений скрыта, когда ей нечего сказать, поэтому места рядов задаются явно: рабочая область всегда в растягиваемом ряду */
.ss-top { grid-row: 1; }
.ss-notes { grid-row: 2; }
.ss-stages { grid-row: 3; }
.ss-work { grid-row: 4; }

/* ── Верхняя полоса ───────────────────────────────────────────────────────── */

.ss-top {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: var(--c-surface, #fff);
    border-bottom: 1px solid var(--c-border, #dfe4ef);
    min-width: 0;
}

.ss-top > * { flex: 0 0 auto; }

.ss-back {
    color: var(--c-accent-text, #4455c8);
    text-decoration: none;
    font-size: 0.92rem;
    white-space: nowrap;
}

.ss-back:hover { text-decoration: underline; }

.ss-scenario {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 260px;
    min-width: 0;
}

.ss-scenario-title {
    min-width: 0;
    max-width: 38ch;
    padding: 5px 10px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    font: inherit;
    font-weight: 600;
    color: inherit;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.ss-scenario-title:hover { border-color: var(--c-border, #dfe4ef); background: var(--c-surface-2, #eef1f8); }
.ss-scenario-title:empty { display: none; }

.ss-link {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    font-size: 0.85rem;
    color: var(--c-accent-text, #4455c8);
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
}

.ss-link:hover { text-decoration: underline; }
.ss-link[hidden] { display: none; }

.ss-status {
    font-size: 0.82rem;
    color: var(--c-muted, #5b6784);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.ss-status[data-status="error"],
.ss-status[data-status="conflict"],
.ss-status[data-status="limit"] { color: var(--c-danger, #b3261e); }

.ss-group { display: flex; gap: 4px; }
.ss-spacer { flex: 1 1 0; min-width: 0; }

.ss-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border: 1px solid var(--c-border, #dfe4ef);
    border-radius: 999px;
    font-size: 0.8rem;
    white-space: nowrap;
}

.ss-chip[hidden] { display: none; }

.ss-chip-live { color: #15803d; border-color: transparent; background: #dcfce7; }
.ss-chip-live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

.ss-format .st-seg-btn { padding: 5px 10px; font-size: 0.82rem; }
.ss-format .st-seg-btn:disabled { opacity: 0.5; cursor: default; }

.ss-top .st-btn { padding: 5px 10px; }

/* Управление записью (видно на любой странице) */
.ss-rec {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 8px;
    border: 1px solid var(--st-rec, #d97706);
    border-radius: 10px;
    font-size: 0.85rem;
    min-width: 0;
}

.ss-rec[hidden] { display: none; }
.ss-rec .st-rec-live { gap: 8px; font-weight: 600; }
.ss-rec .st-btn { padding: 3px 9px; font-size: 0.82rem; }
.ss-rec p { margin: 0; font-size: 0.8rem; }
.ss-rec .st-rec-result { flex-direction: row; align-items: center; padding: 3px 8px; }
.ss-rec .st-rec-result button { align-self: center; }

/* ── Сообщения ────────────────────────────────────────────────────────────── */

.ss-notes {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    padding: 6px 16px;
    background: var(--c-surface-2, #eef1f8);
    border-bottom: 1px solid var(--c-border, #dfe4ef);
    font-size: 0.85rem;
}

.ss-notes[hidden] { display: none; }

/* Подсказка на время записи и показа ролика: строка во всю ширину над остальными сообщениями */
.st-rec-cue {
    flex: 1 1 100%;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 4px 10px;
    border-left: 4px solid var(--c-border, #dfe4ef);
    border-radius: 6px;
}
.st-rec-cue[hidden] { display: none; }
.st-rec-cue-head { display: flex; flex-wrap: wrap; gap: 4px 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.st-rec-cue-next { color: var(--c-muted, #5b6784); }
.st-rec-cue-text { font-size: 1rem; line-height: 1.4; overflow-wrap: anywhere; }
.st-rec-cue-text[hidden] { display: none; }
.st-rec-cue.is-soon { border-left-color: var(--st-rec, #d97706); background: #fef3c7; }
.st-rec-cue.is-soon .st-rec-cue-next { color: #92400e; }
.ss-notes > :empty { display: none; }
.ss-notes .st-status { min-height: 0; }

/* ── Полоса этапов ────────────────────────────────────────────────────────── */

.ss-stages {
    display: flex;
    gap: 6px;
    padding: 8px 16px;
    overflow-x: auto;
    scrollbar-width: thin;
}

.ss-stage {
    flex: 1 0 150px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto auto;
    gap: 0 10px;
    align-items: center;
    padding: 7px 12px;
    border: 1px solid var(--c-border, #dfe4ef);
    border-radius: 12px;
    background: var(--c-surface, #fff);
    font: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.ss-stage:hover { border-color: var(--c-accent, #5568e0); }

.ss-stage-num {
    grid-row: span 2;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--c-surface-2, #eef1f8);
    color: var(--c-muted, #5b6784);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.ss-stage-name { font-weight: 600; line-height: 1.25; }

.ss-stage-sub {
    font-size: 0.75rem;
    color: var(--c-muted, #5b6784);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.25;
    min-height: 1em;
}

.ss-stage.is-active { border-color: var(--c-accent, #5568e0); box-shadow: inset 0 0 0 1px var(--c-accent, #5568e0); }
.ss-stage.is-active .ss-stage-num { background: var(--c-accent, #5568e0); color: var(--c-on-accent, #fff); }

/* ── Рабочая область ──────────────────────────────────────────────────────── */

.ss-work {
    display: grid;
    min-height: 0;
    gap: 10px 16px;
    padding: 0 16px 14px;
    grid-template-columns: minmax(0, 1fr) 440px;
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-areas:
        "stage side"
        "under side";
}

.ss-cell { min-width: 0; min-height: 0; }
.ss-cell-stage { grid-area: stage; position: relative; }
.ss-cell-under { grid-area: under; display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.ss-cell-under:not(:has(> :not([hidden]))) { display: none; }
.ss-cell-side {
    grid-area: side;
    overflow-y: auto;
    border: 1px solid var(--c-border, #dfe4ef);
    border-radius: 12px;
    background: var(--c-surface, #fff);
}

/* Сцена одна на все страницы. Где она стоит, решает сетка (data-page); на странице без сцены она остаётся в документе
   с прежним размером (visibility, а не display: none), иначе доска получит нулевой размер */
.ss-cell-stage .st-wrap {
    position: absolute;
    inset: 0;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
}

.ss-cell-stage .st-wrap-fit {
    position: absolute;
    inset: 0;
    width: auto;
    aspect-ratio: auto;
}

.ss-cell-stage .studio-stage { border-radius: 14px; box-shadow: 0 2px 14px rgba(0, 0, 0, 0.35); }
.ss-cell-stage .st-wrap.is-show .studio-stage { border-radius: 0; box-shadow: none; }
.ss-cell-stage .st-wrap:fullscreen { background: #000; }

.ss-app[data-page="rec"] .ss-work {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas: "side";
}

.ss-app[data-page="rec"] .ss-cell-stage {
    position: absolute;
    left: 0;
    top: 0;
    width: 960px;
    height: 540px;
    visibility: hidden;
    pointer-events: none;
}

.ss-app[data-page="rec"] .ss-cell-under { display: none; }

.ss-app[data-page="scene"] .ss-cell-under { display: none; }

.ss-cell-side .st-section { border: 0; }

/* Лента ходов под сценой («Разметка», «Вид») */
.ss-ribbon {
    max-height: 96px;
    overflow-y: auto;
    padding: 6px 10px;
    border: 1px solid var(--c-border, #dfe4ef);
    border-radius: 10px;
    background: var(--c-surface, #fff);
    color: var(--c-text, #1d2740);
    font-size: 0.95rem;
    line-height: 1.5;
}

.ss-ribbon .st-moves-title,
.ss-ribbon .st-moves-fill { display: none; }

.ss-ribbon .st-moves-grid {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 4px;
}

.ss-ribbon .st-moves-num { text-align: left; margin-left: 6px; }
.ss-ribbon .st-moves-var,
.ss-ribbon .st-moves-steps,
.ss-ribbon .st-moves-game { flex: 0 0 100%; margin-left: 0 !important; }

/* Списки и панели внутри правой колонки растягиваются по высоте колонки */
.ss-app[data-page="game"] .ss-cell-side { display: flex; flex-direction: column; }
.ss-app[data-page="game"] .st-section-game { flex: 1 1 auto; min-height: 0; }
.ss-app[data-page="game"] .st-moves { flex: 1 1 120px; min-height: 120px; }

.ss-rec-page { max-width: 1180px; margin: 0 auto; width: 100%; }

/* «Показ и запись»: три карточки - «Вживую», «Ролик по сценарию», «Мои записи» */
.ss-rec-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    align-items: start;
}

.ss-rec-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--c-border, #d6dae1);
    border-radius: 12px;
    background: var(--c-surface, #fff);
}

.ss-rec-card h3 { margin: 0; font-size: 1rem; }
.ss-rec-video-box { display: flex; flex-direction: column; gap: 8px; }
.ss-rec-video-box .st-row { flex-wrap: wrap; }
.ss-rec-video-box .st-rec-notice { margin: 0; padding: 6px 10px; font-size: 0.82rem; }
.ss-rec-video-box .st-btn { width: auto; align-self: flex-start; }

.ss-rec-preview {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: 8px;
    background: #000;
}

.ss-rec-meter { display: flex; flex-direction: column; gap: 4px; font-size: 0.82rem; }

.ss-rec-meter-track {
    height: 8px;
    overflow: hidden;
    border-radius: 4px;
    background: var(--c-surface-2, #e8ebf0);
}

.ss-rec-meter-bar {
    width: 0;
    height: 100%;
    border-radius: 4px;
    background: #22c55e;
}

/* Громкость, автоподстройка и проверка микрофона под шкалой уровня */
.ss-rec-mic-tune { display: flex; flex-direction: column; gap: 8px; font-size: 0.82rem; }
.ss-rec-mic-tune[hidden] { display: none; }

.ss-rec-slider {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 2px 10px;
}

.ss-rec-slider > span:first-child { grid-column: 1 / -1; }
.ss-rec-slider input[type="range"] { width: 100%; min-width: 0; margin: 0; }
.ss-rec-slider-value { min-width: 3.2em; text-align: right; font-variant-numeric: tabular-nums; }

.ss-rec-check { display: flex; align-items: flex-start; gap: 6px; cursor: pointer; }
.ss-rec-check input { flex: none; margin: 2px 0 0; }

.ss-rec-mic-test { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.ss-rec-mic-test .st-btn { width: auto; }

.ss-rec-scenes { display: flex; flex-direction: column; gap: 6px; }
.ss-rec-scene-row { display: flex; flex-wrap: wrap; gap: 6px; }

@media (max-width: 1280px) {
    .ss-rec-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1000px) {
    .ss-rec-grid { grid-template-columns: minmax(0, 1fr); }
}

/* Разделы «Сцены» (Расположение / Показ / Фон) */
.ss-subtabs {
    display: flex;
    gap: 4px;
    padding-bottom: 8px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--c-border, #dfe4ef);
}

.ss-subtab {
    flex: 1 1 0;
    padding: 6px 8px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    font: inherit;
    font-size: 0.88rem;
    color: var(--c-muted, #5b6784);
    cursor: pointer;
}

.ss-subtab:hover { color: var(--c-text, #1d2740); }
.ss-subtab.is-active { background: var(--c-accent-soft, #eceffd); color: var(--c-accent-text, #4455c8); font-weight: 600; }

.ss-subpanel[hidden] { display: none; }

/* ── Строка рисования и панель «Разметка» ─────────────────────────────────── */

.ss-draw {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px 22px;
    padding: 6px 10px;
    border: 1px solid var(--c-border, #dfe4ef);
    border-radius: 10px;
    background: var(--c-surface, #fff);
}

.ss-draw[hidden] { display: none; }

.ss-draw-colors, .ss-draw-marks { display: flex; align-items: center; gap: 4px; }
.ss-draw-label { font-size: 0.78rem; color: var(--c-muted, #5b6784); margin-right: 4px; white-space: nowrap; }
.ss-draw-hint { flex: 1 1 100%; text-align: center; font-size: 0.78rem; color: var(--c-muted, #5b6784); }

/* Кнопка цвета: цифра на цвете (клавиши 1-8) */
.ss-color {
    display: inline-grid;
    place-items: center;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 50%;
    background: var(--swatch, #888);
    color: #fff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    text-shadow: 0 0 2px rgba(0, 0, 0, 0.7);
}

.ss-color[data-color="white"], .ss-color[data-color="yellow"] { color: #111; text-shadow: none; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.3); }
.ss-color-small { width: 26px; height: 26px; font-size: 0.8rem; }
.ss-color-big { width: 46px; height: 46px; font-size: 1.1rem; }
.ss-color.is-active { border-color: var(--c-accent, #5568e0); box-shadow: 0 0 0 2px var(--c-surface, #fff), 0 0 0 4px var(--c-accent, #5568e0); }
.ss-colors-big { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 4px 6px; }

.ss-mark { width: 34px; height: 34px; }
.ss-arrow-preview { width: 90px; height: 30px; }
.ss-arrow-preview svg { width: 100%; height: 100%; display: block; }

/* «На этом кадре» */
.ss-frame-list { display: flex; flex-direction: column; gap: 4px; }
.ss-frame-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 6px;
    border: 1px solid var(--c-border, #dfe4ef);
    border-radius: 7px;
    min-height: 34px;
}
.ss-frame-row.is-view-only { background: var(--c-surface-2, #eef1f8); }
.ss-frame-icon { flex: 0 0 auto; width: 52px; height: 24px; display: inline-flex; align-items: center; justify-content: center; }
.ss-frame-icon svg { height: 100%; width: 100%; }
.ss-frame-mark { width: 26px; }
.ss-frame-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.88rem; }
.ss-frame-label { background: #0f172a; border-radius: 4px; padding: 1px 6px; font-weight: 700; flex: 0 1 auto; }

/* Всплывающая панель формы надписи */
.ss-pop {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 60;
    width: 380px;
    max-height: calc(100vh - 230px);
    overflow-y: auto;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: 1px solid var(--c-border, #dfe4ef);
    border-radius: 12px;
    background: var(--c-surface, #fff);
    color: var(--c-text, #1d2740);
    box-shadow: var(--c-shadow, 0 10px 30px rgba(29, 39, 64, 0.2));
}

.ss-pop[hidden], .ss-pop [hidden] { display: none !important; }
.ss-pop-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* Меню знаков хода: три ряда значков над пунктами удаления */
.st-context-heading { padding: 4px 10px 0; font-size: 0.75rem; font-weight: 600; opacity: 0.7; }
.st-context-glyphs { display: flex; flex-wrap: wrap; gap: 3px; padding: 3px 4px; max-width: 360px; }
.st-context-glyph {
    min-width: 34px;
    padding: 6px 4px;
    border: 1px solid var(--st-line, #dde3ea);
    border-radius: 6px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.st-context-glyph:hover, .st-context-glyph:focus { background: var(--st-accent-soft, #dbeafe); outline: none; }
.st-context-glyph.is-on { background: var(--st-accent, #2563eb); border-color: var(--st-accent, #2563eb); color: #fff; }
.st-context-sep { height: 1px; margin: 3px 4px; background: var(--st-line, #dde3ea); }

/* ── Список сцен («Сцена») ────────────────────────────────────────────────── */

.ss-app[data-page="scene"] .ss-work {
    grid-template-columns: 250px minmax(0, 1fr) 440px;
    grid-template-areas:
        "cards stage side"
        "cards under side";
}

.ss-cell-cards {
    grid-area: cards;
    overflow-y: auto;
    padding-right: 4px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ss-cell-cards[hidden] { display: none; }
.ss-cards { display: flex; flex-direction: column; gap: 8px; }
.ss-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    border: 1px solid var(--c-border, #dfe4ef);
    border-radius: 12px;
    background: var(--c-surface, #fff);
    cursor: pointer;
}
.ss-card:hover { border-color: var(--c-accent, #5568e0); }
.ss-card.is-active { border-color: var(--c-accent, #5568e0); box-shadow: inset 0 0 0 1px var(--c-accent, #5568e0); }
.ss-card-thumbs { display: flex; align-items: flex-end; gap: 6px; }
.ss-thumb { position: relative; overflow: hidden; border-radius: 4px; flex: 0 0 auto; border: 1px solid rgba(0, 0, 0, 0.25); }
.ss-thumb-wide { width: 124px; aspect-ratio: 16 / 9; }
.ss-thumb-short { width: 52px; aspect-ratio: 9 / 16; }
.ss-thumb-block { position: absolute; border-radius: 2px; box-sizing: border-box; }
.ss-thumb-block.is-board { background: repeating-conic-gradient(#eed9b6 0% 25%, #b98a5e 0% 50%) 0 0 / 25% 25%; }
.ss-thumb-block.is-header { background: #facc15; opacity: 0.9; }
.ss-thumb-block.is-notation { background: #94a3b8; opacity: 0.85; }
.ss-thumb-block.is-comment { background: #e2e8f0; opacity: 0.8; }
.ss-thumb-block.is-item { background: #60a5fa; opacity: 0.85; }
.ss-thumb-block.is-item-camera { background: #f472b6; }
.ss-thumb-block.is-item-image { background: #34d399; }
.ss-card-head { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.ss-card-key { font-size: 0.75rem; color: var(--c-muted, #5b6784); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ss-card-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ss-card-live { font-size: 0.75rem; color: #15803d; }
.ss-card-live::before { content: "● "; }
.ss-card-actions { display: flex; gap: 3px; }
.ss-card-add { align-self: stretch; }
.ss-scene-nav { display: inline-flex; align-items: center; gap: 4px; }
.ss-chip-scene { cursor: pointer; background: transparent; font: inherit; font-size: 0.8rem; color: inherit; }
.ss-chip-scene:hover { border-color: var(--c-accent, #5568e0); }
.ss-chip-scene b { color: var(--c-accent-text, #4455c8); }

/* Панель свойств блока на сцене («Расположение») */
.ss-block-pop { right: 24px; bottom: 24px; }
.ss-block-formats { margin-top: 4px; }

/* Ниже 900 px Студия не работает: вместо неё сообщение */
@media (max-width: 899px) {
    .st-shell .ss-app { display: none !important; }
    .st-shell .st-narrow { display: block; }
}

@media (max-width: 1200px) {
    .ss-work { grid-template-columns: minmax(0, 1fr) 380px; }
    .ss-app[data-page="scene"] .ss-work { grid-template-columns: 210px minmax(0, 1fr) 380px; }
    .ss-thumb-wide { width: 104px; }
    .ss-thumb-short { width: 44px; }
}
