/* =====================================================================
   app.css — страница вокруг редактора. Вид документа — editor/editor.css.
   ===================================================================== */

* { box-sizing: border-box; }
/* Высота — от видимой части экрана (viewport.js): на iPhone клавиатура
   сжимает её, и страница должна сжаться следом, а не уехать вверх */
html { height: 100%; }
body { height: var(--app-h, 100%); overflow: hidden; margin: 0; background: var(--c-field); color: var(--c-text);
       font: 16px/1.45 var(--font-text);
       display: flex; flex-direction: column; }
.shell { flex: 1; min-height: 0; display: flex; flex-direction: column; }
/* Страница-статья (/markdown/) — обычная, прокручивается */
body.page { height: auto; overflow: visible; display: block; }

/* Липкая шапка наверху — по ней Safari красит полосу вкладок в её цвет,
   как в BAZA TZ. Одного theme-color ему мало: с ним и нелипкой шапкой
   полоса оставалась белой (Safari на Mac, 2026-09-24) */
.top { position: sticky; top: 0; z-index: 10;
       display: flex; align-items: center; gap: 16px; padding: 10px 16px;
       background: var(--c-header); color: var(--c-header-text); }
.brand { font-weight: 700; letter-spacing: .01em; }
.brand span { color: var(--c-accent); font-weight: 600; }
.status { margin-left: auto; font-size: 14px; color: var(--c-header-muted); min-width: 0;
          overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .lang { color: var(--c-header-text); font-size: 14px; font-weight: 600; text-decoration: none; }
.top .lang:hover { text-decoration: underline; }
.status.dirty { color: var(--c-header-dirty); }
.actions { display: flex; gap: 6px; }
/* Кнопки на шапке — контуром: белая рамка, прозрачный фон, подсветка
   при наведении. Главная (оранжевая) — ниже, одна на всю страницу. */
.actions button, .modes, .fs, .help-x { border: 1px solid var(--c-header-line); border-radius: 8px; }
.actions button, .modes button, .fs, .help-x { background: transparent; cursor: pointer; }
.actions button:hover, .modes button:hover, .fs:hover, .help-x:hover { background: var(--c-header-hover); }
.modes button[aria-pressed="true"], .fs[aria-expanded="true"] { background: var(--c-header-pressed); }
.actions button { height: 36px; padding: 0 14px; color: var(--c-header-text); font: inherit; font-size: 15px;
                  touch-action: manipulation; }
.actions button.primary, #draft-restore, .btn.primary {
    background: var(--c-accent); border-color: var(--c-accent); color: var(--c-on-accent); font-weight: 600; }
