/* SanitizePDF — Local-First Modern Minimalist UI (Light & Dark Mode Design System) */
:root {
  --bg-primary: #0f172a;
  --bg-header: rgba(30, 41, 59, 0.88);
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --bg-input: #0b1120;
  --bg-canvas-well: #090d16;
  --border-subtle: #334155;
  --border-focus: #10b981;
  --text-main: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-emerald: #10b981;
  --accent-emerald-hover: #059669;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --shadow-canvas: 0 4px 16px rgba(0, 0, 0, 0.55);
  --scrollbar-track: rgba(11, 17, 32, 0.55);
  --scrollbar-thumb: #334155;
  --scrollbar-thumb-hover: #475569;
  --scrollbar-thumb-active: #10b981;
}

body.light-mode {
  --bg-primary: #f8fafc;
  --bg-header: rgba(255, 255, 255, 0.92);
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-input: #f1f5f9;
  --bg-canvas-well: #cbd5e1;
  --border-subtle: #cbd5e1;
  --border-focus: #059669;
  --text-main: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --accent-emerald: #10b981;
  --accent-emerald-hover: #059669;
  --accent-amber: #d97706;
  --accent-rose: #e11d48;
  --shadow-canvas: 0 4px 14px rgba(15, 23, 42, 0.18);
  --scrollbar-track: rgba(226, 232, 240, 0.65);
  --scrollbar-thumb: #cbd5e1;
  --scrollbar-thumb-hover: #94a3b8;
  --scrollbar-thumb-active: #059669;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

/* Custom Scrollbars — Integrated with Dark & Light Palette */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

.datatype-categories-box::-webkit-scrollbar,
.modal-card::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border-radius: 9999px;
}

::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb);
  border-radius: 9999px;
  border: 1.5px solid transparent;
  background-clip: padding-box;
  transition: background-color 0.15s ease;
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--scrollbar-thumb-hover);
}

::-webkit-scrollbar-thumb:active {
  background-color: var(--scrollbar-thumb-active);
}

::-webkit-scrollbar-corner {
  background: transparent;
}

body {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-size: 13.5px;
  line-height: 1.45;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  transition: background-color 0.18s ease, color 0.18s ease;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(8px);
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.brand-subtitle {
  font-size: 10px;
  color: var(--accent-emerald);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.badge-free {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.badge-free:hover {
  border-color: var(--accent-amber);
  color: var(--accent-amber);
}

.badge-pro {
  background: rgba(16, 185, 129, 0.18);
  color: #059669;
  border: 1px solid rgba(16, 185, 129, 0.45);
}

body:not(.light-mode) .badge-pro {
  color: #34d399;
}

.badge-credits {
  background: rgba(16, 185, 129, 0.14);
  color: #059669;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

body:not(.light-mode) .badge-credits {
  color: #34d399;
}

.badge-credits.empty {
  background: rgba(245, 158, 11, 0.16);
  color: var(--accent-amber);
  border-color: rgba(245, 158, 11, 0.45);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  line-height: 1.15;
  padding: 2px 8px;
  border-radius: 8px;
  text-align: center;
  font-size: 10px;
}

.badge-credits.empty .badge-line-top {
  font-weight: 700;
  white-space: nowrap;
}

.badge-credits.empty .badge-line-sub {
  font-size: 9.5px;
  opacity: 0.92;
  white-space: nowrap;
}

body:not(.light-mode) .badge-credits.empty {
  color: #fbbf24;
}

.icon-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}

.icon-btn:hover {
  color: var(--text-main);
  border-color: var(--text-secondary);
  background: var(--bg-card-hover);
}

/* Navigation Tabs */
.nav-tabs {
  display: flex;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 12px;
}

.nav-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
}

.nav-tab:hover {
  color: var(--text-main);
}

.nav-tab.active {
  color: var(--accent-emerald);
  border-bottom-color: var(--accent-emerald);
}

/* Main Content Area */
.container {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tab-panel {
  display: none;
  flex-direction: column;
  gap: 12px;
}

.tab-panel.active {
  display: flex;
}

/* Cards & Sections */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 12px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.card-header.collapsible-header {
  cursor: pointer;
  user-select: none;
  gap: 8px;
}

.card.collapsed .card-header {
  margin-bottom: 0;
}

.card.collapsed .collapsible-body {
  display: none;
}

.collapse-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 10px;
  transition: transform 0.18s ease, color 0.15s ease, border-color 0.15s ease;
  flex-shrink: 0;
}

.card-header.collapsible-header:hover .collapse-chevron {
  color: var(--text-main);
  border-color: var(--text-secondary);
}

.card.collapsed .collapse-chevron {
  transform: rotate(-90deg);
}

.highlight-scans {
  color: #34d399;
  font-weight: 700;
}

body.light-mode .highlight-scans {
  color: #059669;
}

.card-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Country & Categorized Data Type Selector */
.country-selector-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.section-subhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
}

.country-pills-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.country-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}

