:root {
  color-scheme: light;
  --brand: #f04438;
  --brand-strong: #d92d20;
  --brand-soft: #fff0ee;
  --navy: #17324d;
  --navy-2: #29465f;
  --ink: #172033;
  --muted: #64748b;
  --subtle: #8b99aa;
  --line: #dce3eb;
  --line-strong: #bec9d5;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef3f8;
  --stage: #e8eef5;
  --shadow: 0 16px 38px rgba(28, 45, 68, .14);
  --toolbar-height: 56px;
  --sidebar-width: 292px;
  --comments-width: 344px;
  --radius: 9px;
  --active-color: #ffd75e;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e8edf4;
  --muted: #a8b4c4;
  --subtle: #7f8da0;
  --line: #34465a;
  --line-strong: #4e6175;
  --surface: #172333;
  --surface-2: #1c2a3b;
  --surface-3: #233448;
  --stage: #0e1724;
  --navy: #eff5fb;
  --navy-2: #c5d2df;
  --brand-soft: #3b2327;
  --shadow: 0 20px 45px rgba(0, 0, 0, .38);
}

html[data-theme="night"] {
  color-scheme: dark;
  --ink: #edf2f7;
  --muted: #a4b1c0;
  --subtle: #778699;
  --line: #2c3b4c;
  --line-strong: #435569;
  --surface: #111b28;
  --surface-2: #152130;
  --surface-3: #1a293a;
  --stage: #080e16;
  --navy: #eff6fd;
  --navy-2: #c8d5e2;
  --brand-soft: #382126;
  --shadow: 0 20px 50px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }

html,
body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea { font: inherit; }

button,
summary,
select { -webkit-tap-highlight-color: transparent; }

button { color: inherit; }

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-sprite {
  position: fixed;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

.visually-hidden {
  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;
}

.workspace {
  display: grid;
  grid-template-rows: var(--toolbar-height) minmax(0, 1fr);
  width: 100%;
  height: 100dvh;
  min-height: 540px;
  background: var(--surface);
}

.topbar {
  position: relative;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: 0 2px 8px rgba(24, 42, 62, .04);
}

.topbar-section {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.topbar-brand-section { flex: 1 1 275px; }
.view-controls { flex: 0 0 auto; }
.annotation-controls { flex: 0 1 auto; }
.topbar-actions { flex: 1 1 260px; justify-content: flex-end; }

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--navy);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

.brand-lockup img {
  width: 27px;
  height: 27px;
  border-radius: 7px;
}

.topbar-divider {
  width: 1px;
  height: 24px;
  margin: 0 5px;
  background: var(--line);
}

.document-identity {
  display: grid;
  min-width: 0;
  line-height: 1.25;
}

.document-identity strong,
.document-identity span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-identity strong { max-width: min(25vw, 330px); color: var(--navy); font-size: 12px; font-weight: 700; }
.document-identity span { color: var(--muted); font-size: 10px; }

.icon-button,
.tool-button,
.action-button,
.color-summary,
.scope-menu > summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  min-width: 34px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--navy-2);
  cursor: pointer;
  list-style: none;
  transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}

.icon-button::-webkit-details-marker,
.tool-button::-webkit-details-marker,
.color-summary::-webkit-details-marker,
.scope-menu > summary::-webkit-details-marker { display: none; }

.icon-button:hover,
.tool-button:hover,
.action-button:hover,
.color-summary:hover,
.scope-menu > summary:hover {
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--navy);
}

.icon-button:focus-visible,
.tool-button:focus-visible,
.action-button:focus-visible,
.color-summary:focus-visible,
.scope-menu > summary:focus-visible,
.popover button:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid #5c8dff;
  outline-offset: 2px;
}

.icon-button[disabled] { opacity: .35; cursor: default; }
.icon-button[disabled]:hover { border-color: transparent; background: transparent; }
.icon-button > span { font-size: 18px; line-height: 1; }
.icon-button.small { width: 28px; height: 28px; min-width: 28px; padding: 0; }
.icon-button.small svg { width: 15px; height: 15px; }
.back-button { margin-right: -2px; }

