/* =============================================
   Dhammapada Digital Palm-Leaf — ebook-new.css
   Design: Warm editorial, refined manuscript feel
   ============================================= */

/* ---------- Google Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,600;0,700;1,400&family=Cinzel:wght@400;600;700&display=swap');

@font-face {
  font-family: 'THSarabunPali';
  src: url('../fonts/THSarabunPali.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'THSarabunPali';
  src: url('../fonts/THSarabunPali.ttf') format('truetype');
  font-weight: bold;
  font-style: normal;
  font-display: swap;
}

/* ---------- CSS Custom Properties ---------- */
:root {
  /* Palette — warm parchment / gold / ink */
  --parchment:      #FDFBF7;
  --parchment-deep: #F5F0E8;
  --cream:          #FEFDFB;
  --gold:           #C9A554;
  --gold-light:     #E8D5A0;
  --gold-dark:      #A07D3A;
  --brown:          #5C3D10;
  --brown-dark:     #3C1F10;
  --brown-light:    #8B6914;
  --ink:            #2C1810;
  --ink-light:      #4A3728;
  --pali-color:     #7A2E0E;
  --thai-color:     #1A3A6B;
  --attha-color:    #2D5016;
  --accent:         #B8432F;
  --muted:          #8C7B6B;
  --border:         #DDD0BE;
  --border-light:   #EDE4D4;
  --shadow:         rgba(60, 31, 16, 0.08);
  --shadow-md:      rgba(60, 31, 16, 0.12);
  --shadow-lg:      rgba(60, 31, 16, 0.18);

  /* Typography */
  --font-display: 'Cinzel', 'Cormorant Garamond', serif;
  --font-body:    'Sarabun', sans-serif;
  --font-serif:   'Cormorant Garamond', serif;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Base / Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }

body {
  background: var(--parchment);
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(201,165,84,0.06) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 100%, rgba(201,165,84,0.04) 0%, transparent 60%);
  background-attachment: fixed;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

/* Utility: hide */
.hide { display: none !important; }
[v-cloak] { display: none !important; }

/* ---------- Punctuation Hiding ---------- */
.hide-punctuation .pali-text { }

/* ---------- Loading Spinner ---------- */
.spinner-loading {
  animation: spinner-rotate 1s linear infinite !important;
  display: inline-block;
}
@keyframes spinner-rotate {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ---------- Text Styles ---------- */
.pali-text {
  font-family: 'THSarabunPali', var(--font-body);
  font-size: 1.65rem;
  line-height: 2.3;
  color: var(--pali-color);
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal;
}

.thai-text {
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.9;
  color: var(--thai-color);
}

.thai-attha-text {
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.9;
  color: var(--attha-color);
}

/* ---------- Hidden Thai (Quiz Mode) ---------- */
.hidden-thai {
  position: relative;
  background: var(--parchment-deep);
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  min-height: 2.5rem;
  display: flex;
  align-items: center;
  padding: 0.5rem;
  border: 1px dashed var(--border);
}

.hidden-thai > * {
  visibility: hidden;
  opacity: 0;
  transition: visibility 0s, opacity 0.25s var(--ease);
}

.hidden-thai.reveal-thai > * {
  visibility: visible;
  opacity: 1;
}

/* =============================================
   USER BAR
   ============================================= */
.en-user-bar {
  background: linear-gradient(135deg, var(--brown-dark), var(--brown), var(--brown-dark));
  padding: 7px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.85rem;
  border-bottom: 2px solid var(--gold-dark);
  position: relative;
}

.en-user-bar::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-light), transparent);
}

.en-story-title-bar {
  color: var(--gold-light);
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
  font-weight: 300;
  letter-spacing: 0.02em;
}

.en-story-title-bar i {
  color: var(--gold);
  margin-right: 6px;
}

.en-user-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.en-sync-status {
  color: var(--gold);
  font-size: 0.75rem;
}

.en-user-menu-wrap {
  position: relative;
}

.en-user-menu-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  background: transparent;
  border: 1px solid rgba(201,165,84,0.3);
  border-radius: 20px;
  padding: 3px 14px;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  color: var(--gold-light);
  font-family: var(--font-body);
  font-size: 0.85rem;
}

.en-user-menu-btn:hover {
  background: rgba(201,165,84,0.12);
  border-color: rgba(201,165,84,0.5);
}

.en-user-menu-btn img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(201,165,84,0.5);
}

.en-user-menu-btn .chevron {
  font-size: 0.7rem;
  transition: transform 0.2s var(--ease);
}

.en-user-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 6px;
  background: var(--cream);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px var(--shadow-lg);
  min-width: 190px;
  overflow: hidden;
  z-index: 1000;
  border: 1px solid var(--border-light);
}

.en-user-dropdown a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 18px;
  color: var(--ink-light);
  text-decoration: none;
  transition: background 0.15s;
  font-size: 0.88rem;
}

.en-user-dropdown a:hover {
  background: var(--parchment-deep);
}

.en-user-dropdown a + a {
  border-top: 1px solid var(--border-light);
}

.en-login-link {
  color: var(--gold-light);
  text-decoration: none;
  padding: 5px 18px;
  background: rgba(201,165,84,0.1);
  border-radius: 20px;
  font-size: 0.85rem;
  border: 1px solid rgba(201,165,84,0.25);
  transition: all 0.2s;
}

.en-login-link:hover {
  background: rgba(201,165,84,0.2);
  color: #fff;
}

/* =============================================
   COMPACT NAVIGATION BAR
   ============================================= */
.en-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--cream);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 12px var(--shadow);
  padding: 8px 14px;
  transition: transform 0.3s var(--ease);
}

.en-nav.hidden {
  transform: translateY(-100%);
}

.en-nav-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
}

/* Hamburger / Settings */
.en-nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--cream);
  color: var(--brown);
  cursor: pointer;
  font-size: 1.15rem;
  transition: all 0.15s var(--ease);
  flex-shrink: 0;
}

.en-nav-btn:hover:not(:disabled) {
  background: var(--parchment-deep);
  border-color: var(--gold-light);
  color: var(--gold-dark);
}

.en-nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Center: book + page selects */
.en-nav-center {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.en-book-select,
.en-page-select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 0.85rem;
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--ink);
  transition: border-color 0.15s;
}

