:root {
  --brand-yellow: #fffe31;
  --brand-yellow-deep: #f2d915;
  --ink: #24262b;
  --ink-soft: #565b66;
  --muted: #747b88;
  --line: #dfe3e8;
  --line-strong: #cdd2d9;
  --surface: #ffffff;
  --surface-subtle: #f7f8fa;
  --canvas-bg: #eceff3;
  --danger: #b42318;
  --focus: #2f6fed;
  --header-height: 64px;
  --sidebar-width: 312px;
  --toolbar-height: 58px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 2px 8px rgba(25, 29, 35, 0.08);
  --shadow-md: 0 12px 32px rgba(25, 29, 35, 0.14);
  color-scheme: light;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input { font: inherit; }

button { color: inherit; }

button,
a,
input { -webkit-tap-highlight-color: transparent; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 38%, transparent);
  outline-offset: 2px;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

[hidden] { display: none !important; }

.startup-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: #fff;
  transition: opacity 180ms ease;
}

.startup-screen.is-hiding {
  opacity: 0;
  pointer-events: none;
}

.startup-card {
  width: min(360px, calc(100vw - 40px));
  text-align: center;
}

.startup-card img {
  display: block;
  width: min(250px, 70vw);
  height: 90px;
  margin: 0 auto 22px;
  object-fit: contain;
  object-position: center;
  border-radius: 12px;
}

.startup-card p {
  margin: 14px 0 0;
  color: var(--ink-soft);
  font-weight: 650;
}

.startup-spinner {
  width: 34px;
  height: 34px;
  margin: auto;
  border: 3px solid #e5e7eb;
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  grid-template-rows: var(--header-height) minmax(0, 1fr);
  width: 100%;
  height: 100vh;
  height: 100dvh;
  background: var(--canvas-bg);
}

.app-shell[data-mode="landing"] {
  grid-template-columns: 0 minmax(0, 1fr);
}

.app-header {
  position: relative;
  z-index: 50;
  grid-column: 1 / -1;
  grid-row: 1;
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  height: var(--header-height);
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  width: 158px;
  height: 50px;
  overflow: hidden;
  border-radius: var(--radius-sm);
}

.brand img {
  width: 154px;
  height: 50px;
  object-fit: contain;
  object-position: left center;
}

.header-title-wrap {
  display: flex;
  flex-direction: column;
  min-width: 170px;
  max-width: 300px;
  line-height: 1.15;
}

.header-title-wrap strong {
  overflow: hidden;
  font-size: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-eyebrow {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.header-search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 520px;
  max-width: 720px;
  height: 42px;
  margin-left: auto;
  overflow: hidden;
  background: var(--surface-subtle);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
}

.header-search > svg {
  margin-left: 12px;
  color: var(--muted);
}

.header-search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0 10px;
  background: transparent;
  border: 0;
  outline: 0;
}

.header-search:focus-within {
  border-color: #98a2b3;
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.10);
}

.search-submit {
  align-self: stretch;
  min-width: 78px;
  padding: 0 16px;
  background: var(--brand-yellow);
  border: 0;
  border-left: 1px solid var(--line-strong);
  cursor: pointer;
  font-weight: 750;
}

.search-submit:hover { background: var(--brand-yellow-deep); }

.header-actions {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.icon-button,
.text-button,
.chip-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.icon-button {
  width: 38px;
  padding: 0;
}

.icon-button.compact {
  width: 32px;
  height: 32px;
}

.icon-button.compact svg { width: 17px; height: 17px; }

.text-button { padding: 0 12px; font-weight: 680; }

.icon-button:hover:not(:disabled),
.text-button:hover:not(:disabled),
.chip-button:hover:not(:disabled) {
  background: #f1f3f5;
  border-color: var(--line-strong);
}

.icon-button:active:not(:disabled),
.text-button:active:not(:disabled),
.chip-button:active:not(:disabled) { transform: translateY(1px); }

.icon-button:disabled,
.text-button:disabled,
.chip-button:disabled,
.search-submit:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.menu-popover {
  position: absolute;
  top: calc(100% - 4px);
  right: 14px;
  z-index: 80;
  min-width: 190px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
}

.menu-popover button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 42px;
  padding: 0 11px;
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}

.menu-popover button:hover { background: var(--surface-subtle); }

.load-progress {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 3px;
  overflow: hidden;
  background: rgba(255, 254, 49, 0.32);
}

