/* =============================================
   BÁN CÓ LỜI TRÊN APPFOOD — EBOOK READER
   Color System matched to Book Cover:
   - Primary Green: #00B14F (Xanh lá tươi — GrabFood / bìa sách)
   - Orange:        #F58220 (Cam ấm — ShopeeFood / bìa sách)
   - Cyan:          #06B6D4 (Xanh lơ — Xanh SM Ngon / AI bot)
   - Yellow:        #F59E0B (Vàng — BeFood accent)
   - Base:          Clean white / xanh mint nhạt
   ============================================= */

:root {
  /* === Book Cover Brand Colors === */
  --shopee: #F58220;
  --shopee-light: #FF9635;
  --shopee-dark: #D96D10;
  --grab: #00B14F;
  --grab-light: #00CC5C;
  --grab-dark: #008C3E;
  --be: #F59E0B;
  --be-light: #FBBF24;
  --be-dark: #D97706;
  --xanhsm: #06B6D4;
  --xanhsm-light: #22D3EE;
  --xanhsm-dark: #0891B2;
  --fresh: #00B14F;

  /* === Clean / Fresh Theme (matched to book cover white bg) === */
  --bg-base: #F8FBF9;
  /* Nền chính: trắng xanh mint nhẹ */
  --bg-surface: #FFFFFF;
  /* Nền card trắng */
  --bg-card: #F0FAF4;
  /* Nền card xanh mint nhạt */
  --bg-card-hover: #E5F5EC;
  --bg-sidebar: #FFFFFF;
  /* Sidebar trắng sạch */
  --bg-chat: #F5FAF7;
  /* Chat nền xanh mint */

  /* === Text (tối trên nền sáng) === */
  --text-primary: #1A2B23;
  /* Xanh đen, dễ đọc */
  --text-secondary: #2D4A3A;
  /* Xanh đậm */
  --text-muted: #7A9A8A;
  /* Xanh nhạt */
  --text-accent: #00B14F;

  /* === Gradient System === */
  --grad-hero: linear-gradient(135deg, #00B14F 0%, #F58220 50%, #06B6D4 100%);
  --grad-shopee: linear-gradient(135deg, #F58220, #FF9635);
  --grad-grab: linear-gradient(135deg, #00B14F, #00CC5C);
  --grad-be: linear-gradient(135deg, #F59E0B, #FBBF24);
  --grad-fresh: linear-gradient(135deg, #00B14F, #06B6D4);
  --grad-card: linear-gradient(135deg, rgba(0, 177, 79, 0.06), rgba(6, 182, 212, 0.06));

  /* === Borders === */
  --border: rgba(0, 177, 79, 0.15);
  --border-hover: rgba(0, 177, 79, 0.4);

  /* === Shadows === */
  --shadow-sm: 0 2px 8px rgba(0, 100, 50, 0.08);
  --shadow-md: 0 8px 32px rgba(0, 100, 50, 0.12);
  --shadow-glow: 0 0 30px rgba(0, 177, 79, 0.2);

  /* === Sizing === */
  --sidebar-w: 280px;
  --chat-w: 340px;
  --header-h: 58px;
  --radius: 12px;
  --radius-lg: 20px;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow: hidden;
  line-height: 1.7;
}

/* ===== TOP HEADER ===== */
.top-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  background: rgba(248, 251, 249, 0.96);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
  gap: 12px;
  box-shadow: 0 1px 12px rgba(0, 100, 50, 0.06);
}

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

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

.sidebar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 6px;
  border-radius: 8px;
  transition: background 0.2s;
}

.sidebar-toggle:hover {
  background: rgba(0, 177, 79, 0.08);
}

.sidebar-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-secondary);
  border-radius: 2px;
  transition: all 0.3s;
}

.book-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.app-dots {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 6px currentColor;
}

.dot.shopee {
  background: var(--shopee);
  color: var(--shopee);
}

.dot.grab {
  background: var(--grab);
  color: var(--grab);
}

.dot.be {
  background: var(--be);
  color: var(--be);
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-author {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.update-badge {
  font-size: 11px;
  font-weight: 600;
  background: rgba(0, 177, 79, 0.15);
  color: var(--grab);
  border: 1px solid rgba(0, 177, 79, 0.3);
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

.chat-toggle-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--grad-hero);
  color: #fff;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 20px;
  transition: opacity 0.2s, transform 0.2s;
  white-space: nowrap;
}

.chat-toggle-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

/* Header Action Buttons (Refresh + Logout) */
.header-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.header-action-btn:hover {
  border-color: var(--grab);
  color: var(--grab);
  background: rgba(0, 177, 79, 0.08);
  transform: translateY(-1px);
}

.refresh-btn:hover {
  border-color: var(--xanhsm);
  color: var(--xanhsm);
  background: rgba(6, 182, 212, 0.08);
}

.logout-btn:hover {
  border-color: #EF4444;
  color: #EF4444;
  background: rgba(239, 68, 68, 0.06);
}

/* ===== LAYOUT GRID ===== */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr 0px;
  grid-template-rows: calc(100vh - var(--header-h));
  height: calc(100vh - var(--header-h));
  margin-top: var(--header-h);
  transition: grid-template-columns 0.3s ease;
  overflow: hidden;
}

.layout.chat-open {
  grid-template-columns: var(--sidebar-w) 1fr var(--chat-w);
}

.layout.sidebar-closed {
  grid-template-columns: 0px 1fr 0px;
}

.layout.sidebar-closed.chat-open {
  grid-template-columns: 0px 1fr var(--chat-w);
}

/* ===== LEFT SIDEBAR ===== */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  transition: none;
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(0, 177, 79, 0.2);
  border-radius: 2px;
}

