/* ==========================================================================
   URL PRINTER STUDIO - LIGHT & ELEGANT USER INTERFACE (V4.1)
   Minimalist light design with soft pastel accents, monochrome SVG icons,
   independent canvas zoom wrapper, slide-out drawer & optimized inspector.
   ========================================================================== */

:root {
  /* Core UI Colors (Light & Pastel Theme) */
  --ui-bg: #f8fafc;
  --ui-surface: #ffffff;
  --ui-surface-subtle: #f1f5f9;
  --ui-border: #e2e8f0;
  --ui-border-focus: #0284c7;
  
  --ui-text-heading: #0f172a;
  --ui-text-body: #334155;
  --ui-text-muted: #64748b;
  --ui-text-light: #94a3b8;

  /* Pastel Accent Colors */
  --pastel-blue-bg: #f0f9ff;
  --pastel-blue-border: #bae6fd;
  --pastel-blue-text: #0369a1;

  --pastel-sage-bg: #f0fdf4;
  --pastel-sage-border: #bbf7d0;
  --pastel-sage-text: #15803d;

  --pastel-lavender-bg: #f5f3ff;
  --pastel-lavender-border: #ddd6fe;
  --pastel-lavender-text: #5b21b6;

  --pastel-amber-bg: #fffbeb;
  --pastel-amber-border: #fde68a;
  --pastel-amber-text: #92400e;

  --pastel-rose-bg: #fff1f2;
  --pastel-rose-border: #fecdd3;
  --pastel-rose-text: #9f1239;

  /* Primary Button Accents */
  --btn-primary-bg: #0284c7;
  --btn-primary-hover: #0369a1;
  --btn-primary-text: #ffffff;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--ui-bg);
  color: var(--ui-text-body);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* --------------------------------------------------------------------------
   App Topbar Header
   -------------------------------------------------------------------------- */
.app-topbar {
  height: 52px;
  background: var(--ui-surface);
  border-bottom: 1px solid var(--ui-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  z-index: 50;
  gap: 10px;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.topbar-left-group,
.topbar-center-group,
.topbar-right-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-logo {
  width: 30px;
  height: 30px;
  background: var(--pastel-blue-bg);
  border: 1px solid var(--pastel-blue-border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--pastel-blue-text);
}

.brand-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--ui-text-heading);
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-badge {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--pastel-blue-bg);
  color: var(--pastel-blue-text);
  border: 1px solid var(--pastel-blue-border);
  padding: 1px 5px;
  border-radius: 4px;
}

.brand-version-badge {
  font-size: 10px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace, monospace;
  background: var(--ui-surface-subtle);
  color: var(--ui-text-muted);
  border: 1px solid var(--ui-border);
  padding: 1px 6px;
  border-radius: 4px;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.brand-version-badge:hover {
  background: var(--pastel-blue-bg);
  color: var(--pastel-blue-text);
  border-color: var(--pastel-blue-border);
}

.topbar-divider {
  width: 1px;
  height: 22px;
  background: var(--ui-border);
  margin: 0 2px;
}

.topbar-btn-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

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

.btn svg {
  flex-shrink: 0;
}

.btn-topbar {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  color: var(--ui-text-body);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-topbar:hover {
  background: var(--ui-surface-subtle);
  border-color: #cbd5e1;
  color: var(--ui-text-heading);
}

.btn-primary {
  background: var(--btn-primary-bg);
  color: #ffffff;
  border: 1px solid var(--btn-primary-bg);
}
.btn-primary:hover {
  background: var(--btn-primary-hover);
  border-color: var(--btn-primary-hover);
}

.btn-secondary {
  background: var(--ui-surface);
  border-color: var(--ui-border);
  color: var(--ui-text-body);
}
.btn-secondary:hover {
  background: var(--ui-surface-subtle);
  border-color: #cbd5e1;
  color: var(--ui-text-heading);
}

.btn-success {
  background: #059669;
  color: #ffffff;
  border-color: #059669;
}
.btn-success:hover {
  background: #047857;
}

.btn-block {
  width: 100%;
}

/* History Undo / Redo */
.history-group {
  display: flex;
  align-items: center;
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  overflow: hidden;
}

.history-btn {
  background: transparent;
  border: none;
  color: var(--ui-text-body);
  padding: 5px 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.history-btn:hover:not(:disabled) {
  background: var(--ui-surface-subtle);
  color: var(--ui-text-heading);
}

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

/* Language Switcher */
.lang-switch-group {
  display: flex;
  align-items: center;
  background: var(--ui-surface-subtle);
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}

.lang-btn {
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--ui-text-muted);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 7px;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  user-select: none;
}

.lang-btn:hover {
  color: var(--ui-text-heading);
  background: rgba(0, 0, 0, 0.04);
}

.lang-btn.active {
  background: var(--btn-primary-bg);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

/* Zoom Controls Box */
.zoom-box {
  display: flex;
  align-items: center;
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  padding: 2px 4px;
  gap: 2px;
}

.zoom-icon-btn {
  background: transparent;
  border: none;
  color: var(--ui-text-muted);
  width: 24px;
  height: 24px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.zoom-icon-btn:hover {
  background: var(--ui-surface-subtle);
  color: var(--ui-text-heading);
}

.zoom-val-wrap {
  display: flex;
  align-items: center;
}

.zoom-num-input {
  width: 44px;
  border: none;
  background: transparent;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ui-text-heading);
  text-align: right;
  outline: none;
  -moz-appearance: textfield;
}
.zoom-num-input::-webkit-outer-spin-button,
.zoom-num-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.zoom-unit {
  font-size: 11px;
  font-weight: 600;
  color: var(--ui-text-muted);
  margin-left: 1px;
  margin-right: 4px;
}

/* Page Navigator Box */
.page-nav-box {
  display: flex;
  align-items: center;
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  padding: 2px 6px;
  gap: 4px;
}

.page-nav-arrow {
  background: transparent;
  border: none;
  color: var(--ui-text-muted);
  width: 22px;
  height: 22px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.page-nav-arrow:hover {
  background: var(--ui-surface-subtle);
  color: var(--ui-text-heading);
}

.page-nav-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--ui-text-muted);
}

.page-jump-input {
  width: 32px;
  height: 22px;
  padding: 0 4px;
  border: 1px solid var(--ui-border);
  border-radius: 4px;
  background: var(--ui-surface-subtle);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ui-text-heading);
  text-align: center;
  outline: none;
  -moz-appearance: textfield;
}
.page-jump-input::-webkit-outer-spin-button,
.page-jump-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.page-jump-input:focus {
  border-color: var(--ui-border-focus);
  background: #ffffff;
}

.page-nav-total {
  font-size: 11px;
  font-weight: 600;
  color: var(--ui-text-muted);
}

/* View & Panel Toggles */
.view-toggles-box,
.panel-toggles-group {
  display: flex;
  align-items: center;
  gap: 3px;
}

.btn-tool-icon,
.btn-panel-toggle {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  color: var(--ui-text-muted);
  width: 30px;
  height: 30px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.btn-tool-icon:hover,
.btn-panel-toggle:hover {
  background: var(--ui-surface-subtle);
  color: var(--ui-text-heading);
  border-color: #cbd5e1;
}

.btn-tool-icon.active,
.btn-panel-toggle.active {
  background: var(--pastel-blue-bg);
  border-color: var(--pastel-blue-border);
  color: var(--pastel-blue-text);
}

/* Tooltip text */
.btn-tool-icon .tooltip-text {
  visibility: hidden;
  position: absolute;
  top: 100%;
  margin-top: 6px;
  background: #0f172a;
  color: #ffffff;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 6px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
  z-index: 100;
}
.btn-tool-icon:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}

/* --------------------------------------------------------------------------
   Main Workspace Layout
   -------------------------------------------------------------------------- */
.app-main {
  flex: 1;
  display: flex;
  height: calc(100vh - 52px);
  position: relative;
  overflow: hidden;
  background: var(--ui-bg);
}

/* Left Sidebar */
.app-sidebar {
  width: 310px;
  background: var(--ui-surface);
  border-right: 1px solid var(--ui-border);
  display: flex;
  flex-direction: column;
  z-index: 20;
  flex-shrink: 0;
  transition: margin-left 0.2s ease, width 0.2s ease;
}

.app-sidebar.collapsed {
  margin-left: -310px;
}

.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--ui-border);
  background: var(--ui-surface-subtle);
}

