/**
 * FontStudio VN - Hệ thống Thiết kế Bàn làm việc Chuyên nghiệp (Creative Type Foundry Studio)
 * Tuân thủ nghiêm ngặt AGENTS.md:
 * 1. Nạp phông chữ giao diện cục bộ (@font-face) chuẩn Tiếng Việt.
 * 2. Thang chữ đáp ứng 4 điểm gãy tường minh (không để clamp() trôi tự do).
 * 3. Căn tâm nút bấm hình học trên cả 2 trục ngang/dọc (sai lệch <= 2px).
 * 4. Thẻ cùng hàng cao bằng nhau tuyệt đối (sai lệch <= 1px, chân thẻ margin-top: auto).
 * 5. Tuyệt đối 0% Inline Style (mọi trạng thái điều khiển qua lớp CSS và thẻ <progress>/<canvas>).
 */

/* ==========================================================================
   1. KHAI BÁO PHÔNG CHỮ GIAO DIỆN & KHO 16 PHÔNG TÍCH HỢP CỤC BỘ
   ========================================================================== */
@font-face {
  font-family: "Be Vietnam Pro";
  src: url("../fonts/ui/BeVietnamPro-400.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: block;
}
@font-face {
  font-family: "Be Vietnam Pro";
  src: url("../fonts/ui/BeVietnamPro-500.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: block;
}
@font-face {
  font-family: "Be Vietnam Pro";
  src: url("../fonts/ui/BeVietnamPro-600.ttf") format("truetype");
  font-weight: 600;
  font-style: normal;
  font-display: block;
}
@font-face {
  font-family: "Be Vietnam Pro";
  src: url("../fonts/ui/BeVietnamPro-700.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: block;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("../fonts/ui/JetBrainsMono-400.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: block;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("../fonts/ui/JetBrainsMono-500.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: block;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("../fonts/ui/JetBrainsMono-600.ttf") format("truetype");
  font-weight: 600;
  font-style: normal;
  font-display: block;
}

/* 16 phông chữ tích hợp sẵn cho thẻ xem trước danh mục & kết quả quét */
@font-face { font-family: "Cat_BeVietnamPro"; src: url("../fonts/catalog/BeVietnamPro-Regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Cat_Inter"; src: url("../fonts/catalog/Inter-Regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Cat_Roboto"; src: url("../fonts/catalog/Roboto-Regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Cat_Montserrat"; src: url("../fonts/catalog/Montserrat-Regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Cat_Raleway"; src: url("../fonts/catalog/Raleway-Regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Cat_Oswald"; src: url("../fonts/catalog/Oswald-Regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Cat_PlayfairDisplay"; src: url("../fonts/catalog/PlayfairDisplay-Regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Cat_Lora"; src: url("../fonts/catalog/Lora-Regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Cat_Merriweather"; src: url("../fonts/catalog/Merriweather-Regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Cat_RobotoSlab"; src: url("../fonts/catalog/RobotoSlab-Regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Cat_Cinzel"; src: url("../fonts/catalog/Cinzel-Regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Cat_AbrilFatface"; src: url("../fonts/catalog/AbrilFatface-Regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Cat_Orbitron"; src: url("../fonts/catalog/Orbitron-Regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Cat_DancingScript"; src: url("../fonts/catalog/DancingScript-Regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Cat_PatrickHand"; src: url("../fonts/catalog/PatrickHand-Regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Cat_JetBrainsMono"; src: url("../fonts/catalog/JetBrainsMono-Regular.ttf") format("truetype"); font-display: swap; }

.font-cat-builtin_be_vietnam_pro { font-family: "Cat_BeVietnamPro", sans-serif; }
.font-cat-builtin_inter { font-family: "Cat_Inter", sans-serif; }
.font-cat-builtin_roboto { font-family: "Cat_Roboto", sans-serif; }
.font-cat-builtin_montserrat { font-family: "Cat_Montserrat", sans-serif; }
.font-cat-builtin_raleway { font-family: "Cat_Raleway", sans-serif; }
.font-cat-builtin_oswald { font-family: "Cat_Oswald", sans-serif; }
.font-cat-builtin_playfair_display { font-family: "Cat_PlayfairDisplay", serif; }
.font-cat-builtin_lora { font-family: "Cat_Lora", serif; }
.font-cat-builtin_merriweather { font-family: "Cat_Merriweather", serif; }
.font-cat-builtin_roboto_slab { font-family: "Cat_RobotoSlab", serif; }
.font-cat-builtin_cinzel { font-family: "Cat_Cinzel", serif; }
.font-cat-builtin_abril_fatface { font-family: "Cat_AbrilFatface", serif; }
.font-cat-builtin_orbitron { font-family: "Cat_Orbitron", sans-serif; }
.font-cat-builtin_dancing_script { font-family: "Cat_DancingScript", cursive; }
.font-cat-builtin_patrick_hand { font-family: "Cat_PatrickHand", cursive; }
.font-cat-builtin_jetbrains_mono { font-family: "Cat_JetBrainsMono", monospace; }

/* ==========================================================================
   2. BIẾN TOKEN MÀU SẮC & THANG CHỮ ĐÁP ỨNG 4 ĐIỂM GÃY TƯỜNG MINH
   ========================================================================== */
:root {
  --bg-studio-canvas: #f8fafc;
  --bg-surface-card: #ffffff;
  --bg-surface-subtle: #f1f5f9;
  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;

  --color-primary: #4338ca;
  --color-primary-hover: #3730a3;
  --color-primary-soft: #eef2ff;
  --color-primary-border: #c7d2fe;

  --color-text-main: #0f172a;
  --color-text-secondary: #475569;

  /* Điểm gãy 1: Desktop (>= 1200px) */
  --fs-workspace-title: 26px;
  --lh-workspace-title: 1.30;

  --fs-section-title: 20px;
  --lh-section-title: 1.35;

  --fs-card-title: 19px;
  --lh-card-title: 1.38;

  --fs-lead: 18px;
  --lh-lead: 1.50;

  --fs-body: 16px;
  --lh-body: 1.55;

  --fs-label-meta: 13.5px;
  --lh-label-meta: 1.45;

  --fs-glyph-code: 11.5px;
  --lh-glyph-code: 1.30;
}

/* Điểm gãy 2: Tablet (992px – 1199px) */
@media (max-width: 1199.98px) {
  :root {
    --fs-workspace-title: 24px;
    --fs-section-title: 19.5px;
    --fs-card-title: 18.5px;
    --fs-lead: 17px;
    --fs-body: 16px;
    --fs-label-meta: 13.5px;
    --fs-glyph-code: 11.5px;
  }
}

/* Điểm gãy 3: Small Tablet (768px – 991px) */
@media (max-width: 991.98px) {
  :root {
    --fs-workspace-title: 23px;
    --fs-section-title: 19px;
    --fs-card-title: 18px;
    --fs-lead: 16px;
    --fs-body: 15.5px;
    --fs-label-meta: 13px;
    --fs-glyph-code: 11px;
  }
}

/* Điểm gãy 4: Mobile (< 768px) — Tuân thủ trần AGENTS.md */
@media (max-width: 767.98px) {
  :root {
    --fs-workspace-title: 21px;
    --lh-workspace-title: 1.35;

    --fs-section-title: 18px;
    --lh-section-title: 1.38;

    --fs-card-title: 17.5px;
    --lh-card-title: 1.40;

    --fs-lead: 16px;
    --fs-body: 15px;
    --fs-label-meta: 13px;
    --fs-glyph-code: 11px;
  }
}

.studio-body {
  font-family: "Be Vietnam Pro", system-ui, -apple-system, sans-serif;
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--color-text-main);
  background-color: var(--bg-studio-canvas);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.studio-main {
  flex: 1 1 auto;
}

.studio-container {
  width: 100%;
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 16px;
  padding-right: 16px;
}

@media (min-width: 640px) {
  .studio-container {
    padding-left: 24px;
    padding-right: 24px;
  }
}

.selection-indigo ::selection {
  background-color: #e0e7ff;
  color: #1e1b4b;
}

/* Các lớp tiêu thụ Token Thang chữ */
.typo-workspace-title {
  font-size: var(--fs-workspace-title);
  line-height: var(--lh-workspace-title);
  letter-spacing: -0.015em;
}
.typo-section-title {
  font-size: var(--fs-section-title);
  line-height: var(--lh-section-title);
  letter-spacing: -0.01em;
}
.typo-card-title {
  font-size: var(--fs-card-title);
  line-height: var(--lh-card-title);
}
.typo-lead {
  font-size: var(--fs-lead);
  line-height: var(--lh-lead);
}
.typo-body {
  font-size: var(--fs-body);
  line-height: var(--lh-body);
}
.typo-meta {
  font-size: var(--fs-label-meta);
  line-height: var(--lh-label-meta);
}

/* ==========================================================================
   3. CHUẨN CĂN TÂM NÚT BẤM HÌNH HỌC (MANDATORY BUTTON ALIGNMENT <= 2PX)
   ========================================================================== */
.btn-studio {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-sizing: border-box;
  text-align: center;
  vertical-align: middle;
  font-family: "Be Vietnam Pro", sans-serif;
  font-weight: 600;
  line-height: 1.25;
  border-radius: 9px;
  border: 1px solid transparent;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  text-decoration: none;
  cursor: pointer;
}

.btn-studio.w-full {
  display: flex;
  width: 100%;
}

.btn-studio > svg,
.seg-workspace-btn > svg,
.brand-logo-btn svg {
  display: block;
  flex-shrink: 0;
}

.btn-studio > span,
.seg-workspace-btn > span,
.source-tab-btn > span {
  line-height: 1.25;
}

.btn-studio:focus-visible,
.seg-workspace-btn:focus-visible,
.source-tab-btn:focus-visible,
.seg-choice-btn:focus-visible,
.filter-pill-btn:focus-visible,
.glyph-matrix-cell:focus-visible {
  outline: 2px solid #4f46e5;
  outline-offset: 2px;
}

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

/* Bậc kích thước nút chuẩn cân xứng trên/dưới & trái/phải */
.btn-xs {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 12.5px;
  gap: 5px;
  border-radius: 7px;
}

.btn-sm {
  min-height: 36px;
  padding: 7px 13px;
  font-size: 13.5px;
  gap: 6px;
}

.btn-md {
  min-height: 40px;
  padding: 8px 16px;
  font-size: 14.5px;
  gap: 8px;
}

.btn-lg {
  min-height: 46px;
  padding: 11px 20px;
  font-size: 15.5px;
  gap: 9px;
  border-radius: 10px;
}

.btn-icon {
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  border-radius: 9px;
}

/* Biến thể màu sắc nút bấm */
.btn-primary {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
  color: #ffffff;
  box-shadow: 0 1px 2px rgba(30, 27, 75, 0.14);
}
.btn-primary:hover:not(:disabled) {
  background-color: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

.btn-indigo-soft {
  background-color: var(--color-primary-soft);
  border-color: var(--color-primary-border);
  color: #3730a3;
}
.btn-indigo-soft:hover:not(:disabled) {
  background-color: #e0e7ff;
}

.btn-secondary {
  background-color: #ffffff;
  border-color: #cbd5e1;
  color: #1e293b;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.btn-secondary:hover:not(:disabled) {
  background-color: #f8fafc;
  border-color: #94a3b8;
}

.btn-secondary-active {
  background-color: #eef2ff;
  border-color: #6366f1;
  color: #3730a3;
}

.btn-ghost {
  background-color: transparent;
  border-color: transparent;
  color: #475569;
}
.btn-ghost:hover:not(:disabled) {
  background-color: #f1f5f9;
  color: #0f172a;
}

.btn-danger-soft {
  background-color: #fff1f2;
  border-color: #fecdd3;
  color: #9f1239;
}
.btn-danger-soft:hover:not(:disabled) {
  background-color: #ffe4e6;
}

/* Chip mẫu thử nhanh 1 chạm */
.btn-chip {
  background-color: #ffffff;
  border-color: #cbd5e1;
  color: #1e293b;
  border-radius: 999px;
  min-height: 34px;
  padding: 5px 11px;
  font-size: 13px;
}
.btn-chip:hover {
  border-color: #6366f1;
  color: #3730a3;
  background-color: #f5f7ff;
}
.btn-chip.is-active {
  background-color: #3730a3;
  border-color: #3730a3;
  color: #ffffff;
}
.chip-mini-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  background-color: #f1f5f9;
  color: #475569;
}
.btn-chip.is-active .chip-mini-tag {
  background-color: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

/* ==========================================================================
   4. THANH ĐIỀU HƯỚNG ĐỈNH & PRELINE SEGMENTED TABS
   ========================================================================== */
.brand-logo-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 4px 6px;
  min-height: 40px;
  border-radius: 10px;
  color: #0f172a;
  box-sizing: border-box;
}
.brand-logo-btn:hover {
  background-color: #f8fafc;
}
.brand-mark-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background-color: #3730a3;
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(49, 46, 129, 0.25);
}
.brand-text-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.brand-name-main {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.brand-ver-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  border-radius: 6px;
  background-color: #eef2ff;
  color: #4338ca;
}

.privacy-trust-badge {
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background-color: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.25;
}

.workspace-seg-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background-color: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 11px;
}

.seg-workspace-btn {
  flex: 1 1 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
  color: #475569;
  box-sizing: border-box;
  text-align: center;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.seg-workspace-btn:hover:not(.active) {
  color: #0f172a;
}
.seg-workspace-btn.active {
  background-color: #ffffff;
  color: #4338ca;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.tab-live-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.2;
  background-color: #eef2ff;
  color: #3730a3;
  white-space: nowrap;
}
.pill-emerald-soft {
  background-color: #ecfdf5;
  color: #065f46;
}

@media (max-width: 767.98px) {
  .seg-workspace-btn {
    padding: 6px 10px;
    font-size: 13.5px;
    gap: 6px;
    white-space: nowrap;
  }
  .seg-workspace-btn .tab-live-pill {
    display: none;
  }
  .brand-name-main {
    font-size: 15px;
  }
  .brand-logo-btn {
    gap: 7px;
    padding: 2px 4px;
  }
  .brand-mark-box {
    width: 32px;
    height: 32px;
  }
  .studio-topbar .btn-md {
    min-height: 36px;
    padding: 6px 10px;
    font-size: 13px;
    gap: 5px;
  }
}

.studio-count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  padding: 2px 7px;
  border-radius: 999px;
  background-color: #eef2ff;
  color: #3730a3;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
}

/* Thanh thẻ ngăn gạch chân cân xứng (Bordered Tabs) */
.source-tabs-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-bottom: 1px solid #e2e8f0;
}

.source-tab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 14px;
  border-top: 2px solid transparent;
  border-bottom: 2px solid transparent;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
  color: #475569;
  box-sizing: border-box;
  text-align: center;
  margin-bottom: -1px;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.source-tab-btn:hover:not(.active) {
  color: #0f172a;
}
.source-tab-btn.active {
  color: #4338ca;
  border-bottom-color: #4f46e5;
}

/* Nhóm nút phân đoạn 2 trạng thái (Segmented Pill Radio) */
.seg-pill-group {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  background-color: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 9px;
}
.seg-pill-group.grid {
  display: grid;
}
.seg-choice-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  color: #475569;
  box-sizing: border-box;
  text-align: center;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.seg-choice-btn:hover:not(.is-selected) {
  color: #0f172a;
}
.seg-choice-btn.is-selected {
  background-color: #ffffff;
  color: #3730a3;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.filter-pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background-color: #ffffff;
  color: #334155;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.25;
  box-sizing: border-box;
  text-align: center;
}
.filter-pill-btn:hover {
  border-color: #6366f1;
  color: #3730a3;
}
.filter-pill-btn.is-active {
  background-color: #4338ca;
  border-color: #4338ca;
  color: #ffffff;
}

/* ==========================================================================
   5. BỀ MẶT BÀN LÀM VIỆC & CHUẨN THẺ CÙNG HÀNG CAO BẰNG NHAU (EQUAL-HEIGHT)
   ========================================================================== */
.context-sample-strip {
  background-color: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 14px 18px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.studio-panel {
  background-color: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.equal-card-grid {
  align-items: stretch;
}

.studio-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  box-sizing: border-box;
  background-color: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: 13px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.studio-card-footer {
  margin-top: auto;
}

.result-font-card.is-rank-one {
  border-color: #818cf8;
  box-shadow: 0 3px 10px rgba(67, 56, 202, 0.08);
}

.result-font-card.is-selected-compare {
  border-color: #4f46e5;
}

.studio-export-card {
  background-color: #ffffff;
  border: 1.5px solid #818cf8;
  border-radius: 14px;
  box-shadow: 0 4px 12px rgba(67, 56, 202, 0.08);
}

/* ==========================================================================
   6. VÙNG VẼ ĐỒ HỌA <CANVAS> & KHUNG SO SÁNH
   ========================================================================== */
.canvas-stage-frame {
  position: relative;
  border-radius: 11px;
  border: 1.5px dashed #cbd5e1;
  background-color: #f1f5f9;
  overflow: hidden;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.canvas-stage-frame.is-dragover,
.upload-drop-card.is-dragover {
  border-color: #4f46e5;
  background-color: #eef2ff;
}

.studio-crop-canvas {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 360px;
  touch-action: none;
  margin-left: auto;
  margin-right: auto;
}

.canvas-binary-frame,
.canvas-compare-frame,
.inspector-canvas-wrap {
  border-radius: 11px;
  border: 1px solid #cbd5e1;
  background-color: #ffffff;
  overflow: hidden;
}

.studio-binary-canvas {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 160px;
  margin-left: auto;
  margin-right: auto;
}

.studio-compare-canvas {
  display: block;
  width: 100%;
  height: auto;
}

.studio-inspector-canvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
}

/* Thu gọn thanh trượt trên màn hình Mobile khi bấm nút Ẩn/Hiện */
@media (max-width: 767.98px) {
  #scan-preprocess-controls.mobile-collapsed {
    display: none;
  }
}

.specimen-preview-box {
  padding: 14px 16px;
  border-radius: 10px;
  background-color: #f8fafc;
  border: 1px solid #e2e8f0;
  font-size: 28px;
  line-height: 1.35;
  color: #0f172a;
  overflow-wrap: break-word;
  word-break: break-word;
}

.catalog-sample-line {
  padding: 9px 12px;
  border-radius: 8px;
  background-color: #f8fafc;
  border: 1px solid #f1f5f9;
  font-size: 19px;
  line-height: 1.35;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compare-specimen-card {
  padding: 16px 18px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
}
.compare-before {
  background-color: #f8fafc;
}
.compare-after {
  background-color: #ffffff;
  border-color: #a5b4fc;
  box-shadow: 0 2px 8px rgba(67, 56, 202, 0.06);
}

/* Các lớp cỡ chữ xem trước động (Thay thế hoàn toàn element.style.fontSize) */
.preview-fs-18 { font-size: 18px; line-height: 1.55; }
.preview-fs-24 { font-size: 24px; line-height: 1.50; }
.preview-fs-32 { font-size: 32px; line-height: 1.45; }
.preview-fs-44 { font-size: 44px; line-height: 1.38; }

@media (max-width: 639.98px) {
  .preview-fs-32 { font-size: 25px; }
  .preview-fs-44 { font-size: 32px; }
}

/* ==========================================================================
   7. LƯỚI MA TRẬN 134 KÝ TỰ TIẾNG VIỆT
   ========================================================================== */
.glyph-matrix-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

@media (min-width: 640px) {
  .glyph-matrix-grid {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }
}
@media (min-width: 1024px) {
  .glyph-matrix-grid {
    grid-template-columns: repeat(9, minmax(0, 1fr));
  }
}
@media (min-width: 1280px) {
  .glyph-matrix-grid {
    grid-template-columns: repeat(11, minmax(0, 1fr));
  }
}

.glyph-matrix-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 7px 6px;
  min-height: 82px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background-color: #ffffff;
  box-sizing: border-box;
  text-align: center;
  transition: border-color 0.12s ease, background-color 0.12s ease, box-shadow 0.12s ease;
}
.glyph-matrix-cell:hover {
  border-color: #6366f1;
  background-color: #f8faff;
}
.glyph-matrix-cell.is-inspected {
  border-color: #4338ca;
  background-color: #eef2ff;
  box-shadow: 0 0 0 1px #4338ca;
}

.glyph-matrix-char {
  font-size: 26px;
  line-height: 1.3;
  color: #0f172a;
  margin: 2px 0;
}

.glyph-matrix-code {
  font-size: var(--fs-glyph-code);
  line-height: var(--lh-glyph-code);
  color: #64748b;
}

.glyph-origin-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
}
.tag-orig { background-color: #ecfdf5; color: #065f46; }
.tag-new { background-color: #eef2ff; color: #3730a3; }
.tag-unify { background-color: #fffbeb; color: #92400e; }

.glyph-override-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background-color: #e11d48;
}
.glyph-override-dot.is-invisible {
  opacity: 0;
}

/* ==========================================================================
   8. BIỂU MẪU, THANH TRƯỢT, THẺ <PROGRESS> & CHÚ GIẢI THUẦN CSS
   ========================================================================== */
.studio-input,
.studio-select,
.studio-textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 9px;
  border: 1px solid #cbd5e1;
  background-color: #ffffff;
  color: #0f172a;
  font-size: var(--fs-body);
  line-height: 1.4;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.studio-input:focus,
.studio-select:focus,
.studio-textarea:focus,
.studio-num-input:focus,
.studio-select-sm:focus {
  outline: none;
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.14);
}

.studio-select-sm {
  min-height: 36px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background-color: #ffffff;
  font-size: 13px;
  font-weight: 500;
  color: #1e293b;
}

.studio-num-input {
  width: 68px;
  min-height: 32px;
  padding: 4px 8px;
  border-radius: 7px;
  border: 1px solid #cbd5e1;
  background-color: #ffffff;
  text-align: center;
  font-size: 13px;
}

.studio-checkbox {
  width: 18px;
  height: 18px;
  accent-color: #4338ca;
  cursor: pointer;
}

.studio-range {
  width: 100%;
  height: 6px;
  accent-color: #4338ca;
  cursor: pointer;
}
.studio-range:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Thẻ <progress> chuẩn HTML5 không dùng Inline Width Style */
.studio-progress {
  -webkit-appearance: none;
  appearance: none;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  border: none;
  background-color: #e2e8f0;
}
.studio-progress::-webkit-progress-bar {
  background-color: #e2e8f0;
  border-radius: 999px;
}
.studio-progress::-webkit-progress-value {
  border-radius: 999px;
  transition: width 0.2s ease;
}
.studio-progress::-moz-progress-bar {
  border-radius: 999px;
}

.progress-indigo::-webkit-progress-value { background-color: #4338ca; }
.progress-indigo::-moz-progress-bar { background-color: #4338ca; }

.progress-emerald::-webkit-progress-value { background-color: #059669; }
.progress-emerald::-moz-progress-bar { background-color: #059669; }

.progress-amber::-webkit-progress-value { background-color: #d97706; }
.progress-amber::-moz-progress-bar { background-color: #d97706; }

.progress-rose::-webkit-progress-value { background-color: #e11d48; }
.progress-rose::-moz-progress-bar { background-color: #e11d48; }

.progress-slate::-webkit-progress-value { background-color: #475569; }
.progress-slate::-moz-progress-bar { background-color: #475569; }

/* Huy hiệu & Thẻ cảnh báo */
.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 9px;
  border-radius: 6px;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  background-color: #f1f5f9;
  color: #334155;
}
.rank-badge-top {
  background-color: #3730a3;
  color: #ffffff;
}

.status-pill,
.studio-meta-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  border: 1px solid transparent;
}
.studio-meta-pill {
  background-color: #f1f5f9;
  border-color: #e2e8f0;
  color: #334155;
}
.pill-emerald { background-color: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.pill-amber { background-color: #fffbeb; border-color: #fde68a; color: #92400e; }
.pill-rose { background-color: #fff1f2; border-color: #fecdd3; color: #9f1239; }
.pill-indigo { background-color: #eef2ff; border-color: #c7d2fe; color: #3730a3; }
.pill-slate { background-color: #f8fafc; border-color: #e2e8f0; color: #475569; }

.studio-alert {
  padding: 12px 15px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: var(--fs-label-meta);
  line-height: 1.48;
}
.alert-emerald { background-color: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-amber { background-color: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-rose { background-color: #fff1f2; border-color: #fecdd3; color: #9f1239; }
.alert-indigo { background-color: #eef2ff; border-color: #c7d2fe; color: #3730a3; }

.upload-drop-card {
  border-radius: 12px;
  border: 1.5px dashed #cbd5e1;
  background-color: #f8fafc;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.local-steps-box {
  border-radius: 12px;
  border: 1px solid #cbd5e1;
  background-color: #f8fafc;
}
.step-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 9px;
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
}
.step-highlight-emerald {
  background-color: #ecfdf5;
  border-color: #6ee7b7;
}
.step-highlight-indigo {
  background-color: #f5f7ff;
  border-color: #c7d2fe;
}
.step-num-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 6px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.2;
  background-color: #e2e8f0;
  color: #1e293b;
  flex-shrink: 0;
}
.step-num-badge.badge-emerald { background-color: #059669; color: #ffffff; }
.step-num-badge.badge-indigo { background-color: #4338ca; color: #ffffff; }

/* Tooltip thuần CSS tương đối (Không dùng @floating-ui để tuyệt đối cấm style="...") */
.studio-tooltip-wrap {
  position: relative;
  display: inline-flex;
}
.studio-tooltip-box {
  position: absolute;
  right: 0;
  bottom: calc(100% + 6px);
  width: 280px;
  padding: 8px 10px;
  border-radius: 8px;
  background-color: #0f172a;
  color: #f8fafc;
  font-size: 12px;
  line-height: 1.4;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.22);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 25;
  transition: opacity 0.15s ease;
}
.studio-tooltip-wrap:hover .studio-tooltip-box,
.studio-tooltip-wrap:focus-within .studio-tooltip-box {
  opacity: 1;
  visibility: visible;
}

/* ==========================================================================
   9. NGĂN KÉO (DRAWER), HỘP THOẠI (MODAL) & THÔNG BÁO (TOAST) THUẦN LỚP CSS
   ========================================================================== */
.studio-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.45);
  z-index: 40;
}

.studio-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 450px;
  background-color: #ffffff;
  border-left: 1px solid #e2e8f0;
  box-shadow: -8px 0 28px rgba(15, 23, 42, 0.16);
  z-index: 50;
  display: flex;
  flex-direction: column;
}

.studio-modal-wrap {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.studio-modal-panel {
  width: 100%;
  max-width: 760px;
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.22);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.max-h-modal-body {
  max-height: 70vh;
}

.kbd-tag {
  display: inline-block;
  padding: 2px 6px;
  margin-right: 4px;
  border-radius: 5px;
  border: 1px solid #cbd5e1;
  background-color: #f8fafc;
  font-size: 11.5px;
  font-weight: 600;
  color: #1e293b;
}

.studio-toast-stack {
  position: fixed;
  bottom: 20px;
  right: 16px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 390px;
  width: calc(100% - 32px);
  pointer-events: none;
}

.studio-toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 11px;
  border: 1px solid transparent;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.14);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.4;
}
.toast-indigo { background-color: #ffffff; border-color: #818cf8; color: #1e1b4b; }
.toast-emerald { background-color: #ecfdf5; border-color: #6ee7b7; color: #064e3b; }
.toast-amber { background-color: #fffbeb; border-color: #fcd34d; color: #78350f; }
.toast-rose { background-color: #fff1f2; border-color: #fda4af; color: #881337; }

.studio-thin-scroll::-webkit-scrollbar {
  height: 5px;
}
.studio-thin-scroll::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 999px;
}

/* ==========================================================================
   9B. KHO ĐÁM MÂY 1.2 TRIỆU PHÔNG (WHATFONTIS API 200 LƯỢT/NGÀY & PHIẾU XẾP HÀNG)
   ========================================================================== */
.wfi-engine-bar {
  background-color: #ffffff;
  border: 1px solid #c7d2fe;
  border-radius: 14px;
  padding: 12px 16px;
  box-shadow: 0 1px 3px rgba(67, 56, 202, 0.05);
}

.wfi-quota-pill-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.wfi-mini-progress {
  width: 84px;
}

.wfi-quota-card {
  background-color: #fffbeb;
  border: 1.5px solid #f59e0b;
  border-radius: 14px;
  padding: 16px 20px;
  box-shadow: 0 4px 14px rgba(217, 119, 6, 0.08);
}

.wfi-ticket-box {
  background-color: #ecfdf5;
  border: 1px solid #6ee7b7;
  border-radius: 10px;
  padding: 10px 14px;
}

.wfi-specimen-img-wrap {
  padding: 12px 14px;
  border-radius: 10px;
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  overflow: hidden;
}

.wfi-specimen-img {
  max-height: 48px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}

.underline {
  text-decoration: underline;
}

/* ==========================================================================
   10. QUY TẮC ẨN/HIỆN ĐÁP ỨNG CUỐI BẢNG KIỂU (0% !IMPORTANT, ĐÚNG THỨ TỰ CASCADE)
   ========================================================================== */
.hidden,
[hidden] {
  display: none;
}

@media (min-width: 640px) {
  .sm\:hidden {
    display: none;
  }
  .sm\:inline {
    display: inline;
  }
  .sm\:inline-flex {
    display: inline-flex;
  }
}

@media (min-width: 768px) {
  .md\:hidden {
    display: none;
  }
}

@media (min-width: 1280px) {
  .xl\:inline-flex {
    display: inline-flex;
  }
}
