/* ==========================================================================
   Notion-inspired Design Tokens & Modern 2026 Typography
   Optimized for iPad 9th Gen (10.2", Retina 2160x1620, Safari / WebKit)
   ========================================================================== */

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Notion neutral palette */
  --bg-primary: #FFFFFF;
  --bg-secondary: #F7F6F3;
  --bg-tertiary: #EFEFEF;
  --bg-hover: rgba(55, 53, 47, 0.08);
  --bg-active: rgba(55, 53, 47, 0.16);

  --text-primary: #37352F;
  --text-secondary: #787774;
  --text-tertiary: #9B9A97;

  --border-light: rgba(55, 53, 47, 0.09);
  --border-medium: rgba(55, 53, 47, 0.16);
  --border-accent: #2EAADC;

  --accent-blue: #0B6BCB;
  --accent-blue-subtle: #EBF3FB;
  --accent-red: #EB5757;
  --accent-green: #0F7B6C;
  --accent-yellow: #F7B500;

  --shadow-subtle: 0 1px 2px rgba(15, 15, 15, 0.05);
  --shadow-floating: 0 8px 24px -4px rgba(15, 15, 15, 0.12), 0 2px 6px -1px rgba(15, 15, 15, 0.06);
  --shadow-dock: 0 12px 32px 0 rgba(0, 0, 0, 0.14), 0 2px 6px 0 rgba(0, 0, 0, 0.08);

  --header-height: 52px;
  --dock-height: 54px;
  --sidebar-width: 280px;
  --drawer-width: 380px;

  /* Safe Area variables for iPad (notch / home indicator) */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

/* Base reset */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  height: -webkit-fill-available;
  height: 100dvh;
  overflow: hidden;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

/* ==========================================================================
   Header: Notion minimal styling
   ========================================================================== */
.app-header {
  height: calc(var(--header-height) + var(--safe-top));
  padding-top: var(--safe-top);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: max(10px, var(--safe-left));
  padding-right: max(10px, var(--safe-right));
  z-index: 100;
  gap: 8px;
  flex-shrink: 0;
  max-width: 100vw;
  box-sizing: border-box;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 1;
  min-width: 0;
}

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

.header-center {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.doc-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 170px;
  overflow: hidden;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
  position: relative;
}

.doc-meta:hover {
  background: var(--bg-hover);
}

.doc-dropdown-arrow {
  width: 14px;
  height: 14px;
  color: var(--text-tertiary);
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.doc-meta.open .doc-dropdown-arrow {
  transform: rotate(180deg);
}

/* Recent Documents Dropdown Menu (Notion Style) */
.recent-docs-dropdown {
  position: absolute;
  top: calc(var(--header-height) + var(--safe-top) + 4px);
  left: max(16px, var(--safe-left));
  width: 320px;
  max-width: 90vw;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-medium);
  border-radius: 10px;
  box-shadow: var(--shadow-floating);
  z-index: 150;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: fadeInDown 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.recent-docs-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-secondary);
}

.recent-docs-list {
  max-height: 320px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  padding: 6px;
  gap: 2px;
}

.recent-doc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.recent-doc-item:hover {
  background: var(--bg-hover);
}

.recent-doc-item.active {
  background: var(--accent-blue-subtle);
}

.recent-doc-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
  flex: 1;
}

.recent-doc-name {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-doc-meta {
  font-size: 10.5px;
  color: var(--text-tertiary);
}

.recent-doc-delete-btn {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  padding: 4px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.6;
  transition: opacity 0.15s, color 0.15s;
}

.recent-doc-delete-btn:hover {
  opacity: 1;
  color: var(--accent-red);
  background: rgba(235, 87, 87, 0.1);
}

/* Welcome Screen Recent Documents */
.welcome-recent-box {
  margin-top: 24px;
  width: 100%;
  border-top: 1px solid var(--border-light);
  padding-top: 16px;
  text-align: left;
}

.welcome-recent-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.welcome-recent-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.doc-icon {
  font-size: 16px;
}

.doc-title {
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13.5px;
}

.undo-redo-group {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 4px;
}

.undo-redo-group .icon-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}

.badge-status {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-hover);
  padding: 2px 7px;
  border-radius: 12px;
}

