@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

:root {
  --gradient-a: #f5f3ff;
  --gradient-b: #e4f2ff;
  --gradient-c: #ffe6f3;
  --gradient-d: #fff2d9;
  --primary: #5d4bff;
  --primary-dark: #4635d1;
  --accent: #ff7ac7;
  --accent-dark: #e664b1;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-strong: rgba(255, 255, 255, 0.9);
  --shadow: 0 24px 60px rgba(68, 53, 130, 0.18);
  --text-dark: #0d1740;
  --text-light: #51608c;
  --transition: cubic-bezier(0.18, 0.72, 0.3, 1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Poppins', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text-dark);
  min-height: 100vh;
  background: linear-gradient(140deg, var(--gradient-a) 0%, var(--gradient-b) 30%, var(--gradient-c) 65%, var(--gradient-d) 100%);
  position: relative;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

html {
  background: #f3efff;
}

a {
  color: var(--primary-dark);
  text-decoration: none;
  transition: color 0.3s var(--transition);
}

a:hover,
a:focus-visible {
  color: var(--accent-dark);
}

body::before,
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  opacity: 0.75;
  background-size: 200% 200%;
  animation: gradientShift 24s ease-in-out infinite;
}

body::before {
  background: linear-gradient(140deg, rgba(93, 75, 255, 0.18), rgba(255, 122, 199, 0.16), rgba(255, 188, 87, 0.18));
}

body::after {
  z-index: -1;
  opacity: 0.45;
  background: radial-gradient(circle at 20% 20%, rgba(93, 75, 255, 0.32), transparent 55%),
    radial-gradient(circle at 80% 35%, rgba(255, 122, 199, 0.26), transparent 60%),
    radial-gradient(circle at 40% 80%, rgba(255, 188, 87, 0.24), transparent 65%);
  animation: pulse 16s ease-in-out infinite;
}

@media (max-width: 900px), (pointer: coarse) {
  body::before,
  body::after {
    content: none;
    animation: none;
  }
}


main {
  flex: 1 0 auto;
  width: min(1100px, 94vw);
  margin: 0 auto;
  padding: 5rem 0 4rem;
  display: flex;
  flex-direction: column;
  gap: 3.5rem;
}

.login-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 2.5rem;
  align-items: stretch;
}

@media (max-width: 900px) {
  .login-layout {
    grid-template-columns: 1fr;
  }

  .metric-card-wide {
    grid-column: auto;
  }
}

body:not(.app-dashboard) header.navbar {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  padding: 0.75rem 0;
  background: rgba(16, 3, 25, 0.72);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(18px);
  z-index: 20;
  display: flex;
  justify-content: center;
}

body:not(.app-dashboard) header.navbar .navbar-inner {
  width: min(1100px, 94vw);
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

body:not(.app-dashboard) header.navbar .brand-logo {
  height: 132px;
  width: auto;
  display: block;
}

body:not(.app-dashboard) header.navbar img {
  max-height: 132px;
}

body:not(.app-dashboard) header.navbar .nav-links a {
  padding: 0.55rem 1rem;
  border-radius: 999px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.86);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

body:not(.app-dashboard) header.navbar .nav-links {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

body:not(.app-dashboard) header.navbar .nav-links a:hover,
body:not(.app-dashboard) header.navbar .nav-links a:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(93, 75, 255, 0.18);
  color: #ffffff;
}

body:not(.app-dashboard) main {
  padding-top: 5rem;
}


.admin-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  margin: 0 0 0.5rem;
  background: var(--surface);
  border-radius: 1.35rem;
  border: 1px solid rgba(93, 75, 255, 0.14);
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}

.admin-title {
  flex: 1;
  min-width: 220px;
}

.admin-title h1 {
  margin: 0;
  font-size: 1.6rem;
}

.admin-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-left: auto;
}

.admin-actions .btn {
  padding: 0.75rem 1.35rem;
  white-space: nowrap;
}

.admin-actions .btn.secondary {
  color: var(--text-dark);
}

.admin-dashboard-page {
  padding: 2.5rem 1.75rem 4.5rem;
}

.admin-dashboard {
  max-width: none;
  width: 100%;
  margin: 0 auto;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

@media (max-width: 720px) {
  .admin-dashboard-page {
    padding: 2rem 1.1rem 3.5rem;
  }

  .admin-dashboard {
    gap: 1.5rem;
  }
}

.admin-tabs {
  display: inline-flex;
  gap: 0.75rem;
  padding: 0.35rem;
  background: var(--surface);
  border-radius: 999px;
  border: 1px solid rgba(93, 75, 255, 0.14);
  box-shadow: 0 14px 28px rgba(93, 75, 255, 0.18);
  align-self: flex-start;
}

.tab-pill {
  padding: 0.65rem 1.35rem;
  border-radius: 999px;
  font-weight: 700;
  color: var(--text-dark);
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid transparent;
  box-shadow: 0 10px 20px rgba(13, 23, 64, 0.08);
  transition: transform 0.3s var(--transition), box-shadow 0.3s var(--transition), background 0.3s var(--transition);
}

.tab-pill:hover,
.tab-pill:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 16px 28px rgba(93, 75, 255, 0.2);
}

.tab-pill.active {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  border-color: transparent;
  box-shadow: 0 18px 32px rgba(93, 75, 255, 0.28);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.metric-card {
  position: relative;
  padding: 1rem 1.1rem 1.2rem;
  border-radius: 1.2rem;
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.82)) padding-box,
    linear-gradient(135deg, rgba(93, 75, 255, 0.4), rgba(255, 122, 199, 0.42), rgba(255, 188, 87, 0.4)) border-box;
  border: 1px solid transparent;
  box-shadow: 0 20px 48px rgba(93, 75, 255, 0.25), 0 12px 24px rgba(8, 12, 54, 0.18);
  overflow: hidden;
  backdrop-filter: blur(10px);
  display: grid;
  gap: 0.55rem;
}

.metric-card::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: radial-gradient(circle at 18% 20%, rgba(93, 75, 255, 0.18), transparent 35%),
    radial-gradient(circle at 80% 0%, rgba(255, 122, 199, 0.18), transparent 36%),
    radial-gradient(circle at 20% 100%, rgba(255, 188, 87, 0.22), transparent 35%);
  pointer-events: none;
  opacity: 0.7;
}

.metric-card > * {
  position: relative;
  z-index: 1;
}

.metric-card-wide {
  grid-column: span 2;
}

.metric-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: linear-gradient(120deg, rgba(93, 75, 255, 0.16), rgba(255, 122, 199, 0.2));
  border: 1px solid rgba(93, 75, 255, 0.28);
  color: var(--text-dark);
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.metric-divider {
  height: 3px;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--accent), #ffbc57);
  box-shadow: 0 12px 26px rgba(93, 75, 255, 0.28);
}

.metric-value {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text-dark);
}

.metric-subtext {
  color: var(--text-light);
  font-size: 0.95rem;
  font-weight: 600;
}

.metric-pair {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.section-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-start;
  justify-content: space-between;
  padding: 1rem 1.2rem 0.75rem;
}

.section-header h2 {
  margin: 0 0 0.25rem;
}

.section-subtext {
  margin: 0;
  color: var(--text-light);
  font-weight: 500;
}

.chip-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
  align-items: center;
  overflow-x: auto;
  padding: 0.25rem;
  margin: -0.25rem;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.chip-row .chip {
  flex: 0 0 auto;
  white-space: nowrap;
}

@media (max-width: 720px) {
  .chip-row {
    gap: 0.4rem;
  }

  .chip-row .chip {
    padding: 0.5rem 1rem;
  }
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.chip {
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  border: 1px solid rgba(93, 75, 255, 0.14);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-dark);
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 16px rgba(13, 23, 64, 0.06);
  transition: transform 0.25s var(--transition), box-shadow 0.25s var(--transition), background 0.25s var(--transition);
}

.chip.secondary {
  background: rgba(93, 75, 255, 0.08);
}

.chip.active {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  box-shadow: 0 16px 28px rgba(93, 75, 255, 0.22);
  border-color: transparent;
}

.chip:hover,
.chip:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(93, 75, 255, 0.2);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: rgba(93, 75, 255, 0.08);
  font-weight: 700;
  text-transform: capitalize;
  border: 1px solid rgba(93, 75, 255, 0.18);
}

.status-open { background: rgba(255, 188, 87, 0.16); border-color: rgba(255, 188, 87, 0.4); }
.status-pending { background: rgba(255, 122, 199, 0.18); border-color: rgba(255, 122, 199, 0.32); }
.status-cpaa { background: rgba(93, 75, 255, 0.14); border-color: rgba(93, 75, 255, 0.32); }
.status-resolved { background: rgba(96, 223, 255, 0.18); border-color: rgba(96, 223, 255, 0.36); }
.status-closed { background: rgba(93, 75, 255, 0.16); border-color: rgba(93, 75, 255, 0.36); }
.status-invalid { background: rgba(255, 87, 87, 0.14); border-color: rgba(255, 87, 87, 0.32); color: #7a0b0b; }
.status-none { background: rgba(13, 23, 64, 0.05); border-color: rgba(13, 23, 64, 0.14); }
.status-plan { background: rgba(93, 75, 255, 0.1); border-color: rgba(93, 75, 255, 0.24); }

.link-action {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.85rem;
  border-radius: 0.75rem;
  font-weight: 700;
  font-size: 0.9rem;
  background: rgba(93, 75, 255, 0.08);
  color: var(--primary-dark);
  border: 1px solid rgba(93, 75, 255, 0.18);
  box-shadow: 0 12px 18px rgba(93, 75, 255, 0.12);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.2s var(--transition), box-shadow 0.2s var(--transition), filter 0.2s var(--transition);
}

.link-action:hover,
.link-action:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 16px 28px rgba(93, 75, 255, 0.18);
  filter: brightness(1.05);
}

.link-action:disabled,
.link-action[aria-disabled="true"] {
  opacity: 0.65;
  pointer-events: none;
}

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

.row-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.tickets-section,
.users-section,
.analytics-section {
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.86)) padding-box,
    linear-gradient(135deg, rgba(93, 75, 255, 0.38), rgba(255, 122, 199, 0.36), rgba(255, 188, 87, 0.32)) border-box;
  border: 1px solid transparent;
  border-radius: 1.4rem;
  box-shadow: 0 20px 48px rgba(93, 75, 255, 0.24), 0 12px 26px rgba(12, 8, 64, 0.12);
  overflow: hidden;
}

.tickets-section h2,
.users-section h2,
.analytics-section h2 {
  margin: 0;
  font-size: 1.2rem;
  letter-spacing: 0.01em;
}

.tickets-section {
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.86)) padding-box,
    linear-gradient(135deg, rgba(93, 75, 255, 0.38), rgba(255, 122, 199, 0.36), rgba(255, 188, 87, 0.32)) border-box;
  border: 1px solid transparent;
  border-radius: 1.4rem;
  box-shadow: 0 20px 48px rgba(93, 75, 255, 0.24), 0 12px 26px rgba(12, 8, 64, 0.12);
  overflow: hidden;
}

.tickets-section h2 {
  margin: 0;
  padding: 1.1rem 1.25rem;
  font-size: 1.2rem;
  letter-spacing: 0.01em;
  border-bottom: 1px solid rgba(93, 75, 255, 0.12);
  background: linear-gradient(120deg, rgba(93, 75, 255, 0.1), rgba(255, 122, 199, 0.08));
}

.table-scroll {
  overflow-x: auto;
  width: 100%;
  box-sizing: border-box;
  padding: 0 0 1rem;
}

.tickets-table {
  width: 100%;
  border-collapse: collapse;
  min-width: min(680px, 100%);
}

.tickets-table th,
.tickets-table td {
  padding: 0.72rem 0.8rem;
  text-align: left;
  border-bottom: 1px solid rgba(93, 75, 255, 0.08);
  font-size: 0.95rem;
}

.tickets-table .ticket-description-col {
  max-width: 420px;
  width: 32%;
}

