@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700;800&display=swap');

:root {
  --bg: #F4F6FA;
  --desk: #E8EDF4;
  --surface: #FFFFFF;
  --surface-muted: #F8FAFC;
  --border: #E2E8F0;
  --border-strong: #CBD5E1;
  --ink: #0F172A;
  --ink-secondary: #475569;
  --ink-muted: #64748B;
  --primary: #1673B9;
  --primary-dark: #0E4F86;
  --primary-soft: #EBF4FC;
  --success: #059669;
  --success-soft: #ECFDF5;
  --danger: #DC2626;
  --danger-soft: #FEF2F2;
  --warning: #D97706;
  --warning-soft: #FFFBEB;
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 10px 28px rgba(15, 23, 42, 0.09);
  --shadow-paper: 0 16px 44px rgba(15, 23, 42, 0.14);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --font-sans: 'Cairo', 'Segoe UI', Tahoma, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select {
  font-family: var(--font-sans);
}

/* Never trigger iOS auto-zoom on input focus */
input, textarea, select {
  font-size: 16px;
}

.hidden {
  display: none !important;
}

/* ==================== Shared Calm Buttons ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: background 0.14s, border-color 0.14s, transform 0.1s, opacity 0.14s;
}
.btn:hover:not(:disabled) {
  background: var(--surface-muted);
}
.btn:active:not(:disabled) {
  transform: scale(0.97);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-lg {
  height: 48px;
  padding: 0 20px;
  font-size: 15px;
  border-radius: 14px;
}
.btn-sm {
  height: 34px;
  padding: 0 10px;
  font-size: 12.5px;
  border-radius: 10px;
}
.btn-icon {
  width: 40px;
  padding: 0;
}
.btn-icon-sm {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 10px;
}
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #FFFFFF;
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}
.btn-dark {
  background: var(--ink);
  border-color: var(--ink);
  color: #FFFFFF;
}
.btn-dark:hover:not(:disabled) {
  background: #1E293B;
}
.btn-success {
  background: var(--success);
  border-color: var(--success);
  color: #FFFFFF;
}
.btn-success:hover:not(:disabled) {
  background: #047857;
}
.btn-danger-outline {
  background: var(--danger-soft);
  border-color: #FECACA;
  color: var(--danger);
}
.btn-danger-outline:hover:not(:disabled) {
  background: #FEE2E2;
}
.btn-active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-dark);
}

/* ==================== Screen 1: Login Gate ==================== */
.login-shell {
  height: 100dvh;
  width: 100%;
  overflow-y: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 410px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 28px 24px;
  box-shadow: var(--shadow-md);
}

.brand-mark {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--primary-soft);
  border: 1px solid #C8E1F6;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
}

.login-title {
  margin: 0;
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  color: var(--ink);
}

.login-sub {
  margin: 6px 0 22px;
  text-align: center;
  font-size: 13.5px;
  color: var(--ink-secondary);
  line-height: 1.5;
}

.field-group {
  margin-bottom: 14px;
}
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
}
.field-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.field-input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1.4px solid var(--border-strong);
  background: var(--surface-muted);
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.field-input:focus {
  border-color: var(--primary);
  background: var(--surface);
}
.field-textarea {
  width: 100%;
  min-height: 74px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1.4px solid var(--border-strong);
  background: var(--surface-muted);
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
  resize: vertical;
  outline: none;
}
.field-textarea:focus {
  border-color: var(--primary);
  background: var(--surface);
}
#loginPass {
  padding-right: 46px;
}
.eye-btn {
  position: absolute;
  right: 8px;
  left: auto;
  background: transparent;
  border: none;
  color: var(--ink-muted);
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 8px;
}
.error-banner {
  background: var(--danger-soft);
  border: 1px solid #FECACA;
  color: var(--danger);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 14px;
  text-align: center;
}

/* ==================== Screen 2: Files Hub ==================== */
.hub-shell {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.hub-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.hub-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.hub-brand-badge {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.hub-title {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
}
.hub-subtitle {
  font-size: 12px;
  color: var(--ink-muted);
  font-weight: 600;
}

.hub-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.hub-container {
  max-width: 1120px;
  margin: 0 auto;
}

.hub-hero-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 16px;
}

.file-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: transform 0.14s, border-color 0.14s, box-shadow 0.14s;
}
.file-card:hover {
  border-color: #B6D6F2;
  box-shadow: var(--shadow-md);
}

