:root {
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-hover: #e2e8f0;
  --text-main: #0f172a;
  --text-primary: #0f172a;
  --text-muted: #64748b;
  --border-color: #cbd5e1;
  --primary-color: #e11d48;
  --primary-hover: #be123c;
  --primary-light: #fff1f2;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --canvas-bg: #e2e8f0;
}

[data-theme="dark"] {
  --bg-app: #0b0f19;
  --bg-surface: #0f172a;
  --bg-subtle: #1e293b;
  --bg-hover: #334155;
  --text-main: #f8fafc;
  --text-primary: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: #334155;
  --primary-color: #f43f5e;
  --primary-hover: #e11d48;
  --primary-light: rgba(225, 29, 72, 0.15);
  --canvas-bg: #0b0f19;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  color: var(--text-main);
  background: var(--bg-app);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select { font: inherit; color: inherit; }
.ic { width: 16px; height: 16px; }
.ic-sm { width: 14px; height: 14px; }
.muted { color: var(--text-muted); }
.primary-t { color: var(--primary-color); }

/* Header */
.header {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 48px;
  padding: 0 16px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  position: relative;
  z-index: 1000;
  flex-shrink: 0;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  color: var(--primary-color);
  letter-spacing: -0.3px;
}
.logo svg, .logo i { font-size: 18px; }
.title {
  width: 220px;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 4px 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  background: transparent;
  outline: none;
  transition: all 0.15s ease;
}
.title:hover {
  background: var(--bg-subtle);
  border-color: var(--border-color);
}
.title:focus {
  background: var(--bg-surface);
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px var(--primary-light);
}
.status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-muted);
}
.badge {
  border: 1px solid rgba(225, 29, 72, 0.25);
  background: var(--primary-light);
  color: var(--primary-color);
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 12px;
  font-weight: 600;
}
.header-right-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-main);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
  transition: all 0.15s ease;
}
.btn:hover {
  background: var(--bg-subtle);
  border-color: var(--text-muted);
}
.btn-primary {
  background: var(--primary-color);
  color: #fff;
  border-color: var(--primary-color);
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #fff;
}

/* Language Button */
.btn-lang-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}
.btn-lang-toggle:hover {
  background-color: var(--bg-subtle);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

/* Menu Bar (Standard Suite Styling matching Docs, Sheets, Slides) */
.menu-bar, .menubar {
  height: 28px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 2px;
  font-size: 0.82rem;
  position: relative;
  z-index: 500;
  flex-shrink: 0;
}

.menu-item {
  position: relative;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-main);
  font-weight: 500;
  user-select: none;
  transition: background-color 0.12s ease;
}

.menu-item:hover, .menu-item.active {
  background-color: var(--border-color);
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  box-shadow: var(--shadow-lg);
  min-width: 250px;
  padding: 6px 0;
  z-index: 600;
}

.menu-item.active > .dropdown-menu {
  display: block;
}

.dropdown-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 7px 14px;
  background: none;
  border: none;
  text-align: left;
  font-size: 0.82rem;
  color: var(--text-main);
  cursor: pointer;
  gap: 10px;
  transition: all 0.12s ease;
  user-select: none;
}

.dropdown-item i {
  width: 16px;
  text-align: center;
  color: var(--text-muted);
  flex-shrink: 0;
  font-size: 13px;
}

.dropdown-item:hover {
  background-color: var(--primary-light);
  color: var(--primary-color);
}

.dropdown-item:hover i {
  color: var(--primary-color);
}

.dropdown-item .shortcut,
.dropdown-item .menu-shortcut {
  margin-left: auto;
  padding-left: 16px;
  font-size: 0.72rem;
  color: var(--text-muted);
  direction: ltr;
  unicode-bidi: isolate;
  display: inline-block;
  white-space: nowrap;
  flex-shrink: 0;
}

html[dir="rtl"] .dropdown-menu {
  left: auto;
  right: 0;
}

html[dir="rtl"] .dropdown-item {
  text-align: right;
}

html[dir="rtl"] .dropdown-item .shortcut,
html[dir="rtl"] .dropdown-item .menu-shortcut {
  margin-left: 0;
  margin-right: auto;
  padding-left: 0;
  padding-right: 16px;
}

