/* ==========================================================================
   THINKSMART TOOL — DESIGN SYSTEM
   Premium SaaS reskin · token-driven · light (default) + dark themes
   Brand accent: Thinksmart violet (#4F00CA family)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. DESIGN TOKENS
   -------------------------------------------------------------------------- */
:root {
  /* Brand — violet ramp derived from #4F00CA */
  --brand-50:  #F5F2FF;
  --brand-100: #ECE6FE;
  --brand-200: #D8CCFD;
  --brand-300: #B9A3FA;
  --brand-400: #9670F4;
  --brand-500: #7C3AED;   /* interactive */
  --brand-600: #6D28D9;   /* primary action */
  --brand-700: #5B21B6;   /* pressed */
  --brand-800: #4F00CA;   /* signature / logo */
  --brand-900: #3A0E7A;

  /* Semantic brand */
  --brand:            var(--brand-600);
  --brand-hover:      var(--brand-500);
  --brand-active:     var(--brand-700);
  --brand-contrast:   #FFFFFF;
  --brand-soft:       var(--brand-50);
  --brand-soft-2:     var(--brand-100);
  --brand-ring:       rgba(109, 40, 217, 0.28);
  --accent-primary:   var(--brand-600);

  /* Neutral surfaces (light) */
  --app-bg:      #F4F5F8;
  --surface:     #FFFFFF;
  --surface-2:   #FBFBFD;
  --surface-3:   #F1F2F6;
  --canvas-bg:   #E9EBF0;
  --header-bg:   #FFFFFF;

  /* Text */
  --text:    #111420;
  --text-2:  #565E70;
  --text-3:  #667085; /* đậm hơn bản cũ #8A90A2 → contrast ≥4.5:1 trên nền sáng (WCAG AA) */
  --text-on-brand: #FFFFFF;

  /* Borders */
  --border:        #E6E8EF;
  --border-strong: #D5D9E3;
  --divider:       #EEF0F4;

  /* Status */
  --success: #15A34A;  --success-soft: #E7F7EE;
  --warning: #C2740B;  --warning-soft: #FBF1E2;
  --danger:  #DC2626;  --danger-soft:  #FCECEC;
  --attention: #F59E0B; /* chấm "chưa lưu" — sáng hơn --warning vì là đèn báo, không phải chữ */

  /* File-type hues — màu theo LOẠI file xuất (thông tin, không phải trang trí):
     JPEG = teal (ảnh), PDF = đỏ (tài liệu). Nút Xuất & mockup cover dùng chung. */
  --ft-jpeg-1: #14B8A6;  --ft-jpeg-2: #0E7490;
  --ft-pdf-1:  #F43F5E;  --ft-pdf-2:  #BE123C;

  /* Category accents */
  --cat-client: var(--brand-600);
  --cat-plan:   #0E9488;
  --cat-agent:  #C2740B;

  /* Fonts */
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Fira Code', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  /* Type scale (bậc nhỏ nhất --fs-2xs dành cho eyebrow/chip; 16px trên mobile là
     hằng số chức năng chống iOS auto-zoom, không thuộc scale) */
  --fs-2xs: 10.5px;
  --fs-xs: 11.5px;
  --fs-sm: 12.5px;
  --fs-base: 14px;
  --fs-md: 15px;
  --fs-lg: 17px;
  --fs-xl: 20px;

  /* Radius */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --r-pill: 999px;

  /* Elevation (light) */
  --shadow-xs: 0 1px 2px rgba(17, 20, 32, 0.05);
  --shadow-sm: 0 1px 3px rgba(17, 20, 32, 0.08), 0 1px 2px rgba(17, 20, 32, 0.04);
  --shadow-md: 0 6px 16px rgba(17, 20, 32, 0.08), 0 2px 6px rgba(17, 20, 32, 0.04);
  --shadow-lg: 0 18px 40px rgba(17, 20, 32, 0.14), 0 6px 12px rgba(17, 20, 32, 0.06);
  --shadow-brand: 0 6px 18px rgba(109, 40, 217, 0.30);
  --shadow-inner: inset 0 1px 2px rgba(17, 20, 32, 0.06);

  /* Motion */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur: 180ms;

  /* Layout */
  --header-height: 64px;
  --sidebar-left-width: 320px;
  --sidebar-right-width: 408px;
  --status-bar-height: 34px;

  /* Scrollbar */
  --scroll-thumb: rgba(17, 20, 32, 0.16);
  --scroll-thumb-hover: rgba(17, 20, 32, 0.28);
}

