/* =========================================================
   GIỌNG HÀI VIỆT - BẢNG MÀU SÁNG / TỐI & KIỂU DÁNG
   Chỉ đổi biến màu giữa :root và :root[data-theme="dark"]
   ========================================================= */
:root {
  --bg: #FFF8EE;
  --surface: #FFFFFF;
  --surface-soft: #FFF4E4;
  --surface-hover: #FDECD5;
  --border: #F1E3CF;
  --text: #3A2A1E;
  --text-muted: #6B5544;
  --accent: #F57C12;
  --accent-strong: #C85600;
  --accent-text: #FFFFFF;
  --dark-btn: #3A2A1E;
  --dark-btn-text: #FFFFFF;
  --vip: #F9C74F;
  --vip-text: #3A2A1E;
  --banner-bg: #FFF1D6;
  --banner-border: #F3D9A6;
  --danger: #C62828;
  --danger-bg: #FDECEA;
  --success: #1E7E34;
  --success-bg: #E8F5E9;
  --warn: #9A6700;
  --warn-bg: #FFF3CD;
  --shadow: 0 4px 16px rgba(58, 42, 30, 0.06);
  --shadow-lg: 0 14px 36px rgba(58, 42, 30, 0.18);
  --backdrop: rgba(30, 22, 16, 0.52);
  --radius: 16px;
  --radius-sm: 10px;
}

:root[data-theme="dark"] {
  --bg: #1E1A17;
  --surface: #2A2420;
  --surface-soft: #342C27;
  --surface-hover: #3F352E;
  --border: #443931;
  --text: #F5EDE3;
  --text-muted: #C7B8A8;
  --accent: #F57C12;
  --accent-strong: #E06805;
  --accent-text: #1E1A17;
  --dark-btn: #423730;
  --dark-btn-text: #F5EDE3;
  --vip: #F9C74F;
  --vip-text: #1E1A17;
  --banner-bg: #33291F;
  --banner-border: #55432E;
  --danger: #FF7B7B;
  --danger-bg: #452424;
  --success: #6EE787;
  --success-bg: #1F3B27;
  --warn: #F9C74F;
  --warn-bg: #423519;
  --shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);
  --backdrop: rgba(0, 0, 0, 0.72);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  overflow-x: hidden;
}

[hidden] { display: none !important; }

a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

/* Mọi nút bị khóa đều mờ rõ rệt và hiện con trỏ cấm */
button:disabled,
.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

.main-content {
  flex: 1;
  padding-top: 16px;
  padding-bottom: 104px;
}

/* ==================== TOPBAR ==================== */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 64px;
  padding-top: 8px;
  padding-bottom: 8px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--accent-strong);
  font-weight: 800;
  font-size: 1.15rem;
  min-height: 44px;
  min-width: 0;
}
.brand:hover { text-decoration: none; }
.brand-logo { display: inline-flex; width: 48px; height: 36px; flex-shrink: 0; }
.brand-logo svg { width: 100%; height: 100%; }
.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  min-height: 44px;
  cursor: pointer;
}
.theme-icon {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 1rem;
}
:root:not([data-theme="dark"]) .theme-sun,
:root[data-theme="dark"] .theme-moon {
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.14);
}

.account-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 4px 12px 4px 6px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-weight: 600;
  max-width: 170px;
}
.account-pill:hover { text-decoration: none; background: var(--surface-hover); }
.account-pill-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.avatar-mini {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.avatar-mini img, .avatar-lg img { width: 100%; height: 100%; object-fit: cover; }

/* Dưới 600px: thanh trên cùng gọn đúng 1 hàng, cao tối đa 64px */
@media (max-width: 599px) {
  .topbar-inner {
    flex-wrap: nowrap;
    min-height: 56px;
    max-height: 64px;
    padding-top: 6px;
    padding-bottom: 6px;
    gap: 6px;
  }
  .brand { font-size: 1rem; gap: 6px; }
  .brand-logo { width: 34px; height: 26px; }
  .topbar-actions { gap: 6px; }

  .theme-toggle {
    width: 44px;
    height: 44px;
    padding: 0;
    justify-content: center;
  }
  :root:not([data-theme="dark"]) .theme-moon,
  :root[data-theme="dark"] .theme-sun {
    display: none;
  }
  .theme-icon { background: transparent !important; box-shadow: none !important; }

  .nav-login-text,
  .nav-feedback-text,
  .account-pill-name,
  #nav-vip-text {
    display: none;
  }
  #nav-login-btn,
  #nav-feedback-btn,
  #nav-vip-btn {
    width: 44px;
    height: 44px;
    padding: 0;
  }
  .account-pill {
    width: 44px;
    height: 44px;
    padding: 0;
    justify-content: center;
  }
}

/* Dải báo lỗi máy chủ */
.server-error-banner {
  background: var(--danger-bg);
  color: var(--danger);
  border-bottom: 1px solid var(--danger);
}
.server-error-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 8px;
  padding-bottom: 8px;
  font-weight: 600;
  font-size: 0.92rem;
}

/* Dải khách dùng thử */
.guest-banner {
  background: var(--banner-bg);
  border-bottom: 1px solid var(--banner-border);
}
.guest-banner-inner {
  padding-top: 10px;
  padding-bottom: 10px;
  text-align: center;
  font-size: 0.94rem;
}