.sidebar-tab-btn {
  flex: 1;
  padding: 10px 6px;
  background: transparent;
  border: none;
  color: var(--ui-text-muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-bottom: 2px solid transparent;
  transition: all 0.15s ease;
}

.sidebar-tab-btn:hover {
  color: var(--ui-text-heading);
}

.sidebar-tab-btn.active {
  color: var(--pastel-blue-text);
  border-bottom-color: var(--btn-primary-bg);
  background: var(--ui-surface);
}

.sidebar-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ui-text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--ui-border);
  padding-bottom: 4px;
}

/* Chapter Tree List */
.chapter-tree-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.chapter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chapter-item:hover {
  border-color: #cbd5e1;
  background: var(--ui-surface-subtle);
}

.chapter-item.active {
  border-color: var(--pastel-blue-border);
  background: var(--pastel-blue-bg);
}

.chapter-handle {
  color: var(--ui-text-light);
  cursor: grab;
}

.chapter-badge {
  font-size: 10px;
  font-weight: 700;
  background: var(--ui-surface-subtle);
  color: var(--ui-text-muted);
  padding: 2px 5px;
  border-radius: 3px;
}

.chapter-name {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  color: var(--ui-text-heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chapter-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.chapter-btn-icon {
  background: transparent;
  border: none;
  color: var(--ui-text-muted);
  cursor: pointer;
  padding: 3px 5px;
  border-radius: 4px;
  font-size: 10px;
}
.chapter-btn-icon:hover {
  color: #dc2626;
  background: var(--pastel-rose-bg);
}

/* Insert Tiles Grid (Vložit prvek) */
.insert-tiles-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.insert-tile {
  padding: 10px 8px;
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.insert-tile:hover {
  border-color: var(--pastel-blue-border);
  background: var(--pastel-blue-bg);
}

.insert-tile-icon {
  color: var(--ui-text-heading);
}

.insert-tile-name {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ui-text-heading);
}

.insert-tile-desc {
  font-size: 9.5px;
  color: var(--ui-text-muted);
  line-height: 1.2;
}

/* Controls in Sidebar */
.control-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.control-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ui-text-body);
  display: flex;
  justify-content: space-between;
}