.sidebar-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-sidebar);
  z-index: 1;
}

.sidebar-header h2 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
}

.sidebar-header p {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Search Box */
.search-box {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 60px;
  background: var(--bg-sidebar);
  z-index: 1;
}

.search-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1.5px solid rgba(0, 177, 79, 0.18);
  border-radius: 8px;
  padding: 7px 10px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input-row:focus-within {
  border-color: #00B14F;
  box-shadow: 0 0 0 3px rgba(0, 177, 79, 0.08);
}

.search-icon {
  flex-shrink: 0;
  color: #00B14F;
  opacity: 0.5;
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 12.5px;
  color: var(--text-primary);
  background: transparent;
  font-family: inherit;
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-clear {
  background: none;
  border: none;
  font-size: 12px;
  color: var(--text-accent);
  cursor: pointer;
  padding: 0 2px;
  opacity: 0.5;
}

.search-clear:hover {
  opacity: 1;
}

.search-results {
  margin-top: 8px;
  max-height: 280px;
  overflow-y: auto;
  border-radius: 8px;
  background: #fff;
  border: 1px solid rgba(0, 177, 79, 0.15);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.search-result-item {
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid rgba(0, 177, 79, 0.08);
  transition: background 0.15s;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background: rgba(0, 177, 79, 0.05);
}

.search-result-chapter {
  font-size: 10px;
  font-weight: 700;
  color: #00B14F;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 3px;
}

.search-result-text {
  font-size: 12px;
  color: var(--text-primary);
  line-height: 1.45;
}

.search-result-text mark {
  background: rgba(0, 177, 79, 0.15);
  color: #008C3E;
  font-weight: 700;
  border-radius: 2px;
  padding: 0 2px;
}

.search-no-results {
  padding: 16px 12px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

/* Suggested follow-up questions in chat */
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.chat-suggest-btn {
  font-size: 11px;
  padding: 6px 12px;
  background: linear-gradient(135deg, #F0FAF4, #E5F5EC);
  border: 1px solid rgba(0, 177, 79, 0.2);
  border-radius: 16px;
  color: #008C3E;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
  font-family: inherit;
  text-align: left;
  line-height: 1.35;
}

.chat-suggest-btn:hover {
  background: linear-gradient(135deg, #E5F5EC, #D1F0DC);
  border-color: rgba(0, 177, 79, 0.4);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 177, 79, 0.12);
}

/* Chat bubble tables */
.chat-table-wrap {
  overflow-x: auto;
  margin: 8px -4px;
  padding: 0 4px;
}

.chat-table {
  width: 100%;
  min-width: 200px;
  border-collapse: separate;
  border-spacing: 0;
  margin: 4px 0;
  font-size: 11px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(180, 120, 70, 0.2);
  table-layout: fixed;
  word-wrap: break-word;
}

.chat-table th {
  background: linear-gradient(135deg, #3D2B1F, #5C4033);
  padding: 8px 10px;
  color: #FFF5EE;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: left;
  border-bottom: 2px solid #EE4D2D;
}

.chat-table td {
  padding: 7px 10px;
  color: #3D2B1F;
  border-bottom: 1px solid rgba(180, 130, 100, 0.1);
  font-weight: 500;
}

.chat-table tr:nth-child(even) td {
  background: rgba(255, 245, 238, 0.5);
}

.chat-table tr:last-child td {
  border-bottom: none;
}

/* Chat bubble lists */
.chat-list {
  margin: 8px 0;
  padding-left: 16px;
  list-style: none;
}

.chat-list li {
  position: relative;
  padding: 3px 0 3px 12px;
  font-size: 12.5px;
  line-height: 1.5;
}

.chat-list li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: #EE4D2D;
  font-weight: 700;
}

/* Chat headings */
.chat-h2 {
  font-size: 13.5px;
  font-weight: 800;
  color: #3D2B1F;
  margin: 10px 0 4px;
  border-bottom: 1px solid rgba(180, 130, 100, 0.15);
  padding-bottom: 3px;
}

.chat-h3 {
  font-size: 12.5px;
  font-weight: 700;
  color: #5C4033;
  margin: 8px 0 3px;
}

.msg-bubble code {
  background: rgba(238, 77, 45, 0.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11px;
  font-family: monospace;
  color: #C03E1D;
}

.toc-nav {
  padding: 8px 0 20px;
}

.toc-loading {
  padding: 20px 16px;
  color: var(--text-muted);
  font-size: 13px;
}

/* TOC Sections */
.toc-section {
  margin-bottom: 4px;
}

.toc-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  transition: color 0.2s;
  user-select: none;
}

.toc-section-header:hover {
  color: var(--text-secondary);
}

.section-icon {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.section-icon.s1 {
  background: var(--shopee);
}

.section-icon.s2 {
  background: var(--be);
}

.section-icon.s3 {
  background: #F59E0B;
}

.section-icon.s4 {
  background: var(--grab);
}

.section-icon.s5 {
  background: #8B5CF6;
}

.section-icon.s6 {
  background: #EC4899;
}

.section-icon.s7 {
  background: var(--shopee-light);
}

.section-icon.s8 {
  background: var(--grab-light);
}

.toc-items {
  display: flex;
  flex-direction: column;
}

.toc-item {
  display: block;
  width: 100%;
  padding: 7px 16px 7px 32px;
  font-size: 12.5px;
  color: var(--text-secondary);
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.4;
  transition: all 0.15s;
  border-left: 2px solid transparent;
}

.toc-item:hover {
  background: rgba(0, 177, 79, 0.06);
  color: var(--text-primary);
  border-left-color: rgba(0, 177, 79, 0.4);
}

.toc-item.active {
  background: rgba(0, 177, 79, 0.08);
  color: var(--grab-light);
  border-left-color: var(--grab);
  font-weight: 600;
}

/* Special TOC items */
.toc-item.toc-intro {
  color: var(--grab);
}

.toc-item.toc-intro.active {
  color: var(--grab-light);
  background: rgba(0, 177, 79, 0.08);
  border-left-color: var(--grab);
}

/* ===== MAIN CONTENT AREA ===== */
.content-area {
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  background: var(--bg-base);
}

.content-area::-webkit-scrollbar {
  width: 6px;
}

.content-area::-webkit-scrollbar-track {
  background: transparent;
}

.content-area::-webkit-scrollbar-thumb {
  background: rgba(0, 177, 79, 0.2);
  border-radius: 3px;
}

/* ===== WELCOME SCREEN ===== */
.welcome-screen {
  min-height: calc(100vh - var(--header-h));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  position: relative;
  overflow: hidden;
}

.welcome-inner {
  text-align: center;
  max-width: 560px;
  position: relative;
  z-index: 1;
}

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

.pill {
  font-size: 12px;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: 20px;
  letter-spacing: 0.3px;
}

.pill.shopee {
  background: rgba(238, 77, 45, 0.15);
  color: var(--shopee-light);
  border: 1px solid rgba(238, 77, 45, 0.3);
}

.pill.grab {
  background: rgba(0, 177, 79, 0.15);
  color: var(--grab-light);
  border: 1px solid rgba(0, 177, 79, 0.3);
}

.pill.be {
  background: rgba(26, 79, 160, 0.2);
  color: #60A5FA;
  border: 1px solid rgba(37, 99, 235, 0.4);
}

.welcome-title {
  font-size: clamp(36px, 6vw, 60px);
  font-weight: 900;
  line-height: 1.1;
  background: var(--grad-hero);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 16px;
  letter-spacing: -1px;
}

.welcome-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 32px;
}

.welcome-subtitle strong {
  color: var(--grab-light);
}

.welcome-author {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  margin-bottom: 32px;
}

.author-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--grad-hero);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 0 20px rgba(238, 77, 45, 0.3);
}

.author-info {
  text-align: left;
}

.author-info strong {
  display: block;
  font-size: 14px;
  color: var(--text-primary);
}

.author-info span {
  font-size: 12px;
  color: var(--text-muted);
}

.welcome-stats {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 36px;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.stat {
  text-align: center;
}

.stat-num {
  display: block;
  font-size: 28px;
  font-weight: 900;
  background: var(--grad-hero);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.start-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--grad-hero);
  color: #fff;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  padding: 16px 36px;
  border-radius: 50px;
  transition: all 0.25s;
  box-shadow: var(--shadow-glow);
  letter-spacing: 0.3px;
}

.start-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 40px rgba(238, 77, 45, 0.35);
}

.start-btn:active {
  transform: translateY(0);
}

/* Animated background blobs */
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.08;
  animation: float 8s ease-in-out infinite;
}

.blob-1 {
  width: 400px;
  height: 400px;
  background: var(--shopee);
  top: -100px;
  right: -100px;
  animation-delay: 0s;
}

.blob-2 {
  width: 300px;
  height: 300px;
  background: var(--grab);
  bottom: -80px;
  left: -80px;
  animation-delay: 2.5s;
}

.blob-3 {
  width: 250px;
  height: 250px;
  background: var(--be);
  top: 50%;
  left: 50%;
  animation-delay: 5s;
}

@keyframes float {

  0%,
  100% {
    transform: translateY(0) scale(1);
  }

  50% {
    transform: translateY(-20px) scale(1.05);
  }
}

/* ===== BOOK CONTENT ===== */
.book-content {
  max-width: 780px;
  margin: 0 auto;
  padding: 40px 40px 80px;
}

.book-content.hidden {
  display: none;
}

.content-header {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.breadcrumb span {
  color: var(--text-muted);
}

.breadcrumb strong {
  color: var(--shopee-light);
}

.chapter-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 8px;
}

/* ===== MARKDOWN BODY STYLES ===== */
.markdown-body h1 {
  font-size: 32px;
  font-weight: 900;
  line-height: 1.2;
  margin-bottom: 16px;
  letter-spacing: -0.5px;
  background: var(--grad-hero);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.markdown-body h2 {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  margin: 36px 0 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid rgba(238, 77, 45, 0.3);
  line-height: 1.3;
}

.markdown-body h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--shopee-light);
  margin: 24px 0 10px;
}