.country-pill:hover {
  border-color: var(--text-secondary);
  color: var(--text-main);
}

.country-pill.active {
  background: rgba(16, 185, 129, 0.14);
  border-color: var(--accent-emerald);
  color: var(--text-main);
  font-weight: 700;
}

.datatype-categories-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 2px;
}

.datatype-category {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  padding: 7px 9px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.datatype-category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 3px;
}

.datatype-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px 10px;
}

.datatype-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-main);
  cursor: pointer;
  user-select: none;
}

.datatype-item input[type="checkbox"] {
  accent-color: var(--accent-emerald);
  width: 13px;
  height: 13px;
  cursor: pointer;
  flex-shrink: 0;
}

.mini-link-btn {
  background: none;
  border: none;
  color: var(--accent-emerald);
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 0 2px;
  text-decoration: underline;
}

.mini-link-btn:hover {
  opacity: 0.85;
}

.pro-pill {
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(245, 158, 11, 0.2);
  color: var(--accent-amber);
  font-weight: 700;
}

body:not(.light-mode) .pro-pill {
  color: #fbbf24;
}

/* Blind CV Checkmark Options Panel */
.blind-cv-options {
  display: flex;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-subtle);
  flex-direction: column;
  gap: 6px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  accent-color: var(--accent-emerald);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

/* Drag and Drop Zone */
.dropzone {
  border: 2px dashed var(--border-subtle);
  border-radius: 10px;
  background: var(--bg-input);
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.08);
}

.dropzone-icon {
  font-size: 24px;
  margin-bottom: 6px;
  display: block;
}

.dropzone-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 3px;
}

.dropzone-sub {
  font-size: 11px;
  color: var(--text-secondary);
}

/* Workspace Canvas & Preview */
.workspace-area {
  display: none;
  flex-direction: column;
  gap: 10px;
}

.workspace-area.visible {
  display: flex;
}

.toolbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  background: var(--bg-input);
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
}

.page-nav, .zoom-controls {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
}

/* Scrollable Canvas Container — Preserves True Aspect Ratio (Never Flattened) */
.canvas-wrapper {
  position: relative;
  background: var(--bg-canvas-well);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: auto;
  max-height: 380px;
  padding: 12px;
  text-align: center;
}

#pdfCanvas {
  display: inline-block;
  cursor: crosshair;
  box-shadow: var(--shadow-canvas);
  vertical-align: top;
}

.drag-selection-box {
  position: absolute;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.72);
  border: 2px solid #10b981;
  box-sizing: border-box;
  display: none;
  z-index: 5;
}

/* Detection Summary Bar */
.detection-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.35);
  font-size: 11.5px;
  color: var(--text-main);
}

.detection-summary.warning {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.45);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent-emerald);
  color: #052e16;
  font-weight: 700;
}

.btn-primary:hover:not(:disabled) {
  background: #34d399;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-main);
  border-color: var(--border-subtle);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-card-hover);
}

.btn-amber {
  background: rgba(245, 158, 11, 0.18);
  color: var(--accent-amber);
  border-color: rgba(245, 158, 11, 0.45);
}

body:not(.light-mode) .btn-amber {
  color: #fbbf24;
}

.btn-amber:hover:not(:disabled) {
  background: rgba(245, 158, 11, 0.28);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.14);
  color: var(--accent-rose);
  border-color: rgba(244, 63, 94, 0.4);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(244, 63, 94, 0.24);
}

.btn-sm {
  padding: 4px 8px;
  font-size: 11px;
}

.btn-full {
  width: 100%;
  padding: 9px 14px;
  font-size: 12.5px;
}

.export-actions-stack {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

/* Forms & Inputs */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 10px;
}

.form-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-main);
}

.form-microcopy {
  font-size: 10.5px;
  color: var(--text-secondary);
}

.input-field, .select-field {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 12px;
  outline: none;
}

.input-field:focus, .select-field:focus {
  border-color: var(--accent-emerald);
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.radio-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  cursor: pointer;
}

.radio-item input[type="radio"] {
  accent-color: var(--accent-emerald);
}

/* Crawlable Technical Overview (Web Browser Mode Only — Hidden in Installed Standalone PWA) */
.seo-specs {
  padding: 16px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-primary);
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.seo-specs-heading {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.seo-specs-lead {
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.seo-specs-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.seo-specs-item {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.seo-specs-item h3 {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-main);
}

.seo-specs-item p {
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-secondary);
}

@media (max-width: 640px) {
  .seo-specs-grid {
    grid-template-columns: 1fr;
  }
}

@media (display-mode: standalone) {
  .seo-specs {
    display: none;
  }
}

/* Legal Disclaimer Footer */
.legal-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-card);
  font-size: 10px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.legal-links {
  display: flex;
  gap: 12px;
}