.control-sublabel {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ui-text-muted);
}

.control-input,
.control-select {
  width: 100%;
  padding: 6px 8px;
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  color: var(--ui-text-heading);
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s ease;
}

.control-input:focus,
.control-select:focus {
  border-color: var(--ui-border-focus);
}

.chk-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--ui-text-body);
  cursor: pointer;
}

/* Vertical Margins Grid (Sliders underneath number inputs) */
.margins-vertical-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.margin-box-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: var(--ui-surface-subtle);
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  padding: 8px 10px;
}

.margin-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.control-num-input {
  width: 48px;
  padding: 3px 6px;
  border: 1px solid var(--ui-border);
  border-radius: 4px;
  background: var(--ui-surface);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ui-text-heading);
  text-align: right;
}

.control-range-full {
  width: 100%;
  accent-color: var(--btn-primary-bg);
  cursor: pointer;
}

/* Typography Parameter Sliders & Reset Controls */
.slider-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 2px;
}

.slider-val-action {
  display: flex;
  align-items: center;
  gap: 4px;
}

.slider-val-badge {
  font-size: 11px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--ui-text-heading);
  background: var(--ui-surface-subtle);
  border: 1px solid var(--ui-border);
  padding: 2px 6px;
  border-radius: 4px;
  min-width: 48px;
  text-align: center;
  line-height: 1.2;
}

.btn-reset-param {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: 4px;
  color: var(--ui-text-muted);
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  transition: all 0.15s ease;
}

.btn-reset-param:hover {
  background: var(--pastel-blue-bg);
  border-color: var(--pastel-blue-border);
  color: #0284c7;
  transform: rotate(-30deg);
}

.control-range {
  width: 100%;
  accent-color: #0284c7;
  cursor: pointer;
  height: 5px;
  border-radius: 3px;
  margin-top: 2px;
}