.markdown-body h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--grab-light);
  margin: 18px 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.markdown-body p {
  font-size: 15.5px;
  color: var(--text-secondary);
  line-height: 1.85;
  margin-bottom: 16px;
}

.markdown-body strong {
  color: var(--text-primary);
  font-weight: 700;
}

.markdown-body em {
  color: var(--grab-light);
  font-style: normal;
  font-weight: 500;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 20px;
  margin-bottom: 16px;
}

.markdown-body li {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.8;
  margin-bottom: 6px;
}

.markdown-body li::marker {
  color: var(--shopee);
}

/* Tables — Premium & prominent */
.markdown-body table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 28px 0;
  font-size: 13.5px;
  border-radius: 12px;
  overflow: hidden;
  border: 1.5px solid rgba(180, 120, 70, 0.25);
  box-shadow: 0 4px 20px rgba(150, 80, 50, 0.06), 0 1px 4px rgba(0, 0, 0, 0.04);
  background: #fff;
}

.markdown-body thead {
  position: relative;
}

.markdown-body th {
  background: linear-gradient(135deg, #3D2B1F 0%, #5C4033 100%);
  padding: 13px 18px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #FFF5EE;
  border-bottom: 2px solid #EE4D2D;
}

.markdown-body th:first-child {
  border-left: 3px solid #EE4D2D;
}

.markdown-body td {
  padding: 12px 18px;
  color: #3D2B1F;
  border-bottom: 1px solid rgba(180, 130, 100, 0.12);
  vertical-align: top;
  line-height: 1.55;
  font-weight: 500;
}

.markdown-body tr:nth-child(even) td {
  background: rgba(255, 245, 238, 0.5);
}

.markdown-body tr:last-child td {
  border-bottom: none;
}

.markdown-body tr:hover td {
  background: rgba(238, 77, 45, 0.05);
  transition: background 0.2s;
}

.markdown-body td:first-child {
  font-weight: 600;
  color: #5C4033;
}

/* Blockquotes */
.markdown-body blockquote {
  margin: 20px 0;
  padding: 16px 20px;
  border-left: 4px solid var(--shopee);
  background: rgba(238, 77, 45, 0.06);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.markdown-body blockquote p {
  color: var(--text-secondary);
  margin: 0;
  font-style: italic;
  font-size: 15px;
}

/* Code blocks */
.markdown-body code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  background: var(--bg-card);
  color: var(--grab-light);
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.markdown-body pre {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin: 20px 0;
  overflow-x: auto;
}

.markdown-body pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 13px;
  color: var(--text-primary);
}

/* Horizontal rule */
.markdown-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 32px 0;
}

