/* Browser and iframe controls share the same responsive layout. */
.embedded-reader.embed-no-modeSwitch #editor-mode-control { display: none !important; }
.format-sheet-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.format-sheet-header .format-compact-control { padding: 0; justify-content: flex-start; }
#format-close { width: 36px; height: 36px; flex: none; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: var(--paper); font: 22px/1 var(--sans); cursor: pointer; }
.format-categories { display: none; }
#web-editor-settings { gap: 10px; }
#web-editor-settings[hidden] { display: none; }
#web-editor-settings #show-markdown, #web-editor-settings #cancel-edit { width: 100%; min-height: 40px; border: 1px solid var(--line); border-radius: 9px; padding: 9px 12px; color: var(--ink); background: var(--paper); font: 600 13px/1.4 var(--sans); }
#web-editor-settings #show-markdown[aria-pressed=true] { background: var(--accent-strong); color: white; }
#web-editor-settings .editor-mode-control { width: 100%; }
#web-editor-settings .editor-preview-control { justify-content: flex-start; }
@media (max-width:820px) {
  body.editing-document .reader-bar { display: grid; grid-template-columns: minmax(0,1fr); gap: 6px; min-height: 94px; padding: 8px 10px; }
  body.editing-document .file-heading { min-width: 0; padding-left: 44px; height: 30px; display: flex; align-items: center; }
  body.editing-document .reader-actions { display: flex; flex-wrap: nowrap; width: 100%; gap: 6px; padding: 0; overflow: visible; }
  body.editing-document .reader-actions #edit-document,
  body.editing-document .reader-actions #palette-toggle { min-width: 58px; min-height: 40px; padding: 0 10px; }
  body.editing-document #editor-insert-control { order: 1; }
  body.editing-document #share-document { order: 2; margin-left: auto; }
  body.editing-document #editor-insert-toggle { width: auto; min-width: 80px; height: 40px; padding: 0 10px; }
  body.editing-document .progress-track { top: 93px; }
}
@media (max-width:600px) {
  #editor-insert-menu, #editor-insert-menu.compact-formatting { width: calc(100vw - 16px); display: flex; flex-direction: column; overflow: hidden; padding: 10px; border-radius: 18px; background: var(--paper); }
  #editor-insert-menu[hidden] { display: none; }
  .format-sheet-header { flex: none; }
  .format-categories { display: flex; flex: none; gap: 6px; padding: 8px 0; }
  .format-categories button { flex: 1; min-height: 36px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); color: var(--ink); font: 650 12px var(--sans); cursor: pointer; }
  .format-categories button[aria-pressed=true] { background: var(--accent-soft); color: var(--accent-strong); border-color: var(--accent); }
  .format-groups { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
  #editor-insert-menu .editor-insert-group { padding: 0; border: 0; }
  #editor-insert-menu .editor-insert-group:not([data-mobile-active=true]), #editor-insert-menu .editor-insert-group > strong { display: none; }
  #editor-insert-menu .editor-insert-group > div { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  #editor-insert-menu [data-markdown-command] { gap: 5px; padding: 10px 6px; min-height: 46px; }
  #editor-insert-menu .format-glyph { flex-basis: 22px; }
  #editor-insert-menu .format-description small { font-size: 10px; line-height: 1.4; }
  #editor-insert-menu.compact-formatting .editor-insert-group > div { display: grid; }
  #editor-insert-menu.compact-formatting [data-markdown-command] { justify-content: center; }
}
.format-categories button { -webkit-tap-highlight-color: transparent; }