.select-control {
  position: relative;
  display: inline-flex;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.select-control select {
  min-width: 110px;
  height: 100%;
  padding: 0 27px 0 9px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.select-control.full,
.select-control.full select { width: 100%; }

.zoom-control { border-color: transparent; background: var(--surface-2); }
.zoom-control select { min-width: 90px; }

.tool-button {
  border-color: var(--line);
  background: var(--surface);
  font-size: 11px;
  font-weight: 650;
}

.tool-button.active,
.workspace[data-tool="comment"] [data-tool-button="comment"],
.workspace[data-tool="text"] [data-tool-button="text"],
.workspace[data-tool="select"] [data-tool-button="select"] {
  border-color: color-mix(in srgb, var(--brand) 55%, var(--line));
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.split-tool { padding-right: 5px; }
.chevron { width: 13px; height: 13px; stroke-width: 2.2; }
.icon-only-tool { padding: 0; }
.toolbar-separator { width: 1px; height: 22px; margin: 0 2px; background: var(--line); }

.tool-menu,
.scope-menu { position: relative; }

.tool-menu > summary,
.scope-menu > summary { user-select: none; }

.tool-menu[open] > summary,
.scope-menu[open] > summary {
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.color-summary { padding: 0 6px; border-color: var(--line); background: var(--surface); }
.active-color {
  display: block;
  width: 20px;
  height: 20px;
  border: 1px solid rgba(23, 32, 51, .18);
  border-radius: 5px;
  background: var(--active-color);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .35);
}

.scope-menu > summary {
  min-width: 82px;
  border-color: var(--line);
  background: var(--surface);
  font-size: 10.5px;
  font-weight: 700;
}

.scope-dot { width: 7px; height: 7px; border-radius: 999px; background: #3f8f68; }

.action-button {
  border-color: var(--line);
  background: var(--surface);
  font-size: 11px;
  font-weight: 700;
}

.ai-button { border-color: #f3bbb6; background: #fff8f7; color: var(--brand-strong); }
.ai-button { white-space: nowrap; }
html[data-theme="dark"] .ai-button,
html[data-theme="night"] .ai-button { border-color: #7a3d3d; background: #392329; }

.popover {
  position: absolute;
  z-index: 100;
  top: calc(100% + 7px);
  left: 0;
  width: 240px;
  padding: 7px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--ink);
}

.popover.align-right { right: 0; left: auto; }

.popover button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 39px;
  padding: 7px 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.popover button:hover { background: var(--surface-2); }
.popover button:disabled { opacity: .48; cursor: not-allowed; }
.popover button:disabled:hover { background: transparent; }
.popover button > span:not(.markup-sample):not(.shape-sample):not(.scope-option-icon) { display: grid; flex: 1; gap: 2px; }
.popover button strong { font-size: 11.5px; font-weight: 700; }
.popover button small { color: var(--muted); font-size: 9.5px; line-height: 1.35; }
.popover button kbd,
.settings-popover kbd { margin-left: auto; color: var(--muted); font-size: 9px; }

.tool-popover button > span:nth-child(2) { grid-template-columns: 1fr auto; align-items: center; }
.tool-popover button small { justify-self: end; }

.markup-sample,
.shape-sample {
  display: grid;
  place-items: center;
  width: 26px;
  height: 24px;
  flex: 0 0 26px;
  color: var(--navy);
  font-size: 13px;
  font-weight: 700;
}

.highlight-sample { border-radius: 3px; background: rgba(255, 215, 94, .7); }
.underline-sample { text-decoration: underline 2px var(--brand); text-underline-offset: 3px; }
.strike-sample { text-decoration: line-through 2px var(--brand); }
.shape-sample.rectangle-sample { width: 18px; height: 15px; margin: 0 4px; border: 2px solid currentColor; }
.shape-sample.ellipse-sample { width: 18px; height: 15px; margin: 0 4px; border: 2px solid currentColor; border-radius: 50%; }
.arrow-sample { font-size: 21px; }
.pencil-sample { font-size: 22px; }
.menu-icon-sample { display: block; width: 20px; height: 20px; margin: 0 3px; stroke-width: 1.8; }

.color-popover { width: 230px; padding: 12px; }
.color-popover > strong { display: block; margin-bottom: 9px; font-size: 11.5px; }
.swatch-grid { display: grid; grid-template-columns: repeat(6, 28px); gap: 7px; }
.swatch-button,
.mini-swatch {
  width: 28px !important;
  height: 28px !important;
  min-height: 0 !important;
  padding: 0 !important;
  border: 1px solid rgba(23, 32, 51, .18) !important;
  border-radius: 7px !important;
  background: var(--swatch) !important;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .38);
}
.swatch-button.selected,
.mini-swatch.selected { outline: 2px solid var(--navy); outline-offset: 2px; }
.custom-color-row { display: grid; grid-template-columns: 1fr 36px auto; align-items: center; gap: 7px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10.5px; }
.custom-color-row input { width: 36px; height: 28px; padding: 2px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.custom-color-row button { width: auto; min-height: 28px; padding: 0 9px; background: var(--surface-2); font-size: 10px; }

.scope-popover { right: 0; left: auto; width: 270px; }
.scope-option-icon { font-size: 12px; }
.scope-option-icon.private { color: #3f8f68; }
.scope-option-icon.shared { color: #3c76d2; }
.scope-popover button.selected { background: var(--surface-2); }

.action-popover { width: 274px; }
.action-popover svg,
.settings-popover svg { width: 17px; height: 17px; color: var(--muted); }
.settings-popover { width: 238px; }
.mobile-menu-action { display: none !important; }
.settings-popover hr { height: 1px; margin: 7px 0; border: 0; background: var(--line); }
.menu-heading { padding: 6px 8px 7px; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.theme-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; padding: 0 5px 6px; }
.theme-options button { justify-content: center; min-height: 31px; padding: 0; border: 1px solid var(--line); background: var(--surface-2); font-size: 10px; font-weight: 650; text-align: center; }
.theme-options button.selected { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-strong); }

.workspace-body {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
}

.workspace.comments-open .workspace-body { grid-template-columns: var(--sidebar-width) minmax(0, 1fr) var(--comments-width); }
.workspace.sidebar-collapsed .workspace-body { grid-template-columns: minmax(0, 1fr); }
.workspace.sidebar-collapsed.comments-open .workspace-body { grid-template-columns: minmax(0, 1fr) var(--comments-width); }
.workspace.sidebar-collapsed .left-sidebar { display: none; }

.left-sidebar,
.comments-panel {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--surface);
}

.left-sidebar { display: grid; grid-template-rows: 44px minmax(0, 1fr); border-right: 1px solid var(--line); }

.sidebar-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 5px 8px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.sidebar-tabs button {
  display: grid;
  place-items: center;
  min-width: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--subtle);
  cursor: pointer;
}

.sidebar-tabs button:hover { color: var(--navy); }
.sidebar-tabs button[aria-selected="true"] { background: var(--surface); color: var(--brand-strong); box-shadow: 0 1px 4px rgba(31, 48, 69, .1); }
.sidebar-tabs svg { width: 16px; height: 16px; }
.sidebar-tabs span { font-size: 19px; line-height: 1; }

.sidebar-panel {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  min-height: 0;
  overflow: hidden;
}

.sidebar-panel[hidden] { display: none; }
.sidebar-panel > header,
.comments-panel > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 14px 15px 10px; }
.sidebar-panel h2,
.comments-panel h2 { margin: 2px 0 0; color: var(--navy); font-family: Inter, "Segoe UI", Arial, sans-serif; font-size: 15px; letter-spacing: -.015em; }
.sidebar-panel h2 span { display: inline-grid; place-items: center; min-width: 19px; height: 19px; margin-left: 3px; padding: 0 5px; border-radius: 99px; background: var(--surface-3); color: var(--muted); font: 700 9px Inter, sans-serif; vertical-align: 2px; }
.eyebrow { color: var(--brand-strong); font-size: 8.5px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }

.sidebar-search {
  display: grid;
  grid-template-columns: 17px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  margin: 0 12px 9px;
  padding: 0 8px;
  height: 35px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
}
.sidebar-search:focus-within { border-color: #6d95e5; box-shadow: 0 0 0 3px rgba(80, 124, 211, .12); }
.sidebar-search svg { width: 15px; height: 15px; color: var(--subtle); }
.sidebar-search input { min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 11px; }
.sidebar-search input::placeholder { color: var(--subtle); }
.sidebar-search kbd { color: var(--subtle); font-size: 8px; }
.sidebar-search.compact { margin: 0; }
.annotation-search-row { padding: 0 12px 9px; }

.panel-help { margin: 0; padding: 4px 15px 10px; color: var(--muted); font-size: 10.5px; line-height: 1.45; }
.search-results,
.annotation-list { min-height: 0; margin: 0; padding: 0 8px 12px; overflow: auto; list-style: none; scrollbar-gutter: stable; }

.search-result-button,
.annotation-card {
  display: grid;
  width: 100%;
  margin: 0 0 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.search-result-button:hover,
.annotation-card:hover { border-color: var(--line-strong); background: var(--surface-2); }
.search-result-button strong { color: var(--brand-strong); font-size: 9px; text-transform: uppercase; }
.search-result-button span { margin-top: 4px; color: var(--muted); font-size: 10.5px; line-height: 1.45; }
.search-result-button mark { padding: 0 1px; background: #ffe78a; color: #172033; }

.annotation-card {
  grid-template-columns: 6px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: start;
}
.annotation-card.selected { border-color: #749ee2; background: color-mix(in srgb, #edf4ff 60%, var(--surface)); box-shadow: 0 0 0 2px rgba(88, 133, 207, .1); }
.annotation-card-color { width: 6px; min-height: 38px; border-radius: 99px; background: var(--annotation-color); }
.annotation-card-copy { min-width: 0; }
.annotation-card-copy strong { display: block; color: var(--navy); font-size: 10.5px; }
.annotation-card-copy p { display: -webkit-box; overflow: hidden; margin: 4px 0 0; color: var(--muted); font-size: 10px; line-height: 1.4; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.annotation-card-page { color: var(--subtle); font-size: 9px; font-weight: 700; }

.annotation-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; padding: 0 12px 10px; }
.annotation-filters[hidden] { display: none; }
.annotation-filters label { display: grid; gap: 4px; color: var(--muted); font-size: 8.5px; font-weight: 700; text-transform: uppercase; }
.annotation-filters select { width: 100%; height: 31px; padding: 0 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); font-size: 9.5px; text-transform: none; }

.annotation-empty,
.comments-empty {
  display: grid;
  place-content: center;
  justify-items: center;
  min-height: 0;
  padding: 30px 24px;
  color: var(--muted);
  text-align: center;
}
.annotation-empty[hidden],
.comments-empty[hidden] { display: none; }
.empty-illustration { display: grid; place-items: center; width: 50px; height: 50px; margin-bottom: 11px; border-radius: 16px; background: var(--brand-soft); color: var(--brand-strong); }
.empty-illustration svg { width: 23px; height: 23px; }
.annotation-empty strong,
.comments-empty strong { color: var(--navy); font-size: 12px; }
.annotation-empty p,
.comments-empty p { max-width: 220px; margin: 7px 0 0; font-size: 10.5px; line-height: 1.5; }

.sidebar-footer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  padding: 9px 12px 12px;
  border-top: 1px solid var(--line);
}
.sidebar-footer-actions button { height: 32px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--navy); font-size: 10px; font-weight: 700; cursor: pointer; }
.sidebar-footer-actions button:hover { background: var(--surface-2); }

.outline-list { min-height: 0; padding: 0 10px 18px; overflow: auto; }
.outline-group { display: grid; gap: 2px; margin-left: 9px; border-left: 1px solid var(--line); }
.outline-button { display: block; width: 100%; padding: 7px 8px 7px calc(8px + var(--outline-depth, 0) * 8px); overflow: hidden; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 10.5px; text-align: left; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.outline-button:hover { background: var(--surface-2); color: var(--navy); }

.thumbnail-grid { display: grid; grid-template-columns: 1fr 1fr; align-content: start; gap: 12px 9px; min-height: 0; padding: 4px 14px 20px; overflow: auto; }
.thumbnail-button { display: grid; justify-items: center; gap: 5px; padding: 5px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--muted); font-size: 9px; cursor: pointer; }
.thumbnail-button:hover { background: var(--surface-2); }
.thumbnail-button.active { border-color: #7b9fd5; background: #edf4ff; color: #365e95; }
.thumbnail-button canvas { display: block; max-width: 100%; height: auto; border: 1px solid var(--line); background: white; box-shadow: 0 3px 9px rgba(34, 54, 76, .11); }

.document-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background-color: var(--stage);
  background-image: radial-gradient(circle at 1px 1px, rgba(88, 111, 137, .11) 1px, transparent 0);
  background-size: 22px 22px;
}

.empty-workspace,
.loading-state {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 40px;
  text-align: center;
}
.empty-workspace[hidden],
.loading-state[hidden] { display: none; }
.empty-brand { position: relative; display: grid; place-items: center; width: 70px; height: 70px; margin-bottom: 18px; border-radius: 22px; background: var(--surface); box-shadow: var(--shadow); }
.empty-brand::after { content: ""; position: absolute; inset: 7px; border: 1px solid var(--line); border-radius: 16px; pointer-events: none; }
.empty-brand img { width: 46px; height: 46px; border-radius: 12px; }
.empty-workspace h1 { max-width: 680px; margin: 9px 0 10px; color: var(--navy); font-family: Inter, "Segoe UI", Arial, sans-serif; font-size: clamp(28px, 4vw, 45px); letter-spacing: -.045em; line-height: 1.02; }
.empty-workspace > p { max-width: 570px; margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.6; }
.empty-actions { display: flex; align-items: center; gap: 12px; margin-top: 22px; color: var(--subtle); font-size: 10.5px; }
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--brand-strong) !important;
  border-radius: 7px;
  background: var(--brand) !important;
  color: #fff !important;
  font-weight: 750;
  box-shadow: 0 4px 11px rgba(217, 45, 32, .18);
  cursor: pointer;
}
.primary-button:hover { background: var(--brand-strong) !important; }
.feature-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; margin-top: 24px; }
.feature-chips span { padding: 6px 9px; border: 1px solid color-mix(in srgb, var(--line) 78%, transparent); border-radius: 99px; background: color-mix(in srgb, var(--surface) 86%, transparent); color: var(--muted); font-size: 9.5px; font-weight: 650; }

.loading-state { background: color-mix(in srgb, var(--stage) 88%, transparent); backdrop-filter: blur(3px); }
.loading-state strong { color: var(--navy); font-size: 15px; }
.loading-state p { margin: 7px 0 0; color: var(--muted); }
.loading-spinner { width: 34px; height: 34px; margin-bottom: 13px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.pdf-scroll { position: absolute; inset: 0; overflow: auto; overscroll-behavior: contain; scroll-behavior: smooth; scrollbar-gutter: stable; }
.pdf-scroll[hidden] { display: none; }
.pdf-pages { display: grid; justify-items: center; gap: 22px; min-width: max-content; padding: 18px 28px 72px; }
.page-shell {
  position: relative;
  flex: none;
  overflow: hidden;
  background: white;
  box-shadow: 0 5px 18px rgba(29, 43, 62, .18), 0 0 0 1px rgba(64, 80, 99, .12);
  transform-origin: center;
}
.page-shell.loading::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, #f7f8fa 20%, #edf1f5 36%, #f7f8fa 52%); background-size: 250% 100%; animation: shimmer 1.35s infinite linear; }
@keyframes shimmer { to { background-position-x: -250%; } }
.page-shell canvas { display: block; width: 100%; height: 100%; }
html[data-theme="night"] .page-shell .pdf-canvas { filter: invert(.92) hue-rotate(180deg) contrast(.92) brightness(.85); }
html[data-theme="night"] .page-shell { background: #101418; box-shadow: 0 6px 22px rgba(0, 0, 0, .58), 0 0 0 1px #364353; }

.textLayer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  opacity: 1;
  line-height: 1;
  text-size-adjust: none;
  forced-color-adjust: none;
  transform-origin: 0 0;
  z-index: 2;
  --min-font-size: 1;
  --text-scale-factor: calc(var(--total-scale-factor, var(--scale-factor, 1)) * var(--min-font-size));
  --min-font-size-inv: calc(1 / var(--min-font-size));
}
.textLayer :is(span, br) { position: absolute; color: transparent; white-space: pre; cursor: text; transform-origin: 0% 0%; -webkit-user-select: text; user-select: text; }
.textLayer > :not(.markedContent),
.textLayer .markedContent span:not(.markedContent) {
  --font-height: 0;
  --scale-x: 1;
  --rotate: 0deg;
  z-index: 1;
  font-size: calc(var(--text-scale-factor) * var(--font-height));
  transform: rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv));
}
.textLayer .markedContent { display: contents; }
.textLayer ::selection { background: rgba(67, 117, 203, .34); }
.workspace:not([data-tool="select"]):not([data-tool="highlight"]):not([data-tool="underline"]):not([data-tool="strikeout"]) .textLayer { pointer-events: none; }