.en-book-select {
  font-weight: 600;
  color: var(--brown);
  min-width: 78px;
  max-width: 95px;
}

.en-page-select {
  min-width: 72px;
  max-width: 105px;
}

.en-book-select:focus,
.en-page-select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(201,165,84,0.2);
}

/* Right side action buttons */
.en-nav-right {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}

.en-nav-btn-quiz {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--gold);
  color: #fff;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.15s var(--ease);
  flex-shrink: 0;
}

.en-nav-btn-quiz:hover { background: var(--gold-dark); }
.en-nav-btn-quiz.active { background: var(--muted); }

.en-nav-btn-action {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.15s var(--ease);
  flex-shrink: 0;
}

.en-nav-btn-action:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
}

.en-nav-btn-page {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 38px;
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all 0.15s var(--ease);
  flex-shrink: 0;
}

.en-nav-btn-page.prev { background: var(--brown); }
.en-nav-btn-page.prev:hover:not(:disabled) { background: var(--brown-dark); }
.en-nav-btn-page.next { background: var(--gold-dark); }
.en-nav-btn-page.next:hover:not(:disabled) { background: var(--gold); }
.en-nav-btn-page:disabled { background: #C4B8A8; cursor: not-allowed; }

/* Select2 in nav */
.en-nav-center .select2-container {
  min-width: 82px !important;
  max-width: 105px !important;
}
.en-nav-center .select2-container .select2-selection--single {
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  background: var(--cream);
}
.en-nav-center .select2-container .select2-selection--single .select2-selection__rendered {
  line-height: 30px;
  padding-left: 10px;
  font-size: 0.85rem;
  color: var(--ink);
}
.en-nav-center .select2-container .select2-selection--single .select2-selection__arrow {
  height: 30px;
}
.compact-page-dropdown .select2-search--dropdown .select2-search__field {
  font-size: 0.85rem;
  padding: 5px 8px;
}
.compact-page-dropdown .select2-results__option {
  font-size: 0.85rem;
  padding: 5px 8px;
}

/* =============================================
   PANEL TOGGLE (floating gear)
   ============================================= */
.en-panel-toggle {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 110;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 46px;
  height: 46px;
  display: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(201,165,84,0.4);
  transition: all 0.3s var(--ease);
  font-size: 1.1rem;
  align-items: center;
  justify-content: center;
}

.en-panel-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 24px rgba(201,165,84,0.5);
}

/* =============================================
   SETTINGS OFFCANVAS
   ============================================= */
.en-settings-section {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
}

.en-settings-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

/* =============================================
   HERO SECTION
   ============================================= */
.en-hero {
  text-align: center;
  padding: 2rem 1.5rem;
  margin-bottom: 1.5rem;
  border-radius: var(--radius-xl);
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg,
    var(--cream) 0%,
    var(--parchment-deep) 30%,
    rgba(201,165,84,0.15) 60%,
    var(--parchment-deep) 80%,
    var(--cream) 100%);
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px var(--shadow);
}

.en-hero::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    radial-gradient(circle at 25% 80%, rgba(201,165,84,0.08) 0%, transparent 50%),
    radial-gradient(circle at 75% 20%, rgba(201,165,84,0.06) 0%, transparent 50%),
    linear-gradient(45deg, transparent 30%, rgba(255,255,255,0.1) 50%, transparent 70%);
  pointer-events: none;
  animation: heroShimmer 12s ease-in-out infinite alternate;
}

@keyframes heroShimmer {
  0%   { opacity: 0.5; }
  100% { opacity: 0.9; }
}

.en-hero-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--brown-dark);
  margin: 0 0 0.3rem;
  position: relative;
  z-index: 1;
  letter-spacing: 0.05em;
  text-shadow: 0 1px 2px rgba(255,255,255,0.5);
}

.en-hero-subtitle {
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--brown-light);
  font-weight: 400;
  position: relative;
  z-index: 1;
  margin: 0;
}

/* =============================================
   BOOK SELECTION GRID
   ============================================= */
.en-book-grid {
  padding: 1.5rem;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  background: linear-gradient(160deg, var(--cream), var(--parchment-deep) 50%, var(--cream));
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px var(--shadow);
}

.en-book-card {
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.25s var(--ease);
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px var(--shadow);
  background: var(--cream);
}

.en-book-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px var(--shadow-md);
  border-color: var(--gold-light);
}

.en-book-card-inner {
  aspect-ratio: 3 / 4;
  display: flex;
  flex-direction: column;
  position: relative;
}

.en-book-cover {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
}

.en-book-cover img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.en-book-fallback {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.en-book-fallback-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--brown);
}

.en-book-fallback-num {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--gold-dark);
}

.en-book-label {
  text-align: center;
  padding: 0.5rem 0.25rem;
  background: rgba(255,255,255,0.9);
  border-top: 1px solid var(--border-light);
  font-size: 0.78rem;
  color: var(--brown);
}

.en-book-label-title {
  font-weight: 600;
  display: block;
}

.en-book-label-sub {
  font-size: 0.7rem;
  color: var(--muted);
}

/* =============================================
   MAIN CONTENT AREA
   ============================================= */
.en-main {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 2rem 2rem;
}

.en-loading {
  text-align: center;
  padding: 3rem 0;
  color: var(--muted);
  font-style: italic;
}

/* Column / Line View shared */
#columnView, #lineView {
  background: var(--cream);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow:
    0 4px 24px var(--shadow),
    inset 0 1px 0 rgba(255,255,255,0.7);
  padding: 1.5rem;
  position: relative;
  overflow: visible;
}

/* Column View */
.en-col-header {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.en-col-header h3 {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  margin: 0;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
}

.en-col-header h3:first-child { color: var(--thai-color); }
.en-col-header h3:last-child  { color: var(--pali-color); }

.column-row {
  display: flex;
  margin-bottom: 0.5rem;
  min-height: fit-content;
}

.column-item {
  flex: 1;
  padding: 0.6rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: flex-start;
}

/* Line View */
.sentence-pair {
  margin-bottom: 1.5rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-light);
}
.sentence-pair .pali-text,
.sentence-pair .thai-text,
.sentence-pair .thai-attha-text { margin-bottom: 0.5rem; }