.subcontrol-panel {
  padding: 10px;
  background: var(--ui-surface-subtle);
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.page-variant-title {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--ui-text-muted);
}

.row-inputs-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.color-picker-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-swatch-input {
  width: 28px;
  height: 28px;
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
}

.color-picker-label {
  font-size: 11.5px;
  color: var(--ui-text-body);
}

/* --------------------------------------------------------------------------
   Center Stage: Canvas & Slide-out Miniatures/TOC Drawer
   -------------------------------------------------------------------------- */
.app-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #e2e8f0;
  position: relative;
  overflow: hidden;
}

/* Drawer Toggle in Top-Left Corner of Viewport */
.canvas-drawer-toggle {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 28px;
  height: 28px;
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  color: var(--ui-text-body);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 30;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.canvas-drawer-toggle:hover {
  background: var(--pastel-blue-bg);
  border-color: var(--pastel-blue-border);
  color: var(--pastel-blue-text);
}

.canvas-drawer-toggle.drawer-open {
  left: 230px;
  transform: rotate(180deg);
}

/* Slide-out Drawer Panel */
.canvas-drawer {
  position: absolute;
  top: 0;
  left: -240px;
  width: 230px;
  height: 100%;
  background: var(--ui-surface);
  border-right: 1px solid var(--ui-border);
  box-shadow: var(--shadow-md);
  z-index: 25;
  display: flex;
  flex-direction: column;
  transition: left 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.canvas-drawer.open {
  left: 0;
}

.drawer-header {
  height: 42px;
  border-bottom: 1px solid var(--ui-border);
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--ui-surface-subtle);
}

.drawer-tabs {
  display: flex;
  gap: 2px;
}

.drawer-tab-btn {
  padding: 4px 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ui-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.drawer-tab-btn:hover {
  color: var(--ui-text-heading);
}

.drawer-tab-btn.active {
  background: var(--ui-surface);
  border-color: var(--ui-border);
  color: var(--pastel-blue-text);
}

.drawer-close-btn {
  background: transparent;
  border: none;
  font-size: 16px;
  color: var(--ui-text-muted);
  cursor: pointer;
}

.drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

/* Thumbnails list */
.drawer-thumbs-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.drawer-thumb-card {
  width: 144px;
  background: #ffffff;
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3px;
}

.drawer-thumb-card:hover {
  border-color: var(--btn-primary-bg);
  box-shadow: 0 2px 10px rgba(2, 132, 199, 0.25);
  transform: translateY(-1px);
}

.drawer-thumb-card.active {
  border-color: var(--btn-primary-bg);
  outline: 2px solid var(--pastel-blue-border);
}

.drawer-thumb-frame {
  position: relative;
  overflow: hidden;
  background: #ffffff;
  border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.drawer-thumb-footer {
  width: 100%;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--ui-text-muted);
  padding: 4px 6px;
  background: var(--ui-surface-subtle);
  border-top: 1px solid var(--ui-border);
  text-align: center;
  border-radius: 0 0 4px 4px;
}


/* Document TOC Tree */
.drawer-toc-tree {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.drawer-toc-item {
  padding: 5px 8px;
  border-radius: 4px;
  font-size: 11.5px;
  color: var(--ui-text-body);
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-toc-item:hover {
  background: var(--pastel-blue-bg);
  color: var(--pastel-blue-text);
}

.drawer-toc-item.level-h2 {
  padding-left: 16px;
  font-size: 11px;
}

.drawer-toc-item.level-h3 {
  padding-left: 24px;
  font-size: 10.5px;
  color: var(--ui-text-muted);
}

/* Bottom Canvas Status Bar */
.canvas-bottom-bar {
  height: 28px;
  background: var(--ui-surface);
  border-top: 1px solid var(--ui-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  z-index: 10;
}

.canvas-status-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-badge {
  background: var(--pastel-blue-bg);
  border: 1px solid var(--pastel-blue-border);
  color: var(--pastel-blue-text);
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 10.5px;
  font-weight: 700;
}

.status-hint {
  font-size: 11px;
  color: var(--ui-text-muted);
}

/* --------------------------------------------------------------------------
   Real Virtual Sheets Viewport & Zoom Wrapper
   Viewport has 100% full-size scrollbars; Zoom applies ONLY to inner wrapper!
   -------------------------------------------------------------------------- */
.sheet-viewport {
  flex: 1;
  overflow: auto;
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
}

.sheet-zoom-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
  padding: 30px 20px 80px;
  min-width: 100%;
  width: max-content;
  margin: 0 auto;
  transform-origin: top center;
  transition: transform 0.15s ease-out;
}

.sheet-viewport.spread-mode .sheet-zoom-wrapper {
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
}

/* --------------------------------------------------------------------------
   Right Sidebar: Optimized Block Inspector
   -------------------------------------------------------------------------- */
.inspector-sidebar {
  width: 290px;
  background: var(--ui-surface);
  border-left: 1px solid var(--ui-border);
  display: flex;
  flex-direction: column;
  z-index: 20;
  flex-shrink: 0;
  transition: margin-right 0.2s ease, width 0.2s ease;
}

.inspector-sidebar.collapsed {
  margin-right: -290px;
}

.inspector-header {
  height: 42px;
  padding: 0 14px;
  border-bottom: 1px solid var(--ui-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: var(--ui-text-heading);
  background: var(--ui-surface-subtle);
}

.inspector-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.inspector-section-card {
  padding: 10px;
  background: var(--ui-surface-subtle);
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inspector-sec-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ui-text-muted);
}

/* Text & Block Alignment Buttons */
.align-btn-group {
  display: flex;
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--ui-surface);
}

.align-btn {
  flex: 1;
  padding: 5px 0;
  background: transparent;
  border: none;
  color: var(--ui-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.align-btn:hover {
  background: var(--ui-surface-subtle);
  color: var(--ui-text-heading);
}

.align-btn.active {
  background: var(--pastel-blue-bg);
  color: var(--pastel-blue-text);
}

/* Slider with number input */
.slider-num-pair {
  display: flex;
  align-items: center;
  gap: 8px;
}

.slider-num-pair input[type="range"] {
  flex: 1;
  accent-color: var(--btn-primary-bg);
}

.slider-num-pair input[type="number"] {
  width: 48px;
  padding: 3px 5px;
  border: 1px solid var(--ui-border);
  border-radius: 4px;
  font-size: 11.5px;
  color: var(--ui-text-heading);
  text-align: right;
}

/* Contextual Disabled State */
.inspector-control-disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   Modals & Dialogs
   -------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-window {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: 10px;
  width: 90%;
  max-width: 620px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: translateY(10px);
  transition: transform 0.2s ease;
}

.modal-overlay.open .modal-window {
  transform: translateY(0);
}

.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--ui-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--ui-surface-subtle);
  border-radius: 10px 10px 0 0;
}

.modal-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ui-text-heading);
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--ui-text-muted);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}