.file-thumb {
  height: 158px;
  background: #F8FAFC;
  border-bottom: 1px solid var(--border);
  position: relative;
  padding: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.file-thumb-paper {
  width: 100%;
  height: 100%;
  max-width: 210px;
  aspect-ratio: 297 / 210;
  background: #FFFFFF;
  border: 1px solid #CBD5E1;
  border-radius: 4px;
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.08);
  overflow: hidden;
}
.file-thumb svg {
  width: 100%;
  height: 100%;
  display: block;
}

.file-info {
  padding: 14px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}
.file-name {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.35;
  cursor: pointer;
}
.file-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--ink-muted);
  font-weight: 600;
}
.meta-pill {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11.5px;
  color: var(--ink-secondary);
}
.file-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  padding-top: 6px;
}

/* ==================== Screen 3: A4 Workspace Editor ==================== */
.editor-shell {
  height: 100dvh;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--desk);
  user-select: none;
}

.editor-topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
  z-index: 30;
}

.editor-topbar > .topbar-group:first-child {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.editor-topbar > .topbar-group:last-child {
  flex-shrink: 0;
}

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

.topbar-group > button,
.topbar-group > .save-badge {
  flex-shrink: 0;
}

.doc-title-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 0 1 auto;
  max-width: 240px;
  overflow: hidden;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}
.doc-title-btn:hover {
  background: var(--surface-muted);
  border-color: var(--border);
}
.doc-title-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.save-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  background: var(--success-soft);
  color: var(--success);
  white-space: nowrap;
}
.save-badge.saving {
  background: var(--primary-soft);
  color: var(--primary-dark);
}
.save-badge.error {
  background: var(--warning-soft);
  color: var(--warning);
}

/* Floating Guided Mode Banner (Link Mode — no canvas layout jump!) */
.mode-banner {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 24px);
  background: rgba(15, 23, 42, 0.94);
  color: #FFFFFF;
  padding: 9px 14px;
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  z-index: 29;
  text-align: center;
}
.mode-banner .btn-cancel-link {
  height: 30px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.14);
  color: #FFFFFF;
  font-weight: 700;
  font-size: 12.5px;
  cursor: pointer;
  flex-shrink: 0;
}

/* Viewport & A4 Drafting Surface */
.canvas-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  background-color: var(--desk);
  background-image: radial-gradient(rgba(15, 23, 42, 0.08) 1px, transparent 1px);
  background-size: 20px 20px;
  cursor: grab;
}
.canvas-viewport.panning {
  cursor: grabbing;
}

.canvas-stage {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.a4-sheet {
  width: 1123px;
  height: 794px;
  background: #FFFFFF;
  position: relative;
  box-shadow: var(--shadow-paper);
  border: 1px solid #CBD5E1;
  border-radius: 3px;
  overflow: hidden;
}

.a4-grid-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(15, 23, 42, 0.035) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(15, 23, 42, 0.035) 1px, transparent 1px);
  background-size: 20px 20px;
}

.a4-print-margins {
  position: absolute;
  inset: 14px;
  border: 1px dashed rgba(22, 115, 185, 0.14);
  pointer-events: none;
}

/* Editable Paper Header & Footer inside A4 */
.sheet-header {
  position: absolute;
  top: 16px;
  left: 26px;
  right: 26px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px dashed transparent;
  cursor: pointer;
  z-index: 5;
  direction: ltr;
}
.sheet-header:hover {
  border-color: #93C5FD;
  background: rgba(235, 244, 252, 0.45);
}
.sheet-logo-box {
  height: 44px;
  min-width: 90px;
  max-width: 190px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
}
.sheet-logo-box img {
  max-height: 42px;
  max-width: 170px;
  object-fit: contain;
}
.sheet-logo-placeholder {
  font-size: 11px;
  font-weight: 700;
  color: #94A3B8;
  border: 1px dashed #CBD5E1;
  padding: 5px 10px;
  border-radius: 6px;
}
.sheet-title-wrap {
  flex: 1;
  text-align: center;
}
.sheet-title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  color: #334155;
  line-height: 1.2;
}
.sheet-subtitle {
  font-size: 11px;
  font-weight: 600;
  color: #64748B;
}
.sheet-header-spacer {
  min-width: 90px;
  display: flex;
  justify-content: flex-end;
}

