:root {
  --accent: #d92c50;
  --accent-dark: #bd173b;
  --ink: #1d2530;
  --muted: #6f7782;
  --line: #dfe3e9;
  --panel: #ffffff;
  --workspace: #edf0f4;
  --toolbar-height: 72px;
  --format-height: 48px;
  --sidebar-width: 270px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
}

@font-face { font-family: "Inter"; src: url("/static/fonts/Inter.ttf") format("truetype"); }
@font-face { font-family: "Roboto"; src: url("/static/fonts/Roboto.ttf") format("truetype"); }
@font-face { font-family: "Open Sans"; src: url("/static/fonts/OpenSans.ttf") format("truetype"); }
@font-face { font-family: "Lato"; src: url("/static/fonts/Lato.ttf") format("truetype"); }
@font-face { font-family: "Montserrat"; src: url("/static/fonts/Montserrat.ttf") format("truetype"); }
@font-face { font-family: "Poppins"; src: url("/static/fonts/Poppins.ttf") format("truetype"); }
@font-face { font-family: "Nunito"; src: url("/static/fonts/Nunito.ttf") format("truetype"); }
@font-face { font-family: "Raleway"; src: url("/static/fonts/Raleway.ttf") format("truetype"); }
@font-face { font-family: "Oswald"; src: url("/static/fonts/Oswald.ttf") format("truetype"); }
@font-face { font-family: "Merriweather"; src: url("/static/fonts/Merriweather.ttf") format("truetype"); }
@font-face { font-family: "Playfair Display"; src: url("/static/fonts/PlayfairDisplay.ttf") format("truetype"); }
@font-face { font-family: "Source Sans 3"; src: url("/static/fonts/SourceSans3.ttf") format("truetype"); }
@font-face { font-family: "Noto Sans"; src: url("/static/fonts/NotoSans.ttf") format("truetype"); }
@font-face { font-family: "Noto Serif"; src: url("/static/fonts/NotoSerif.ttf") format("truetype"); }
@font-face { font-family: "Ubuntu"; src: url("/static/fonts/Ubuntu.ttf") format("truetype"); }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
button, input, select { font: inherit; }
button { color: inherit; }

[hidden] { display: none !important; }

.upload-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 18% 20%, rgba(217, 44, 80, .12), transparent 30%),
    radial-gradient(circle at 84% 74%, rgba(50, 98, 255, .12), transparent 34%),
    #f5f7fb;
}

.upload-card {
  width: min(620px, calc(100vw - 32px));
  padding: 42px;
  border: 1px solid rgba(25, 37, 55, .08);
  border-radius: 24px;
  background: rgba(255,255,255,.94);
  box-shadow: 0 28px 80px rgba(36, 46, 66, .16);
  text-align: center;
}