/* Khung quảng cáo */
.ad-slot {
  margin: 12px 0;
  min-height: 72px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ==================== BUTTONS & CARDS ==================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  min-width: 0;
  max-width: 100%;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  min-width: 0;
}
.card-title { margin: 0; font-size: 1.05rem; font-weight: 700; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, background-color 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { text-decoration: none; opacity: 0.92; }
.btn-pill { border-radius: 999px; }
.btn-full { width: 100%; }
.btn-sm { min-height: 38px; padding: 0 12px; font-size: 0.9rem; }
.btn-xs { min-height: 36px; padding: 0 10px; font-size: 0.85rem; }

.btn-primary { background: var(--accent-strong); color: var(--accent-text); }
.btn-dark { background: var(--dark-btn); color: var(--dark-btn-text); }
.btn-vip { background: var(--vip); color: var(--vip-text); }
.btn-vip.is-vip-badge { cursor: default; border: 1px solid var(--accent); }
.btn-outline { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-outline:hover:not(:disabled) { background: var(--surface-soft); }
.btn-danger { background: var(--danger); color: #FFFFFF; }
.btn-google {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  justify-content: space-between;
  padding: 0 18px;
}
.google-g { font-weight: 900; font-size: 1.1rem; color: var(--accent-strong); }

.link-btn {
  background: none;
  border: none;
  padding: 4px 2px;
  color: var(--accent-strong);
  cursor: pointer;
  font-weight: 600;
  text-decoration: underline;
}
.link-btn.strong { font-weight: 800; }
.danger-link { color: var(--danger); margin-top: 4px; }

.muted-text { color: var(--text-muted); }
.small-text { font-size: 0.85rem; }
.strong { font-weight: 700; }

/* ==================== TRANG CHÍNH ==================== */
.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.home-side-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.textarea-wrap {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 12px 12px 30px;
  min-width: 0;
}
.textarea-wrap.is-over { border-color: var(--danger); }

.tts-textarea {
  width: 100%;
  min-height: 150px;
  border: none;
  background: transparent;
  resize: vertical;
  outline: none;
  font-size: 1rem;
  line-height: 1.55;
}

.char-counter {
  position: absolute;
  right: 12px;
  bottom: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.char-counter.is-over { color: var(--danger); font-weight: 700; }

/* Thanh chèn hiệu ứng */
.tag-bar-wrap { margin-top: 12px; min-width: 0; }
.tag-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-width: 0;
}
.tag-chip {
  min-height: 44px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  max-width: 100%;
}
.tag-chip:hover { background: var(--surface-hover); }
.tag-note { margin: 6px 0 0; font-size: 0.82rem; color: var(--text-muted); }

.emotion-wrap { position: relative; max-width: 100%; }
.emotion-popover {
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  width: min(300px, calc(100vw - 48px));
  max-height: 240px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  z-index: 30;
}
.emotion-item {
  min-height: 36px;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  font-size: 0.85rem;
  cursor: pointer;
}
.emotion-item:hover { background: var(--surface-hover); }

/* Bộ chọn Giọng & Vùng miền */
.selectors-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.picker { position: relative; min-width: 0; }
.picker-trigger {
  width: 100%;
  min-height: 48px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  text-align: left;
  font-weight: 600;
  min-width: 0;
}
.picker-trigger:hover { background: var(--surface-hover); }
.picker-trigger-main {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}
.picker-label-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.voice-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.picker-panel {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 35;
  padding: 8px;
  max-height: 300px;
  overflow-y: auto;
}

.picker-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.picker-tab {
  flex: 1;
  min-height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.picker-tab.is-active {
  background: var(--accent-strong);
  color: var(--accent-text);
  border-color: var(--accent-strong);
}

.picker-option {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 8px;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  cursor: pointer;
}
.picker-option:hover { background: var(--surface-soft); }
.picker-option.is-selected { background: var(--surface-hover); font-weight: 700; }
.picker-option.is-locked-voice .picker-opt-info { opacity: 0.65; }
.picker-option.is-locked-voice:hover .picker-opt-info { opacity: 0.9; }
.picker-opt-info { display: flex; flex-direction: column; min-width: 0; }
.picker-opt-desc { font-size: 0.8rem; color: var(--text-muted); }

.picker-badge {
  font-size: 0.76rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: 8px;
}
.picker-badge-token {
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid var(--accent);
}
.picker-badge-free {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success);
}
.picker-badge-vip {
  background: var(--banner-bg);
  color: var(--accent-strong);
  border: 1px solid var(--vip);
}

/* Tùy chọn khác */
.advanced-box {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  min-width: 0;
}
.advanced-summary {
  cursor: pointer;
  font-weight: 600;
  min-height: 44px;
  display: flex;
  align-items: center;
  list-style: none;
}
.advanced-summary::after { content: " ▾"; margin-left: 6px; }
.advanced-box[open] .advanced-summary::after { content: " ▴"; }
.advanced-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  padding: 8px 0 4px;
  min-width: 0;
}
.advanced-field { min-width: 0; width: 100%; }
.advanced-label-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}
.advanced-field input[type="range"] { width: 100%; margin: 0; accent-color: var(--accent); }
.range-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.advanced-label { display: block; margin-bottom: 6px; font-weight: 600; }
.format-group { display: flex; gap: 8px; width: 100%; }
.format-btn {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-soft);
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.format-btn.is-active {
  background: var(--dark-btn);
  color: var(--dark-btn-text);
  border-color: var(--dark-btn);
}

/* Nút Đọc ngay (dính đáy trên điện thoại < 900px) */
.speak-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
}
.token-chip {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
}
.btn-speak {
  width: 100%;
  min-height: 48px;
  font-size: 1.05rem;
  letter-spacing: 0.3px;
}