.ticket-description-text {
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.tickets-table th {
  background: linear-gradient(120deg, rgba(93, 75, 255, 0.08), rgba(255, 122, 199, 0.08));
  font-weight: 700;
  font-size: 0.88rem;
  letter-spacing: 0.03em;
  color: var(--text-dark);
}

.tickets-table tr:hover {
  background: rgba(93, 75, 255, 0.06);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text-dark);
  text-decoration: none;
}

.brand span.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.85rem;
  background: linear-gradient(140deg, rgba(93, 75, 255, 0.9), rgba(255, 122, 199, 0.85));
  color: white;
  font-size: 1.3rem;
  box-shadow: 0 12px 24px rgba(93, 75, 255, 0.25);
}

.brand-logo {
  height: 170px;
  width: auto;
  display: block;
  object-fit: contain;
}

@media (max-width: 480px) {
  .brand-logo {
    height: 140px;
  }

  body:not(.app-dashboard) header.navbar .brand-logo {
    height: 88px;
  }
}

body:not(.app-dashboard) .brand-logo {
  height: 132px !important;
  width: auto !important;
  display: block;
}

@media (max-width: 560px) {
  body:not(.app-dashboard) .brand-logo {
    height: 88px !important;
  }

  body:not(.app-dashboard) header.navbar {
    min-height: 104px;
  }
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.nav-links a {
  text-decoration: none;
  color: var(--text-light);
  font-weight: 500;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  transition: transform 0.35s var(--transition), box-shadow 0.35s var(--transition), color 0.35s var(--transition);
}

.nav-links a:hover,
.nav-links a:focus-visible {
  color: var(--text-dark);
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(93, 75, 255, 0.18);
}

.nav-links .cta {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  box-shadow: 0 16px 32px rgba(93, 75, 255, 0.25);
}

.hero {
  background: var(--surface-strong);
  border-radius: 2rem;
  padding: clamp(2.5rem, 5vw, 4rem);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 2.75rem;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(93, 75, 255, 0.16), rgba(255, 122, 199, 0.12));
  mix-blend-mode: screen;
}

.hero-text {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.hero-text h1,
.hero-text h2 {
  margin: 0;
  font-size: clamp(2.25rem, 5vw, 3.1rem);
  line-height: 1.15;
}

.hero-text p {
  margin: 0;
  color: var(--text-light);
  font-size: 1.05rem;
  max-width: 32ch;
}

/* App dashboard experience */
.app-dashboard {
  margin: 0;
  min-height: 100vh;
  color: #f7f5ff;
  background: radial-gradient(circle at 10% 20%, rgba(93, 75, 255, 0.3), transparent 30%),
    radial-gradient(circle at 80% 10%, rgba(255, 122, 199, 0.28), transparent 32%),
    linear-gradient(135deg, #0f0a2b, #251056 45%, #381677 70%, #5a2aa8 100%);
  font-family: 'Poppins', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  overflow-x: hidden;
  position: relative;
}

.app-dashboard a {
  color: inherit;
}

.app-dashboard::after {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 30% 70%, rgba(255, 188, 87, 0.08), transparent 50%),
    radial-gradient(circle at 75% 55%, rgba(96, 223, 255, 0.12), transparent 45%);
  pointer-events: none;
  z-index: 0;
}

.app-dashboard canvas#bgCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  filter: brightness(1.05) blur(0.75px);
  mix-blend-mode: screen;
}

.app-dashboard .user-badge {
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(93, 75, 255, 0.5), rgba(255, 122, 199, 0.45)) padding-box,
    linear-gradient(120deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.08)) border-box;
  border: 1px solid transparent;
  color: #ffffff;
  box-shadow: 0 16px 32px rgba(8, 6, 38, 0.45), 0 10px 22px rgba(93, 75, 255, 0.28);
  text-decoration: none;
}

.app-dashboard .user-badge .label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 10px;
  background: linear-gradient(120deg, rgba(93, 75, 255, 0.7), rgba(255, 122, 199, 0.75));
  border: 1px solid rgba(255, 255, 255, 0.35);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.app-dashboard .user-badge .value {
  font-weight: 700;
  font-size: 0.98rem;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.28);
}

.app-dashboard .top-actions {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 2;
  display: flex;
  gap: 10px;
  align-items: center;
}

.app-dashboard .cancel-top-button,
.app-dashboard .logout-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #ffffff;
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.25s var(--transition), box-shadow 0.25s var(--transition);
  box-shadow: 0 16px 32px rgba(8, 6, 38, 0.45);
}

.app-dashboard .cancel-top-button {
  background: linear-gradient(135deg, rgba(255, 94, 98, 0.28), rgba(255, 166, 43, 0.26));
  box-shadow: 0 14px 28px rgba(255, 94, 98, 0.24);
}

.app-dashboard .logout-button {
  background: linear-gradient(135deg, rgba(255, 94, 98, 0.28), rgba(93, 75, 255, 0.26));
}

.app-dashboard .cancel-top-button:hover,
.app-dashboard .cancel-top-button:focus-visible,
.app-dashboard .logout-button:hover,
.app-dashboard .logout-button:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 20px 36px rgba(93, 75, 255, 0.45);
}


.app-dashboard .main-app-wrapper {
  position: relative;
  width: 100%;
  min-height: 100vh;
}

.app-dashboard .container {
  position: relative;
  z-index: 1;
  max-width: 900px;
  margin: 0 auto 32px;
  padding: 20px 24px 32px;
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02)) padding-box,
    linear-gradient(135deg, rgba(93, 75, 255, 0.55), rgba(255, 122, 199, 0.45), rgba(255, 188, 87, 0.45)) border-box;
  border: 1px solid transparent;
  box-shadow: 0 24px 68px rgba(7, 3, 36, 0.65), 0 12px 28px rgba(93, 75, 255, 0.35);
  border-radius: 18px;
  backdrop-filter: blur(12px);
}

.app-topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  margin-bottom: 16px;
}

.app-topbar-left {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.app-topbar-credits {
  display: inline-flex;
  align-items: center;
}

.app-topbar-credits .app-credits-list {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.app-topbar-credits .pdf-quota-button[data-docx-quota],
.app-topbar-credits .pdf-quota-button[data-txt-quota] {
  order: -1;
}

.app-topbar-credits .pdf-quota-button[data-pdf-quota] {
  order: 0;
}

.app-topbar-credits .usage-quota-chip {
  order: 1;
}

.app-topbar-logo {
  height: 160px;
  width: auto;
  filter: drop-shadow(0 6px 14px rgba(93, 75, 255, 0.35));
}

.app-topbar-logo-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

@media (max-width: 640px) {
  .app-topbar-logo {
    height: 72px;
  }
}

.app-plan-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.7;
  color: #ffffff;
}

.app-plan-name {
  font-size: 13px;
  font-weight: 600;
  color: #ffffff;
  padding: 2px 8px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.08);
}

.app-topbar-username {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #ffffff;
}

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

.app-topbar-links {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.app-topbar-links a {
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(93, 75, 255, 0.2), rgba(255, 122, 199, 0.2));
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f9f8ff;
  font-weight: 600;
  font-size: 0.75rem;
  transition: transform 0.3s var(--transition), box-shadow 0.3s var(--transition);
  white-space: nowrap;
}

.app-topbar-links a:hover,
.app-topbar-links a:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(93, 75, 255, 0.35);
}

.app-topbar-links .app-topbar-upgrade {
  background: linear-gradient(135deg, rgba(93, 75, 255, 0.45), rgba(255, 122, 199, 0.4));
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-weight: 700;
  box-shadow: 0 14px 28px rgba(10, 4, 48, 0.4), 0 8px 18px rgba(255, 122, 199, 0.22);
}

.app-topbar-links .app-topbar-upgrade:hover,
.app-topbar-links .app-topbar-upgrade:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 18px 34px rgba(93, 75, 255, 0.5);
}

.app-dashboard .account-pill {
  border: none;
  cursor: pointer;
  border-radius: 9999px;
  padding: 7px 14px;
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  background: linear-gradient(135deg, #ff6ac1, #7b5cff);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.app-dashboard .account-pill:hover,
.app-dashboard .account-pill:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.42);
}

.app-dashboard header.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 14px;
  width: min(900px, 92vw);
  max-width: 900px;
  box-sizing: border-box;
  border-radius: 16px;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 16px 32px rgba(8, 6, 38, 0.45);
  flex-wrap: wrap;
  gap: 8px;
  position: fixed;
  top: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
}

.app-dashboard header.navbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  text-decoration: none;
  font-size: 1.2rem;
  letter-spacing: 0.01em;
  color: #fdfcff;
}

.app-dashboard header.navbar .nav-right {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: flex-start;
  margin-left: auto;
  flex: 1 1 0;
  min-width: 0;
  max-width: 100%;
}

.app-dashboard header.navbar .nav-right nav,
.app-dashboard header.navbar .upgrade-button,
.app-dashboard header.navbar .unlimited-banner {
  order: 1;
}

.app-dashboard header.navbar .unlimited-banner {
  margin-left: auto;
}

.app-dashboard header.navbar .pdf-quota-actions,
.app-dashboard header.navbar .user-stats {
  order: 2;
  flex-basis: 100%;
  justify-content: flex-start;
}

.app-dashboard .account-menu {
  position: relative;
  display: flex;
  align-items: center;
}

.app-dashboard .account-avatar {
  width: 32px;
  height: 32px;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.16);
  color: #0f0a2b;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 8px 18px rgba(10, 4, 48, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.app-dashboard .account-avatar:hover,
.app-dashboard .account-avatar:focus-visible {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.22);
  box-shadow: 0 12px 22px rgba(10, 4, 48, 0.45);
}

.app-dashboard .account-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  min-width: 200px;
  background: #1f2933;
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
  padding: 6px 0;
  z-index: 20;
  font-size: 13px;
  color: #e5e7eb;
}

.app-dashboard .account-dropdown.hidden {
  display: none;
}


.app-dashboard .account-user {
  padding: 8px 14px 6px;
  font-size: 12px;
  color: #cbd5e1;
  font-weight: 600;
  line-height: 1.2;
  word-break: break-word;
}

.app-dashboard .account-divider {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin: 4px 0;
}

.app-dashboard .account-item {
  width: 100%;
  text-align: left;
  padding: 8px 14px;
  background: transparent;
  border: none;
  cursor: pointer;
  font: inherit;
  color: #e5e7eb;
  transition: background 0.15s ease, color 0.15s ease;
}

.app-dashboard .account-item:hover,
.app-dashboard .account-item:focus-visible {
  background: rgba(255, 255, 255, 0.06);
}

.app-dashboard .plan-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 14px;
  background:
    linear-gradient(140deg, rgba(96, 216, 255, 0.15), rgba(160, 32, 240, 0.15)) padding-box,
    linear-gradient(120deg, rgba(93, 75, 255, 0.4), rgba(255, 122, 199, 0.35)) border-box;
  border: 1px solid transparent;
  box-shadow: 0 10px 26px rgba(10, 4, 48, 0.32), 0 6px 16px rgba(255, 122, 199, 0.16);
  white-space: nowrap;
}

.app-dashboard .plan-badge .label {
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #f5f1ff;
  opacity: 0.85;
}

.app-dashboard .plan-badge .value {
  font-weight: 700;
  color: #ffffff;
  font-size: 0.95rem;
}

.app-dashboard .unlimited-banner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  margin: 10px 0 6px;
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
  border-radius: 9999px;
  background: linear-gradient(135deg, #34d399, #10b981);
  box-shadow: 0 10px 20px rgba(16, 185, 129, 0.25);
}

.app-dashboard header.navbar nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.app-dashboard header.navbar nav a {
  text-decoration: none;
  padding: 3px 8px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(93, 75, 255, 0.2), rgba(255, 122, 199, 0.2));
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f9f8ff;
  font-weight: 600;
  font-size: 0.7rem;
  transition: transform 0.3s var(--transition), box-shadow 0.3s var(--transition);
}

.app-dashboard header.navbar nav .cancel-link {
  background: linear-gradient(135deg, rgba(255, 94, 98, 0.22), rgba(255, 166, 43, 0.2));
  border-color: rgba(255, 129, 133, 0.35);
  color: #fff5f5;
  box-shadow: 0 8px 16px rgba(255, 94, 98, 0.18);
}