/* ==========================================================================
   Segmented Tool Picker (Apple / Notion inspired)
   ========================================================================== */
.tool-segmented-bar {
  display: flex;
  align-items: center;
  background: var(--bg-tertiary);
  border-radius: 9px;
  padding: 3px;
  gap: 2px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tool-segmented-bar::-webkit-scrollbar {
  display: none;
}

.tool-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.16s ease;
}

.tool-btn i {
  width: 16px;
  height: 16px;
}

.tool-btn:hover {
  color: var(--text-primary);
}

.tool-btn.active {
  background: #FFFFFF;
  color: var(--text-primary);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  font-weight: 600;
}

/* Floating Contextual Pen Palette (Apple Notes & Notion Style) */
.pen-settings.floating-pen-palette {
  position: fixed;
  top: calc(var(--header-height) + var(--safe-top) + 8px);
  left: 50%;
  transform: translateX(-50%);
  display: none;
  align-items: center;
  gap: 10px;
  padding: 5px 14px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border: 1px solid rgba(0, 0, 0, 0.10);
  border-radius: 30px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.10), 0 1px 3px rgba(0, 0, 0, 0.04);
  z-index: 105;
  animation: floatInPalette 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.pen-settings::-webkit-scrollbar {
  display: none;
}

@keyframes floatInPalette {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.color-palette {
  display: flex;
  align-items: center;
  gap: 6px;
}

.color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.15s ease;
  border: 2px solid #FFFFFF;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18);
  touch-action: manipulation;
}

.color-swatch::after {
  content: '';
  position: absolute;
  top: -6px;
  left: -6px;
  right: -6px;
  bottom: -6px;
}

.color-swatch.active {
  transform: scale(1.22);
  box-shadow: 0 0 0 2.5px var(--accent-blue);
}

.palette-divider {
  width: 1px;
  height: 20px;
  background: var(--border-medium);
  margin: 0 2px;
}

.stroke-size-selector {
  display: flex;
  gap: 4px;
  border-left: 1px solid var(--border-medium);
  padding-left: 6px;
  align-items: center;
}

.stroke-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  touch-action: manipulation;
}

.stroke-btn.active {
  background: var(--bg-hover);
  border-color: var(--border-medium);
  color: var(--text-primary);
}

/* Notion-style Input Mode Toggle (Apple Pencil vs Finger Drawing) */
.input-mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 500;
  border: 1px solid var(--border-medium);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.16s ease;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  white-space: nowrap;
}

.input-mode-toggle svg {
  width: 13px;
  height: 13px;
  stroke-width: 2;
  flex-shrink: 0;
}

.input-mode-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.input-mode-toggle.mode-finger {
  background: rgba(11, 107, 203, 0.10);
  border-color: rgba(11, 107, 203, 0.40);
  color: var(--accent-blue);
  font-weight: 600;
}

.input-mode-toggle.mode-finger:hover {
  background: rgba(11, 107, 203, 0.16);
}

/* Minimalist Notion Floating Toast */
.app-toast {
  position: fixed;
  bottom: calc(76px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: rgba(25, 25, 25, 0.88);
  color: #FFFFFF;
  padding: 8px 18px;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.16s ease, transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.app-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.app-toast .toast-icon {
  font-size: 15px;
  line-height: 1;
}

/* ==========================================================================
   Buttons & Controls
   ========================================================================== */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s;
}

.icon-btn:hover {
  background: var(--bg-hover);
}

.search-trigger {
  width: auto;
  padding: 0 10px;
  gap: 6px;
  background: var(--accent-blue-subtle);
  color: var(--accent-blue);
  font-size: 12.5px;
  font-weight: 500;
}

.search-trigger:hover {
  background: #DCECF9;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 6px;
  background: var(--text-primary);
  color: white;
  border: none;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  background: white;
  color: var(--text-primary);
  border: 1px solid var(--border-medium);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 8px;
}

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

/* ==========================================================================
   Workspace Layout (Sidebar + Viewer + Drawer)
   ========================================================================== */
.workspace-layout {
  display: flex;
  flex: 1;
  position: relative;
  overflow: hidden;
  height: calc(100% - var(--header-height));
  width: 100%;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1), margin-left 0.24s ease;
  z-index: 40;
  flex-shrink: 0;
}

