/* Ramaneeya Font - Legacy Telugu font for branding */
@font-face {
  font-family: 'RamaneeyaWin';
  src: url('../fonts/RamaneeyaWin.eot');
  src: url('../fonts/RamaneeyaWin.eot?#iefix') format('embedded-opentype'),
       url('../fonts/RamaneeyaWin.woff') format('woff'),
       url('../fonts/RamaneeyaWin.ttf') format('truetype'),
       url('../fonts/RamaneeyaWin.svg#RamaneeyaWin') format('svg');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* Minimal functional styles - design polish deferred to future phase */

:root {
  --color-bg: #ffffff;
  --color-text: #1a1a1a;
  --color-header-bg: #000000;
  --color-header-text: #ffffff;
  --color-success: #2d6a4f;
  --color-error: #c1121f;
  --color-border: #cccccc;
  --color-poem: darkblue;

  /* 4 Font Purposes */
  --font-logo: 'RamaneeyaWin', 'Noto Sans Telugu', sans-serif;  /* 1. Logo/Brand (Ramaneeya - legacy) */
  --font-display: 'Timmana', 'Noto Sans Telugu', sans-serif;    /* 2. Display/Headers (meter names) */
  --font-editor: 'Suranna', 'Noto Sans Telugu', serif;          /* 3. Editor text */
  --font-main: 'Noto Sans Telugu', sans-serif;                  /* 4. Body/Table text */

  /* Suranna font styling variables */
  --font-editor-size: 1.1rem;
  --font-editor-letter-spacing: 0.05em;
  --font-editor-line-height: 1.8;
}

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

body {
  font-family: var(--font-main);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Header */
header {
  background: var(--color-header-bg);
  color: var(--color-header-text);
  padding: 1rem 0;
}

header h1 {
  font-family: var(--font-logo);
  font-size: 1.5rem;
  display: inline-block;
  margin-right: 2rem;
  /* Embossed 3D effect */
  text-shadow:
    -1px -1px 0 rgba(0, 0, 0, 0.3),    /* Dark shadow top-left (depth) */
    1px 1px 0 rgba(255, 255, 255, 0.8), /* Light highlight bottom-right (raised edge) */
    2px 2px 3px rgba(0, 0, 0, 0.2);     /* Soft shadow for depth */
  letter-spacing: 0.02em;
}

nav {
  display: inline-block;
}

nav a {
  color: var(--color-header-text);
  text-decoration: none;
  margin-right: 1rem;
  padding: 0.5rem;
}

nav a:hover {
  background: rgba(255, 255, 255, 0.1);
}

#nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--color-header-text);
  color: var(--color-header-text);
  font-size: 1.5rem;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  float: right;
}

.lang-toggle {
  display: none; /* Hidden for now - Telugu is default */
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: var(--color-header-text);
  font-family: var(--font-main);
  font-size: 0.85rem;
  padding: 0.25rem 0.6rem;
  cursor: pointer;
  border-radius: 3px;
  margin-left: 0.5rem;
  vertical-align: middle;
  transition: background 0.15s;
}

.lang-toggle:hover {
  background: rgba(255, 255, 255, 0.15);
}

@media (max-width: 768px) {
  #nav-toggle {
    display: block;
  }

  nav {
    display: none;
    width: 100%;
    margin-top: 1rem;
  }

  nav.open {
    display: block;
  }

  nav a {
    display: block;
    padding: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
  }
}

/* Main Content */
main {
  flex: 1;
  padding: 2rem 1rem;
}

/* Footer */
footer {
  background: var(--color-header-bg);
  color: var(--color-header-text);
  text-align: center;
  padding: 1rem;
  margin-top: 2rem;
}

footer a {
  color: var(--color-header-text);
}

/* Analyze Page */
.rule-set-section {
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: #f9f9f9;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.rule-set-section label {
  font-weight: bold;
  white-space: nowrap;
}

.rule-set-switcher {
  padding: 0.5rem;
  font-family: var(--font-main);
  font-size: 1rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  min-width: 200px;
}

#loading-indicator {
  color: #666;
  font-size: 0.9rem;
}

/* ========================================
   ANIMATED BRAND LOADERS
   ======================================== */

/* Container for loading animation - ALWAYS CENTERED */
.loader-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.3);

  /* Flexbox centering */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  z-index: 9999;
  opacity: 1;
  transition: opacity 0.5s ease-out;
}

/* Fade-out animation */
.loader-container.fade-out {
  opacity: 0;
}

/* Loader GIF - centered by parent flexbox */
.loader-gif {
  width: auto;
  height: auto;
  max-width: 148px;

  /* Preserve GIF quality */
  image-rendering: crisp-edges;
  image-rendering: -moz-crisp-edges;
  image-rendering: -webkit-optimize-contrast;

  /* Prevent unwanted margins */
  margin: 0;
  display: block;
}

/* Fallback text (if GIF fails to load) */
.loader-fallback {
  color: #ffffff;
  font-family: var(--font-main);
  font-size: 1.2rem;
  margin-top: 1rem;
  text-align: center;
}

/* Initial loader specific styling */
#initial-loader .loader-container {
  background: rgba(0, 0, 0, 0.4); /* Slightly more opaque for initial load */
}

/* Dynamic loader overlay (appears over content) */
#dynamic-loader-container .loader-container {
  background: rgba(0, 0, 0, 0.3); /* Transparent overlay */
}

/* Mobile responsive */
@media (max-width: 768px) {
  .loader-fallback {
    font-size: 1rem;
  }
}

.editor-section {
  margin-bottom: 1.5rem;
}

#poem-editor {
  width: 100%;
  min-height: 10rem;  /* Start with ~5 lines height */
  padding: 0.75rem;
  font-family: var(--font-editor);  /* Suranna serif font for poetry */
  font-size: var(--font-editor-size);
  letter-spacing: var(--font-editor-letter-spacing);
  line-height: var(--font-editor-line-height);
  border-radius: 4px;
  resize: vertical;
}

/* Accordion */
.accordion {
  margin-bottom: 1rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
}

.accordion-header {
  padding: 0.75rem;
  background: #f5f5f5;
  cursor: pointer;
  font-weight: bold;
  user-select: none;
}

.accordion-header:hover {
  background: #eeeeee;
}

.accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  padding: 0;
}

.accordion-header.open + .accordion-content {
  padding: 1rem;
}

/* Accordion content items */
.accordion-content label {
  display: block;
  margin-bottom: 0.5rem;
}

.accordion-content label input {
  margin-right: 0.5rem;
}

/* Actions */
.actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 1.5rem 0;
}