.legal-links a {
  color: var(--text-secondary);
  text-decoration: underline;
  cursor: pointer;
}

/* Modals & Toasts */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.78);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.modal-backdrop.open {
  display: flex;
}

.modal-card {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 16px;
  width: 100%;
  max-width: 468px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

/* Subscription Plan Cards (1-Week €9, 1-Month €19, 1-Year €189) */
.plan-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.plan-card {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 9px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  text-align: center;
  text-decoration: none;
  color: var(--text-main);
  transition: all 0.16s ease;
  position: relative;
  gap: 4px;
}

.plan-card:hover {
  border-color: var(--accent-emerald);
  transform: translateY(-1px);
}

.plan-card.popular {
  border-color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.1);
}

.plan-badge {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 9999px;
  background: rgba(148, 163, 184, 0.18);
  color: var(--text-secondary);
}

.plan-card.popular .plan-badge {
  background: rgba(16, 185, 129, 0.22);
  color: var(--accent-emerald);
}

body:not(.light-mode) .plan-card.popular .plan-badge {
  color: #34d399;
}

.plan-name {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-main);
}

.plan-price {
  font-size: 14px;
  font-weight: 800;
  color: var(--accent-emerald);
}

body:not(.light-mode) .plan-price {
  color: #34d399;
}

.plan-period {
  font-size: 10px;
  color: var(--text-secondary);
}

.plan-cta {
  margin-top: 4px;
  width: 100%;
  padding: 5px 6px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 700;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
}

.plan-card.popular .plan-cta {
  background: var(--accent-emerald);
  border-color: var(--accent-emerald);
  color: #052e16;
}

/* Friendly Out-of-Credits Notice Box */
.out-of-credits-banner {
  display: none;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.45);
  font-size: 11.5px;
}

.out-of-credits-banner.visible {
  display: flex;
}

/* Legal / EULA Clickwrap & Scrollable Policy Box */
#modalLegal {
  z-index: 60;
}

.legal-prompt-notice {
  display: none;
  padding: 8px 10px;
  margin-bottom: 10px;
  border-radius: 7px;
  background: rgba(245, 158, 11, 0.13);
  border: 1px solid rgba(245, 158, 11, 0.45);
  color: var(--text-main);
  font-size: 11.5px;
  line-height: 1.42;
}

.legal-prompt-notice.visible {
  display: block;
}

.legal-scroll-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 11.5px;
  line-height: 1.48;
  color: var(--text-secondary);
  max-height: 350px;
  overflow-y: auto;
  padding-right: 6px;
}

.legal-section-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.legal-section-block + .legal-section-block {
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.legal-section-heading {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-emerald);
  letter-spacing: 0.01em;
}

body:not(.light-mode) .legal-section-heading {
  color: #34d399;
}

.legal-scroll-box p {
  margin: 0;
}

.legal-scroll-box strong {
  color: var(--text-main);
}

.legal-scroll-box code {
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  font-size: 10.5px;
  color: var(--text-main);
}

.legal-full-policy-row {
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
  font-size: 11px;
  color: var(--text-muted);
}

.legal-full-policy-row a {
  color: var(--accent-emerald);
  font-weight: 600;
  text-decoration: underline;
}

body:not(.light-mode) .legal-full-policy-row a {
  color: #34d399;
}

.toast-container {
  position: fixed;
  bottom: 14px;
  right: 14px;
  left: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 100;
  pointer-events: none;
}

.toast {
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--accent-emerald);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toast.error {
  border-left-color: var(--accent-rose);
}

.toast.warning {
  border-left-color: var(--accent-amber);
}

/* ============================================================================
   MOBILE & TABLET PWA ERGONOMICS (Android, iPhone & iPad)
   ============================================================================ */

.pwa-install-banner {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 14px;
  background: rgba(16, 185, 129, 0.12);
  border-bottom: 1px solid rgba(16, 185, 129, 0.35);
  font-size: 12px;
  color: var(--text-main);
}

.pwa-install-banner.visible {
  display: flex;
}

.pwa-install-text {
  flex: 1;
  line-height: 1.35;
}

.pwa-install-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.quick-links-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.summary-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.toolbar-row-top,
.toolbar-row-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-touch-mode {
  padding: 6px 10px;
  font-size: 11.5px;
  font-weight: 700;
  border-radius: 7px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-main);
}

.btn-touch-mode.active-draw {
  background: rgba(16, 185, 129, 0.16);
  border-color: var(--accent-emerald);
  color: var(--accent-emerald);
}