.app-dashboard header.navbar .upgrade-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(93, 75, 255, 0.45), rgba(255, 122, 199, 0.4));
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.7rem;
  text-decoration: none;
  box-shadow: 0 14px 28px rgba(10, 4, 48, 0.4), 0 8px 18px rgba(255, 122, 199, 0.22);
  transition: transform 0.3s var(--transition), box-shadow 0.3s var(--transition);
  white-space: nowrap;
}

.app-dashboard header.navbar .upgrade-button:hover,
.app-dashboard header.navbar .upgrade-button:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 18px 34px rgba(93, 75, 255, 0.5);
}

.app-dashboard header.navbar nav a:hover,
.app-dashboard header.navbar nav a:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(93, 75, 255, 0.35);
}

.app-dashboard .user-stats {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-start;
  overflow-x: visible;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.app-dashboard .user-stats::-webkit-scrollbar {
  display: none;
}

.app-dashboard .user-stats .stat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  border-radius: 6px;
  min-width: 0;
  max-width: 100%;
  flex-shrink: 1;
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.05)) padding-box,
    linear-gradient(120deg, rgba(93, 75, 255, 0.45), rgba(255, 122, 199, 0.4)) border-box;
  border: 1px solid transparent;
  box-shadow: 0 10px 26px rgba(10, 4, 48, 0.45), 0 6px 14px rgba(255, 122, 199, 0.18);
  text-align: left;
}

.app-dashboard .user-stats .stat .label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 5px;
  border-radius: 8px;
  background: linear-gradient(120deg, rgba(93, 75, 255, 0.7), rgba(255, 122, 199, 0.75));
  border: 1px solid rgba(255, 255, 255, 0.35);
  font-size: 0.52rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #fefbff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.app-dashboard .user-stats .stat .value {
  font-size: 0.76rem;
  font-weight: 600;
  margin-top: 0;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-dashboard .accent-divider {
  height: 4px;
  margin: 14px 0 18px;
  border-radius: 999px;
  background: linear-gradient(90deg, #5d4bff, #ff7ac7, #5d4bff 70%, #ffbc57);
  box-shadow: 0 16px 32px rgba(93, 75, 255, 0.35), 0 10px 24px rgba(255, 122, 199, 0.28);
}

.app-dashboard .logo-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.app-dashboard .glow-avatar {
  height: 44px;
  animation: float-glow 3s ease-in-out infinite;
  filter: drop-shadow(0 0 10px #aa00ff);
}

.app-dashboard .logo-title h4 {
  font-size: 1.5rem;
  margin: 0;
  font-weight: 800;
  display: inline-block;
  letter-spacing: 0.02em;
}

.app-dashboard .logo-title .highlight {
  background: linear-gradient(90deg, #60d8ff, #a020f0, #ff7ac7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shine 2.25s linear infinite;
}

.app-dashboard .logo-title .subtitle {
  background: linear-gradient(90deg, #bce5ff, #eac8ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.app-dashboard #ebookForm {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
}

/* 2-column layout: topic/chapters stacked + genres */
.gen-form-row {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(0, 1.35fr);
  gap: 14px;
  align-items: start;
  margin-top: 6px;
}

.gen-col {
  min-width: 0;
}

.topic-stack {
  display: grid;
  gap: 8px;
}

.gen-secondary {
  gap: 8px;
  margin-top: 4px;
}

.form-note {
  font-size: 0.62rem;
  line-height: 1.2;
  margin-top: 2px;
}

.genres-wide {
  margin-top: 6px;
  padding-top: 0;
}

.genres-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
}

.genres-title,
.genres-helper {
  margin: 0;
}

.topic-stack .form-row {
  max-width: 420px;
  width: 100%;
}

/* Keep genres box usable and not too tall in the row */
.genres-col .genres-container,
.genres-col .genres-box,
.genres-col .genre-list {
  max-height: 220px;
  overflow: auto;
}

/* Mobile: stack vertically */
@media (max-width: 900px) {
  .gen-form-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .genres-col .genres-container,
  .genres-col .genres-box,
  .genres-col .genre-list {
    max-height: 260px;
  }
}

.genres-col .genres-container * {
  box-sizing: border-box;
}
.genres-col .genres-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.app-dashboard form label {
  display: block;
  margin-top: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #fdfcff;
}

.app-dashboard #ebookForm input,
.app-dashboard #ebookForm button,
.app-dashboard #bottom-buttons button,
.app-dashboard #download button {
  width: 100%;
  padding: 12px 14px;
  margin: 8px 0;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  transition: border-color 0.3s var(--transition), box-shadow 0.3s var(--transition), transform 0.2s ease;
}

.app-dashboard #ebookForm input::placeholder {
  color: #ffffff;
  opacity: 0.8;
}

.app-dashboard #ebookForm input:focus-visible,
.app-dashboard .preview-controls input:focus-visible,
.app-dashboard .preview-controls select:focus-visible,
.app-dashboard #ebookForm button:focus-visible,
.app-dashboard #bottom-buttons button:focus-visible,
.app-dashboard #download button:focus-visible {
  outline: none;
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 16px 34px rgba(93, 75, 255, 0.32);
}

.app-dashboard #ebookForm button,
.app-dashboard #bottom-buttons button,
.app-dashboard #download button {
  background: linear-gradient(120deg, #00ffa3, #5d4bff, #ff7ac7);
  cursor: pointer;
  font-weight: 800;
  letter-spacing: 0.01em;
  box-shadow: 0 18px 36px rgba(0, 255, 163, 0.25), 0 10px 24px rgba(93, 75, 255, 0.3);
}

body.app-dashboard.page-app #ebookForm button.qb-tiny-btn,
body.app-dashboard.page-app #bottom-buttons button.qb-tiny-btn,
body.app-dashboard.page-app #download button.qb-tiny-btn,
body.app-dashboard.page-app button.qb-tiny-btn {
  width: fit-content;
  display: inline-flex;
  justify-self: start;
  align-self: start;
  padding: 2px 8px;
  margin: 0;
  font-size: 12px;
  line-height: 1.2;
  min-height: 24px;
  white-space: nowrap;
}

.app-dashboard #ebookForm button:hover:not(.no-hover-lift),
.app-dashboard #bottom-buttons button:hover:not(.no-hover-lift),
.app-dashboard #download button:hover:not(.no-hover-lift) {
  transform: translateY(-1px);
}

/* Prevent hover-jitter / flicker on mouse by avoiding layout-shifting transforms on key CTAs. */
.app-dashboard .no-hover-lift,
.app-dashboard .secondary-button,
.app-dashboard .pdf-quota-button {
  transform: none !important;
}

.app-dashboard .no-hover-lift:hover,
.app-dashboard .no-hover-lift:focus-visible,
.app-dashboard .secondary-button:hover,
.app-dashboard .secondary-button:focus-visible,
.app-dashboard .pdf-quota-button:hover,
.app-dashboard .pdf-quota-button:focus-visible {
  transform: none !important;
  filter: brightness(1.05);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
  border-color: rgba(255, 255, 255, 0.25);
}

.app-dashboard #wizardStepGenerate {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  max-height: none;
  overflow-x: hidden;
  overflow-y: visible;
}

.app-dashboard .qb-generate-topbar {
  margin-top: 4px;
  display: flex;
  gap: 6px;
  align-items: center;
}

.app-dashboard .qb-toolbar-box,
.app-dashboard .qb-nav-box {
  border-radius: 10px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.04));
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 8px 20px rgba(8, 4, 44, 0.4);
}

.app-dashboard .qb-toolbar-box {
  flex: 1;
  padding: 8px;
}

.app-dashboard .qb-nav-box {
  width: 240px;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.app-dashboard #wizardStepGenerate .preview-controls button,
.app-dashboard #wizardStepGenerate .preview-controls select,
.app-dashboard #wizardStepGenerate .preview-controls input,
.app-dashboard #wizardStepGenerate .page-nav-button {
  width: auto !important;
  margin: 0 !important;
  padding: 0 8px !important;
  height: 28px !important;
  min-width: 28px;
  font-size: 12px;
  border-radius: 10px;
  box-shadow: none !important;
}

.app-dashboard #wizardStepGenerate .preview-controls {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
}

.app-dashboard .preview-controls {
  margin-top: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  padding: 0;
  border: 0;
  box-shadow: none;
  background: transparent;
  overflow: visible;
}

.app-dashboard .preview-controls .toolbar-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 3px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #f6f5ff;
}

.app-dashboard .preview-controls .tool {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.app-dashboard .preview-controls .toolbar-item label {
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0;
}

.app-dashboard .preview-controls input,
.app-dashboard .preview-controls select,
.app-dashboard .preview-controls button,
.app-dashboard .qb-toolbar-box input,
.app-dashboard .qb-toolbar-box select,
.app-dashboard .qb-toolbar-box button {
  height: 24px;
  padding: 2px 6px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.14);
  color: #0a0a0a;
  font-size: 12px;
  line-height: 1;
}

.app-dashboard .preview-controls select {
  min-width: 60px;
  background: #0d0b1d;
  color: #fdfbff;
  height: 28px !important;
  padding: 0 10px !important;
  border-radius: 12px;
  box-shadow: none !important;
  font-size: 12px;
}

.app-dashboard .preview-controls #fontFamilySelect,
.app-dashboard .preview-controls #customFontInput {
  min-width: 140px;
  max-width: 180px;
  background: #0d0b1d;
  color: #fdfbff;
  border-color: rgba(255, 255, 255, 0.24);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-dashboard .preview-controls #fontSizeSelect {
  min-width: 62px;
}

.app-dashboard .preview-controls .text-style-group,
.app-dashboard .preview-controls .alignment-group {
  display: inline-flex;
  gap: 4px;
}

.app-dashboard .preview-controls .style-toggle,
.app-dashboard .qb-toolbar-box .icon-btn {
  width: 24px;
  min-width: 24px;
  height: 24px;
  padding: 0;
  display: grid;
  place-items: center;
  font-weight: 800;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.08));
  color: #0d0b1d;
  cursor: pointer;
  transition: box-shadow 0.2s ease;
}

.app-dashboard .preview-controls .style-toggle.is-active {
  box-shadow: 0 0 0 2px #ff7ac7 inset, 0 5px 12px rgba(255, 122, 199, 0.35);
}

.app-dashboard .preview-controls .align-toggle {
  font-size: 0.72rem;
}