.sidebar.collapsed {
  margin-left: calc(-1 * var(--sidebar-width));
}

.sidebar-header {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-light);
}

.sidebar-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-tertiary);
  padding: 2px;
  border-radius: 6px;
  width: 100%;
  box-sizing: border-box;
}

.sidebar-tab {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: transparent;
  padding: 5px 1px;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-tab i {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.sidebar-tab.active {
  background: white;
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.sidebar-panel {
  display: none;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sidebar-panel.active {
  display: flex;
  flex-direction: column;
}

/* Quick Page Jump Box in Sidebar */
.page-jump-box {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  background: white;
}

.page-jump-box input {
  flex: 1;
  border: 1px solid var(--border-medium);
  border-radius: 5px;
  padding: 5px 8px;
  font-size: 12.5px;
  outline: none;
}

.page-jump-box input:focus {
  border-color: var(--accent-blue);
}

.thumbnails-container {
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-content: start;
}

.thumb-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  align-self: start;
  height: fit-content;
  background: white;
  border-radius: 8px;
  padding: 6px;
  border: 1px solid var(--border-light);
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-subtle);
  position: relative;
}

.thumb-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-medium);
}

.thumb-card.active {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px var(--accent-blue-subtle), 0 2px 8px rgba(11, 107, 203, 0.2);
}

.thumb-canvas {
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1.414;
  border-radius: 4px;
  background: #FFF;
  object-fit: contain;
  display: block;
}

.thumb-num {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-top: 5px;
}

/* Annotations List Tab */
.annotations-list {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.annotation-item {
  background: white;
  border-radius: 6px;
  padding: 10px;
  border: 1px solid var(--border-light);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background 0.15s;
}

.annotation-item:hover {
  background: var(--bg-hover);
}

.annotation-item-header {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
}

.annotation-item-body {
  font-size: 12.5px;
  color: var(--text-primary);
  line-height: 1.4;
  word-break: break-word;
}

/* ==========================================================================
   Center Viewer
   ========================================================================== */
.viewer-container {
  flex: 1;
  height: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: #ECEAE4;
  /* Premium warm paper-like gray */
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: 90px;
  /* Space for bottom dock */
}

/* Welcome Screen */
.welcome-card {
  max-width: 500px;
  margin: 60px 20px;
  background: white;
  border-radius: 14px;
  padding: 36px 30px;
  text-align: center;
  box-shadow: var(--shadow-floating);
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 1px solid var(--border-light);
}

.welcome-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.welcome-card h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.welcome-card p {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 20px;
}

.feature-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 24px;
}

.feature-pills span {
  background: var(--bg-secondary);
  padding: 5px 10px;
  border-radius: 12px;
  font-size: 11.5px;
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}

/* PDF Pages Display */
.pdf-canvas-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 24px 16px;
  width: 100%;
}

.page-wrapper {
  position: relative;
  background: white;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
  border-radius: 4px;
  overflow: visible;
  margin: 0 auto;
}

/* Extended Margin Mode (Working Canvas with 4-side perimeter margin) */
.page-wrapper.extended-margin {
  background: #F7F6F3;
  /* Notion subtle warm gray/canvas */
  background-image: radial-gradient(rgba(55, 53, 47, 0.08) 1px, transparent 1px);
  background-size: 16px 16px;
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.09), 0 1px 4px rgba(0, 0, 0, 0.05);
}

/* The underlying PDF rendered layer */
.pdf-page-canvas {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  user-select: none;
  pointer-events: none;
  background: white;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.07), 0 2px 8px rgba(0, 0, 0, 0.04);
}

/* In extended mode, the PDF canvas is positioned at the exact center offset */
.page-wrapper.extended-margin .pdf-page-canvas {
  border-radius: 2px;
}

/* Transparent Text Layer (for selection & dictionary lookup) */
.text-layer {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  line-height: 1.0;
  user-select: text;
  -webkit-user-select: text;
  pointer-events: auto;
  opacity: 1;
}

.text-layer span {
  color: transparent;
  position: absolute;
  white-space: pre;
  cursor: text;
  transform-origin: 0% 0%;
}