.load-progress span {
  display: block;
  width: 30%;
  height: 100%;
  background: var(--brand-yellow-deep);
  transform-origin: left;
  animation: progress-indeterminate 1.2s ease-in-out infinite;
}

.load-progress.has-value span { animation: none; }

@keyframes progress-indeterminate {
  0% { transform: translateX(-120%) scaleX(0.7); }
  50% { transform: translateX(160%) scaleX(1.2); }
  100% { transform: translateX(360%) scaleX(0.7); }
}

.sidebar {
  position: relative;
  z-index: 20;
  grid-column: 1;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.app-shell[data-mode="landing"] .sidebar { display: none; }

.app-shell[data-mode="landing"] .header-search,
.app-shell[data-mode="landing"] .header-actions,
.app-shell[data-mode="landing"] .mobile-page-indicator,
.app-shell[data-mode="landing"] #hamburger { display: none; }

.sidebar-heading {
  flex: 0 0 auto;
  padding: 16px 16px 12px;
}

.sidebar-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sidebar-topline .icon-button { flex: 0 0 auto; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  margin: -3px 0 10px;
  padding: 0 8px 0 4px;
  color: var(--ink-soft);
  background: transparent;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 680;
}

.back-link:hover { background: var(--surface-subtle); color: var(--ink); }
.back-link svg { width: 18px; height: 18px; }

.sidebar-heading h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.sidebar-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.sidebar-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  flex: 0 0 auto;
  margin: 0 12px 12px;
  padding: 4px;
  background: #f0f2f4;
  border-radius: 10px;
}

.sidebar-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 10px;
  color: var(--ink-soft);
  background: transparent;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 700;
}

.sidebar-tab.active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(25, 29, 35, 0.12);
}

.sidebar-panel {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  scrollbar-gutter: stable;
}

.outline-filter-wrap {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  height: 42px;
  margin: 0 12px 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
}

.outline-filter-wrap svg {
  width: 17px;
  height: 17px;
  margin-left: 10px;
  color: var(--muted);
}

.outline-filter-wrap input {
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0 10px;
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 14px;
}

.outline-tree,
.outline-tree ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.outline-tree { padding: 0 8px 22px; }
.outline-children { margin-left: 18px !important; border-left: 1px solid var(--line); }

.outline-node { margin: 2px 0; }

.outline-row {
  display: flex;
  align-items: stretch;
  gap: 2px;
  min-width: 0;
}