/* Cột phải: Kết quả sóng âm & Lịch sử gần đây */
.waveform-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  min-width: 0;
}
.play-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--accent-strong);
  color: var(--accent-text);
  font-size: 1.05rem;
  cursor: pointer;
  flex-shrink: 0;
}
.waveform-track { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.waveform-canvas { width: 100%; height: 64px; display: block; cursor: pointer; }
.seek-range { width: 100%; margin: 0; accent-color: var(--accent); cursor: pointer; }

.result-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.recent-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.recent-item-btn {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-soft);
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  cursor: pointer;
  min-width: 0;
}
.recent-item-btn:hover { background: var(--surface-hover); }
.recent-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
}

/* ==================== TRANG LỊCH SỬ ==================== */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.page-head-left { justify-content: flex-start; }
.page-title { margin: 0; font-size: 1.55rem; font-weight: 800; }
.accent-title { color: var(--accent-strong); }

.history-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
  min-width: 0;
}
.filter-group, .history-bulk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.input, .select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
}
.filter-group .select { flex: 1; min-width: 120px; }
.history-bulk-actions .btn { flex: 1; min-width: 0; white-space: normal; text-align: center; padding: 6px 12px; }

.hist-table-wrap { width: 100%; min-width: 0; }
.hist-table { width: 100%; border-collapse: collapse; }
.hist-table th, .hist-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
.hist-table tr.is-checked { background: var(--surface-soft); }
.hist-file-name { font-weight: 600; word-break: break-word; }
.hist-preview { color: var(--text-muted); font-size: 0.9rem; word-break: break-word; }
.hist-row-actions { display: inline-flex; gap: 6px; }
.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: none;
  background: var(--dark-btn);
  color: var(--dark-btn-text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.check-label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }

.empty-state { text-align: center; padding: 28px 12px; }
.empty-cat-svg { width: 120px; height: 100px; margin: 0 auto 10px; }
.empty-text { font-weight: 600; margin: 0 0 14px; }

.pagination {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 16px;
}
.page-btn {
  min-width: 44px;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-weight: 700;
  cursor: pointer;
}
.page-btn.is-active {
  background: var(--dark-btn);
  color: var(--dark-btn-text);
  border-color: var(--dark-btn);
}

/* Mobile (< 768px): bảng lịch sử thành thẻ, không cuộn ngang */
@media (max-width: 767px) {
  .hist-table thead th:not(.col-check) { display: none; }
  .hist-table thead tr { display: block; margin-bottom: 8px; }
  .hist-table tbody { display: flex; flex-direction: column; gap: 10px; }
  .hist-table tbody tr {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    background: var(--surface);
  }
  .hist-table tbody td {
    display: block;
    border: none;
    padding: 2px 0;
    min-width: 0;
  }
  .hist-table tbody td.col-check { grid-row: 1 / span 2; }
  .hist-table tbody td.col-actions { grid-column: 1 / -1; margin-top: 6px; }
}

/* ==================== BẢNG GIÁ ==================== */
.pricing-head { text-align: center; margin-bottom: 20px; }
.pricing-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}
.plan-card {
  display: flex;
  flex-direction: column;
  position: relative;
  padding: 22px 18px;
  min-width: 0;
}
.plan-card-vip { border: 2px solid var(--accent); }
.plan-card-token {
  border: 1.5px solid var(--border);
  background: var(--surface);
}
.plan-subprice {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: -8px 0 14px;
}
.plan-badge {
  position: absolute;
  top: -13px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent-strong);
  color: var(--accent-text);
  padding: 3px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}
.plan-name { text-align: center; margin: 4px 0; font-size: 1.2rem; }
.plan-price { text-align: center; font-size: 1.55rem; font-weight: 800; margin: 6px 0 14px; }
.plan-features {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wallet-banner {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: center;
  background: var(--surface-soft);
}
.wallet-banner-title { font-size: 1.05rem; }

/* ==================== TÀI KHOẢN ==================== */
.account-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}
.account-right-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.profile-card { text-align: center; }
.profile-avatar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 6px;
}
#acc-avatar {
  cursor: pointer;
  margin-bottom: 6px;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
#acc-avatar:hover {
  opacity: 0.92;
  transform: scale(1.03);
}
#acc-avatar:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
.avatar-change-btn {
  margin-top: -2px;
  margin-bottom: 6px;
  font-size: 0.85rem;
  color: var(--accent-strong);
  cursor: pointer;
  background: none;
  border: none;
  text-decoration: underline;
  font-weight: 600;
}
.avatar-change-btn:hover {
  color: var(--accent);
}
.avatar-lg {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  margin: 0 auto 12px;
  background: var(--accent-strong);
  color: var(--accent-text);
  font-size: 2rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.profile-name-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.profile-name { margin: 0; font-size: 1.25rem; }
.profile-email { margin: 4px 0 14px; word-break: break-all; }
.inline-name-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.inline-name-actions { display: flex; gap: 8px; justify-content: center; }

.profile-plan-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 14px;
  text-align: left;
}
.profile-plan-label { font-weight: 700; font-size: 0.92rem; }
.profile-actions { display: flex; flex-direction: column; gap: 10px; }