.text-layer ::selection {
  background: rgba(46, 170, 220, 0.35);
}

/* The Inking Drawing Layer (Apple Pencil Canvas) */
.draw-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
  z-index: 10;
}

/* When in text or audio note mode, change pointer */
.page-wrapper.tool-text .draw-canvas,
.page-wrapper.tool-audio .draw-canvas {
  cursor: copy;
}

.page-wrapper.tool-hand .draw-canvas {
  pointer-events: none;
  /* Allows free scrolling with finger */
}

/* ==========================================================================
   Interactive Note Pins (Audio) & Floating Text Boxes on Pages
   ========================================================================== */
.notes-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 25;
}

.notes-container>* {
  pointer-events: auto;
}

.note-pin {
  position: absolute;
  z-index: 25;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.note-pin-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 2px solid var(--accent-red);
  color: var(--accent-red);
  transition: transform 0.15s ease;
}

.note-pin-badge:active {
  transform: scale(0.92);
}


/* Ghost Text Box: 100% Transparent when in resting state */
.floating-text-box {
  position: absolute;
  z-index: 35;
  min-width: 60px;
  min-height: 24px;
  background: transparent;
  border: 1px dashed transparent;
  border-radius: 4px;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  touch-action: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

/* When editing or hovering: reveal subtle boundary and floating toolbar */
.floating-text-box:hover,
.floating-text-box:focus-within,
.floating-text-box.active-focus {
  border-color: rgba(11, 107, 203, 0.45);
  background: rgba(255, 255, 255, 0.25);
}

/* Floating Toolbar: positioned on top by default, or flipped to bottom if box is at top edge */
.textbox-toolbar {
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 5px;
  height: 28px;
  background: #191919;
  color: white;
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 6px;
  user-select: none;
  -webkit-user-select: none;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 50;
  white-space: nowrap;
}

/* Flipped below the box when near top edge of page */
.floating-text-box.toolbar-bottom .textbox-toolbar {
  bottom: auto;
  top: 100%;
  margin-bottom: 0;
  margin-top: 5px;
  transform: translateY(-4px);
}

.floating-text-box:hover .textbox-toolbar,
.floating-text-box:focus-within .textbox-toolbar,
.floating-text-box.active-focus .textbox-toolbar {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.textbox-drag-handle {
  display: flex;
  align-items: center;
  gap: 3px;
  cursor: grab;
  color: #CCC;
  padding: 2px 4px;
  border-radius: 3px;
  font-size: 10px;
}

.textbox-drag-handle:active {
  cursor: grabbing;
  color: white;
}

.textbox-font-controls {
  display: flex;
  align-items: center;
  gap: 2px;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  border-right: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0 4px;
}

.btn-tb-font {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 10.5px;
  font-weight: 600;
  color: white;
  cursor: pointer;
  line-height: 1.2;
}

.btn-tb-font:active {
  background: rgba(255, 255, 255, 0.3);
}

.textbox-font-label {
  font-size: 10px;
  font-weight: 600;
  color: #CCC;
  min-width: 26px;
  text-align: center;
}

.btn-tb-delete {
  background: transparent;
  border: none;
  color: #FF6B6B;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-tb-delete:hover,
.btn-tb-delete:active {
  background: rgba(235, 87, 87, 0.25);
}

/* Textarea inside the box: completely borderless and seamless */
.textbox-textarea {
  flex: 1;
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  background: transparent;
  padding: 2px 4px;
  font-family: var(--font-sans);
  color: var(--text-primary);
  line-height: 1.35;
  resize: none;
  box-sizing: border-box;
  overflow: hidden;
}

.textbox-textarea::placeholder {
  color: rgba(55, 53, 47, 0.4);
  font-style: italic;
}

/* Corner Resize Grip Handle: subtle and only visible on active/hover */
.textbox-resize-handle {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 12px;
  height: 12px;
  cursor: nwse-resize;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  touch-action: none;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.floating-text-box:hover .textbox-resize-handle,
.floating-text-box:focus-within .textbox-resize-handle,
.floating-text-box.active-focus .textbox-resize-handle {
  opacity: 1;
  pointer-events: auto;
}

.textbox-resize-handle::after {
  content: '';
  width: 5px;
  height: 5px;
  border-right: 2px solid var(--accent-blue);
  border-bottom: 2px solid var(--accent-blue);
}

/* Note Popover / Inline Card for Audio */
.note-card-popover {
  position: absolute;
  left: 36px;
  top: 0;
  width: 250px;
  background: white;
  border-radius: 8px;
  padding: 10px;
  box-shadow: var(--shadow-floating);
  border: 1px solid var(--border-medium);
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.note-card-textarea {
  width: 100%;
  min-height: 70px;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: 6px;
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
  outline: none;
}

.note-card-textarea:focus {
  border-color: var(--accent-blue);
}

.note-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.btn-micro {
  padding: 3px 8px;
  font-size: 11px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-micro-danger {
  background: rgba(235, 87, 87, 0.12);
  color: var(--accent-red);
}

/* Audio Player inside Note */
.audio-player-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-secondary);
  padding: 4px 10px;
  border-radius: 20px;
  width: 100%;
}

.audio-play-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-red);
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* ==========================================================================
   WordReference / Dictionary Slide-over Drawer
   ========================================================================== */
.dict-drawer {
  width: var(--drawer-width);
  max-width: 90vw;
  background: #FFFFFF;
  border-left: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
  z-index: 150;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s;
  visibility: hidden;
  pointer-events: none;
}

.dict-drawer.open {
  transform: translateX(0);
  visibility: visible;
  pointer-events: auto;
}

.dict-header {
  height: var(--header-height);
  padding: 0 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #FFFFFF;
  flex-shrink: 0;
}

.dict-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
}

.dict-title i {
  color: var(--accent-blue);
}

.dict-search-box {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dict-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-icon {
  position: absolute;
  left: 10px;
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
}

.dict-input-wrap input {
  width: 100%;
  padding: 8px 32px 8px 32px;
  border: 1px solid var(--border-medium);
  border-radius: 6px;
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
  background: white;
}

.dict-input-wrap input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px var(--accent-blue-subtle);
}

.icon-btn-micro {
  position: absolute;
  right: 6px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-tertiary);
  display: flex;
}

.dict-lang-selector {
  display: flex;
  gap: 8px;
}

.dict-lang-selector select {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--border-medium);
  border-radius: 5px;
  font-size: 12px;
  background: white;
  outline: none;
}

