:root,
[data-theme="light"] {
  --bg-main: #FCF9F2;
  --bg-surface: #FFFFFF;
  --bg-surface-variant: #F3EDE0;
  --bg-elevated: #FFFDF8;
  --text-primary: #1C241E;
  --text-secondary: #535E55;
  --primary: #1B5E20;
  --primary-soft: #E2F1E4;
  --primary-text: #0D3B10;
  --accent: #B8860B;
  --accent-soft: #FDF3D7;
  --border: #E5DEC9;
  --shadow: 0 4px 18px rgba(28, 36, 30, 0.06);
  --poem-font: 'Noto Serif Bengali', serif;
  --poem-size: 20px;
  --poem-line-height: 1.85;
}

[data-theme="sepia"] {
  --bg-main: #F4ECD8;
  --bg-surface: #FAF3E3;
  --bg-surface-variant: #E8DEC5;
  --bg-elevated: #FDF8EC;
  --text-primary: #3B2F2F;
  --text-secondary: #6A584C;
  --primary: #7B3F00;
  --primary-soft: #EFE1CE;
  --primary-text: #4E2700;
  --accent: #A66E2E;
  --accent-soft: #F5E6C8;
  --border: #DFCFAF;
  --shadow: 0 4px 18px rgba(59, 47, 47, 0.08);
}

[data-theme="dark"] {
  --bg-main: #121814;
  --bg-surface: #1B231E;
  --bg-surface-variant: #253029;
  --bg-elevated: #212B25;
  --text-primary: #ECEFE9;
  --text-secondary: #A6B3A9;
  --primary: #66BB6A;
  --primary-soft: #1F3B23;
  --primary-text: #A5D6A7;
  --accent: #FFD54F;
  --accent-soft: #3A3219;
  --border: #2D3A31;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

[data-theme="oled"] {
  --bg-main: #000000;
  --bg-surface: #0D0F0E;
  --bg-surface-variant: #181C19;
  --bg-elevated: #121513;
  --text-primary: #F5F5F5;
  --text-secondary: #9E9E9E;
  --primary: #81C784;
  --primary-soft: #142817;
  --primary-text: #B9F6CA;
  --accent: #FFD54F;
  --accent-soft: #2E2610;
  --border: #222623;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.7);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: 'Hind Siliguri', 'Noto Serif Bengali', sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  padding-bottom: 84px;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.header-inner {
  max-width: 1140px;
  margin: 0 auto;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.brand-emblem {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #1B5E20, #2E7D32);
  color: #FFD54F;
  font-family: 'Noto Serif Bengali', serif;
  font-size: 24px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(27, 94, 32, 0.25);
}

.brand-title {
  font-family: 'Noto Serif Bengali', serif;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
}

.desktop-nav {
  display: flex;
  gap: 6px;
}

.nav-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s;
}

.nav-btn:hover {
  background: var(--bg-surface-variant);
  color: var(--text-primary);
}

.nav-btn.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-pill {
  border: 1px solid var(--border);
  background: var(--accent-soft);
  color: var(--text-primary);
  font-family: inherit;
  font-weight: 600;
  font-size: 13px;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
}

.icon-circle-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-surface-variant);
  color: var(--text-primary);
  font-size: 17px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Main Container */
.main-container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 20px 16px;
}

.hidden {
  display: none !important;
}

.loading-box {
  text-align: center;
  padding: 80px 20px;
}

.spinner {
  width: 42px;
  height: 42px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 14px;
}

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

/* Section Headers */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 26px 0 12px;
  gap: 10px;
}

.section-title {
  font-family: 'Noto Serif Bengali', serif;
  font-size: 21px;
  font-weight: 700;
}