/* Thẻ token + mèo ôm hũ xu */
.token-card-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  min-width: 0;
}
.cat-jar-wrap { width: 124px; height: 112px; flex-shrink: 0; }
.cat-jar-wrap svg { width: 100%; height: 100%; }
.token-info { width: 100%; min-width: 0; }
.token-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.token-big { font-size: 1.65rem; font-weight: 900; line-height: 1.2; }
.token-sub { margin: 6px 0 10px; font-size: 0.92rem; }
.progress-track {
  height: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 6px;
}
.progress-fill { height: 100%; background: var(--accent); width: 0%; transition: width 0.3s ease; }

.defaults-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.topups-table-wrap { overflow-x: auto; margin-top: 10px; max-width: 100%; }
.topups-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.topups-table th, .topups-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.status-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}
.status-paid { background: var(--success-bg); color: var(--success); }
.status-pending { background: var(--warn-bg); color: var(--warn); }
.status-expired { background: var(--surface-soft); color: var(--text-muted); }

/* ==================== FOOTER & TOAST ==================== */
.site-footer {
  position: relative;
  border-top: 1px solid var(--border);
  padding: 16px 0 92px;
  text-align: center;
  font-size: 0.86rem;
  color: var(--text-muted);
}
.footer-inner { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.corner-cat {
  display: none;
  position: fixed;
  right: 14px;
  bottom: 0;
  width: 82px;
  height: 64px;
  pointer-events: none;
  z-index: 10;
}

.toast-region {
  position: fixed;
  top: 74px;
  right: 16px;
  left: 16px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--dark-btn);
  color: var(--dark-btn-text);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-weight: 600;
  max-width: 440px;
  pointer-events: auto;
}
.toast.is-error { background: var(--danger); color: #FFFFFF; }
.toast.is-success { background: var(--success); color: #FFFFFF; }

/* ==================== MODALS ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--backdrop);
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}
.modal-dialog {
  position: relative;
  width: 100%;
  max-width: 430px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px 20px;
  box-shadow: var(--shadow-lg);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}
.modal-sm { max-width: 380px; }
.modal-qr-dialog { max-width: 500px; }

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: transparent;
  font-size: 1.2rem;
  cursor: pointer;
}
.modal-close:hover { background: var(--surface-soft); }
.modal-mascot { width: 84px; height: 64px; margin: 0 auto 6px; }
.modal-title { margin: 0 0 6px; text-align: center; font-size: 1.25rem; }
.modal-subtitle { margin: 0 0 14px; text-align: center; color: var(--text-muted); font-size: 0.92rem; }

/* Thông báo giới hạn 3 tài khoản trên 1 máy */
.device-limit-box {
  text-align: center;
  padding: 14px 12px;
  border-radius: var(--radius-sm);
  background: var(--warn-bg);
  border: 1px solid var(--accent);
  margin-bottom: 14px;
}
.device-limit-cat { width: 92px; height: 74px; margin: 0 auto 8px; }
.device-limit-cat svg { width: 100%; height: 100%; }
.device-limit-text {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.45;
}

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  color: var(--text-muted);
  font-size: 0.86rem;
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.field { margin-bottom: 12px; }
.field label { display: block; font-weight: 600; margin-bottom: 5px; font-size: 0.9rem; }
.password-wrap { position: relative; display: flex; align-items: center; }
.password-wrap .input { padding-right: 48px; }
.eye-btn {
  position: absolute;
  right: 2px;
  width: 42px;
  height: 42px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1.05rem;
}

.auth-forgot-row { text-align: right; margin: -4px 0 12px; }
.auth-switch { margin-top: 14px; text-align: center; font-size: 0.92rem; }
.form-alert {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  background: var(--danger-bg);
  color: var(--danger);
}
.form-alert.is-success { background: var(--success-bg); color: var(--success); }
.resend-wrap { text-align: center; margin-bottom: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* Gói nạp & Hộp QR */
.topup-packages-list { display: flex; flex-direction: column; gap: 10px; }
.topup-pkg-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}
.topup-pkg-tokens { font-weight: 800; font-size: 1.05rem; }

.qr-status-banner {
  text-align: center;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--warn-bg);
  color: var(--warn);
  font-weight: 700;
  margin-bottom: 14px;
}
.qr-status-banner.is-paid { background: var(--success-bg); color: var(--success); }
.qr-status-banner.is-expired { background: var(--danger-bg); color: var(--danger); }

.qr-body { display: flex; flex-direction: column; gap: 14px; }
.qr-img-wrap { text-align: center; }
.qr-image {
  width: 196px;
  height: 196px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #FFFFFF;
  padding: 6px;
}
.qr-img-fallback {
  margin: 0 auto 8px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--warn-bg);
  color: var(--warn);
  font-weight: 600;
  font-size: 0.92rem;
}
.qr-timer { margin-top: 6px; font-size: 0.92rem; }
.qr-details { display: flex; flex-direction: column; gap: 8px; }
.qr-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  border: 1px solid var(--border);
}
.qr-row-highlight { border-color: var(--accent); }
.qr-label { display: block; font-size: 0.78rem; color: var(--text-muted); }
.qr-val { font-size: 0.92rem; word-break: break-all; }
.qr-amount { font-size: 1.15rem; color: var(--accent-strong); }