.sheet-footer {
  position: absolute;
  bottom: 14px;
  left: 26px;
  right: 26px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px dashed transparent;
  cursor: pointer;
  z-index: 5;
  direction: ltr;
}
.sheet-footer:hover {
  border-color: #93C5FD;
  background: rgba(235, 244, 252, 0.45);
}
.footer-approved {
  font-size: 11.5px;
  font-weight: 700;
  color: #1E293B;
}
.footer-date-badge {
  font-size: 11px;
  font-weight: 700;
  color: #1E293B;
  border: 1.2px solid #475569;
  padding: 4px 12px;
  background: #FFFFFF;
}

/* SVG Connector Layer */
.edges-svg {
  position: absolute;
  inset: 0;
  width: 1123px;
  height: 794px;
  z-index: 6;
  pointer-events: none;
}
.edge-hit-path {
  fill: none;
  stroke: transparent;
  stroke-width: 24px;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: stroke;
  cursor: pointer;
}
.linking-active .edge-hit-path {
  stroke: rgba(22, 115, 185, 0.16);
  stroke-width: 26px;
}
.linking-active .edge-hit-path:hover {
  stroke: rgba(22, 115, 185, 0.35);
}
.edge-visible-path {
  fill: none;
  stroke-linecap: square;
  stroke-linejoin: round;
  pointer-events: none;
  transition: stroke 0.12s;
}
.edge-visible-path.selected {
  stroke: #1673B9 !important;
  filter: drop-shadow(0 0 3px rgba(22, 115, 185, 0.35));
}

/* Nodes (Org Boxes) */
.nodes-layer {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.org-node {
  position: absolute;
  pointer-events: auto;
  border-radius: 4px;
  border-style: solid;
  border-width: 1.4px;
  padding: 4px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: move;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
  transition: box-shadow 0.12s, outline 0.1s;
  touch-action: none;
}
.org-node:hover {
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.14);
}
.org-node.selected {
  outline: 2.5px solid var(--primary);
  outline-offset: 2px;
  z-index: 20;
  box-shadow: 0 8px 20px rgba(22, 115, 185, 0.22);
}
.org-node.link-candidate {
  outline: 2.5px dashed var(--primary);
  outline-offset: 3px;
  cursor: crosshair;
}
.org-node.link-source {
  outline: 2.5px solid var(--success);
  outline-offset: 2px;
}

.org-node-content {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  pointer-events: none;
}
.org-node-content.rotated {
  transform: rotate(-90deg);
  flex-shrink: 0;
  height: auto;
  overflow: visible;
}
.org-node-title {
  font-weight: 800;
  line-height: 1.2;
  word-break: break-word;
}
.org-node-sub {
  font-weight: 600;
  line-height: 1.2;
  margin-top: 2px;
  opacity: 0.9;
  word-break: break-word;
}

/* On-Node Quick Touch Handles (Sits cleanly outside text box with generous touch target) */
.node-handle {
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 2px solid #FFFFFF;
  background: var(--primary);
  color: #FFFFFF;
  font-weight: 800;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.28);
  cursor: pointer;
  z-index: 25;
  padding: 0;
}
.node-handle::after {
  content: '';
  position: absolute;
  inset: -7px;
}
.node-handle-child {
  bottom: -21px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--success);
}
.node-handle-link {
  top: 50%;
  right: -21px;
  transform: translateY(-50%);
  background: var(--primary);
  font-size: 12px;
}
.node-handle-resize {
  bottom: -11px;
  right: -11px;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: var(--ink);
  cursor: nwse-resize;
  font-size: 11px;
}