/* ===== CUSTOM FLOWCHART STYLES ===== */
.flow-wrapper {
  margin: 28px 0;
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(145deg, #FFFBF5 0%, #FFF9F0 100%);
  border: 1px solid rgba(180, 130, 100, 0.2);
  box-shadow: 0 4px 20px rgba(150, 80, 50, 0.06);
}

.flow-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  background: linear-gradient(135deg, rgba(238, 77, 45, 0.06) 0%, rgba(204, 102, 51, 0.03) 100%);
  border-bottom: 1px solid rgba(180, 130, 100, 0.12);
}

.flow-header-icon {
  font-size: 15px;
  line-height: 1;
}

.flow-header-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #996644;
}

.flow-body {
  padding: 28px 24px;
  overflow-x: auto;
}

/* CHART CONTAINER */
.flow-chart {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.flow-chart.flow-lr {
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
}

/* NODE BASE */
.flow-node {
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.5;
  color: #3D2B1F;
  text-align: center;
  max-width: 260px;
  min-width: 80px;
  word-break: break-word;
  position: relative;
  background: #fff;
  border: 2px solid #D4A574;
  box-shadow: 0 2px 8px rgba(180, 120, 70, 0.08);
  transition: transform 0.2s, box-shadow 0.2s;
}

.flow-node:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(180, 120, 70, 0.14);
}