/* ==================== CHỌN ẢNH ĐẠI DIỆN ==================== */
.avatar-modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.avatar-group-title {
  margin: 8px 0 2px;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-muted);
}
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(4, 72px);
  gap: 12px;
  justify-content: center;
  margin-bottom: 6px;
  max-width: 100%;
}
.avatar-choice-btn {
  width: 72px;
  height: 72px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 3px solid transparent;
  background: var(--surface-soft);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.1s ease;
}
.avatar-choice-btn:hover {
  background: var(--surface-hover);
  transform: scale(1.04);
}
.avatar-choice-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.avatar-choice-btn[aria-pressed="true"],
.avatar-choice-btn.is-active {
  border: 3px solid #F57C12;
  background: var(--surface-hover);
}
.avatar-choice-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

@media (max-width: 440px) {
  .avatar-grid {
    grid-template-columns: repeat(3, 72px);
    gap: 10px;
  }
}

/* ==================== DESKTOP (>= 900px) ==================== */
@media (min-width: 900px) {
  .main-content { padding-top: 22px; padding-bottom: 40px; }
  .site-footer { padding-bottom: 20px; }
  .corner-cat { display: block; }

  .home-grid {
    grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
    align-items: start;
  }

  .selectors-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .advanced-body { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: end; }

  /* Trên máy tính nút Đọc nằm trong thẻ, không dính đáy */
  .speak-bar {
    position: static;
    border-top: none;
    padding: 0;
    margin-top: 16px;
    box-shadow: none;
    background: transparent;
    flex-direction: row-reverse;
    align-items: center;
    gap: 12px;
  }
  .btn-speak { flex: 1; }
  .token-chip {
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 14px;
    white-space: nowrap;
  }

  .history-toolbar {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
  }
  .search-box { flex: 1.2; min-width: 200px; }
  .filter-group { flex: 1; }
  .history-bulk-actions { flex-shrink: 0; }
  .history-bulk-actions .btn { flex: 0 0 auto; white-space: nowrap; }

  .pricing-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wallet-banner {
    flex-direction: row;
    text-align: left;
    max-width: 560px;
    margin: 20px auto 0;
  }

  .account-grid {
    grid-template-columns: 310px minmax(0, 1fr);
    align-items: start;
  }
  .token-card-body { flex-direction: row; }
  .defaults-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; align-items: center; }

  .toast-region { left: auto; align-items: flex-end; }
}

@media (min-width: 1100px) {
  .pricing-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 600px) and (max-width: 899px) {
  .pricing-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ==================== NÚT NỔI & HỘP ĐÁNH GIÁ ==================== */
.float-feedback-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 85;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #FF8F00 0%, #E65100 100%);
  color: #fff;
  border: 2px solid #FFF8EE;
  border-radius: 999px;
  padding: 13px 22px;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  letter-spacing: 0.2px;
  box-shadow: 0 6px 22px rgba(245, 124, 18, 0.5);
  animation: floatPulse 3s infinite ease-in-out;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.float-feedback-btn:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 10px 30px rgba(245, 124, 18, 0.7);
}
.float-feedback-btn:active {
  transform: translateY(0) scale(0.98);
}
.float-feedback-icon,
.nav-feedback-star {
  font-size: 1.45rem;
  line-height: 1;
  display: inline-block;
  transform-origin: bottom center;
  animation: starBounce 1.4s infinite cubic-bezier(0.28, 0.84, 0.42, 1);
}
@keyframes starBounce {
  0%, 100% {
    transform: translateY(0) scale(1) rotate(0deg);
  }
  20% {
    transform: translateY(-8px) scale(1.25) rotate(-10deg);
  }
  40% {
    transform: translateY(0) scale(0.95) rotate(0deg);
  }
  55% {
    transform: translateY(-4px) scale(1.1) rotate(8deg);
  }
  70% {
    transform: translateY(0) scale(1) rotate(0deg);
  }
}
@keyframes floatPulse {
  0%, 100% {
    box-shadow: 0 6px 22px rgba(245, 124, 18, 0.5);
  }
  50% {
    box-shadow: 0 8px 28px rgba(245, 124, 18, 0.75), 0 0 0 6px rgba(245, 124, 18, 0.18);
  }
}
.feedback-textarea {
  resize: vertical;
  min-height: 120px;
  font-family: inherit;
  line-height: 1.5;
}
@media (max-width: 600px) {
  .float-feedback-btn {
    bottom: 18px;
    right: 16px;
    padding: 10px 16px;
    font-size: 0.92rem;
    gap: 7px;
  }
  .float-feedback-icon {
    font-size: 1.25rem;
  }
}