.outline-toggle,
.outline-link {
  min-height: 38px;
  color: var(--ink-soft);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.outline-toggle {
  flex: 0 0 30px;
  width: 30px;
  padding: 0;
}

.outline-toggle svg {
  width: 15px;
  height: 15px;
  transition: transform 150ms ease;
}

.outline-node.expanded > .outline-row .outline-toggle svg { transform: rotate(90deg); }

.outline-link {
  flex: 1;
  min-width: 0;
  padding: 7px 9px;
  overflow: hidden;
  font-size: 14px;
  font-weight: 620;
  line-height: 1.3;
  text-align: left;
  text-overflow: ellipsis;
}

.outline-toggle:hover,
.outline-link:hover { color: var(--ink); background: var(--surface-subtle); }

.outline-link.active {
  color: var(--ink);
  background: color-mix(in srgb, var(--brand-yellow) 72%, white);
  font-weight: 760;
}

.outline-children[hidden] { display: none; }

.outline-loading,
.outline-empty {
  margin: 20px 16px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.thumbnail-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  min-height: 100%;
  padding: 4px 12px 24px;
}

.thumbnail-item {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
  padding: 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
}

.thumbnail-item:hover { background: var(--surface-subtle); }
.thumbnail-item.active { background: color-mix(in srgb, var(--brand-yellow) 30%, white); border-color: var(--brand-yellow-deep); }

.thumbnail-frame {
  display: grid;
  place-items: center;
  aspect-ratio: 0.77;
  overflow: hidden;
  background: #eef0f3;
  border: 1px solid var(--line-strong);
  box-shadow: 0 1px 4px rgba(25, 29, 35, 0.08);
}

.thumbnail-frame canvas { display: block; max-width: 100%; max-height: 100%; }
.thumbnail-placeholder { width: 55%; height: 9px; background: #d9dde3; border-radius: 999px; }
.thumbnail-label { color: var(--ink-soft); font-size: 12px; font-weight: 700; text-align: center; }

.main {
  position: relative;
  z-index: 1;
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.app-shell[data-mode="landing"] .main { grid-column: 2; }

.landing-view {
  height: 100%;
  overflow: auto;
  padding: 44px clamp(22px, 4vw, 64px) 64px;
  background: linear-gradient(180deg, #f7f8fa 0%, #eceff3 100%);
}

.landing-hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 30px;
  max-width: 1420px;
  margin: 0 auto 30px;
}

.section-kicker {
  display: block;
  margin-bottom: 8px;
  color: #555b65;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.landing-hero h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(32px, 4vw, 52px);
  line-height: 1.04;
  letter-spacing: -0.035em;
}

.landing-hero p {
  max-width: 690px;
  margin: 14px 0 0;
  color: var(--ink-soft);
  font-size: 17px;
  line-height: 1.55;
}

.catalog-filter {
  display: flex;
  align-items: center;
  flex: 0 1 360px;
  min-width: 260px;
  height: 46px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  box-shadow: var(--shadow-sm);
}

.catalog-filter svg { margin-left: 13px; color: var(--muted); }
.catalog-filter input { flex: 1; min-width: 0; height: 100%; padding: 0 12px; border: 0; outline: 0; background: transparent; }

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 22px;
  max-width: 1420px;
  margin: 0 auto;
}

.catalog-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(25, 29, 35, 0.06);
  cursor: pointer;
  text-align: left;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.catalog-card:hover {
  transform: translateY(-3px);
  border-color: #b7bdc6;
  box-shadow: 0 14px 28px rgba(25, 29, 35, 0.12);
}

.catalog-cover-wrap {
  position: relative;
  aspect-ratio: 0.7725;
  overflow: hidden;
  background: var(--brand-yellow);
  border-bottom: 1px solid var(--line);
}

.catalog-cover-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 220ms ease;
}

.catalog-card:hover .catalog-cover-wrap img { transform: scale(1.018); }

.catalog-card-copy { display: flex; flex: 1; flex-direction: column; padding: 16px 17px 17px; }
.catalog-card h2 { margin: 0; font-size: 18px; line-height: 1.25; }
.catalog-card p { margin: 8px 0 16px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.catalog-card-cta { display: inline-flex; align-items: center; gap: 5px; margin-top: auto; font-size: 13px; font-weight: 800; }
.catalog-card-cta svg { width: 16px; height: 16px; }

.empty-state {
  max-width: 680px;
  margin: 60px auto;
  color: var(--muted);
  text-align: center;
}

.workspace {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.workspace-toolbar {
  position: relative;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  flex: 0 0 var(--toolbar-height);
  min-width: 0;
  padding: 8px 18px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 7px rgba(25, 29, 35, 0.04);
}

.toolbar-group,
.fit-controls,
.page-jump {
  display: inline-flex;
  align-items: center;
}

.toolbar-group { gap: 6px; }

.toolbar-divider {
  width: 1px;
  height: 28px;
  background: var(--line);
}

.page-jump { gap: 7px; color: var(--ink-soft); font-size: 14px; font-weight: 720; }

#pageNumberInput {
  width: 58px;
  height: 38px;
  padding: 0 8px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  font-weight: 750;
}

#pageNumberInput:disabled { background: #f1f3f5; }

#zoomLevel {
  min-width: 54px;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 760;
  text-align: center;
}

.fit-controls {
  gap: 4px;
  padding: 3px;
  background: #f0f2f4;
  border-radius: 10px;
}

.chip-button {
  height: 34px;
  padding: 0 10px;
  background: transparent;
  border-color: transparent;
  font-size: 13px;
  font-weight: 730;
}

.chip-button svg { width: 17px; height: 17px; }
.chip-button.active { background: var(--surface); border-color: var(--line); box-shadow: 0 1px 3px rgba(25, 29, 35, 0.09); }

.viewer {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: stretch;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--canvas-bg);
  scrollbar-gutter: stable both-edges;
}

.placeholder-message {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #9aa1ac;
  pointer-events: none;
}

.placeholder-message svg { width: 54px; height: 54px; margin-bottom: 12px; stroke-width: 1.4; }
.placeholder-message p { margin: 0; font-size: 18px; font-weight: 680; }

.page-shell {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  box-sizing: border-box;
  margin: 0;
}

.page-layer {
  position: relative;
  overflow: hidden;
  background: #fff;
  border: 1px solid rgba(30, 35, 42, 0.08);
  box-shadow: 0 7px 20px rgba(25, 29, 35, 0.12);
  backface-visibility: hidden;
}

.pdf-canvas { display: block; backface-visibility: hidden; }

.highlight-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  transform-origin: top left;
}