/* NODE SHAPES */
.flow-node-stadium {
  border-radius: 30px;
  padding: 12px 24px;
  background: linear-gradient(135deg, #FFF5EE, #FFEEDD);
  border-color: #EE4D2D;
}

.flow-node-diamond {
  border-radius: 4px;
  background: linear-gradient(135deg, #FFFAF0, #FFF3E0);
  border-color: #CC6633;
  padding: 14px 18px;
  transform: none;
  font-weight: 700;
  font-size: 13px;
}

.flow-node-diamond::before {
  content: '◇';
  position: absolute;
  top: -8px;
  right: -8px;
  font-size: 10px;
  color: #CC6633;
  opacity: 0.5;
}

.flow-node-rounded {
  border-radius: 20px;
  padding: 12px 22px;
}

.flow-node-circle {
  border-radius: 50%;
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
}

/* NODE ACCENTS */
.flow-node-start {
  background: linear-gradient(135deg, #FFF0EA, #FFDFD0);
  border-color: #EE4D2D;
  font-weight: 700;
}

.flow-node-end {
  background: linear-gradient(135deg, #F0FFF4, #E8F5E9);
  border-color: #00B14F;
}

/* ARROWS */
.flow-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 0;
  font-size: 18px;
  color: #CC6633;
  font-weight: 300;
  line-height: 1;
  position: relative;
}

.flow-lr .flow-arrow {
  flex-direction: row;
  padding: 0 10px;
  font-size: 20px;
}

.flow-arrow-label {
  font-size: 11px;
  font-weight: 600;
  color: #996644;
  background: rgba(255, 249, 240, 0.9);
  padding: 2px 10px;
  border-radius: 10px;
  border: 1px solid rgba(0, 177, 79, 0.15);
  margin-bottom: 2px;
  white-space: nowrap;
}

.flow-lr .flow-arrow-label {
  margin-bottom: 0;
  margin-right: 4px;
}

/* BRANCHING */
.flow-branch {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  padding: 4px 0;
}

.flow-branch-path {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  min-width: 120px;
  max-width: 260px;
  flex: 1;
}

/* PIE CHART */
.pie-title {
  font-size: 15px;
  font-weight: 700;
  color: #3D2B1F;
  text-align: center;
  margin-bottom: 16px;
}

.pie-bar {
  display: flex;
  height: 28px;
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
}

.pie-seg {
  transition: opacity 0.2s;
  cursor: pointer;
}

.pie-seg:hover {
  opacity: 0.8;
}

.pie-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  justify-content: center;
}

.pie-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #5C4033;
}

.pie-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.pie-label {
  font-weight: 600;
}

.pie-pct {
  font-weight: 700;
  color: #3D2B1F;
}

/* Calculator trigger buttons injected by JS */

/* ===== AI SUGGEST BOX ===== */
.ai-suggest-box {
  background: var(--bg-card);
  border: 1px solid rgba(0, 177, 79, 0.2);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin: 32px 0 24px;
}

.ai-suggest-box h4 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--grab);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-suggest-box .suggest-questions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-suggest-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 177, 79, 0.08);
  border: 1px solid rgba(0, 177, 79, 0.2);
  color: var(--text-secondary);
  padding: 10px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  text-align: left;
  transition: all 0.2s;
}

.ai-suggest-btn:hover {
  background: rgba(0, 177, 79, 0.15);
  color: var(--text-primary);
  border-color: rgba(0, 177, 79, 0.4);
  transform: translateX(4px);
}

/* ===== NAVIGATION BUTTONS ===== */
.content-footer {
  padding-top: 24px;
}

.nav-buttons {
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.nav-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 12px 24px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s;
}

.nav-btn:hover:not(:disabled) {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.next-btn {
  background: var(--grad-shopee);
  color: #fff;
  border-color: transparent;
}

.next-btn:hover {
  opacity: 0.9;
  background: var(--grad-shopee);
  color: #fff;
  transform: translateX(2px);
}

/* ===== CHAT PANEL ===== */
.chat-panel {
  background: var(--bg-chat);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  min-width: 280px;
}

.chat-resize-handle {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  cursor: col-resize;
  background: transparent;
  z-index: 10;
  transition: background 0.15s;
}

.chat-resize-handle:hover,
.chat-resize-handle.active {
  background: rgba(238, 77, 45, 0.3);
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-ai-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--grad-hero);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
  color: #fff;
  flex-shrink: 0;
}

.chat-header h3 {
  font-size: 14px;
  font-weight: 700;
  margin: 0;
}

.chat-header p {
  font-size: 11px;
  color: var(--text-muted);
  margin: 0;
}

.chat-header>div {
  flex: 1;
}