.thanks-backdrop {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.65);
  cursor: pointer;
  z-index: 1000;
  transition: opacity 0.4s ease;
}
.thanks-dialog {
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: auto;
  max-width: 90vw;
  max-height: 85vh;
}
.thanks-img {
  max-width: 320px;
  width: 82vw;
  height: auto;
  border-radius: 16px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
  animation: thanksPop 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes thanksPop {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.thanks-fadeout {
  opacity: 0 !important;
  pointer-events: none;
}

/* ==== GD3 ==== */

/* 1. Đổi giao diện sáng/tối mượt ~1 giây */
body,
.topbar,
.site-footer,
.card,
.plan-card,
.wallet-banner,
.modal-dialog,
.speak-bar,
.input,
.select,
.tts-textarea,
.textarea-wrap,
.btn,
.tag-chip,
.picker-trigger,
.picker-panel,
.format-btn,
.theme-toggle,
.topup-pkg-card {
  transition: background-color 1s ease, color 1s ease, border-color 1s ease, box-shadow 1s ease, fill 1s ease;
}

/* Nút và thành phần tương tác giữ hover nhanh 0.2s */
.btn:hover,
.btn:active,
.tag-chip:hover,
.format-btn:hover,
.picker-trigger:hover,
.theme-toggle:hover {
  transition-duration: 0.2s;
}

/* 2. Hiệu ứng nhịp đập nhẹ cho nút chọn gói nạp token */
@keyframes topupPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.06);
  }
}

.topup-pkg-card .btn {
  display: inline-flex;
  animation: topupPulse 1.8s infinite ease-in-out;
  transform-origin: center center;
}

/* So le nhau giữa các nút gói nạp */
.topup-packages-list .topup-pkg-card:nth-child(1) .btn {
  animation-delay: 0s;
}
.topup-packages-list .topup-pkg-card:nth-child(2) .btn {
  animation-delay: 0.35s;
}
.topup-packages-list .topup-pkg-card:nth-child(3) .btn {
  animation-delay: 0.7s;
}
.topup-packages-list .topup-pkg-card:nth-child(4) .btn {
  animation-delay: 1.05s;
}
.topup-packages-list .topup-pkg-card:nth-child(n+5) .btn {
  animation-delay: 1.4s;
}

/* Gói 49.000đ / gói phổ biến nổi bật hơn với viền sáng nhẹ */
.topup-packages-list .topup-pkg-card:nth-child(2) {
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(245, 124, 18, 0.25);
}
.topup-packages-list .topup-pkg-card:nth-child(2) .btn {
  box-shadow: 0 0 8px rgba(245, 124, 18, 0.35);
}

/* Nút VIP trong modal (nếu có) cũng phập phồng nhẹ */
#daily-limit-vip-btn,
.modal-dialog .btn-vip {
  animation: topupPulse 1.8s infinite ease-in-out;
  animation-delay: 0.5s;
}

/* Dừng animation khi hover */
.topup-pkg-card .btn:hover,
#daily-limit-vip-btn:hover,
.modal-dialog .btn-vip:hover {
  animation-play-state: paused;
}

/* 3. Ẩn nút góp ý nổi trên màn hình hẹp (<= 768px) để không che nút ĐỌC */
@media (max-width: 768px) {
  #float-feedback-btn {
    display: none !important;
  }
}

/* 4. Tiêu đề khối tùy chọn khác (luôn mở) */
.advanced-title {
  margin: 0 0 6px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

/* Tôn trọng người dùng bật giảm chuyển động (prefers-reduced-motion) */
@media (prefers-reduced-motion: reduce) {
  body,
  .topbar,
  .site-footer,
  .card,
  .plan-card,
  .wallet-banner,
  .modal-dialog,
  .speak-bar,
  .input,
  .select,
  .tts-textarea,
  .textarea-wrap,
  .btn,
  .tag-chip,
  .picker-trigger,
  .picker-panel,
  .format-btn,
  .theme-toggle,
  .topup-pkg-card {
    transition: none !important;
  }

  .topup-pkg-card .btn,
  #daily-limit-vip-btn,
  .modal-dialog .btn-vip {
    animation: none !important;
  }
}

/* ==== GD3-B ==== */

/* Nút Clone giọng trên header */
.topbar-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.nav-clone-btn {
  min-height: 40px;
  padding: 0 12px;
  font-size: 0.9rem;
}
@media (max-width: 599px) {
  .nav-clone-text { display: none; }
  .nav-clone-btn {
    width: 44px;
    height: 44px;
    padding: 0;
  }
}

/* Trình phát dùng chung (GHV.Player) */
.ghv-player {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 170px;
  max-width: 240px;
}
.ghv-player-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--accent-strong);
  color: var(--accent-text);
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}
.ghv-player-track {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ghv-player-seek {
  width: 100%;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.ghv-player-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Lịch sử gần đây dạng hàng có nút phát + xóa */
.recent-item-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-soft);
}
.recent-item-top {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.recent-item-top .recent-name {
  flex: 1;
  min-width: 0;
}
.recent-del-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--danger);
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.recent-del-btn:hover { background: var(--danger-bg); }
.ghv-player-compact {
  min-width: 0;
  max-width: 100%;
  width: 100%;
}
.ghv-player-compact .ghv-player-track { display: none; }
.ghv-player-compact.is-active .ghv-player-track { display: flex; }

/* Nút xóa dòng lịch sử */
.icon-btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger);
}
.icon-btn-danger:hover { opacity: 0.9; }

/* Dòng bảng lịch sử nạp bấm được */
.topups-table tbody tr.is-clickable {
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.topups-table tbody tr.is-clickable:hover {
  background: var(--surface-hover);
}
.topups-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

/* Nhóm Giọng của tôi trong bộ chọn giọng */
.picker-group-label {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--accent-strong);
  padding: 4px 8px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.picker-clone-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.picker-clone-row .picker-option { flex: 1; }
.picker-clone-del {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--danger);
  cursor: pointer;
  flex-shrink: 0;
}
.picker-clone-del:hover { background: var(--danger-bg); }