/* Embedded sessions edit a host-owned document; document management stays with the host. */
.embedded-reader #new-markdown, .embedded-reader #format-filter { display:none !important; }
.embed-readonly .library-controls, .embed-readonly .file-remove-button {display:none !important;}
.embed-no-sidebar #sidebar, .embed-no-sidebar #sidebar-toggle { display:none !important; }
.embed-no-sidebar .app { grid-template-columns:minmax(0,1fr) !important; }
.embed-no-sidebar .reader-shell { grid-column:1 / -1; }
body.embed-no-sidebar.editing-document .file-heading { padding-left:0; }
.embed-no-share #share-document, .embed-no-formatting #editor-insert-control, .embed-no-formatting #direct-table-tools,
.embed-no-settings #palette-toggle { display:none !important; }
#file-name[role=button] { cursor:text; border-radius:5px; }
#file-name[role=button]:hover { text-decoration:underline dotted; text-underline-offset:4px; }
#file-name[role=button]:focus-visible { outline:2px solid var(--accent-strong); outline-offset:3px; }
#file-name[hidden], #rename-file[hidden] { display:none !important; }
#rename-file { display:flex; align-items:center; gap:4px; min-width:0; max-width:100%; height:30px; color:var(--muted); }
#rename-file-stem { width:180px; min-width:30px; flex:1 1 auto; height:30px; box-sizing:border-box; border:1px solid var(--line); border-radius:6px; padding:3px 6px; color:var(--ink); background:var(--paper); font:inherit; }
#rename-file-extension { flex:none; font:13px var(--sans); }
#rename-file button { flex:none; height:30px; width:30px; border:1px solid var(--line); border-radius:6px; background:var(--paper); color:var(--ink); cursor:pointer; }

.embed-language-hidden { display:none !important; }
#embed-welcome { position:absolute; z-index:20; inset:100px 12px 12px; background:var(--paper); border:1px dashed var(--line); border-radius:20px; padding:24px; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:18px; text-align:center; color:var(--ink); }
#embed-welcome h2 {font:700 22px var(--sans);margin:0;}
#embed-welcome p {font:14px/1.6 var(--sans);color:var(--muted);max-width:360px;}
#embed-welcome button {max-width:100%;white-space:normal;min-height:44px;}

.embed-no-language .language-control {display:none !important;}

.embedded-reader.embed-hide-formatting #editor-insert-control, .embedded-reader.embed-hide-formatting #direct-table-tools,
.embedded-reader.embed-hide-share #share-document {display:none !important;}
#embed-toolbar-settings label {display:flex;align-items:center;gap:10px;min-height:36px;color:var(--ink);font:13px var(--sans);cursor:pointer;}
#embed-toolbar-settings[hidden], #embed-toolbar-settings label[hidden] {display:none !important;}
#embed-toolbar-settings input {width:16px;height:16px;accent-color:var(--accent-strong);}
#embed-draft-hint {margin:0;padding:6px 4px 12px;font-size:12px;}

/* Embedded header: filename on the left, one persistent Save on the right. */
body.embedded-reader .reader-bar{display:flex;align-items:center;gap:10px;min-height:66px;padding:10px 14px;flex-wrap:nowrap}
body.embedded-reader .file-heading{flex:1;min-width:0;padding-left:42px;height:auto}
body.embedded-reader .reader-actions{width:auto;flex:0 0 auto;justify-content:flex-end;gap:6px;padding:0}
body.embedded-reader #edit-document{background:#f5c9dc;color:#713c55;border:1px solid #dfa9c0;box-shadow:0 3px 10px #b8708b18}
body.embedded-reader #edit-document:hover{background:#efbad0}
body.embedded-reader .progress-track{top:65px}
body.embedded-reader #sidebar .appearance-control{order:initial!important}
body.embedded-reader #sidebar .appearance-button{display:flex;align-items:center;gap:6px;width:auto;min-width:68px;padding:0 10px}
body.embedded-reader #sidebar .appearance-theme-icon{width:20px;font-size:20px}
body.embedded-reader .embed-library-controls{display:flex!important;gap:8px;flex-wrap:wrap}
body.embed-readonly #choose-file{display:none}

/* Missing local images stay near the document, outside the reading content. */
.local-media-notice { margin: 10px 20px 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface, #fff8fb); color: var(--ink); font-size: 13px; line-height: 1.5; flex-shrink: 0; }
.local-media-notice[hidden] { display: none; }
.local-media-notice p { margin: 0 0 8px; }
.local-media-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.local-media-notice details { margin-top: 8px; color: var(--muted); }
.local-media-notice pre { max-height: 90px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 11px; }
.local-media-notice progress { width: 100%; margin-top: 8px; accent-color: var(--accent); }
@media (max-width: 600px) { .local-media-notice { margin: 8px 10px 0; padding: 10px; font-size: 12px; } }
.local-media-notice [hidden] { display: none !important; }
body.editor-preview-enabled .reader-shell:has(.local-media-notice:not([hidden])) { grid-template-rows: auto auto minmax(0, 1fr); }

#local-media-folder-button { background: var(--accent-soft); color: var(--ink); border-color: var(--accent); }
