/* Shared visual language. Layout, reader gestures and document artwork stay in
   their own modules; this layer supplies type, surfaces and interaction states. */
@font-face {
  font-family: 'Instrument Sans';
  src: url('./fonts/instrument-sans.woff2') format('woff2');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Cormorant Garamond';
  src: url('./fonts/cormorant-garamond.woff2') format('woff2');
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

@media screen {
  :root {
    --font: 'Instrument Sans', 'Segoe UI', Arial, sans-serif;
    --display: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
    --paper: #f8f6f0;
    --white: #fffdfa;
    --ink: #302e28;
    --muted: #69655b;
    --line: #ded9ce;
    --green: #444c3e;
    --lime: #ede9dd;
    --sand: #e9e4da;
    --accent: #7c6340;
    --accent-soft: #c7b38d;
    --on-accent: #fffdf7;
    --surface: #f1eee6;
    --cover-ground: #eae6dd;
    --cover-edge: #d5cec1;
    --reader-toolbar: #f1eee7;
    --reader-stage: #dcd9d1;
    --shadow: 0 12px 36px -24px #302b2452;
  }
  [data-theme='dark'] {
    --paper: #1c1e1b;
    --white: #232622;
    --ink: #e8e4da;
    --muted: #b6b0a3;
    --line: #3c4037;
    --green: #d3c19b;
    --lime: #33372e;
    --sand: #30332c;
    --accent: #d3bc8e;
    --accent-soft: #76684c;
    --on-accent: #24261f;
    --surface: #262923;
    --cover-ground: #2c3029;
    --cover-edge: #43483b;
    --reader-toolbar: #242821;
    --reader-stage: #121510;
    --shadow: 0 14px 40px -22px #000b;
  }
  body {
    font-family: var(--font);
    font-weight: 400;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }
  ::selection {
    background: var(--accent-soft);
    color: #252720;
  }
  button,
  input,
  select,
  textarea {
    font-family: var(--font);
  }
  button,
  a,
  summary,
  input,
  select,
  textarea {
    outline-color: var(--accent);
  }
  button:focus-visible,
  a:focus-visible,
  summary:focus-visible,
  input:focus-visible,
  select:focus-visible,
  textarea:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
  }
  button,
  a,
  summary {
    transition:
      color 0.16s ease,
      background-color 0.16s ease,
      border-color 0.16s ease,
      box-shadow 0.16s ease;
  }
  button:hover,
  a:hover,
  [data-theme='dark'] button:hover,
  [data-theme='dark'] a:hover {
    color: var(--accent);
  }
  button:disabled {
    cursor: default;
  }
  a {
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
  }
  h1,
  h2,
  h3 {
    font-kerning: normal;
  }
  .ui-icon {
    display: inline-block;
    vertical-align: middle;
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
  }

  /* The masthead and quiet navigation establish the same hierarchy everywhere. */
  .compact .topbar {
    height: 62px;
    padding-inline: 26px;
    border-bottom-color: var(--line);
  }
  .identity {
    font-size: 12px;
    letter-spacing: 2.6px;
    font-weight: 600;
    color: var(--ink);
    gap: 12px;
  }
  .identity em {
    font-weight: 500;
  }
  .identity svg {
    stroke: var(--accent);
    width: 35px;
    height: 35px;
  }
  .top-actions {
    gap: 18px;
  }
  .private {
    font-size: 10px;
    letter-spacing: 0.5px;
    color: var(--muted);
  }
  .theme-toggle {
    border-bottom: 1px solid var(--line);
    padding: 5px 0;
    font-size: 11px;
  }
  .icon-btn {
    border-color: var(--line);
    color: var(--muted);
    font-family: var(--display);
    font-size: 18px;
  }
  .compact .tabs {
    padding-inline: 26px;
    gap: 27px;
    min-height: 47px;
    background: var(--paper);
  }
  .compact .tabs > .tab {
    height: 47px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.1px;
    color: var(--muted);
  }
  .compact .tabs > .tab.active {
    border-bottom-color: var(--accent);
    color: var(--ink);
    font-weight: 600;
  }
  .tab span {
    font-size: 9px;
    background: var(--sand);
    font-variant-numeric: tabular-nums;
  }
  .nav-menu > summary {
    border: 1px solid transparent;
    background: transparent;
    border-radius: 3px;
    color: var(--muted);
    padding: 6px 10px;
    font-size: 11px;
  }
  .nav-menu.active > summary,
  .nav-menu[open] > summary {
    color: var(--ink);
    border-color: var(--line);
    background: var(--white);
  }
  .nav-menu > summary:hover {
    border-color: var(--line);
    color: var(--ink);
  }
  .nav-menu .workspace-links {
    border-color: var(--line);
    background: var(--white);
    border-radius: 6px;
    box-shadow: var(--shadow);
    padding: 10px;
  }
  .nav-menu .workspace-links .eyebrow {
    letter-spacing: 1.8px;
    color: var(--accent);
  }
  .compact .nav-menu .workspace-links .menu-item {
    border-radius: 3px;
    padding: 10px 12px;
    color: var(--ink);
  }
  .nav-menu .menu-item small {
    color: var(--muted);
  }
  .compact .sidebar {
    padding-top: 23px;
    background: var(--paper);
  }
  .eyebrow {
    letter-spacing: 1.9px;
    font-weight: 500;
    color: var(--muted);
  }
  .compact .sidebar > .eyebrow {
    font-size: 9px;
    line-height: 1.8;
    margin-bottom: 15px;
    padding-left: 10px;
  }
  .compact .side {
    min-height: 35px;
    padding: 7px 10px;
    margin: 2px 0;
    border: 1px solid transparent;
    border-radius: 3px;
    font-size: 11px;
    color: var(--muted);
  }
  .side span {
    font-size: 10px;
    font-variant-numeric: tabular-nums;
  }
  .compact .side:hover {
    background: var(--surface);
    color: var(--ink);
  }
  .compact .side.active {
    background: var(--lime);
    border-color: var(--line);
    color: var(--ink);
    font-weight: 600;
  }
  .side.active span {
    color: var(--accent);
  }
  .sidebar-note .tiny-mark {
    color: var(--accent-soft);
  }
  .compact .sidebar-note h3 {
    font: 500 22px/1.05 var(--display);
    letter-spacing: -0.3px;
  }
  .sidebar-note p {
    line-height: 1.7;
  }
  .snapshot {
    line-height: 1.8;
  }
  .compact main {
    padding-top: 20px;
  }
  .compact .hero {
    padding-bottom: 13px;
    min-height: 0;
  }
  .compact .hero .eyebrow {
    font-size: 9px;
    margin-bottom: 4px;
    color: var(--accent);
  }
  .compact .hero h1 {
    font: 500 39px/1.04 var(--display);
    letter-spacing: -1.1px;
    margin-bottom: 7px;
  }
  .compact .hero .intro {
    font-size: 12px;
    line-height: 1.55;
    max-width: 700px;
  }
  .library-help {
    gap: 18px;
    margin-top: 8px;
  }
  .library-help .text-button {
    font-size: 10px;
    color: var(--muted);
    text-decoration-color: var(--line);
  }
  .library-help .text-button:hover {
    color: var(--accent);
    text-decoration-color: currentColor;
  }
  .compact .stats {
    gap: 30px;
    padding: 10px 0;
    margin-bottom: 19px;
    align-items: center;
  }
  .compact .stat {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
  }
  .compact .stat strong {
    font: 500 29px/1 var(--display);
    font-variant-numeric: lining-nums tabular-nums;
    color: var(--ink);
  }
  .stat span {
    font-size: 10px;
    line-height: 1.35;
    letter-spacing: 0;
    max-width: 100px;
  }
  .stats .stat-note {
    font-size: 10px;
    line-height: 1.5;
  }
  .section-heading {
    align-items: center;
  }
  .compact .section-heading {
    margin-bottom: 12px;
  }
  .compact .section-heading h2 {
    font: 500 30px/1.1 var(--display);
    letter-spacing: -0.55px;
  }
  .section-heading p {
    font-size: 11px;
    line-height: 1.55;
    margin-top: 4px;
  }
  .shelf-display {
    gap: 13px;
  }
  #continue-reading {
    color: var(--muted);
    max-width: 220px;
    text-align: left;
  }
  .view-toggle {
    border-color: var(--line);
    border-radius: 4px;
    padding: 2px;
    gap: 1px;
    background: var(--white);
  }
  .view-toggle button {
    display: grid;
    place-items: center;
    min-width: 32px;
    min-height: 30px;
    padding: 5px 7px;
    border-radius: 2px;
    color: var(--muted);
  }
  .view-toggle .selected,
  [data-theme='dark'] .view-toggle .selected {
    background: var(--green);
    color: var(--paper);
  }
  .reading-desk {
    border-color: var(--line);
    background: var(--white);
    border-radius: 4px;
    box-shadow: none;
    margin-bottom: 13px;
  }
  .reading-desk > summary {
    padding: 10px 13px;
    gap: 12px;
    font-size: 11px;
  }
  .reading-desk > summary > strong {
    font-weight: 500;
    letter-spacing: 0.1px;
  }
  .reading-desk > summary > span {
    font-size: 10px;
  }
  .reading-desk > summary:after {
    font-weight: 400;
    color: var(--accent);
    font-size: 16px;
    line-height: 1;
  }
  .reading-item strong {
    font-size: 12px;
    font-weight: 500;
  }
  .reading-item:hover {
    background: var(--surface);
  }
  .shelf-instruction {
    font-size: 10px;
    line-height: 1.6;
    margin-bottom: 10px;
  }

  /* Porcelain-like fields and clear, closely spaced controls. */
  .compact .filters {
    gap: 7px;
    margin-bottom: 13px;
  }
  .compact .search,
  .compact .filters select {
    background: var(--white);
    border-color: var(--line);
    border-radius: 4px;
    box-shadow: none;
  }
  .compact .filters select {
    color: var(--ink);
    font-size: 11px;
    height: 35px;
    padding-left: 10px;
  }
  .compact .filters .search {
    height: 39px;
    min-width: 0;
  }
  .search svg {
    stroke: var(--accent);
    width: 16px;
    height: 16px;
  }
  .search input {
    font-size: 12px;
    min-width: 0;
  }
  .search input::placeholder {
    color: var(--muted);
    opacity: 1;
  }
  .search:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
  }
  .search input:focus-visible {
    outline: none;
  }
  .active-filters {
    font-size: 10px;
    gap: 8px;
  }
  .filter-pill {
    background: var(--lime);
    border: 1px solid var(--line);
    padding: 4px 8px;
    border-radius: 3px;
    color: var(--ink);
  }
  .primary,
  [data-theme='dark'] .primary {
    background: var(--green);
    border: 1px solid var(--green);
    color: var(--paper);
    border-radius: 4px;
    font-weight: 500;
    padding: 10px 15px;
    font-size: 12px;
    line-height: 1.4;
  }
  .primary:hover,
  [data-theme='dark'] .primary:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-accent);
  }
  .secondary,
  [data-theme='dark'] .secondary {
    background: var(--white);
    border-color: var(--line);
    border-radius: 4px;
    color: var(--ink);
    font-size: 12px;
    padding: 10px 13px;
    line-height: 1.4;
  }
  .secondary:hover,
  [data-theme='dark'] .secondary:hover {
    background: var(--surface);
    border-color: var(--accent-soft);
    color: var(--ink);
  }
  .text-button {
    font-size: 11px;
    color: var(--green);
  }
  form input,
  form textarea,
  form select,
  .edition-picker select,
  .notebook-filters input,
  .notebook-filters select,
  .maps-toolbar select,
  .patterns-toolbar select,
  .studies-tools select,
  .catalog-analysis input,
  .catalog-analysis textarea,
  .catalog-analysis select {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 4px;
    color: var(--ink);
  }
  form label,
  .edition-picker label,
  .patterns-toolbar label {
    font-size: 11px;
    color: var(--muted);
  }
  form input,
  form textarea,
  form select {
    line-height: 1.5;
  }

  /* Uniform display plinths let the individual publications supply the color. */
  .compact .shelf-grid:not(.list) {
    gap: 23px 18px;
  }
  .catalog-card {
    color: var(--ink);
    display: flex;
    flex-direction: column;
  }
  .catalog-card .cover-button {
    flex-shrink: 0;
  }
  .catalog-card .cover,
  .catalog-card:nth-child(3n) .cover,
  .catalog-card:nth-child(3n + 2) .cover {
    background: var(--cover-ground);
    border: 1px solid var(--cover-edge);
    border-radius: 3px;
    box-shadow: none;
  }
  .compact .catalog-card .cover {
    padding: 13px;
    max-height: 210px;
    aspect-ratio: 1;
  }
  .cover img {
    filter: drop-shadow(0 5px 5px #0002);
    transition:
      transform 0.2s ease,
      filter 0.2s ease;
  }
  [data-theme='dark'] .cover img {
    filter: drop-shadow(0 6px 7px #0005);
  }
  .cover-button:hover .cover {
    border-color: var(--accent-soft);
  }
  .cover-button:hover img {
    transform: translateY(-3px);
    filter: drop-shadow(0 7px 7px #0003);
  }
  .cover-button:focus-visible {
    outline-offset: 5px;
    border-radius: 3px;
  }
  .cover-placeholder {
    background: var(--white);
    border-color: var(--line);
    color: var(--ink);
    box-shadow: 0 3px 5px #0001;
  }
  .compact .cover-placeholder .cover-name {
    font: 500 26px/1 var(--display);
    letter-spacing: -0.5px;
  }
  .cover-placeholder small {
    color: var(--muted);
    letter-spacing: 1.5px;
  }
  .cover-placeholder .cover-art {
    stroke: var(--accent-soft);
  }
  .cover-placeholder .cover-edition {
    border-color: var(--line);
    color: var(--muted);
  }
  .compact .card-meta {
    font-size: 9px;
    letter-spacing: 0.65px;
    margin: 10px 0 6px;
    line-height: 1.35;
    align-items: baseline;
    gap: 9px;
  }
  .card-meta > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
  }
  .card-meta > span:first-child {
    flex: 0 1 auto;
    max-width: 60%;
  }
  .card-meta > span:last-child {
    flex: 0 1 auto;
    max-width: 70%;
    margin-left: auto;
    text-align: right;
  }
  .card-meta .badge {
    background: var(--lime);
    border: 1px solid var(--line);
    border-radius: 2px;
    font-size: 8px;
    padding: 2px 4px;
    letter-spacing: 0.35px;
    color: var(--green);
  }
  .compact .card-title {
    font: 600 22px/1.08 var(--display);
    letter-spacing: -0.25px;
    margin-bottom: 5px;
    color: var(--ink);
    align-self: flex-start;
  }
  .compact .card-title:hover {
    color: var(--accent);
  }
  .compact .card-subtitle {
    font-size: 11px;
    line-height: 1.45;
    margin-bottom: 8px;
    color: var(--muted);
  }
  .compact button.edition-count {
    font: 400 10px/1.5 var(--font);
    margin-top: 4px;
    padding: 2px 0;
    color: var(--muted);
    text-decoration-color: var(--line);
  }
  .compact button.edition-count:hover {
    text-decoration-color: currentColor;
    color: var(--ink);
  }
  .compact .card-bottom {
    border-color: var(--line);
    padding-top: 6px;
    min-height: 32px;
    gap: 6px;
    margin-top: auto;
  }
  .compact button.availability,
  .web-card-action {
    font-size: 11px;
    font-weight: 500;
    line-height: 1.4;
    padding: 4px 0;
    color: var(--green);
  }
  .availability {
    font-size: 10px;
    line-height: 1.5;
    min-width: 0;
  }
  .availability.saved i {
    background: var(--accent);
    width: 4px;
    height: 4px;
    flex-shrink: 0;
  }
  .card-actions {
    gap: 2px;
    flex-shrink: 0;
  }
  .card-actions button {
    display: grid;
    place-items: center;
    min-width: 28px;
    min-height: 30px;
    padding: 4px;
    border: 1px solid transparent;
    border-radius: 3px;
    color: var(--muted);
  }
  .card-actions button:hover {
    color: var(--ink);
    background: var(--surface);
    border-color: var(--line);
  }
  .card-actions button.on {
    background: var(--lime);
    border-color: var(--line);
    color: var(--accent);
  }
  .card-actions button.on[data-favorite] svg {
    fill: var(--accent);
    stroke: var(--accent);
  }
  .compact .list .card-title {
    font-size: 21px;
  }
  .compact .list .card-meta {
    margin: 0 0 4px;
    justify-content: flex-start;
  }
  .list .card-meta > span {
    flex: none !important;
    max-width: 70%;
    text-align: left !important;
  }
  .compact .list .card-bottom {
    margin-top: 0;
  }
  .compact .list .cover {
    padding: 3px;
    aspect-ratio: 3/4;
  }
  .web-cover-label {
    color: var(--accent);
    font-size: 8px;
    letter-spacing: 1.5px;
  }
  .web-cover-date {
    color: var(--muted);
    font-size: 9px;
  }
  .web-cover .web-cover-image {
    border-color: var(--cover-edge);
    box-shadow: 0 3px 7px #0002;
    border-radius: 1px;
  }
  .web-card-state {
    font-size: 10px;
  }
  .web-capture-status {
    border-left-color: var(--accent-soft);
  }
  .empty,
  .reader-empty {
    border: 1px solid var(--line);
    background: var(--white);
    border-radius: 4px;
    color: var(--muted);
  }
  .empty h3 {
    font: 500 30px/1.1 var(--display);
  }
  .portfolio-banner,
  .notebook-intro,
  [data-theme='dark'] .notebook-intro {
    background: var(--surface);
    border-color: var(--line);
    border-left-color: var(--accent-soft);
    color: var(--ink);
  }
  footer {
    color: var(--accent);
    letter-spacing: 1.7px;
  }
  footer span {
    font-family: var(--display);
    font-size: 15px;
  }

  /* Detail windows, research and notes use the same editorial hierarchy. */
  dialog {
    border-color: var(--line);
    border-radius: 7px;
    box-shadow: 0 24px 90px -20px #15140e73;
    background: var(--paper);
  }
  dialog::backdrop,
  [data-theme='dark'] dialog::backdrop {
    background: #13160fc2;
    backdrop-filter: blur(7px);
  }
  dialog .dialog-close {
    border-radius: 50%;
    border-color: var(--line);
    background: var(--white);
    color: var(--muted);
    font-weight: 300;
  }
  dialog .dialog-close:hover {
    color: var(--ink);
    border-color: var(--accent-soft);
  }
  .detail-layout .cover {
    background: var(--cover-ground);
    border: 1px solid var(--cover-edge);
    border-radius: 3px;
    box-shadow: none;
  }
  .detail-content h2 {
    font: 500 41px/1.02 var(--display);
    letter-spacing: -0.7px;
    margin-bottom: 10px;
  }
  .detail-content h3 {
    font: 600 12px/1.4 var(--font);
    letter-spacing: 0.15px;
    color: var(--ink);
  }
  .detail-content p {
    font-size: 12px;
    line-height: 1.8;
  }
  .detail-sub {
    font-size: 12px;
    line-height: 1.55;
  }
  .metadata {
    gap: 18px;
  }
  .metadata dt {
    font-size: 9px;
    letter-spacing: 1.2px;
    color: var(--muted);
  }
  .metadata dd {
    font-size: 12px;
    line-height: 1.6;
  }
  .source-line {
    line-height: 1.75;
  }
  .edition-picker {
    margin-block: 17px 20px;
  }
  .edition-picker select {
    font-size: 12px;
    padding: 10px;
  }
  #help-content h2,
  #page-reference-dialog h2,
  #note-title,
  #storage-title,
  #section-glossary-title,
  #compare-title {
    font: 500 34px/1.08 var(--display);
    letter-spacing: -0.5px;
  }
  .topic,
  .note-card,
  .study-card,
  .study-panel,
  .pattern-card,
  .pattern-study,
  .section-card,
  .section-entry,
  .analysis-source,
  .analysis-observation,
  .pattern-count-grid > article,
  .pattern-levels > div,
  .map-diagrams section,
  .map-compare-grid > article {
    border-color: var(--line);
    background: var(--white);
    border-radius: 4px;
    box-shadow: none;
  }
  .topic h3,
  .study-card h3,
  .pattern-card h3,
  .map-title h3,
  .section-card h3,
  .analysis-review-heading h3 {
    font-family: var(--display);
    font-weight: 500;
    letter-spacing: -0.35px;
  }
  .study-card h3,
  .analysis-review-heading h3 {
    font-size: 32px;
  }
  .pattern-card h3,
  .map-title h3 {
    font-size: 30px;
  }
  .analysis-report h3 {
    font: 500 27px/1.15 var(--display);
    letter-spacing: -0.25px;
  }
  .analysis-report p {
    font-size: 13px;
    line-height: 1.85;
    max-width: 88ch;
  }
  .analysis-report .text-button {
    background: var(--lime);
    border-color: var(--line);
    color: var(--green);
    padding: 2px 5px;
    line-height: 1.4;
  }
  .note-card h3 {
    font: 600 16px/1.4 var(--font);
  }
  .note-head {
    font-size: 10px;
    color: var(--muted);
  }
  .note-body {
    font-size: 13px;
    line-height: 1.8;
  }
  .note-quote,
  .anchor-context {
    background: var(--surface);
    border-left-color: var(--accent-soft);
  }
  .map-analysis {
    border-top: 1px solid var(--accent-soft);
  }
  .map-node,
  .flow-node {
    border-color: var(--line);
    background: var(--white);
    border-radius: 3px;
  }
  .map-path,
  .map-selected,
  .map-model,
  .pattern-summary,
  .pattern-method,
  .study-question,
  .study-comparison,
  .patterns-counts,
  .pattern-route span,
  .study-route span,
  .pattern-status,
  .section-identity,
  .section-method {
    background: var(--lime);
    color: var(--ink);
    border-color: var(--line);
  }
  .patterns-principle,
  .patterns-related,
  .section-glossary-equivalents {
    border-color: var(--accent-soft);
    background: var(--surface);
    color: var(--ink);
  }
  .patterns-nav button {
    background: var(--white);
    color: var(--ink);
    border-color: var(--line);
  }
  .patterns-nav button.selected,
  [data-theme='dark'] .patterns-nav button.selected {
    background: var(--green);
    color: var(--paper);
    border-color: var(--green);
  }
  .pattern-route i,
  .map-path i {
    color: var(--accent);
  }
  .pattern-bar {
    background: var(--sand);
  }
  .pattern-bar i,
  .progress i {
    background: var(--accent-soft);
  }
  .table-wrap th {
    background: var(--surface);
    color: var(--muted);
    font-size: 9px;
    letter-spacing: 1.2px;
    border-color: var(--line);
  }
  .table-wrap td {
    border-color: var(--line);
  }
  .compare-brand {
    font: 500 26px/1.1 var(--display) !important;
    color: var(--ink) !important;
    letter-spacing: -0.3px !important;
    text-transform: none !important;
  }
  #compare-tray {
    background: var(--white);
    border-color: var(--line);
    border-radius: 5px;
    box-shadow: var(--shadow);
  }
  #toast,
  [data-theme='dark'] #toast {
    background: var(--green);
    color: var(--paper);
    border: 1px solid var(--line);
    border-radius: 4px;
    box-shadow: var(--shadow);
  }

  /* Reader chrome stays compact. The PDF canvas and selection layer are untouched. */
  .reader-pane .reader-header,
  .comparison-header,
  .website-header {
    background: var(--paper);
    border-color: var(--line);
  }
  .reader-pane .reader-header h2 {
    font: 500 12px/1.45 var(--font);
    letter-spacing: 0.05px;
    color: var(--ink);
  }
  .reader-pane .reader-header [data-close],
  .comparison-header [data-close],
  .website-header [data-close] {
    font-weight: 300;
    color: var(--muted);
    border-radius: 3px;
  }
  .reader-pane .reader-controls {
    background: var(--reader-toolbar);
    border-color: var(--line);
  }
  .reader-pane .reader-controls button,
  .reader-pane .reader-controls select,
  .reader-pane .reader-controls input,
  .reader-pane .reader-more > summary {
    background: var(--white);
    border-color: var(--line);
    border-radius: 3px;
    color: var(--ink);
    font-size: 12px;
  }
  .reader-pane .reader-controls button:hover:not(:disabled),
  .reader-pane .reader-more > summary:hover {
    border-color: var(--accent-soft);
    background: var(--surface);
    color: var(--ink);
  }
  .reader-pane .reader-mode-switch {
    background: var(--sand);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 2px;
    gap: 1px;
  }
  .reader-pane .reader-mode-switch button {
    background: transparent;
    border: 0;
    font-size: 11px;
    font-weight: 500;
    padding: 5px 9px;
    min-height: 28px;
  }
  .reader-pane .reader-controls [aria-pressed='true'],
  [data-theme='dark'] .reader-mode-switch button[aria-pressed='true'],
  [data-theme='dark'] .reader-controls .tool-active {
    background: var(--green);
    color: var(--paper);
    border-color: var(--green);
  }
  .reader-pane .reader-controls [aria-pressed='true']:hover:not(:disabled) {
    background: var(--green);
    color: var(--paper);
    border-color: var(--green);
  }
  .reader-pane .reader-icon svg {
    stroke-width: 1.5;
  }
  .reader-pane .reader-stage {
    background: var(--reader-stage);
  }
  .reader-pane .pdf-sheet {
    box-shadow: 0 4px 20px #0003;
  }
  .reader-pane .reader-more-panel {
    background: var(--paper);
    border-color: var(--line);
    border-radius: 5px;
    box-shadow: 0 8px 30px #0004;
  }
  .reader-pane .reader-tools-heading {
    font: 500 21px/1.1 var(--display);
    color: var(--ink);
  }
  .reader-pane .reader-more-panel a {
    color: var(--ink);
    background: var(--white);
    border-color: var(--line);
  }
  .reader-pane .reader-navigation,
  .reader-pane .reader-notes {
    background: var(--paper);
    border-color: var(--line);
  }
  .reader-panel-heading {
    font: 500 23px/1.1 var(--display);
    padding-bottom: 7px;
    border-bottom: 1px solid var(--line);
  }
  .reader-navigation-tabs {
    border-color: var(--line);
    gap: 2px;
  }
  .reader-navigation-tabs button {
    font-size: 11px;
    border-radius: 3px;
    color: var(--muted);
  }
  .reader-navigation-tabs button.active,
  .reader-navigation-tabs [aria-selected='true'] {
    color: var(--ink);
    background: var(--lime);
    border-color: var(--accent-soft);
  }
  .reader-pane .reader-notes-head h3,
  .reader-composer h3 {
    font: 500 25px/1.1 var(--display);
  }
  .reader-pane .reader-note {
    background: var(--white);
    border-color: var(--line);
    border-radius: 4px;
  }
  .reader-pane .reader-note h4 {
    font-weight: 500;
  }
  .reader-pane .reader-note p {
    line-height: 1.75;
  }
  .reader-pagination {
    background: var(--reader-toolbar);
    border-color: var(--line);
  }
  .reader-pagination > button {
    background: transparent;
    border-color: transparent;
    color: var(--muted);
    border-radius: 3px;
    font-size: 11px;
  }
  .reader-pagination > button:hover:not(:disabled) {
    background: var(--white);
    border-color: var(--line);
    color: var(--ink);
  }
  .reader-page-track {
    font-size: 10px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
  }
  .reader-page-track input {
    accent-color: var(--accent);
  }
  .reader-turn-zones .edge-prev svg,
  .reader-turn-zones .edge-next svg,
  .reader-turn-zones .corner-prev,
  .reader-turn-zones .corner-next {
    background: var(--paper);
    color: var(--ink);
    border-radius: 3px;
  }
  .reader-focus-actions .reader-reveal,
  .reader-focus-close {
    background: var(--paper);
    border-color: var(--line);
    color: var(--ink);
    box-shadow: 0 3px 14px #0003;
  }
  .comparison-header h2 {
    font: 500 24px/1.05 var(--display);
    letter-spacing: -0.2px;
  }
  .compare-reader-pane:first-child {
    border-right-color: var(--line);
  }
  .website-header h2 {
    font: 500 26px/1.05 var(--display);
  }
  .website-toolbar {
    background: var(--reader-toolbar);
    border-color: var(--line);
  }
  .website-toolbar button {
    background: var(--white);
    border-color: var(--line);
    color: var(--ink);
  }
  .website-toolbar button[aria-pressed='true'] {
    background: var(--green);
    color: var(--paper);
  }
  .website-stage {
    background: var(--reader-stage);
  }
}