.chat-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 6px;
  border-radius: 6px;
  transition: all 0.2s;
}

.chat-close:hover {
  background: rgba(180, 100, 60, 0.08);
  color: var(--text-primary);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-messages::-webkit-scrollbar {
  width: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(180, 100, 60, 0.2);
  border-radius: 2px;
}

.chat-msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-msg.user-msg {
  align-items: flex-end;
}

.chat-msg.ai-msg {
  align-items: flex-start;
}

.msg-bubble {
  max-width: 90%;
  padding: 12px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.6;
  overflow: hidden;
}

.ai-msg .msg-bubble {
  max-width: 100%;
  overflow-x: auto;
}

.user-msg .msg-bubble {
  background: var(--grad-shopee);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.ai-msg .msg-bubble {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.ai-msg .msg-bubble strong {
  color: var(--text-primary);
}

.typing-indicator {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 8px 0;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing 1.2s ease-in-out infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {

  0%,
  80%,
  100% {
    transform: scale(0.8);
    opacity: 0.5;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

.chat-input-area {
  border-top: 1px solid var(--border);
  padding: 12px;
  flex-shrink: 0;
}

.quick-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 500;
}

.quick-questions {
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.quick-q {
  background: rgba(238, 77, 45, 0.06);
  border: 1px solid rgba(238, 77, 45, 0.15);
  color: var(--text-secondary);
  padding: 7px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  text-align: left;
  transition: all 0.2s;
}

.quick-q:hover {
  background: rgba(238, 77, 45, 0.12);
  color: var(--text-primary);
  border-color: rgba(238, 77, 45, 0.3);
}

.chat-input-row {
  display: flex;
  gap: 8px;
}

.chat-input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

.chat-input:focus {
  border-color: rgba(238, 77, 45, 0.4);
}

.chat-input::placeholder {
  color: var(--text-muted);
}

.chat-send {
  background: var(--grad-shopee);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
  flex-shrink: 0;
}

.chat-send:hover {
  opacity: 0.9;
  transform: scale(1.05);
}

/* ===== CALCULATOR MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
  transform: scale(0.95);
  transition: transform 0.25s;
}

.modal-overlay.open .modal-box {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 800;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.2s;
}

.modal-close:hover {
  background: rgba(180, 100, 60, 0.08);
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

/* Calculator Styles */
.calc-group {
  margin-bottom: 20px;
}

.calc-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  display: block;
}

.calc-input {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  outline: none;
  transition: border-color 0.2s;
}

.calc-input:focus {
  border-color: rgba(238, 77, 45, 0.5);
}

.calc-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.calc-result {
  background: rgba(0, 177, 79, 0.08);
  border: 1px solid rgba(0, 177, 79, 0.25);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-top: 8px;
}

.calc-result-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.calc-result-value {
  font-size: 28px;
  font-weight: 900;
  background: var(--grad-grab);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.calc-result-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.calc-btn {
  width: 100%;
  background: var(--grad-hero);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 14px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
  margin-top: 8px;
}

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

/* ===== CHART & DIAGRAM BLOCKS ===== */
.chart-wrapper {
  margin: 28px 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: linear-gradient(145deg, #16192B, #1E2238);
  border: 1px solid rgba(238, 77, 45, 0.18);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  animation: fadeInChart 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes fadeInChart {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.99);
  }

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

.chart-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  background: linear-gradient(90deg, rgba(238, 77, 45, 0.12), rgba(26, 79, 160, 0.08));
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.chart-icon {
  font-size: 15px;
}

.chart-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: rgba(240, 242, 255, 0.6);
}

.chart-canvas-wrapper {
  padding: 20px 24px 12px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.chart-canvas-wrapper canvas {
  max-height: 280px;
}

.chart-caption {
  padding: 10px 20px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 12px;
  color: rgba(154, 160, 192, 0.85);
  font-style: italic;
  text-align: center;
  line-height: 1.5;
}

/* ===== STEP FLOW (for process diagrams) ===== */
.steps-wrapper .chart-header .chart-icon {
  content: '🔀';
}

.steps-container {
  padding: 28px 20px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 100px;
  max-width: 150px;
  text-align: center;
}

.step-num {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #EE4D2D, #B53018);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(238, 77, 45, 0.5);
}

.step-text {
  font-size: 12.5px;
  font-weight: 600;
  color: #D0D4EE;
  line-height: 1.35;
}

.step-arrow {
  font-size: 20px;
  color: rgba(238, 77, 45, 0.5);
  font-weight: 300;
  flex-shrink: 0;
  align-self: center;
  padding-bottom: 20px;
  /* align with step-num vertically */
}

.step-done-badge {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0, 177, 79, 0.15);
  border: 2px solid rgba(0, 177, 79, 0.5);
  color: #00B14F;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  align-self: center;
  padding-bottom: 20px;
  box-shadow: 0 0 12px rgba(0, 177, 79, 0.2);
}

@media (max-width: 600px) {
  .steps-container {
    flex-direction: column;
    align-items: flex-start;
    padding: 20px;
    gap: 4px;
  }

  .step-item {
    flex-direction: row;
    max-width: 100%;
    text-align: left;
    min-width: unset;
    width: 100%;
    gap: 12px;
  }

  .step-arrow,
  .step-done-badge {
    padding-bottom: 0;
    font-size: 16px;
  }

  .step-arrow {
    transform: rotate(90deg);
    align-self: unset;
  }

  .step-text {
    flex: 1;
  }
}

/* ===== UTILITIES ===== */
.hidden {
  display: none !important;
}

/* Platform badge colors in content */
.badge-shopee {
  color: var(--shopee-light);
}

.badge-grab {
  color: var(--grab-light);
}

.badge-be {
  color: #60A5FA;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  :root {
    --sidebar-w: 260px;
    --chat-w: 100vw;
  }

  /* Mobile: sidebar overlay */
  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    height: calc(100vh - var(--header-h));
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 4px 0 20px rgba(150, 80, 50, 0.15);
  }

  .layout.sidebar-open .sidebar {
    transform: translateX(0);
  }

  /* Mobile: luôn 1 cột content */
  .layout,
  .layout.chat-open,
  .layout.sidebar-closed,
  .layout.sidebar-closed.chat-open {
    grid-template-columns: 1fr !important;
  }

  /* Mobile: chat panel overlay */
  .chat-panel {
    position: fixed;
    top: var(--header-h);
    right: 0;
    height: calc(100vh - var(--header-h));
    width: min(100vw, 360px);
    z-index: 50;
    transform: translateX(100%);
    transition: transform 0.3s ease;
  }

  .layout.chat-open .chat-panel {
    transform: translateX(0);
  }

  .book-content {
    padding: 24px 20px 60px;
  }

  .welcome-stats {
    gap: 16px;
  }

  .brand-author {
    display: none;
  }

  .update-badge {
    display: none;
  }
}

/* ===== AI-GENERATED BOOK IMAGES ===== */
.book-image-wrapper {
  margin: 28px 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid rgba(238, 77, 45, 0.18);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
  animation: fadeInChart 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  background: #0F1120;
  position: relative;
}

.book-image-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: linear-gradient(90deg, rgba(238, 77, 45, 0.1), rgba(26, 79, 160, 0.07));
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.book-image-header-icon {
  font-size: 14px;
}

.book-image-header-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: rgba(240, 242, 255, 0.5);
}

.book-image-loading {
  padding: 52px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.image-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(238, 77, 45, 0.15);
  border-top-color: #EE4D2D;
  border-radius: 50%;
  animation: imgSpin 0.85s linear infinite;
}

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

.image-loading-label {
  font-size: 14px;
  font-weight: 600;
  color: #C8CCE8;
}

.image-loading-prompt {
  font-size: 12px;
  color: rgba(154, 160, 192, 0.55);
  font-style: italic;
  max-width: 320px;
  line-height: 1.5;
}

.book-image-img {
  width: 100%;
  height: auto;
  display: block;
  transition: opacity 0.4s ease;
}

.book-image-badge {
  position: absolute;
  top: 52px;
  right: 14px;
  background: rgba(20, 22, 40, 0.85);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 10px;
  font-weight: 700;
  color: rgba(200, 204, 232, 0.7);
  letter-spacing: 0.5px;
  pointer-events: none;
}

.book-image-caption {
  padding: 10px 18px 13px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 12px;
  color: rgba(154, 160, 192, 0.8);
  font-style: italic;
  text-align: center;
  line-height: 1.5;
  background: rgba(0, 0, 0, 0.15);
}

.book-image-error {
  padding: 28px 24px;
  text-align: center;
  color: #F87171;
  font-size: 13px;
  line-height: 1.6;
}

/* =============================================
   LOGIN SCREEN — Email + OTP Authentication
   ============================================= */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0A2118 0%, #0D2B1C 30%, #0B1F18 60%, #081A14 100%);
  overflow: hidden;
}

.login-screen.hidden {
  display: none;
}

/* Animated background blobs */
.login-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.login-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
  animation: loginFloat 12s ease-in-out infinite;
}

.login-blob-1 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, #00B14F 0%, transparent 70%);
  top: -10%;
  left: -5%;
  animation-delay: 0s;
  opacity: 0.5;
}

