/* The post editor: a large white sheet with the text on the left and the live preview on the right.
   On a phone it fills the screen and the section buttons jump between its parts. */

/* Photo or infographic: two white choices; the picker always sits on a grey tile (Grafika here, the week brief in Plan). */
.visual-style-picker { margin-top: var(--space-4); }
.visual-style-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
.visual-style-options label { display: flex; align-items: center; gap: 10px; min-height: 52px; margin: 0; padding: 10px var(--space-4); border-radius: var(--radius-row); background: var(--color-surface); box-shadow: var(--shadow-card); cursor: pointer;
  transition: background-color var(--duration-fast), box-shadow var(--duration-fast); }
.visual-style-options label:hover { box-shadow: var(--shadow-card), 0 6px 16px rgba(0, 0, 0, .07); }
.visual-style-options label:has(input:checked) { background: var(--color-accent-soft); box-shadow: inset 0 0 0 1.5px var(--color-accent); }
.visual-style-options label:has(input:focus-visible) { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.visual-style-options label:has(input:disabled) { opacity: .55; cursor: not-allowed; }
.visual-style-copy { min-width: 0; }
.visual-style-copy strong { display: block; font-size: var(--text-body); font-weight: 600; line-height: 1.35; }

/* ---- The sheet ---- */
.post-dialog { width: min(1180px, calc(100% - 48px)); max-width: none; height: calc(100dvh - 48px); max-height: none; margin: auto; padding: 0; overflow-y: auto; overscroll-behavior: contain; scroll-padding-block: 124px 132px; }
.post-dialog .dialog-heading { top: 0; height: 60px; margin: 0; padding: 0 var(--space-4) 0 var(--space-6); }
.post-dialog .dialog-heading h2 { font-size: var(--text-title-3); }

/* Section switcher: the four jump buttons join into one pill-shaped track, on a blurred bar under the heading.
   Each button paints its part of the track; its ::before is the rounded highlight inside it. */
.editor-section-nav { position: sticky; top: 60px; z-index: 6; display: flex; margin: 0; padding: 0 var(--space-6) var(--space-3);
  background: rgba(255, 255, 255, .88); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); box-shadow: 0 1px 0 var(--color-separator); }
.editor-section-nav button { position: relative; isolation: isolate; flex: 0 0 auto; min-height: 36px; padding: 0 18px; border: 0; border-radius: 0; background: var(--color-fill); color: var(--color-text); font-size: 14px; font-weight: 500; white-space: nowrap; }
.editor-section-nav button:first-child { padding-left: 20px; border-radius: var(--radius-control) 0 0 var(--radius-control); }
.editor-section-nav button:last-child { padding-right: 20px; border-radius: 0 var(--radius-control) var(--radius-control) 0; }
.editor-section-nav button::before { content: ""; position: absolute; inset: 3px 1px; z-index: -1; border-radius: var(--radius-control); transition: background-color var(--duration-fast), box-shadow var(--duration-fast); }
.editor-section-nav button:first-child::before { left: 3px; }
.editor-section-nav button:last-child::before { right: 3px; }
.editor-section-nav button:hover:not(:disabled)::before { background: rgba(0, 0, 0, .05); }
.editor-section-nav button:active:not(:disabled) { transform: none; }
.editor-section-nav button:active:not(:disabled)::before { background: var(--color-surface); box-shadow: 0 1px 3px rgba(0, 0, 0, .14); }
.editor-section-nav button:focus-visible { outline: none; }
.editor-section-nav button:focus-visible::before { outline: 2px solid var(--color-accent); outline-offset: 0; }

