/* Apple HIG adaptation for the existing iOS WKWebView, not native SwiftUI controls.
   Sidebar/tab-bar guidance: https://developer.apple.com/design/human-interface-guidelines/
   Browser and Mac layouts continue to use bookshelf.css. */
.qa-native-ios .shelf-page {
  --sf-bg: #fff;
  --sf-muted-bg: #f2f2f7;
  --sf-text: #1c1c1e;
  --sf-muted: #6c6c70;
  --sf-line: rgba(60,60,67,.16);
  --sf-accent: #0e6b5c;
  --sf-primary: #0e6b5c;
  --sf-selected: #e3efeb;
  --sf-danger: #c9342b;
  --sf-bar: rgba(249,249,251,.94);
  --sf-header-height: calc(52px + env(safe-area-inset-top));
  background: var(--sf-muted-bg);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
.qa-native-ios[data-theme=dark] .shelf-page {
  --sf-bg: #1c1c1e;
  --sf-muted-bg: #000;
  --sf-text: #f5f5f7;
  --sf-muted: #a1a1a6;
  --sf-line: rgba(235,235,245,.18);
  --sf-accent: #76cbb7;
  --sf-primary: #0e6b5c;
  --sf-selected: #203b34;
  --sf-danger: #ff6961;
  --sf-bar: rgba(28,28,30,.94);
}
.qa-native-ios .shelf-icon { width: 44px; height: 44px; min-width: 44px; min-height: 44px; padding: 11px; border-radius: 10px; color: var(--sf-accent); }
.qa-native-ios .shelf-icon:active { background: var(--sf-selected); }
.qa-native-ios .shelf-layout { grid-template-columns: 248px minmax(0,1fr); min-height: calc(100dvh - var(--sf-header-height)); }
.qa-native-ios .shelf-sidebar { position: sticky; top: var(--sf-header-height); height: calc(100dvh - var(--sf-header-height)); overflow: auto; padding: 20px 12px; background: var(--sf-bar); border-right: .5px solid var(--sf-line); }
.qa-native-ios .shelf-tree-row { min-height: 46px; margin: 3px 0; padding-left: min(calc(var(--depth)*12px),48px); border-radius: 10px; }
.qa-native-ios .shelf-tree-row:hover { background: var(--sf-selected); }
.qa-native-ios .shelf-tree-row[data-current=true] { background: var(--sf-selected); color: var(--sf-accent); }
.qa-native-ios .shelf-expander { width: 28px; min-height: 44px; font-size: 20px; }
.qa-native-ios .shelf-tree-label { min-height: 44px; padding: 8px 0; gap: 10px; font-size: 16px; line-height: 22px; }
.qa-native-ios .shelf-tree-label svg { width: 20px; height: 20px; color: var(--sf-accent); }
.qa-native-ios .shelf-tree-root { margin-top: 8px; }
.qa-native-ios .shelf-tree-row>.shelf-menu>summary { width: 44px; min-width: 44px; height: 44px; padding: 11px; opacity: 1; }
.qa-native-ios .shelf-main { padding: 16px 28px 32px; }
.qa-native-ios .shelf-toolbar { gap: 8px; margin-bottom: 16px; }
.qa-native-ios .shelf-path { min-height: 44px; font-size: 14px; line-height: 20px; }
.qa-native-ios .shelf-path [aria-current] { color: var(--sf-text); font-weight: 600; }
.qa-native-ios .shelf-sort select { min-height: 44px; max-width: 132px; border: 0; background: transparent; color: var(--sf-accent); font-size: 14px; }
.qa-native-ios .shelf-tools { gap: 0; }
.qa-native-ios .shelf-tools>.shelf-icon { border: 0; background: transparent; }
.qa-native-ios .shelf-table-head { display: none; }
.qa-native-ios .shelf-book-list { overflow: hidden; background: var(--sf-bg); border: 0; border-radius: 14px; }
.qa-native-ios .shelf-page.shelf-touch-list .shelf-book-list { --sf-list-inset: 12px; }
.qa-native-ios .shelf-book-row { position: relative; grid-template-columns: minmax(0,1fr) auto auto 44px; gap: 12px; padding: 18px 16px; border-bottom: .5px solid var(--sf-line); }
.qa-native-ios .shelf-book-row:hover { background: var(--sf-bg); }
.qa-native-ios .shelf-book-main { grid-column: auto; gap: 14px; align-items: center; margin: 0; }
.qa-native-ios .shelf-book-icon { width: 48px; height: 66px; border-radius: 3px 6px 6px 3px; }
.qa-native-ios .shelf-book-info { gap: 3px; }
.qa-native-ios .shelf-book-info strong { font-size: 16px; line-height: 22px; font-weight: 600; }
.qa-native-ios .shelf-author { font-size: 13px; line-height: 19px; }
.qa-native-ios .shelf-book-position { display: none; }
.qa-native-ios .shelf-mobile-position { display: block; margin-top: 3px; font-size: 12px; line-height: 18px; color: var(--sf-muted); }
.qa-native-ios .shelf-book-notes { min-height: 44px; margin: 0; padding: 0 6px; font-size: 13px; color: var(--sf-accent)!important; }
.qa-native-ios .shelf-book-notes.is-empty { color: var(--sf-muted)!important; }
.qa-native-ios .shelf-read { display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 12px; border: 0; border-radius: 22px; background: var(--sf-selected); color: var(--sf-accent)!important; font-size: 14px; font-weight: 600; }
.qa-native-ios .shelf-book-more { position: static; justify-self: end; color: var(--sf-muted); }
.qa-native-ios .shelf-book-main:hover strong { text-decoration: none; }
.qa-native-ios .shelf-covers { grid-template-columns: repeat(auto-fill,minmax(0,180px)); gap: 28px; }
.qa-native-ios .shelf-covers .shelf-cover-card { display: block; padding: 0; border: 0; background: transparent; }
.qa-native-ios .shelf-cover-card .shelf-book-main { display: block; margin: 0; }
.qa-native-ios .shelf-cover-card .shelf-book-icon { width: 100%; height: auto; aspect-ratio: 3/4; padding: 18px 14px 64px 18px; gap: 12px; border-radius: 3px 8px 8px 3px; box-shadow: 0 2px 5px #00000009; }
.qa-native-ios .shelf-cover-card .shelf-book-icon strong { font-size: 15px; line-height: 1.4; }
.qa-native-ios .shelf-cover-card .shelf-book-icon small { font-size: 11px; line-height: 16px; }
.qa-native-ios .shelf-cover-card .shelf-book-more { position: relative; width: 44px; min-width: 44px; height: 44px; min-height: 44px; color: inherit; }
.qa-native-ios .shelf-cover-card .shelf-book-notes { left: 8px; bottom: 6px; min-width: 44px; min-height: 44px; padding: 0 6px; font-size: 13px; }
.qa-native-ios .shelf-button { min-height: 44px; min-width: 44px; padding: 10px 16px; border: 0; border-radius: 11px; font-size: 16px; font-weight: 500; }
.qa-native-ios .shelf-button:active { opacity: .7; }
.qa-native-ios .shelf-button.primary { background: var(--sf-primary); color: #fff; }
.qa-native-ios .shelf-dialog { border: 0; border-radius: 22px; padding: 24px; background: var(--sf-bg); box-shadow: 0 20px 80px #00000029; }
.qa-native-ios .shelf-dialog::backdrop { background: #0000004d; }
.qa-native-ios .shelf-dialog>header { margin-bottom: 12px; }
.qa-native-ios .shelf-dialog h2 { font-size: 19px; line-height: 26px; }
.qa-native-ios .shelf-dialog>header>.shelf-icon { border-radius: 50%; background: var(--sf-muted-bg); color: var(--sf-muted); }
.qa-native-ios .shelf-dialog p { font-size: 14px; line-height: 1.6; }
.qa-native-ios .shelf-field { font-size: 14px; gap: 8px; }
.qa-native-ios .shelf-field input,.qa-native-ios .shelf-field select { min-height: 48px; padding: 11px 12px; border: .5px solid var(--sf-line); border-radius: 10px; background: var(--sf-muted-bg); font-size: 17px; }
.qa-native-ios .shelf-form-actions { gap: 12px; }
.qa-native-ios .shelf-details { gap: 16px; font-size: 14px; }
.qa-native-ios .shelf-detail-title { font-size: 23px; }
.qa-native-ios .shelf-detail-actions { gap: 10px; }
.qa-native-ios .shelf-menu-panel { padding: 6px; border: .5px solid var(--sf-line); border-radius: 14px; box-shadow: 0 8px 32px #00000026; }
.qa-native-ios .shelf-menu-item,.qa-native-ios .shelf-text { min-height: 44px; padding: 11px 14px; border-radius: 8px; font-size: 16px; }
.qa-native-ios .shelf-native-menu { position: relative; cursor: pointer; }
.qa-native-ios .shelf-native-menu>select { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; opacity: 0; font-size: 17px; cursor: pointer; }
.qa-native-ios:not(.qa-pointer-input) .shelf-native-menu:focus-within { outline: 2px solid var(--sf-accent); outline-offset: 3px; }
.qa-native-ios .shelf-native-menu.is-disabled { opacity: .5; cursor: not-allowed; }
.qa-native-ios .shelf-empty { min-height: 280px; border: 0; border-radius: 14px; background: var(--sf-bg); gap: 10px; }
.qa-native-ios .shelf-empty h2 { font-size: 18px; font-weight: 600; }
.qa-native-ios .shelf-empty p { font-size: 14px; }
.qa-native-ios .shelf-query { border: 0; border-radius: 10px; background: var(--sf-bg); font-size: 14px; }
.qa-native-ios .shelf-message { font-size: 13px; }
.qa-native-ios .shelf-footer { font-size: 12px; }
.qa-native-ios .shelf-notes { padding: 24px; }
.qa-native-ios .shelf-notes h1 { font-size: 28px; font-weight: 700; letter-spacing: -.5px; }
.qa-native-ios .shelf-note-group { min-height: 88px; padding: 16px; gap: 12px; align-items: center; border: 0; border-radius: 14px; background: var(--sf-bg); }
.qa-native-ios #shelfNoteGroups { gap: 12px; border-top: 0; }
.qa-native-ios .shelf-note-group>.shelf-svg { width: 36px; height: 44px; border-radius: 8px; }
.qa-native-ios .shelf-note-group>.shelf-svg svg { width: 22px; height: 22px; }
.qa-native-ios .shelf-note-group>span:last-child { flex: none; padding: 0; font-size: 22px; line-height: 1; }
.qa-native-ios .shelf-note-group strong { font-size: 16px; line-height: 22px; }
.qa-native-ios .shelf-note-group small { font-size: 13px; }

/* Task sheets keep book math in the existing WebKit renderer. */
.qa-native-ios .shelf-book-detail { max-width: min(560px,calc(100vw - 32px)); background: var(--sf-muted-bg); }
.qa-native-ios .shelf-detail-hero { display: flex; gap: 16px; align-items: center; margin: 20px 0; }
.qa-native-ios .shelf-detail-hero>.shelf-book-icon { width: 68px; height: 92px; flex: none; }
.qa-native-ios .shelf-detail-hero>div { min-width: 0; }
.qa-native-ios .shelf-detail-hero .shelf-detail-title { margin: 0 0 6px; font-size: 21px; line-height: 29px; }
.qa-native-ios .shelf-detail-hero p { margin: 0; font-size: 14px; }
.qa-native-ios .shelf-book-detail .shelf-details { grid-template-columns: 88px minmax(0,1fr); gap: 0; margin: 20px 0; padding: 0 14px; border-radius: 14px; background: var(--sf-bg); }
.qa-native-ios .shelf-book-detail .shelf-details dt,.qa-native-ios .shelf-book-detail .shelf-details dd { padding: 13px 0; border-bottom: .5px solid var(--sf-line); font-size: 14px; line-height: 21px; }
.qa-native-ios .shelf-book-detail .shelf-details dt:last-of-type,.qa-native-ios .shelf-book-detail .shelf-details dd:last-of-type { border-bottom: 0; }
.qa-native-ios .shelf-book-detail .shelf-detail-actions { gap: 1px; border-radius: 12px; overflow: hidden; }
.qa-native-ios .shelf-book-detail .shelf-detail-actions>.shelf-button { min-height: 48px; justify-content: flex-start; padding: 12px 14px; border-radius: 0; background: var(--sf-bg); text-align: left; font-size: 16px; }
.qa-native-ios .shelf-book-detail .shelf-detail-actions>.primary { margin-bottom: 12px; justify-content: center; border-radius: 12px; background: var(--sf-primary); color: #fff; font-weight: 600; }
.qa-native-ios .shelf-action-chevron { margin-left: auto; color: var(--sf-muted); font-size: 22px; }
.qa-native-ios .shelf-move-dialog { background: var(--sf-muted-bg); }
.qa-native-ios .shelf-move-context { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; overflow-wrap: anywhere; }
.qa-native-ios .shelf-move-context>.shelf-svg { margin-top: 2px; color: var(--sf-accent); }
.qa-native-ios .shelf-move-context strong { min-width: 0; font-size: 16px; line-height: 24px; font-weight: 600; }
.qa-native-ios .shelf-move-content>p { margin: 0 0 16px; }
.qa-native-ios .shelf-move-options { margin: 0; padding: 0; border: 0; border-radius: 12px; background: var(--sf-bg); max-height: min(44dvh,360px); overflow: auto; overscroll-behavior: contain; }
.qa-native-ios .shelf-move-option { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 12px 14px; border-bottom: .5px solid var(--sf-line); cursor: pointer; }
.qa-native-ios .shelf-move-option:last-child { border-bottom: 0; }
.qa-native-ios .shelf-move-option>.shelf-svg { color: var(--sf-accent); }
.qa-native-ios .shelf-move-option>span:nth-child(2) { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.qa-native-ios .shelf-move-option strong { display: block; font-size: 16px; line-height: 22px; font-weight: 500; }
.qa-native-ios .shelf-move-option small { display: block; margin-top: 3px; font-size: 12px; line-height: 18px; }
.qa-native-ios .shelf-move-option input { -webkit-appearance: none; appearance: none; width: 24px; height: 24px; flex: none; margin: 0; border: 0; background: none; color: var(--sf-accent); font-size: 21px; }
.qa-native-ios .shelf-move-option input:checked::after { content: "✓"; }
.qa-native-ios .shelf-move-option:active { background: var(--sf-selected); }

/* Compact iPad windows and both iPhone orientations use the same navigation model. */
.qa-native-ios.qa-compact-navigation .shelf-layout { display: block; min-height: calc(100dvh - var(--sf-header-height) - 50px - env(safe-area-inset-bottom)); }
.qa-native-ios.qa-compact-navigation .shelf-sidebar { display: none; }
.qa-native-ios.qa-compact-navigation .shelf-main { padding: 8px max(16px,env(safe-area-inset-right)) 24px max(16px,env(safe-area-inset-left)); }
.qa-native-ios.qa-compact-navigation .shelf-toolbar { margin-bottom: 10px; flex-wrap: wrap; }
.qa-native-ios.qa-compact-navigation .shelf-path { flex-wrap: nowrap; overflow: auto; scrollbar-width: none; gap: 8px; font-size: 13px; }
.qa-native-ios.qa-compact-navigation .shelf-path>* { flex: none; }
.qa-native-ios.qa-compact-navigation .shelf-path-link { white-space: nowrap; }
.qa-native-ios.qa-compact-navigation .shelf-sort select { font-size: 13px; max-width: 112px; }
.qa-native-ios.qa-compact-navigation .shelf-book-row { grid-template-columns: minmax(0,1fr) auto; gap: 4px 8px; padding: 16px 12px 8px; }
.qa-native-ios.qa-compact-navigation .shelf-book-main { grid-column: 1/-1; align-items: flex-start; gap: 12px; margin-right: 32px; }
.qa-native-ios.qa-compact-navigation .shelf-book-notes { grid-column: 1; margin-left: 52px; }
.qa-native-ios.qa-compact-navigation .shelf-read { grid-column: 2; padding: 0 10px; background: none; }
.qa-native-ios.qa-compact-navigation .shelf-book-more { position: absolute; top: 8px; right: 4px; }
.qa-native-ios.qa-compact-navigation .shelf-book-row:last-child { border-bottom: 0; }
.qa-native-ios.qa-compact-navigation .shelf-covers { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 20px 18px; }
.qa-native-ios.qa-compact-navigation .shelf-covers .shelf-cover-card { padding: 0; }
.qa-native-ios.qa-compact-navigation .shelf-cover-card .shelf-book-main { display: block; margin: 0; }
.qa-native-ios.qa-compact-navigation .shelf-cover-card .shelf-book-icon { padding: 16px 12px 64px 16px; }
.qa-native-ios.qa-compact-navigation .shelf-cover-card .shelf-book-icon strong { font-size: clamp(13px,3.8vw,16px); }

.qa-native-ios.qa-compact-navigation .shelf-cover-card .shelf-book-more { position: relative; }
.qa-native-ios.qa-compact-navigation .shelf-cover-card .shelf-book-notes { margin: 0; }
.qa-native-ios.qa-compact-navigation .shelf-dialog { position: fixed; inset: auto 0 0; width: 100%; max-width: 100vw; max-height: 88dvh; margin: 0; border-radius: 22px 22px 0 0; padding: 20px max(20px,env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(20px,env(safe-area-inset-left)); }
.qa-native-ios.qa-compact-navigation .shelf-book-detail { max-width: 100vw; }
.qa-native-ios.qa-compact-navigation .shelf-form-actions>* { flex: 1; }
.qa-native-ios.qa-compact-navigation .shelf-sheet-actions { gap: 2px; }
.qa-native-ios.qa-compact-navigation .shelf-sheet-actions .shelf-text { min-height: 50px; border-bottom: .5px solid var(--sf-line); border-radius: 0; }
.qa-native-ios.qa-compact-navigation .shelf-sheet-actions .shelf-text:last-child { border-bottom: 0; }
.qa-native-ios.qa-compact-navigation .shelf-drawer { inset: 0 auto 0 0; width: min(340px,calc(100vw - 44px)); height: 100dvh; max-height: 100dvh; padding: calc(12px + env(safe-area-inset-top)) 12px calc(20px + env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left)); border-radius: 0 20px 20px 0; background: var(--sf-bar); }
.qa-native-ios.qa-compact-navigation .shelf-drawer>header { padding: 0 4px 12px; border-bottom: .5px solid var(--sf-line); }
.qa-native-ios.qa-compact-navigation .shelf-drawer[open] { animation: shelf-drawer-in 240ms cubic-bezier(.22,1,.36,1) both; }
.qa-native-ios.qa-compact-navigation .shelf-drawer[open]::backdrop { animation: shelf-drawer-shade-in 240ms ease-out both; }
.qa-native-ios.qa-compact-navigation .shelf-drawer.shelf-drawer-closing { animation: shelf-drawer-out 180ms ease-in both; pointer-events: none; }
.qa-native-ios.qa-compact-navigation .shelf-drawer.shelf-drawer-closing::backdrop { animation: shelf-drawer-shade-out 180ms ease-in both; }
.qa-native-ios.qa-compact-navigation .shelf-notes { padding: 20px 16px 24px; min-height: calc(100dvh - var(--sf-header-height) - 50px - env(safe-area-inset-bottom)); }

/* Regular iPad: larger cover slot, inset separators and one horizontal action group. */
.qa-native-ios:not(.qa-compact-navigation) .shelf-page.shelf-touch-list .shelf-book-list>.shelf-book-row { min-height: 132px; padding: 16px 20px; border-bottom: 0; }
.qa-native-ios:not(.qa-compact-navigation) .shelf-page.shelf-touch-list .shelf-book-list>.shelf-book-row::after { content: ""; position: absolute; left: 108px; right: 20px; bottom: 0; height: .5px; background: var(--sf-line); }
.qa-native-ios:not(.qa-compact-navigation) .shelf-page.shelf-touch-list .shelf-book-list>.shelf-book-row:last-child::after { display: none; }
.qa-native-ios:not(.qa-compact-navigation) .shelf-page.shelf-touch-list .shelf-book-list .shelf-book-main { gap: 16px; align-items: center; min-height: 100px; margin: 0 124px 0 0; }
.qa-native-ios:not(.qa-compact-navigation) .shelf-page.shelf-touch-list .shelf-book-list .shelf-book-icon { width: 72px; height: 100px; }
.qa-native-ios:not(.qa-compact-navigation) .shelf-page.shelf-touch-list .shelf-book-list .shelf-book-info strong { font-size: 17px; line-height: 24px; }
.qa-native-ios:not(.qa-compact-navigation) .shelf-page.shelf-touch-list .shelf-book-list .shelf-author { font-size: 13px; line-height: 19px; }
.qa-native-ios:not(.qa-compact-navigation) .shelf-page.shelf-touch-list .shelf-book-list .shelf-mobile-position { font-size: 13px; line-height: 20px; }
.qa-native-ios:not(.qa-compact-navigation) .shelf-page.shelf-touch-list .shelf-book-list .shelf-book-more { inset: 50% 12px auto auto; transform: translateY(-50%); }
.qa-native-ios:not(.qa-compact-navigation) .shelf-page.shelf-touch-list .shelf-book-list .shelf-book-notes { inset: 50% 68px auto auto; transform: translateY(-50%); font-size: 13px; }
@media (orientation:landscape) and (max-height:500px) {
  .qa-native-ios.qa-compact-navigation .shelf-covers { grid-template-columns: repeat(auto-fill,minmax(0,156px)); }
}
@media (prefers-reduced-motion:reduce) {
  .qa-native-ios.qa-compact-navigation .shelf-drawer[open],
  .qa-native-ios.qa-compact-navigation .shelf-drawer[open]::backdrop { animation: none; }
}

/* The shelf scrolls vertically; breadcrumb overflow remains inside its own row. */
html.qa-native-ios:has(>body.shelf-page),.qa-native-ios body.shelf-page {
  overflow-x: clip;
  overscroll-behavior-x: none;
}