.brand-lockup, .brand-button { display: inline-flex; align-items: center; gap: 10px; }
.brand-lockup { justify-content: center; }
.brand-symbol { width: 35px; height: 35px; flex: 0 0 35px; display: inline-grid; place-items: center; }
.brand-symbol svg { width: 100%; height: 100%; }
.brand-symbol .brand-symbol-bg { fill: var(--accent); }
.brand-symbol .brand-page { fill: #fff; stroke: none; }
.brand-symbol .brand-fold { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.brand-symbol .brand-lines { fill: none; stroke: var(--accent); stroke-width: 1.45; stroke-linecap: round; }
.brand-word { display: inline-flex; align-items: baseline; letter-spacing: -.035em; font-size: 31px; line-height: 1; }
.brand-word strong { color: #202b3b; font-weight: 850; }
.brand-word span { color: var(--accent); font-weight: 760; }
.upload-card .brand-symbol { width: 42px; height: 42px; flex-basis: 42px; }
.upload-card .brand-word { font-size: 36px; }
.upload-card h1 { margin: 26px 0 10px; font-size: clamp(30px, 5vw, 48px); line-height: 1.05; }
.upload-card p { margin: 0 auto 28px; max-width: 500px; color: var(--muted); line-height: 1.6; }
.upload-card small { display: block; margin-top: 18px; color: #87909d; }
.upload-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 190px;
  min-height: 52px;
  padding: 0 24px;
  border-radius: 12px;
  background: var(--accent);
  color: white;
  font-weight: 750;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(217,44,80,.22);
}
.upload-button:hover { background: var(--accent-dark); }
.drop-zone {
  margin-top: 16px;
  padding: 20px;
  border: 1.5px dashed #b9c0cb;
  border-radius: 14px;
  color: #758090;
  transition: .2s ease;
}
.drop-zone.dragover { border-color: var(--accent); background: rgba(217,44,80,.05); color: var(--accent); }
.upload-progress { margin-top: 22px; display: inline-flex; align-items: center; gap: 10px; color: #4a5360; }
.spinner { width: 18px; height: 18px; border: 2px solid #d9dde4; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.app { height: 100%; background: var(--workspace); color: var(--ink); }
.top-header {
  height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: white;
  position: relative;
  z-index: 20;
}
.header-left, .header-actions { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-button { border: 0; background: transparent; padding: 4px 6px; border-radius: 10px; cursor: pointer; white-space: nowrap; }
.brand-button:hover { background: #f5f7fa; }
.filename-field {
  height: 42px;
  width: 250px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #cbd1d9;
  border-radius: 9px;
  padding: 0 11px;
  background: #fff;
  color: #273141;
  box-shadow: inset 0 1px 2px rgba(25, 37, 55, .035);
  color-scheme: light;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.filename-field:focus-within {
  border-color: #8d80c5;
  box-shadow: 0 0 0 3px rgba(119, 104, 183, .12);
}
.filename-field input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: #273141;
  font-size: 15px;
  font-weight: 600;
  color-scheme: light;
  appearance: none;
}
.filename-field span {
  flex: 0 0 auto;
  color: #7b8491;
  font-size: 17px;
  pointer-events: none;
}
.header-actions { justify-content: flex-end; }
.header-tool {
  min-width: 104px;
  height: 46px;
  padding: 0 14px;
  border: 1px solid #dfe3e9;
  border-radius: 11px;
  background: #fff;
  color: #303948;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 9px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 680;
  transition: border-color .16s ease, background .16s ease, color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.header-tool:hover { border-color: #bfc7d2; background: #fafbfc; box-shadow: 0 4px 12px rgba(25, 36, 52, .07); transform: translateY(-1px); }
.header-tool svg { width: 20px; height: 20px; flex: 0 0 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.action-label { white-space: nowrap; }
.search-box {
  width: 190px;
  min-width: 160px;
  justify-content: flex-start;
  padding: 0 12px;
  background: #f7f8fa;
  cursor: text;
}
.search-box:focus-within { border-color: #7768b7; background: white; box-shadow: 0 0 0 3px rgba(119,104,183,.12); transform: none; }
.search-box input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; text-align: left; color: #242d3a; font-size: 13px; }
.search-box input::placeholder { color: #7b8491; }
.print-tool:hover { color: #1e5b9b; border-color: #a9c5df; background: #f5faff; }
.download-tool { color: #b91f43; border-color: #e8bdc8; background: #fff9fa; }
.download-tool:hover { color: #9f1536; border-color: #d98ca0; background: #fff2f5; }
.share-button {
  height: 52px;
  min-width: 154px;
  border-radius: 12px;
  font-weight: 750;
  font-size: 16px;
  cursor: pointer;
}
.share-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1.5px solid #c8c1e5;
  background: linear-gradient(180deg, #fff 0%, #faf9ff 100%);
  color: #2f2851;
  box-shadow: 0 2px 7px rgba(59, 44, 110, .08);
}
.share-button:hover { border-color: #8e81c8; background: #f5f2ff; transform: translateY(-1px); }
.share-button svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.autosave-status {
  min-width: 64px;
  padding: 7px 10px;
  border-radius: 999px;
  background: #edf8f1;
  color: #287143;
  font-size: 12px;
  font-weight: 720;
  text-align: center;
  white-space: nowrap;
}
.autosave-status.saving { background: #eef4fd; color: #2c64a4; }
.autosave-status.error { background: #fff0f1; color: #ad2940; }

.main-toolbar {
  height: var(--toolbar-height);
  padding: 4px 12px;
  display: flex;
  align-items: stretch;
  gap: 6px;
  overflow-x: auto;
  overflow-y: visible;
  border-bottom: 1px solid var(--line);
  background: white;
  position: relative;
  z-index: 15;
  scrollbar-width: thin;
}
.toolbar-group {
  display: flex;
  align-items: stretch;
  gap: 2px;
  flex: 0 0 auto;
}
.navigation-tools {
  padding: 3px;
  border-radius: 11px;
  background: #f7f8fa;
}
.tool {
  min-width: 66px;
  padding: 4px 9px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
}
.tool:hover, .tool.active { background: #fff0f4; color: var(--accent); }
.tool.muted { color: #a2a8b1; }
.tool.muted:not(:disabled):hover { color: var(--accent); }
.tool:disabled { opacity: .45; cursor: not-allowed; }
.tool-icon { min-height: 24px; font-size: 26px; line-height: 1; font-weight: 500; }
.annotation-tool-icon { width: 27px; height: 27px; display: grid; place-items: center; }
.annotation-tool-icon svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.highlighter-tool-icon { width: 27px; height: 27px; display: grid; place-items: center; }
.highlighter-tool-icon svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.highlighter-tool-icon .highlighter-tip { stroke-width: 3.5; }
.text-icon { font-family: Georgia, serif; }
.boxed-text { border: 2px solid currentColor; border-radius: 5px; font-size: 19px; width: 25px; height: 25px; display: grid; place-items: center; }
.toolbar-divider { width: 1px; margin: 8px 5px; background: #eceef2; flex: 0 0 auto; }
.toolbar-spacer { flex: 1 0 12px; }
.tool-menu-wrap { position: relative; display: flex; }
.page-action-group {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 7px;
  margin-left: 2px;
  padding: 5px 4px 5px 12px;
  border-left: 1px solid #e2e6ec;
  background: white;
}
.page-action-button {
  height: 52px;
  padding: 0 13px;
  border: 1px solid #dce1e8;
  border-radius: 10px;
  background: #f8f9fb;
  color: #354052;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 680;
  white-space: nowrap;
  cursor: pointer;
  transition: .16s ease;
}
.page-action-button:first-child { min-width: 94px; }
.page-action-button:last-child { min-width: 132px; }
.page-action-button svg { flex: 0 0 20px; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.page-action-button:hover { border-color: #b9c2ce; background: white; color: #1f5e9a; box-shadow: 0 4px 12px rgba(29,45,65,.08); transform: translateY(-1px); }
.tool-menu {
  position: fixed;
  z-index: 220;
  min-width: 150px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--ink);
  box-shadow: 0 14px 32px rgba(37,45,60,.18);
}
.tool-menu button { width: 100%; padding: 10px 12px; border: 0; border-radius: 7px; background: white; text-align: left; cursor: pointer; }
.tool-menu button:has(svg) { display: flex; align-items: center; gap: 9px; }
.tool-menu button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tool-menu button:hover { background: #f3f5f8; }

.format-toolbar {
  height: var(--format-height);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  border-bottom: 1px solid var(--line);
  background: #f7f8fa;
  position: relative;
  z-index: 13;
  overflow-x: auto;
}
.format-toolbar button, .format-toolbar select, .format-toolbar input[type="number"] {
  height: 34px;
  border: 1px solid #d7dbe2;
  border-radius: 7px;
  background: white;
}
.format-toolbar button { min-width: 35px; cursor: pointer; }
.format-toolbar button.active { background: #222b38; color: white; border-color: #222b38; }
.format-toolbar select { padding: 0 28px 0 10px; }
#fontFamily { min-width: 150px; }
.upload-font-button { padding: 0 10px; white-space: nowrap; color: #424c5d; font-weight: 650; }
#fontSize {
  width: 74px;
  padding: 0 3px 0 6px;
  font-size: 12px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.format-label { min-width: 210px; max-width: 300px; color: #647080; font-size: 13px; }
.color-control {
  width: 40px;
  height: 36px;
  display: grid;
  place-items: stretch;
  border: 1px solid #cfd5de;
  border-radius: 8px;
  padding: 3px;
  background: #fff;
  overflow: hidden;
  cursor: pointer;
  color-scheme: light;
  box-shadow: inset 0 1px 1px rgba(25, 37, 55, .035);
  transition: border-color .16s ease, box-shadow .16s ease;
}
.color-control:hover,
.color-control:focus-within {
  border-color: #8d80c5;
  box-shadow: 0 0 0 3px rgba(119, 104, 183, .1);
}
.color-control input {
  width: 100%;
  height: 100%;
  min-width: 0;
  border: 0;
  border-radius: 5px;
  padding: 0;
  overflow: hidden;
  background: transparent;
  cursor: pointer;
  color-scheme: light;
  appearance: none;
  -webkit-appearance: none;
}
.color-control input::-webkit-color-swatch-wrapper { padding: 0; }
.color-control input::-webkit-color-swatch {
  border: 0;
  border-radius: 5px;
}
.color-control input::-moz-color-swatch {
  border: 0;
  border-radius: 5px;
}
.color-control > span { display: none; }
.range-control { display: flex; align-items: center; gap: 7px; padding: 0 9px; height: 34px; border: 1px solid #d7dbe2; border-radius: 7px; background: white; font-size: 12px; white-space: nowrap; }
.range-control input { width: 74px; }
.trash-selection { margin-left: auto; color: #b31732; }
.alignment-control {
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid #d7dbe2;
  border-radius: 8px;
  background: white;
}
.alignment-control[hidden] { display: none !important; }
.alignment-control button {
  width: 30px;
  min-width: 30px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #596474;
}
.alignment-control button:hover { background: #eef2f7; color: #263142; }
.alignment-control button.active { background: #27364a; color: white; }
.align-lines {
  display: block;
  width: 18px;
  height: 14px;
  margin: auto;
}
.align-lines.left {
  background:
    linear-gradient(currentColor 0 0) left 0 top 0 / 18px 2px no-repeat,
    linear-gradient(currentColor 0 0) left 0 top 4px / 12px 2px no-repeat,
    linear-gradient(currentColor 0 0) left 0 top 8px / 16px 2px no-repeat,
    linear-gradient(currentColor 0 0) left 0 top 12px / 10px 2px no-repeat;
}
.align-lines.center {
  background:
    linear-gradient(currentColor 0 0) center top 0 / 18px 2px no-repeat,
    linear-gradient(currentColor 0 0) center top 4px / 12px 2px no-repeat,
    linear-gradient(currentColor 0 0) center top 8px / 16px 2px no-repeat,
    linear-gradient(currentColor 0 0) center top 12px / 10px 2px no-repeat;
}
.align-lines.right {
  background:
    linear-gradient(currentColor 0 0) right 0 top 0 / 18px 2px no-repeat,
    linear-gradient(currentColor 0 0) right 0 top 4px / 12px 2px no-repeat,
    linear-gradient(currentColor 0 0) right 0 top 8px / 16px 2px no-repeat,
    linear-gradient(currentColor 0 0) right 0 top 12px / 10px 2px no-repeat;
}
.align-lines.justify {
  background: repeating-linear-gradient(to bottom, currentColor 0 2px, transparent 2px 4px);
}

.workspace {
  height: calc(100% - 82px - var(--toolbar-height) - var(--format-height));
  display: flex;
  min-height: 0;
}
.page-sidebar {
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  border-right: 1px solid #cfd4dc;
  background: #f8f9fb;
  overflow-y: auto;
  transition: margin-left .2s ease;
}
.page-sidebar.collapsed { margin-left: calc(var(--sidebar-width) * -1); }
.sidebar-title { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 10px; background: #f8f9fb; }
.sidebar-title span { color: var(--muted); font-size: 13px; }
.thumbnails { padding: 6px 18px 40px; }
.thumbnail {
  position: relative;
  margin: 0 auto 28px;
  padding: 5px;
  border: 2px solid transparent;
  border-radius: 9px;
  background: white;
  box-shadow: 0 2px 9px rgba(26,35,50,.08);
  cursor: pointer;
}
.thumbnail.active { border-color: var(--accent); }
.thumbnail-viewport { width: 100%; overflow: hidden; border-radius: 4px; background: white; }
.thumbnail img { display: block; max-width: none; transform-origin: left top; background: white; }
.thumbnail-number { position: absolute; left: 50%; bottom: -22px; transform: translateX(-50%); font-size: 13px; color: #59616e; }
.thumbnail-rotation { position: absolute; top: 8px; right: 8px; padding: 2px 5px; border-radius: 4px; background: rgba(31,39,51,.82); color: white; font-size: 10px; }

.viewer-scroll { flex: 1; min-width: 0; overflow: auto; position: relative; scroll-behavior: smooth; }
.pages-container { min-height: 100%; padding: 28px 50px 110px; display: flex; flex-direction: column; align-items: center; gap: 28px; }
.pages-container.two-column {
  width: 100%;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  justify-items: center;
  gap: 24px;
  padding-left: 28px;
  padding-right: 28px;
}
.pages-container.two-column .page-shell { max-width: 100%; }
.page-shell {
  position: relative;
  width: min(850px, calc(100vw - var(--sidebar-width) - 100px));
  background: white;
  box-shadow: 0 8px 26px rgba(32,43,61,.13);
  user-select: none;
  transform-origin: center center;
  overflow: hidden;
}
.page-content { position: absolute; }
.page-shell.current { box-shadow: 0 0 0 2px rgba(217,44,80,.28), 0 8px 26px rgba(32,43,61,.13); }
.page-image { width: 100%; height: 100%; display: block; pointer-events: none; user-select: none; }
.page-overlay, .text-hit-layer { position: absolute; inset: 0; }
.page-overlay { z-index: 2; overflow: hidden; }
.text-hit-layer { z-index: 1; pointer-events: none; }
.page-shell.text-aware .page-overlay { pointer-events: none; }
.page-shell.text-aware .page-overlay .operation { pointer-events: auto; }
.text-hit {
  position: absolute;
  border: 1px solid transparent;
  background: transparent;
  cursor: text;
  pointer-events: none;
}
.page-shell.text-aware .text-hit { pointer-events: auto; }
.page-shell.text-aware .text-hit:hover { border-color: rgba(57, 128, 237, .8); background: rgba(57, 128, 237, .08); }
.page-shell.edit-mode .text-hit:hover { background: rgba(57, 128, 237, .13); }
.search-match-marker {
  position: absolute;
  z-index: 6;
  border-radius: 2px;
  background: rgba(255, 181, 36, .46);
  box-shadow: 0 0 0 1px rgba(225, 132, 0, .7);
  mix-blend-mode: multiply;
  pointer-events: none;
  animation: pulse-hit 1.1s ease 2;
}
@keyframes pulse-hit { 50% { box-shadow: 0 0 0 6px rgba(255,159,26,.15); } }

.operation {
  position: absolute;
  touch-action: none;
  cursor: pointer;
  user-select: none;
}
.replacement-background { position: absolute; pointer-events: none; }
.operation { cursor: grab; }
.operation:active { cursor: grabbing; }
.text-operation[contenteditable="true"],
body[data-mode="edit_text"] .text-operation { cursor: text; }
body[data-mode="eraser"] .operation { cursor: crosshair; }
.operation.selected {
  outline: 0;
  border-radius: 0;
  overflow: visible !important;
  box-shadow: 0 0 0 2px #79b8f5;
}
.operation.selected::before {
  display: none;
}
.resize-handle {
  position: absolute;
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  z-index: 8;
  touch-action: none;
}
.resize-handle::after {
  content: "";
  position: absolute;
  left: 8px;
  top: 8px;
  width: 14px;
  height: 14px;
  box-sizing: border-box;
  border: 2px solid white;
  border-radius: 50%;
  background: #3195ef;
  box-shadow: 0 0 0 1px rgba(35,112,190,.28);
}
.resize-handle.nw { left: -15px; top: -15px; cursor: nwse-resize !important; }
.resize-handle.n { left: 50%; top: -15px; transform: translateX(-50%); cursor: ns-resize !important; }
.resize-handle.ne { right: -15px; top: -15px; cursor: nesw-resize !important; }
.resize-handle.e { right: -15px; top: 50%; transform: translateY(-50%); cursor: ew-resize !important; }
.resize-handle.se { right: -15px; bottom: -15px; cursor: nwse-resize !important; }
.resize-handle.s { left: 50%; bottom: -15px; transform: translateX(-50%); cursor: ns-resize !important; }
.resize-handle.sw { left: -15px; bottom: -15px; cursor: nesw-resize !important; }
.resize-handle.w { left: -15px; top: 50%; transform: translateY(-50%); cursor: ew-resize !important; }
.rotation-handle {
  position: absolute;
  z-index: 12;
  left: 50%;
  top: 100%;
  width: 38px;
  height: 64px;
  transform: translateX(-50%);
  cursor: grab;
  touch-action: none;
}
.rotation-handle:active { cursor: grabbing; }
.rotation-handle::before {
  content: "";
  position: absolute;
  left: 18px;
  top: 7px;
  width: 2px;
  height: 36px;
  background: #79b8f5;
}
.rotation-handle::after {
  content: "";
  position: absolute;
  left: 10px;
  top: 41px;
  width: 16px;
  height: 16px;
  box-sizing: border-box;
  border: 2px solid white;
  border-radius: 50%;
  background: #3195ef;
  box-shadow: 0 0 0 1px rgba(35,112,190,.28);
}
.text-operation {
  min-width: 14px;
  min-height: 12px;
  padding: 0;
  overflow: hidden;
  white-space: pre-wrap;
  line-height: 1.16;
  cursor: text;
  user-select: text;
  outline-offset: 2px;
}
.text-operation[contenteditable="true"] {
  overflow: visible;
  caret-color: #111;
}
.text-operation.selected { overflow: visible; }
.highlight-operation { background: rgba(255, 234, 53, .36); mix-blend-mode: multiply; }
.shape-operation { border-style: solid; background: transparent; }
.note-operation { display: grid; place-items: center; background: #ffd84d; border: 1px solid #b99512; border-radius: 4px 4px 10px 4px; color: #5d4a00; box-shadow: 0 2px 5px rgba(82,65,0,.18); }
.note-operation svg { width: 72%; height: 72%; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.note-operation:not(.selected):hover::after {
  content: attr(data-note-text);
  position: absolute;
  z-index: 30;
  left: 0;
  top: calc(100% + 7px);
  width: max-content;
  min-width: 150px;
  max-width: 290px;
  padding: 9px 11px;
  border: 1px solid #d4dae3;
  border-radius: 9px;
  background: rgba(31, 42, 57, .97);
  color: white;
  box-shadow: 0 10px 28px rgba(22,31,44,.26);
  font: 12px/1.45 Arial, sans-serif;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  pointer-events: none;
}
.link-operation { border: 1.5px dashed #2377d8; background: rgba(35,119,216,.08); }
.image-operation img { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; }
.svg-operation svg { width: 100%; height: 100%; display: block; overflow: visible; }
.draft-operation { pointer-events: none; z-index: 100; }
.crop-selection {
  position: absolute;
  z-index: 120;
  border: 2px solid #1685e6;
  background: rgba(40, 145, 235, .08);
  box-shadow: 0 0 0 9999px rgba(20, 31, 46, .35);
  pointer-events: none;
}
.crop-actions {
  position: fixed;
  z-index: 230;
  width: min(230px, calc(100vw - 24px));
  display: grid;
  gap: 7px;
  padding: 11px;
  border: 1px solid #cbd5e2;
  border-radius: 11px;
  background: white;
  box-shadow: 0 16px 42px rgba(25, 39, 59, .24);
}
.crop-actions[hidden] { display: none; }
.crop-actions strong { padding: 2px 3px 5px; color: #26364a; font-size: 13px; }
.crop-actions button {
  min-height: 36px;
  border: 0;
  border-radius: 7px;
  background: #1f78d1;
  color: white;
  font-weight: 700;
  cursor: pointer;
}
.crop-actions button:hover { background: #1767b7; }
.crop-actions .crop-cancel-button { background: #eef1f5; color: #445164; }

.inline-pdf-editor {
  position: absolute;
  z-index: 145;
  width: min(250px, 42%);
  min-width: 190px;
  padding: 10px;
  border: 1px solid #aeb9c8;
  border-radius: 10px;
  background: rgba(255,255,255,.98);
  box-shadow: 0 12px 34px rgba(24,38,58,.28);
  pointer-events: auto;
}
.inline-pdf-editor strong { display: block; margin-bottom: 7px; color: #263449; font-size: 12px; }
.inline-pdf-editor textarea,
.inline-pdf-editor input {
  width: 100%;
  border: 1px solid #cbd3de;
  border-radius: 7px;
  outline: 0;
  background: white;
  color: #202b3b;
  font: 13px/1.4 inherit;
}
.inline-pdf-editor textarea { min-height: 76px; padding: 8px; resize: vertical; }
.inline-pdf-editor input { height: 36px; padding: 0 9px; }
.inline-pdf-editor textarea:focus,
.inline-pdf-editor input:focus { border-color: #3187df; box-shadow: 0 0 0 3px rgba(49,135,223,.13); }
.inline-editor-error { min-height: 16px; margin: 5px 1px 0; color: #b21f3c; font-size: 11px; }
.inline-editor-actions { display: flex; justify-content: flex-end; gap: 7px; margin-top: 7px; }
.inline-editor-actions button { min-height: 32px; padding: 0 11px; border: 0; border-radius: 7px; font-weight: 700; cursor: pointer; }
.inline-editor-cancel { background: #edf0f4; color: #425064; }
.inline-editor-save { background: #2679ce; color: white; }

.page-number-preview {
  position: absolute;
  z-index: 4;
  display: flex;
  align-items: center;
  color: #3a4352;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
}
.page-number-preview.left { justify-content: flex-start; text-align: left; }
.page-number-preview.center { justify-content: center; text-align: center; }
.page-number-preview.right { justify-content: flex-end; text-align: right; }

.page-number-panel {
  position: fixed;
  z-index: 235;
  top: 154px;
  right: 22px;
  width: min(390px, calc(100vw - 28px));
  max-height: calc(100vh - 174px);
  overflow: auto;
  padding: 16px;
  border: 1px solid #d4dae3;
  border-radius: 14px;
  background: white;
  box-shadow: 0 20px 54px rgba(24,37,56,.24);
}
.page-number-panel[hidden] { display: none; }
.page-number-panel header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.page-number-panel header div { display: grid; gap: 3px; }
.page-number-panel header strong { color: #202c3c; font-size: 16px; }
.page-number-panel header span { color: #778292; font-size: 11px; }
.page-number-panel header button { width: 30px; height: 30px; border: 0; border-radius: 8px; background: #f0f2f5; color: #536073; font-size: 20px; cursor: pointer; }
.page-number-field { display: grid; gap: 6px; margin-bottom: 12px; color: #455267; font-size: 12px; font-weight: 650; }
.page-number-field input,
.page-number-field select { width: 100%; height: 38px; padding: 0 10px; border: 1px solid #cdd4de; border-radius: 8px; outline: 0; background: white; color: #273448; font: inherit; }
.page-number-field input:focus,
.page-number-field select:focus { border-color: #3286da; box-shadow: 0 0 0 3px rgba(50,134,218,.12); }
.page-number-field small { color: #7b8695; font-weight: 450; line-height: 1.35; }
.page-number-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.page-number-row .page-number-color { display: grid; align-content: start; gap: 6px; color: #455267; font-size: 12px; font-weight: 650; }
.page-number-color input { width: 100%; height: 38px; padding: 3px; border: 1px solid #cdd4de; border-radius: 8px; background: white; }
.page-number-row:has(.page-number-color) { grid-template-columns: 1fr 80px 70px; }
.page-number-positions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.page-number-positions button { position: relative; height: 43px; border: 1px solid #d3d9e2; border-radius: 8px; background: #fafbfc; cursor: pointer; }
.page-number-positions button:hover { border-color: #86b5e5; }
.page-number-positions button.active { border-color: #247bd1; background: #edf6ff; box-shadow: 0 0 0 2px rgba(36,123,209,.12); }
.page-number-positions i { position: absolute; width: 8px; height: 8px; border-radius: 50%; background: #718096; }
.page-number-positions button.active i { background: #247bd1; }
.page-number-positions [data-position="top-left"] i { top: 5px; left: 6px; }
.page-number-positions [data-position="top-center"] i { top: 5px; left: calc(50% - 4px); }
.page-number-positions [data-position="top-right"] i { top: 5px; right: 6px; }
.page-number-positions [data-position="bottom-left"] i { bottom: 5px; left: 6px; }
.page-number-positions [data-position="bottom-center"] i { bottom: 5px; left: calc(50% - 4px); }
.page-number-positions [data-position="bottom-right"] i { right: 6px; bottom: 5px; }
.page-number-panel footer { display: flex; justify-content: space-between; gap: 10px; margin-top: 4px; }
.page-number-panel footer button { min-height: 38px; padding: 0 14px; border: 0; border-radius: 8px; font-weight: 720; cursor: pointer; }
.page-number-remove { background: #f1f2f5; color: #a3203d; }
.page-number-apply { margin-left: auto; background: #2579ce; color: white; }

.text-context-menu {
  position: fixed;
  z-index: 170;
  min-width: 160px;
  max-width: min(350px, calc(100vw - 24px));
  padding: 7px;
  border: 1px solid #d9dee7;
  border-radius: 12px;
  background: white;
  color: var(--ink);
  box-shadow: 0 14px 38px rgba(29, 39, 57, .2);
}
.context-edit-button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 0;
  border-radius: 8px;
  padding: 9px 11px;
  background: white;
  color: #202a38;
  font-weight: 720;
  cursor: pointer;
  text-align: left;
}
.context-edit-button:hover { background: #f1f5fb; }
.context-edit-icon { width: 24px; height: 24px; display: grid; place-items: center; border: 1.5px solid #2f78ed; border-radius: 5px; color: #2f78ed; font-family: Georgia, serif; }
.font-warning { display: grid; gap: 5px; margin-top: 5px; padding: 10px; border-radius: 8px; background: #fff7e8; color: #5a4218; font-size: 12px; line-height: 1.4; }
.font-warning strong { font-size: 12px; }
.font-warning button { justify-self: start; border: 0; border-radius: 6px; padding: 6px 9px; background: #755717; color: white; font-weight: 700; cursor: pointer; }
.font-mismatch-actions { display: flex; gap: 7px; margin-top: 4px; }
.font-mismatch-actions[hidden] { display: none; }
.font-warning .warning-secondary { background: transparent; color: #684e1b; box-shadow: inset 0 0 0 1px rgba(104,78,27,.34); }

body[data-mode="eraser"] .page-overlay { cursor: crosshair; }
body[data-mode="eraser"] .operation.selected { outline: 0; box-shadow: none; }
body[data-mode="eraser"] .operation.selected::before,
body[data-mode="eraser"] .operation.selected .resize-handle,
body[data-mode="eraser"] .operation.selected .rotation-handle { display: none; }

.floating-controls {
  position: fixed;
  z-index: 25;
  left: calc(50% + var(--sidebar-width) / 2);
  bottom: 22px;
  transform: translateX(-50%);
  height: 58px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 10px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 19px;
  background: rgba(36, 48, 66, .96);
  color: white;
  box-shadow: 0 14px 36px rgba(22,30,43,.24);
  backdrop-filter: blur(14px);
}
.floating-controls button {
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #f5f7fb;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.floating-controls button:hover { background: rgba(255,255,255,.13); color: white; transform: translateY(-1px); }
.floating-controls button:active { transform: translateY(0); background: rgba(255,255,255,.18); }
.floating-controls svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.floating-controls input {
  width: 50px;
  height: 36px;
  padding: 0 4px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 9px;
  outline: 0;
  background: rgba(255,255,255,.14);
  color: white;
  text-align: center;
  font-weight: 720;
  font-variant-numeric: tabular-nums;
}
.floating-controls input:focus { border-color: rgba(255,255,255,.52); box-shadow: 0 0 0 3px rgba(255,255,255,.09); }
.page-label { margin-left: 2px; color: #cdd4de; font-size: 12px; font-weight: 650; }
.page-total { min-width: 34px; color: #e8edf4; font-size: 13px; font-variant-numeric: tabular-nums; }
.zoom-value { min-width: 45px; color: #e8edf4; text-align: center; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.fit-width-button { margin-left: 2px; color: #d7deea !important; }
.floating-divider { width: 1px; height: 30px; margin: 0 4px; background: rgba(255,255,255,.2); }

.modal {
  width: min(980px, calc(100vw - 40px));
  max-height: calc(100vh - 48px);
  border: 0;
  border-radius: 18px;
  padding: 0;
  box-shadow: 0 30px 100px rgba(22,30,43,.32);
}
.modal::backdrop { background: rgba(18,24,34,.48); backdrop-filter: blur(2px); }
.modal form { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 22px 24px 14px; border-bottom: 1px solid var(--line); }
.modal h2 { margin: 0; }
.modal p { margin: 18px 24px 0; color: var(--muted); }
.modal-close { width: 38px; height: 38px; border: 0; border-radius: 50%; background: #f0f2f5; font-size: 24px; cursor: pointer; }
.modal footer { padding: 16px 24px; display: flex; justify-content: flex-end; border-top: 1px solid var(--line); }
.manage-grid { padding: 20px 24px; overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px; }
.manage-card { padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: #f8f9fb; cursor: grab; }
.manage-card.dragging { opacity: .45; }
.manage-preview-viewport { width: 100%; overflow: hidden; border-radius: 6px; background: white; }
.manage-card img { display: block; max-width: none; transform-origin: left top; background: white; }
.manage-card strong { display: block; padding: 8px 2px 4px; text-align: center; }
.manage-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.manage-actions button { border: 1px solid #d5d9e0; border-radius: 7px; background: white; padding: 7px 4px; cursor: pointer; }
.manage-actions button:last-child { color: #b31732; }
.primary-button, .secondary-button { min-height: 40px; padding: 0 18px; border-radius: 9px; cursor: pointer; }
.primary-button { border: 0; background: var(--accent); color: white; font-weight: 700; }
.secondary-button { border: 1px solid #d2d7df; background: white; }
.signature-modal {
  width: min(620px, calc(100vw - 32px));
  height: auto;
  max-height: 390px;
}
.signature-modal form { max-height: none; }
.signature-modal header { padding: 16px 20px 12px; }
.signature-modal canvas {
  width: calc(100% - 40px);
  height: 165px;
  flex: 0 0 165px;
  margin: 18px 20px;
  border: 2px dashed #c8ced8;
  border-radius: 12px;
  background: white;
  touch-action: none;
}
.signature-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 0 20px 18px; }

.toast {
  position: fixed;
  z-index: 200;
  left: 50%;
  bottom: 90px;
  transform: translate(-50%, 20px);
  max-width: min(560px, calc(100vw - 32px));
  padding: 12px 18px;
  border-radius: 10px;
  background: #222b38;
  color: white;
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
  box-shadow: 0 10px 30px rgba(22,30,43,.24);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #a91d36; }

@media (max-width: 1180px) {
  .share-button { display: none; }
  .filename-field { width: 190px; }
  .top-header { padding: 0 14px; }
  .page-shell { width: min(790px, calc(100vw - var(--sidebar-width) - 52px)); }
}

@media (max-width: 820px) {
  :root { --sidebar-width: 210px; }
  .brand-button .brand-word { font-size: 25px; }
  .brand-button .brand-symbol { width: 31px; height: 31px; flex-basis: 31px; }
  .filename-field { display: none; }
  .header-tool span:last-child { display: none; }
  .header-tool { min-width: 44px; padding: 0 10px; border: 0; }
  .search-box { width: 44px; min-width: 44px; }
  .search-box input { display: none; }
  .format-label, .range-control span { display: none; }
  .pages-container { padding-left: 20px; padding-right: 20px; }
  .page-shell { width: calc(100vw - 255px); }
  .floating-controls { left: 50%; }
}

@media (max-width: 620px) {
  :root { --sidebar-width: 160px; }
  .page-sidebar { position: absolute; z-index: 30; height: 100%; box-shadow: 10px 0 24px rgba(20,30,45,.15); }
  .page-sidebar.collapsed { margin-left: calc(var(--sidebar-width) * -1); }
  .page-shell { width: calc(100vw - 28px); }
  .pages-container { padding: 16px 14px 100px; }
  .top-header { height: 68px; }
  .workspace { height: calc(100% - 68px - var(--toolbar-height) - var(--format-height)); }
  .brand-button .brand-word { font-size: 22px; }
  .header-tool { height: 48px; }
  .floating-controls { width: calc(100vw - 20px); justify-content: center; bottom: 10px; }
  .upload-card { padding: 30px 22px; }
}