/* Hero Poem of the Day */
.hero-card {
  background: linear-gradient(135deg, #164A21 0%, #246932 60%, #1B4332 100%);
  color: #FFFDF7;
  border-radius: 24px;
  padding: 26px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 28px rgba(22, 74, 33, 0.22);
}

.hero-badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.hero-badge {
  background: rgba(255, 213, 79, 0.22);
  color: #FFE082;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}

.hero-title {
  font-family: 'Noto Serif Bengali', serif;
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 4px;
}

.hero-poet {
  color: #FFE082;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: inline-block;
  margin-bottom: 14px;
}

.hero-verse {
  font-family: 'Noto Serif Bengali', serif;
  font-size: 18px;
  line-height: 1.8;
  white-space: pre-line;
  background: rgba(0, 0, 0, 0.18);
  padding: 16px 18px;
  border-radius: 16px;
  border-left: 4px solid #FFD54F;
  margin-bottom: 18px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Buttons */
.btn-primary, .btn-tonal, .btn-outline, .btn-gold {
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.12s, opacity 0.12s;
}

.btn-primary:active, .btn-tonal:active, .btn-outline:active, .btn-gold:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: #FFFFFF;
}

.btn-gold {
  background: #FFD54F;
  color: #1B301E;
}

.btn-tonal {
  background: var(--primary-soft);
  color: var(--primary);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.hero-actions .btn-outline {
  border-color: rgba(255, 255, 255, 0.35);
  color: #FFFFFF;
}

/* Quick Discovery Banner Row */
.discovery-banner-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.discovery-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}

.discovery-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}

/* Chips */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s;
}

.chip:hover {
  border-color: var(--primary);
}

.chip.active {
  background: var(--primary);
  color: #FFFFFF;
  border-color: var(--primary);
}

/* Cards Grid */
.poet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.poem-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.poet-card, .poem-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  box-shadow: var(--shadow);
  transition: transform 0.15s, border-color 0.15s;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.poet-card:hover, .poem-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}

.poet-card-top {
  display: flex;
  align-items: flex-start;
  gap: 13px;
}

.poet-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  color: #FFFFFF;
  font-family: 'Noto Serif Bengali', serif;
  font-size: 21px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 3px 8px rgba(0,0,0,0.15);
}

.poet-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 50%;
}

.honorific-pill {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  margin-bottom: 4px;
}

.poet-name {
  font-family: 'Noto Serif Bengali', serif;
  font-size: 17px;
  font-weight: 700;
}

.poet-dates {
  font-size: 12.5px;
  color: var(--text-secondary);
}

.poet-works-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.poet-count-badge {
  margin-top: 10px;
  display: inline-block;
  align-self: flex-start;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 8px;
}

/* Poem Card */
.poem-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.poem-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.badge-tag {
  background: var(--bg-surface-variant);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 8px;
}

.badge-rhyme {
  background: var(--accent-soft);
  color: var(--text-primary);
}

.poem-title {
  font-family: 'Noto Serif Bengali', serif;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 2px;
}

.poem-poet-link {
  color: var(--primary);
  font-size: 13.5px;
  font-weight: 600;
}

.poem-poet-link:hover {
  text-decoration: underline;
}

.poem-firstline {
  font-family: 'Noto Serif Bengali', serif;
  font-size: 14.5px;
  color: var(--text-secondary);
  margin-top: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.poem-card-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.icon-btn {
  border: none;
  background: transparent;
  font-size: 18px;
  padding: 6px;
  border-radius: 50%;
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--bg-surface-variant);
}

/* Reader View */
.reader-wrapper {
  max-width: 780px;
  margin: 0 auto;
}

.reader-topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.reader-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
}

.reader-title {
  font-family: var(--poem-font);
  font-size: 30px;
  font-weight: 700;
  margin-bottom: 6px;
}

.reader-poet-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 12px;
}

.reader-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.reader-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
  background: var(--bg-surface-variant);
  padding: 12px;
  border-radius: 16px;
}

.stanza-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.stanza-box {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid transparent;
  transition: all 0.15s;
  cursor: pointer;
}

.stanza-box:hover {
  background: var(--bg-surface-variant);
}

.stanza-box.selected, .stanza-box.speaking {
  background: var(--primary-soft);
  border-color: var(--primary);
}