html[dir="rtl"] .dropdown-item .submenu-arrow {
  margin-left: 0;
  margin-right: auto;
  padding-left: 0;
  padding-right: 12px;
  transform: scaleX(-1);
}

html[data-platform="mac"] .shortcut[data-mac],
html[data-platform="mac"] .menu-shortcut[data-mac] {
  font-size: 0 !important;
}
html[data-platform="mac"] .shortcut[data-mac]::before,
html[data-platform="mac"] .menu-shortcut[data-mac]::before {
  content: attr(data-mac);
  font-size: 0.72rem !important;
  color: var(--text-muted);
  direction: ltr;
  unicode-bidi: isolate;
  display: inline-block;
}
html[data-platform="windows"] .shortcut[data-win],
html[data-platform="windows"] .menu-shortcut[data-win] {
  font-size: 0 !important;
}
html[data-platform="windows"] .shortcut[data-win]::before,
html[data-platform="windows"] .menu-shortcut[data-win]::before {
  content: attr(data-win);
  font-size: 0.72rem !important;
  color: var(--text-muted);
  direction: ltr;
  unicode-bidi: isolate;
  display: inline-block;
}

.dropdown-item .submenu-arrow {
  margin-left: auto;
  padding-left: 12px;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.dropdown-menu hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 5px 0;
}

/* Submenu & Flyout Menus */
.dropdown-submenu-item {
  position: relative;
}

.dropdown-submenu-item:hover > .submenu-flyout {
  display: block !important;
}

.submenu-flyout {
  display: none;
  position: absolute;
  top: -6px;
  left: 100%;
  min-width: 250px;
}

html[dir="rtl"] .submenu-flyout {
  left: auto;
  right: 100%;
}