.app-dashboard .preview-controls .color-pair {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.app-dashboard .preview-controls .qb-color-tools {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.app-dashboard .preview-controls [data-tip] {
  position: relative;
}

.app-dashboard .preview-controls [data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translate(-50%, 2px);
  opacity: 0;
  pointer-events: none;
  z-index: 40;
  padding: 4px 7px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: linear-gradient(180deg, rgba(42, 38, 74, 0.96), rgba(21, 17, 47, 0.96));
  box-shadow: 0 6px 16px rgba(7, 5, 20, 0.42);
  color: #fefcff;
  font-size: 11px;
  line-height: 1.1;
  white-space: nowrap;
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.app-dashboard .preview-controls [data-tip]::before {
  content: '';
  position: absolute;
  left: 50%;
  bottom: calc(100% + 2px);
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
  z-index: 39;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid rgba(24, 20, 51, 0.96);
  transition: opacity 0.16s ease;
}

.app-dashboard .preview-controls [data-tip]:hover::after,
.app-dashboard .preview-controls [data-tip]:hover::before,
.app-dashboard .preview-controls [data-tip]:focus-visible::after,
.app-dashboard .preview-controls [data-tip]:focus-visible::before {
  opacity: 1;
  transform: translate(-50%, 0);
}

.app-dashboard .preview-controls .qb-icon-btn {
  width: 28px;
  min-width: 28px;
  height: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.08));
  color: #0d0b1d;
}

.app-dashboard .preview-controls .qb-color-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.app-dashboard .preview-controls .qb-color-btn {
  position: relative;
  overflow: visible;
}

.app-dashboard .preview-controls .qb-color-icon-text {
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.app-dashboard .preview-controls .qb-color-icon-text::after {
  content: '';
  position: absolute;
  left: 1px;
  right: 1px;
  bottom: -2px;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff7ac7, #7ef3ff);
}

.app-dashboard .preview-controls .qb-color-icon-bg {
  width: 13px;
  height: 10px;
  border: 1.5px solid currentColor;
  border-radius: 2px;
  transform: rotate(-14deg);
}

.app-dashboard .preview-controls .qb-color-icon-bg::after {
  content: '';
  position: absolute;
  width: 7px;
  height: 2px;
  background: currentColor;
  border-radius: 999px;
  right: -4px;
  top: -3px;
  transform: rotate(25deg);
}

.app-dashboard .preview-controls .qb-swatch {
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  background: #ffffff;
}

.app-dashboard .preview-controls .qb-color-picker {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .app-dashboard .preview-controls [data-tip]::after,
  .app-dashboard .preview-controls [data-tip]::before {
    transition: none;
    transform: translate(-50%, 0);
  }
}

.app-dashboard .preview-controls .color-chip {
  display: inline-flex;
  gap: 3px;
  align-items: center;
  padding: 1px 3px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.app-dashboard .preview-controls .color-chip span {
  font-weight: 700;
  color: #fdfbff;
  font-size: 10px;
}

.app-dashboard .qb-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-dashboard .preview-controls input[type='color'] {
  width: 22px;
  min-width: 22px;
  height: 20px;
  padding: 0;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  cursor: pointer;
}

.app-dashboard .preview-controls #fontFamilySelect:focus-visible,
.app-dashboard .preview-controls #customFontInput:focus-visible,
.app-dashboard .preview-controls select:focus-visible,
.app-dashboard .preview-controls button:focus-visible,
.app-dashboard .preview-controls input[type='color']:focus-visible {
  outline: 2px solid #ff7ac7;
  outline-offset: 2px;
}

.app-dashboard .page-nav {
  margin-top: 0;
  border-radius: 10px;
  font-size: 11px;
}

.app-dashboard .page-nav-button {
  border: none;
  border-radius: 8px;
  padding: 2px 8px;
  height: 24px;
  cursor: pointer;
  font-weight: 700;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  box-shadow: none;
  transition: transform 0.2s ease, background 0.2s ease;
}

.app-dashboard .page-nav-status {
  font-weight: 600;
  text-align: center;
  flex: 1;
  font-size: 11px;
  line-height: 1.2;
}

.app-dashboard .qb-preview-stack {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.app-dashboard .qb-preview-viewport {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  flex: 1;
  min-height: 0;
  height: auto;
  padding: 2px 0;
  overflow-x: hidden;
  overflow-y: auto;
  margin-top: 0;
}

.app-dashboard .qb-preview-scale {
  transform: scale(var(--qb-preview-scale, 1));
  transform-origin: top center;
  will-change: transform;
}

.app-dashboard #viewer,
.app-dashboard .qb-preview-page {
  --viewer-bg-color: #f5f5dc;
  --viewer-text-color: #4b2e1f;
  --viewer-font-size-pt: 12pt;
  --viewer-font-weight: 400;
  --viewer-font-style: normal;
  --viewer-text-decoration: none;
  --viewer-page-width: 832px;
  --viewer-page-top-gap: 3.4em;
  width: 832px;
  height: 1258px;
  aspect-ratio: auto;
  background: var(--viewer-bg-color, #f5f5dc);
  color: var(--viewer-text-color, #4b2e1f);
  padding: 22px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-size: var(--viewer-font-size-pt, 12pt);
  font-family: var(--viewer-font-family, 'Segoe UI', sans-serif);
  font-weight: var(--viewer-font-weight, 400);
  font-style: var(--viewer-font-style, normal);
  text-decoration: var(--viewer-text-decoration, none);
  overflow-x: hidden;
  overflow-y: auto;
  word-break: break-word;
  hyphens: auto;
}

.app-dashboard #viewer.is-paged {
  max-height: none;
  overflow-x: hidden;
  overflow-y: auto;
}

.app-dashboard #viewer .is-page-hidden {
  display: none;
}

.app-dashboard #viewer.is-editing {
  outline: 2px dashed rgba(255, 255, 255, 0.35);
  box-shadow: 0 20px 48px rgba(8, 4, 44, 0.65), 0 12px 28px rgba(93, 75, 255, 0.5);
  overflow-y: auto;
}

.app-dashboard .qb-page-measure-host {
  position: fixed;
  visibility: hidden;
  inset: auto;
  pointer-events: none;
  left: -99999px;
  top: 0;
  z-index: -1;
}

.app-dashboard .qb-page-measure {
  overflow: visible !important;
  aspect-ratio: auto;
  min-height: 0;
  height: auto;
}

.app-dashboard .qb-page-overflow {
  overflow: hidden;
}

@media (max-width: 820px) {
  .app-dashboard .qb-generate-topbar {
    flex-direction: column;
    gap: 6px;
  }

  .app-dashboard #wizardStepGenerate .preview-controls {
    flex-wrap: wrap;
  }

  .app-dashboard .qb-nav-box {
    width: 100%;
    display: flex;
  }
}

@media (max-width: 768px) {
  .app-dashboard .qb-preview-stack {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    background: rgba(8, 6, 28, 0.55);
  }

  .app-dashboard .qb-preview-viewport {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    overflow-y: auto;
    padding-left: 8px;
    padding-right: 8px;
    box-sizing: border-box;
    background: rgba(8, 6, 28, 0.55);
    -webkit-overflow-scrolling: touch;
  }

  .app-dashboard .qb-preview-scale {
    width: 100%;
    display: flex;
    justify-content: center;
    transform: translateZ(0) scale(var(--qb-preview-scale, 1));
    backface-visibility: hidden;
  }

  .app-dashboard .qb-preview-page,
  .app-dashboard #viewer {
    --viewer-font-size-pt: 8.75pt;
    height: auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    backface-visibility: hidden;
    transform: translateZ(0);
  }
}

@media (max-width: 520px) {
  .app-dashboard .qb-toolbar-box,
  .app-dashboard .qb-nav-box {
    padding: 5px 6px;
  }

  .app-dashboard .qb-preview-page,
  .app-dashboard #viewer {
    padding: 12px;
  }

  .app-dashboard .qb-preview-page,
  .app-dashboard #viewer,
  .app-dashboard .chapter-card,
  .app-dashboard .book-title-page,
  .app-dashboard .toc-page,
  .app-dashboard .book-cover-page {
    --viewer-page-width: 1000px;
  }

  .app-dashboard #viewer p,
  .app-dashboard .chapter-card p,
  .app-dashboard .chapter-body {
    line-height: 1.45;
  }

  .app-dashboard .qb-preview-viewport {
    height: auto;
  }
}

.app-dashboard #progress {
  margin-top: 4px;
  margin-bottom: 6px;
  min-height: 14px;
  font-size: 12px;
  line-height: 1.2;
  padding: 6px;
}

.app-dashboard .status-message {
  margin-top: 6px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 18px rgba(8, 4, 44, 0.35);
  line-height: 1.3;
  font-size: 12px;
  color: #fdfcff;
}

.app-dashboard .status-message p {
  margin: 0;
  font-weight: 700;
}

.app-dashboard .status-message.info {
  background: rgba(96, 223, 255, 0.14);
  border-color: rgba(96, 223, 255, 0.4);
}

.app-dashboard .status-message.error {
  background: rgba(255, 99, 132, 0.18);
  border-color: rgba(255, 99, 132, 0.45);
}

.app-dashboard .status-message.success {
  background: rgba(0, 255, 163, 0.18);
  border-color: rgba(0, 255, 163, 0.45);
}

.app-dashboard .status-message .actions {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.app-dashboard .status-message .action-link {
  text-decoration: none;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #fff;
  font-weight: 700;
  transition: transform 0.2s ease, background 0.2s ease;
}

.app-dashboard .status-message .action-link:hover,
.app-dashboard .status-message .action-link:focus-visible {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.15);
}

.app-dashboard .status-message .action-link.primary {
  background: linear-gradient(120deg, #ff8c00, #ff0080);
  border: none;
  box-shadow: 0 12px 24px rgba(255, 0, 128, 0.28);
}

.app-dashboard .chapter-card {
  background: transparent;
  border-radius: 16px;
  padding: calc(16px + var(--viewer-page-top-gap)) 16px 16px;
  margin-bottom: 18px;
  box-shadow: 0 12px 28px rgba(7, 3, 36, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.16);
  max-width: min(100%, var(--viewer-page-width, 832px));
  margin-left: auto;
  margin-right: auto;
  overflow: hidden;
}

.app-dashboard .book-title-page,
.app-dashboard .toc-page {
  background: transparent;
  border-radius: 16px;
  padding: calc(18px + var(--viewer-page-top-gap)) 18px 18px;
  margin-bottom: 18px;
  box-shadow: 0 12px 28px rgba(7, 3, 36, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.16);
  max-width: min(100%, var(--viewer-page-width, 832px));
  margin-left: auto;
  margin-right: auto;
}

.app-dashboard .book-cover-page {
  margin-bottom: 18px;
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 22px 46px rgba(7, 3, 36, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.22);
  max-width: min(100%, var(--viewer-page-width, 832px));
  margin-left: auto;
  margin-right: auto;
  background: linear-gradient(180deg, rgba(19, 17, 53, 0.92), rgba(10, 9, 32, 0.95));
}

.app-dashboard .book-cover-page {
  width: min(100%, var(--viewer-page-width, 832px));
  aspect-ratio: 832 / 1258;
  padding: clamp(10px, 2vw, 18px);
  box-sizing: border-box;
}

.app-dashboard .book-cover-page img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  object-position: center;
  background: transparent;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.app-dashboard .chapter-card h2 {
  margin-top: 0;
  text-align: left;
  font-size: calc(var(--viewer-font-size-pt, 12pt) * 1.35);
  color: inherit;
  line-height: 1.3;
  font-weight: 800;
  word-break: break-word;
  hyphens: auto;
}

.app-dashboard .chapter-card p {
  margin: 0 0 12px;
  line-height: 1.7;
  color: inherit;
}

.app-dashboard .chapter-card,
.app-dashboard .chapter-card p,
.app-dashboard #viewer {
  white-space: normal;
  overflow-wrap: break-word;
  word-wrap: break-word;
  text-align: var(--viewer-text-align, left);
}

.app-dashboard .book-header {
  text-align: center;
  margin-bottom: 18px;
}

.app-dashboard .book-header h1 {
  margin: 0;
  font-size: calc(var(--viewer-font-size-pt, 12pt) * 2.2);
  color: inherit;
}

.app-dashboard .book-header p {
  margin: 6px 0 0;
  color: inherit;
}

.app-dashboard .book-footer {
  margin-top: 26px;
  text-align: center;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: inherit;
}

.app-dashboard #viewer h1,
.app-dashboard #viewer h2,
.app-dashboard #viewer h3 {
  font-weight: 800;
  margin: 18px 0 10px;
  text-align: var(--viewer-text-align, left);
  line-height: 1.3;
  color: inherit;
}

.app-dashboard #viewer h1 {
  font-size: calc(var(--viewer-font-size-pt, 12pt) * 2);
}

.app-dashboard #viewer h2 {
  font-size: calc(var(--viewer-font-size-pt, 12pt) * 1.6);
}

.app-dashboard #viewer h3 {
  font-size: calc(var(--viewer-font-size-pt, 12pt) * 1.3);
}

.app-dashboard #viewer p {
  line-height: 1.8;
  margin: 0 0 15px;
  color: inherit;
  text-align: var(--viewer-text-align, left);
}

.app-dashboard #viewer ul,
.app-dashboard #viewer ol {
  margin: 0 0 20px 25px;
  padding: 0;
  text-align: var(--viewer-text-align, left);
}

.app-dashboard #viewer li {
  margin-bottom: 8px;
  line-height: 1.7;
  color: inherit;
  text-align: var(--viewer-text-align, left);
}

.app-dashboard #viewer h1.chapter-title {
  font-size: calc(var(--viewer-font-size-pt, 12pt) * 2.2);
}