.btn-primary-sm {
  padding: 6px 12px;
  border-radius: 5px;
  border: none;
  background: var(--accent-blue);
  color: white;
  font-weight: 500;
  font-size: 12px;
  cursor: pointer;
}

.dict-results {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  font-size: 13.5px;
  line-height: 1.5;
  background: #FFFFFF;
}

.loader-spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--border-medium);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  margin: 0 auto;
  animation: dict-spin 0.8s linear infinite;
}

@keyframes dict-spin {
  to { transform: rotate(360deg); }
}

.dict-placeholder {
  text-align: center;
  color: var(--text-secondary);
  margin-top: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* Word Definition Card */
.word-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}

.word-term {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}

.word-phonetic {
  font-family: var(--font-mono);
  color: var(--accent-blue);
  font-size: 13px;
}

.word-pos-tag {
  display: inline-block;
  background: var(--bg-hover);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.def-entry {
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
}

.def-text {
  font-weight: 500;
  margin-bottom: 4px;
}

.def-example {
  color: var(--text-secondary);
  font-style: italic;
  font-size: 12.5px;
}

.dict-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-secondary);
}

.wr-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-decoration: none;
  color: var(--accent-blue);
  font-weight: 500;
  font-size: 12.5px;
}

/* ==========================================================================
   Floating Bottom Navigation Dock (Ergonomic for iPad thumb navigation)
   Does NOT get hidden in Landscape or Portrait
   ========================================================================== */