/* Dark theme overrides */
body.dark-theme {
  --brand:          var(--brand-400);
  --brand-hover:    #A98BF6;
  --brand-active:   var(--brand-500);
  --brand-soft:     rgba(139, 92, 246, 0.14);
  --brand-soft-2:   rgba(139, 92, 246, 0.22);
  --brand-ring:     rgba(150, 112, 244, 0.38);
  --accent-primary: var(--brand-400);

  --app-bg:    #0B0D14;
  --surface:   #14161F;
  --surface-2: #171A25;
  --surface-3: #1F2331;
  --canvas-bg: #0D0F17;
  --header-bg: #101219;

  --text:   #F1F3F8;
  --text-2: #A7AEC0;
  --text-3: #8B93A8; /* sáng hơn bản cũ #6D7488 → contrast ≥4.5:1 trên nền tối (WCAG AA) */
  --text-on-brand: #FFFFFF;

  --border:        rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --divider:       rgba(255, 255, 255, 0.06);

  --success-soft: rgba(21, 163, 74, 0.14);
  --warning-soft: rgba(194, 116, 11, 0.16);
  --danger-soft:  rgba(220, 38, 38, 0.16);

  --cat-client: var(--brand-400);
  --cat-plan:   #2DD4BF;
  --cat-agent:  #FBBF24;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 22px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 22px 48px rgba(0, 0, 0, 0.6), 0 8px 14px rgba(0, 0, 0, 0.45);
  --shadow-brand: 0 6px 18px rgba(124, 58, 237, 0.45);
  --shadow-inner: inset 0 1px 2px rgba(0, 0, 0, 0.3);

  --scroll-thumb: rgba(255, 255, 255, 0.14);
  --scroll-thumb-hover: rgba(255, 255, 255, 0.26);
}

/* --------------------------------------------------------------------------
   2. RESET & BASE
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  background-color: var(--app-bg);
  color: var(--text);
  height: 100vh;
  height: 100dvh; /* mobile: trừ đúng thanh URL động */
  width: 100vw;
  overflow: hidden;
  font-size: var(--fs-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv05' 1, 'ss01' 1;
}

button, input, textarea, select { font-family: inherit; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: var(--r-pill);
  border: 3px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); background-clip: padding-box; }
* { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }

/* --------------------------------------------------------------------------
   3. APP LAYOUT
   -------------------------------------------------------------------------- */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
}

/* Header */
.app-header {
  height: var(--header-height);
  background-color: var(--header-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  gap: 16px;
  z-index: 100;
  box-shadow: var(--shadow-xs);
}

.header-left { display: flex; align-items: center; gap: 12px; min-width: 200px; }

.logo-icon {
  background: linear-gradient(140deg, var(--brand-500), var(--brand-800));
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-brand);
  flex-shrink: 0;
}
.logo-icon svg { width: 22px; height: 22px; }

.brand-info { display: flex; flex-direction: column; gap: 1px; }
.brand-info h1 {
  font-size: var(--fs-md);
  font-weight: 800;
  letter-spacing: -0.2px;
  line-height: 1.1;
  color: var(--text);
}
.brand-info .sub-brand {
  font-size: var(--fs-2xs);
  color: var(--brand);
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
}

.header-center { flex: 1; display: flex; justify-content: center; min-width: 0; }

