/* Desktop keeps its existing layout. Mobile uses the same commands in a different shell. */
.mobile-settings,.mobile-done { display:none; }
@media (max-width:767px), (pointer:coarse) and (max-width:1023px) {
  #app.mobile-workspace > .editor-topbar {
    display:grid;grid-template-columns:minmax(0,1fr) auto;gap:0 8px;
    min-height:64px;max-height:none;overflow:visible;padding:4px 12px 6px;
  }
  .mobile-workspace .editor-topbar .brand,.mobile-workspace .gamebook-switch-field > label { display:none; }
  .mobile-workspace .editor-topbar .gamebook-switch-field { display:block;grid-column:1;grid-row:1; }
  .mobile-workspace .gamebook-switch-field select { width:100%;max-width:100%;min-width:0;min-height:44px;font-size:16px; }
  .mobile-workspace .editor-topbar .header-actions { grid-column:2;grid-row:1;display:flex;gap:4px; }
  .mobile-workspace .editor-topbar .header-feedback { grid-column:1/-1;grid-row:2;display:block;padding:0;max-width:none; }
  .mobile-workspace .header-progress { position:relative;display:flex;flex-wrap:wrap;align-items:center;gap:4px 12px; }
  .mobile-workspace #headerSaveState { font-size:12px;line-height:1.4; }
  .mobile-workspace .save-details summary { min-height:44px; }
  .mobile-workspace .save-details { position:static; }
  .mobile-workspace .save-details p { left:0;right:auto;top:100%;width:min(360px,100%);box-sizing:border-box; }
  .mobile-workspace #btnProject { font-size:0;padding:6px;min-width:44px; }
  .mobile-workspace #btnProject::before { content:'⋮';font-size:25px;line-height:1; }
  #app.mobile-workspace > .mode-bar {
    order:10;display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:0;
    min-height:64px;padding:0 4px env(safe-area-inset-bottom,0px);border-top:1px solid var(--line);border-bottom:0;
  }
  .mobile-workspace .mode-bar .mode-secondary { display:none; }
  .mobile-workspace .mode-bar .mobile-primary,.mobile-workspace .mode-bar .mode-more {
    display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;
    min-width:0;min-height:64px;max-width:none;margin:0;padding:6px 2px;
    font-size:12px;line-height:1.3;border-bottom:0;border-top:3px solid transparent;overflow-wrap:anywhere;
  }
  .mobile-workspace .mode-bar [aria-current="page"] { border-top-color:var(--accent); }
  .mobile-workspace .mode-bar button::before { content:'';display:block;width:22px;height:22px;background:currentColor;mask:var(--mobile-icon) center/contain no-repeat; }
  .mobile-workspace [data-mode="book"] { --mobile-icon:url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"%3E%3Cpath fill="none" stroke="black" stroke-width="1.8" d="M12 5v15M12 5C9 3 5 3 2 4v15c3-1 7-1 10 1 3-2 7-2 10-1V4c-3-1-7-1-10 1Z"/%3E%3C/svg%3E'); }
  .mobile-workspace [data-mode="graph"] { --mobile-icon:url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"%3E%3Cpath fill="none" stroke="black" stroke-width="1.8" d="m2 5 6-2 8 3 6-2v15l-6 2-8-3-6 2Zm6-2v15m8-12v15"/%3E%3C/svg%3E'); }
  .mobile-workspace [data-mode="notes"] { --mobile-icon:url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"%3E%3Cpath fill="none" stroke="black" stroke-width="1.8" d="M4 3h16v14l-5 4H4Zm4 5h8M8 12h8M8 16h4"/%3E%3C/svg%3E'); }
  .mobile-workspace .mode-more { --mobile-icon:url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"%3E%3Cg%3E%3Ccircle cx="4" cy="12" r="2"/%3E%3Ccircle cx="12" cy="12" r="2"/%3E%3Ccircle cx="20" cy="12" r="2"/%3E%3C/g%3E%3C/svg%3E'); }
  .mobile-workspace.author-reading #workspaceToolbar .scene-context-label,.mobile-workspace.author-reading #workspaceToolbar > button:not(#btnScenes):not(#btnBookDetails) { display:none; }
  .mobile-workspace.author-reading #workspaceToolbar { max-height:none;overflow:visible;min-height:44px;justify-content:space-between; }
  .mobile-workspace #btnBookDetails { max-width:60%;overflow:hidden;text-overflow:ellipsis; }
  .mobile-workspace .author-view { padding:12px; }
  .mobile-workspace .book-scene { padding:16px 4px;margin-bottom:16px;border:0;border-radius:0;border-bottom:1px solid var(--line); }
  .mobile-workspace .manuscript-preview,.mobile-workspace .book-text-editor { font-size:18px;line-height:1.65; }
  .mobile-workspace .book-scene h2 { font-size:22px;line-height:1.3;overflow-wrap:anywhere; }
  .mobile-settings { display:flex;flex-direction:column;align-items:stretch;gap:12px;margin-top:16px;border-top:1px solid var(--line);padding-top:12px; }
  .mobile-settings h3 { margin:0;font-size:16px; }
  .mobile-settings .header-accounts { border:0;padding:0; }
  .mobile-settings .book-counts { white-space:normal; }
  .mobile-settings .note-view-filters { width:100%; }
  .mobile-settings .note-view-filter-body { position:static;width:100%;max-width:none;box-sizing:border-box; }
  .mobile-settings button { white-space:normal;min-height:44px;min-width:44px; }
  .mobile-settings #btnCollaboration { min-height:44px; }
  .mobile-workspace.mobile-writing .mobile-done:not([hidden]) { display:block;min-height:44px; }
  /* Focus can outlive the Android keyboard. Navigation must remain reachable. */
  .mobile-workspace.mobile-writing #btnProject { display:none; }
  .mobile-workspace.mobile-writing > .editor-topbar { min-height:44px; }
  #app.mobile-workspace .author-view > .view-controls { gap:8px;margin-bottom:12px; }
  .mobile-workspace .mobile-book-tools { flex:1 1 140px;min-width:0; }
  .mobile-workspace .mobile-book-tools summary,.mobile-workspace .mobile-branch-details summary { min-height:44px;padding:12px 8px;cursor:pointer;font:14px/20px system-ui,sans-serif;color:var(--accent); }
  .mobile-workspace .mobile-disclosure-body { display:flex;flex-wrap:wrap;align-items:center;gap:12px;padding:8px;min-width:0; }
  .mobile-workspace .mobile-disclosure-body > * { max-width:100%;min-width:0; }
  .mobile-workspace .mobile-disclosure-body select { min-height:44px;font-size:16px; }
  .mobile-workspace .book-choice-context { padding:8px 0;border-top:1px solid var(--line);margin:0; }
  .mobile-workspace .book-choice { min-height:44px;font-size:16px;line-height:1.5;margin:0; }
  .mobile-workspace .mobile-branch-details .branch-mechanics { margin:0;font-size:14px;line-height:1.5; }
  .mobile-workspace .rich-toolbar { display:flex;flex-wrap:wrap;max-width:100%; }
  .mobile-workspace .rich-toolbar button { min-width:44px;min-height:44px; }
  .mobile-workspace .book-scene-main,.mobile-workspace .rich-editor { max-width:100%;min-width:0; }
}