@media screen and (min-width: 701px) and (max-width: 1000px) {
  .compact .stats {
    gap: 20px;
  }
  .compact .stat {
    display: block;
  }
  .compact .stat strong {
    font-size: 27px;
  }
  .stat span {
    display: block;
    max-width: 130px;
    margin-top: 4px;
  }
  .compact .hero h1 {
    font-size: 36px;
  }
  .compact .shelf-display {
    gap: 9px;
  }
  .shelf-display > button {
    font-size: 10px;
  }
  .compact .card-title {
    font-size: 21px;
  }
  .compact .card-meta {
    font-size: 8px;
    letter-spacing: 0.45px;
  }
}
@media screen and (max-width: 700px), screen and (max-width: 950px) and (max-height: 500px) {
  .compact .topbar {
    height: 54px;
    padding-inline: max(12px, env(safe-area-inset-left));
    gap: 8px;
  }
  .identity {
    font-size: 10px;
    letter-spacing: 1.8px;
    gap: 9px;
  }
  .identity svg {
    width: 29px;
    height: 29px;
  }
  .top-actions {
    gap: 12px;
  }
  .top-actions .theme-toggle {
    border-bottom: 0;
  }
  .top-actions .icon-btn {
    width: 30px;
    height: 30px;
  }
  .compact .tabs {
    padding-inline: 13px;
    gap: 23px;
    min-height: 0;
  }
  .compact .tabs > .tab {
    height: 43px;
    font-size: 12px;
  }
  .compact .tabs .tab-tools {
    gap: 7px;
    padding-bottom: 6px;
  }
  .nav-menu > summary {
    min-height: 36px;
    padding: 4px 8px;
    font-size: 11px;
    border-color: var(--line);
    background: var(--white);
  }
  .nav-menu .workspace-links {
    left: 12px;
    right: 12px;
  }
  .compact .sidebar {
    padding: 3px 8px;
    gap: 3px;
    scrollbar-width: none;
  }
  .compact .sidebar::-webkit-scrollbar {
    display: none;
  }
  .compact .side {
    min-height: 38px;
    margin: 0;
    font-size: 11px;
    padding: 7px 10px;
  }
  .compact main {
    padding: 13px max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  }
  .compact .hero {
    display: none;
  }
  .compact .hero h1 {
    font-size: 33px;
    line-height: 1.02;
    letter-spacing: -0.65px;
    margin-bottom: 6px;
  }
  .compact .hero .intro {
    font-size: 12px;
    line-height: 1.5;
    max-width: 38ch;
  }
  .compact .section-heading h2 {
    font-size: 27px;
  }
  .section-heading p {
    font-size: 10px;
    line-height: 1.5;
  }
  .compact #shelf-view > .section-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 8px;
    align-items: center;
  }
  #shelf-view > .section-heading > div:first-child {
    display: contents;
  }
  #shelf-title {
    grid-column: 1;
    grid-row: 1;
    margin-bottom: 0;
  }
  #result-label {
    grid-column: 1/-1;
    grid-row: 2;
    margin-top: 0;
  }
  #shelf-view > .section-heading .shelf-display {
    grid-column: 2;
    grid-row: 1;
    flex-wrap: nowrap;
  }
  .shelf-display {
    gap: 6px;
  }
  .view-toggle button {
    min-width: 36px;
    min-height: 34px;
  }
  #continue-reading {
    max-width: 122px;
    font-size: 10px;
  }
  .reading-desk {
    margin-bottom: 11px;
  }
  .reading-desk > summary {
    padding: 10px 11px;
    gap: 6px 10px;
    min-height: 42px;
  }
  .reading-desk > summary > span {
    font-size: 10px;
  }
  .shelf-instruction {
    font-size: 10px;
    line-height: 1.55;
    margin-bottom: 9px;
  }
  .compact .filters {
    gap: 8px;
  }
  .compact .filters .search {
    height: 44px;
  }
  .search input {
    font-size: 16px;
  }
  .search input::placeholder {
    font-size: 12px;
  }
  .library-filter-options > summary {
    background: var(--white);
    border-color: var(--line);
    border-radius: 4px;
    font-size: 12px;
  }
  .filter-options {
    background: var(--surface);
    border-color: var(--line);
    border-radius: 4px;
  }
  .compact .filter-options select {
    min-height: 44px;
    font-size: 12px;
  }
  .compact .shelf-grid:not(.list) {
    gap: 22px 13px;
  }
  .compact .catalog-card .cover {
    padding: 10px;
    max-height: none;
  }
  .compact .card-title {
    font-size: 23px;
    line-height: 1.05;
    margin-bottom: 5px;
  }
  .compact .card-meta {
    font-size: 8px;
    letter-spacing: 0.55px;
    margin-top: 9px;
  }
  .card-meta > span:first-child {
    flex: 0 1 auto;
  }
  .card-meta > span:last-child {
    flex: 0 1 auto;
  }
  .card-meta .badge {
    display: block;
  }
  .compact .card-subtitle {
    font-size: 11px;
    line-height: 1.45;
  }
  .compact button.edition-count {
    font-size: 10px;
    min-height: 28px;
    display: flex;
    align-items: center;
  }
  .compact .card-bottom {
    gap: 3px;
    align-items: center;
    min-height: 40px;
  }
  .card-actions {
    gap: 0;
  }
  .card-actions button {
    min-width: 30px;
    min-height: 40px;
    padding: 5px;
  }
  .card-actions .ui-icon {
    width: 16px;
    height: 16px;
  }
  .compact button.availability,
  .web-card-action {
    font-size: 10px;
    min-height: 40px;
    line-height: 1.4;
  }
  .compact .list .card-title {
    font-size: 21px;
  }
  .compact .list .cover {
    padding: 3px;
  }
  .compact .cover-placeholder .cover-name {
    font-size: 24px;
  }
  .web-cover-label {
    font-size: 8px;
  }
  .web-cover-date {
    font-size: 8px;
  }
  dialog {
    border-radius: 6px;
  }
  .detail-content h2 {
    font-size: 36px;
  }
  .detail-content p {
    font-size: 12px;
    line-height: 1.75;
  }
  .detail-buttons .primary,
  .detail-buttons .secondary {
    font-size: 11px;
    min-height: 44px;
  }
  .edition-picker select,
  form input,
  form textarea,
  form select,
  .notebook-filters input,
  .notebook-filters select,
  .catalog-analysis input,
  .catalog-analysis textarea,
  .catalog-analysis select {
    font-size: 16px;
  }
  .pattern-card h3,
  .map-title h3,
  .analysis-review-heading h3 {
    font-size: 29px;
  }
  .analysis-report h3 {
    font-size: 25px;
  }
  dialog.reader-dialog,
  dialog.pdf-compare-dialog,
  dialog.website-dialog {
    border-radius: 0;
  }
  .reader-pane .reader-mode-switch button {
    min-height: 30px;
    font-size: 11px;
    padding-inline: 8px;
  }
  .reader-pane .reader-controls input,
  .reader-pane .reader-controls select {
    font-size: 16px;
  }
  .reader-pane .reader-header h2 {
    font-size: 11px;
  }
  .reader-pane .page-control input {
    font-size: 16px;
  }
  .reader-pane .reader-more-panel .reader-edition-label select {
    font-size: 16px;
  }
  .reader-panel-heading,
  .reader-notes-head h3,
  .reader-composer h3 {
    font-size: 24px;
  }
  .reader-pagination > button {
    min-height: 36px;
    font-size: 10px;
  }
  .reader-page-track {
    font-size: 9px;
  }
  .comparison-header h2 {
    font-size: 23px;
  }
  .website-header h2 {
    font-size: 23px;
  }
  .mobile-comparison-tabs {
    background: var(--reader-toolbar);
  }
  .mobile-comparison-tabs button {
    color: var(--ink);
    border-color: var(--line);
    font-size: 12px;
  }
  .mobile-comparison-tabs button[aria-pressed='true'] {
    background: var(--lime);
  }
}
@media screen and (max-width: 370px) {
  .compact .tabs {
    gap: 20px;
  }
  .compact .card-title {
    font-size: 21px;
  }
  .compact .card-bottom {
    flex-wrap: wrap;
  }
  .card-actions {
    margin-left: auto;
  }
  .compact .hero h1 {
    font-size: 31px;
  }
  .reader-pane .reader-mode-switch button {
    padding-inline: 6px;
  }
}
@media (prefers-reduced-motion: reduce) {
  button,
  a,
  summary,
  .cover img {
    transition: none !important;
  }
}