.active-file-title {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface-3);
  padding: 7px 16px;
  border-radius: var(--r-pill);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  max-width: 460px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.active-file-title::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-3);
  flex-shrink: 0;
}
.active-file-title.is-active { color: var(--text); }
.active-file-title.is-active::before { background: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

.header-right { display: flex; align-items: center; gap: 10px; }

/* App body */
.app-body {
  display: flex;
  flex: 1;
  height: calc(100vh - var(--header-height));
  height: calc(100dvh - var(--header-height));
  overflow: hidden;
  position: relative;
}

aside {
  background-color: var(--surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10;
}
.sidebar-left  { width: var(--sidebar-left-width); border-right: 1px solid var(--border); }
.sidebar-right { width: var(--sidebar-right-width); border-left: 1px solid var(--border); }

/* --------------------------------------------------------------------------
   4. LEFT SIDEBAR — EXPLORER
   -------------------------------------------------------------------------- */
.sidebar-section { padding: 14px 14px; border-bottom: 1px solid var(--divider); }

.search-input-container { position: relative; width: 100%; }
.search-icon {
  position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}
.search-input-container input {
  width: 100%;
  background-color: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px 10px 40px;
  border-radius: var(--r-md);
  font-size: var(--fs-base);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.search-input-container input::placeholder { color: var(--text-3); }
.search-input-container input:hover { border-color: var(--border-strong); }
.search-input-container input:focus {
  outline: none;
  background-color: var(--surface);
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}

.category-header {
  font-size: var(--fs-2xs);
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-3);
  letter-spacing: 1px;
  margin-bottom: 10px;
}
.category-pills { display: flex; gap: 6px; }
.pill {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 7px 12px;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  cursor: pointer;
  font-weight: 600;
  transition: all var(--dur) var(--ease);
  flex: 1;
  text-align: center;
}
.pill:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }
.pill.active {
  background: var(--brand-soft);
  color: var(--brand-active);
  border-color: transparent;
  box-shadow: inset 0 0 0 1px var(--brand-200);
}
body.dark-theme .pill.active { color: var(--brand-hover); box-shadow: inset 0 0 0 1px rgba(139,92,246,0.4); }

.file-tree-section { flex: 1; overflow: hidden; padding: 14px 0 4px; display: flex; flex-direction: column; }
.section-title-container {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 16px 10px;
  font-size: var(--fs-2xs); font-weight: 700; text-transform: uppercase;
  color: var(--text-3); letter-spacing: 1px;
}
.file-count-badge {
  background-color: var(--brand-soft);
  color: var(--brand);
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: var(--fs-2xs);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.tree-container { flex: 1; overflow-y: auto; padding: 4px 8px 8px; }

/* Tree */
.tree-folder { margin-bottom: 2px; }
.tree-folder-header {
  display: flex; align-items: center;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-weight: 700;
  font-size: var(--fs-sm);
  color: var(--text-2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  user-select: none;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.tree-folder-header:hover { background-color: var(--surface-3); color: var(--text); }
.tree-folder-icon { margin-right: 8px; color: var(--text-3); display: flex; align-items: center; }
.tree-folder-arrow { margin-left: auto; color: var(--text-3); transition: transform var(--dur) var(--ease); display: flex; align-items: center; }
.tree-folder.open > .tree-folder-header > .tree-folder-arrow { transform: rotate(90deg); }
.tree-folder-content { padding-left: 8px; display: none; margin-left: 15px; margin-top: 2px; border-left: 1px solid var(--divider); }
.tree-folder.open > .tree-folder-content { display: block; }

.tree-file-item {
  display: flex; align-items: center;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: var(--fs-base);
  color: var(--text-2);
  transition: all var(--dur) var(--ease);
  margin-bottom: 2px;
  position: relative;
}
.tree-file-item:hover { background-color: var(--surface-3); color: var(--text); }
.tree-file-item.active {
  background-color: var(--brand-soft);
  color: var(--brand-active);
  font-weight: 700;
}
body.dark-theme .tree-file-item.active { color: var(--text); }
.tree-file-item.active .tree-file-icon { color: var(--brand); }
.tree-file-icon { margin-right: 9px; color: var(--text-3); display: flex; align-items: center; flex-shrink: 0; }
.tree-file-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* States */
.loading-state, .no-data, .error-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 20px; text-align: center;
  color: var(--text-3); gap: 12px; font-size: var(--fs-sm);
}
.no-data { padding: 24px 16px; }
.spinner {
  width: 26px; height: 26px;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------------------
   5. CANVAS VIEWPORT
   -------------------------------------------------------------------------- */
.canvas-viewport {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--canvas-bg);
  position: relative;
  overflow: hidden;
}

.viewport-toolbar {
  height: 46px;
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 8px;
  z-index: 5;
}
.toolbar-group {
  display: flex; align-items: center; gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 3px;
}
.toolbar-separator { width: 1px; height: 20px; background-color: var(--border); margin: 0 6px; }
.toolbar-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-2);
  width: 30px; height: 30px;
  border-radius: var(--r-xs);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}
.toolbar-btn:hover { background-color: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }
.toolbar-btn:active { transform: scale(0.94); }
.toolbar-btn.active { background-color: var(--brand-soft); color: var(--brand); }

.zoom-indicator {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-2);
  min-width: 50px;
  text-align: center;
  user-select: none;
  font-variant-numeric: tabular-nums;
}
/* Color presets */
.color-presets { display: flex; gap: 6px; align-items: center; }
.preset-btn {
  width: 18px; height: 18px; border-radius: 50%;
  border: 1px solid var(--border-strong);
  cursor: pointer; position: relative;
  transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.preset-btn:hover { transform: scale(1.15); border-color: var(--brand); }
.preset-btn.active::after {
  content: ''; position: absolute;
  width: 6px; height: 6px; background-color: #fff; border-radius: 50%;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.25);
}
.preset-btn.transparent {
  background-image:
    linear-gradient(45deg, #ccc 25%, transparent 25%),
    linear-gradient(-45deg, #ccc 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ccc 75%),
    linear-gradient(-45deg, transparent 75%, #ccc 75%);
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0;
}
.preset-btn.white { background-color: #fff; }
.preset-btn.light-purple { background-color: #F7F5FC; }
.preset-btn.dark-indigo { background-color: #241452; }
.preset-btn.dark-theme-bg { background-color: #0c0a1a; }

/* Canvas */
.canvas-container { flex: 1; position: relative; overflow: hidden; cursor: grab; user-select: none; }
.canvas-container:active { cursor: grabbing; }
.grid-backdrop {
  background-color: var(--canvas-bg);
  background-image: radial-gradient(circle, rgba(17, 20, 32, 0.10) 1px, transparent 1px);
  background-size: 22px 22px;
}
body.dark-theme .grid-backdrop { background-image: radial-gradient(circle, rgba(255, 255, 255, 0.07) 1px, transparent 1px); }
.canvas-wrapper { position: absolute; top: 0; left: 0; transform-origin: 0 0; }

.no-selection-message {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; max-width: 560px; padding: 40px 44px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  z-index: 2;
}
.no-selection-message h2 { margin-top: 18px; font-size: var(--fs-lg); font-weight: 700; color: var(--text); letter-spacing: -0.2px; white-space: nowrap; }
.no-selection-message p { margin-top: 8px; font-size: var(--fs-sm); color: var(--text-2); line-height: 1.6; }
.pulse-icon { color: var(--brand); animation: pulse-glow 2.6s infinite ease-in-out; }
@keyframes pulse-glow {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.06); opacity: 1; filter: drop-shadow(0 8px 20px var(--brand-ring)); }
}

.rendered-svg-container {
  box-shadow: var(--shadow-lg);
  border-radius: var(--r-xs);
  background-color: #fff;
  display: inline-block;
  overflow: visible;
  line-height: 0;
  transition: background-color var(--dur) var(--ease);
}
.rendered-svg-container svg { display: block; width: 100%; height: 100%; }

.canvas-status-bar {
  height: var(--status-bar-height);
  background-color: var(--surface);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px;
  font-size: var(--fs-xs);
  color: var(--text-3);
  font-weight: 500;
}

/* --------------------------------------------------------------------------
   6. RIGHT SIDEBAR — INSPECTOR
   -------------------------------------------------------------------------- */
.sidebar-right-header {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  background-color: var(--surface);
  font-weight: 800;
  font-size: var(--fs-xs);
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 1px;
  display: flex; align-items: center;
}
.sidebar-right-header svg { color: var(--brand); }

.inspector-content { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.tab-pane { display: none; padding: 14px; flex-direction: column; gap: 12px; }
.tab-pane.active { display: flex; }

/* Inspector footer (chứa 2 nút Xuất — xem mục 17) */
.sidebar-actions-footer {
  padding: 14px;
  border-top: 1px solid var(--border);
  background-color: var(--surface);
  display: flex; gap: 10px; flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   7. BUTTONS
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px;
  border-radius: var(--r-md);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn:active:not(:disabled) { transform: translateY(1px); }

.btn-primary {
  background: linear-gradient(140deg, var(--brand-500), var(--brand-700));
  color: #fff;
  box-shadow: var(--shadow-brand);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.07); box-shadow: 0 8px 22px rgba(109, 40, 217, 0.36); }
.btn-primary:disabled { background: var(--surface-3); color: var(--text-3); cursor: not-allowed; box-shadow: none; }

.btn-secondary {
  background-color: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-secondary:hover:not(:disabled) { background-color: var(--surface-3); border-color: var(--border-strong); }
.btn-secondary:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-sm { padding: 6px 12px; font-size: var(--fs-sm); border-radius: var(--r-sm); }

.action-buttons-stack { display: flex; flex-direction: column; gap: 8px; }

/* Icon / theme toggle button */
.icon-btn {
  width: 38px; height: 38px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  flex-shrink: 0;
}
.icon-btn:hover { color: var(--text); background: var(--surface-3); }
.icon-btn .icon-sun { display: none; }
.icon-btn .icon-moon { display: block; }
body.dark-theme .icon-btn .icon-sun { display: block; }
body.dark-theme .icon-btn .icon-moon { display: none; }

/* --------------------------------------------------------------------------
   8. TEXT EDITOR (inspector)
   -------------------------------------------------------------------------- */
.texts-list-container { display: flex; flex-direction: column; gap: 12px; overflow: visible; }

.text-edit-block {
  background-color: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 11px;
  display: flex; flex-direction: column; gap: 6px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background-color var(--dur) var(--ease);
  cursor: text;
}
.text-edit-block:hover { border-color: var(--brand-300); background-color: var(--brand-soft); }
.text-edit-block:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
  background-color: var(--surface);
}
.text-edit-block:focus-within .text-meta { color: var(--brand); }

.text-meta { font-size: var(--fs-xs); color: var(--text-3); font-weight: 600; margin-bottom: 2px; transition: color var(--dur) var(--ease); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.text-id { font-family: var(--font-sans); font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); letter-spacing: 0; }

.text-input-field {
  width: 100%;
  background-color: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  resize: vertical;
  line-height: 1.45;
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.text-input-field:hover { border-color: var(--brand-300); }
.text-input-field:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}

/* --------------------------------------------------------------------------
   9. TEXT GROUPS (client / plan / agent)
   -------------------------------------------------------------------------- */
.text-group {
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background-color: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.text-group-title {
  background-color: var(--surface-2);
  padding: 12px 14px;
  font-weight: 700;
  font-size: var(--fs-sm);
  color: var(--text);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
  border-left: 3px solid var(--text-3);
  transition: background-color var(--dur) var(--ease);
}
.text-group-title:hover { background-color: var(--surface-3); }
.text-group-title svg { color: var(--text-2); }
.group-arrow { color: var(--text-3); }
.text-group-items { padding: 12px; display: flex; flex-direction: column; gap: 12px; }

/* Category accents via :has (client / plan / agent) */
.text-group:has(#group-client) .text-group-title { border-left-color: var(--cat-client); }
.text-group:has(#group-client) .text-group-title svg { color: var(--cat-client); }
.text-group:has(#group-plan) .text-group-title { border-left-color: var(--cat-plan); }
.text-group:has(#group-plan) .text-group-title svg { color: var(--cat-plan); }
.text-group:has(#group-agent) .text-group-title { border-left-color: var(--cat-agent); }
.text-group:has(#group-agent) .text-group-title svg { color: var(--cat-agent); }

/* --------------------------------------------------------------------------
   10. COLORS EDITOR
   -------------------------------------------------------------------------- */
.colors-list-container {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px; max-height: 50vh; overflow-y: auto; padding-right: 4px;
}
.color-edit-block {
  background-color: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  position: relative;
  transition: all var(--dur) var(--ease);
}
.color-edit-block:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.color-picker-wrapper {
  position: relative; width: 44px; height: 44px;
  border-radius: var(--r-md); overflow: hidden;
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-inner); cursor: pointer;
}
.color-picker-input { position: absolute; top: -10px; left: -10px; width: 66px; height: 66px; border: 0; padding: 0; cursor: pointer; }
.color-hex { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--text); font-weight: 500; text-transform: uppercase; }
.color-tag { font-size: var(--fs-xs); color: var(--text-3); text-align: center; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --------------------------------------------------------------------------
   12. TOOLTIP
   -------------------------------------------------------------------------- */
.tooltip { position: relative; }
.tooltip::before {
  content: attr(data-tooltip);
  position: absolute; bottom: -34px; left: 50%;
  transform: translateX(-50%) translateY(-4px);
  background-color: var(--text);
  color: var(--surface);
  font-size: var(--fs-xs); font-weight: 600;
  padding: 5px 9px; border-radius: var(--r-xs);
  white-space: nowrap;
  opacity: 0; visibility: hidden;
  transition: all var(--dur) var(--ease);
  pointer-events: none;
  box-shadow: var(--shadow-md);
  z-index: 200;
}
.tooltip:hover::before { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }

/* --------------------------------------------------------------------------
   13. SELECTS, WARNINGS, PRESETS
   -------------------------------------------------------------------------- */
select.text-input-field, .select-field {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23565E70' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px;
}
select.text-input-field option, .select-field option { background-color: var(--surface); color: var(--text); }

/* Delete (trash) button for draft proposals */
.tree-file-delete {
  margin-left: auto;
  color: var(--text-3);
  font-size: var(--fs-sm);
  padding: 4px 6px;
  border-radius: var(--r-xs);
  opacity: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--dur) var(--ease);
}
.tree-file-item:hover .tree-file-delete { opacity: 1; }
.tree-file-delete:hover { color: var(--danger); background: var(--danger-soft); }

/* --------------------------------------------------------------------------
   14. CANVAS INTERACTIVE TEXT + HIGHLIGHT
   -------------------------------------------------------------------------- */
.svg-editable-text { cursor: pointer; transition: filter 0.12s var(--ease), opacity 0.12s var(--ease); }
/* Neutral, background-agnostic hover: a soft light+dark halo (no brand color to clash with the artwork) */
.svg-editable-text:hover {
  filter: drop-shadow(0 0 1.5px rgba(255, 255, 255, 0.95)) drop-shadow(0 0 2px rgba(0, 0, 0, 0.42)) brightness(1.03) !important;
}

@keyframes highlightFlash {
  0% { background-color: var(--brand-soft-2); box-shadow: 0 0 0 3px var(--brand-ring); }
  100% { background-color: transparent; box-shadow: none; }
}
.text-edit-block.highlight-flash { animation: highlightFlash 1.5s var(--ease-out); border-radius: var(--r-md); }

/* --------------------------------------------------------------------------
   15. FONT FACES (Illustrator PostScript names → local/woff)
   -------------------------------------------------------------------------- */
@font-face { font-family: 'SFProDisplay-Bold';    src: local('SF Pro Display Bold'), local('SFPRODISPLAYBOLD'), url('fonts/SFProDisplay-Bold.woff') format('woff'); font-display: swap; }
@font-face { font-family: 'SFProDisplay-Medium';  src: local('SF Pro Display Medium'), local('SFPRODISPLAYMEDIUM'), url('fonts/SFProDisplay-Medium.woff') format('woff'); font-display: swap; }
@font-face { font-family: 'SFProDisplay-Regular'; src: local('SF Pro Display Regular'), local('SFPRODISPLAYREGULAR'), url('fonts/SFProDisplay-Regular.woff') format('woff'); font-display: swap; }
@font-face { font-family: 'SFProDisplay-Heavy';   src: local('SF Pro Display Heavy'), local('SFPRODISPLAYHEAVY'), url('fonts/SFProDisplay-Heavy.woff') format('woff'); font-display: swap; }
@font-face { font-family: 'SFProDisplay-Black';   src: local('SF Pro Display Black'), local('SFPRODISPLAYBLACK'), url('fonts/SFProDisplay-Black.woff') format('woff'); font-display: swap; }
@font-face { font-family: 'SFProText-Bold';       src: local('SF Pro Text Bold'), local('SFPROTEXTBOLD'), url('fonts/SFProText-Bold.woff') format('woff'); font-display: swap; }
@font-face { font-family: 'SFProText-Regular';    src: local('SF Pro Text Regular'), local('SFPROTEXTREGULAR'), url('fonts/SFProText-Regular.woff') format('woff'); font-display: swap; }
/* Italic weights — real files (subset từ SF Pro cài trong Windows, 2026-07-17) */
@font-face { font-family: 'SFProDisplay-RegularItalic'; src: local('SF Pro Display Italic'), local('SFProDisplay-RegularItalic'), url('fonts/SFProDisplay-RegularItalic.woff') format('woff'); font-display: swap; }
@font-face { font-family: 'SFProDisplay-MediumItalic';  src: local('SF Pro Display Medium Italic'), local('SFProDisplay-MediumItalic'), url('fonts/SFProDisplay-MediumItalic.woff') format('woff'); font-display: swap; }
@font-face { font-family: 'SFProDisplay-BoldItalic';    src: local('SF Pro Display Bold Italic'), local('SFProDisplay-BoldItalic'), url('fonts/SFProDisplay-BoldItalic.woff') format('woff'); font-display: swap; }
/* Bodoni Moda 18pt Italic (slogan NLG) — Google Fonts, OFL license */
@font-face { font-family: 'BodoniModa18pt-Italic'; src: local('Bodoni Moda 18pt Italic'), local('BodoniModa18pt-Italic'), url('fonts/BodoniModa18pt-Italic.woff2') format('woff2'); font-display: swap; }

/* --------------------------------------------------------------------------
   16. NAVIGATION — main tools (Proposal / Brochure / Name Card)
   -------------------------------------------------------------------------- */
.tree-folder-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Top-level section (a "tool") */
.tree-folder.nav-section { margin-bottom: 6px; }
.tree-folder.nav-section > .tree-folder-header {
  text-transform: none;
  letter-spacing: -0.1px;
  font-size: var(--fs-base);
  font-weight: 800;
  color: var(--text);
  padding: 9px 10px;
  border-radius: var(--r-md);
}
.tree-folder.nav-section > .tree-folder-header:hover { background: var(--surface-3); color: var(--text); }
.tree-folder.nav-section > .tree-folder-header .tree-folder-icon {
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  background: var(--brand-soft);
  color: var(--brand);
  display: flex; align-items: center; justify-content: center;
  margin-right: 10px;
  flex-shrink: 0;
}
/* Per-section accent (children order: 1 Proposal · 2 Brochure · 3 Name Card) */
.tree-container > .tree-folder:nth-of-type(2) > .tree-folder-header .tree-folder-icon {
  background: rgba(14, 148, 136, 0.13); color: var(--cat-plan);
}
.tree-container > .tree-folder:nth-of-type(3) > .tree-folder-header .tree-folder-icon {
  background: rgba(194, 116, 11, 0.15); color: var(--cat-agent);
}
.nav-section > .tree-folder-content { margin-left: 8px; padding-left: 4px; border-left: none; margin-top: 2px; }

/* Carrier sub-group */
.tree-folder.nav-carrier > .tree-folder-header {
  text-transform: none; letter-spacing: 0;
  font-size: var(--fs-sm); font-weight: 700; color: var(--text-2);
}
.tree-folder.nav-carrier > .tree-folder-header .tree-folder-icon { color: var(--text-3); }
.nav-carrier > .tree-folder-content { margin-left: 18px; padding-left: 4px; border-left: 1px solid var(--divider); }

.nav-count {
  font-size: var(--fs-2xs); font-weight: 700; color: var(--text-3);
  background: var(--surface-3); border-radius: var(--r-pill);
  padding: 1px 7px; margin-left: 8px;
  font-variant-numeric: tabular-nums;
}
.nav-empty { padding: 9px 14px; font-size: var(--fs-sm); text-align: left; align-items: flex-start; color: var(--text-3); line-height: 1.5; }

/* --------------------------------------------------------------------------
   17. RIGHT EDITOR VISIBILITY  +  LIBRARY PREVIEW (Brochure / Name Card)
   -------------------------------------------------------------------------- */
body.no-editor .sidebar-right { display: none; }

.library-view {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column; align-items: center; justify-content: center;
  gap: 20px; padding: 32px;
  z-index: 3;
}
.library-thumb {
  background: var(--surface);
  border: none;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  max-width: min(72%, 760px);
  max-height: 62vh;
  display: flex; align-items: center; justify-content: center;
}
.library-thumb img { max-width: 100%; max-height: 60vh; display: block; }
.library-thumb-pdf { width: min(72%, 760px); height: 60vh; }
.library-thumb-pdf iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.library-thumb-file { width: 200px; height: 200px; color: var(--text-3); }
.library-meta { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.library-name { font-weight: 700; font-size: var(--fs-lg); color: var(--text); letter-spacing: -0.2px; }
.library-sub { font-size: var(--fs-sm); color: var(--text-2); font-variant-numeric: tabular-nums; }
.library-download { margin-top: 10px; text-decoration: none; padding: 11px 26px; }

/* Prominent export buttons (JPEG + PDF) — footer khai báo ở mục 6 */
.sidebar-actions-footer .btn-export-main {
  flex: 1 1 0;
  min-width: 0;
  font-size: var(--fs-base);
  font-weight: 700;
  padding: 13px 10px;
  gap: 8px;
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur) var(--ease), filter var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.btn-export-jpeg { background: linear-gradient(140deg, var(--ft-jpeg-1), var(--ft-jpeg-2)); }
.btn-export-pdf  { background: linear-gradient(140deg, var(--brand-500), var(--brand-700)); }
.btn-export-main:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-export-main:active:not(:disabled) { transform: translateY(0); }
.btn-export-main:disabled { background: var(--surface-3); color: var(--text-3); box-shadow: none; cursor: not-allowed; }

/* --------------------------------------------------------------------------
   18. ACCESSIBILITY — reduced motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* --------------------------------------------------------------------------
   19. LIBRARY GROUP VIEW (Multiple Brochures / Name Cards)
   -------------------------------------------------------------------------- */
.library-view-group {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: 40px;
  display: flex;
  flex-wrap: wrap;
  gap: 32px;
  justify-content: center;
  align-content: flex-start;
}

/* Ensure parent library-view is scrollable and styled correctly when group is active */
.library-view.has-group {
  display: block !important;
  overflow-y: auto;
  padding: 0;
  align-items: stretch;
  justify-content: stretch;
}

.library-item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
  width: 440px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.library-item-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.library-card-preview {
  height: 580px;
  background: var(--surface-3); /* Light grey container canvas */
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-bottom: 1px solid var(--divider);
  position: relative;
  padding: 24px;
}

.library-card-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain; /* Preserve aspect ratio strictly */
  background: #ffffff;
  box-shadow: 0 10px 24px -4px rgba(17, 20, 32, 0.15), 0 4px 8px -2px rgba(17, 20, 32, 0.1);
  border-radius: var(--r-xs);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.library-item-card:hover .library-card-preview img {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 20px 32px -8px rgba(17, 20, 32, 0.25), 0 8px 16px -4px rgba(17, 20, 32, 0.15);
}

/* Premium PDF Mockup Cover */
.library-card-preview-pdf {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--ft-pdf-1), var(--ft-pdf-2));
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  box-shadow: 0 10px 24px -4px rgba(17, 20, 32, 0.15), 0 4px 8px -2px rgba(17, 20, 32, 0.1);
  border-radius: var(--r-xs);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.library-item-card:hover .library-card-preview-pdf {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 20px 32px -8px rgba(17, 20, 32, 0.25), 0 8px 16px -4px rgba(17, 20, 32, 0.15);
}

.pdf-icon-wrapper {
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--r-md);
  padding: 16px;
  margin-bottom: 16px;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--dur) var(--ease);
}

.library-item-card:hover .pdf-icon-wrapper {
  transform: scale(1.08) rotate(-2deg);
}

.library-card-info {
  padding: 20px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.library-card-title {
  font-size: var(--fs-base);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.4;
  min-height: 2.8em; /* Ensure 2 lines alignment */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.library-card-meta {
  font-size: var(--fs-xs);
  color: var(--text-3);
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.library-card-ext {
  background: var(--surface-3);
  color: var(--text-2);
  padding: 2px 6px;
  border-radius: var(--r-xs);
  font-size: var(--fs-2xs);
  font-weight: 800;
  letter-spacing: 0.5px;
}

.library-card-btn {
  margin-top: auto;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: var(--fs-sm);
  font-weight: 700;
  border-radius: var(--r-md);
  background: var(--brand-soft);
  color: var(--brand);
  border: 1px solid transparent;
  transition: all var(--dur) var(--ease);
  text-decoration: none;
}

.library-item-card:hover .library-card-btn {
  background: var(--brand);
  color: #FFFFFF;
  box-shadow: var(--shadow-brand);
}


/* --------------------------------------------------------------------------
   20. MOBILE (≤ 900px) — drawer trái + bottom-sheet phải + cử chỉ cảm ứng
   -------------------------------------------------------------------------- */

/* Các nút chỉ dành cho mobile: ẩn trên desktop */
.mobile-only { display: none; }
.mobile-backdrop { display: none; }

@media (max-width: 900px) {
  :root {
    --header-height: 56px;
    --sidebar-left-width: min(320px, 86vw);
  }

  /* ---- Header gọn: ẩn chữ thương hiệu + tên file, nút chỉ còn icon ---- */
  .app-header { padding: 0 10px; gap: 8px; }
  .header-left { min-width: 0; gap: 8px; }
  .logo-icon { width: 34px; height: 34px; }
  .logo-icon svg { width: 18px; height: 18px; }
  .brand-info { display: none; }
  .header-center { display: none; }
  .header-right { gap: 6px; margin-left: auto; }
  .header-right .btn {
    font-size: 0;          /* giấu chữ, giữ icon (svg có width/height riêng) */
    gap: 0;
    padding: 9px 11px;
  }
  .header-right .btn svg { width: 18px; height: 18px; }

  #btn-mobile-nav { display: inline-flex; }
  #btn-editor-close { display: inline-flex; }
  body:not(.no-editor) #btn-mobile-editor { display: inline-flex; }

  /* ---- Sidebar trái → ngăn kéo trượt từ cạnh trái ---- */
  .sidebar-left {
    position: fixed;
    top: var(--header-height);
    bottom: 0;
    left: 0;
    width: var(--sidebar-left-width);
    transform: translateX(-105%);
    transition: transform 240ms var(--ease);
    z-index: 300;
    box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar-left { transform: translateX(0); }

  /* ---- Sidebar phải → bottom sheet trượt từ cạnh dưới ---- */
  .sidebar-right {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    width: 100%;
    height: min(66vh, 580px);
    height: min(66dvh, 580px);
    transform: translateY(105%);
    transition: transform 260ms var(--ease);
    z-index: 300;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    box-shadow: var(--shadow-lg);
  }
  body.editor-open .sidebar-right { transform: translateY(0); }

  /* ---- Backdrop mờ khi drawer / sheet đang mở ---- */
  .mobile-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 22, 0.45);
    z-index: 250;
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms var(--ease);
  }
  body.nav-open .mobile-backdrop,
  body.editor-open .mobile-backdrop { opacity: 1; pointer-events: auto; }

  /* ---- Canvas: tự xử lý cảm ứng (1 ngón kéo, 2 ngón chụm zoom) ---- */
  .canvas-container { touch-action: none; }

  /* ---- Kích thước chạm chuẩn ≥44px (Apple HIG / Material) ---- */
  .toolbar-btn { width: 44px; height: 44px; }
  .icon-btn { width: 44px; height: 44px; }
  .tree-file-item { padding-top: 12px; padding-bottom: 12px; }
  .tree-file-delete { padding: 10px; margin: -6px 0; } /* vùng chạm to, không làm dòng cao thêm */

  /* ---- iOS: input < 16px sẽ bị tự phóng to khi focus → nâng lên 16px ---- */
  .text-input-field, #search-input { font-size: 16px; }

  /* ---- Status bar: bỏ mẹo giữ Space (không áp dụng cho cảm ứng) ---- */
  #status-right { display: none; }

  /* ---- Preview thư viện brochure vừa khung màn nhỏ ---- */
  .library-view-group { padding: 16px; gap: 16px; }
  .library-item-card { width: 100%; }
  .library-card-preview { height: auto; min-height: 220px; max-height: 60vh; padding: 12px; }
  .library-thumb, .library-thumb-pdf { max-width: 94%; width: auto; }
}

/* --------------------------------------------------------------------------
   21. WORKFLOW ĐƠN GIẢN — 4 bước chào mừng + chấm "chưa lưu nháp"
   -------------------------------------------------------------------------- */
.welcome-steps {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 18px;
}
.welcome-steps .step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 7px 14px;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
}
.welcome-steps .step b { color: var(--brand); margin-right: 5px; }
.welcome-steps .arrow { color: var(--text-3); font-weight: 700; }

/* Nút Lưu Nháp hiện chấm cam khi bản đang mở có thay đổi chưa lưu */
#btn-save-top { position: relative; }
#btn-save-top.has-unsaved::after {
  content: '';
  position: absolute;
  top: -4px;
  right: -4px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--attention);
  border: 2px solid var(--header-bg);
}

/* Mobile: khung chào hẹp → cho tiêu đề xuống dòng bình thường, card chiếm 88% màn */
@media (max-width: 900px) {
  .no-selection-message { width: 88vw; max-width: 88vw; padding: 28px 20px; }
  .no-selection-message h2 { white-space: normal; }
}

/* Mobile: không có hover → icon thùng rác của bản nháp luôn hiện */
@media (max-width: 900px) {
  .tree-file-delete { opacity: 1; }
}

/* Hàng chỉnh sửa gộp của cột biểu đồ IUL: [ô tiền | ô tuổi] */
.dual-input-row { display: flex; gap: 8px; }
.dual-input-row .text-input-field { min-width: 0; flex: 1; }
.dual-input-row .dual-age { flex: 0 0 40%; }