/* Cửa sổ Clone giọng */
.modal-clone-dialog { max-width: 480px; }
.clone-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.clone-pane {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}
.clone-sample-box {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  border: 1px solid var(--border);
}
.clone-sample-box p { margin: 4px 0 0; }
.clone-rec-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.clone-countdown { font-size: 0.95rem; }
.clone-meter {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  overflow: hidden;
}
.clone-meter-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.08s linear;
}
.clone-rec-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.clone-preview-audio {
  width: 100%;
  margin-bottom: 12px;
}
.clone-consent-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.86rem;
  line-height: 1.45;
  margin-bottom: 12px;
  cursor: pointer;
}
.clone-consent-label input {
  margin-top: 3px;
  flex-shrink: 0;
}
.clone-error-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.clone-error-text { margin: 0; }
.clone-status-note {
  text-align: center;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--warn-bg);
  color: var(--warn);
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 10px;
}

/* ==== GD3-B sửa (Claude): "Lịch sử gần đây" gọn 1 dòng: ▶ | tên… | 🗑 ; thanh tiến độ chỉ hiện ở mục đang nghe ==== */
.recent-item-top { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; column-gap: 10px; row-gap: 6px; }
.recent-item-top .ghv-player { display: contents; }
.recent-item-top .ghv-player-btn { grid-column: 1; grid-row: 1; width: 34px; height: 34px; flex: none; }
.recent-item-top .recent-name { grid-column: 2; grid-row: 1; order: 0; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.recent-item-top .recent-name-file,
.recent-item-top .recent-name-meta { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-item-top .recent-name-meta { font-size: 0.78rem; color: var(--text-muted, var(--muted, inherit)); opacity: 0.85; }
.recent-item-top .recent-del-btn { grid-column: 3; grid-row: 1; width: 34px; height: 34px; opacity: 1; color: var(--text); }
.recent-item-top .ghv-player-track { grid-column: 1 / -1; grid-row: 2; display: none; }
.recent-item-top .ghv-player.is-active .ghv-player-track { display: flex; }


/* ==== GD4: Hiệu ứng giọng, lọc giọng theo tag, bảng giá mới ==== */
.voice-picker-panel {
  max-height: 380px;
}
.voice-tag-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 6px;
  margin-bottom: 8px;
}
.voice-filter-select {
  min-height: 34px;
  padding: 2px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  font-size: 0.82rem;
  min-width: 0;
}
.picker-voice-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.picker-voice-row .picker-option {
  flex: 1;
  min-width: 0;
}
.picker-opt-tags {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent-strong);
}
.picker-empty-msg {
  padding: 12px 8px;
  text-align: center;
}
.sample-play-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}
.sample-play-btn:hover,
.sample-play-btn.is-playing {
  background: var(--accent-strong);
  color: var(--accent-text);
  border-color: var(--accent-strong);
}

/* Bộ chọn hiệu ứng giọng */
.effect-picker-panel {
  max-height: 420px;
}
.effect-none-btn {
  width: 100%;
  min-height: 40px;
  padding: 6px 10px;
  margin-bottom: 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  text-align: left;
  font-weight: 600;
  cursor: pointer;
}
.effect-none-btn.is-selected {
  border-color: var(--accent);
  background: var(--surface-hover);
}
.effect-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.effect-card {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  min-width: 0;
}
.effect-card.is-selected {
  border-color: var(--accent);
  background: var(--surface-hover);
}
.effect-card.is-locked .effect-card-main {
  opacity: 0.7;
}
.effect-card-main {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 2px 0;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.effect-card-top {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 0.88rem;
  min-width: 0;
  max-width: 100%;
}
.effect-card-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.effect-card-main .picker-badge {
  margin-left: 0;
}
.effect-level-wrap {
  border-top: 1px solid var(--border);
  padding-top: 8px;
}
.effect-level-wrap.is-locked {
  opacity: 0.75;
}
.effect-level-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.effect-level-btns {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.effect-level-btn {
  min-height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}
.effect-level-btn.is-active {
  background: var(--accent-strong);
  color: var(--accent-text);
  border-color: var(--accent-strong);
}

/* Ghi chú bảng giá & gói nạp token */
.pricing-note {
  text-align: center;
  margin: 14px 0 0;
  font-size: 0.92rem;
  font-weight: 600;
}
.topup-pkg-head {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.topup-pkg-bonus {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--success);
  margin-top: 2px;
}
@media (min-width: 900px) {
  .defaults-row-single {
    grid-template-columns: minmax(0, 1fr) auto;
  }
}

/* ==== GD4B: Thanh kéo kiểu ElevenLabs (Cường độ hiệu ứng & Biểu cảm) ==== */
.el-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    var(--accent) 0%,
    var(--accent) var(--range-pct, 50%),
    var(--border) var(--range-pct, 50%),
    var(--border) 100%
  );
  outline: none;
  cursor: pointer;
  margin: 8px 0 6px;
  display: block;
}

.el-slider::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: transparent;
}

.el-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-strong);
  border: 2px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  margin-top: -6px;
  cursor: pointer;
  transition: transform 0.12s ease;
}

.el-slider::-webkit-slider-thumb:hover {
  transform: scale(1.12);
}