.line-number {
  font-size: 0.75rem;
  color: #999;
  margin-right: 0.5rem;
  user-select: none;
}

.word-by-word-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--gold);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  font-size: 0.75rem;
  margin-left: 0.5rem;
  cursor: pointer;
  vertical-align: middle;
  transition: background var(--transition-speed);
}
.word-by-word-btn:hover {
  background: var(--gold-dark);
}

/* =============================================
   PAGE INFO
   ============================================= */
.en-page-info {
  text-align: center;
  padding: 1.2rem 0;
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
}

/* =============================================
   BOTTOM NAVIGATION
   ============================================= */
.en-bottom-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 1.5rem 0;
}

.en-bottom-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 24px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.2s var(--ease);
}

.en-bottom-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.en-bottom-prev {
  background: var(--parchment-deep);
  color: var(--ink-light);
  border: 1px solid var(--border);
}
.en-bottom-prev:hover:not(:disabled) {
  background: var(--border);
  color: var(--ink);
}

.en-bottom-book {
  background: linear-gradient(135deg, var(--brown), var(--brown-dark));
  color: var(--gold-light);
  box-shadow: 0 3px 12px rgba(92,61,16,0.3);
}
.en-bottom-book:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(92,61,16,0.4);
}

.en-bottom-next {
  background: var(--parchment-deep);
  color: var(--ink-light);
  border: 1px solid var(--border);
}
.en-bottom-next:hover:not(:disabled) {
  background: var(--border);
  color: var(--ink);
}

@media (max-width: 576px) {
  .en-bottom-btn {
    padding: 9px 16px;
    font-size: 0.82rem;
  }
  .en-bottom-label { display: none; }
}

/* =============================================
   FOOTER
   ============================================= */