#qbLegacyProgressWrap {
  display: none !important;
  pointer-events: none !important;
}

.app-dashboard #progressContainer {
  width: 100%;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  overflow: hidden;
  height: 10px;
  margin-top: 2px;
  margin-bottom: 4px;
  display: none;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.24);
}

.app-dashboard #progressBar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #00ffa3, #5d4bff, #ff7ac7);
  text-align: center;
  line-height: 12px;
  font-size: 10px;
  color: #0d0c2c;
  font-weight: 800;
  transition: width 0.3s ease;
  pointer-events: none;
}

.app-dashboard #progress {
  display: none;
  pointer-events: none;
}

body.app-dashboard.is-generating #progress,
body.app-dashboard.is-generating #progressContainer,
body.app-dashboard.is-paused #progress,
body.app-dashboard.is-paused #progressContainer {
  display: block;
}


.app-dashboard #bottom-buttons.qb-bottombar {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.app-dashboard .qb-bottombar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-start;
}

.app-dashboard #download {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 10px;
  flex: 0 0 auto;
  align-items: center;
}

.app-dashboard #bottom-buttons button,
.app-dashboard #download button {
  flex: 0 0 auto;
}

/* Make bottom action and download buttons compact */
.app-dashboard #bottom-buttons button,
.app-dashboard #download button {
  width: auto;
  min-width: 0;
  height: 44px;
  line-height: 44px;
  padding: 0 16px;
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  flex: 0 0 auto;
  width: fit-content;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  border-radius: 14px;
}

.app-dashboard .qb-bottombar-actions button,
.app-dashboard .qb-bottombar-actions a {
  width: auto !important;
  margin: 0 !important;
}

.app-dashboard .qb-bottombar-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.app-dashboard #editBtn,
.app-dashboard #saveBtn,
.app-dashboard #toggleBtn {
  height: 36px;
  line-height: 36px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: 10px;
}

.app-dashboard #download button {
  background: linear-gradient(120deg, #ff8c00, #ff0080);
}

.app-dashboard #downloadBtn,
.app-dashboard #downloadDocxBtn,
.app-dashboard #downloadTxtBtn,
.app-dashboard #downloadEpubBtn,
.app-dashboard #downloadCertificateBtn {
  white-space: nowrap;
  min-width: 0;
  text-align: center;
}

.app-dashboard #toggleBtn {
  display: none;
}

@media print {
  .app-dashboard,
  .app-dashboard #viewer {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    background: #5d4bff !important;
    color: #fff !important;
    padding: 20px !important;
  }

  .app-dashboard .mjx-chtml {
    font-size: 100% !important;
    color: #fff !important;
  }

  .app-dashboard .container {
    background: rgba(0, 0, 0, 0.5) !important;
    border-radius: 10px !important;
    padding: 20px !important;
  }
}

/* Dev note: hover flicker came from the global button:hover transform in styles.css. */
.app-dashboard .my-books-panel .book-actions .download-action,
.app-dashboard #download .stable-action {
  white-space: nowrap;
  min-width: 0;
  font-size: clamp(12px, 2.8vw, 14px);
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.app-dashboard .qb-bottombar-meta {
  width: 100%;
}

.app-dashboard .qb-bottombar-disclaimer {
  font-size: 12px;
  opacity: 0.75;
  line-height: 1.35;
  max-width: 100%;
  text-align: left;
  padding: 0 2px;
  overflow-wrap: anywhere;
  position: static !important;
  float: none !important;
}

.app-dashboard .qb-bottombar-disclaimer .ai-disclaimer-micro {
  margin: 0;
  font-size: inherit;
  line-height: inherit;
  text-align: inherit;
  color: rgba(255, 255, 255, 0.75);
  position: static !important;
  float: none !important;
}

.app-dashboard .qb-bottombar-nav {
  display: flex;
  justify-content: flex-start;
}

.app-dashboard .qb-bottombar-nav button,
.app-dashboard .qb-bottombar-nav a {
  height: 36px;
  padding: 0 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  line-height: 36px;
  width: auto !important;
  margin: 0 !important;
}

@media (max-width: 700px) {
  .app-dashboard .qb-bottombar-actions {
    gap: 8px;
  }

  .app-dashboard .qb-bottombar-actions button,
  .app-dashboard .qb-bottombar-actions a {
    height: 40px;
    line-height: 40px;
    padding: 0 14px;
    font-size: 13px;
  }
}

@keyframes qbSpin {
  to {
    transform: rotate(360deg);
  }
}

button[aria-busy="true"]::after {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 8px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: qbSpin 0.8s linear infinite;
  vertical-align: -2px;
}

.app-dashboard .my-books-panel .book-actions .stable-action:hover,
.app-dashboard .my-books-panel .book-actions .stable-action:focus-visible,
.app-dashboard #download .stable-action:hover,
.app-dashboard #download .stable-action:focus-visible {
  transform: none !important;
  filter: brightness(1.05);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
}