.actions button {
  padding: 0.75rem 1.5rem;
  font-family: var(--font-main);
  font-size: 1rem;
  background: var(--color-header-bg);
  color: var(--color-header-text);
  border: none;
  border-radius: 20px;
  cursor: pointer;
}

.actions button:hover {
  opacity: 0.9;
}

.actions button:disabled {
  background: #cccccc;
  cursor: not-allowed;
}

/* Rule Picker */
.rule-picker {
  width: 100%;
  padding: 0.5rem;
  font-family: var(--font-main);
  font-size: 1rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
}

/* ========================================
   RESULTS CARD (REDESIGNED)
   ======================================== */

/* Results Card Container */
.match-card {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  border: 2px solid transparent;
  transition: all 0.3s;
}

.match-card.match-success {
  border-color: #2d6a4f;
  background: linear-gradient(to bottom, rgba(45, 106, 79, 0.02), white);
}

.match-card.match-failure {
  border-color: #c1121f;
  background: linear-gradient(to bottom, rgba(193, 18, 31, 0.02), white);
}

/* Match Header */
.match-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #e8e8e8;
}

.match-title-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
}

.match-icon {
  font-size: 1.5rem;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
}

.match-success .match-icon {
  background: #d8f3dc;
  color: #2d6a4f;
}

.match-failure .match-icon {
  background: #ffe5e5;
  color: #c1121f;
}

.match-title-group .meter-name {
  margin: 0;
  font-size: 1.5rem;
}