.text-highlight {
  position: absolute;
  background: rgba(255, 235, 0, 0.44);
  border: 1px solid rgba(210, 170, 0, 0.45);
  border-radius: 3px;
}

.page-loading-overlay {
  position: fixed;
  top: calc(var(--header-height) + var(--toolbar-height) + 22px);
  left: calc(var(--sidebar-width) + (100vw - var(--sidebar-width)) / 2);
  z-index: 30;
  display: none;
  flex-direction: column;
  align-items: center;
  width: 170px;
  padding: 15px;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.96);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
}

.page-skeleton {
  position: relative;
  width: 92px;
  height: 119px;
  padding: 16px 11px;
  overflow: hidden;
  background: #f5f6f8;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.page-skeleton img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.page-skeleton span {
  display: block;
  height: 6px;
  margin-bottom: 9px;
  background: #dfe3e8;
  border-radius: 99px;
  animation: skeleton-pulse 1.1s ease-in-out infinite alternate;
}

.page-skeleton span:nth-child(3) { width: 82%; }
.page-skeleton span:nth-child(4) { width: 68%; }
.page-skeleton span:nth-child(5) { width: 90%; }

@keyframes skeleton-pulse { from { opacity: 0.55; } to { opacity: 1; } }

.loading-text { margin: 10px 0 0; color: var(--ink-soft); font-size: 13px; font-weight: 730; }

.search-results-popover {
  position: fixed;
  top: calc(var(--header-height) - 4px);
  right: 150px;
  z-index: 70;
  width: min(440px, calc(100vw - 30px));
  max-height: min(560px, calc(100dvh - var(--header-height) - 20px));
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 13px;
  box-shadow: var(--shadow-md);
}

.search-results-header,
.mobile-search-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
}

.search-results-header > div,
.mobile-search-summary > div { display: flex; gap: 4px; }

.search-results-list {
  max-height: 480px;
  overflow: auto;
  padding: 6px;
}

.search-result-item {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  width: 100%;
  min-height: 58px;
  padding: 9px 10px;
  background: transparent;
  border: 0;
  border-radius: 9px;
  cursor: pointer;
  text-align: left;
}