.stanza-text {
  font-family: var(--poem-font);
  font-size: var(--poem-size);
  line-height: var(--poem-line-height);
  white-space: pre-line;
}

.stanza-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

/* Study Guide Card */
.study-card {
  margin-top: 24px;
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
}

/* Poet Museum Profile */
.museum-banner {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.couplet-banner {
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  padding: 16px 18px;
  border-radius: 16px;
  margin: 16px 0;
}

/* Search Box */
.search-input-wrap {
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border: 2px solid var(--border);
  border-radius: 999px;
  padding: 6px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.search-input-wrap:focus-within {
  border-color: var(--primary);
}

.search-input {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 16px;
  padding: 8px 10px;
  outline: none;
}

/* Modal / Share Card Studio */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-sheet {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-radius: 24px;
  width: 100%;
  max-width: 960px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 22px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.modal-sub {
  font-size: 13px;
  color: var(--text-secondary);
}

.close-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-surface-variant);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 16px;
}

.studio-body {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 22px;
}

.canvas-preview-wrap {
  background: var(--bg-surface-variant);
  border-radius: 16px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#shareCardCanvas {
  max-width: 100%;
  max-height: 380px;
  width: auto;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.studio-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.control-group {
  margin-bottom: 14px;
}

.control-group.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.control-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.line-picker-list {
  max-height: 150px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  background: var(--bg-main);
}

.line-Check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  font-family: 'Noto Serif Bengali', serif;
  font-size: 14px;
  cursor: pointer;
  border-radius: 8px;
}

.line-Check-item:hover {
  background: var(--bg-surface-variant);
}

/* Kids Mode Overlay */
.kids-overlay {
  position: fixed;
  inset: 0;
  z-index: 95;
  background: #FFF8E1;
  color: #3E2723;
  overflow-y: auto;
  padding: 20px;
}

/* Bottom Navigation (Mobile) */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 60;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  display: none;
  justify-content: space-around;
  padding: 6px 4px;
}

.bottom-nav-item {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 12px;
  border-radius: 12px;
  cursor: pointer;
}

.bottom-nav-item.active {
  color: var(--primary);
  background: var(--primary-soft);
  font-weight: 700;
}

.nav-icon {
  font-size: 18px;
}

.nav-label {
  font-size: 11.5px;
}

/* Toast */
.toast-bar {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  background: #1B5E20;
  color: #FFFFFF;
  padding: 10px 20px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

@media (max-width: 820px) {
  .desktop-nav {
    display: none;
  }
  .bottom-nav {
    display: flex;
  }
  .studio-body {
    grid-template-columns: 1fr;
  }
  .hero-title {
    font-size: 23px;
  }
}

/* Printable A4 PDF / Print Styles (Phase 3 FR-PDF-1) */
@media print {
  header.app-header,
  nav.bottom-nav,
  .reader-topbar,
  .reader-toolbar,
  .stanza-actions,
  .toast-bar,
  #shareStudioModal,
  #kidsModeOverlay,
  .action-pill,
  button {
    display: none !important;
  }

  body {
    background: #FFFFFF !important;
    color: #111827 !important;
    font-size: 12pt !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .main-container {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .reader-wrapper {
    max-width: 100% !important;
  }

  .reader-card {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }

  .reader-title {
    font-size: 24pt !important;
    color: #7A1C14 !important;
    margin-bottom: 6pt !important;
  }

  .reader-poet-chip {
    font-size: 14pt !important;
    font-weight: bold !important;
    color: #374151 !important;
    border: none !important;
    background: none !important;
    padding: 0 !important;
    margin-bottom: 12pt !important;
  }

  .stanza-box {
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
    margin-bottom: 16pt !important;
    page-break-inside: avoid;
  }

  .stanza-text {
    font-size: 13pt !important;
    line-height: 1.8 !important;
    color: #1F2937 !important;
  }

  .study-card {
    border: 1pt solid #E5E7EB !important;
    background: #F9FAFB !important;
    padding: 12pt !important;
    page-break-inside: avoid;
  }
}