.login-blob-2 {
  width: 350px;
  height: 350px;
  background: radial-gradient(circle, #F58220 0%, transparent 70%);
  bottom: -10%;
  right: -5%;
  animation-delay: -4s;
  opacity: 0.45;
}

.login-blob-3 {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, #F59E0B 0%, transparent 70%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: -8s;
  opacity: 0.25;
}

.login-blob-4 {
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, #06B6D4 0%, transparent 70%);
  bottom: 20%;
  left: 10%;
  animation-delay: -6s;
  opacity: 0.3;
}

@keyframes loginFloat {

  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }

  33% {
    transform: translate(30px, -20px) scale(1.05);
  }

  66% {
    transform: translate(-20px, 15px) scale(0.95);
  }
}

/* Container: book image + card side by side */
.login-container {
  display: flex;
  align-items: center;
  gap: 48px;
  position: relative;
  z-index: 2;
  max-width: 900px;
  width: 100%;
  padding: 24px;
}

/* Book Cover */
.login-book-cover {
  flex-shrink: 0;
  animation: bookFloat 6s ease-in-out infinite;
}

.login-book-cover img {
  width: 320px;
  max-width: 320px;
  border-radius: 16px;
  box-shadow:
    0 20px 60px rgba(0, 177, 79, 0.3),
    0 0 80px rgba(0, 177, 79, 0.15),
    0 0 120px rgba(245, 130, 32, 0.1);
  transform: perspective(800px) rotateY(-5deg);
  transition: transform 0.4s ease;
}