.search-result-item:hover { background: var(--surface-subtle); }
.search-result-item.active { background: color-mix(in srgb, var(--brand-yellow) 38%, white); }
.search-result-page { flex: 0 0 auto; min-width: 50px; color: var(--muted); font-size: 12px; font-weight: 800; }
.search-result-copy { min-width: 0; }
.search-result-copy strong { display: block; overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.search-result-copy span { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.35; }

.search-empty { padding: 24px 18px; color: var(--muted); text-align: center; }

.mobile-only,
.mobile-page-indicator,
.mobile-toolbar,
.mobile-sheet,
.mobile-backdrop { display: none; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 150;
  max-width: min(420px, calc(100vw - 30px));
  padding: 10px 14px;
  color: #fff;
  background: rgba(32, 35, 40, 0.96);
  border-radius: 9px;
  box-shadow: var(--shadow-md);
  transform: translateX(-50%);
  font-size: 14px;
  font-weight: 650;
  text-align: center;
}

@media (max-width: 1180px) {
  .header-title-wrap { min-width: 140px; max-width: 220px; }
  .desktop-action span { display: none; }
  .desktop-action { width: 38px; padding: 0; }
  .header-search { flex-basis: 360px; }
}

@media (max-width: 900px) {
  :root {
    --header-height: 56px;
    --toolbar-height: 0px;
    --sidebar-width: 100vw;
  }

  body { overflow: hidden; }

  .app-shell,
  .app-shell[data-mode="landing"] {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--header-height) minmax(0, 1fr);
  }

  .app-header {
    grid-column: 1;
    padding: 0 10px;
    gap: 9px;
  }

  .mobile-only { display: inline-flex; }

  .brand {
    width: 92px;
    height: 44px;
  }

  .brand img {
    width: 92px;
    height: 42px;
    object-fit: contain;
    object-position: left center;
  }

  .header-title-wrap {
    flex: 1;
    min-width: 0;
    max-width: none;
  }

  .header-title-wrap strong { font-size: 15px; }
  .header-eyebrow { font-size: 9px; }
  .desktop-search,
  .desktop-action { display: none; }
  .mobile-page-indicator { display: inline; flex: 0 0 auto; color: var(--ink-soft); font-size: 12px; font-weight: 750; white-space: nowrap; }
  .header-actions { margin-left: 0; }

  .sidebar {
    position: fixed;
    inset: var(--header-height) 0 0;
    z-index: 120;
    display: flex !important;
    width: 100%;
    max-height: calc(100dvh - var(--header-height));
    border: 0;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -12px 40px rgba(25, 29, 35, 0.2);
    transform: translateY(105%);
    transition: transform 220ms cubic-bezier(.2,.8,.2,1);
  }

  .sidebar::before,
  .mobile-sheet .sheet-handle {
    content: "";
    display: block;
    flex: 0 0 auto;
    width: 42px;
    height: 4px;
    margin: 8px auto 0;
    background: #c8cdd4;
    border-radius: 99px;
  }

  .sidebar.active { transform: translateY(0); }

  .sidebar-heading { padding-top: 12px; }
  .thumbnail-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  .main,
  .app-shell[data-mode="landing"] .main {
    grid-column: 1;
    grid-row: 2;
  }

  .landing-view { padding: 26px 16px 90px; }
  .landing-hero { display: block; margin-bottom: 22px; }
  .landing-hero h1 { font-size: clamp(30px, 9vw, 42px); }
  .landing-hero p { font-size: 15px; }
  .catalog-filter { width: 100%; min-width: 0; margin-top: 22px; }
  .catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
  .catalog-card-copy { padding: 12px; }
  .catalog-card h2 { font-size: 15px; }
  .catalog-card p { display: none; }
  .catalog-card-cta { margin-top: 8px; font-size: 12px; }

  .workspace-toolbar { display: none; }
  .viewer { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  .page-layer { box-shadow: 0 4px 14px rgba(25,29,35,.10); }

  .page-loading-overlay {
    position: fixed;
    top: calc(var(--header-height) + 16px);
    left: 50%;
    width: 150px;
  }

  .search-results-popover { display: none !important; }

  .mobile-backdrop {
    position: fixed;
    inset: var(--header-height) 0 0;
    z-index: 110;
    display: block;
    background: rgba(18, 21, 26, 0.42);
    opacity: 0;
    transition: opacity 180ms ease;
  }

  .mobile-backdrop.active { opacity: 1; }

  .mobile-sheet {
    position: fixed;
    inset: auto 0 0;
    z-index: 125;
    display: flex;
    flex-direction: column;
    max-height: calc(100dvh - var(--header-height) - 8px);
    min-height: min(610px, calc(100dvh - var(--header-height) - 8px));
    overflow: hidden;
    background: var(--surface);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -12px 40px rgba(25, 29, 35, 0.22);
    transform: translateY(105%);
    transition: transform 220ms cubic-bezier(.2,.8,.2,1);
  }

  .mobile-sheet.active { transform: translateY(0); }

  .sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px 10px;
  }

  .sheet-header h2 { margin: 0; font-size: 20px; }

  .mobile-search-form {
    display: flex;
    align-items: center;
    height: 46px;
    margin: 0 14px 10px;
    overflow: hidden;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
  }

  .mobile-search-form > svg { margin-left: 11px; color: var(--muted); }
  .mobile-search-form input { flex: 1; min-width: 0; height: 100%; padding: 0 9px; border: 0; outline: 0; }
  .mobile-search-form > button { align-self: stretch; padding: 0 14px; background: var(--brand-yellow); border: 0; border-left: 1px solid var(--line); font-weight: 760; }
  .mobile-results { flex: 1; max-height: none; }

  .mobile-toolbar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 60;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    min-height: calc(62px + env(safe-area-inset-bottom));
    padding: 5px 6px env(safe-area-inset-bottom);
    background: rgba(255,255,255,0.97);
    border-top: 1px solid var(--line);
    box-shadow: 0 -4px 18px rgba(25, 29, 35, 0.10);
  }

  .mobile-toolbar button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    color: var(--ink-soft);
    background: transparent;
    border: 0;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 700;
  }

  .mobile-toolbar button:hover:not(:disabled),
  .mobile-toolbar button:active:not(:disabled) { background: var(--surface-subtle); color: var(--ink); }
  .mobile-toolbar button:disabled { opacity: 0.4; }
  .mobile-toolbar svg { width: 21px; height: 21px; }

  .menu-popover { top: 50px; right: 8px; }
  .toast { bottom: calc(75px + env(safe-area-inset-bottom)); }
}

@media (max-width: 520px) {
  .brand { display: none; }
  .catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .catalog-card { border-radius: 12px; }
  .catalog-card-copy { padding: 10px; }
  .catalog-card h2 { font-size: 14px; }
  .catalog-card-cta span { display: none; }
  .thumbnail-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