/* Rule Details Link (opens in new tab) */
.rule-details-link {
  color: var(--color-header-bg);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  padding: 0.5rem 1rem;
  border: 1px solid currentColor;
  border-radius: 6px;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.rule-details-link:hover {
  background: var(--color-header-bg);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Match Actions (buttons + link group in results header) */
.match-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-add-example,
.btn-submit-github {
  border: none;
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-add-example {
  background: var(--color-header-bg, #2d6a4f);
  color: white;
}

.btn-add-example:hover {
  filter: brightness(0.85);
}

.btn-add-example.btn-success {
  background: #40916c;
  cursor: default;
}

.btn-add-example.btn-warning {
  background: #e9c46a;
  color: #333;
  cursor: default;
}

.btn-add-example[disabled],
.btn-submit-github[disabled] {
  opacity: 0.7;
  pointer-events: none;
}

.btn-submit-github {
  background: #24292f;
  color: white;
}

.btn-submit-github:hover {
  background: #1a1f23;
}

/* Examples footer (learn detail page) */
.examples-footer {
  margin-top: 1.5rem;
  display: flex;
  justify-content: flex-end;
}

/* Score Badge */
.match-score {
  font-size: 1.25rem;
  font-weight: 700;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-family: 'Segoe UI', system-ui, sans-serif;
  flex-shrink: 0;
}

.match-score-high {
  background: #d8f3dc;
  color: #2d6a4f;
}

.match-score-medium {
  background: #ffe5cc;
  color: #d97706;
}

.match-score-low {
  background: #ffe5e5;
  color: #c1121f;
}

/* Split View Layout */
.match-body-split {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin: 1rem 0;
  align-items: flex-start;
}

.match-body-full {
  margin: 1rem 0;
}

.match-table-container {
  flex: 1 1 55%;
  min-width: 400px;
  overflow-x: auto;
  border-radius: 8px;
}

.match-errors-container {
  flex: 1 1 40%;
  min-width: 350px;
}

/* Errors Section */
.errors-section {
  padding: 1rem;
  background: #fff9f0;
  border: 1px solid #ffe5cc;
  border-left: 4px solid #ff8000;
  border-radius: 8px;
  height: fit-content;
}

.errors-header {
  margin: 0 0 1rem 0;
  font-size: 1rem;
  font-weight: 600;
  color: #333;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Errors Table */
.errors-table-wrapper {
  overflow-x: auto;
  border-radius: 6px;
}

.errors-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: white;
}

.errors-table thead {
  background: #f5f5f5;
  font-weight: 600;
  color: #555;
}

.errors-table th {
  padding: 0.5rem;
  text-align: left;
  border-bottom: 2px solid #e0e0e0;
  font-size: 0.85rem;
  white-space: nowrap;
}

.errors-table td {
  padding: 0.5rem;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: top;
}

.errors-table tbody tr:hover {
  background: #fef9f0;
}

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

/* Error Table Columns */
.error-line,
.error-position {
  text-align: center;
  font-weight: 600;
  color: #666;
  font-family: monospace;
  width: 50px;
}

.error-type {
  font-weight: 600;
  color: #d97706;
  font-family: var(--font-main);
  white-space: nowrap;
  min-width: 80px;
}

.error-expected {
  background: #d8f3dc;
  color: #2d6a4f;
  font-weight: 600;
  font-family: var(--font-main);
  padding: 0.25rem 0.5rem;
  border-radius: 3px;
  text-align: center;
  min-width: 60px;
}

.error-actual {
  background: #ffe5e5;
  color: #c1121f;
  font-weight: 700;
  font-family: var(--font-main);
  padding: 0.25rem 0.5rem;
  border-radius: 3px;
  text-align: center;
  min-width: 60px;
}

.error-description {
  color: #555;
  line-height: 1.5;
}

.error-description em {
  display: block;
  margin-top: 0.25rem;
  color: #666;
  font-size: 0.85rem;
}

/* ========================================
   LEGACY CLASSES FOR 100% MATCH VIEW
   (Beautified poem + Gana vibhajana side-by-side)
   ======================================== */

/* Outer wrapper for decorated poem section */
.padyam {
  flex: 1 1 45%;
  min-width: 350px;
  padding: 1.25rem;
  background: #fafff9;         /* Light green tint */
  border-left: 5px solid #2d6a4f;  /* Thick left border like quote */
  border-top: 1px solid #d8f3dc;
  border-right: 1px solid #d8f3dc;
  border-bottom: 1px solid #d8f3dc;
  border-radius: 4px;
  overflow-x: auto;
}

/* Inner poem text container */
.poem {
  font-family: var(--font-editor);  /* Suranna serif for poetry */
  font-size: var(--font-editor-size);
  letter-spacing: var(--font-editor-letter-spacing);
  line-height: var(--font-editor-line-height);
  color: var(--color-poem);
  white-space: normal;
  word-wrap: break-word;
}

/* ========================================
   FILTER BAR (Learn Index Page)
   ======================================== */

.filter-bar {
  margin-bottom: 1.5rem;
}

.filter-bar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
}

.filter-bar .filter-search {
  flex: 0 1 200px;
  padding: 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 0.9rem;
  font-family: var(--font-main);
}

.filter-bar .filter-search:focus {
  outline: none;
  border-color: var(--color-success);
}

.btn-clear-filters {
  background: white;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0.4rem 0.75rem;
  color: #555;
  transition: all 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.btn-clear-filters:hover {
  background: #f5f5f5;
  border-color: #b0b0b0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.btn-clear-filters:active {
  transform: scale(0.97);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

.filter-bar .rule-count {
  font-size: 0.8rem;
  color: #999;
  white-space: nowrap;
}

.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: #666;
}

.empty-state p {
  margin: 0.5rem 0;
  font-size: 1rem;
}

.empty-state p:first-child {
  font-size: 1.1rem;
  font-weight: 600;
  color: #555;
}

@media (max-width: 768px) {
  .filter-bar-row {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-bar .filter-search {
    flex: 1 1 100%;
  }
}

/* Preserve decorations from Beautify() method */
.poem u {
  text-decoration: underline;
  text-decoration-color: #ff8000;  /* Yati underline - orange */
  text-underline-offset: 2px;
  text-decoration-thickness: 1.5px;
}

.poem b {
  font-weight: 700;
  color: #6a4c93;  /* Prasa bold - purple */
}

/* Gana vibhajana table wrapper (100% match scenario) */
.ganaVibhajana {
  flex: 1 1 50%;
  min-width: 400px;
  overflow-x: auto;
  border-radius: 8px;
}

/* Ensure table inside ganaVibhajana has proper styling */
.ganaVibhajana .tab {
  margin: 0;  /* Remove default margin when inside wrapper */
}

/* Utility */
.btn-primary {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  background: var(--color-header-bg);
  color: var(--color-header-text);
  text-decoration: none;
  border-radius: 4px;
  font-weight: bold;
}

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

/* Meter Name Typography - Telugu Display Font */
.meter-name {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.3;
}

/* ========================================
   LEGACY TABLE CLASSES (Core-generated HTML)
   ======================================== */

/* Results table - Core-generated HTML */
.tab {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.stamper {
  background: #f5f5f5;
  color: #666;
  width: 40px;
  text-align: center;
  border-right: 2px solid #e0e0e0;
  font-size: 1.2rem;
  padding: 0.5rem 0.25rem;
}

/* Gana row (pattern names) */
.ga {
  background: #f9f9f9;
  font-size: 0.95rem;
  font-weight: 500;
  color: #2d6a4f;
}

/* Matra pattern row */
.up {
  background: #fef9f9;
  font-size: 0.9rem;
  color: #c1121f;
  font-family: 'Courier New', monospace;
}

/* Text row */
.dw {
  background: #ffffff;
  font-size: 1.05rem;
  font-family: var(--font-main);
  font-weight: 500;
  padding: 0.5rem 0.75rem;
}

/* Table cells */
.X, .X3 {
  border: 1px solid #e8e8e8;
  padding: 0.4rem 0.6rem;
  text-align: center;
  transition: background-color 0.2s;
}

.X3 {
  border-bottom: 2px solid #ddd;
}

/* Match status */
.gOk {
  background-color: rgba(45, 106, 79, 0.05);
}

.gErr {
  background-color: rgba(193, 18, 31, 0.08);
  color: #c1121f;
  font-weight: 600;
}

.X.gErr {
  border-color: #c1121f;
  box-shadow: inset 0 0 0 1px rgba(193, 18, 31, 0.2);
}

/* Yati marker */
.yati {
  color: #ff8000;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: rgba(255, 128, 0, 0.4);
  text-underline-offset: 2px;
}

/* Prasa marks */
.y1 u {
  color: #6a4c93;
  text-decoration: underline;
  text-decoration-style: double;
}

/* ========================================
   NEW PAGES STYLES (Phase 5-11)
   ======================================== */

/* Home page */
.home-page {
  max-width: 900px;
  margin: 0 auto;
}

.home-page h1 {
  text-align: center;
  margin-bottom: 0.5rem;
}

.home-page .subtitle {
  text-align: center;
  color: #666;
  margin-bottom: 3rem;
}

.rule-set-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  margin-top: 2rem;
}

.rule-set-card {
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  padding: 2rem;
  transition: all 0.3s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.rule-set-card:hover {
  border-color: var(--color-header-bg);
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  transform: translateY(-4px);
}

.rule-set-card h2 {
  margin-top: 0;
  margin-bottom: 0.5rem;
  color: var(--color-header-bg);
}

.rule-set-card .rule-count {
  color: #666;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.rule-set-card .description {
  color: #555;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.rule-set-card .card-actions {
  display: flex;
  gap: 1rem;
}

.rule-set-card .btn-analyze,
.rule-set-card .btn-learn {
  flex: 1;
  text-align: center;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  text-decoration: none;
  font-weight: bold;
  transition: all 0.2s;
}

.rule-set-card .btn-analyze {
  background: var(--color-header-bg);
  color: var(--color-header-text);
}

.rule-set-card .btn-analyze:hover {
  opacity: 0.9;
  transform: translateY(-2px);
}

.rule-set-card .btn-learn {
  background: #f0f0f0;
  color: var(--color-text);
}

.rule-set-card .btn-learn:hover {
  background: #e0e0e0;
}

/* Favorites ruleset card - distinctive styling */
.rule-set-card.favorites-ruleset {
  border: 3px solid #e74c3c;
  background: linear-gradient(135deg, #fff5f5 0%, #ffffff 100%);
  box-shadow: 0 4px 12px rgba(231, 76, 60, 0.15);
}

.rule-set-card.favorites-ruleset:hover {
  border-color: #c0392b;
  box-shadow: 0 6px 20px rgba(231, 76, 60, 0.25);
  transform: translateY(-4px);
}

.rule-set-card.favorites-ruleset h2 {
  color: #e74c3c;
}

.rule-set-card.favorites-ruleset .btn-analyze {
  background: #e74c3c;
  color: white;
}

.rule-set-card.favorites-ruleset .btn-analyze:hover {
  background: #c0392b;
}

/* Rule set info labels */
.rule-set-info, .current-rule-info {
  padding: 0.75rem;
  background: #f9f9f9;
  border-radius: 4px;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.rule-set-info .label, .current-rule-info .label {
  font-weight: bold;
  color: #666;
}

.rule-set-info .name, .current-rule-info .name {
  font-weight: bold;
  color: var(--color-text);
}

.rule-set-info .count {
  color: #666;
  font-style: italic;
}

/* Page links */
.page-links {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 0.5rem;
  flex-wrap: wrap;
}

.page-links a {
  text-decoration: none;
  color: var(--color-text);
  padding: 0.5rem 1rem;
  border-radius: 4px;
  transition: background 0.2s;
}

.page-links a:hover {
  background: #e0e0e0;
}

.learn-link::before { content: "📖 "; }
.browse-link::before { content: "📚 "; }

/* Quick actions section */
.quick-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  margin-bottom: 1rem;
  padding: 0.5rem;
}

.quick-actions button {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  opacity: 0.6;
  transition: opacity 0.2s, transform 0.1s;
}

.quick-actions button:hover {
  opacity: 1;
}

.quick-actions button:active {
  transform: scale(0.95);
}

/* Main actions (Determine, Match) - more prominent */
.main-actions {
  display: flex;
  gap: 1rem;
  margin: 1.5rem 0;
}

.main-actions button {
  padding: 0.75rem 2rem;
  font-family: var(--font-main);
  font-size: 1.1rem;
  font-weight: bold;
  background: var(--color-header-bg);
  color: var(--color-header-text);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.main-actions button:hover {
  opacity: 0.9;
  transform: translateY(-2px);
}

.main-actions button:disabled {
  background: #cccccc;
  cursor: not-allowed;
  transform: none;
}

/* Rule selection section */
.rule-selection {
  margin-bottom: 1.5rem;
}

.rule-selection label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: bold;
}

/* Results section - hidden by default */
#results-section {
  display: none;
  margin-top: 2rem;
  padding: 1rem;
  background: #f9f9f9;
  border-radius: 8px;
}

#results-section h3 {
  margin-top: 0;
  margin-bottom: 1rem;
}


/* "Try in Analyzer" styled as prominent button */
.compute-link {
  background: var(--color-header-bg) !important;
  color: var(--color-header-text) !important;
  font-weight: bold;
  padding: 0.75rem 1.5rem !important;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.compute-link::before {
  content: "✏️ ";
}

.compute-link:hover {
  opacity: 0.9;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* Learn detail page */
.learn-detail-page h1 {
  margin-bottom: 0.5rem;
}

.rule-metadata {
  color: #666;
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

.rule-metadata span {
  margin-right: 1rem;
}

.technical-details dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem 1rem;
  margin-top: 1rem;
}

.technical-details dt {
  font-weight: bold;
  color: #666;
}

.technical-details dd {
  margin: 0;
}

.technical-details code {
  background: #f5f5f5;
  padding: 0.25rem 0.5rem;
  border-radius: 3px;
  font-family: monospace;
}

.example-card {
  background: #f9f9f9;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.example-poem-area {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 1.2rem;
}

.poem-text {
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 1rem;
  font-family: var(--font-main);
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--color-poem);
  white-space: pre-wrap;
  overflow-x: auto;
}

.poem-attribution {
  text-align: right;
  color: #666;
  font-style: italic;
  font-size: 0.95rem;
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid #eee;
}

.example-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.example-reference {
  color: #666;
  font-size: 0.85rem;
  flex: 1 1 auto;
}

/* Special rules from RuleText */
.special-rules {
  margin: 0.75rem 0;
}

.special-rules-content {
  border-left: 3px solid var(--accent, #6a4c93);
  padding: 0.5rem 1rem;
  margin-top: 0.5rem;
}

.special-rules-content .gName {
  font-weight: 700;
  color: var(--accent, #6a4c93);
}

/* Yati cell in row-wise gana table */
.yati-cell {
  color: #666;
  font-size: 0.9rem;
  padding-left: 1rem;
}

.try-example-btn {
  display: inline-block;
  background: var(--color-header-bg);
  color: var(--color-header-text);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.2s;
  margin-top: 0.5rem;
}

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

/* Learn index page */
.learn-index-page h1 {
  margin-bottom: 0.5rem;
}

.learn-index-page .rule-count {
  color: #666;
  margin-bottom: 2rem;
}

.chandam-group {
  margin-bottom: 3rem;
}

.chandam-group > h2 {
  color: var(--color-header-bg);
  border-bottom: 2px solid var(--color-header-bg);
  padding-bottom: 0.5rem;
  margin-bottom: 1.5rem;
}

.type-group {
  margin-bottom: 2rem;
  margin-left: 1rem;
}

.type-group h3 {
  color: #555;
  margin-bottom: 1rem;
}

.rule-list-item {
  background: #f9f9f9;
  border-left: 4px solid var(--color-header-bg);
  padding: 1rem;
  margin-bottom: 0.75rem;
  border-radius: 4px;
}

.rule-list-item .rule-name {
  font-size: 1.1rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
}

.rule-list-item .rule-meta {
  color: #666;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.rule-list-item .rule-links {
  display: flex;
  gap: 0.75rem;
}

.rule-list-item .rule-links a {
  text-decoration: none;
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.rule-list-item .learn-more-link {
  background: #e0e0e0;
  color: var(--color-text);
}

.rule-list-item .learn-more-link:hover {
  background: #d0d0d0;
}

.rule-list-item .try-link {
  background: var(--color-header-bg);
  color: var(--color-header-text);
  font-weight: bold;
}

.rule-list-item .try-link:hover {
  opacity: 0.9;
}

/* Favorited rule list item - distinctive styling */
.rule-list-item.favorited {
  border-left: 4px solid #e74c3c;  /* Red left border matching heart icon */
  background: linear-gradient(to right, #fff5f5, #f9f9f9);  /* Subtle rose tint */
}

.rule-list-item.favorited:hover {
  background: linear-gradient(to right, #ffe5e5, #f0f0f0);
  box-shadow: 0 2px 8px rgba(231, 76, 60, 0.15);
}

.rule-list-item.favorited .rule-name {
  color: #c0392b;  /* Darker red for better readability */
}

/* ========================================
   EDITOR SECTION WITH CONTEXTUAL TOOLBAR
   ======================================== */
.editor-section {
  background: #fafafa;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  margin-bottom: 1rem;
}

.editor-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.editor-context-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
}

.editor-context-group .separator {
  color: #ccc;
  font-size: 1.2rem;
  margin: 0 0.25rem;
}

/* Context label - subtle indication */
.editor-context {
  color: #666;
  font-size: 0.9rem;
  font-weight: normal;
  font-style: italic;
}

/* Rule picker inline */
.rule-picker-inline {
  position: relative;
  display: inline-block;
}

.rule-picker-inline summary {
  cursor: pointer;
  color: #666;
  font-size: 0.9rem;
  list-style: none;
  user-select: none;
}

.rule-picker-inline summary::-webkit-details-marker {
  display: none;
}

.rule-picker-inline[open] summary {
  color: var(--color-header-bg);
  font-weight: 500;
}

.editor-section .rule-picker-inline summary.has-selection {
  color: var(--color-poem);
  font-weight: 500;
}

.picker-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 300px;
  max-height: 400px;
  overflow-y: auto;
  background: white;
  border: 1px solid #d0d0d0;
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
  z-index: 100;
  margin-top: 0.5rem;
}

.rule-list {
  padding: 0.5rem;
}

.rule-group-header {
  font-weight: normal;
  color: #666;
  font-size: 0.9rem;
  padding: 0.5rem;
  margin-top: 0.5rem;
  border-bottom: 1px solid #e0e0e0;
}

.rule-item {
  padding: 0.5rem 1rem;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.2s;
}

.rule-item:hover {
  background: #f0f0f0;
}

/* Error state for rule picker validation */
.rule-picker-inline.error summary {
  color: #d32f2f;
  border: 2px solid #d32f2f;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  animation: shake 0.3s;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.editor-actions .action-separator {
  color: #ccc;
  font-size: 1.1rem;
  margin: 0 0.25rem;
  user-select: none;
}

.editor-actions button {
  background: white;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0.4rem 0.75rem;
  color: #555;
  transition: all 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.editor-actions button:hover {
  background: #f5f5f5;
  border-color: #b0b0b0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.editor-actions button:active {
  transform: scale(0.97);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

#poem-editor {
  width: 100%;
  min-height: 200px;
  padding: 0.875rem;
  margin: 1rem 0;
  font-family: var(--font-editor);  /* Suranna serif font for poetry */
  font-size: var(--font-editor-size);
  letter-spacing: var(--font-editor-letter-spacing);
  line-height: var(--font-editor-line-height);
  color: var(--color-poem);
  border: 1px solid #d8d8d8;
  border-radius: 8px;
  resize: vertical;
  background: white;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#poem-editor:focus {
  outline: none;
  border-color: var(--color-header-bg);
  box-shadow: 0 0 0 3px rgba(139, 0, 0, 0.08);
}

/* ========================================
   TOGGLE SWITCH COMPONENT
   ======================================== */
.toggle-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  user-select: none;
  padding: 0.25rem 0;
}

.toggle-switch input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-slider {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  background: #d0d0d0;
  border-radius: 13px;
  transition: background 0.25s ease;
  border: 1px solid #bbb;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  top: 2px;
  left: 2px;
  transition: left 0.25s ease;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.toggle-switch input[type="checkbox"]:checked + .toggle-slider {
  background: var(--color-header-bg);
  border-color: var(--color-header-bg);
}

.toggle-switch input[type="checkbox"]:checked + .toggle-slider::after {
  left: 24px;
}

.toggle-switch:hover .toggle-slider {
  box-shadow: 0 0 0 2px rgba(139, 0, 0, 0.1);
}

.toggle-label {
  font-weight: 500;
  color: #444;
  font-size: 0.95rem;
}

/* ========================================
   CONTROLS BAR (Below Editor)
   ======================================== */
.controls-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0;
  background: transparent;
}

.toggle-group {
  display: flex;
  gap: 2rem;
  align-items: center;
}

/* Primary action button */
.main-actions {
  margin: 0;
}

.btn-primary {
  padding: 0.75rem 2rem;
  font-size: 1.05rem;
  font-weight: 600;
  background: var(--color-header-bg);
  color: var(--color-header-text);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.18);
  background: #9b0000;
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0,0,0,0.12);
}

/* ========================================
   RESPONSIVE (MOBILE)
   ======================================== */
@media (max-width: 768px) {
  .editor-section {
    padding: 0.875rem;
    border-radius: 10px;
  }

  .editor-toolbar {
    flex-wrap: wrap;
    gap: 0.5rem;
    padding-bottom: 0.875rem;
  }

  .editor-context-group {
    width: 100%;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .editor-context-group .separator {
    display: none;  /* Hide separator on mobile */
  }

  .editor-context,
  .rule-picker-inline {
    font-size: 0.85rem;
  }

  .editor-actions {
    margin-left: auto;
  }

  .editor-actions button {
    padding: 0.35rem 0.6rem;
    font-size: 0.85rem;
  }

  .controls-bar {
    flex-direction: column;
    gap: 1rem;
    padding-top: 0.875rem;
    padding-bottom: 0;
  }

  .toggle-group {
    width: 100%;
    display: flex;
    gap: 1.5rem;
    justify-content: center;
  }

  .toggle-switch {
    gap: 0.4rem;
  }

  .toggle-label {
    font-size: 0.9rem;
  }

  .main-actions {
    width: 100%;
  }

  .main-actions button {
    width: 100%;
    padding: 0.875rem;
    font-size: 1rem;
  }

  .picker-dropdown {
    min-width: 250px;
  }

  /* Results Mobile Responsive */
  /* Force stacking on mobile by reducing min-widths */
  .match-table-container {
    min-width: 100%;
    flex: 1 1 100%;
  }

  .match-errors-container {
    min-width: 100%;
    flex: 1 1 100%;
  }

  .match-body-split {
    gap: 1rem;
  }

  .match-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .match-title-group {
    width: 100%;
  }

  .match-title-group .meter-name {
    font-size: 1.25rem;
  }

  .match-score {
    font-size: 1rem;
  }

  .match-actions {
    width: 100%;
    justify-content: stretch;
  }

  .match-actions .btn-add-example,
  .match-actions .btn-submit-github,
  .match-actions .rule-details-link {
    flex: 1;
    text-align: center;
  }

  .rule-details-link {
    width: 100%;
    text-align: center;
  }

  /* Make errors table scrollable on mobile */
  .errors-table {
    font-size: 0.85rem;
  }

  .errors-table th,
  .errors-table td {
    padding: 0.375rem 0.25rem;
  }

  /* ========================================
     LEGACY CLASSES MOBILE RESPONSIVE
     ======================================== */

  .padyam {
    min-width: 100%;
    flex: 1 1 100%;
    padding: 0.75rem;
    margin-bottom: 1rem;  /* Space between stacked items */
  }

  .poem {
    font-size: 1.75rem;
    line-height: 1.8;
  }

  .ganaVibhajana {
    min-width: 100%;
    flex: 1 1 100%;
  }
}

/* Hide less critical columns on very small screens */
@media (max-width: 480px) {
  .error-position {
    display: none;
  }
}

/* ========== HTML Description Content ========== */
.description-content {
  line-height: 1.8;
  color: var(--color-text);
}

.description-content h2 {
  font-family: var(--font-main);
  font-size: 1.35rem;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  color: var(--color-header-bg);
  border-bottom: 2px solid var(--color-header-bg);
  padding-bottom: 0.5rem;
}

.description-content ul,
.description-content ol {
  margin-left: 1.5rem;
  margin-bottom: 1rem;
  list-style-position: outside;
}

.description-content ul {
  list-style-type: disc;
}

.description-content li {
  margin-bottom: 0.5rem;
  line-height: 1.7;
}

.description-content code {
  background: #f5f5f5;
  padding: 0.25rem 0.5rem;
  border-radius: 3px;
  font-family: monospace;
  font-size: 0.9em;
  color: #c7254e;
  border: 1px solid #e1e8ed;
}

.description-content p {
  margin-bottom: 1rem;
}

.description-content strong {
  font-weight: 700;
}

/* ========== Breadcrumb Navigation ========== */
.breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  padding: 0.75rem 0;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.breadcrumb-link {
  color: #0066cc;  /* Blue color for better visibility */
  text-decoration: none;
  transition: color 0.2s;
}

.breadcrumb-link:hover {
  color: var(--color-header-bg);
  text-decoration: underline;
}

.breadcrumb-separator {
  margin: 0 0.3rem;
  color: #666;
  user-select: none;
}

.breadcrumb-current {
  color: var(--color-header-bg);
  font-weight: 600;
}

/* ========== Mode Switcher (Segmented Control) ========== */
.mode-switcher {
  display: inline-flex;
  gap: 0;
  border-radius: 6px;
  overflow: hidden;
  margin: 1rem 0;
  border: 2px solid var(--color-header-bg);
}

.mode-tab {
  display: inline-block;
  padding: 0.5rem 1.5rem;
  font-size: 0.95rem;
  text-decoration: none;
  border: none;
  transition: all 0.2s ease;
  cursor: pointer;
  white-space: nowrap;
}

.mode-tab.mode-tab-active {
  background: var(--color-header-bg);
  color: white;
  font-weight: 600;
  cursor: default;
}

.mode-tab:not(.mode-tab-active) {
  background: transparent;
  color: var(--color-header-bg);
  font-weight: 400;
}

.mode-tab:not(.mode-tab-active):hover {
  background: rgba(0, 0, 0, 0.08);
}

/* Mobile: Compact mode switcher */
@media (max-width: 768px) {
  .mode-tab {
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
  }
}

/* ========== Page Header Controls ========== */
.page-header-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.page-header-controls h1 {
  margin: 0;
  font-size: 1.5rem;
}

.page-header-controls .mode-switcher {
  margin-left: auto;
  margin-top: 0;
  margin-bottom: 0;
}

.page-subtitle {
  color: #666;
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

@media (max-width: 480px) {
  .page-header-controls {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-header-controls .mode-switcher {
    margin-left: 0;
    align-self: flex-end;
  }
}

/* ========== Home Page Landing ========== */
.home-page-landing {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.hero-section {
  text-align: center;
  margin-bottom: 4rem;
}

.hero-title {
  font-family: var(--font-logo);
  font-size: 4rem;
  margin-bottom: 0.5rem;
  text-shadow: -1px -1px 0 rgba(0, 0, 0, 0.3),
    1px 1px 0 rgba(255, 255, 255, 0.8),
    2px 2px 3px rgba(0, 0, 0, 0.2);
}

.hero-subtitle {
  font-family: var(--font-display);
  font-size: 1.75rem;
  color: #555;
  margin-bottom: 1.5rem;
}

.hero-description {
  font-size: 1.15rem;
  line-height: 1.8;
  color: #666;
  max-width: 700px;
  margin: 0 auto 2rem;
}

.hero-actions {
  margin-top: 2rem;
}

.btn-large {
  font-size: 1.25rem;
  padding: 1rem 2.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ========== Quick Links Section ========== */
.quick-links-section {
  margin-top: 3rem;
}

.quick-links-section h3 {
  text-align: center;
  font-size: 1.5rem;
  margin-bottom: 2rem;
  color: var(--color-header-bg);
}

.quick-links-grid {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.quick-link-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  background: #f9f9f9;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  text-decoration: none;
  color: var(--color-text);
  transition: all 0.3s;
  min-width: 150px;
}

.quick-link-card:hover {
  border-color: var(--color-header-bg);
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.quick-link-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.quick-link-title {
  font-size: 1rem;
  font-weight: bold;
  color: var(--color-header-bg);
  white-space: nowrap;
}

.quick-link-desc {
  display: none; /* Hide descriptions in horizontal layout */
}

/* ========== Rule Sets Page ========== */
.rule-sets-page {
  max-width: 900px;
  margin: 0 auto;
}

.rule-sets-page h1 {
  text-align: center;
  margin-bottom: 0.5rem;
}

.rule-sets-page .subtitle {
  text-align: center;
  font-size: 1.1rem;
  color: #666;
  margin-bottom: 2rem;
}

/* ========== Mobile Responsive Adjustments ========== */
@media (max-width: 768px) {
  .hero-title {
    font-size: 2.5rem;
  }

  .hero-subtitle {
    font-size: 1.35rem;
  }

  .hero-description {
    font-size: 1rem;
  }

  .btn-large {
    font-size: 1.1rem;
    padding: 0.9rem 2rem;
  }

  .quick-links-grid {
    flex-direction: column;
    align-items: center;
  }

  .quick-link-card {
    width: 100%;
    max-width: 300px;
    justify-content: center;
  }

  .breadcrumbs {
    font-size: 0.85rem;
  }

  .breadcrumb-separator {
    margin: 0 0.2rem;
  }

  .breadcrumb-modes {
    margin-left: 0.2rem;
    gap: 0.2rem;
  }

  .breadcrumb-mode-link,
  .breadcrumb-mode-current {
    font-size: 0.75rem;
    padding: 0.15rem 0.4rem;
  }
}

/* ========== Rule Action Toolbar ========== */
/* Toolbar for rule pages (favorite, share, print, etc.) */

.page-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.current-rule-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.rule-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Base action button style (shared by all action buttons) */
.action-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  transition: background-color 0.2s, transform 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.action-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  transform: scale(1.05);
}

.action-btn:active {
  transform: scale(0.95);
}

/* Favorite button specific styles */
.btn-favorite .heart-icon {
  transition: fill 0.3s ease, transform 0.2s ease;
}

/* Gray state (not favorited) */
.btn-favorite[data-favorited="false"] .heart-icon {
  fill: #ddd;
  stroke: #999;
  stroke-width: 1.5;
}

/* Red state (favorited) */
.btn-favorite[data-favorited="true"] .heart-icon {
  fill: #e74c3c;
  stroke: none;
}

/* Hover effect for favorite button */
.btn-favorite:hover .heart-icon {
  transform: scale(1.1);
}

/* Click animation */
@keyframes heart-pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.btn-favorite.favoriting .heart-icon {
  animation: heart-pop 0.3s ease;
}

/* Delete button in action toolbar - matches favorite icon style */
.action-btn.btn-delete .trash-icon {
  fill: #c1121f;
  transition: transform 0.2s ease;
}

.action-btn.btn-delete:hover .trash-icon {
  fill: #a00;
  transform: scale(1.1);
}

/* Delete button in rule list (inline with links) - matches Learn/Try link style */
.btn-delete-inline {
  background: #c1121f;
  color: white;
  border: none;
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: var(--font-main);
  text-decoration: none;
  transition: all 0.2s;
}

.btn-delete-inline:hover {
  background: #a00;
}

/* Future action buttons (share, print, etc.) */
/*
.btn-share .share-icon,
.btn-print .print-icon {
  fill: #666;
  transition: fill 0.2s ease;
}

.btn-share:hover .share-icon {
  fill: #4a90e2;
}

.btn-print:hover .print-icon {
  fill: #2d6a4f;
}
*/

/* Mobile responsive */
@media (max-width: 768px) {
  .rule-actions {
    gap: 0.25rem;
  }

  .action-btn {
    padding: 0.375rem;
  }
}

/* Error state for failed initialization */
.loader-container.error h2 {
  color: #d32f2f;
  margin-bottom: 1rem;
}

.loader-container.error button {
  background-color: #1976d2;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 1rem;
}

.loader-container.error button:hover {
  background-color: #1565c0;
}

/* ========================================
   CUSTOM RULES COLLECTION CARD
   ======================================== */
.custom-rules-card {
  border: 3px solid #3498db;
  background: linear-gradient(to bottom, #f0f8ff, #ffffff);
  border-radius: 12px;
  padding: 1.5rem;
  transition: all 0.3s ease;
}

.custom-rules-card:hover {
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
  transform: translateY(-2px);
}

/* ========================================
   RULE CREATOR PAGE
   ======================================== */
.rule-creator-page {
  max-width: 1000px;
  margin: 0 auto;
  padding: 1rem;
}

.rule-creator-page h2 {
  color: var(--color-text);
  font-family: var(--font-main);
  margin-bottom: 1.5rem;
  font-size: 1.8rem;
}

/* Classification row (side-by-side dropdowns) */
.classification-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
}

.dropdown-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dropdown-group label {
  font-family: var(--font-main);
  font-size: 0.9rem;
  color: var(--color-text);
  white-space: nowrap;
}

.dropdown-select {
  padding: 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-family: var(--font-main);
  font-size: 0.9rem;
  background: white;
  cursor: pointer;
  min-width: 120px;
}

.dropdown-select:hover {
  border-color: #3498db;
}

.dropdown-select:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.1);
}

/* Compact toolbar styling */
.editor-toolbar.compact-toolbar {
  flex-wrap: wrap;
  gap: 0.5rem;
}

.editor-toolbar.compact-toolbar .editor-context-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.editor-toolbar.compact-toolbar .editor-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Name input in toolbar */
.name-input {
  padding: 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-family: var(--font-main);
  font-size: 1rem;
  min-width: 300px;
  margin-left: 0.5rem;
}

.name-input.compact {
  min-width: 200px;
  max-width: 300px;
  margin-left: 0;
}

.name-input:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.1);
}

/* Compact dropdown styling */
.dropdown-select.compact {
  min-width: 100px;
}

/* Compact toggle switch */
.toggle-switch.compact {
  margin-right: 0;
}

/* ========================================
   PATTERN ROWS SECTION (INLINE LAYOUT)
   ======================================== */
.pattern-section .editor-toolbar {
  border-bottom: none;
}

.pattern-rows-container {
  padding: 1rem;
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Inline row layout */
.pattern-row-inline {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  flex-wrap: wrap;
  transition: box-shadow 0.2s;
}

.pattern-row-inline:hover {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* Row badge */
.row-badge {
  background: #3498db;
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
  flex-shrink: 0;
}

/* Gana count label */
.gana-count {
  min-width: 80px;
  font-size: 0.85rem;
  color: #666;
  flex-shrink: 0;
}

/* Row action buttons (inline) */
.row-gana-actions {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

.btn-icon-sm {
  background: #f8f9fa;
  border: 1px solid var(--color-border);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: all 0.2s;
  min-width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon-sm:hover {
  background: #e9ecef;
  border-color: #3498db;
}

.btn-icon-sm.btn-danger {
  border-color: #c1121f;
  color: #c1121f;
}

.btn-icon-sm.btn-danger:hover {
  background: #c1121f;
  color: white;
}

/* Toolbar icon buttons */
.btn-icon {
  background: #f8f9fa;
  border: 1px solid var(--color-border);
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  transition: all 0.2s;
  min-width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover:not(:disabled) {
  background: #e9ecef;
  border-color: #3498db;
}

.btn-icon.btn-danger {
  border-color: #c1121f;
  color: #c1121f;
}

.btn-icon.btn-danger:hover:not(:disabled) {
  background: #c1121f;
  color: white;
}

.btn-icon:disabled,
.btn-icon-sm:disabled,
.btn-icon.disabled,
.btn-icon-sm.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Inline gana dropdowns */
.gana-dropdowns-inline {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  flex: 1;
  min-width: 200px;
}

.gana-select {
  padding: 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-family: var(--font-main);
  font-size: 0.9rem;
  background: white;
  cursor: pointer;
  min-width: 120px;
  transition: border-color 0.2s;
}

.gana-select:hover {
  border-color: #3498db;
}

.gana-select:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.1);
}

/* Inline yati input */
.yati-input-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.yati-label {
  font-size: 0.85rem;
  color: #666;
  white-space: nowrap;
}

.yati-input-compact {
  width: 100px;
  padding: 0.4rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 0.85rem;
  font-family: var(--font-main);
}

.yati-input-compact:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.1);
}

/* ========================================
   LINES DROPDOWN (shown when same-rules checked)
   ======================================== */
.lines-dropdown-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.lines-dropdown-group label {
  font-size: 0.9rem;
  color: var(--color-text);
}

/* ========================================
   DELETE BUTTON (for custom rules browse)
   ======================================== */
.btn-delete {
  background: #c1121f;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: var(--font-main);
  transition: background 0.2s;
}

.btn-delete:hover {
  background: #a00;
}

/* ========================================
   SECONDARY BUTTON (add row)
   ======================================== */
.btn-secondary {
  background: #6c757d;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: var(--font-main);
  transition: background 0.2s;
}

.btn-secondary:hover {
  background: #5a6268;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */
@media (max-width: 768px) {
  .editor-toolbar.compact-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .editor-toolbar.compact-toolbar .editor-context-group {
    flex-direction: column;
    align-items: stretch;
  }

  .editor-toolbar.compact-toolbar .editor-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .name-input.compact {
    min-width: 100%;
    max-width: 100%;
  }

  .dropdown-select.compact {
    width: 100%;
  }

  /* Inline rows stack on mobile */
  .pattern-row-inline {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .row-gana-actions {
    justify-content: space-between;
    width: 100%;
  }

  .btn-icon-sm {
    flex: 1;
  }

  .gana-dropdowns-inline {
    width: 100%;
    flex-direction: column;
  }

  .gana-select {
    width: 100%;
  }

  .yati-input-inline {
    width: 100%;
  }

  .yati-input-compact {
    flex: 1;
    width: auto;
  }
}

/* ========== Rule Description Styling ========== */

/* Matra visualization - laghu and guru symbols */
.description-content .laghu {
  color: #e74c3c;
  font-weight: bold;
  font-family: monospace;
  font-size: 1.1em;
}

.description-content .guru {
  color: #3498db;
  font-weight: bold;
  font-family: monospace;
  font-size: 1.1em;
}

/* Highlighted terms in descriptions */
.description-content .gName {
  color: #16a085;
  font-weight: 600;
}

/* ========== Compact Badge Layout Styles ========== */

/* Aliases - less emphasis */
.rule-aliases {
  color: #7f8c8d;
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}

/* Badge row for primary stats */
.rule-summary-badges {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.badge {
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
  background: #ecf0f1;
  transition: all 0.2s;
}

.badge:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.badge-type {
  background: #e8daef;
  color: #6c3483;
}

.badge-chars {
  background: #d6eaf8;
  color: #1f618d;
}

.badge-matras {
  background: #d5f4e6;
  color: #186a3b;
}

.badge-chandam {
  background: #fdebd0;
  color: #935116;
}

/* Properties grid */
.rule-properties {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: #f8f9fa;
  border-radius: 8px;
}

.property {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  padding-left: 1rem;
  border-left: 3px solid #dee2e6;
}

.property:first-child {
  padding-left: 0;
  border-left: none;
}

.property .label {
  font-weight: 600;
  color: #555;
}

.property .value {
  color: #2c3e50;
  font-weight: 500;
}

/* Color-coded checkmarks */
.check-yes {
  color: #27ae60;
  font-weight: bold;
  font-size: 1.1em;
}

.check-no {
  color: #e74c3c;
  font-weight: bold;
  font-size: 1.1em;
}

/* Gana sequence highlight */
.gana-sequence {
  padding: 1rem;
  background: #fff8dc;
  border-left: 4px solid #f39c12;
  border-radius: 4px;
  margin-bottom: 2rem;
  font-size: 1.1rem;
}

.gana-sequence strong {
  color: #d35400;
}

.gana-table {
  width: 100%;
  margin-top: 1rem;
  border-collapse: collapse;
}

.gana-table td {
  padding: 0.5rem;
  border-bottom: 1px solid #f5e6c4;
}

.gana-table .padam-label {
  font-weight: 600;
  color: #d35400;
  width: 140px;
}

/* Matra details section */
.matra-details {
  margin-bottom: 2rem;
  padding: 1.25rem;
  background: #f0f8ff;
  border-radius: 8px;
  border-left: 4px solid #1abc9c;
}

.matra-details h3 {
  font-size: 1.2rem;
  margin-top: 0;
  margin-bottom: 1rem;
  color: #16a085;
}

.matra-details h4 {
  font-size: 1rem;
  margin-top: 1rem;
  margin-bottom: 0.75rem;
  color: #117a65;
}

.matra-details p {
  margin: 0.75rem 0;
}

.matra-details ul {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0;
}

.matra-details ul li {
  padding: 0.4rem 0;
  padding-left: 1.5rem;
  position: relative;
}

.matra-details ul li::before {
  content: "▸";
  position: absolute;
  left: 0;
  color: #16a085;
  font-weight: bold;
}

/* Keep existing laghu/guru coloring */
.matra-details .laghu {
  color: #e74c3c;
  font-weight: bold;
  font-family: monospace;
  font-size: 1.1em;
}

.matra-details .guru {
  color: #3498db;
  font-weight: bold;
  font-family: monospace;
  font-size: 1.1em;
}

/* Original rule section */
.original-rule {
  margin-bottom: 2rem;
  padding: 1.25rem;
  background: #fdfefe;
  border-radius: 8px;
  border-left: 4px solid #7f8c8d;
}

.original-rule h3 {
  font-size: 1.2rem;
  margin-top: 0;
  margin-bottom: 1rem;
  color: #34495e;
}

.original-rule blockquote {
  margin: 0;
  padding: 1rem 1.5rem;
  background: white;
  border-left: 4px solid #95a5a6;
  font-style: italic;
  color: #555;
  border-radius: 4px;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .rule-summary-badges {
    gap: 0.5rem;
  }

  .badge {
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
  }

  .rule-properties {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    padding: 0.75rem;
  }

  .property {
    flex-direction: column;
    gap: 0.25rem;
  }

  .gana-sequence {
    padding: 0.75rem;
    font-size: 1rem;
  }

  .matra-details,
  .original-rule {
    padding: 1rem;
  }
}

@media (max-width: 480px) {
  .rule-properties {
    grid-template-columns: 1fr;
  }
}

/* ========================================
   EXPORT BOOK FEATURE
   ======================================== */
.btn-export-book,
.btn-export-single {
  background: white;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0.4rem 0.75rem;
  color: #555;
  transition: all 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  font-family: var(--font-main);
}

.btn-export-book:hover,
.btn-export-single:hover {
  background: #f5f5f5;
  border-color: #b0b0b0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.btn-export-book:active,
.btn-export-single:active {
  transform: scale(0.97);
}

.btn-export-book:disabled,
.btn-export-single:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Export progress overlay */
.export-progress-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.export-progress-card {
  background: white;
  border-radius: 12px;
  padding: 2rem;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

.export-progress-card h3 {
  margin: 0 0 1.5rem 0;
  font-family: var(--font-main);
}

.export-progress-bar-container {
  width: 100%;
  height: 8px;
  background: #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.export-progress-bar {
  height: 100%;
  background: var(--color-header-bg);
  border-radius: 4px;
  transition: width 0.15s ease;
}

.export-progress-text {
  color: #666;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.btn-cancel-export {
  background: transparent;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  padding: 0.5rem 1.5rem;
  cursor: pointer;
  font-family: var(--font-main);
  color: #666;
  transition: all 0.2s;
}

.btn-cancel-export:hover {
  background: #f5f5f5;
  border-color: #b0b0b0;
}