@keyframes float-glow {
  0% {
    transform: translateY(0px);
    filter: drop-shadow(0 0 6px #aa00ff);
  }
  50% {
    transform: translateY(-8px);
    filter: drop-shadow(0 0 14px #ff00ff);
  }
  100% {
    transform: translateY(0px);
    filter: drop-shadow(0 0 6px #aa00ff);
  }
}

@keyframes shine {
  0% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.5);
  }
  100% {
    filter: brightness(1);
  }
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  position: relative;
  z-index: 1;
}

.hero-actions .btn {
  font-size: 1rem;
  padding: 0.85rem 1.65rem;
}

.hero-image {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 1.25rem;
  align-content: center;
}

.hero-image img {
  width: min(100%, 320px);
  justify-self: center;
  filter: drop-shadow(0 32px 55px rgba(33, 23, 85, 0.35));
  animation: float 7s ease-in-out infinite;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.badge {
  padding: 0.5rem 1rem;
  border-radius: 0.9rem;
  background: linear-gradient(120deg, rgba(93, 75, 255, 0.18), rgba(255, 122, 199, 0.24));
  color: var(--text-dark);
  font-weight: 700;
  font-size: 0.9rem;
  border: 1px solid rgba(93, 75, 255, 0.24);
  box-shadow: 0 12px 22px rgba(93, 75, 255, 0.18);
}

.section-card {
  background: var(--surface);
  border-radius: 1.75rem;
  padding: clamp(2rem, 4vw, 2.75rem);
  box-shadow: var(--shadow);
  position: relative;
  overflow: visible;
}

.section-card h2,
.section-card h3 {
  margin-top: 0;
}

.section-card p {
  color: var(--text-light);
}

.form-card form {
  display: grid;
  gap: 1rem;
}

label {
  display: grid;
  gap: 0.35rem;
  color: var(--text-light);
  font-weight: 600;
  font-size: 0.95rem;
}

.form-consent {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-weight: 500;
  font-size: 0.85rem;
  line-height: 1.4;
}

.form-consent input {
  margin-top: 0.2rem;
}

.form-consent a {
  color: inherit;
  text-decoration: underline;
}

.form-status {
  min-height: 1.5rem;
  margin-top: 0.25rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.75rem;
  background: rgba(93, 75, 255, 0.08);
  color: var(--text-light);
  font-weight: 500;
  text-align: center;
  transition: opacity 0.3s var(--transition);
}

.form-status.success {
  background: rgba(47, 154, 93, 0.15);
  color: #217a4a;
}

.form-status.error {
  background: rgba(229, 72, 77, 0.15);
  color: #b12a34;
}

.text-muted {
  color: var(--text-light);
  opacity: 0.75;
  text-align: center;
}

input,
textarea,
select {
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: 0.9rem;
  border: 1px solid rgba(93, 75, 255, 0.15);
  background: rgba(255, 255, 255, 0.85);
  font-family: inherit;
  font-size: 1rem;
  color: var(--text-dark);
  transition: border-color 0.3s var(--transition), box-shadow 0.3s var(--transition), transform 0.3s var(--transition);
}

.input-with-toggle {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-toggle input {
  padding-right: 2.6rem;
}

.password-toggle {
  position: absolute;
  right: 0.55rem;
  border: none;
  background: none;
  color: var(--text-light);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.35rem;
  display: inline-flex;
  align-items: center;
  gap: 0;
  box-shadow: none;
  transition: color 0.2s var(--transition), transform 0.2s var(--transition);
}

.password-toggle:hover,
.password-toggle:focus-visible {
  color: var(--primary);
}

.password-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 0.65rem;
}

.password-toggle .icon-eye-off {
  display: none;
}

.password-toggle[aria-pressed="true"] .icon-eye {
  display: none;
}

.password-toggle[aria-pressed="true"] .icon-eye-off {
  display: inline;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(93, 75, 255, 0.12);
  transform: translateY(-2px);
}

textarea {
  min-height: 160px;
  resize: vertical;
}

.btn,
button {
  appearance: none;
  border: none;
  border-radius: 0.95rem;
  padding: 0.85rem 1.7rem;
  font-weight: 600;
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  box-shadow: 0 18px 30px rgba(93, 75, 255, 0.28);
  transition: transform 0.35s var(--transition), box-shadow 0.35s var(--transition), filter 0.35s var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  text-decoration: none;
}

.btn.secondary {
  background: rgba(255, 255, 255, 0.95);
  color: var(--primary);
  box-shadow: inset 0 0 0 2px rgba(93, 75, 255, 0.25);
}

.btn:hover,
.btn:focus-visible,
button:hover,
button:focus-visible {
  transform: translateY(-3px) scale(1.01);
  box-shadow: 0 24px 40px rgba(93, 75, 255, 0.32);
  filter: brightness(1.02);
}

.info-grid {
  display: grid;
  gap: 1.75rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.info-card {
  background: rgba(255, 255, 255, 0.82);
  padding: 1.75rem;
  border-radius: 1.5rem;
  box-shadow: 0 16px 40px rgba(15, 23, 66, 0.12);
  display: grid;
  gap: 0.75rem;
  position: relative;
  overflow: hidden;
}

.info-card::after {
  content: '';
  position: absolute;
  inset: auto -20% -40% -20%;
  height: 60%;
  background: linear-gradient(135deg, rgba(93, 75, 255, 0.18), rgba(255, 122, 199, 0.18));
  filter: blur(45px);
  opacity: 0;
  transition: opacity 0.5s ease;
}

.info-card:hover::after {
  opacity: 1;
}

.plan-grid {
  display: grid;
  gap: 2rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  align-items: stretch;
  grid-auto-rows: 1fr;
  position: relative;
  z-index: 2;
  isolation: isolate;
}

.plans-heading {
  margin: 0 0 0.5rem;
  text-align: center;
  font-size: clamp(2rem, 5vw, 3rem);
}

.plans-subheading {
  margin: 0 auto 2rem;
  text-align: center;
  max-width: 780px;
  color: var(--text-light);
  font-size: 1.05rem;
}

.plan-card {
  background: rgba(255, 255, 255, 0.88);
  padding: 2rem 1.75rem;
  border-radius: 1.75rem;
  box-shadow: 0 20px 45px rgba(15, 23, 66, 0.14);
  display: grid;
  gap: 0.8rem;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(93, 75, 255, 0.12);
}

.plan-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, rgba(93, 75, 255, 0.18), transparent 60%);
  opacity: 0;
  transition: opacity 0.45s ease;
}

.plan-card:hover::before {
  opacity: 1;
}

.plan-card h3 {
  margin: 0;
}

.plan-card .price {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
}

.plan-card ul {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  color: var(--text-light);
  display: grid;
  gap: 0.35rem;
}

.plan-card ul li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.plan-card .plan-btn {
  width: 100%;
  text-align: center;
  margin-top: auto;
}

.plan-card button {
  margin-top: 0.75rem;
}

.plan-card button.loading {
  opacity: 0.65;
  cursor: progress;
  box-shadow: inset 0 0 0 1px rgba(93, 75, 255, 0.2);
}

.plan-card button.highlight {
  animation: planPulse 1.5s ease-in-out infinite;
}

@keyframes planPulse {
  0% { box-shadow: 0 18px 30px rgba(93, 75, 255, 0.28); }
  50% { box-shadow: 0 28px 45px rgba(93, 75, 255, 0.45); }
  100% { box-shadow: 0 18px 30px rgba(93, 75, 255, 0.28); }
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  background: rgba(93, 75, 255, 0.18);
  border-radius: 999px;
  font-size: 0.85rem;
  color: var(--primary-dark);
  font-weight: 600;
}

.chat-container {
  display: grid;
  gap: 1.75rem;
}

.chat-log {
  background: rgba(255, 255, 255, 0.82);
  border-radius: 1.5rem;
  padding: 1.5rem;
  height: clamp(260px, 45vh, 420px);
  overflow: auto;
  box-shadow: inset 0 0 0 1px rgba(93, 75, 255, 0.1);
}

.chat-form {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.chat-form input {
  flex: 1 1 250px;
}

.ticket-list {
  display: grid;
  gap: 1rem;
}

.ticket-item {
  padding: 1rem 1.25rem;
  border-radius: 1.2rem;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 12px 28px rgba(15, 23, 66, 0.12);
  font-weight: 500;
}

#bg-canvas, canvas.page-bg, .page-overlay, .page-gradient::before { pointer-events:none !important; z-index:0 !important; }
header, nav, main, .plans, .plan-card { position:relative; z-index:1; }

.modal[hidden]{ display:none; }
.modal{ position:fixed; inset:0; background:rgba(0,0,0,.35); display:flex; align-items:center; justify-content:center; z-index:9999; }
.modal-card{ background:#fff; color:#111; border-radius:12px; padding:20px; width:min(420px, 92vw); box-shadow:0 20px 60px rgba(0,0,0,.25); }
.modal-card input{ width:100%; height:44px; font-size:16px; padding:8px 12px; margin:10px 0 6px; }
.modal-card .actions{ display:flex; gap:12px; justify-content:flex-end; }

footer {
  text-align: center;
  color: var(--text-light);
  padding: 2.5rem 0 1.5rem;
  font-size: 0.9rem;
}

.site-footer {
  padding: 3rem 1.5rem 4rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(6, 2, 12, 0.6);
  text-align: left;
}

.site-footer .footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  justify-content: space-between;
  align-items: flex-start;
  color: rgba(245, 242, 255, 0.75);
}

.site-footer .footer-inner > div {
  flex: 1 1 680px;
  min-width: 0;
}

.site-footer .footer-links {
  display: grid;
  gap: 0.5rem;
  font-weight: 600;
  flex: 0 0 220px;
  justify-items: start;
  text-align: left;
}

.site-footer .footer-links a {
  color: rgba(245, 242, 255, 0.85);
}

.site-footer .footer-address {
  color: rgba(245, 242, 255, 0.6);
  font-size: 0.9rem;
  line-height: 1.5;
  max-width: 520px;
}

.site-footer .copyright {
  font-size: 0.85rem;
  color: rgba(245, 242, 255, 0.6);
}

.footer-content {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
}

.footer-address {
  max-width: 720px;
  font-size: 0.8rem;
  opacity: 0.75;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}

.footer-links a {
  color: var(--text-light);
  text-decoration: none;
  opacity: 0.85;
}

.footer-links a:hover,
.footer-links a:focus {
  opacity: 1;
  text-decoration: underline;
}

@media (max-width: 980px) {
  .site-footer .footer-inner {
    flex-direction: column;
    gap: 0.85rem;
  }

  .site-footer {
    padding: 1.25rem 1rem 1.5rem;
    text-align: center;
  }

  .site-footer .footer-address {
    font-size: 0.82rem;
    line-height: 1.4;
  }

  .site-footer .copyright {
    font-size: 0.78rem;
    line-height: 1.35;
  }

  .site-footer .footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    align-items: center;
    text-align: center;
  }
}

@media (min-width: 980px) {
  .site-footer .footer-inner {
    flex-wrap: nowrap;
  }
}

.cookie-banner {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  transform: none;
  background: #0f172a;
  color: #f8fafc;
  border-radius: 12px;
  padding: 0.85rem 1rem;
  width: min(360px, 90vw);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
  z-index: 99999;
  pointer-events: auto;
}

.cookie-banner * {
  pointer-events: auto;
}

.cookie-banner p {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.4;
}

.cookie-banner a {
  color: #9de1ff;
  font-weight: 600;
}

.cookie-banner-actions {
  margin-top: 0.65rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.cookie-banner-actions button {
  border: none;
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-weight: 600;
  font-size: 0.78rem;
  cursor: pointer;
}

.cookie-banner-actions .primary {
  background: #7c5cff;
  color: #fff;
}

.cookie-banner-actions .secondary {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.floating-shape {
  position: absolute;
  border-radius: 50%;
  filter: blur(45px);
  opacity: 0.45;
  pointer-events: none;
  animation: float 18s ease-in-out infinite;
}

.shape-1 {
  width: 340px;
  height: 340px;
  background: rgba(93, 75, 255, 0.26);
  top: 8%;
  left: -120px;
}

.shape-2 {
  width: 260px;
  height: 260px;
  background: rgba(255, 122, 199, 0.25);
  bottom: 12%;
  right: -80px;
  animation-delay: -4s;
}

.shape-3 {
  width: 220px;
  height: 220px;
  background: rgba(255, 188, 87, 0.32);
  top: 55%;
  right: 12%;
  animation-delay: -7s;
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-14px);
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.38;
  }
  50% {
    opacity: 0.55;
  }
}

@keyframes gradientShift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

@media (max-width: 768px) {
  header.navbar .navbar-inner {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
  }

  .hero {
    padding: 2.5rem 2rem;
  }

  .hero-text h1,
  .hero-text h2 {
    font-size: clamp(2.1rem, 6vw, 2.6rem);
  }

  .hero-image img {
    width: min(100%, 260px);
  }

  .chat-form {
    flex-direction: column;
  }

  .chat-form input {
    flex: 1 1 auto;
    width: 100%;
  }
}

@media (max-width: 520px) {
  main {
    padding-top: 4rem;
  }

  body:not(.app-dashboard) main {
    padding-top: 4rem;
  }

  body:not(.app-dashboard) header.navbar {
    padding: 0.4rem 0;
  }

  header.navbar .navbar-inner {
    padding: 0.75rem 1rem;
  }

  body:not(.app-dashboard) header.navbar .navbar-inner {
    gap: 0.55rem;
  }

  body:not(.app-dashboard) header.navbar .brand-logo {
    height: 64px;
  }

  body:not(.app-dashboard) header.navbar .nav-links {
    gap: 0.5rem;
  }

  body:not(.app-dashboard) header.navbar .nav-links a {
    padding: 0.4rem 0.75rem;
    font-size: 0.9rem;
  }

  .section-card,
  .hero {
    border-radius: 1.5rem;
  }
}

.section-card { overflow: visible; }
.chapter-body{
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.75;
  font-size: var(--viewer-font-size-pt, 16px);
  max-width: 100%;
  padding-right: 8px;
  font-family: var(--viewer-font-family, 'Merriweather', Georgia, serif);
  text-align: var(--viewer-text-align, left);
  hyphens: auto;
}
.chapter-body h1,.chapter-body h2,.chapter-body h3{ margin:.6em 0 .4em; line-height:1.25; word-break:break-word; hyphens:auto; }
.chapter-body p{ margin:.75em 0; }
.chapter-body ul,.chapter-body ol{ margin:.75em 0 .85em 1.4em; }
.chapter-body li{ margin:.25em 0; }
.chapter-body pre{
  white-space: pre-wrap;
  word-break: break-word;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 10px;
  padding: 12px 14px;
  margin: .85em 0;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  font-size: .95em;
  max-width: 100%;
  box-sizing: border-box;
}
.chapter-body code{
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  background: rgba(255,255,255,0.06);
  border-radius: 6px;
  padding: 2px 6px;
  word-break: break-word;
}

/* If an old <pre> preview still exists anywhere, kill it */
#chapter-output pre { display:none !important; }
.impersonation-banner{
  position: sticky;
  top: 0;
  z-index: 9999;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  margin: 0 auto 10px;
  width: min(1100px, 94vw);
  border-radius: 12px;
  background: rgba(255, 231, 182, 0.92);
  border: 1px solid rgba(146, 64, 14, 0.25);
  color: #6b2c00;
  box-shadow: 0 10px 30px rgba(0,0,0,0.08);
}
.impersonation-stop-form{ margin: 0; }
.btn.small,
.btn-small{
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 600;
}

/* Wizard + compact topbar upgrades */
.app-dashboard,
.app-dashboard .main-app-wrapper,
.app-dashboard .container {
  overflow-x: clip;
}

.app-dashboard .qb-skip-link {
  position: fixed;
  left: 12px;
  top: 10px;
  transform: translateY(-200%);
  z-index: 3000;
  padding: 10px 14px;
  border-radius: 10px;
  background: #0f1029;
  border: 1px solid rgba(255,255,255,.35);
}

.app-dashboard .qb-skip-link:focus-visible {
  transform: translateY(0);
}

.app-dashboard :where(button,input,select,textarea,a):focus-visible {
  outline: 3px solid #60d8ff;
  outline-offset: 2px;
  scroll-margin-top: 96px;
}

.qb-create-header h2 { margin: 0 0 6px; font-size: clamp(1.3rem,2vw,1.8rem); }
.qb-create-header p { margin: 0 0 14px; opacity: .86; }

.qb-wizard { display: grid; gap: 12px; }
.qb-wizard-tabs { display:flex; gap:8px; flex-wrap:wrap; }
.qb-wizard-tab {
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.08);
  color: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
}
.qb-wizard-tab.is-active,
.qb-wizard-tab[aria-selected="true"] { background: linear-gradient(120deg,#5d4bff,#ff7ac7); }

@media (max-width: 768px) {
  .qb-wizard-tabs {
    flex-wrap: nowrap;
    white-space: nowrap;
    overflow-x: auto;
    gap: 3px;
  }

  .qb-wizard-tab {
    flex: 0 0 auto;
    padding: 3px 6px;
    font-size: 0.64rem;
    line-height: 1.05;
  }

  .wizard-generate-cta {
    flex-wrap: nowrap;
    white-space: nowrap;
    overflow-x: auto;
    gap: 6px;
  }

  .wizard-generate-cta .buy-credits-button,
  .wizard-generate-cta .upgrade-plan-button,
  .wizard-generate-cta .secondary-button,
  .wizard-generate-cta a,
  .wizard-generate-cta button {
    flex: 0 0 auto;
    padding: 1px 5px;
    font-size: 9px;
    line-height: 1.1;
    white-space: nowrap;
  }

  #buyCreditsBtn,
  #upgradePlanBtn {
    font-size: 9px;
    line-height: 1.1;
    padding: 1px 5px;
  }
}

.qb-wizard-panel { padding: 12px; border-radius: 14px; background: rgba(255,255,255,.04); border:1px solid rgba(255,255,255,.12); }
.qb-wizard-actions { display:flex; justify-content:space-between; align-items:center; gap:8px; margin-top: 12px; flex-wrap: wrap; }

.qb-topic-step {
  display: grid;
  gap: 10px;
}

[hidden] { display: none !important; }

#titleSuggestionsWrap {
  margin-top: 4px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.18);
  background: linear-gradient(140deg, rgba(93,75,255,.16), rgba(255,122,199,.12));
  backdrop-filter: blur(8px);
}

#titleSuggestionsWrap h4 {
  margin: 0 0 8px;
  font-size: .95rem;
  color: #fff;
}

#titleSuggestionsList {
  display: grid;
  gap: 10px;
  min-height: 0;
}

.qb-title-row,
.qb-skel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  padding: 12px 14px;
  border-radius: 12px;
}

.qb-title-row {
  width: 100%;
  text-align: left;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.08);
  box-shadow: 0 10px 26px rgba(9, 8, 25, 0.26);
  color: #fff;
  backdrop-filter: blur(8px);
  transition: transform .2s ease, border-color .2s ease, background .2s ease, box-shadow .2s ease;
}

