#chapter-toggle { display: none; }

@media (max-width: 680px) {
  :root {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --header: calc(60px + var(--safe-top));
    --chapter-bar: 46px;
    --gutter: 20px;
  }
  html { scroll-padding-top: calc(var(--header) + var(--chapter-bar) + 12px); }
  .chapter, .source-row { scroll-margin-top: 0; }
  .masthead { padding-top: var(--safe-top); }
  .masthead .context-toggle { min-width: 40px; min-height: 44px; }
  .masthead nav.language-menu { padding: 0 2px; }
  .masthead nav.language-menu a { height: 42px; }
  .cover { height: auto; min-height: 360px; display: grid; grid-template-rows: 1fr auto; }
  .cover-content { width: 100%; padding: 2rem var(--gutter) 1.5rem; }
  .cover h1 { font-size: 4.25rem; }
  :lang(de) .cover h1, :lang(en) .cover h1 { font-size: 3rem; }
  .cover-deck { font-size: 0.9375rem; line-height: 1.55; }
  .cover-deck br { display: initial; }
  .cover-link { min-height: 44px; padding-block: 0.5rem; }
  .cover-caption { position: relative; padding: 0.75rem var(--gutter); font-size: 0.75rem; line-height: 1.4; }
  .reader-shell { padding-inline: var(--gutter); }
  .timeline { margin-inline: calc(-1 * var(--gutter)); }
  #chapter-toggle {
    width: 100%;
    height: var(--chapter-bar);
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr) 18px;
    align-items: center;
    gap: 0.7rem;
    padding: 0 var(--gutter);
    border: 0;
    background: #fff;
    color: var(--teal);
    text-align: left;
    font-size: 0.9375rem;
    font-weight: 700;
  }
  #chapter-toggle span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #chapter-toggle svg { width: 18px; height: 18px; }
  #chapter-toggle[aria-expanded="true"] svg:last-child { transform: rotate(180deg); }
  #chapter-toggle:focus-visible { outline-offset: -4px; }
  .timeline nav { display: none; }
  #chapter-toggle[aria-expanded="true"] + #chapter-nav {
    position: absolute;
    inset: 100% 0 auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    height: auto;
    max-height: calc(100dvh - var(--header) - var(--chapter-bar) - var(--safe-bottom) - 8px);
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-width: auto;
    padding: 0.4rem var(--gutter);
    background: white;
    border-bottom: 1px solid var(--line);
    box-shadow: 0 8px 14px #24282919;
  }
  .timeline nav a { display: flex; align-items: center; min-height: 44px; padding: 0.45rem 0.6rem; font-size: 0.9375rem; overflow-wrap: anywhere; }
  .timeline nav a.active { border: 0; background: var(--paper); }
  .timeline nav a:focus-visible { outline-offset: -3px; }
  .chapter { padding-block: 2rem; }
  .chapter p { font-size: 1rem; line-height: 1.65; }
  .context p, .source-row p, .research-log p { font-size: 0.9375rem; line-height: 1.6; }
  .context a, .source-row a, .month-detail a, .site-footer a { font-size: 0.875rem; }
  .source-row .shelf { font-size: 0.75rem; }
  .source-row a { padding-block: 0.55rem; }
  .profile-links a { display: inline-flex; align-items: center; min-height: 44px; }
  .tree-node { font-size: 1rem; }
  .tree-role { font-size: 0.8125rem; }
  .tree-node.node-zinaida { min-height: 0; }
  .months button { min-height: 44px; font-size: 0.875rem; }
  .month-detail { min-height: 0; }
  .doc-filters { flex-wrap: wrap; }
  .doc-filters button { min-height: 44px; font-size: 0.875rem; }
  .document-grid { grid-template-columns: minmax(0, 1fr); gap: 0.625rem; }
  .doc-tile { display: grid; grid-template-columns: 96px minmax(0, 1fr); min-height: 100px; align-items: stretch; }
  .doc-tile img { height: 100%; max-height: 130px; align-self: center; padding: 8px; }
  .doc-tile .tile-copy { align-self: center; }
  .doc-tile strong { font-size: 0.9375rem; font-weight: 600; }
  .doc-tile small, .doc-tile .tile-date { font-size: 0.75rem; }
  .scan-lightbox { padding-bottom: var(--safe-bottom); }
  .scan-lightbox .dialog-header { padding-top: calc(8px + var(--safe-top)); }
  .scan-lightbox .reader-actions .icon-button, .scan-lightbox .image-toolbar .icon-button { width: 44px; height: 44px; }
  .scan-lightbox .image-toolbar { gap: 3px; padding-inline: 8px; }
  .scan-lightbox .image-viewport { padding: 6px; }
  .translation-panel p, .translation-row span { font-size: 0.9375rem; }
  .site-footer { padding-bottom: calc(2rem + var(--safe-bottom)); }
  #back-top { width: 44px; height: 44px; bottom: calc(12px + var(--safe-bottom)); }
}

@media (max-width: 360px) {
  .masthead .context-toggle { min-width: 34px; }
  .masthead nav.language-menu a { width: 30px; }
  .months { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tree-parents .tree-node { padding-inline: 0.55rem; }
}

@media (hover: none) and (pointer: coarse) and (orientation: landscape) {
  .scan-lightbox .dialog-header {
    padding-inline: max(12px, env(safe-area-inset-left, 0px)) max(12px, env(safe-area-inset-right, 0px));
  }
  .scan-lightbox .image-toolbar {
    padding-inline: max(8px, env(safe-area-inset-left, 0px)) max(8px, env(safe-area-inset-right, 0px));
  }
}