.login-book-cover img:hover {
  transform: perspective(800px) rotateY(0deg) scale(1.03);
}

@keyframes bookFloat {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-12px);
  }
}

/* Login Card — Glassmorphism */
.login-card {
  flex: 1;
  max-width: 400px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(0, 177, 79, 0.2);
  border-radius: 24px;
  padding: 36px 32px;
  box-shadow: 0 16px 64px rgba(0, 80, 40, 0.4);
  animation: cardFadeIn 0.8s ease forwards;
}

@keyframes cardFadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

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

/* Login Brand */
.login-brand {
  text-align: center;
  margin-bottom: 28px;
}

.login-app-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
}

.login-app-dots .dot {
  width: 12px;
  height: 12px;
}

.dot.xanhsm {
  background: #06B6D4;
  color: #06B6D4;
}

.login-title {
  font-size: 28px;
  font-weight: 900;
  line-height: 1.15;
  background: linear-gradient(135deg, #00B14F 0%, #F58220 50%, #06B6D4 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 6px;
}

.login-title-sm {
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 6px;
}

.login-subtitle {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.55);
  line-height: 1.5;
}

.login-subtitle strong {
  color: #00CC5C;
}

/* OTP Icon */
.otp-icon {
  font-size: 42px;
  margin-bottom: 8px;
}

/* Login Form */
.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-label {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.login-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 12px 16px;
  transition: all 0.3s;
}

.login-input-wrap:focus-within {
  border-color: #00B14F;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 0 3px rgba(0, 177, 79, 0.2);
}

.login-input-icon {
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.4);
}

.login-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 15px;
  color: #fff;
  font-family: inherit;
}

.login-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

/* Login Button */
.login-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(135deg, #00B14F, #008C3E);
  color: #fff;
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
}

.login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 177, 79, 0.4);
}

.login-btn:active {
  transform: translateY(0);
}

.login-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.login-btn-loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* OTP Inputs */
.otp-inputs {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.otp-box {
  width: 48px;
  height: 56px;
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  outline: none;
  transition: all 0.3s;
  caret-color: #00B14F;
}

.otp-box:focus {
  border-color: #00B14F;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 0 3px rgba(0, 177, 79, 0.2);
  transform: translateY(-2px);
}

.otp-box.filled {
  border-color: #F58220;
  background: rgba(245, 130, 32, 0.1);
}

/* Login Error */
.login-error {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  margin-top: 8px;
  animation: shakeError 0.4s ease;
}

.login-error.error-red {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #FCA5A5;
}

.login-error.error-yellow {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #FCD34D;
}

@keyframes shakeError {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-6px);
  }

  50% {
    transform: translateX(6px);
  }

  75% {
    transform: translateX(-4px);
  }
}

/* OTP Actions */
.otp-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.otp-resend,
.otp-back {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.2s;
}

.otp-resend:hover,
.otp-back:hover {
  color: #00CC5C;
  background: rgba(0, 177, 79, 0.1);
}

.otp-sep {
  color: rgba(255, 255, 255, 0.2);
  font-size: 16px;
}

/* Login Footer */
.login-footer {
  text-align: center;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.25);
  margin-top: 24px;
}

.login-footer strong {
  color: rgba(255, 255, 255, 0.45);
}

/* Login Step transition */
.login-step {
  animation: stepFadeIn 0.4s ease;
}

@keyframes stepFadeIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }

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

/* ===== LOGIN RESPONSIVE ===== */
@media (max-width: 768px) {
  .login-container {
    flex-direction: column;
    gap: 24px;
    padding: 16px;
  }

  .login-book-cover img {
    width: 200px;
    max-width: 200px;
    transform: none;
  }

  .login-book-cover img:hover {
    transform: scale(1.03);
  }

  .login-card {
    max-width: 100%;
    padding: 28px 20px;
  }

  .login-title {
    font-size: 24px;
  }

  .otp-box {
    width: 42px;
    height: 48px;
    font-size: 18px;
  }
}