.bottom-dock {
  position: absolute;
  bottom: calc(14px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  pointer-events: auto;
  max-width: calc(100vw - 20px);
}

.dock-inner {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  padding: 5px 8px;
  border-radius: 30px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: var(--shadow-dock);
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.dock-inner::-webkit-scrollbar {
  display: none;
}

.dock-btn {
  height: 36px;
  min-width: 36px;
  padding: 0 8px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}

.dock-btn.active {
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-weight: 600;
}

.dock-btn:hover {
  background: var(--bg-hover);
}

.dock-btn:active {
  transform: scale(0.93);
}

.dock-btn-text {
  font-size: 12px;
  display: inline-block;
}

.dock-page-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  background: var(--bg-secondary);
  border-radius: 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.dock-page-indicator .divider {
  color: var(--text-tertiary);
}

.dock-separator {
  width: 1px;
  height: 20px;
  background: var(--border-medium);
  margin: 0 4px;
}

.zoom-level-badge {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 38px;
  text-align: center;
}

.dock-btn-accent {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--text-primary);
  color: white;
  border-radius: 20px;
  border: none;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}

/* ==========================================================================
   Audio Modal / Voice Note Recorder
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-card {
  width: 90%;
  max-width: 380px;
  background: white;
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow-floating);
  text-align: center;
}

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

.modal-header h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
}

.audio-waveform-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 50px;
  margin-bottom: 16px;
}

.wave-bar {
  width: 6px;
  height: 14px;
  background: var(--accent-red);
  border-radius: 4px;
  transition: height 0.15s ease;
}

.recording .wave-bar:nth-child(1) {
  animation: wave 0.8s infinite 0.1s;
}

.recording .wave-bar:nth-child(2) {
  animation: wave 0.8s infinite 0.25s;
}

.recording .wave-bar:nth-child(3) {
  animation: wave 0.8s infinite 0.15s;
}

.recording .wave-bar:nth-child(4) {
  animation: wave 0.8s infinite 0.3s;
}

.recording .wave-bar:nth-child(5) {
  animation: wave 0.8s infinite 0.2s;
}

@keyframes wave {

  0%,
  100% {
    height: 12px;
  }

  50% {
    height: 44px;
  }
}

.audio-timer {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.modal-instruction {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.audio-controls {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.btn-record {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--accent-red);
  color: white;
  border-radius: 24px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: #191919;
  color: white;
  border-radius: 24px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

/* Sheet Options Grid inside Add Sheet Modal */
.sheet-options-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.sheet-option-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--border-light);
  background: var(--bg-hover);
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  width: 100%;
}

.sheet-option-card:hover {
  background: #FFFFFF;
  border-color: var(--accent-blue);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
}

.sheet-option-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #FFFFFF;
  border: 1px solid var(--border-light);
  color: var(--accent-blue);
  flex-shrink: 0;
}

.sheet-option-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sheet-option-text strong {
  font-size: 14px;
  color: var(--text-primary);
}

.sheet-option-text span {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Badge and delete button on thumbnails */
.thumb-card {
  position: relative;
}

.thumb-card.is-annex {
  border-color: #f59e0b;
  background: #fffdfa;
}

.thumb-annex-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  background: #f59e0b;
  color: white;
  font-size: 9px;
  font-weight: 600;
  padding: 2px 5px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.thumb-delete-annex-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(220, 38, 38, 0.9);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  transition: transform 0.15s ease;
}

.thumb-delete-annex-btn:hover {
  transform: scale(1.15);
  background: #dc2626;
}

/* ==========================================================================
   Quick Word Popover on Selection
   ========================================================================== */
.quick-word-bubble {
  position: absolute;
  z-index: 90;
  background: #191919;
  color: white;
  border-radius: 8px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  font-size: 12px;
  transform: translate(-50%, -100%) translateY(-8px);
}