.qb-title-row-left,
.qb-title-row-right {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.qb-title-row-left {
  min-width: 0;
}

.qb-title-row-right {
  margin-left: auto;
  min-width: 160px;
  justify-content: flex-end;
}

.qb-title-row-text {
  font-weight: 700;
  color: #fff;
  line-height: 1.35;
  font-size: .95rem;
  text-wrap: pretty;
}

.qb-title-indicator {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  border: 1px solid rgba(219, 234, 255, 0.45);
  background: rgba(10, 15, 42, 0.55);
  opacity: .8;
  flex: 0 0 auto;
  position: relative;
}

.qb-title-row-locked {
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0;
  font-size: .76rem;
  font-weight: 600;
  white-space: nowrap;
  color: rgba(236, 245, 255, 0.9);
}

.qb-title-row-tick {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 800;
  color: #071032;
  background: #dff1ff;
}

.qb-title-row:hover {
  transform: translateY(-1px);
  border-color: rgba(150, 204, 255, 0.58);
  background: rgba(255,255,255,.12);
}

.qb-title-row.is-selected {
  border-color: rgba(178, 219, 255, 0.9);
  background: linear-gradient(128deg, rgba(28, 112, 255, 0.62), rgba(122, 165, 255, 0.5));
  box-shadow: 0 16px 32px rgba(34, 97, 255, 0.3), 0 0 0 1px rgba(180, 221, 255, 0.28) inset;
}

.qb-title-row.is-selected .qb-title-indicator {
  border-color: rgba(218, 241, 255, .85);
  background: linear-gradient(160deg, rgba(214, 237, 255, .95), rgba(157, 213, 255, .96));
  opacity: 1;
}

.qb-title-row.is-selected .qb-title-row-locked,
.qb-title-row.is-selected .qb-title-row-tick {
  display: inline-flex;
}

.qb-title-row.is-selected .qb-title-indicator::after {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: 2px;
  background: #0b2d7f;
}

.qb-title-row:focus-visible {
  outline: 3px solid rgba(206, 236, 255, 0.95);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(50, 130, 255, 0.4);
}

#titleSuggestionsList.is-ready .qb-title-row {
  animation: qbTitleRowReveal .26s ease both;
}

#titleSuggestionsList.is-ready .qb-title-row:nth-child(2) { animation-delay: .03s; }
#titleSuggestionsList.is-ready .qb-title-row:nth-child(3) { animation-delay: .06s; }
#titleSuggestionsList.is-ready .qb-title-row:nth-child(4) { animation-delay: .09s; }

.qb-skel-row {
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.09);
  box-shadow: 0 10px 26px rgba(9, 8, 25, 0.26);
}

.qb-skel-title,
.qb-skel-pill {
  display: inline-block;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255,255,255,.15), rgba(255,255,255,.3), rgba(255,255,255,.15));
  background-size: 200% 100%;
  animation: qbTitleSkeletonShimmer 1.2s ease-in-out infinite;
}

.qb-skel-title {
  width: 65%;
  max-width: 360px;
  height: 14px;
}

.qb-skel-pill {
  width: 92px;
  height: 28px;
  margin-left: auto;
}

.qb-title-error {
  display: grid;
  gap: 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 136, 176, 0.38);
  background: rgba(86, 21, 45, 0.32);
  padding: 12px;
}

.qb-title-error-text {
  color: #ffd7e4;
  font-size: .9rem;
}

.qb-title-retry {
  width: fit-content;
}

.title-locked-check {
  font-weight: 800;
  color: #dff1ff;
}

@keyframes qbTitleSkeletonShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes qbTitleRowReveal {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .qb-title-row,
  .qb-skel-row,
  .qb-skel-title,
  .qb-skel-pill,
  #titleSuggestionsList.is-ready .qb-title-row {
    animation: none !important;
    transition: none !important;
  }
}


.title-suggestions-helper {
  margin-top: 0;
  color: rgba(222, 241, 255, 0.86);
  font-size: .8rem;
}

.title-suggestions-helper.is-error {
  color: #ffd7e4;
}

.qb-inline-link {
  width: auto !important;
  display: inline-flex;
  align-self: flex-start;
  margin: 2px 0 0;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  color: rgba(191, 231, 255, 0.82);
  font-size: 12px;
  line-height: 1.1;
  text-decoration: none;
  cursor: pointer;
  box-shadow: none !important;
}

.qb-inline-link:hover,
.qb-inline-link:focus-visible {
  color: #ffffff;
  text-decoration: underline;
}

#manualTitleWrap {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 10px;
  align-items: center;
  margin-top: 4px;
}

#manualTitleWrap #lockManualTitleBtn {
  width: auto;
  min-width: 120px;
}

.title-status {
  margin-top: 6px;
  min-height: 1.25em;
  font-size: .92rem;
  color: rgba(255,255,255,.86);
}

.title-status.is-confirmed {
  color: #a9ffe1;
  font-weight: 700;
}

.qb-compact-quotas { display:flex; flex-wrap: wrap; align-items: center; gap:8px; max-width: 100%; }
.qb-compact-quotas-main { display:flex; flex-wrap: wrap; align-items:center; gap:8px; flex: 1 1 auto; min-width: 0; }
.qb-plan-primary {
  row-gap: 6px;
}
.qb-plan-primary .pdf-quota-button,
.qb-plan-primary .app-plan-name,
.qb-quotas-more > summary {
  min-height: 32px;
  box-sizing: border-box;
}
.qb-plan-primary .pdf-quota-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
}
.qb-plan-primary .pdf-quota-label,
.qb-plan-primary .pdf-quota-value,
.qb-plan-primary .pdf-quota-button small {
  font-size: 12px;
  line-height: 1.15;
}
.qb-compact-quotas-main .qb-extra-credit-inline { margin-right: 0; }
.qb-quotas-more { position: relative; flex: 0 0 auto; }
.qb-quotas-more > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.08);
  font-size: 12px;
  font-weight: 600;
}
.qb-quotas-more[open] > .app-topbar-credits {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 30;
  width: min(84vw, 420px);
  padding: 10px;
  border-radius: 14px;
  background: linear-gradient(150deg, rgba(35, 28, 73, 0.96), rgba(19, 14, 44, 0.96));
  border:1px solid rgba(255,255,255,.18);
  box-shadow: 0 16px 34px rgba(4, 3, 18, 0.5);
  backdrop-filter: blur(10px);
}
.qb-quotas-more[open] .app-credits-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.qb-quotas-more[open] .app-credits-list .pdf-quota-button {
  width: 100%;
  min-height: 32px;
  padding: 5px 10px;
  justify-content: space-between;
}
.qb-quotas-more[open] .pdf-quota-label,
.qb-quotas-more[open] .pdf-quota-value,
.qb-quotas-more[open] .pdf-quota-button small {
  font-size: 12px;
}

#genreList { display:flex; flex-wrap:wrap; gap:8px; }
.qb-chip { position: relative; display:inline-flex; }
.qb-chip input[type="checkbox"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.qb-chip-label {
  display:inline-flex;
  padding: 8px 12px;
  border-radius: 999px;
  border:1px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.08);
  font-size: .85rem;
}
.qb-chip input[type="checkbox"]:checked + .qb-chip-label {
  background: linear-gradient(120deg,#5d4bff,#ff7ac7);
  border-color: transparent;
}


.qb-generate-primary {
  background: linear-gradient(120deg,#00ffa3,#3d74ff,#b655ff) !important;
  box-shadow: 0 14px 34px rgba(0,255,163,.35),0 10px 24px rgba(61,116,255,.35) !important;
}

@media (max-width: 767px) {
  .qb-compact-quotas {
    align-items: flex-start;
  }
  .qb-compact-quotas-main {
    flex-basis: 100%;
  }
  .qb-plan-primary {
    gap: 6px;
  }
  .qb-plan-primary .app-plan-label,
  .qb-plan-primary .app-plan-name {
    order: -2;
  }
  .qb-quotas-more {
    margin-left: auto;
  }
  .qb-quotas-more[open] > .app-topbar-credits {
    position: static;
    width: 100%;
  }
  .qb-quotas-more[open] .app-credits-list {
    grid-template-columns: 1fr;
  }
  .app-dashboard .container { padding-inline: 12px; }
}

@media (max-width: 640px) {
  #genreList {
    gap: 4px;
  }

  .qb-chip-label {
    padding: 4px 7px;
    font-size: 0.62rem;
    line-height: 1;
    border-radius: 999px;
  }

  body.app-dashboard.page-app .app-topbar {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 8px;
    padding: 6px 10px;
    margin-bottom: 8px;
  }

  body.app-dashboard.page-app .app-topbar-left {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 0;
    flex: 1 1 100%;
    overflow: visible;
  }

  body.app-dashboard.page-app .app-topbar-logo {
    height: 40px;
    flex: 0 0 auto;
  }

  body.app-dashboard.page-app .qb-compact-quotas,
  body.app-dashboard.page-app .qb-compact-quotas-main {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    white-space: nowrap;
    gap: 4px;
  }

  body.app-dashboard.page-app .qb-compact-quotas {
    width: 100%;
    min-width: 0;
    flex: 1 1 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  body.app-dashboard.page-app .qb-compact-quotas::-webkit-scrollbar {
    display: none;
  }

  body.app-dashboard.page-app .qb-compact-quotas-main {
    min-width: max-content;
    flex: 0 0 auto;
  }

  body.app-dashboard.page-app .qb-plan-primary {
    row-gap: 0;
  }

  body.app-dashboard.page-app .qb-plan-primary .app-plan-label,
  body.app-dashboard.page-app .qb-plan-primary .app-plan-name,
  body.app-dashboard.page-app .qb-plan-primary .pdf-quota-label,
  body.app-dashboard.page-app .qb-plan-primary .pdf-quota-value,
  body.app-dashboard.page-app .qb-plan-primary .pdf-quota-button small,
  body.app-dashboard.page-app .qb-quotas-more > summary {
    font-size: 10px;
    line-height: 1.1;
    white-space: nowrap;
  }

  body.app-dashboard.page-app .qb-plan-primary .app-plan-name,
  body.app-dashboard.page-app .qb-plan-primary .pdf-quota-button,
  body.app-dashboard.page-app .qb-quotas-more > summary {
    min-height: 24px;
  }

  body.app-dashboard.page-app .qb-plan-primary .app-plan-name {
    padding: 3px 8px;
  }

  body.app-dashboard.page-app .qb-plan-primary .pdf-quota-button,
  body.app-dashboard.page-app .qb-quotas-more > summary {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
  }

  body.app-dashboard.page-app .qb-quotas-more {
    flex: 0 0 auto;
    margin-left: 0;
  }

  body.app-dashboard.page-app .qb-quotas-more[open] > .app-topbar-credits {
    right: 0;
  }

  body.app-dashboard.page-app .app-topbar-right {
    flex: 0 0 auto;
    gap: 6px;
    min-width: 0;
    margin-left: auto;
  }

  body.app-dashboard.page-app .app-topbar-username {
    max-width: 72px;
    font-size: 10px;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  body.app-dashboard.page-app .account-pill {
    min-height: 24px;
    padding: 4px 8px;
    font-size: 10px;
    line-height: 1;
  }
}

/* Mobile stability guardrails for the app dashboard.
   Fixed overlays + heavy blur effects can jitter on mobile GPU compositors. */
@media (max-width: 768px), (pointer: coarse) {
  body.app-dashboard.page-app::after,
  body.app-dashboard.page-app canvas#bgCanvas {
    display: none !important;
  }

  body.app-dashboard.page-app .container {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  body.app-dashboard.page-app .app-topbar,
  body.app-dashboard.page-app .qb-preview-scale,
  body.app-dashboard.page-app #viewer,
  body.app-dashboard.page-app .chapter-card,
  body.app-dashboard.page-app .book-title-page,
  body.app-dashboard.page-app .toc-page,
  body.app-dashboard.page-app .book-cover-page {
    transform: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-dashboard * { animation: none !important; transition: none !important; }
  .app-dashboard canvas#bgCanvas { display: none !important; }
}

.qb-gen-status {
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(93, 75, 255, 0.2);
  background: rgba(255, 255, 255, 0.62);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 24px rgba(68, 53, 130, 0.12);
}

.qb-gen-status-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.qb-gen-status-text {
  font-size: 0.88rem;
  font-weight: 600;
  color: #1d2350;
}

.qb-gen-status-meta {
  font-size: 0.76rem;
  color: rgba(29, 35, 80, 0.7);
  text-align: right;
}

.qb-gen-progress {
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(93, 75, 255, 0.14);
}

.qb-gen-progress-bar {
  height: 100%;
  border-radius: 999px;
  width: 0;
  background: linear-gradient(90deg, #5d4bff 0%, #ff7ac7 100%);
  transition: width .25s ease;
}

.qb-toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 9999;
}

.qb-toast-card {
  width: min(420px, 92vw);
  border-radius: 16px;
  padding: 12px;
  border: 1px solid rgba(93, 75, 255, 0.22);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(12px);
  box-shadow: 0 20px 36px rgba(37, 24, 89, 0.24);
}

.qb-toast-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(13, 23, 64, 0.72);
}

.qb-toast-text {
  margin-top: 4px;
  color: #0f1842;
  font-weight: 600;
}

.qb-toast-inputrow {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
}

.qb-toast-inputrow label {
  font-size: 0.8rem;
  color: rgba(13, 23, 64, 0.78);
}

.qb-toast-inputrow input {
  width: 86px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid rgba(93, 75, 255, 0.26);
  font: inherit;
}

.qb-toast-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 10px;
}

.qb-toast-actions button {
  border: 0;
  border-radius: 10px;
  padding: 7px 12px;
  font-weight: 600;
  cursor: pointer;
}

.qb-btn-primary {
  background: linear-gradient(135deg, #5d4bff, #7a63ff);
  color: #fff;
}

.qb-btn-ghost {
  background: rgba(93, 75, 255, 0.1);
  color: #2a2f5e;
}

@media (prefers-reduced-motion: reduce) {
  .qb-gen-progress-bar,
  .qb-toast,
  .qb-toast-card,
  .qb-btn-primary,
  .qb-btn-ghost {
    transition: none !important;
  }
}

body.app-dashboard.page-app #ebookForm .qb-notify-short {
  display: none;
}

body.app-dashboard.page-app #ebookForm .qb-notify-long {
  display: inline;
}

body.app-dashboard.page-app #ebookForm .qb-notify-label {
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal;
}