.modal-body {
  padding: 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--ui-border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--ui-surface-subtle);
  border-radius: 0 0 10px 10px;
}

.sample-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sample-pill {
  padding: 5px 9px;
  background: var(--pastel-blue-bg);
  border: 1px solid var(--pastel-blue-border);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--pastel-blue-text);
  cursor: pointer;
  transition: all 0.15s ease;
}

.sample-pill:hover {
  background: var(--btn-primary-bg);
  color: #ffffff;
  border-color: var(--btn-primary-bg);
}

/* --------------------------------------------------------------------------
   Project History Cards
   -------------------------------------------------------------------------- */
.project-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 48vh;
  overflow-y: auto;
  padding-right: 4px;
}

.project-card {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: all 0.15s ease;
}

.project-card:hover {
  border-color: var(--pastel-blue-border);
  background: var(--pastel-blue-bg);
  box-shadow: var(--shadow-sm);
}

.project-card-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.project-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ui-text-heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 10.5px;
  color: var(--ui-text-muted);
}

.project-card-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.btn-card-open {
  background: var(--btn-primary-bg);
  color: #ffffff;
  padding: 5px 10px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  border: none;
  cursor: pointer;
}

.btn-card-export {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  color: var(--ui-text-body);
  padding: 5px 8px;
  border-radius: 5px;
  font-size: 11px;
  cursor: pointer;
}