/* Alignment Snap Guides */
.snap-guides-svg {
  position: absolute;
  inset: 0;
  width: 1123px;
  height: 794px;
  z-index: 15;
  pointer-events: none;
}

/* Floating Zoom Controls */
.zoom-floating {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 4px;
  box-shadow: var(--shadow-sm);
  z-index: 22;
}
.zoom-readout {
  min-width: 44px;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink);
}

/* Beginner Friendly Bottom Dock + Page Strip */
.editor-bottom {
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 30;
  flex-shrink: 0;
}

.context-toolbar {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--surface);
}
.context-toolbar::-webkit-scrollbar {
  display: none;
}

.swatch-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px;
}
.swatch-dot {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 2px solid rgba(15, 23, 42, 0.18);
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.12s;
}
.swatch-dot.active {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  transform: scale(1.1);
}

.pages-bar {
  padding: 7px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--surface-muted);
}
.pages-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  padding-inline-end: 4px;
}
.pages-bar .topbar-group {
  flex-shrink: 0;
}
.page-pill {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 250px;
  overflow: hidden;
  height: 32px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink-secondary);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.page-pill-sub {
  opacity: 0.78;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.page-pill.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #FFFFFF;
}

/* ==================== Modals & Bottom Sheets ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-card {
  width: 100%;
  max-width: 470px;
  max-height: 90dvh;
  background: var(--surface);
  border-radius: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}
.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
}
.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  background: var(--surface-muted);
}

.template-choice {
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  margin-bottom: 10px;
  background: var(--surface);
}
.template-choice.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.template-choice-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
}
.template-choice-desc {
  font-size: 12px;
  color: var(--ink-secondary);
  margin-top: 2px;
}

.export-option-card {
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
}
.export-option-card.active {
  border-color: var(--success);
  background: var(--success-soft);
}

.toast {
  position: fixed;
  bottom: 92px;
  left: 50%;
  transform: translateX(-50%);
  background: #0F172A;
  color: #FFFFFF;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  z-index: 90;
  box-shadow: var(--shadow-md);
  white-space: nowrap;
  max-width: 92vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==================== Responsive Tuning (Tablet & Mobile) ==================== */
@media (max-width: 980px) {
  .doc-title-btn {
    max-width: 140px;
  }
  .hide-narrow {
    display: none !important;
  }
}

@media (max-width: 768px) {
  .hide-mobile {
    display: none !important;
  }
  .editor-topbar {
    flex-direction: column;
    align-items: stretch;
    padding: 6px 8px;
    gap: 6px;
  }
  .editor-topbar > .topbar-group:first-child {
    justify-content: space-between;
    width: 100%;
    gap: 4px;
  }
  .editor-topbar > .topbar-group:last-child {
    justify-content: space-between;
    width: 100%;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .editor-topbar > .topbar-group:last-child::-webkit-scrollbar {
    display: none;
  }
  .editor-topbar .btn-sm {
    height: 34px;
    padding: 0 9px;
    font-size: 12px;
  }
  .editor-topbar .btn-icon-sm {
    height: 34px;
    width: 34px;
  }
  .doc-title-btn {
    flex: 1 1 0;
    min-width: 0;
    max-width: none;
    overflow: hidden;
    justify-content: center;
    padding: 4px 6px;
    font-size: 13px;
  }
  .save-badge {
    padding: 4px 8px;
    font-size: 11px;
  }
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }
  .modal-card {
    border-radius: 20px 20px 0 0;
    max-height: 88dvh;
  }
  .zoom-floating {
    top: 8px;
    left: 8px;
  }
  .context-toolbar {
    padding: 8px 10px;
  }
  .pages-bar {
    padding: 6px 8px;
    gap: 6px;
  }
  .pages-bar .btn-sm {
    height: 32px;
    padding: 0 9px;
    font-size: 12px;
  }
  .page-pill {
    height: 32px;
    max-width: 155px;
    padding: 0 10px;
    font-size: 12px;
  }
  .btn {
    height: 40px;
  }
  .hub-body {
    padding: 14px;
  }
}

@media print {
  @page {
    size: A4 landscape;
    margin: 0;
  }
  body {
    background: #FFFFFF !important;
  }
}