body:not(.light-mode) .btn-touch-mode.active-draw {
  color: #34d399;
}

.btn-touch-mode.active-pan {
  background: rgba(245, 158, 11, 0.16);
  border-color: var(--accent-amber);
  color: var(--accent-amber);
}

body:not(.light-mode) .btn-touch-mode.active-pan {
  color: #fbbf24;
}

.btn-touch-lg {
  padding: 12px 16px;
  font-size: 13.5px;
  border-radius: 9px;
}

#pdfCanvas.touch-draw-mode {
  touch-action: none;
}

#pdfCanvas.touch-pan-mode {
  touch-action: pan-x pan-y pinch-zoom;
}

.intercept-pills-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.intercept-match-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: var(--accent-amber);
}

body:not(.light-mode) .intercept-match-pill {
  color: #fbbf24;
}

.intercept-match-pill.meta {
  background: rgba(244, 63, 94, 0.14);
  border-color: rgba(244, 63, 94, 0.4);
  color: var(--accent-rose);
}

.guide-box {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 10px 12px;
  line-height: 1.45;
}

.guide-box-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}

/* Tablet & Desktop Workspace Proportions (iPad Portrait, Landscape & Split View) */
@media (min-width: 641px) {
  body {
    max-width: 840px;
  }

  .datatype-categories-box {
    max-height: 260px;
  }

  .canvas-wrapper {
    max-height: 62dvh;
    min-height: 400px;
  }
}

/* Universal Touch-Screen Targets & Safari Input Zoom Guard (iPad, iPhone & Android) */
@media (pointer: coarse) {
  .icon-btn {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }

  .country-pill {
    padding: 7px 11px;
    font-size: 12px;
    min-height: 36px;
  }

  .datatype-item {
    font-size: 12.5px;
    min-height: 30px;
  }

  .datatype-item input[type="checkbox"],
  .checkbox-label input[type="checkbox"],
  .radio-item input[type="radio"] {
    width: 18px;
    height: 18px;
  }

  .mini-link-btn {
    font-size: 12px;
    padding: 4px 6px;
  }

  .btn-sm {
    padding: 7px 10px;
    font-size: 12px;
    min-height: 34px;
  }

  /* Prevent iOS & iPadOS Safari auto-zoom on input focus (requires >= 16px) */
  .input-field,
  .select-field {
    font-size: 16px;
    padding: 9px 11px;
  }
}

/* Phone Viewport Optimizations (Android Phones & iPhones <= 640px) */
@media (max-width: 640px) {
  body {
    padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px));
  }

  .app-header {
    padding: 10px 12px;
  }

  .brand-title {
    font-size: 14px;
  }

  .brand-subtitle {
    font-size: 9px;
  }

  .icon-btn {
    width: 34px;
    height: 34px;
    font-size: 14px;
  }

  /* Bottom App Navigation Bar for 1-Handed Thumb Reach */
  .nav-tabs {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 40;
    padding: 4px 8px calc(4px + env(safe-area-inset-bottom, 0px));
    border-bottom: none;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-header);
    backdrop-filter: blur(12px);
    justify-content: space-around;
  }

  .nav-tab {
    flex: 1;
    flex-direction: column;
    gap: 2px;
    padding: 6px 4px;
    font-size: 11px;
    border-bottom: none;
    border-radius: 8px;
  }

  .nav-tab.active {
    background: rgba(16, 185, 129, 0.12);
  }

  .nav-tab-icon {
    font-size: 15px;
  }

  /* Larger Touch Targets for Narrow Viewports */
  .country-pill {
    padding: 7px 11px;
    font-size: 12px;
    min-height: 36px;
  }

  .datatype-grid {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .datatype-item {
    font-size: 12.5px;
    min-height: 30px;
  }

  .datatype-item input[type="checkbox"],
  .checkbox-label input[type="checkbox"],
  .radio-item input[type="radio"] {
    width: 18px;
    height: 18px;
  }

  .mini-link-btn {
    font-size: 12px;
    padding: 4px 6px;
  }

  .btn-sm {
    padding: 7px 10px;
    font-size: 12px;
    min-height: 34px;
  }

  /* Prevent iOS Safari input auto-zoom on focus (requires >= 16px) */
  .input-field,
  .select-field {
    font-size: 16px;
    padding: 9px 11px;
  }

  .canvas-wrapper {
    max-height: 56dvh;
    padding: 8px;
  }

  /* Bottom Sheet Presentation for Modals on Phones */
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal-card {
    max-width: 100%;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    padding: 16px 16px calc(18px + env(safe-area-inset-bottom, 0px));
    max-height: 90dvh;
  }

  .toast-container {
    bottom: calc(74px + env(safe-area-inset-bottom, 0px));
  }
}