body.app-dashboard.page-app #ebookForm .qb-notify-row {
  display: inline-flex;
  align-items: center;
  gap: 0.25em;
  min-width: 0;
  flex-shrink: 0;
}

body.app-dashboard.page-app #ebookForm .qb-notify-row #notifyEmailWhenReady {
  margin: 0;
}

body.app-dashboard.page-app #ebookForm .gen-buttons {
  width: auto;
  max-width: 100%;
  padding: 8px 14px;
}

body.app-dashboard.page-app #ebookForm .qb-gen-options-row,
body.app-dashboard.page-app #ebookForm .qb-gen-actions-row {
  width: auto;
  max-width: 100%;
}

body.app-dashboard.page-app #ebookForm .qb-chimg-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

body.app-dashboard.page-app #ebookForm .qb-chimg-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

body.app-dashboard.page-app #ebookForm .qb-chimg-toggle-text {
  white-space: nowrap;
}

body.app-dashboard.page-app #ebookForm .qb-chimg-count {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

body.app-dashboard.page-app #ebookForm .qb-chimg-count-label {
  white-space: nowrap;
}

@media (max-width: 600px) {

  /* Ensure the options row is stable and never overlaps */
  body.app-dashboard.page-app #ebookForm .qb-gen-options-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;               /* gap between groups is OK */
    width: 100%;
    max-width: 100%;
  }

  body.app-dashboard.page-app #ebookForm .qb-images-opt {
    flex: 1 1 auto;
    min-width: 0;
  }

  /* IMPORTANT: no wrap => prevents # input sitting on top of "Chapter Images" */
  body.app-dashboard.page-app #ebookForm .qb-chimg-row {
    display: flex;
    align-items: center;
    flex-wrap: nowrap !important;
    gap: 8px; /* gap between "Chapter Images" group and #count is OK */
    width: 100%;
    min-width: 0;
  }

  /* STRICT: no gap between checkbox and text */
  body.app-dashboard.page-app #ebookForm .qb-chimg-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0 !important;
    min-width: 0;
  }

  body.app-dashboard.page-app #ebookForm .qb-chimg-toggle input {
    margin: 0 !important;
  }

  body.app-dashboard.page-app #ebookForm .qb-chimg-toggle-text {
    margin-left: 0 !important;
    padding-left: 0 !important;
    white-space: nowrap;
  }

  /* Keep # and count compact, never expanding across the row */
  body.app-dashboard.page-app #ebookForm .qb-chimg-count {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto !important;
    justify-content: flex-end;
    margin-left: auto;  /* pushes it right without overlapping */
  }

  body.app-dashboard.page-app #ebookForm #autoChapterImagesCount {
    width: 62px;
    max-width: 62px;
    padding: 6px 8px;
    font-size: 14px;
  }

  /* Notify: STRICT no gap checkbox + text */
  body.app-dashboard.page-app #ebookForm .qb-notify-row {
    display: inline-flex;
    align-items: center;
    gap: 0 !important;
    flex: 0 0 auto;
    justify-content: flex-end;
    padding-right: 0 !important;
    white-space: nowrap !important;
  }

  body.app-dashboard.page-app #ebookForm .qb-notify-row input {
    margin: 0 !important;
  }

  body.app-dashboard.page-app #ebookForm .qb-notify-short,
  body.app-dashboard.page-app #ebookForm .qb-notify-long {
    margin-left: 0 !important;
    padding-left: 0 !important;
  }

  body.app-dashboard.page-app #ebookForm .qb-chimg-count-label {
    font-size: 12px;
    line-height: 1.2;
    white-space: nowrap !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
  }

  body.app-dashboard.page-app #ebookForm .qb-notify-long {
    display: none;
  }

  body.app-dashboard.page-app #ebookForm .qb-notify-short {
    display: inline;
  }

  body.app-dashboard.page-app #ebookForm .qb-notify-label {
    white-space: nowrap !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
    font-size: 14px;
    line-height: 1.2;
    max-width: 100%;
  }

  body.app-dashboard.page-app #ebookForm .qb-chimg-row::before,
  body.app-dashboard.page-app #ebookForm .qb-chimg-row::after,
  body.app-dashboard.page-app #ebookForm .qb-chimg-toggle::before,
  body.app-dashboard.page-app #ebookForm .qb-chimg-toggle::after,
  body.app-dashboard.page-app #ebookForm .qb-chimg-count::before,
  body.app-dashboard.page-app #ebookForm .qb-chimg-count::after {
    content: none !important;
  }

  body.app-dashboard.page-app #ebookForm .gen-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
  }

  body.app-dashboard.page-app #ebookForm #generateImagesBtn,
  body.app-dashboard.page-app #ebookForm #retryMissingImagesBtn,
  body.app-dashboard.page-app #ebookForm #generateBtn,
  body.app-dashboard.page-app #ebookForm #stopBtn {
    font-size: 14px;
    padding: 10px 14px;
    min-height: auto;
    flex: 1 1 150px;
  }

  body.app-dashboard.page-app #ebookForm #stopBtn {
    flex-basis: 100%;
  }
}

@media (max-width: 480px) {
  body.app-dashboard.page-app #ebookForm #generateImagesBtn,
  body.app-dashboard.page-app #ebookForm #retryMissingImagesBtn,
  body.app-dashboard.page-app #ebookForm #generateBtn,
  body.app-dashboard.page-app #ebookForm #stopBtn {
    font-size: 13px;
    padding: 8px 12px;
  }
}

/* Mobile tight spacing fixes (Generate options row) */
@media (max-width: 600px) {
  body.app-dashboard.page-app #ebookForm .qb-gen-options-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0 !important;
    column-gap: 0 !important;
    row-gap: 0 !important;
    flex-wrap: nowrap;
  }

  body.app-dashboard.page-app #ebookForm .qb-chimg-row {
    gap: 0 !important;
    flex-wrap: nowrap;
  }

  body.app-dashboard.page-app #ebookForm .qb-chimg-toggle,
  body.app-dashboard.page-app #ebookForm .qb-notify-row,
  body.app-dashboard.page-app #ebookForm .qb-chimg-count {
    gap: 0 !important;
  }

  body.app-dashboard.page-app #ebookForm .qb-chimg-toggle input,
  body.app-dashboard.page-app #ebookForm .qb-notify-row input {
    margin: 0 !important;
  }

  body.app-dashboard.page-app #ebookForm .qb-chimg-toggle-text,
  body.app-dashboard.page-app #ebookForm .qb-notify-short,
  body.app-dashboard.page-app #ebookForm .qb-notify-long,
  body.app-dashboard.page-app #ebookForm .qb-chimg-count-label {
    margin-left: 0 !important;
    padding-left: 0 !important;
  }

  /* Keep the count compact so it never overlaps other controls */
  body.app-dashboard.page-app #ebookForm .qb-chimg-count {
    flex: 0 0 auto !important;
    justify-content: flex-end;
  }

  body.app-dashboard.page-app #ebookForm #autoChapterImagesCount {
    width: 64px;
    max-width: 64px;
    padding: 6px 8px;
    font-size: 14px;
  }

  /* Ensure Notify is always a single short label on mobile */
  body.app-dashboard.page-app #ebookForm .qb-notify-label {
    max-width: none;
    font-size: 14px;
    line-height: 1;
  }

  /* Number of chapters input: avoid weird zoom + improve tapping */
  body.app-dashboard.page-app #ebookForm #chapterCount {
    font-size: 16px; /* prevents iOS zoom and improves editing */
  }
}

/* Mobile: Make the options row layout overlap-proof */
@media (max-width: 600px) {

  /* 3 columns: [ChapterImages] [#count] [Notify] */
  body.app-dashboard.page-app #ebookForm .qb-chimg-row {
    display: grid !important;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    column-gap: 10px; /* gap between groups (OK) */
    width: 100%;
    min-width: 0;
  }

  /* STRICT: no gap between checkbox and text */
  body.app-dashboard.page-app #ebookForm .qb-toggle {
    display: inline-flex !important;
    align-items: center !important;
    gap: 0 !important;
    min-width: 0;
    white-space: nowrap;
  }

  body.app-dashboard.page-app #ebookForm .qb-toggle-input {
    margin: 0 !important;
  }

  body.app-dashboard.page-app #ebookForm .qb-toggle-text {
    margin-left: 0 !important;
    padding-left: 0 !important;
    line-height: 1 !important;
  }

  /* Keep #count compact so it never steals label space */
  body.app-dashboard.page-app #ebookForm .qb-chimg-count {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    justify-content: flex-end;
  }

  body.app-dashboard.page-app #ebookForm #autoChapterImagesCount {
    width: 62px;
    max-width: 62px;
    padding: 6px 8px;
    font-size: 14px;
  }

  /* Keep Notify label single-line */
  body.app-dashboard.page-app #ebookForm .qb-notify-label {
    white-space: nowrap !important;
  }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {

  /* Remove native checkbox rendering issues on iOS Safari */
  body.app-dashboard.page-app #ebookForm .qb-toggle-input[type="checkbox"] {
    -webkit-appearance: none !important;
    appearance: none !important;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    border: 2px solid rgba(255,255,255,0.6);
    background: rgba(0,0,0,0.15);
    display: inline-grid;
    place-content: center;
    margin: 0 !important;
    padding: 0 !important;
    flex: 0 0 auto;
    vertical-align: middle;
  }

  body.app-dashboard.page-app #ebookForm .qb-toggle-input[type="checkbox"]:checked {
    background: rgba(60, 130, 255, 0.95);
    border-color: rgba(60, 130, 255, 1);
  }

  /* checkmark */
  body.app-dashboard.page-app #ebookForm .qb-toggle-input[type="checkbox"]:checked::after {
    content: "✓";
    font-size: 14px;
    line-height: 1;
    font-weight: 800;
    color: white;
    transform: translateY(-1px);
  }
}
