/* Mobile writing and progressive disclosure, using the approved brand tokens. */
.post-settings { margin: 0 0 24px; padding: 0; border: 0; }
.post-settings > summary { display: none; }
.post-settings-fields { display: grid; gap: 16px; }
.writing-panel { min-width: 0; }
.writing-panel #post-body, .writing-panel #visual-body { height: var(--text-editor-height, 240px); min-height: 180px; overflow-y: auto; }
#editor.touch-editor:not(.text-focus) #post-body, #editor.touch-editor:not(.text-focus) #visual-body { max-height: var(--editor-input-max-height, none); }
.text-resizer { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; margin: 0 0 4px; border-radius: 10px; color: var(--muted); font-size: 11px; cursor: ns-resize; touch-action: none; user-select: none; }
.text-resizer:focus-visible { outline: 3px solid var(--action); outline-offset: -3px; }
.text-resizer:hover { background: var(--sky); }
#editor.touch-editor::backdrop { background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none; }
/* Tablets use the visible WebView, rather than an inset desktop modal. This
   also ignores an SDK height left over from an earlier keyboard animation. */
#editor.touch-editor:not(.text-focus) {
  position: fixed; inset: auto; top: var(--editor-viewport-top, 0px); left: 0;
  width: 100%; max-width: none; height: var(--editor-viewport-height, 100dvh);
  max-height: none; margin: 0; border: 0; border-radius: 0;
}
#editor.touch-editor .editor-heading { padding: 8px 20px; padding-top: max(8px, var(--app-safe-top, 0px)); min-height: 60px; }
#editor.touch-editor .editor-heading .eyebrow, #editor.touch-editor .editor-author { display: none; }
#editor.touch-editor .editor-heading h2 { font-family: var(--font-body); font-size: 20px; margin: 0; }
#editor.touch-editor .editor-actions { background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none; padding-bottom: max(8px, var(--app-safe-bottom, 0px)); }
#editor.touch-editor #post-body, #editor.touch-editor #visual-body { font-size: 16px; }
.format-help { margin: 8px 0 16px; padding: 0; border: 0; }
.format-help > summary { font-size: 12px; color: var(--muted); cursor: pointer; min-height: 44px; padding-block: 12px; }
.format-help p { margin-bottom: 8px; }
.writing-heading { display: none; }
.writing-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0 12px; }
.writing-tools .editor-mode-switch { display: contents; }
.writing-tools button { font-size: 13px; min-height: 44px; }
.writing-tools .hint:empty { display: none; }
.editor-more { position: relative; margin: 0; padding: 0; border: 0; }
.editor-actions > div { align-items: center; }
.editor-more:not(:has(button:not([hidden]))) { display: none; }
.editor-more > summary { display: flex; align-items: center; cursor: pointer; list-style: none; min-height: 46px; font-size: 14px; line-height: 1.4; border: 1px solid var(--control-border); border-radius: 12px; padding: 8px 12px; color: var(--ink); }
.editor-more > summary::-webkit-details-marker { display: none; }
.editor-more-menu { position: absolute; bottom: calc(100% + 8px); right: 0; display: grid; gap: 4px; width: 230px; padding: 8px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: 0 8px 24px var(--shadow-dialog); }
.editor-more-menu button { text-align: left; min-height: 44px; }
.editor-more > summary:focus-visible, .post-settings > summary:focus-visible { outline: 3px solid var(--action); outline-offset: 3px; }
@media (max-width: 760px) {
  /* Cover the visible WebView, including its gesture area. Safe insets belong
     inside the opaque editor, not outside it over the blurred backdrop. */
  #editor:not(.text-focus) {
    position: fixed; inset: auto; top: var(--editor-viewport-top, 0px); left: 0;
    width: 100%; max-width: none; height: var(--editor-viewport-height, 100dvh);
    max-height: none; margin: 0; border: 0; border-radius: 0;
  }
  #editor .editor-heading { min-height: 60px; padding: 8px 16px; padding-top: max(8px, var(--app-safe-top, env(safe-area-inset-top))); }
  #editor .editor-heading .eyebrow, #editor .editor-author { display: none; }
  #editor .editor-heading h2 { font-family: var(--font-body); font-size: 20px; line-height: 1.3; margin: 0; }
  #editor .editor-tabs { padding: 4px 16px; }
  #editor #post-form { padding: 16px max(16px, var(--app-safe-right, env(safe-area-inset-right))) 16px max(16px, var(--app-safe-left, env(safe-area-inset-left))); }
  .post-settings { border: 1px solid var(--border); border-radius: 14px; margin-bottom: 20px; }
  .post-settings > summary { display: flex; gap: 8px; align-items: center; min-height: 44px; padding: 8px 10px; cursor: pointer; list-style: none; }
  .post-settings > summary::-webkit-details-marker { display: none; }
  .post-settings > summary::after { content: '+'; font-size: 20px; margin-left: auto; }
  .post-settings[open] > summary::after { content: '−'; }
  .post-settings > summary > span:first-child { flex-shrink: 0; font-weight: 600; }
  .post-settings > summary > span { margin: 0; font-size: 13px; color: var(--ink); }
  .post-settings > summary > .hint { font-size: 12px; color: var(--muted); }
  #post-settings-summary { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .post-settings-fields { padding: 4px 12px 14px; }
  #editor .editor-actions {
    padding: 8px max(16px, var(--app-safe-right, env(safe-area-inset-right))) 8px max(16px, var(--app-safe-left, env(safe-area-inset-left)));
    padding-bottom: max(8px, var(--app-safe-bottom, env(safe-area-inset-bottom)));
    gap: 4px; background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none;
  }
  #editor .editor-actions > div { display: grid; grid-template-columns: auto 1fr 1fr; width: 100%; gap: 8px; }
  #editor .editor-actions > div:not(:has(.editor-more button:not([hidden]))) { grid-template-columns: 1fr 1fr; }
  #editor .editor-actions > div button { min-height: 44px; padding: 5px 8px; font-size: 12px; line-height: 1.35; }
  #editor .editor-actions .editor-more-menu button { font-size: 14px; text-align: left; }
  .editor-more-menu { left: 0; right: auto; max-width: calc(100vw - 32px); }
  #editor .editor-actions > span { font-size: 11px; }
  .writing-tools button, .format-toolbar button, .schedule-presets button { min-height: 44px; padding: 6px 10px; font-size: 13px; }
  #editor .editor-more > summary { min-height: 44px; padding: 6px 10px; font-size: 13px; }
  .editor-tabs button { min-height: 44px; padding: 6px 10px; }
  .upload-zone { min-height: 52px; padding: 10px; font-size: 13px; }
  .rule-days label { padding: 6px 8px; min-width: 54px; }
}
/* Override ordinary dialog geometry only while writing, also on tablets. */
#editor.text-focus {
  position: fixed; inset: auto; top: 0; left: 0;
  width: 100%; max-width: none; height: var(--editor-layout-height, 100dvh); max-height: none;
  margin: 0; border: 0; border-radius: 0; overflow: hidden; padding: 0;
  scroll-padding: 0;
}
#editor.text-focus > .editor-heading, #editor.text-focus > .editor-tabs,
#editor.text-focus > .recovery-banner, #editor.text-focus > .editor-actions,
#editor.text-focus .preview-column, #editor.text-focus #post-form > :not(.writing-panel) { display: none; }
#editor.text-focus .editor-grid { display: block; position: relative; top: var(--writing-top, 0px); height: var(--writing-height, 100%); }
#editor.text-focus #post-form { display: block; height: 100%; padding: 0; border: 0; }
#editor.text-focus .writing-panel { display: flex; flex-direction: column; height: 100%; gap: 8px; padding: 0 max(16px, var(--app-safe-right, env(safe-area-inset-right))) 0 max(16px, var(--app-safe-left, env(safe-area-inset-left))); padding-bottom: max(8px, var(--app-safe-bottom, 0px)); }
#editor.text-focus .writing-heading { display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; min-height: 56px; padding-top: var(--app-safe-top, 0px); font-size: 16px; font-weight: 600; border-bottom: 1px solid var(--border); }
#editor.text-focus .writing-heading button { min-height: 44px; padding: 8px 14px; }
#editor.text-focus .field-heading, #editor.text-focus .writing-tools, #editor.text-focus .format-help { display: none; }
#editor.text-focus .text-resizer { display: none; }
#editor.text-focus #post-body, #editor.text-focus #visual-body { flex: 1 1 0; min-height: 0; height: auto; width: 100%; overflow-y: auto; resize: none; font-size: 16px; line-height: 1.6; padding: 12px; }
#editor.text-focus .format-toolbar { flex-shrink: 0; display: grid; grid-template-columns: 44px 44px 1fr 1fr; gap: 8px; margin: 0; }
#editor.text-focus .format-toolbar button { padding: 8px; }
#editor.text-focus .text-counter { flex-shrink: 0; margin: 0; font-size: 11px; }