.bubble-word-text {
  font-weight: 600;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bubble-btn {
  background: var(--accent-blue);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ==========================================================================
   Slide View Mode (Single Fixed Page for writing without accidental scroll)
   ========================================================================== */
.viewer-container.slide-mode {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
  padding: 16px 16px calc(80px + var(--safe-bottom)) 16px;
  display: block;
}

.pdf-canvas-stage.slide-mode {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100%;
  min-width: 100%;
  width: max-content;
  height: max-content;
  margin: 0 auto;
  padding: 0;
  gap: 0;
}

.pdf-canvas-stage.slide-mode .page-wrapper {
  display: none;
  margin: 0 auto;
}

.pdf-canvas-stage.slide-mode .page-wrapper.active-slide {
  display: block;
}

@keyframes fadeInSlide {
  from {
    opacity: 0.6;
    transform: scale(0.985);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ==========================================================================
   Class Activity History & Vocabulary Panels (Notion Style)
   ========================================================================== */
.history-controls,
.vocab-header-box {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  background: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.history-header-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.btn-micro {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 5px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-micro:hover {
  background: var(--bg-hover);
  border-color: var(--border-medium);
}

.filter-input {
  flex: 1;
  border: 1px solid var(--border-light);
  background: var(--bg-secondary);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12px;
  outline: none;
  color: var(--text-primary);
}

.filter-input:focus {
  background: white;
  border-color: var(--accent-blue);
}

.notion-textarea {
  border: 1px solid var(--border-light);
  background: var(--bg-secondary);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-primary);
  resize: vertical;
  outline: none;
  line-height: 1.45;
}

.notion-textarea:focus {
  background: white;
  border-color: var(--accent-blue);
}

.history-timeline {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.history-day-card {
  background: white;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 12px;
  box-shadow: var(--shadow-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 6px;
}

.history-day-date {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 5px;
}

.history-day-badge {
  font-size: 10.5px;
  background: var(--accent-blue-subtle);
  color: var(--accent-blue);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}

.history-events-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--bg-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.history-item:hover {
  background: var(--bg-hover);
}

.history-item-icon {
  flex-shrink: 0;
  color: var(--accent-blue);
  margin-top: 2px;
}

.history-item-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-item-title {
  font-weight: 500;
  color: var(--text-primary);
}

.history-item-meta {
  font-size: 10.5px;
  color: var(--text-tertiary);
}

/* Vocabulary List */
.vocab-list {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.vocab-card {
  background: white;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-subtle);
}

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

.vocab-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.vocab-term {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.vocab-phonetic {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
}

.vocab-def-preview {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.vocab-meta-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 10.5px;
  color: var(--text-tertiary);
}

/* ==========================================================================
   iPad 9th Orientation & Responsive Optimization
   Portrait (810px) vs Landscape (1080px)
   ========================================================================== */
@media screen and (max-width: 1100px) {
  /* On iPad (both vertical 810px and horizontal 1080px) keep header compact */
  .doc-meta {
    max-width: 140px;
  }

  .badge-status {
    font-size: 10.5px;
    padding: 2px 6px;
    white-space: nowrap;
  }

  .tool-label {
    display: none; /* Icon-only segmented bar saves >180px in iPad header */
  }

  .tool-btn {
    padding: 6px 8px;
    gap: 0;
  }

  .pen-settings {
    padding: 2px 6px;
    gap: 5px;
  }

  .color-swatch {
    width: 15px;
    height: 15px;
  }

  .search-trigger .btn-text {
    display: none; /* Show book icon on iPad to prevent pushing out Open PDF */
  }

  .search-trigger {
    padding: 0 8px;
  }

  .open-file-label {
    padding: 6px 10px;
    font-size: 12px;
    white-space: nowrap;
  }
}

@media screen and (max-width: 820px) {
  .dock-btn-text {
    display: none; /* Hide labels in bottom dock on iPad portrait to keep it compact */
  }

  .dock-btn {
    padding: 0;
    width: 34px;
    height: 34px;
    min-width: 34px;
  }

  .dock-inner {
    gap: 2px;
    padding: 4px 6px;
  }

  .dock-separator {
    margin: 0 2px;
  }

  .doc-meta {
    max-width: 110px;
  }

  .doc-title {
    font-size: 12px;
  }

  .badge-status {
    font-size: 10px;
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .pen-settings .stroke-size-selector {
    display: none;
  }

  .open-file-label span {
    display: none; /* Icon-only in very narrow portrait */
  }

  .open-file-label {
    padding: 6px 9px;
  }

  .sidebar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    box-shadow: var(--shadow-floating);
    transform: translateX(0);
    transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .sidebar.collapsed {
    margin-left: 0;
    transform: translateX(-100%);
  }

  .dict-drawer {
    width: min(380px, 92vw);
    max-width: 92vw;
  }
}