@container (max-width: 580px) {
  .story-nav {
    position: relative; z-index: 4; gap: 8px; min-height: 58px;
    padding: 6px 16px; border-block-end: 1px solid #5b38251a; box-shadow: none;
  }
  .story-nav strong { font-size: .9rem; gap: 7px; }
  .story-nav strong span { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .story-menu-toggle {
    flex: none; display: inline-flex; align-items: center; gap: 5px; max-width: 47%; min-height: 44px; padding-inline: 9px;
    color: var(--story-accent); font-size: .83rem; font-weight: 720; border-radius: 8px;
  }
  .story-menu-toggle span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .story-menu-toggle[aria-expanded="true"] { background: color-mix(in srgb,var(--story-accent) 10%,var(--story-paper)); }
  .story-menu-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
  .story-nav nav {
    display: none; position: absolute; inset-inline: 14px; inset-block-start: calc(100% + 5px); max-width: none; max-height: 45dvh;
    padding: 6px; flex-direction: column; gap: 2px; color: var(--story-ink); background: var(--story-paper);
    border: 1px solid color-mix(in srgb,var(--story-accent) 25%,transparent); border-radius: 12px; box-shadow: 0 8px 22px #2b16162b;
  }
  .story-nav.menu-open nav { display: flex; }
  .story-nav nav :is(button,a) { display: block; min-height: 44px; padding: 9px 11px; text-align: start; font-size: .88rem; overflow-wrap: anywhere; white-space: normal; }
  .story-nav nav .active { box-shadow: none; background: color-mix(in srgb,var(--story-accent) 11%,transparent); border-radius: 8px; }
  .story-content { padding: 15px 15px 26px; }
  .story-row { display: flex; flex-direction: column; gap: 12px; margin-block-end: 17px; }
  .story-cover { min-height: 288px; border-radius: 13px; }
  .story-cover.cover-with-link { min-height: clamp(305px, 91cqi, 395px); align-items: end; }
  .cover-with-link .cover-wash { background: linear-gradient(0deg,#251822fc 0%,#251722b5 30%,#2b1a2509 75%); }
  .cover-with-link img { object-position: 50% 32%; }
  .cover-copy, .cover-with-link .cover-copy { padding: 23px 20px; }
  .cover-with-link .cover-copy h1 { font-size: clamp(2.8rem,11.2cqi,3.8rem); line-height: 1.14; }
  .cover-copy p { font-size: .9rem; line-height: 1.65; margin-block-start: 3px; }
  .cover-date { margin-bottom: 3px; font-size: .78rem; }
  .story-cta { margin-top: 13px; min-height: 44px; padding-inline: 14px; }
  .story-heading { min-height: 105px; padding: 14px 10px; }
  .story-heading h2 { font-size: clamp(1.7rem,7cqi,2.4rem); }
  .story-heading p, .story-text p { font-size: .95rem; }
  .timeline-row {
    gap: 0; padding: 6px 3px 5px; overflow: visible; background: transparent; border: 0;
    border-block: 1px solid color-mix(in srgb, var(--story-accent) 22%, transparent); border-radius: 0;
  }
  .timeline-heading { display: flex; min-height: 47px; align-items: center; justify-content: space-between; gap: 8px; }
  .timeline-caption { display: flex; align-items: center; gap: 7px; color: var(--story-ink); font-family: var(--album-heading); font-size: 1.42rem; font-weight: 700; }
  .timeline-caption svg { color: var(--story-accent); }
  .timeline-manage { width: 44px; height: 44px; border-radius: 8px; color: var(--story-accent); }
  .timeline-manage:hover { background: color-mix(in srgb,var(--story-accent) 8%,var(--story-paper)); }
  .timeline-row::before {
    inset: 70px 16px 53px auto; width: 1px; height: auto;
    background: color-mix(in srgb,var(--story-accent) 36%,transparent);
  }
  .timeline-row>.story-block { flex: auto; }
  .event-target {
    min-height: 67px; align-items: start; gap: 0; padding: 7px 36px 8px 39px; text-align: right;
    border-color: transparent; border-radius: 10px; background: transparent; color: var(--story-ink);
  }
  .event-target:is(a,button):hover {
    background: color-mix(in srgb, var(--story-accent) 9%, var(--story-paper)); border-color: transparent; color: var(--story-ink);
  }
  .event-mark {
    position: absolute; inset-inline-start: 7px; top: 13px; width: 13px; height: 13px;
    border-color: var(--story-accent); background: var(--story-paper); color: var(--story-accent);
  }
  .event-mark svg { display: none; }
  .event-mark::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
  .event-date { color: var(--story-accent); font-weight: 720; font-size: .76rem; }
  .event-target strong { font-size: 1rem; }
  .event-note { color: color-mix(in srgb,var(--story-ink) 83%, var(--story-paper)); font-size: .8rem; }
  .event-link-mark { inset-inline-end: 13px; bottom: auto; top: 26px; color: var(--story-accent); }
  .event-edit { display: none; }
}

@media (max-width: 840px) {
  .editor { height: 100dvh; min-height: 0; }
  .editor-header {
    min-height: 62px; grid-template-columns: minmax(0,1fr) auto auto;
    padding: max(6px, env(safe-area-inset-top)) 11px 6px; gap: 4px;
    background: #28202b; border-block-end-color: #554354;
  }
  .desktop-brand, .header-actions :is(.history-actions,.account-btn), .canvas-top, .editor .editing-story .story-nav { display: none; }
  .mobile-project { display: flex; align-items: center; gap: 7px; min-width: 0; }
  .mobile-project>.brand-mark { width: 32px; height: 32px; }
  .mobile-project>div { min-width: 0; }
  .mobile-project strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .85rem; line-height: 1.45; }
  .mobile-page { display: inline-flex; align-items: center; gap: 1px; max-width: 100%; min-height: 27px; padding: 0; text-align: right; font-size: .76rem; color: var(--accent-dark); white-space: nowrap; }
  .mobile-page span { overflow: hidden; text-overflow: ellipsis; }
  .editor .mode { display: flex; padding: 0; border: 0; background: transparent; }
  .header-center .mode button { width: 44px; height: 44px; color: var(--accent-dark); }
  .header-center .mode button.active, .header-center .mode button span { display: none; }
  .header-actions { gap: 2px; }
  .header-actions .save-button { width: 44px; height: 44px; position: relative; color: var(--accent-dark); }
  .editor-header:is([data-save-state="dirty"],[data-save-state="saving"]) .save-button::after {
    content: ''; position: absolute; top: 8px; inset-inline-start: 8px;
    width: 7px; height: 7px; border-radius: 50%; background: #ffca83;
  }
  .header-actions .publish-btn { min-height: 44px; padding-inline: 11px; font-size: .8rem; }
  .header-actions .publish-btn svg, .in-preview .header-actions { display: none; }
  .workspace { grid-template-columns: minmax(0,1fr); }
  .right-rail { display: none; }
  .editor .stage { padding: 0; background: #fdf7ee; }
  .editor .canvas-device { width: 100%; border: 0; border-radius: 0; box-shadow: none; }
  .editor .story-nav { padding-inline: 13px; }
  .editing-story .story-block.selected { outline-width: 1.5px; }
  .selection-dot, .block-controls span { display: none; }
  .story-block:hover .block-controls:not(.show):not(:focus-within) { opacity: 0; pointer-events: none; }
  .drag-grip { width: 42px; height: 42px; border: 1px solid #ffffff80; border-radius: 8px; }
  .resize-handle { display: none; }
  .mobile-only { display: inline-grid; }
  .desktop-only { display: none; }

  .mobile-controls { display: block; flex: none; border-top: 1px solid #554354; background: #28202b; padding-bottom: env(safe-area-inset-bottom); }
  .mobile-dock { display: grid; grid-template-columns: repeat(4,1fr); gap: 4px; padding: 5px 12px 6px; }
  .mobile-dock button {
    display: grid; justify-items: center; align-content: center; gap: 3px; min-height: 48px; padding: 3px 0;
    color: #f1dae8; font-size: .79rem; border-radius: 9px;
  }
  .mobile-dock button:hover { background: var(--accent-low); }
  .mobile-dock .dock-add { background: #483544; color: #ffddb3; font-weight: 750; }
  .mobile-dock .dock-active { color: var(--accent); font-weight: 750; }
  .mobile-scrim { display: block; position: fixed; inset: 0; background: #1c1119a0; z-index: 4; }
  .inspector, .bottom-panel {
    display: none; position: fixed; z-index: 5; bottom: var(--sheet-inset,0px); inset-inline: 0; border: 1px solid #745269;
    border-radius: 19px 19px 0 0; max-height: min(76dvh,calc(var(--visible-height,100dvh) - 22px)); padding-bottom: env(safe-area-inset-bottom); direction: rtl;
    box-shadow: 0 -12px 44px #140a1261;
  }
  .inspector.is-open, .bottom-panel.is-open { display: flex; flex-direction: column; }
  .panel-heading, .bottom-head { min-height: 57px; padding-inline: 14px; align-items: center; gap: 8px; }
  .panel-heading .icon-button, .bottom-head .icon-button { width: 44px; height: 44px; }
  .inspector-scroll, .bottom-content { overscroll-behavior: contain; }
  .inspector-group { padding-inline: 16px; }
  .inspector-tools { padding-inline: 13px; }
  .inspector-tools button { min-height: 46px; font-size: .88rem; }
  .inspector .field :is(input,textarea,select) { font-size: 1rem; min-height: 44px; }
  .bottom-head nav { display: none; }
  .mobile-panel-label { display: block; font-size: 1rem; }
  .bottom-panel.expanded .bottom-content { display: grid; grid-template-columns: 1fr; justify-items: stretch; max-height: 58dvh; overflow: auto; padding: 11px 13px 17px; }
  .bottom-content .chip { width: 100%; max-width: none; min-height: 46px; text-align: right; }
  .timeline-chip .timeline-jump { flex: 1; }
  .timeline-chip button { height: 46px; }
  .timeline-chip .timeline-chip-edit { width: 48px; justify-content: center; }
  #toast { bottom: calc(67px + env(safe-area-inset-bottom)); }
  body:has(.editor) #dialog {
    --surface: #2b1c2a; --text: #fcf2e8; --muted: #e1c8d7; --line: #654457;
    --accent: #efc08b; --accent-dark: #ffe1b2; --accent-low: #493042;
    width: 100%; max-width: 100%; max-height: min(85dvh,calc(var(--visible-height,100dvh) - 16px));
    margin: auto 0 var(--sheet-inset,0px); border-radius: 19px 19px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  body:has(.editor) #dialog :is(.icon-button,.insert-grid svg,.form-error) { color: var(--accent-dark); }
  body:has(.editor) #dialog .primary { color: #321d2b; }
  body:has(.editor) #dialog :is(.insert-grid button,.field input,.media-library button,.slug,.upload-drop) { background: #382638; }
  body:has(.editor) #dialog :is(.insert-grid button,.media-library button):hover { background: var(--accent-low); }
  body:has(.editor) #dialog .danger { color: #ffb4c0; }
  .visitor .story-nav { padding-top: max(9px, env(safe-area-inset-top)); }
}

@media (max-width: 840px) and (max-height: 480px) {
  .editor-header { min-height: 56px; }
}

@media (max-width: 560px) {
  .starter-cards { grid-template-columns: 1fr; gap: 8px; }
  .starter-card { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; }
  .starter-choice { display: flex; align-items: center; min-height: 72px; }
  .starter-choice img { flex: 0 0 88px; width: 88px; height: 72px; }
  .starter-choice strong { padding: 7px 9px; font-size: .88rem; }
  .starter-card a { padding-inline: 7px; min-height: 44px; font-size: .77rem; }
  .starter-guide { margin-block: 13px; }
}