/* Secondary sections use one disclosure component on every screen. */
.editor-section { margin: 16px 0; padding: 0; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.editor-section > summary { display: flex; gap: var(--space-control); align-items: center; min-height: var(--control-height); padding: 10px 12px; cursor: pointer; list-style: none; }
.editor-section > summary::-webkit-details-marker { display: none; }
.editor-section > summary > span:first-child { font-weight: 600; color: var(--ink); }
.editor-section > summary::after { content: '+'; margin-left: auto; color: var(--action); font-size: 20px; }
.editor-section[open] > summary::after { content: '−'; }
.editor-section .section-summary { margin: 0; font-weight: 400; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-section-content { padding: 4px 14px 14px; }
.editor-section .section-title { margin-top: 0; }
.editor-section .section-title h3 { display: none; }
.editor-section .section-title p { margin-bottom: 0; }
.publication-summary { padding: 14px; margin: 18px 0 0; border: 1px solid var(--border); border-radius: 14px; }
.publication-summary h3 { font-size: 14px; }
.publication-summary dl { margin: 0; display: grid; gap: 8px; }
.publication-summary dl > div { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.5fr); gap: 12px; font-size: 13px; }
.publication-summary dt { color: var(--muted); }
.publication-summary dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; text-align: right; }
.publication-summary .hint { margin: 12px 0 0; }
.trial-panel { margin: 18px 0; padding: 14px; border: 1px solid var(--border); border-radius: 14px; }
.trial-panel .hint { margin: 10px 0 0; }
#trial-result:empty { display: none; }
@media (max-width: 760px) {
  .editor-section { margin: 12px 0; }
  .editor-section > summary { padding: 8px 10px; font-size: 13px; }
  .editor-section-content { padding: 4px 10px 12px; }
  .publication-summary { margin-top: 14px; padding: 12px; }
}