.btn-card-delete {
  background: var(--pastel-rose-bg);
  border: 1px solid var(--pastel-rose-border);
  color: var(--pastel-rose-text);
  padding: 5px 7px;
  border-radius: 5px;
  cursor: pointer;
}

/* Empty State Card */
.empty-workspace-card {
  text-align: center;
  padding: 60px 30px;
  background: var(--ui-surface);
  border: 2px dashed var(--ui-border);
  border-radius: 12px;
  max-width: 540px;
  margin: 40px auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.empty-workspace-icon {
  font-size: 44px;
}

.empty-workspace-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ui-text-heading);
}

.empty-workspace-desc {
  font-size: 12.5px;
  color: var(--ui-text-muted);
  line-height: 1.5;
}

/* Drop Zone Overlay */
.drop-zone-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(2, 132, 199, 0.9);
  backdrop-filter: blur(6px);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: #ffffff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  border: 3px dashed #ffffff;
  margin: 14px;
  border-radius: 12px;
}

.drop-zone-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* Toast */
.app-toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #0f172a;
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 8px;
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.25s ease;
}

.app-toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* --------------------------------------------------------------------------
   Live Template Specification Card (Sidebar)
   -------------------------------------------------------------------------- */
.template-spec-card {
  margin-top: 10px;
  padding: 10px 11px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.03);
  border: 1px solid var(--ui-border, #e2e8f0);
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.template-spec-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.template-spec-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--ui-text-heading, #0f172a);
  line-height: 1.25;
}

.template-spec-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #0369a1;
  white-space: nowrap;
  flex-shrink: 0;
}

.template-spec-desc {
  font-size: 11px;
  color: var(--ui-text-muted, #64748b);
  line-height: 1.4;
}

.template-spec-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tpl-pill {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: #ffffff;
  border: 1px solid var(--ui-border, #cbd5e1);
  color: var(--ui-text, #334155);
}

.template-spec-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px dashed var(--ui-border, #e2e8f0);
}

.template-swatches {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tpl-swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  display: inline-block;
}

.btn-reapply-layout {
  background: #ffffff;
  border: 1px solid var(--ui-border, #cbd5e1);
  color: var(--ui-text, #334155);
  font-size: 10.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-reapply-layout:hover {
  background: #f0f9ff;
  border-color: #0284c7;
  color: #0284c7;
}

/* --------------------------------------------------------------------------
   Native Browser Print Rules (@media print)
   -------------------------------------------------------------------------- */
@page {
  size: auto;
  margin: 0mm;
}

@media print {
  html,
  body {
    background: #ffffff !important;
    margin: 0 !important;
    padding: 0 !important;
    height: auto !important;
    min-height: 100% !important;
    overflow: visible !important;
    position: static !important;
    display: block !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .app-sidebar,
  .app-topbar,
  .inspector-sidebar,
  .canvas-drawer,
  .canvas-drawer-toggle,
  .canvas-bottom-bar,
  .modal-overlay,
  .empty-workspace-card,
  .app-toast,
  .drop-zone-overlay,
  .no-print {
    display: none !important;
  }

  .app-main,
  .app-center,
  #app-main-layout,
  #app-canvas-container {
    display: block !important;
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    position: static !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .sheet-viewport {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    gap: 0 !important;
    background: transparent !important;
    overflow: visible !important;
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
    position: static !important;
    transform: none !important;
    width: 100% !important;
  }

  .sheet-zoom-wrapper {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    gap: 0 !important;
    transform: none !important;
    overflow: visible !important;
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
    position: static !important;
    width: 100% !important;
  }

  .paper-sheet {
    box-shadow: none !important;
    border: none !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    page-break-after: always !important;
    break-after: page !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    position: relative !important;
    overflow: hidden !important;
  }

  .paper-sheet:last-child {
    page-break-after: auto !important;
    break-after: auto !important;
  }

  .sheet-inner {
    height: 100% !important;
    overflow: visible !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .sheet-body {
    overflow: visible !important;
    flex: 1 !important;
  }

  .doc-page-break {
    display: none !important;
  }

  .doc-element:hover,
  .doc-element.active-selected {
    outline: none !important;
    background-color: transparent !important;
  }
}