.en-footer {
  text-align: center;
  padding: 2rem 0 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.en-footer a {
  display: inline-block;
  margin-bottom: 1rem;
  padding: 8px 24px;
  border-radius: var(--radius-md);
  border: 1px solid var(--gold-light);
  color: var(--gold-dark);
  text-decoration: none;
  font-weight: 600;
  transition: all 0.2s;
}

.en-footer a:hover {
  background: var(--gold-light);
  color: var(--brown-dark);
}

/* =============================================
   WORD CLICK / HOVER
   ============================================= */
.pali-word, .thai-word {
  cursor: pointer;
  padding: 3px 2px;
  border-radius: var(--radius-sm);
  transition: all 0.2s var(--ease);
  display: inline;
  position: relative;
}

.pali-word { white-space: nowrap; }

.pali-word:hover {
  background: linear-gradient(135deg,
    rgba(201,165,84,0.12) 0%,
    rgba(201,165,84,0.2) 50%,
    rgba(201,165,84,0.12) 100%);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(201,165,84,0.25);
}

.thai-word:hover {
  background: linear-gradient(135deg,
    rgba(26,58,107,0.1) 0%,
    rgba(26,58,107,0.16) 50%,
    rgba(26,58,107,0.1) 100%);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(26,58,107,0.2);
}

.word-highlighted {
  background: linear-gradient(135deg,
    rgba(201,165,84,0.5) 0%,
    rgba(201,165,84,0.65) 50%,
    rgba(201,165,84,0.5) 100%) !important;
  font-weight: 600;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(201,165,84,0.35);
}

/* Bracket markers */
.bracket-marker {
  color: var(--accent);
  font-weight: bold;
  font-size: 1.8em;
  display: inline;
  margin: 0 3px;
  cursor: pointer;
  line-height: 0.8;
}

/* =============================================
   NOTE SYSTEM
   ============================================= */
.pali-word[data-has-note="true"],
.thai-word[data-has-note="true"] {
  --note-color: #3b82f6;
}

.pali-word[data-has-note="true"]::before,
.thai-word[data-has-note="true"]::before {
  content: attr(data-note-text);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  color: var(--note-color, #3b82f6);
  font-size: 0.85em;
  font-weight: 500;
  white-space: nowrap;
  margin-bottom: -18px;
  pointer-events: auto;
  cursor: pointer;
  z-index: 5;
}

.has-note {
  color: #7c2d12 !important;
  position: relative;
}

/* Inline Note Editor */
.inline-note-editor {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--cream);
  border: 2px solid var(--gold);
  border-radius: var(--radius-sm);
  padding: 6px;
  box-shadow: 0 4px 16px var(--shadow-lg);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 25px;
}

.inline-note-editor .editor-top {
  display: flex;
  align-items: center;
  gap: 4px;
}

.inline-note-editor .color-swatches {
  display: flex;
  gap: 4px;
  justify-content: center;
  padding-top: 2px;
}

.inline-note-editor .color-swatch {
  width: 22px;
  height: 22px;
  border: 2px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
  transition: all 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.inline-note-editor .color-swatch:hover { transform: scale(1.1); }
.inline-note-editor .color-swatch.selected {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--gold), 0 2px 5px rgba(0,0,0,0.3);
  transform: scale(1.1);
}

.inline-note-editor .note-input {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 0.85rem;
  width: 200px;
  outline: none;
  font-weight: 500;
  font-family: var(--font-body);
}

.inline-note-editor .note-input:focus { border-color: var(--gold); }

.inline-note-editor button {
  padding: 4px 10px;
  border: none;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
  font-family: var(--font-body);
}

.inline-note-editor .btn-save { background: var(--gold); color: #fff; }
.inline-note-editor .btn-save:hover { background: var(--gold-dark); }
.inline-note-editor .btn-cancel { background: var(--parchment-deep); color: var(--ink-light); }
.inline-note-editor .btn-cancel:hover { background: var(--border); }

/* Floating Note (post-it) */
.floating-note {
  position: fixed;
  z-index: 1050;
  background: #feff9c;
  border: none;
  border-radius: 2px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  max-width: 300px;
  transform: rotate(-1deg);
  animation: noteIn 0.2s var(--ease);
  padding: 0;
  font-family: var(--font-body);
}

.floating-note::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  border-width: 0 16px 16px 0;
  border-style: solid;
  border-color: #e4e4a1 #fff;
  box-shadow: -2px 2px 2px rgba(0,0,0,0.1);
}

.floating-note-header {
  padding: 8px 12px 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px dashed rgba(0,0,0,0.1);
}

.floating-note-header i { color: #b5b559; font-size: 14px; }

.floating-note-header .close-btn {
  background: none;
  border: none;
  color: #b5b559;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.floating-note-header .close-btn:hover { color: #999933; }

.note-header-content {
  display: flex;
  align-items: center;
  gap: 8px;
}

.noted-word {
  font-weight: 500;
  color: #726f3b;
  font-size: 0.95em;
}

.floating-note-content {
  font-family: var(--font-body);
  padding: 12px;
  max-height: 200px;
  overflow-y: auto;
  color: #515151;
  line-height: 1.5;
  font-size: 1em;
}

@keyframes noteIn {
  from { opacity: 0; transform: translateY(-10px) rotate(-1deg); }
  to   { opacity: 1; transform: translateY(0) rotate(-1deg); }
}

/* Post-it Modal */
.post-it-modal {
  background: #feff9c;
  border: none;
  border-radius: 3px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.post-it-modal::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  border-width: 0 20px 20px 0;
  border-style: solid;
  border-color: #e4e4a1 #fff;
  box-shadow: -2px 2px 2px rgba(0,0,0,0.1);
}

.post-it-modal .modal-header {
  border-bottom: 1px dashed rgba(0,0,0,0.1);
  padding: 1rem 1.5rem;
  background: transparent;
}

.post-it-modal .note-header-content i { color: #b5b559; font-size: 1.2rem; }
.post-it-modal .modal-title { color: #726f3b; font-size: 1.1rem; margin: 0; font-weight: 500; }
.post-it-modal .btn-close { opacity: 0.5; font-size: 0.8rem; }

.post-it-modal .modal-body {
  padding: 1.5rem;
  background: linear-gradient(transparent, transparent 28px, #e4e4a1 28px);
  background-size: 100% 29px;
}

.post-it-modal .note-textarea {
  background: transparent;
  border: none;
  line-height: 29px;
  height: auto;
  min-height: 116px;
  resize: vertical;
  color: #515151;
  font-size: 1rem;
  padding: 0;
  font-family: var(--font-body);
}

.post-it-modal .note-textarea:focus { box-shadow: none; outline: none; }
.post-it-modal .note-textarea::placeholder { color: #b5b559; opacity: 0.6; }

.post-it-modal .modal-footer {
  border-top: 1px dashed rgba(0,0,0,0.1);
  padding: 1rem 1.5rem;
  background: transparent;
}

.post-it-modal .save-note-btn { background-color: #b5b559; border-color: #b5b559; }
.post-it-modal .save-note-btn:hover { background-color: #999933; border-color: #999933; }
.post-it-modal .btn-light { background-color: rgba(255,255,255,0.5); border-color: rgba(0,0,0,0.1); }
.post-it-modal .btn-light:hover { background-color: rgba(255,255,255,0.7); }

/* =============================================
   FLOATING MENU (highlight / notes / brackets)
   ============================================= */
.floating-menu {
  position: fixed;
  background: var(--cream);
  border-radius: var(--radius-md);
  box-shadow: 0 6px 28px var(--shadow-lg);
  z-index: 1000;
  padding: 0.5rem;
  border: 1px solid var(--border);
}

.floating-menu-content { padding: 8px; }

.highlight-colors {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 4px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}

.color-btn {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
}

.color-btn:hover { transform: scale(1.15); border-color: var(--muted); }

.color-btn.clear-highlight {
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  border: 2px solid var(--border);
}

.color-btn.clear-highlight:hover { color: var(--ink); border-color: var(--muted); }
.color-btn.clear-highlight i { font-size: 12px; }

.note-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px;
  border: none;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  color: var(--ink-light);
  font-size: 0.875rem;
  font-family: var(--font-body);
}

.note-btn:hover { background: var(--parchment-deep); }

.note-btn .bracket-symbol {
  font-size: 1.8rem;
  font-weight: bold;
  color: var(--accent);
  line-height: 1;
}

/* Text Selection Menu */
.selection-menu {
  position: fixed;
  background: var(--cream);
  border-radius: var(--radius-md);
  box-shadow: 0 6px 28px var(--shadow-lg);
  z-index: 10000;
  padding: 12px;
  border: 1px solid var(--border);
  min-width: 220px;
}

.selection-menu-content { display: flex; flex-direction: column; gap: 12px; }
.menu-section { display: flex; flex-direction: column; gap: 6px; }
.menu-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.color-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }

.color-btn-small {
  width: 28px; height: 28px;
  border-radius: 4px;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
  padding: 0;
}
.color-btn-small:hover { transform: scale(1.15); border-color: var(--muted); }

.underline-btn-small {
  width: 28px; height: 28px;
  border-radius: 4px;
  border: 2px solid var(--border);
  border-bottom-width: 4px;
  border-bottom-style: solid;
  cursor: pointer;
  transition: all 0.2s;
  background: #fff;
  padding: 0;
}
.underline-btn-small:hover { transform: scale(1.15); border-color: var(--muted); }

.remove-style-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 8px;
  border: none;
  background: var(--parchment-deep);
  border-radius: 4px;
  cursor: pointer;
  color: var(--ink-light);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s;
  font-family: var(--font-body);
}
.remove-style-btn:hover { background: var(--border); }

/* Text Highlight & Underline */
.text-highlight { padding: 2px 0; border-radius: 2px; }
.text-underline { border-bottom: 3px solid; padding-bottom: 1px; }

/* Highlight Mode Cursor */
body.highlight-mode .pali-word,
body.highlight-mode .thai-word { cursor: crosshair; }

/* =============================================
   SEARCH HIGHLIGHT
   ============================================= */
.search-highlighted {
  background: linear-gradient(135deg,
    rgba(201,165,84,0.25) 0%,
    rgba(201,165,84,0.18) 50%,
    rgba(201,165,84,0.25) 100%);
  border-radius: var(--radius-md);
  padding: 8px;
  border: 2px solid rgba(201,165,84,0.4);
  box-shadow: 0 4px 12px rgba(201,165,84,0.25);
  animation: searchPulse 0.6s ease-in-out;
  margin: 4px 0;
  transition: all 0.3s var(--ease);
}

@keyframes searchPulse {
  0%   { transform: scale(1);    box-shadow: 0 4px 12px rgba(201,165,84,0.25); }
  50%  { transform: scale(1.02); box-shadow: 0 8px 20px rgba(201,165,84,0.35); }
  100% { transform: scale(1);    box-shadow: 0 4px 12px rgba(201,165,84,0.25); }
}

.search-highlighted mark.bg-warning {
  background: linear-gradient(135deg,
    rgba(201,165,84,0.7) 0%,
    rgba(228,213,160,0.8) 50%,
    rgba(201,165,84,0.7) 100%) !important;
  color: var(--ink) !important;
  font-weight: 600;
  padding: 2px 4px;
  border-radius: 3px;
}

.table tbody tr td mark.bg-warning {
  background: linear-gradient(135deg,
    rgba(201,165,84,0.5) 0%,
    rgba(228,213,160,0.6) 50%,
    rgba(201,165,84,0.5) 100%) !important;
  color: var(--ink) !important;
  font-weight: 500;
  padding: 1px 3px;
  border-radius: 3px;
}

/* =============================================
   OFFCANVAS (shared overrides)
   ============================================= */
.offcanvas {
  background: linear-gradient(180deg, var(--cream) 0%, var(--parchment) 100%);
  backdrop-filter: blur(20px);
  border-color: var(--border) !important;
  box-shadow: 0 0 40px var(--shadow-lg);
}

.offcanvas-header {
  background: linear-gradient(135deg, var(--cream), var(--parchment-deep));
  border-bottom: 1px solid var(--border);
}

.offcanvas-body { background: transparent; }

/* =============================================
   TRANSLATION OFFCANVAS
   ============================================= */
.translation-content {
  font-size: 1rem;
  line-height: 1.7;
}

.similar-word {
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  transition: all 0.2s var(--ease);
  background: var(--cream);
  margin-bottom: 8px;
}

.similar-word:hover {
  background: var(--parchment-deep);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--shadow);
}

.similar-word strong { color: var(--ink); font-weight: 600; }

.similar-word.border-warning { border-left: 4px solid var(--gold); }
.similar-word.border-info    { border-left: 4px solid #3b82f6; }
.similar-word.border-secondary { border-left: 4px solid var(--muted); }
.similar-word.border-success { border-left: 4px solid #10b981; }

/* Translation Details */
.translation-content .btn-outline-secondary.btn-sm,
.similar-word .btn-outline-secondary.btn-sm {
  width: 24px; height: 24px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-size: 0.75rem;
  opacity: 0.7;
}

.translation-content .btn-outline-secondary.btn-sm:hover,
.similar-word .btn-outline-secondary.btn-sm:hover {
  background: var(--muted);
  border-color: var(--muted);
  color: #fff;
  opacity: 1;
}

.details-content { transition: all 0.3s; overflow: hidden; }
.details-content .card-body {
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  margin: 0;
}

.clickable-meaning {
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 4px;
  transition: background-color 0.2s;
}
.clickable-meaning:hover { background: rgba(201,165,84,0.08); }

.meaning-line {
  padding: 0.75rem;
  border-radius: var(--radius-md);
  transition: all 0.3s var(--ease);
}

/* =============================================
   WORD BY WORD TRANSLATION
   ============================================= */
.word-by-word-translation {
  background: linear-gradient(135deg, var(--cream) 0%, var(--parchment-deep) 100%);
  border-radius: var(--radius-md);
  box-shadow: 0 2px 8px var(--shadow);
  animation: slideInDown 0.3s var(--ease);
}

.word-by-word-translation .grid {
  background: var(--cream);
  border-radius: var(--radius-sm);
  padding: 8px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.06);
}

.word-by-word-translation .flex.items-start {
  transition: background 0.2s;
}
.word-by-word-translation .flex.items-start:hover {
  background: var(--parchment-deep);
  border-radius: 4px;
  padding: 2px 4px;
}

@keyframes slideInDown {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.word-by-word-loading {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--muted);
  animation: pulse 1.5s ease-in-out infinite;
}
.word-by-word-loading::after {
  content: '\27F3';
  animation: spin 1s linear infinite;
}
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* Confidence colors */
.text-green-600  { color: #059669 !important; font-weight: 600; }
.text-blue-600   { color: #2563eb !important; font-weight: 600; }
.text-orange-600 { color: #ea580c !important; font-weight: 600; }
.text-red-600    { color: #dc2626 !important; font-weight: 600; }

/* =============================================
   EXAM ITEMS
   ============================================= */
.exam-item { transition: background 0.15s; }
.exam-item:hover { background: var(--parchment-deep); }

/* =============================================
   FONT SIZE CONTROL CLASSES
   ============================================= */
.content-font-size-80 .pali-text { font-size: 1.32rem !important; }
.content-font-size-80 .thai-text,
.content-font-size-80 .thai-attha-text { font-size: 0.84rem !important; }

.content-font-size-90 .pali-text { font-size: 1.49rem !important; }
.content-font-size-90 .thai-text,
.content-font-size-90 .thai-attha-text { font-size: 0.945rem !important; }

.content-font-size-110 .pali-text { font-size: 1.82rem !important; }
.content-font-size-110 .thai-text,
.content-font-size-110 .thai-attha-text { font-size: 1.155rem !important; }

.content-font-size-120 .pali-text { font-size: 1.98rem !important; }
.content-font-size-120 .thai-text,
.content-font-size-120 .thai-attha-text { font-size: 1.26rem !important; }

.content-font-size-130 .pali-text { font-size: 2.15rem !important; }
.content-font-size-130 .thai-text,
.content-font-size-130 .thai-attha-text { font-size: 1.365rem !important; }

.content-font-size-140 .pali-text { font-size: 2.31rem !important; }
.content-font-size-140 .thai-text,
.content-font-size-140 .thai-attha-text { font-size: 1.47rem !important; }

.content-font-size-150 .pali-text { font-size: 2.48rem !important; }
.content-font-size-150 .thai-text,
.content-font-size-150 .thai-attha-text { font-size: 1.575rem !important; }

.content-font-size-160 .pali-text { font-size: 2.64rem !important; }
.content-font-size-160 .thai-text,
.content-font-size-160 .thai-attha-text { font-size: 1.68rem !important; }

.content-font-size-170 .pali-text { font-size: 2.81rem !important; }
.content-font-size-170 .thai-text,
.content-font-size-170 .thai-attha-text { font-size: 1.785rem !important; }

.content-font-size-180 .pali-text { font-size: 2.97rem !important; }
.content-font-size-180 .thai-text,
.content-font-size-180 .thai-attha-text { font-size: 1.89rem !important; }

.content-font-size-190 .pali-text { font-size: 3.14rem !important; }
.content-font-size-190 .thai-text,
.content-font-size-190 .thai-attha-text { font-size: 1.995rem !important; }

.content-font-size-200 .pali-text { font-size: 3.30rem !important; }
.content-font-size-200 .thai-text,
.content-font-size-200 .thai-attha-text { font-size: 2.1rem !important; }

/* Translation font sizes */
.translation-font-size-80 .translation-content  { font-size: 0.8rem !important; }
.translation-font-size-80 .similar-word          { font-size: 0.85rem !important; }
.translation-font-size-90 .translation-content   { font-size: 0.9rem !important; }
.translation-font-size-90 .similar-word           { font-size: 0.95rem !important; }
.translation-font-size-110 .translation-content  { font-size: 1.1rem !important; }
.translation-font-size-110 .similar-word          { font-size: 1.15rem !important; }
.translation-font-size-120 .translation-content  { font-size: 1.2rem !important; }
.translation-font-size-120 .similar-word          { font-size: 1.25rem !important; }
.translation-font-size-130 .translation-content  { font-size: 1.3rem !important; }
.translation-font-size-130 .similar-word          { font-size: 1.35rem !important; }
.translation-font-size-140 .translation-content  { font-size: 1.4rem !important; }
.translation-font-size-140 .similar-word          { font-size: 1.45rem !important; }
.translation-font-size-150 .translation-content  { font-size: 1.5rem !important; }
.translation-font-size-150 .similar-word          { font-size: 1.55rem !important; }
.translation-font-size-160 .translation-content  { font-size: 1.6rem !important; }
.translation-font-size-160 .similar-word          { font-size: 1.65rem !important; }
.translation-font-size-170 .translation-content  { font-size: 1.7rem !important; }
.translation-font-size-170 .similar-word          { font-size: 1.75rem !important; }
.translation-font-size-180 .translation-content  { font-size: 1.8rem !important; }
.translation-font-size-180 .similar-word          { font-size: 1.85rem !important; }
.translation-font-size-190 .translation-content  { font-size: 1.9rem !important; }
.translation-font-size-190 .similar-word          { font-size: 1.95rem !important; }
.translation-font-size-200 .translation-content  { font-size: 2.0rem !important; }
.translation-font-size-200 .similar-word          { font-size: 2.05rem !important; }

/* =============================================
   SYNTAX ANNOTATIONS
   ============================================= */
.syntax-lines-svg {
  background: var(--cream);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: visible;
}

.syntax-annotation-block {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: wrap !important;
  align-items: flex-start !important;
  gap: 6px;
  margin-top: 10px;
  padding: 10px 12px;
  background: linear-gradient(135deg, var(--cream) 0%, var(--parchment-deep) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
}

.syntax-word-item {
  display: inline-flex !important;
  flex-direction: column;
  align-items: center;
  flex: 0 0 auto;
  width: auto !important;
  max-width: fit-content;
  padding: 4px 8px;
  background: var(--cream);
  border-radius: var(--radius-sm);
  min-width: 40px;
  box-shadow: 0 1px 3px var(--shadow);
  transition: transform 0.15s;
}

.syntax-word-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px var(--shadow-md);
}

.syntax-word-text { font-size: 1rem; font-weight: 600; color: var(--pali-color); white-space: nowrap; line-height: 1.4; }
.syntax-relation-label { font-size: 0.7rem; font-weight: 500; white-space: nowrap; line-height: 1.3; margin-top: 2px; }
.syntax-link-label { font-size: 0.65rem; color: var(--muted); white-space: nowrap; line-height: 1.2; margin-top: 1px; }

.syntax-implied-item { background: #eff6ff; border: 1px dashed #93c5fd; }
.syntax-implied-item .syntax-word-text { color: #1e40af; font-style: italic; }

.syntax-sandhi-header { background: var(--parchment-deep); border: 1px solid var(--border); }
.syntax-sandhi-header .syntax-word-text { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--accent); text-decoration-thickness: 2px; }
.syntax-split-label { font-size: 0.6rem; color: var(--muted); font-style: italic; }

.syntax-sandhi-part-item { background: var(--cream); border: 1px solid var(--gold-light); margin-left: -2px; }
.syntax-sandhi-part-item .syntax-word-text { color: var(--pali-color); }

.syntax-inline-implied {
  display: inline;
  color: #1e40af;
  font-style: italic;
  background: #eff6ff;
  border: 1px dashed #93c5fd;
  border-radius: 3px;
  padding: 1px 4px;
  margin: 0 2px;
  font-size: 0.95em;
  vertical-align: baseline;
}

.syntax-inline-sandhi { display: inline; color: var(--pali-color); margin-left: 2px; vertical-align: baseline; }
.syntax-inline-sandhi-part { display: inline; }

/* Syntax Filter Offcanvas */
.syntax-filter-category { border-bottom: 1px solid var(--border-light); }

.syntax-filter-cat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  cursor: pointer;
  background: var(--parchment);
  transition: background 0.15s;
}
.syntax-filter-cat-header:hover { background: var(--parchment-deep); }

.syntax-filter-items { padding: 4px 12px 8px 28px; }

.syntax-filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  cursor: pointer;
  font-size: 0.85rem;
}
.syntax-filter-item:hover { color: var(--pali-color); }

.syntax-filter-color {
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.15);
}

.syntax-filter-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Color picker popup */
.syntax-color-picker-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.3);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.syntax-color-picker-popup {
  background: var(--cream);
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  box-shadow: 0 12px 40px var(--shadow-lg);
  min-width: 260px;
  max-width: 320px;
  border: 1px solid var(--border);
}

/* =============================================
   SELECT2 GLOBAL OVERRIDES
   ============================================= */
.select2-container .select2-selection--single {
  height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--cream);
}

.select2-container .select2-selection--single .select2-selection__rendered {
  line-height: 32px;
  padding-left: 10px;
  font-size: 0.875rem;
  color: var(--ink);
}

.select2-container .select2-selection--single .select2-selection__arrow {
  height: 32px;
}

.select2-dropdown {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 16px var(--shadow-md);
}

.select2-search--dropdown .select2-search__field {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-family: var(--font-body);
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 768px) {
  .en-book-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    padding: 1rem;
  }

  .en-hero-title { font-size: 1.5rem; }
  .en-hero { padding: 1.5rem 1rem; }

  .en-main { padding: 0 0.75rem 2rem; }

  #columnView, #lineView { padding: 1rem; border-radius: var(--radius-md); }

  .word-by-word-translation { margin: 8px 0; padding: 8px; }
  .word-by-word-translation .flex.items-start { flex-direction: column; gap: 4px; }
  .word-by-word-translation .text-xs { font-size: 0.7rem; }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .en-book-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 1025px) {
  .en-book-grid {
    grid-template-columns: repeat(8, 1fr);
  }
}

/* =============================================
   MISC UTILITIES
   ============================================= */
.bg-very-light {
  --bs-bg-opacity: 1;
  background-color: var(--parchment) !important;
}

.table {
  --bs-table-accent-bg: transparent;
}

/* Smooth scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--parchment); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* =============================================
   TAILWIND-EQUIVALENT UTILITY CLASSES
   (used by dynamically generated innerHTML)
   ============================================= */
/* Text colors */
.text-amber-800, .text-amber-900 { color: var(--pali-color); }
.text-blue-600 { color: #2563eb; }
.text-blue-900 { color: var(--thai-attha-color, #1e3a5f); }
.text-red-600 { color: #dc2626; }
.text-gray-400 { color: #9ca3af; }
.text-gray-500 { color: #6b7280; }
.text-gray-600 { color: #6b7280; }
.text-gray-700 { color: #374151; }
.text-black { color: #111; }
.text-white { color: #fff; }
.text-success { color: #16a34a; }

/* Font sizes */
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-lg { font-size: 1.125rem; }

/* Font weight */
.font-semibold { font-weight: 600; }

/* Spacing */
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.ml-1 { margin-left: 0.25rem; }
.ml-2 { margin-left: 0.5rem; }
.mr-2 { margin-right: 0.5rem; }
.p-3 { padding: 0.75rem; }
.px-1 { padding-left: 0.25rem; padding-right: 0.25rem; }
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
.py-0\.5 { padding-top: 0.125rem; padding-bottom: 0.125rem; }
.py-1 { padding-top: 0.25rem; padding-bottom: 0.25rem; }

/* Background colors */
.bg-gray-50 { background-color: #f9fafb; }
.bg-gray-500 { background-color: #6b7280; }
.bg-purple-500 { background-color: var(--gold); }
.bg-purple-600 { background-color: var(--gold-dark); }
.bg-orange-500 { background-color: #f97316; }
.bg-orange-600 { background-color: #ea580c; }
.bg-warning { background-color: #fef3c7; }

/* Layout */
.rounded { border-radius: var(--radius-sm); }
.border-l-4 { border-left: 4px solid; }
.border-purple-400 { border-left-color: var(--gold); }
.leading-relaxed { line-height: 1.625; }

/* Word-by-word translation block */
.word-by-word-translation {
  margin: 0.5rem 0;
  padding: 0.75rem;
  background: var(--cream);
  border-radius: var(--radius-md);
  border-left: 4px solid var(--gold);
}

/* Button state colors for word-by-word toggle */
.word-by-word-btn.bg-orange-500 { background: #f97316; }
.word-by-word-btn.bg-orange-500:hover { background: #ea580c; }
.word-by-word-btn.bg-gray-500 { background: #6b7280; }

/* Confidence score badges */
.bg-green-100 { background-color: #dcfce7; }
.text-green-800 { color: #166534; }
.bg-blue-100 { background-color: #dbeafe; }
.text-blue-800 { color: #1e40af; }
.bg-orange-100 { background-color: #ffedd5; }
.text-orange-800 { color: #9a3412; }
.bg-red-100 { background-color: #fee2e2; }
.text-red-800 { color: #991b1b; }

/* Spinner */
.spinner-loading {
  animation: spin 1s linear infinite;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════════
   SAMPAN (สัมพันธ์) INTEGRATION STYLES
   ═══════════════════════════════════════════════════════════ */

.sampan-toggle-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%;
  border: 1.5px solid var(--border); background: var(--cream);
  cursor: pointer; transition: all 0.2s;
  color: var(--muted); vertical-align: middle;
  margin-left: 4px; font-size: 0.85rem; padding: 0;
}
.sampan-toggle-btn:hover { background: #fef3dc; border-color: var(--gold); color: var(--gold); }
.sampan-toggle-btn.active { background: var(--gold); color: #fff; border-color: var(--gold); }

.sampan-panel {
  margin: 10px 0 18px; padding: 14px 16px;
  background: #fdfbf5; border: 1px solid #e2ddd4;
  border-radius: 10px; box-shadow: 0 2px 8px rgba(44,36,22,0.06);
  animation: sampanFadeIn 0.25s ease;
}
.sampan-panel-loading { text-align: center; padding: 24px; color: var(--muted); font-size: 0.9rem; }
.sampan-panel-empty { text-align: center; padding: 16px; color: var(--muted); font-size: 0.85rem; font-style: italic; }
@keyframes sampanFadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.sampan-section-toggle {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; background: #f8f6f2; border: 1px solid #ece8e0;
  border-radius: 6px; cursor: pointer; font-size: 0.82rem; font-weight: 600;
  color: var(--ink); margin-bottom: 4px; transition: all 0.15s;
}
.sampan-section-toggle:hover { background: #f5f0e8; }
.sampan-section-toggle .sampan-badge { background: #e2ddd4; color: #7a7062; padding: 2px 7px; border-radius: 10px; font-size: 0.7rem; }
.sampan-section-toggle .sampan-arrow { transition: transform 0.2s; font-size: 0.7rem; color: var(--muted); }
.sampan-section-toggle.open .sampan-arrow { transform: rotate(180deg); }
.sampan-section-body { display: none; padding: 10px 0 4px; }
.sampan-section-body.open { display: block; }

/* --- Interlinear --- */
.sampan-interlinear { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; }
.sampan-iu {
  display: flex; flex-direction: column; align-items: center;
  padding: 6px 8px; border-radius: 6px; border: 1.5px solid transparent;
  cursor: pointer; transition: all 0.15s; position: relative; min-width: 36px;
}
.sampan-iu:hover { background: #fef9f0; border-color: #e8d5a0; }
.sampan-iu.aligned { border-color: #e2ddd4; background: #fff; }
.sampan-iu.unaligned { opacity: 0.5; border-style: dashed; border-color: #e2ddd4; }
.sampan-iu.highlighted { border-color: var(--gold) !important; background: #fef3dc !important; box-shadow: 0 0 0 2px rgba(201,145,58,0.2); opacity: 1 !important; }
.sampan-iu.implied-unit { opacity: 0.55; border-style: dashed; }
.sampan-iu.implied-unit .iu-pali { font-style: italic; font-weight: 400; }
.sampan-iu .iu-pali { font-family: 'THSarabunPali', var(--font-body); font-size: 1.5rem; color: var(--pali-color); font-weight: 600; line-height: 1.3; text-align: center; }
.sampan-iu .iu-thai { font-size: 1.05rem; color: var(--thai-color); line-height: 1.3; text-align: center; margin-top: 2px; }
.sampan-iu .iu-role { font-size: 0.75rem; font-weight: 600; padding: 2px 6px; border-radius: 2px; color: #fff; margin-top: 3px; white-space: nowrap; }
.sampan-iu .iu-vib { position: absolute; top: -5px; right: -5px; width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid #fff; }

/* --- Sambandh Table --- */
.sampan-tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.sampan-sambandh-tbl { width: 100%; border-collapse: collapse; font-size: 1rem; }
.sampan-sambandh-tbl th { text-align: left; padding: 8px 12px; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--pali-color); font-weight: 700; border-bottom: 2px solid #e8d5b0; background: #fdf6e9; white-space: nowrap; }
.sampan-sambandh-tbl td { padding: 8px 12px; border-bottom: 1px solid #ece8e0; vertical-align: middle; }
.sampan-sambandh-tbl tbody tr { cursor: pointer; transition: background 0.1s; }
.sampan-sambandh-tbl tbody tr:hover { background: #fef9f0; }
.sampan-sambandh-tbl .verb-row { background: #f4f7fb; }
.sampan-sambandh-tbl .sabda-row { background: #f6f3fa; }
.sampan-sambandh-tbl .implied-row { opacity: 0.55; }
.sampan-sambandh-tbl .pali-cell { font-family: 'THSarabunPali', var(--font-body); color: var(--pali-color); font-weight: 600; font-size: 1.45rem; }

.sampan-vib-badge { display: inline-block; padding: 3px 10px; border-radius: 3px; font-size: 0.8rem; font-weight: 700; color: #fff; }
.sampan-vib-badge.vib-pathama { background: #1565C0; }
.sampan-vib-badge.vib-dutiya { background: #C62828; }
.sampan-vib-badge.vib-tatiya { background: #2E7D32; }
.sampan-vib-badge.vib-catutthi { background: #6A1B9A; }
.sampan-vib-badge.vib-pancami { background: #E65100; }
.sampan-vib-badge.vib-chatthi { background: #00695C; }
.sampan-vib-badge.vib-sattami { background: #4E342E; }
.sampan-vib-badge.vib-alapana { background: #AD1457; }
.sampan-vib-badge.vib-verb { background: #37474F; }
.sampan-vib-badge.vib-sabda { background: #607D8B; }

/* --- Dependency Arcs --- */
.sampan-dep-container { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 8px 0; padding: 8px 0 0; }
.sampan-dep-words { display: flex; gap: 0; align-items: flex-end; padding-top: 10px; position: relative; }
.sampan-dep-word { display: flex; flex-direction: column; align-items: center; padding: 0 14px; min-width: 46px; cursor: pointer; position: relative; }
.sampan-dep-word-text { font-family: 'THSarabunPali', var(--font-body); font-size: 1.3rem; font-weight: 500; color: var(--ink); padding: 4px 6px; border-radius: 3px; white-space: nowrap; transition: background 0.12s; }
.sampan-dep-word:hover .sampan-dep-word-text { background: #fef3dc; }
.sampan-dep-word-role { font-size: 0.85rem; color: #a39b8e; margin-top: 2px; white-space: nowrap; }
.sampan-dep-word .vib-dot { width: 7px; height: 7px; border-radius: 50%; margin-top: 2px; }
.sampan-dep-word.dep-implied .sampan-dep-word-text { color: #bbb; font-style: italic; }
.sampan-dep-word.dep-subject .sampan-dep-word-text { color: #1565C0; font-weight: 700; }
.sampan-dep-word.dep-verb .sampan-dep-word-text { color: #D32F2F; font-weight: 700; }
.sampan-dep-word.dep-highlight .sampan-dep-word-text { background: #fef3dc; box-shadow: 0 0 5px rgba(201,145,58,0.3); }
.sampan-dep-svg { position: absolute; top: 0; left: 0; pointer-events: none; overflow: visible; }
.sampan-dep-svg path { fill: none; stroke-width: 1.5; }
.sampan-dep-svg text { font-size: 13px; text-anchor: middle; font-family: 'Sarabun', sans-serif; }
.sampan-dep-svg .arc-label-bg { fill: #fdfbf5; stroke: none; }

/* --- Responsive --- */
@media (max-width: 768px) {
  .sampan-panel { padding: 10px; margin: 8px 0 14px; }
  .sampan-iu { padding: 4px 6px; min-width: 30px; }
  .sampan-iu .iu-pali { font-size: 1.25rem; }
  .sampan-iu .iu-thai { font-size: 0.9rem; }
  .sampan-iu .iu-role { font-size: 0.65rem; }
  .sampan-sambandh-tbl { font-size: 0.9rem; }
  .sampan-sambandh-tbl .pali-cell { font-size: 1.05rem; }
  .sampan-dep-word { padding: 0 8px; min-width: 36px; }
  .sampan-dep-word-text { font-size: 1.1rem; }
  .sampan-dep-word-role { font-size: 0.75rem; }
}