.dropdown-header {
  padding: 4px 14px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.doc-recent-item {
  display: flex !important;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
}

/* Recent Documents Modal List */
.pdf-doc-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 8px;
  background: var(--bg-surface);
  transition: all 0.15s ease;
}
.pdf-doc-list-item:hover {
  border-color: var(--primary-color);
  background: var(--primary-light);
}
.pdf-doc-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}
.pdf-doc-name {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pdf-doc-time {
  font-size: 0.74rem;
  color: var(--text-muted);
}
.pdf-doc-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 12px;
}

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 42px;
  padding: 0 10px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
  flex-shrink: 0;
}
.tb {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  min-width: 30px;
  padding: 0 6px;
  border-radius: 5px;
  color: var(--text-main);
  transition: all 0.12s ease;
}
.tb:hover {
  background: var(--bg-hover);
}
.tb:disabled {
  opacity: .35;
  cursor: default;
}
.tb.active {
  background: var(--primary-light);
  color: var(--primary-color);
  box-shadow: inset 0 0 0 1px rgba(225, 29, 72, 0.4);
}
.sep {
  width: 1px;
  height: 22px;
  background: var(--border-color);
  margin: 0 5px;
  flex-shrink: 0;
}
.field {
  height: 30px;
  border: 1px solid var(--border-color);
  border-radius: 5px;
  padding: 0 8px;
  background: var(--bg-surface);
  color: var(--text-main);
  outline: none;
}
.field:focus {
  border-color: var(--primary-color);
}
.swatch {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  display: inline-block;
  box-shadow: var(--shadow-sm);
}
.zoomlbl {
  min-width: 46px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

/* App Body & Sidebar */
.body {
  display: flex;
  flex: 1;
  min-height: 0;
  background: var(--canvas-bg);
}
.sidebar {
  width: 220px;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  flex-shrink: 0;
}
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--text-muted);
  text-transform: uppercase;
}
.mini {
  border: 1px solid var(--border-color);
  border-radius: 5px;
  padding: 4px;
  display: flex;
  color: var(--text-muted);
  transition: all 0.12s ease;
}
.mini:hover {
  background: var(--bg-hover);
  color: var(--primary-color);
  border-color: var(--primary-color);
}
.thumbs {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.thumb {
  display: flex;
  gap: 10px;
  text-align: left;
  border-radius: 6px;
  padding: 4px;
  transition: all 0.12s ease;
}
.thumb:hover {
  background: var(--bg-subtle);
}
.thumb.cur {
  background: var(--primary-light);
}
.thumb .num {
  width: 18px;
  padding-top: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.thumb.cur .num {
  color: var(--primary-color);
}
.thumb .frame {
  border: 2px solid var(--border-color);
  border-radius: 6px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease;
}
.thumb.cur .frame {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px var(--primary-light);
}

/* Canvas & Document Pages */
.canvas {
  flex: 1;
  overflow: auto;
  background: var(--canvas-bg);
}
.pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  padding: 36px 0;
}
.openhint {
  border: 2px dashed rgba(225, 29, 72, 0.4);
  background: var(--bg-surface);
  color: var(--primary-color);
  border-radius: 10px;
  padding: 16px 28px;
  font-weight: 600;
  font-size: 14px;
  box-shadow: var(--shadow-md);
  transition: all 0.15s ease;
}
.openhint:hover {
  background: var(--primary-light);
  border-color: var(--primary-color);
  transform: translateY(-1px);
}
.page {
  position: relative;
  background: #ffffff;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.18), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  border-radius: 3px;
  transition: box-shadow 0.15s ease;
}
.page.cur {
  box-shadow: 0 0 0 2px var(--primary-color), 0 15px 30px -5px rgba(0, 0, 0, 0.25);
}
.page canvas { display: block; border-radius: 3px; }
.overlay { position: absolute; inset: 0; touch-action: none; border-radius: 3px; }
.overlay svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.ann { position: absolute; }
.ann.sel { outline: 2px dashed var(--primary-color); }
.ann img { width: 100%; height: 100%; user-select: none; display: block; }
.ann .txt {
  width: 100%;
  height: 100%;
  white-space: pre;
  padding: 2px;
  line-height: 1.2;
  outline: none;
  font-family: Helvetica, Arial, sans-serif;
  min-width: 20px;
}
.handle {
  position: absolute;
  right: -6px;
  bottom: -6px;
  width: 12px;
  height: 12px;
  border: 1.5px solid var(--primary-color);
  background: #ffffff;
  border-radius: 3px;
  cursor: se-resize;
  box-shadow: var(--shadow-sm);
}

/* Floating Actions Pill */
.obj-floating-actions {
  position: absolute;
  top: -38px;
  left: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #0f172a;
  color: #fff;
  padding: 4px 8px;
  border-radius: 6px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.45), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
  z-index: 200;
  pointer-events: auto;
  white-space: nowrap;
}
.obj-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 24px;
  padding: 0 10px;
  font-size: 11.5px;
  font-weight: 500;
  color: #f1f5f9;
  background: rgba(255, 255, 255, 0.14);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.12s ease;
  user-select: none;
  line-height: 1;
}
.obj-action-btn i {
  font-size: 11px;
  display: inline-block;
  line-height: 1;
  color: inherit;
}
.obj-action-btn:hover {
  background: rgba(255, 255, 255, 0.28);
  color: #fff;
}
.obj-action-btn.danger:hover {
  background: #e11d48;
  color: #fff;
}
.obj-badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #94a3b8;
  margin-right: 2px;
  font-weight: 600;
}

/* Interactive Content Detection Layer (Text & Images) */
.pdf-content-detect-layer,
.pdf-text-detect-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}
.text-detect-hit {
  position: absolute;
  pointer-events: auto;
  cursor: text;
  border-radius: 2px;
  transition: background 0.1s ease;
}
.text-detect-hit:hover {
  background-color: rgba(225, 29, 72, 0.15);
  box-shadow: 0 0 0 1px rgba(225, 29, 72, 0.4);
}
.image-detect-hit {
  position: absolute;
  pointer-events: auto;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.12s ease;
}
.image-detect-hit:hover {
  background-color: rgba(37, 99, 235, 0.12);
  box-shadow: 0 0 0 2px #2563eb;
}
.ann.edited-item {
  box-shadow: 0 0 0 1px rgba(225, 29, 72, 0.3);
}