/* ---- The form: the text straight on the sheet, Grafika and Plan as grey tiles ---- */
.post-dialog #post-form { padding: var(--space-5) var(--space-6) 0; }
.post-editor-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; gap: var(--space-8); }
.post-editor-content { min-width: 0; }
.post-dialog #post-title { font-size: var(--text-headline); font-weight: 600; }
.post-dialog #post-content { min-height: 260px; font-size: var(--text-body); line-height: 1.6; }
.post-content-count { margin-top: 4px; text-align: right; color: var(--color-text-3); font-size: var(--text-caption); font-variant-numeric: tabular-nums; }
.post-dialog #post-title, .post-dialog #images-heading, .post-dialog #editor-plan-heading, #post-preview-heading { scroll-margin-top: 0; }
.post-dialog .editor-images, .post-dialog .editor-plan { margin-top: var(--space-5); padding: var(--space-5); border: 0; border-radius: var(--radius-lg); background: var(--color-tile); }
.post-dialog .editor-plan h3 { margin-bottom: var(--space-3); }
.post-dialog input[type="date"], .post-dialog input[type="time"] { max-width: 100%; }
/* On the Grafika tile the chosen image and its button are white. */
.post-dialog .image-preview { border-radius: var(--radius-row); background: var(--color-surface); box-shadow: var(--shadow-card); }
.post-dialog .image-preview-photo { max-height: 330px; }
.post-dialog .image-selection-actions .button-secondary { background: var(--color-surface); box-shadow: var(--shadow-card); }
.post-dialog .image-selection-actions .button-secondary:hover:not(:disabled) { background: var(--color-surface); box-shadow: var(--shadow-card), 0 6px 16px rgba(0, 0, 0, .07); }
#editor-images .image-option img { aspect-ratio: 4 / 5; max-height: none; object-fit: contain; }

/* The live preview: a grey tile that stays in view while the text scrolls. */
.post-preview-panel { position: sticky; top: 124px; max-height: calc(100dvh - 300px); min-width: 0; overflow-y: auto; overscroll-behavior: contain; padding: var(--space-5); border-radius: var(--radius-lg); background: var(--color-tile); scrollbar-width: thin; }
#post-preview-heading { margin-bottom: var(--space-3); }
.post-dialog #editor-error, .post-dialog #editor-create-recovery { scroll-margin-block: 124px 132px; }
.post-dialog #editor-error:focus { outline: 2px solid var(--color-danger); outline-offset: 2px; }

/* The save bar stays at the bottom of the sheet, translucent over the content. */
.post-dialog .editor-footer { position: sticky; bottom: 0; z-index: 7; margin: var(--space-6) calc(-1 * var(--space-6)) 0; padding: var(--space-3) var(--space-6) var(--space-4);
  background: rgba(255, 255, 255, .82); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); box-shadow: 0 -1px 0 var(--color-separator); }
.editor-footer-main { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.post-dialog .editor-save-actions button { min-height: 44px; }
.post-dialog .editor-footer > .small-note { margin-top: 6px; font-size: var(--text-caption); color: var(--color-text-3); }

@media (max-width: 920px) {
  .post-dialog { width: min(680px, calc(100% - 32px)); }
  .post-editor-layout { grid-template-columns: minmax(0, 1fr); gap: var(--space-5); }
  .post-preview-panel { position: static; max-height: none; overflow: visible; }
}
@media (max-width: 760px) {
  /* Full screen. */
  .post-dialog { inset: 0; width: 100%; height: 100dvh; margin: 0; border-radius: 0; scroll-padding-block: 120px 150px; }
  .post-dialog[open] { animation-name: sheet-up; }
  .post-dialog .dialog-heading { height: 56px; padding: 0 var(--space-3) 0 var(--space-4); }
  /* The track spans the width; it scrolls sideways only if the four names do not fit. */
  .editor-section-nav { top: 56px; padding-inline: var(--space-4); overflow-x: auto; scrollbar-width: none; }
  .editor-section-nav button, .editor-section-nav button:first-child, .editor-section-nav button:last-child { flex: 1 1 auto; padding-inline: 10px; }
  .post-dialog #post-form { padding: var(--space-4) var(--space-4) 0; }
  .post-dialog .editor-images, .post-dialog .editor-plan { margin-top: var(--space-4); padding: var(--space-4); }
  .post-preview-panel { padding: var(--space-3); }
  .post-dialog .editor-footer { margin-inline: calc(-1 * var(--space-4)); padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom)); }
  .editor-footer-main { flex-wrap: wrap; gap: var(--space-1); }
  .post-dialog .editor-save-actions { flex: 1 1 100%; }
  .post-dialog .editor-footer .button-danger-text { min-height: 36px; padding: 0; }
  .visual-style-options label { padding-inline: 12px; }
}