.annotation-svg,
.annotation-html-layer,
.draw-capture-layer { position: absolute; inset: 0; width: 100%; height: 100%; }
.annotation-svg { z-index: 3; overflow: visible; pointer-events: none; }
.annotation-html-layer { z-index: 4; pointer-events: none; }
.draw-capture-layer { z-index: 5; pointer-events: none; touch-action: none; }
.workspace[data-tool="comment"] .draw-capture-layer,
.workspace[data-tool="rectangle"] .draw-capture-layer,
.workspace[data-tool="ellipse"] .draw-capture-layer,
.workspace[data-tool="arrow"] .draw-capture-layer,
.workspace[data-tool="pencil"] .draw-capture-layer,
.workspace[data-tool="text"] .draw-capture-layer { pointer-events: auto; cursor: crosshair; }

.annotation-node { pointer-events: stroke; cursor: pointer; }
.annotation-node.fill-target { pointer-events: all; }
.annotation-svg g.selected .annotation-node { cursor: move; }
.annotation-node.selected { filter: drop-shadow(0 0 2px #356bd6); }
.annotation-selection-ring { fill: none; stroke: #3c74d4; stroke-width: 2; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; pointer-events: none; }
.comment-pin { pointer-events: all; cursor: pointer; }
.comment-pin circle { stroke: white; stroke-width: 2; vector-effect: non-scaling-stroke; }
.comment-pin text { fill: #172033; font: 700 9px Inter, sans-serif; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.text-annotation {
  position: absolute;
  min-width: 48px;
  min-height: 22px;
  padding: 4px 5px;
  overflow: hidden;
  border: 1px dashed transparent;
  background: rgba(255, 255, 255, .15);
  color: var(--annotation-color);
  line-height: 1.28;
  white-space: pre-wrap;
  pointer-events: auto;
  cursor: pointer;
}
.text-annotation:hover,
.text-annotation.selected { border-color: #3c74d4; background: rgba(255, 255, 255, .72); }

.page-indicator {
  position: absolute;
  z-index: 8;
  right: 18px;
  bottom: 16px;
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 62px;
  height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: 0 5px 16px rgba(28, 45, 68, .14);
  color: var(--navy);
  font-size: 10.5px;
  font-weight: 700;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.drop-overlay { position: absolute; z-index: 30; inset: 12px; display: grid; place-content: center; justify-items: center; border: 2px dashed #5a84ca; border-radius: 16px; background: rgba(235, 243, 255, .93); color: #315e9c; text-align: center; backdrop-filter: blur(4px); }
.drop-overlay[hidden] { display: none; }
.drop-overlay svg { width: 42px; height: 42px; margin-bottom: 12px; }
.drop-overlay strong { font-size: 17px; }
.drop-overlay span { margin-top: 5px; color: #5d7595; }

.comments-panel { display: grid; grid-template-rows: auto minmax(0, 1fr); border-left: 1px solid var(--line); }
.comments-panel[hidden] { display: none; }
.comments-panel > header { border-bottom: 1px solid var(--line); }
.annotation-editor { min-height: 0; padding: 14px; overflow: auto; }
.annotation-editor[hidden] { display: none; }
.annotation-editor-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.annotation-kind { padding: 5px 8px; border-radius: 6px; background: var(--brand-soft); color: var(--brand-strong); font-size: 9px; font-weight: 800; text-transform: uppercase; }
.annotation-page { color: var(--muted); font-size: 9px; font-weight: 700; }
.annotation-editor blockquote { margin: 13px 0; padding: 9px 11px; border-left: 3px solid var(--active-color); background: var(--surface-2); color: var(--muted); font-size: 10.5px; line-height: 1.5; }
.annotation-editor label { display: grid; gap: 6px; margin-top: 13px; color: var(--muted); font-size: 9px; font-weight: 750; letter-spacing: .03em; text-transform: uppercase; }
.annotation-editor textarea,
.ai-card textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 11px;
  line-height: 1.5;
  text-transform: none;
}
.annotation-editor textarea { padding: 9px; }
.editor-color-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 13px; color: var(--muted); font-size: 9px; font-weight: 750; text-transform: uppercase; }
.mini-swatches { display: flex; gap: 7px; }
.mini-swatch { width: 22px !important; height: 22px !important; }
.editor-meta { display: flex; justify-content: space-between; margin-top: 14px; padding-top: 11px; border-top: 1px solid var(--line); color: var(--subtle); font-size: 9px; }
.reply-list { display: grid; gap: 7px; margin-top: 10px; }
.reply-card { padding: 9px; border-radius: 8px; background: var(--surface-2); }
.reply-card strong { color: var(--navy); font-size: 9.5px; }
.reply-card p { margin: 4px 0 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
.editor-actions { display: flex; align-items: center; justify-content: flex-end; gap: 7px; margin-top: 13px; }
.editor-actions button { min-height: 32px; padding: 0 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); font-size: 9.5px; font-weight: 700; cursor: pointer; }
.editor-actions .danger-text { display: inline-flex; align-items: center; gap: 5px; margin-right: auto; border-color: transparent; color: #d92d20; }
.editor-actions svg { width: 14px; height: 14px; }

.toast {
  position: fixed;
  z-index: 300;
  left: 50%;
  bottom: 24px;
  max-width: min(520px, calc(100vw - 32px));
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: #172033;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .28);
  color: white;
  font-size: 11px;
  line-height: 1.45;
  opacity: 0;
  transform: translate(-50%, 16px);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #8f1912; }

.modal {
  width: min(760px, calc(100vw - 28px));
  max-height: calc(100dvh - 36px);
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 13px;
  background: transparent;
  color: var(--ink);
}
.modal::backdrop { background: rgba(15, 27, 42, .54); backdrop-filter: blur(4px); }
.modal-card { display: grid; max-height: calc(100dvh - 36px); margin: 0; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 13px; background: var(--surface); box-shadow: 0 25px 70px rgba(11, 22, 36, .32); }
.modal-card > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 20px 22px 16px; border-bottom: 1px solid var(--line); }
.modal-card > header h2 { margin: 3px 0 0; color: var(--navy); font-family: Inter, "Segoe UI", Arial, sans-serif; font-size: 20px; letter-spacing: -.025em; }
.modal-card > header p { max-width: 540px; margin: 6px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.modal-card > footer { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-height: 58px; padding: 10px 22px; border-top: 1px solid var(--line); background: var(--surface-2); }
.modal-card > footer > span { margin-right: auto; color: var(--muted); font-size: 10px; }
.modal-card > footer button { min-height: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--ink); font-size: 10.5px; font-weight: 700; cursor: pointer; }

.export-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; padding: 18px 22px; overflow: auto; }
.export-grid label { cursor: pointer; }
.export-grid input { position: absolute; opacity: 0; pointer-events: none; }
.export-grid span { display: grid; gap: 4px; min-height: 70px; padding: 14px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.export-grid label:hover span { border-color: var(--line-strong); background: var(--surface-2); }
.export-grid input:checked + span { border-color: #5c84ca; background: #eef5ff; box-shadow: inset 0 0 0 1px #5c84ca; }
html[data-theme="dark"] .export-grid input:checked + span,
html[data-theme="night"] .export-grid input:checked + span { background: #243750; }
.export-grid strong { color: var(--navy); font-size: 12px; }
.export-grid small { color: var(--muted); font-size: 10px; line-height: 1.4; }

.ai-card { width: min(860px, calc(100vw - 28px)); }
.ai-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: 0; overflow: auto; }
.ai-layout > section { min-width: 0; padding: 18px 20px; }
.ai-layout > section + section { border-left: 1px solid var(--line); }
.ai-layout h3,
.shortcuts-card h3 { margin: 0 0 10px; color: var(--navy); font-size: 11px; }
.destination-grid { display: grid; gap: 7px; }
.destination-option { display: grid; grid-template-columns: 18px 32px minmax(0, 1fr); align-items: center; gap: 9px; min-height: 48px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.destination-option:hover { background: var(--surface-2); }
.destination-option:has(input:checked) { border-color: #5c84ca; background: #eef5ff; }
html[data-theme="dark"] .destination-option:has(input:checked),
html[data-theme="night"] .destination-option:has(input:checked) { background: #243750; }
.destination-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--destination-color); color: white; font-size: 10px; font-weight: 800; }
.destination-option strong { display: block; color: var(--navy); font-size: 10.5px; }
.destination-option small { color: var(--muted); font-size: 9px; }
.ai-layout .select-control { margin-bottom: 9px; }
.ai-card textarea { min-height: 190px; padding: 11px; }
.privacy-note { margin: 9px 0 0; padding: 9px 10px; border-radius: 7px; background: var(--surface-2); color: var(--muted); font-size: 9.5px; line-height: 1.45; }

.compact-card { width: min(390px, calc(100vw - 28px)); }
.compact-card > label { display: grid; gap: 6px; padding: 18px 22px; color: var(--muted); font-size: 10px; font-weight: 700; }
.compact-card input { height: 38px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--surface); color: var(--ink); font-size: 13px; }

.shortcuts-card { width: min(880px, calc(100vw - 28px)); }
.shortcut-columns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; overflow: auto; }
.shortcut-columns section { padding: 18px 20px; }
.shortcut-columns section + section { border-left: 1px solid var(--line); }
.shortcut-columns dl { margin: 0; }
.shortcut-columns dl > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 31px; border-bottom: 1px solid var(--line); }
.shortcut-columns dt { color: var(--muted); font-size: 10px; }
.shortcut-columns dd { margin: 0; padding: 3px 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: var(--surface-2); color: var(--navy); font-size: 8.5px; font-weight: 700; white-space: nowrap; }

/* Unified reader visual system — refined after live desktop comparison. */
:root {
  --toolbar-height: 58px;
  --sidebar-width: 300px;
  --comments-width: 360px;
  --line: #d8e0e8;
  --line-strong: #bac7d3;
  --surface-2: #f6f8fb;
  --surface-3: #edf2f7;
  --stage: #e9eff5;
  --shadow: 0 14px 38px rgba(23, 50, 77, .15);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

body { font-size: 14px; }

svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.75;
}

.topbar {
  gap: 12px;
  padding: 0 14px;
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(20, 45, 70, .025);
}

.topbar-section { gap: 5px; }
.topbar-brand-section { flex-basis: 304px; }
.topbar-actions { flex-basis: 280px; }

.brand-lockup {
  gap: 8px;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  font-weight: 750;
  letter-spacing: -.015em;
}

.brand-lockup img {
  width: 30px;
  height: 30px;
  border-radius: 7px;
}

.topbar-divider { height: 26px; margin: 0 6px; }
.sidebar-toggle { margin-left: auto; }

.document-identity { gap: 1px; line-height: 1.2; }
.document-identity strong { max-width: min(24vw, 360px); font-size: 13px; font-weight: 700; letter-spacing: -.01em; }
.document-identity span { font-size: 11px; }

.icon-button,
.tool-button,
.action-button,
.color-summary,
.scope-menu > summary {
  height: 38px;
  min-width: 38px;
  padding: 0 9px;
  gap: 7px;
  border-radius: 8px;
}

.icon-button svg,
.tool-button svg,
.action-button svg,
.color-summary svg,
.scope-menu > summary svg { width: 18px; height: 18px; }

.icon-button.small { width: 32px; height: 32px; min-width: 32px; }
.icon-button.small svg { width: 16px; height: 16px; }

.view-controls {
  height: 40px;
  gap: 0;
  padding: 2px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}

.view-controls .icon-button {
  width: 34px;
  height: 34px;
  min-width: 34px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
}

.view-controls .icon-button:hover { background: var(--surface); }
.view-controls .select-control {
  height: 34px;
  border-width: 0 1px;
  border-color: var(--line);
  border-radius: 0;
  background: transparent;
}

.view-controls .select-control select {
  min-width: 128px;
  padding-left: 13px;
  color: var(--navy);
  font-size: 12.5px;
  font-weight: 650;
}

.tool-button {
  font-size: 12px;
  font-weight: 650;
}

.split-tool { padding-right: 7px; }
.chevron { width: 12px !important; height: 12px !important; stroke-width: 2; }
.toolbar-separator { height: 24px; margin: 0 3px; }

.tool-button.active,
.workspace[data-tool="comment"] [data-tool-button="comment"],
.workspace[data-tool="text"] [data-tool-button="text"],
.workspace[data-tool="select"] [data-tool-button="select"] {
  border-color: #f19b94;
  background: #fff4f2;
  color: #d92d20;
  box-shadow: inset 0 0 0 1px rgba(240, 68, 56, .04);
}

.active-color {
  width: 19px;
  height: 19px;
  border-radius: 5px;
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .55);
}

.scope-menu > summary {
  min-width: 94px;
  font-size: 12px;
}

.action-button { font-size: 12px; }
.ai-button { border-color: #f1aaa4; background: #fff8f7; }

.popover {
  top: calc(100% + 8px);
  width: 258px;
  padding: 7px;
  border-color: var(--line);
  border-radius: 11px;
  box-shadow: 0 16px 38px rgba(22, 43, 65, .17), 0 2px 8px rgba(22, 43, 65, .08);
}

.popover button {
  min-height: 42px;
  padding: 8px 10px;
  border-radius: 8px;
}

.popover button strong { font-size: 12.5px; }
.popover button small { font-size: 11px; }
.popover button kbd,
.settings-popover kbd { font-size: 10.5px; }

.color-popover {
  width: 218px;
  padding: 8px;
}

.color-popover > strong {
  margin: 0;
  padding: 6px 8px 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .075em;
  text-transform: uppercase;
}

.swatch-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px;
  max-height: 286px;
  overflow: auto;
}

.swatch-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
  align-items: center;
  gap: 2px;
}

.swatch-row:not(:has(.remove-swatch)) { grid-template-columns: minmax(0, 1fr); }
.remove-swatch {
  display: grid !important;
  place-items: center;
  width: 30px !important;
  min-height: 30px !important;
  padding: 0 !important;
  color: var(--subtle) !important;
}
.remove-swatch:hover { color: var(--brand-strong) !important; }
.remove-swatch svg { width: 15px; height: 15px; }

.swatch-button {
  display: grid !important;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px !important;
  width: 100% !important;
  height: 38px !important;
  min-height: 38px !important;
  padding: 0 8px !important;
  border: 0 !important;
  border-radius: 7px !important;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--ink);
}

.swatch-button.selected { background: var(--surface-2) !important; outline: 0; }
.swatch-chip {
  position: relative;
  display: block;
  width: 22px;
  height: 22px;
  border: 1px solid rgba(23, 32, 51, .13);
  border-radius: 5px;
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .38);
}
.swatch-button.selected .swatch-chip::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #17324d;
  font-size: 13px;
  font-weight: 800;
}
.swatch-name { overflow: hidden; font-size: 12px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.swatch-button kbd { color: var(--subtle); font-size: 10px; }

.custom-color-row {
  grid-template-columns: minmax(0, 1fr) 34px auto;
  margin-top: 7px;
  padding: 10px 7px 2px;
  font-size: 11px;
}

.custom-color-row input { width: 34px; height: 30px; }
.custom-color-row button { min-height: 30px; font-size: 10.5px; }

.stroke-width-control {
  margin-top: 7px;
  padding: 10px 7px 4px;
  border-top: 1px solid var(--line);
}
.stroke-width-control[hidden] { display: none; }
.stroke-width-control > span,
.format-section > span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.stroke-width-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.stroke-width-options button {
  display: grid;
  place-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 5px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 9px;
}
.stroke-width-options button.selected { border-color: #6f96d5; background: #edf4ff; color: var(--navy); }
.stroke-width-options i { display: block; width: 28px; height: var(--line-width); min-height: 1px; border-radius: 9px; background: currentColor; }

.text-format-popover { width: 292px; }
.text-format-popover > button { border-bottom: 1px solid var(--line); border-radius: 7px 7px 0 0; }
.text-format-popover .menu-icon-sample { width: 18px; height: 18px; }
.format-section { display: block; margin: 0; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.format-section select { width: 100%; height: 34px; padding: 0 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--ink); }
.format-segment { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.format-segment.compact { grid-template-columns: repeat(2, 48px); }
.format-segment button {
  justify-content: center;
  min-height: 34px;
  padding: 0 7px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 10px;
  text-align: center;
}
.format-segment button.selected { border-color: #6f96d5; background: #edf4ff; color: var(--navy); }

.search-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px 8px;
}
.search-controls[hidden] { display: none; }
.search-controls .panel-help { flex: 1; padding: 4px 3px; }
.search-controls > div { display: flex; gap: 4px; }
.search-controls .next-arrow { transform: rotate(180deg); }
.search-result-button.selected { border-color: #749ee2; background: color-mix(in srgb, #edf4ff 60%, var(--surface)); box-shadow: 0 0 0 2px rgba(88, 133, 207, .1); }
.textLayer mark.search-hit { border-radius: 2px; background: rgba(255, 219, 74, .44); color: transparent; box-shadow: 0 0 0 1px rgba(201, 151, 0, .12); }
.textLayer mark.search-hit.active { background: rgba(255, 143, 74, .58); box-shadow: 0 0 0 2px rgba(219, 89, 34, .34); }

.text-annotation.selected { overflow: auto; resize: both; cursor: text; }
.text-drag-handle {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #3c74d4;
  box-shadow: 0 1px 4px rgba(20, 43, 78, .28);
  cursor: move;
}
.text-drag-handle::after { content: ""; position: absolute; inset: 5px; border-top: 2px solid #fff; border-bottom: 2px solid #fff; }

.left-sidebar { grid-template-rows: 52px minmax(0, 1fr); }

.sidebar-tabs {
  padding: 6px 9px;
  gap: 4px;
  background: #f7f9fb;
}

.sidebar-tabs button {
  height: 39px;
  border: 1px solid transparent;
  border-radius: 8px;
}

.sidebar-tabs button:hover { border-color: var(--line); background: var(--surface); }
.sidebar-tabs button[aria-selected="true"] {
  border-color: var(--line);
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(25, 43, 63, .08);
}
.sidebar-tabs svg { width: 18px; height: 18px; }

.sidebar-panel > header,
.comments-panel > header { padding: 18px 18px 12px; }
.sidebar-panel h2,
.comments-panel h2 {
  margin-top: 3px;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.025em;
}
.sidebar-panel h2 span { min-width: 21px; height: 21px; font-size: 10px; }
.eyebrow { font-size: 9.5px; letter-spacing: .1em; }

.sidebar-search {
  grid-template-columns: 18px minmax(0, 1fr) auto;
  gap: 8px;
  height: 42px;
  margin: 0 16px 11px;
  padding: 0 11px;
  border-color: var(--line-strong);
  border-radius: 9px;
}
.sidebar-search svg { width: 16px; height: 16px; }
.sidebar-search input { font-size: 12.5px; }
.sidebar-search kbd { font-size: 9.5px; }
.annotation-search-row { padding: 0 16px 11px; }
.panel-help { padding: 4px 18px 12px; font-size: 12px; line-height: 1.5; }

.search-results,
.annotation-list { padding: 0 11px 14px; }
.search-result-button,
.annotation-card { margin-bottom: 7px; padding: 11px; border-radius: 9px; }
.search-result-button strong { font-size: 10px; }
.search-result-button span { font-size: 12px; }
.annotation-card-copy strong { font-size: 12px; }
.annotation-card-copy p { font-size: 11.5px; }
.annotation-card-page { font-size: 10px; }

.annotation-filters { gap: 9px; padding: 0 16px 12px; }
.annotation-filters label { font-size: 9.5px; }
.annotation-filters select { height: 35px; font-size: 11px; }
.annotation-empty,
.comments-empty { padding: 38px 28px; }
.annotation-empty strong,
.comments-empty strong { font-size: 13px; }
.annotation-empty p,
.comments-empty p { font-size: 12px; }
.sidebar-footer-actions { gap: 8px; padding: 11px 16px 15px; }
.sidebar-footer-actions button { height: 36px; font-size: 11.5px; }

.outline-list { padding: 0 12px 20px; }
.outline-button { padding-top: 9px; padding-bottom: 9px; font-size: 12px; }
.thumbnail-grid { gap: 14px 10px; padding: 5px 16px 22px; }
.thumbnail-button { gap: 6px; font-size: 10.5px; }

.document-stage {
  background-color: var(--stage);
  background-image: linear-gradient(90deg, rgba(91, 116, 143, .035), transparent 14%, transparent 86%, rgba(91, 116, 143, .035));
}

.pdf-scroll {
  scrollbar-width: thin;
  scrollbar-color: #8593a1 transparent;
}
.pdf-scroll::-webkit-scrollbar { width: 12px; height: 12px; }
.pdf-scroll::-webkit-scrollbar-thumb { border: 3px solid transparent; border-radius: 99px; background: #8795a3; background-clip: padding-box; }
.pdf-scroll::-webkit-scrollbar-track { background: transparent; }
.pdf-pages { gap: 24px; padding: 20px 34px 76px; }
.page-shell { box-shadow: 0 5px 16px rgba(29, 43, 62, .13), 0 0 0 1px rgba(64, 80, 99, .1); }

.page-indicator {
  right: 20px;
  bottom: 18px;
  min-width: 70px;
  height: 38px;
  border-radius: 10px;
  font-size: 12px;
}

.modal-card > header h2 { font-family: Inter, "Segoe UI", Arial, sans-serif; font-size: 21px; }
.modal-card > header p { font-size: 12.5px; }
.modal-card > footer button { min-height: 36px; font-size: 12px; }
.export-grid strong { font-size: 13px; }
.export-grid small { font-size: 11.5px; }
.ai-layout h3,
.shortcuts-card h3 { font-size: 12.5px; }
.destination-option strong { font-size: 12px; }
.destination-option small { font-size: 10.5px; }
.privacy-note { font-size: 11px; }
.shortcut-columns dt { font-size: 11.5px; }
.shortcut-columns dd { font-size: 9.5px; }

@media (max-width: 1360px) {
  :root { --sidebar-width: 266px; --comments-width: 320px; }
  .brand-lockup span { display: none; }
  .topbar-divider { margin-left: 1px; }
  .tool-button > span:not(.visually-hidden),
  .ai-button span { display: none; }
  .tool-button { padding: 0 7px; }
  .topbar-brand-section { flex-basis: 235px; }
  .topbar-actions { flex-basis: 210px; }
}

@media (max-width: 1240px) {
  :root { --sidebar-width: 266px; --comments-width: 320px; }
}

@media (max-width: 980px) {
  :root { --sidebar-width: min(310px, calc(100vw - 58px)); }
  .topbar { gap: 4px; padding: 0 6px; }
  .topbar-brand-section { flex: 1 1 auto; }
  .document-identity { display: none; }
  .view-controls .zoom-control { display: none; }
  .scope-menu { display: none; }
  .workspace-body,
  .workspace.comments-open .workspace-body,
  .workspace.sidebar-collapsed .workspace-body,
  .workspace.sidebar-collapsed.comments-open .workspace-body { display: block; }
  .left-sidebar { position: absolute; z-index: 40; top: var(--toolbar-height); bottom: 0; left: 0; width: var(--sidebar-width); box-shadow: 14px 0 35px rgba(20, 35, 52, .2); }
  .workspace.sidebar-collapsed .left-sidebar { display: none; }
  .document-stage { height: 100%; }
  .comments-panel { position: absolute; z-index: 45; top: var(--toolbar-height); right: 0; bottom: 0; width: min(var(--comments-width), calc(100vw - 30px)); box-shadow: -14px 0 35px rgba(20, 35, 52, .22); }
  .popover.align-right { right: 0; }
}

@media (max-width: 700px) {
  :root { --toolbar-height: 52px; }
  .workspace { min-height: 420px; }
  .brand-lockup { display: none; }
  .topbar-divider { display: none; }
  .back-button { margin-right: 0; }
  .topbar-brand-section { flex: 0 0 auto; }
  .view-controls [data-action="zoom-out"],
  .view-controls [data-action="zoom-in"],
  .annotation-controls [data-action="undo"],
  .annotation-controls [data-action="redo"],
  .annotation-controls .toolbar-separator,
  .topbar-actions > details:not(:last-child),
  .topbar-actions .ai-button { display: none; }
  .settings-popover .mobile-menu-action { display: flex !important; }
  .annotation-controls { flex: 1 1 auto; justify-content: center; }
  .topbar-actions { flex: 0 0 auto; }
  .color-menu { display: block; }
  .tool-button { width: 34px; min-width: 34px; padding: 0; }
  .split-tool .chevron { display: none; }
  .pdf-pages { gap: 12px; padding: 10px 10px 60px; }
  .page-indicator { right: 10px; bottom: 10px; }
  .empty-workspace { padding: 28px 20px; }
  .empty-workspace h1 { font-size: 31px; }
  .empty-workspace > p { font-size: 12px; }
  .feature-chips { display: none; }
  .export-grid { grid-template-columns: 1fr; }
  .ai-layout { grid-template-columns: 1fr; }
  .ai-layout > section + section { border-top: 1px solid var(--line); border-left: 0; }
  .shortcut-columns { grid-template-columns: 1fr; }
  .shortcut-columns section + section { border-top: 1px solid var(--line); border-left: 0; }
}

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

@media print {
  @page { margin: 8mm; }
  html,
  body { height: auto; overflow: visible; background: white; }
  .topbar,
  .left-sidebar,
  .comments-panel,
  .page-indicator,
  .toast,
  .drop-overlay { display: none !important; }
  .workspace,
  .workspace-body,
  .document-stage,
  .pdf-scroll { display: block !important; position: static; width: auto; height: auto; overflow: visible; background: white; }
  .pdf-pages { display: block; padding: 0; }
  .page-shell { margin: 0 auto 8mm; break-after: page; box-shadow: none; }
  body.print-source .annotation-svg,
  body.print-source .annotation-html-layer { display: none !important; }
}

/* Novo visual alignment and toolbar interaction hardening. */
:root {
  --brand: #176de7;
  --brand-strong: #0759d1;
  --brand-soft: #eaf4ff;
  --navy: #071a2a;
  --navy-2: #17384f;
  --ink: #0a2133;
  --muted: #5d7282;
  --subtle: #7890a1;
  --line: #dce7ee;
  --line-strong: #b9ccd9;
  --surface-2: #f7fafe;
  --surface-3: #eef5fb;
  --stage: #edf3f7;
  --shadow: 0 18px 48px rgba(8, 34, 54, .13);
  --radius: 8px;
  font-family: Inter, Arial, sans-serif;
}

html[data-theme="dark"],
html[data-theme="night"] {
  --brand: #3294ff;
  --brand-strong: #78b8ff;
  --brand-soft: rgba(50, 148, 255, .15);
}

[hidden] { display: none !important; }

body {
  font-family: Inter, Arial, sans-serif;
  text-rendering: optimizeLegibility;
}

svg {
  stroke-width: 1.9;
}

.brand-lockup {
  color: var(--navy);
  font-family: Manrope, Inter, sans-serif;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -.035em;
}

.brand-mark {
  width: 32px !important;
  height: 32px !important;
  color: var(--brand);
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linecap: square;
}

.brand-mark-monogram { stroke-width: 2.15; }

.topbar {
  border-bottom-color: color-mix(in srgb, var(--line-strong) 52%, transparent);
  background: color-mix(in srgb, var(--surface) 97%, transparent);
  box-shadow: 0 4px 18px rgba(8, 34, 54, .035);
}

.document-identity strong,
.modal-card > header h2,
.empty-workspace h1 {
  font-family: Manrope, Inter, sans-serif;
}

.document-identity strong { color: var(--navy); font-weight: 700; }
.document-identity span { color: var(--muted); }

.icon-button,
.tool-button,
.action-button,
.color-summary,
.scope-menu > summary {
  border-color: var(--line);
  color: var(--navy-2);
}

.icon-button:hover:not(:disabled),
.tool-button:hover:not(:disabled),
.action-button:hover:not(:disabled),
.color-summary:hover,
.scope-menu > summary:hover,
details[open] > summary {
  border-color: #a9caef;
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.icon-button:focus-visible,
.tool-button:focus-visible,
.action-button:focus-visible,
.color-summary:focus-visible,
.scope-menu > summary:focus-visible,
.popover button:focus-visible,
.sidebar-tabs button:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.tool-button.active,
.workspace[data-tool="comment"] [data-tool-button="comment"],
.workspace[data-tool="text"] [data-tool-button="text"],
.workspace[data-tool="select"] [data-tool-button="select"] {
  border-color: #8dbcf3;
  background: var(--brand-soft);
  color: var(--brand-strong);
  box-shadow: inset 0 0 0 1px rgba(23, 109, 231, .04);
}

.ai-button {
  border-color: #b5d3f4;
  background: #f5f9ff;
  color: var(--brand-strong);
}

.view-controls {
  border-color: var(--line);
  background: var(--surface-2);
}

.popover {
  border-color: var(--line-strong);
  border-radius: 10px;
  box-shadow: 0 18px 48px rgba(8, 34, 54, .14);
}

.tool-popover button:hover,
.action-popover button:hover,
.settings-popover > button:hover,
.scope-popover button:hover,
.swatch-option:hover {
  background: var(--brand-soft);
  color: var(--navy);
}

.format-segment button.selected,
.stroke-width-options button.selected,
.theme-options button.selected {
  border-color: #86b9f2;
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.eyebrow,
.menu-heading,
.format-section > span,
.stroke-width-control > span,
.color-popover > strong {
  color: var(--brand-strong);
}

.primary-button {
  border-color: var(--brand-strong) !important;
  background: var(--brand) !important;
  box-shadow: 0 8px 22px rgba(7, 89, 209, .2);
}

.primary-button:hover { background: var(--brand-strong) !important; }

.document-stage { background-color: var(--stage); background-image: none; }

.empty-workspace {
  background-color: #f7fafe;
  background-image:
    linear-gradient(rgba(23, 109, 231, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 109, 231, .045) 1px, transparent 1px),
    radial-gradient(circle at 52% 20%, rgba(50, 148, 255, .12), transparent 32%);
  background-size: 48px 48px, 48px 48px, auto;
}

.empty-brand {
  width: 72px;
  height: 72px;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 16px 42px rgba(8, 34, 54, .1);
}

.empty-brand::after { display: none; }
.empty-brand .brand-mark { width: 48px !important; height: 48px !important; }
.empty-workspace h1 { color: var(--navy); font-weight: 600; letter-spacing: -.055em; }

[data-document-required].is-disabled {
  opacity: .42;
  filter: saturate(.55);
}

details[data-document-required].is-disabled > summary { cursor: not-allowed; }
button:disabled,
select:disabled { cursor: not-allowed; }

.page-indicator {
  border-color: var(--line-strong);
  color: var(--navy);
  box-shadow: 0 12px 30px rgba(8, 34, 54, .12);
}

@media print {
  .document-stage,
  .pdf-scroll { background: white; }
}