/* Theme Toggle Button in Header */
#btn-theme-toggle {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* PWA Installation Button */
.btn-pwa-install {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: var(--primary-light);
  color: var(--primary-color);
  border: 1px solid var(--primary-color);
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  margin-right: 6px;
}

.btn-pwa-install:hover {
  background-color: var(--primary-color);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.btn-pwa-install:active {
  transform: translateY(0);
}

[data-pwa-installed="true"] .btn-pwa-install {
  display: none !important;
}

/* Help Modals (Shortcuts, About, Feedback) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: modalFadeIn 0.15s ease-out;
}
@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
  max-width: 95vw;
  width: 580px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalPopIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-sm { width: 440px; }
.modal-lg { width: 680px; }

@keyframes modalPopIn {
  from { transform: scale(0.96); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
  position: relative;
}
.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  padding: 4px 8px;
  transition: all 0.15s ease;
}
.modal-close:hover {
  color: #ef4444;
  background-color: #fee2e2;
}

.modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  font-size: 0.88rem;
  line-height: 1.5;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-subtle);
}

.shortcut-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}
.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: 6px;
}
.shortcut-key {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.76rem;
  padding: 2px 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  box-shadow: 0 1px 1px rgba(0,0,0,0.08);
}

/* ==========================================================================
   Mobile & Responsive Layout Enhancements (<= 768px and <= 480px)
   ========================================================================== */

/* Toggle Button for Page Thumbnails Drawer on Mobile */
.btn-pages-toggle {
  display: none;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s ease;
}
.btn-pages-toggle:hover {
  background: var(--bg-hover);
  border-color: var(--primary-color);
  color: var(--primary-color);
}
.btn-pages-toggle.active {
  background: var(--primary-light);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

@media screen and (max-width: 768px) {
  /* Header: Horizontal Scroll without clipping */
  .header {
    height: 44px;
    padding: 0 8px;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  .header::-webkit-scrollbar {
    display: none;
  }
  .logo {
    font-size: 14px;
    gap: 6px;
    flex-shrink: 0;
  }
  .title {
    width: 140px;
    font-size: 13px;
    flex-shrink: 0;
  }
  .status {
    display: none;
  }
  .badge {
    padding: 2px 8px;
    font-size: 11px;
    flex-shrink: 0;
  }
  .header-right-actions {
    gap: 5px;
    flex-shrink: 0;
  }
  .header-right-actions .btn {
    padding: 4px 8px;
    font-size: 11.5px;
    gap: 4px;
  }

  /* Menubar: Smooth Horizontal Scroll */
  .menu-bar, .menubar {
    height: 32px;
    padding: 0 6px;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  .menu-bar::-webkit-scrollbar, .menubar::-webkit-scrollbar {
    display: none;
  }
  .menu-item {
    padding: 5px 8px;
    font-size: 0.8rem;
    flex-shrink: 0;
  }

  /* Toolbar: Smooth Touch Horizontal Scroll */
  .toolbar {
    height: 42px;
    padding: 0 6px;
    gap: 2px;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  .toolbar::-webkit-scrollbar {
    display: none;
  }
  .tb {
    height: 32px;
    min-width: 32px;
    padding: 0 6px;
    flex-shrink: 0;
  }
  .field {
    height: 30px;
    font-size: 12px;
    flex-shrink: 0;
  }

  /* Show Drawer Toggle for Thumbnails */
  .btn-pages-toggle {
    display: inline-flex;
  }

  /* App Body & Sidebar Drawer */
  .body {
    position: relative;
    overflow: hidden;
  }
  .sidebar {
    position: fixed;
    top: 118px; /* header + menubar + toolbar */
    bottom: 0;
    left: 0;
    width: 200px;
    z-index: 850;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.25);
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 840;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }
  .sidebar-backdrop.active {
    display: block;
  }

  /* Canvas and Document Pages */
  .canvas {
    padding: 0;
    width: 100%;
    -webkit-overflow-scrolling: touch;
  }
  .pages {
    padding: 16px 8px 40px;
    gap: 16px;
    width: 100%;
    min-width: 0;
  }
  .page {
    max-width: 100% !important;
    height: auto !important;
  }
  .page canvas {
    max-width: 100% !important;
    height: auto !important;
  }
  .openhint {
    font-size: 12.5px;
    padding: 12px 16px;
    text-align: center;
    max-width: 90vw;
  }

  /* Modals on Mobile */
  .modal-card {
    width: 95vw !important;
    max-width: 95vw !important;
    max-height: 85vh;
  }
  .modal-header {
    padding: 12px 16px;
  }
  .modal-body {
    padding: 14px 16px;
  }
  .modal-footer {
    padding: 10px 16px;
  }
  .shortcut-grid {
    grid-template-columns: 1fr;
  }
}

@media screen and (max-width: 480px) {
  .logo span, .logo font {
    display: none;
  }
  .title {
    width: 110px;
  }
  .header-right-actions .btn span {
    display: none;
  }
  .header-right-actions .btn {
    padding: 5px 8px;
  }
}

/* ==========================================================================
   Interactive PDF Form Fields & Field Designer
   ========================================================================== */

.ann-form-field {
  position: absolute;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  user-select: none;
}

.ann-form-field.sel {
  outline: 2px dashed #0284c7 !important;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.25);
}

.ann-form-field.preview-mode {
  outline: none !important;
  box-shadow: none !important;
}

/* Text Field (Single & Multiline) */
.form-input-text {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  border: 1px solid #94a3b8;
  background-color: #f8fafc;
  color: #0f172a;
  padding: 4px 6px;
  font-family: Helvetica, Arial, sans-serif;
  font-size: 13px;
  border-radius: 3px;
  outline: none;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
  resize: none;
}

.form-input-text:hover {
  background-color: #ffffff;
  border-color: #64748b;
}

.form-input-text:focus {
  background-color: #ffffff;
  border-color: #0284c7;
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.2);
}

.form-input-text::placeholder {
  color: #94a3b8;
  font-style: italic;
}

/* Checkbox Field */
.form-checkbox-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.form-checkbox-custom {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  border: 1.5px solid #64748b;
  border-radius: 3px;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.form-checkbox-custom:hover {
  border-color: #0284c7;
  background-color: #f0f9ff;
}

.form-checkbox-custom.checked {
  background: #0284c7;
  border-color: #0284c7;
  color: #ffffff;
}

.form-checkbox-custom svg {
  width: 80%;
  height: 80%;
  stroke: #ffffff;
  stroke-width: 3;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Radio Button Field */
.form-radio-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.form-radio-custom {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  border: 1.5px solid #64748b;
  border-radius: 50%;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.form-radio-custom:hover {
  border-color: #0284c7;
  background-color: #f0f9ff;
}

.form-radio-custom.checked {
  border-color: #0284c7;
}

.form-radio-dot {
  width: 50%;
  height: 50%;
  border-radius: 50%;
  background-color: #0284c7;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

/* Dropdown Field */
.form-select-custom {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  border: 1px solid #94a3b8;
  background-color: #f8fafc;
  color: #0f172a;
  padding: 2px 24px 2px 6px;
  font-family: Helvetica, Arial, sans-serif;
  font-size: 13px;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 12px;
}

.form-select-custom:hover {
  background-color: #ffffff;
  border-color: #64748b;
}

.form-select-custom:focus {
  background-color: #ffffff;
  border-color: #0284c7;
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.2);
}

/* Field Badge (Shown during form design) */
.form-field-badge {
  position: absolute;
  top: -19px;
  left: 0;
  background: #0284c7;
  color: #ffffff;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  pointer-events: none;
  white-space: nowrap;
  letter-spacing: 0.02em;
  line-height: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  z-index: 5;
}

/* Form Properties Modal */
#form-props-modal .field-group {
  margin-bottom: 14px;
}

#form-props-modal .field-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-color);
  margin-bottom: 5px;
}

#form-props-modal .field-group input[type="text"],
#form-props-modal .field-group textarea,
#form-props-modal .field-group select {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 10px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text-color);
  font-size: 0.85rem;
}

#form-props-modal .field-group textarea {
  min-height: 80px;
  font-family: inherit;
  resize: vertical;
}

#form-props-modal .checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--text-color);
  cursor: pointer;
}