.el-slider::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: var(--border);
}

.el-slider::-moz-range-progress {
  height: 4px;
  border-radius: 999px;
  background: var(--accent);
}

.el-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-strong);
  border: 2px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}

.el-slider:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.el-slider:disabled::-webkit-slider-thumb {
  cursor: not-allowed;
  transform: none;
}

.el-slider:disabled::-moz-range-thumb {
  cursor: not-allowed;
}

.el-slider-ends {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.2;
}

.el-slider-hint {
  margin: 6px 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ==== GD5 (Lượt 1): Tùy chọn khác thẳng hàng + Thanh thời gian gọn lịch sử ==== */

/* 1. Khối Tùy chọn khác: lưới đều, cùng kiểu el-slider */
.advanced-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  padding: 6px 0 4px;
  align-items: start;
}

.advanced-field {
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
}

.advanced-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 24px;
  margin-bottom: 2px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.advanced-label-with-tip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.advanced-val {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--accent-strong);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.info-tip-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1;
  cursor: help;
}
.info-tip-btn:hover {
  color: var(--accent-strong);
}

.advanced-label-text {
  font-weight: 600;
  font-size: 0.9rem;
}

.advanced-field-full .format-group {
  margin-top: 4px;
}

@media (min-width: 900px) {
  .advanced-body {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 20px;
    row-gap: 14px;
    align-items: start;
  }
  .advanced-field-full {
    grid-column: 1 / -1;
  }
}

/* 2. Thanh thời gian gọn cho Lịch sử gần đây & Trang Lịch sử */
.ghv-slim-bar {
  position: relative;
  width: 100%;
  padding: 5px 0;
  margin: 1px 0;
  cursor: pointer;
  touch-action: none;
  user-select: none;
}

.ghv-slim-track {
  width: 100%;
  height: 3px;
  border-radius: 999px;
  background: var(--border);
  opacity: 0.55;
  overflow: hidden;
  transition: opacity 0.15s ease;
}

.ghv-slim-bar.is-active .ghv-slim-track,
.ghv-slim-bar:hover .ghv-slim-track {
  opacity: 1;
}

.ghv-slim-fill {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.08s linear;
}

.ghv-slim-time {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}

.ghv-slim-time.is-active {
  color: var(--accent-strong);
  font-weight: 600;
}

/* Lịch sử gần đây: nút ▶ | tên + vạch mảnh + dòng giọng & thời gian | 🗑 */
.recent-item-row {
  padding: 8px 10px;
}

.recent-item-top {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 10px;
  row-gap: 0;
}

.recent-item-top > .ghv-player-btn {
  grid-column: 1;
  grid-row: 1;
  width: 34px;
  height: 34px;
  flex: none;
}

.recent-item-top .recent-name {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.recent-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.recent-meta-row .recent-name-meta {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Trang Lịch sử đầy đủ (bảng): trình phát gọn đồng bộ */
.ghv-player-slim {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 148px;
  max-width: 190px;
}

.ghv-player-slim .ghv-player-btn {
  width: 36px;
  height: 36px;
}

.ghv-slim-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hist-row-actions {
  align-items: center;
}

/* ==== GD5 (Lượt 2): Bảng so sánh 4 gói + Huy hiệu gói + Nhắc nâng cấp nhẹ nhàng ==== */

/* 1. Huy hiệu gói ở header */
.plan-badge-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}
.plan-badge-btn:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
}
.plan-badge-btn.is-plan-token {
  background: var(--warn-bg);
  color: var(--warn);
  border-color: var(--accent);
}
.plan-badge-btn.is-plan-vip {
  background: var(--vip);
  color: var(--vip-text);
  border-color: var(--accent);
}
@media (max-width: 599px) {
  .plan-badge-btn {
    min-height: 34px;
    padding: 0 8px;
    font-size: 0.74rem;
    max-width: 112px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* 2. Cột gói hiện tại nổi bật + Cửa sổ so sánh gói */
.plan-card.is-current-plan {
  border: 2px solid var(--accent-strong);
  box-shadow: 0 0 0 3px rgba(245, 124, 18, 0.16), var(--shadow);
}
.plan-current-badge {
  background: var(--success);
  color: #FFFFFF;
}
.modal-compare-dialog {
  max-width: 980px;
}
.compare-pricing-grid {
  margin-top: 10px;
}
.compare-wallet-bar {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

/* 3. Thẻ nhỏ khi bấm giọng/hiệu ứng bị khóa */
.locked-hint-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin: 6px 0 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: var(--warn-bg);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
}
.locked-hint-text {
  flex: 1;
  min-width: 160px;
}

/* 4. Dòng gợi ý nhỏ sau khi đọc xong */
.post-speak-nudge {
  margin-top: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
  background: var(--surface-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.84rem;
}
.post-speak-nudge-text {
  color: var(--text-muted);
  flex: 1;
  min-width: 0;
}
.post-speak-nudge-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.nudge-close-btn {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}
.nudge-close-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

/* 5. Thanh cảnh báo mảnh phía trên ô nhập */
.quota-warn-bar {
  margin-bottom: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: var(--warn-bg);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  font-weight: 600;
}
.quota-warn-text {
  flex: 1;
  min-width: 180px;
}
.quota-warn-btn {
  min-height: 32px;
  padding: 0 10px;
}