.actions button.primary:hover, .btn.primary:hover { background: var(--c-accent-hover); }
.note { margin: 0; padding: 8px 16px; background: var(--c-note-bg); color: var(--c-note-text); font-size: 14px; }
.draft { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.draft[hidden] { display: none; }
.draft span { flex: 1 1 240px; }
.draft button { height: 32px; padding: 0 12px; border-radius: 8px; border: 1px solid currentColor; background: transparent;
                color: inherit; font: inherit; cursor: pointer; touch-action: manipulation; }
/* Режим: сегменты в одну кнопку */
.modes { display: inline-flex; overflow: hidden; }
.modes button { height: 34px; padding: 0 12px; border: 0; color: var(--c-header-muted);
                font: inherit; font-size: 14px; touch-action: manipulation; }
.modes button + button { border-left: 1px solid var(--c-header-line-soft); }
.modes button:hover, .modes button[aria-pressed="true"] { color: var(--c-header-text); }
@media (max-width: 899px) { .modes [data-mode="split"] { display: none; } }
.fs { height: 34px; width: 36px; color: var(--c-header-text); font-size: 17px; }
.fs[hidden] { display: none; }
/* Телефон: две строки, а не три — экран и так съеден клавиатурой.
   Сверху кнопки файла, справа от них «?» и тема; снизу режим слева, имя
   файла справа. Логотип не нужен. Разрыв строки — пустой ::before с
   flex-basis 100%, иначе на широком телефоне режим въезжал бы в первую. */
@media (max-width: 720px) {
  .top { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .shell .top { gap: 0 6px; }
  .shell .top::before { content: ""; order: 3; flex-basis: 100%; }
  .brand { display: none; }
  .page .actions { flex-basis: 100%; }
  .shell .actions { order: 1; flex: 1 1 auto; min-width: 0; }
  .shell .actions button { padding: 0 8px; font-size: 14px; flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .fs { order: 3; }
  .shell .fs { order: 2; width: 34px; }
  .shell .modes { order: 4; margin-top: 8px; }
  /* Имя файла бывает длинным — ему вся вторая строка после режима */
  .shell .status { order: 5; flex: 1 1 0; margin: 8px 0 0 4px; text-align: right; }
  .shell .top .lang { display: none; }  /* на телефоне строка и так полна; язык — в шапке справки */
  #fullscreen { display: none; }
}
.fs svg { display: block; margin: auto; }
/* Шапка в одну строку не влезала уже 1000 px: переключатель режимов
   сжимался до палки (overflow: hidden разрешает ему ужиматься до нуля),
   логотип и «Два окна» переносились. Режим не сжимается никогда; до
   720 px шапка двухстрочная, как на телефоне; до 999 px без логотипа
   (имя сайта и так в заголовке вкладки) и с промежутками мельче. */
.modes { flex-shrink: 0; }
.brand, .modes button { white-space: nowrap; }
@media (min-width: 721px) and (max-width: 999px) { .shell .top { gap: 10px; } .shell .brand { display: none; } }

#app { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#editor { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--c-surface); }

/* Окна: код слева, документ справа; одно из них скрыто в одиночных режимах */
.panes { flex: 1; min-height: 0; display: flex; }
.pane { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.pane[hidden], .splitter[hidden] { display: none; }
.pane > .cm-editor { flex: 1; min-height: 0; }
.panes[data-mode="split"] .pane-code { flex: 0 0 var(--split, 50%); }
.pane-code { background: var(--c-surface); }
.splitter { flex: 0 0 7px; cursor: col-resize; background: var(--c-border); border-left: 3px solid var(--c-surface); border-right: 3px solid var(--c-surface);
            touch-action: none; }
.splitter:hover { background: var(--c-link-line); }

.boom { margin: 0; padding: 12px 16px; background: var(--c-err-bg); color: var(--c-err-text); font-size: 14px; white-space: pre-wrap; }

/* Статья: страница /markdown/ и панель «Справка». Строка — для чтения */
.article { max-width: 720px; margin: 0 auto; padding: 24px 16px 32px; font-size: 17px; line-height: 1.6; }
.article h1 { font-size: 26px; line-height: 1.25; margin: 0 0 16px; color: var(--c-brand); }
.article h2 { font-size: 21px; line-height: 1.3; margin: 36px 0 12px; color: var(--c-brand); }
.article h3 { font-size: 17px; margin: 22px 0 6px; }
.article p, .article ol { margin: 0 0 12px; }
.article li { margin-bottom: 6px; }
.article a { color: var(--c-link); }
.article code { font: .9em var(--font-mono); background: var(--c-sunken);
                border: 1px solid var(--c-border); border-radius: 4px; padding: 0 4px; }
.cheat { border-collapse: collapse; width: 100%; margin: 0 0 12px; font-size: 16px; background: var(--c-surface); }
.cheat th, .cheat td { border: 1px solid var(--c-border); padding: 6px 10px; text-align: left; vertical-align: top; }
.cheat th { background: var(--c-sunken); color: var(--c-brand); }
.cheat td code { border: 0; background: none; padding: 0; white-space: nowrap; }
.article-cta { margin-top: 32px !important; }
.foot { padding: 16px; text-align: center; font-size: 14px; color: var(--c-muted); border-top: 1px solid var(--c-border); }
@media (max-width: 560px) { .article h1 { font-size: 22px; } .cheat td code { white-space: normal; } }

/* Ссылка-кнопка (шапка статьи) — как кнопки шапки редактора */
.btn { display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border-radius: 8px; text-decoration: none;
       font-size: 15px; font-weight: 600; }
.page .brand { color: inherit; text-decoration: none; }
.page .top .lang { margin-left: auto; color: var(--c-header-text); font-size: 15px; }
.page .top .fs { margin-left: 4px; }
.page .top .actions + .fs { margin-left: auto; }
.foot a { color: var(--c-link); }

/* Панель «Справка»: справа поверх края листа, на телефоне — во весь экран.
   Лист под ней не сжимается: документ не переразмечается от открытой справки */
.help { position: fixed; z-index: 20; top: 0; right: 0; bottom: 0; width: min(440px, 100%);
        display: flex; flex-direction: column; background: var(--c-surface);
        border-left: 1px solid var(--c-border); box-shadow: -8px 0 32px rgba(var(--c-shadow), .16); }
.help[hidden] { display: none; }
/* Телефон: справка во весь экран, рамка и тень слева торчали полосой */
@media (max-width: 560px) { .help { border-left: 0; box-shadow: none; } }
.help-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 10px 20px;
             background: var(--c-header); color: var(--c-header-text); }
.help-head h2 { margin: 0; font-size: 17px; }
.help-lang { margin: 0 14px 0 auto; color: var(--c-header-text); font-size: 15px; }
.help-x { width: 36px; height: 36px; color: inherit; font-size: 22px; line-height: 1; }
.help-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 20px 20px 32px; font-size: 16px; margin: 0; max-width: none; }
.help-body h1 { font-size: 20px; }
.help-body h2 { font-size: 18px; margin-top: 28px; }
.help-body .cheat { font-size: 15px; }
.help-more { margin-top: 24px !important; font-weight: 600; }
.help-sign { margin-top: 24px !important; font-size: 14px; color: var(--c-muted); }
.help-optout { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.help-optout input { width: 18px; height: 18px; margin: 0; accent-color: var(--c-accent); }
.qr { margin: 12px 0 0; }
.qr img { display: block; width: 216px; height: 216px; box-sizing: border-box; padding: 12px; border-radius: 8px; background: #fff; }
.qr figcaption { margin-top: 6px; font-size: 14px; color: var(--c-muted); }
@media (max-width: 600px) { .qr { display: none; } }
