/* ============================================
   CSS Variables for theming
   ============================================ */
:root {
  /* Light mode colors (default) */
  --bg-primary: #ffffff;
  --bg-secondary: #f9f9f9;
  --bg-tertiary: #f5f5f5;
  --text-primary: #333333;
  --text-secondary: #666666;
  --text-tertiary: #999999;
  --link-color: #004BAF;
  --link-hover: #003380;
  --border-color: #eaeaea;
  --border-dark: #ddd;
  --shadow-color: rgba(0, 0, 0, 0.1);
  --input-bg: #ffffff;
  --input-border: #ccc;
  --button-bg: #004BAF;
  --button-text: #ffffff;
  --badge-bg: #e8f5e9;
  --badge-text: #2e7d32;
  --error-text: #ef4444;

  /* Focus colors for accessibility */
  --focus-ring: #fbbf24;
  --focus-ring-light: rgba(251, 191, 36, 0.3);

  /* Success/Error/Warning colors for Saltaparola */
  --success-bg: #d1fae5;
  --success-text: #065f46;
  --success-border: #10b981;
  --warning-bg: #fef3c7;
  --warning-text: #78350f;
  --warning-border: #f59e0b;
  --error-bg: #fee2e2;
  --error-border: #fca5a5;
}

/* Dark mode colors */
[data-theme="dark"] {
  --bg-primary: #1a1a1a;
  --bg-secondary: #252525;
  --bg-tertiary: #2a2a2a;
  --text-primary: #e0e0e0;
  --text-secondary: #b0b0b0;
  --text-tertiary: #808080;
  --link-color: #6eb5ff;
  --link-hover: #8fc7ff;
  --border-color: #3a3a3a;
  --border-dark: #4a4a4a;
  --shadow-color: rgba(0, 0, 0, 0.5);
  --input-bg: #2a2a2a;
  --input-border: #4a4a4a;
  --button-bg: #6eb5ff;
  --button-text: #1a1a1a;
  --badge-bg: #3a3a2a;
  --badge-text: #7bc48e;
  --error-text: #fc8181;

  /* Focus colors for accessibility */
  --focus-ring: #fbbf24;
  --focus-ring-light: rgba(251, 191, 36, 0.2);

  /* Success/Error/Warning colors for Saltaparola */
  --success-bg: #064e3b;
  --success-text: #6ee7b7;
  --success-border: #10b981;
  --warning-bg: #451a03;
  --warning-text: #fcd34d;
  --warning-border: #f59e0b;
  --error-bg: #3a2020;
  --error-border: #fc8181;
}

/* Auto dark mode based on system preference */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-primary: #1a1a1a;
    --bg-secondary: #252525;
    --bg-tertiary: #2a2a2a;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-tertiary: #808080;
    --link-color: #6eb5ff;
    --link-hover: #8fc7ff;
    --border-color: #3a3a3a;
    --border-dark: #4a4a4a;
    --shadow-color: rgba(0, 0, 0, 0.5);
    --input-bg: #2a2a2a;
    --input-border: #4a4a4a;
    --button-bg: #6eb5ff;
    --button-text: #1a1a1a;
    --badge-bg: #3a3a2a;
    --badge-text: #7bc48e;
    --error-text: #fc8181;

    /* Focus colors for accessibility */
    --focus-ring: #fbbf24;
    --focus-ring-light: rgba(251, 191, 36, 0.2);

    /* Success/Error/Warning colors for Saltaparola */
    --success-bg: #064e3b;
    --success-text: #6ee7b7;
    --success-border: #10b981;
    --warning-bg: #451a03;
    --warning-text: #fcd34d;
    --warning-border: #f59e0b;
    --error-bg: #3a2020;
    --error-border: #fc8181;
  }
}

body {
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 1.125em;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  transition: background-color 0.3s ease, color 0.3s ease;
}

em { font-weight: bold; font-style: normal }

* { margin: 0; padding: 0; outline: 0; }

@font-face {
    font-family: 'Essays 1743';
    src: url('/static/fonts/essays1743-webfont.eot#') format('eot'),
         url('/static/fonts/essays1743-webfont.woff') format('woff'),
         url('/static/fonts/essays1743-webfont.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

.disabled {
  pointer-events: none;
  opacity: 0.4;
}

#leftnav {
  position: absolute;
  top: 1px;
  width: 250px;
  z-index: 10;
}

#so {
  margin-left: 40px;
}

#so a.filter {
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 1px dotted var(--text-tertiary);
}

#so a.filter:hover {
  border-bottom: 1px solid var(--text-tertiary);
}

#so ul {
  margin-bottom: 1em;;
  font-size: 0.8em;
  list-style: none;
}

#so li {
  line-height: 1.8em;
  margin: 0px 0px 0px 5px;
  padding-left: 5px;
  border-left: 5px solid var(--bg-primary);
}

#so h1 {
  color: var(--text-primary);
  font-size: 1.2em;
  font-weight: normal;
  text-transform: none;
  text-shadow: none;
  margin-bottom: 5px;
}

#so .active {
  font-weight: bold;
  border-left: 5px solid var(--text-secondary);
  pointer-events: none;
  cursor: default;
}

#so .active a {
  border-bottom: none;
}


.range-slider {
  margin: 4px 0px 10px 5px;
  width: 80%;
  float: left;
}

.range {
  font-weight: bold;
  font-size: 0.8em;
  margin-left: 10px;
}

.reset-button {
  margin: 0 0 0 0px;
  float: right;
  width: auto !important;
  height: auto;
}

/* Tag buttons - simple gray button style */
.tag-anchor {
  display: inline-block;
  margin: 5px;
  padding: 0.4em 1em;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-dark);
  border-radius: 4px;
  color: var(--text-secondary);
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  transition: background-color 0.2s;
}

.tag-anchor:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

#indexsearchsection {
  min-height: 80px;
}

#indexsearchfieldset, #resultssearchfieldset, #tagfieldset, #langfieldset {
  display: flex;
  height: 32px;
  background-color: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 5px;
  -webkit-border-radius: 5px;
  -moz-border-radius: 5px;
  padding: 8px;
  box-shadow: 0 1px 4px 0 var(--shadow-color);
}

#indexsearchfieldset {
  margin: auto;
  max-width: 750px;
}

#resultssearchfieldset {
  max-width: 750px;
}

#tagfieldset, #langfieldset {
  margin: 1em 0;
}

.searchIcon {
  width: 32px;
  margin-right: 10px;
  transition: filter 0.3s ease;
}

/* Invert search icon in dark mode */
[data-theme="dark"] .searchIcon {
  filter: invert(1) brightness(0.9);
}

#text_span {
  flex-grow: 1;
  display: flex;
}

input[type="text"] {
  border: 0;
  width: 100%;
  background-color: var(--input-bg);
  color: var(--text-primary);
  float: left;
  background-image: none;
  line-height: 32px;
}

input {
  color: var(--text-primary);
  font-size: 1.3em;
  -webkit-appearance: none;
}

form.qf, form.qfr, #dintro {
  margin: 0 auto;
  position: relative;
}

form.qf {
  text-align: center;
}

form.qfr {
  text-align: left;
}

.footer {
  font-size: 0.8em;
  margin: 20px 0 20px 0;
  text-align: center;
  color: var(--text-secondary);
}

.footerResults {
  max-width: 750px;
  padding-left: 288px;
}

.dis {
  padding-left: 288px;
}

#searchbutton {
  text-align: center;
  margin-top: 15px;
}

#dintro {
  text-align: center;
}

li.sr {
  display: list-item;
  list-style-type: none;
  margin-top: 0;
  margin-bottom: 25px;
}

ul, li {
  border: 0;
  margin: 0;
  padding: 0;
}

a {
  color: var(--link-color);
}

#searchresults {
  padding: 0 8px 0 18px;
  clear: both;
}

#searchform {
  margin: 0;
  text-align: center;
  padding-top: 3px;
}

.container {
  margin-left: 270px;
  color: var(--text-primary);
}

.text {
  font-size: 1.2em;
  line-height: 1.4em;
}

.textContainer {
  padding: 0 8px 0 18px;
  max-width: 750px;
  margin-right: 100px;
  margin-top: 20px;
}

.text h1, .text h2, .text h3, .text h4, dd {
  margin: 1.5em 0 0.8em 0;
  font-weight: normal;
  text-transform: none;
  text-shadow: none;
  color: var(--text-primary);
  padding: 0;
}

h1.lemma {
  margin: 0 0 0.5em 0;
  line-height: 1;
}

h1.lemma a {
  display: inline-block;
  line-height: 1;
  vertical-align: baseline;
}

dd:first-of-type {
  margin-top: 0;
}

.text h1 {
  font-size: 240%;
}

.text h2 {
  font-size: 180%;
}

.text h3 {
  font-size: 140%;
}

.text h4 {
  font-size: 120%;
}

.text p {
  margin: 0 0 1.15em 0;
} 

.text table p {
  margin: 0;
}

.text ul, ol {
  margin: 20px 0 10px 30px;
  padding: 0;
}

.text li {
  margin: 0 0 0.5em 0;
}

.text li:only-child {
  list-style: none;
}

h3.sr {
  display: inline;
  font-size: 1.2em;
  font-weight: normal;
}

div.sr {
  max-width: 750px;
}

div.mt {
  font-size: 11px;
  color: var(--text-secondary);
}

div.mt span {
  cursor: default;
}

div.mt a {
  text-decoration: none;
}

div.hl {
}

div.definition {
  position: relative;
  overflow: hidden;
  margin: 0 0 1em 0;
  padding: 1em 0 1em 0;
  background: var(--bg-secondary);
  -moz-border-radius: 3px;
  -webkit-border-radius: 3px;
  border-radius: 3px;
  border: 1px solid var(--border-color);
  border-bottom-width: 2px;
  border-top-width: 0;
}

div.definition hr {
  border: 1px solid var(--border-color);
  margin: 1em 0;
}

.definition h3, .definition h4 {
  margin: 0;
}

.definition h3 {
  margin-bottom: 1em;
}

.definition h3 sup {
  font-size: 0.5em;
}

.definition .definition_section {
  margin: 0 1.5rem 0 1.5rem;
}

#dle_container div.definition_section:first-child {
  border-radius: 3px 3px 0 0;
}

#dle_container div.definition_section:last-child {
  border-radius: 0 0 3px 3px;
}

.etymology {
  font-style: italic;
}

div.cova_definition em {
  font-weight: normal;
  font-style: italic;
}

div.definitionTags {
  margin-top: 10px;
}

a.dpd {
  text-decoration: none;
}

span.dpd {
  font-size: 11px;
  vertical-align: super;
}

#tld {
  color: var(--text-tertiary);
  text-shadow: none;
  text-transform: none;
}

span.logo {
  font-family: 'Gabriela', serif;
  font-weight: normal;
  text-shadow: 0 0 1px var(--text-secondary);
  text-transform: uppercase;
  color: var(--text-primary);
  display: inline;
  font-size: 70px;
  line-height: 100px;
}

/* Logo pequeño para resultados de búsqueda y página de palabra */
div.logo-small {
  font-family: 'Gabriela', serif;
  font-weight: normal;
  text-shadow: 0 0 1px var(--text-secondary);
  text-transform: uppercase;
  color: var(--text-primary);
  font-size: 3.5em;
  display: inline;
  line-height: 55px;
}

a.logo {
  text-decoration: none;
}

#srlogo {
  position: absolute;
  padding-left: 40px;
}

#dlogo {
  width: 100%;
  height: 270px;
  line-height: 270px;
}

#dlogo img {
  border: 0;
  max-height: 250px;
}

#logo {
  vertical-align: middle;
  transition: filter 0.3s ease;
}

/* Invert logo in dark mode */
[data-theme="dark"] #logo {
  filter: invert(1) brightness(0.7);
}

#suggestion {
    margin-bottom: 20px;
}

#resultStats {
  height: 1em;
  font-size: 11px;
  padding-left: 8px;
  margin-top: 8px;
  text-align: left;
}

#resultFilters {
  font-size: 0.8em;
  background-color: var(--bg-secondary);
  margin-bottom: 1em;
  display: block;
  max-width: 750px;
  overflow: auto;
  position: relative;
  border: 1px solid var(--border-color);
}

#filterContainer {
  display: table;
  padding: 1em;
}

#filterString {
  display: table-cell;
  width: 100%;
}

#resultFilterButtons {
  display: table-cell;
  white-space: nowrap;
}

#intro {
  margin-top: 20px;
}

#pagination {
  text-align: center;
  max-width: 750px;
  margin: 2em 0 1em 0;
}

#pagination .current {
  margin: 0 5px 0 5px;
}

#pagination a {
  text-decoration: none;
}

#pagination img {
  border: 0;
}


span.about {
    font-size: 1.2em;
    display: block;
    margin: 0 0 1em 0;
}

#daily_word {
    text-align: center;
    font-size: 1.2em;
    margin: 0.5em auto 1.5em auto;
    padding-top: 1.5em;
    border-top: 1px solid var(--border-color);
    max-width: 750px;
}

#daily_word a {
    font-size: 120%;
}

#origin, #rae_origin, #frequency, .complexity-badge {
    font-weight: bold;
}

dt {
    font-size: 120%;
    font-weight: bold;
}

dd img {
    float: right;
    margin: 0 0 0 30px;
}

.sep {
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 14px;
  margin-left: 10px;
  margin-right: 4px;
  margin-top: 14px;
}

#def_marca {
    margin: 2em 0 2em 0;
    font-size: 0.8em;
}

#def_marca p {
    margin: 0.5em 0 0 0;
}

table.taglist {
    display: table;
    background-color: var(--bg-primary);
    width: 100%;
    border-spacing: 0;
    padding: 0;
    border-collapse: collapse;
    margin-top: 2em;
}

table.taglist th {
    text-align: left;
    padding-bottom: 10px;
}

table.taglist th:last-child {
    text-align: right;
}

table.taglist td {
    padding: 10px;
}

table.taglist td:last-child {
    text-align: right;
}

table.taglist td.occ {
    text-align: right;
}

table.taglist tr.odd {
    background-color: var(--bg-secondary);
}

table.taglist tr.even {
    background-color: var(--bg-primary);
}

table.related-word {
    margin: 2em 0 0 1em;
    font-size: 0.9em;
}

table.related-word td {
    vertical-align: top;
    padding: 0 5px 0 5px;
}

table.related-word h3 {
    margin-top: 3px;
}

table.related-word h3 a {
    color: var(--text-primary);
    text-decoration: none;
}

#notfound {
  padding: 2em 0 2em 0;
  text-align: center;
}

#notfound span {
  font-weight: normal;
  text-shadow: 0 0 1px var(--text-secondary);
  color: var(--text-primary);
  font-size: 2em;
}

li.more{
  list-style: none;
  color: var(--link-color);
  cursor: pointer;
}

.button {
  background: var(--bg-tertiary);
  cursor: pointer;
  border-radius: 3px;
  background-image: linear-gradient(var(--bg-secondary), var(--bg-tertiary));
  background-repeat: repeat-x;
  color: var(--text-primary);
  border: 1px solid var(--border-dark);
}

.coll {
  padding: 0;
  border: 1px solid var(--input-border);
  border-radius: 3px 3px 3px 3px;
  height: 1.5em;
  line-height: 1.5em;
  text-align: center;
  padding: 0.3em;
  cursor: pointer;
  max-width: 70%;
  margin-bottom: 1em;
  display: none;
}

#map {
  width: 960px;
  height: 400px;
  position: relative;
}

.overlay {
  fill: none;
  pointer-events: all;
}

.country {
  fill: var(--border-dark);
  stroke: var(--bg-primary);
  stroke-width: .5px;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.spanish {
  fill: var(--link-color);
  opacity: 0.5;
}

.spanish:hover {
  opacity: 0.8;
  cursor: pointer;
}

.hidden { 
  display: none; 
}

.place-label {
  display: none;
  fill: var(--text-primary);
  text-anchor: start;
  font: normal 10px "Helvetica Neue", Helvetica, sans-serif;
}

.place-label tspan {
  font-size: 1.8em;
  font-weight: bold;
}

.place-label tspan.subtitle {
  font-size: 1.2em;
  font-weight: normal
}

img.center {
    display: block;
    margin: auto;
}

.card {
  -moz-border-radius: 3px;
  -webkit-border-radius: 3px;
  border-radius: 3px;
  border: 1px solid var(--border-color);
  border-bottom-width: 2px;
  border-top-width: 0;
}

/* Word button (search icon in word detail) */
.word-button {
  display: inline-block;
  line-height: normal;
  padding: 0.2em 0.5em;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-dark);
  border-radius: 4px;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: bold;
  font-size: 0.6em;
  filter: grayscale(1);
  transition: background-color 0.2s;
}

.word-button:hover {
  background: var(--bg-secondary);
}


div.related {
  float: left;
}

.search-screenshot {
  width: 300px;
}

.ribbon {
  position: absolute;
  top: -18px;
  right: -45px;
  width: 120px;
  text-align: center;
  transform: rotate(45deg);
  background-color: var(--badge-bg);
  padding: 32px 0 3px 0px;
  color: var(--badge-text);
  border-bottom: 2px solid var(--border-dark);
  font-size: 1rem;
}

.ribbon:hover {
  text-decoration: solid underline 1px;
  text-underline-offset: 0.2em;
}
/* ============================================
   Advanced Search Accordion
   Mobile-first responsive design
   ============================================ */

#advanced-search-container {
  width: 100%;
  max-width: 750px;
  margin-left: auto;
  margin-right: auto;
  clear: both;
  box-sizing: border-box;
}

/* In index page, add spacing to match example words */
form.qf #advanced-search-container {
  margin-top: 1.5em;
}

/* In search results, constrain to search form width */
form#srf #advanced-search-container {
  max-width: 750px;
  margin-left: 0;
  margin-right: 0;
  margin-top: 0.5em;
}

/* Advanced header with toggle and stats */
.advanced-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1em;
}

.advanced-header #resultStats {
  height: auto;
  font-size: 11px;
  padding: 0;
  margin: 0;
  text-align: right;
  flex-shrink: 0;
}

.advanced-toggle {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.9em;
  padding: 0;
  text-align: left;
  transition: color 0.2s;
  flex-grow: 1;
}

.advanced-toggle:hover {
  color: var(--text-primary);
}

.toggle-icon {
  display: inline-block;
  transition: transform 0.3s;
  font-size: 0.8em;
}

.advanced-toggle.active .toggle-icon {
  transform: rotate(-180deg);
}

.advanced-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 3px;
  margin-top: 0.5em;
  padding: 0 1.5em;
  max-width: 100%;
  box-sizing: border-box;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.3s ease-out, opacity 0.3s ease-out, padding 0.3s ease-out;
}

.advanced-panel.open {
  max-height: 2000px;
  opacity: 1;
  padding: 1.5em;
}

/* Grid layout - mobile first (single column) */
.advanced-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1em;
  margin-bottom: 1em;
}

/* Tablet and up: two columns */
@media (min-width: 600px) {
  .advanced-grid {
    grid-template-columns: 1fr 1fr;
  }
  
  .advanced-field.full-width {
    grid-column: 1 / -1;
  }
}

.advanced-field label {
  font-size: 0.85em;
  font-weight: 500;
}

.advanced-field > label {
  display: block;
  font-weight: 800;
  margin-bottom: 0.4em;
  color: var(--text-secondary);
}

.advanced-field input[type="text"],
.advanced-field input[type="number"] {
  width: 100%;
  padding: 0.5em;
  border: 1px solid var(--input-border);
  border-radius: 3px;
  font-size: 1em;
  box-sizing: border-box;
  background-color: var(--input-bg);
  color: var(--text-primary);
}

.advanced-field input[type="text"]:focus,
.advanced-field input[type="number"]:focus {
  outline: none;
  border-color: var(--link-color);
  box-shadow: 0 0 0 2px var(--shadow-color);
}

/* Range inputs (min - max) */
.range-inputs {
  display: flex;
  align-items: center;
  gap: 0.5em;
}

.range-inputs input {
  flex: 1;
  min-width: 0;
}

.range-separator {
  color: var(--text-secondary);
  font-size: 0.9em;
}

/* Radio buttons */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 0.5em;
}

@media (min-width: 769px) {
  .radio-group {
    flex-direction: row;
    flex-wrap: wrap;
  }
  #leftnav {
    position: fixed;
    top: 115px;
  }
  #srlogo {
    position: fixed;
    top: 20px;
  }
}

.radio-label {
  display: flex;
  align-items: center;
  font-size: 0.9em;
  cursor: pointer;
  margin-right: 1em;
  font-weight: normal;
}

.radio-label input[type="radio"] {
  margin-right: 0.4em;
  cursor: pointer;
  width: auto;
  height: auto;
  -webkit-appearance: radio;
  appearance: radio;
}

/* Checkboxes */
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 0.5em;
}

@media (min-width: 600px) {
  .checkbox-group {
    flex-direction: row;
    flex-wrap: wrap;
  }
}

.checkbox-label {
  display: flex;
  align-items: center;
  font-size: 0.9em;
  cursor: pointer;
  margin-right: 1em;
  font-weight: normal;
}

.checkbox-label input[type="checkbox"] {
  margin-right: 0.4em;
  cursor: pointer;
  width: auto;
  height: auto;
  -webkit-appearance: checkbox;
  appearance: checkbox;
}

/* Multi-select dropdowns */
.adv-multiselect {
  width: 100%;
  padding: 0.5em;
  border: 1px solid var(--input-border);
  border-radius: 3px;
  font-size: 0.9em;
  font-family: inherit;
  box-sizing: border-box;
  background-color: var(--input-bg);
  color: var(--text-primary);
}

.adv-multiselect:focus {
  outline: none;
  border-color: var(--link-color);
  box-shadow: 0 0 0 2px var(--shadow-color);
}

.adv-multiselect option {
  padding: 0.3em;
}

/* Action buttons */
.advanced-actions {
  display: flex;
  gap: 0.5em;
  justify-content: flex-end;
  padding-top: 0.5em;
  border-top: 1px solid var(--border-dark);
}

.btn-search,
.btn-clear {
  padding: 0.6em 1.5em;
  border: 1px solid var(--input-border);
  border-radius: 3px;
  font-size: 0.9em;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
  background: var(--bg-tertiary);
  background-image: linear-gradient(var(--bg-secondary), var(--bg-tertiary));
  background-repeat: repeat-x;
  color: var(--text-primary);
}

.btn-search:hover,
.btn-clear:hover {
  background: var(--bg-secondary);
  background-image: linear-gradient(var(--bg-primary), var(--bg-secondary));
}

.btn-search:active,
.btn-clear:active {
  transform: scale(0.98);
}

/* Mobile: stack buttons */
@media (max-width: 480px) {
  .advanced-actions {
    flex-direction: column-reverse;
  }

  .btn-search,
  .btn-clear {
    width: 100%;
  }

  .advanced-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .advanced-header #resultStats {
    text-align: left;
    width: 100%;
  }
}

.error-container {
  max-width: 800px;
  margin: 50px auto;
  padding: 40px 20px;
  text-align: center;
}

.error-code {
  font-size: 120px;
  font-weight: bold;
  margin: 30px 0 0 0;
  line-height: 1;
  font-family: 'Gabriela', serif;
}

.error-title {
  font-size: 2em;
  margin: 20px 0;
}

.error-message {
  font-size: 1.2em;
  margin: 20px 0 30px 0;
}
/* ============================================
   Vanilla JS Autocomplete Styles
   ============================================ */

.autocomplete-suggestions {
  position: absolute;
  z-index: 1000;
  background: var(--bg-primary);
  border: 1px solid var(--input-border);
  border-radius: 0 0 5px 5px;
  box-shadow: 0 1px 4px 0 var(--shadow-color);
  max-height: 300px;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 0;
  left: 0;
  right: 0;
  top: 100%;
}

.autocomplete-item {
  padding: 10px 15px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.2s;
  font-size: 1em;
  text-align: center;
  color: var(--text-primary);
}

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

.autocomplete-item:hover,
.autocomplete-item.selected {
  background-color: var(--bg-secondary);
  color: var(--link-color);
}

.autocomplete-item.selected {
  font-weight: 500;
}

/* Ensure autocomplete container is positioned relative */
.autocomplete-wrapper {
  position: relative;
  flex: 1;
  display: flex;
}

/* Make sure #text_span is positioned for autocomplete */
#text_span {
  position: relative;
}

/* ============================================
   Smooth Transitions for Vanilla JS
   ============================================ */

/* Slide toggle transitions */
.slide-transition {
  transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
  overflow: hidden;
}

.slide-hidden {
  max-height: 0 !important;
  opacity: 0;
}

/* Fade transitions */
.fade-transition {
  transition: opacity 0.3s ease-out;
}

.fade-hidden {
  opacity: 0;
  pointer-events: none;
}

/* ============================================
   Icon Buttons (replacing jQuery UI button)
   ============================================ */

/* Filter buttons - icon only style */
#downloadWordlist,
#cancelFilters {
  width: 2.2em;
  height: 2.2em;
  padding: 0.4em;
  text-indent: -9999px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--input-border);
  border-radius: 3px;
  background: var(--bg-tertiary);
  background-image: linear-gradient(var(--bg-secondary), var(--bg-tertiary));
  cursor: pointer;
  transition: background-color 0.2s;
}

#downloadWordlist:hover,
#cancelFilters:hover {
  background: var(--bg-secondary);
  background-image: linear-gradient(var(--bg-primary), var(--bg-secondary));
}

/* Font Awesome icons as pseudo-elements */
#downloadWordlist::before,
#cancelFilters::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: FontAwesome;
  font-size: 1.2em;
  text-indent: 0;
  color: var(--text-primary);
}

#downloadWordlist::before {
  content: '\f019'; /* fa-download */
}

#cancelFilters::before {
  content: '\f0e2'; /* fa-undo */
}

/* ====================================================================
   Deep Links - Enlaces profundos automáticos
   ==================================================================== */

/* Elementos que contienen anclas deben ser position: relative */
.deep-linkable h2,
.deep-linkable h3,
.deep-linkable h4,
.deep-linkable h5,
.deep-linkable h6,
.deep-linkable p,
.deep-linkable li,
.deep-linkable dt {
  position: relative;
}

/* Estilo base del ancla - position absolute sin left/right mantiene posición inline */
.anchor-link {
  position: absolute;
  margin-left: 0.3em;
  opacity: 0;
  text-decoration: none;
  color: var(--text-tertiary);
  font-weight: normal;
  transition: opacity 0.2s ease, color 0.2s ease;
  user-select: none;
  white-space: nowrap;
}

/* Tamaños según tipo de elemento */
h2 .anchor-link,
h3 .anchor-link,
h4 .anchor-link,
dt .anchor-link {
  font-size: 0.85em;
}

h5 .anchor-link,
h6 .anchor-link,
p .anchor-link,
li .anchor-link {
  font-size: 0.8em;
}

/* Mostrar al hacer hover sobre el elemento padre */
/* Usar > para seleccionar solo hijos directos, no descendientes anidados */
h2:hover > .anchor-link,
h3:hover > .anchor-link,
h4:hover > .anchor-link,
h5:hover > .anchor-link,
h6:hover > .anchor-link,
dt:hover > .anchor-link,
p:hover > .anchor-link,
li:hover > .anchor-link {
  opacity: 1;
}

/* Cambiar color al hacer hover sobre el ancla misma */
.anchor-link:hover {
  color: var(--text-primary);
}

/* Cuando el elemento es el target del hash, mostrar siempre */
:target > .anchor-link {
  opacity: 0.5;
}

/* Highlight suave cuando un elemento es el target */
:target {
  animation: highlight 2s ease;
}

@keyframes highlight {
  0% {
    background-color: var(--badge-bg);
  }
  100% {
    background-color: transparent;
  }
}

/* ============================================
   Toggle Switch Component (iOS/Android style)
   Reusable component for on/off controls
   ============================================ */

.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  cursor: pointer;
  padding: 4px 0;
}

.toggle-label input[type="checkbox"] {
  display: none;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  background-color: var(--input-border);
  border-radius: 20px;
  transition: background-color 0.3s;
  flex-shrink: 0;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: white;
  top: 2px;
  left: 2px;
  transition: transform 0.3s;
}

.toggle-label input[type="checkbox"]:checked + .toggle-switch {
  background-color: var(--link-color);
}

.toggle-label input[type="checkbox"]:checked + .toggle-switch::after {
  transform: translateX(16px);
}

.toggle-label:hover .toggle-switch {
  opacity: 0.8;
}

.toggle-label span:not(.toggle-switch) {
  user-select: none;
}

/* ============================================
   UI Buttons Container (Flexible Layout)
   ============================================ */

.ui-buttons-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 12px;
}

@media (max-width: 768px) {
  .ui-buttons-container {
    top: 10px;
    right: 10px;
    flex-direction: column-reverse;
    gap: 6px;
  }
}

/* ============================================
   Dark Mode Toggle Button
   ============================================ */

.theme-toggle {
  position: relative;
  background-color: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px var(--shadow-color);
}

.theme-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px var(--shadow-color);
}

.theme-toggle:active {
  transform: scale(0.95);
}

.theme-icon {
  transition: opacity 0.3s ease;
}

@media (max-width: 768px) {
  .theme-toggle {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }
}

/* ============================================
   Advent of Iedra Menu (Button + Dropdown)
   ============================================ */

.advent-menu-container {
  position: relative;
}

.advent-menu-toggle {
  position: relative;
  background-color: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  box-shadow: 0 2px 8px var(--shadow-color);
}

.advent-menu-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px var(--shadow-color);
}

.advent-menu-toggle:active {
  transform: scale(0.95);
}

.advent-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 24px;
  user-select: none;
}

.advent-menu-dropdown {
  position: absolute;
  top: 60px;
  right: 0;
  z-index: 1010;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-top-width: 0;
  border-bottom-width: 2px;
  border-radius: 3px;
  min-width: 240px;
  max-width: 280px;
  padding: 1em;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  text-decoration: none;
  color: inherit;
}

.advent-menu-dropdown.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.advent-menu-dropdown:hover {
  background-color: var(--bg-tertiary);
}

.advent-menu-header {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  padding-bottom: 0.5em;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 0.75em;
}

.advent-menu-entries {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 8em;
  overflow: hidden;
}

.advent-menu-entry {
  display: flex;
  align-items: center;
  gap: 0.75em;
  margin-bottom: 0.75em;
}

.advent-menu-entry:last-child {
  margin-bottom: 0;
}

/* Opacity gradient for older entries */
.advent-menu-entry[data-age="0"] {
  opacity: 1;
}

.advent-menu-entry[data-age="1"] {
  opacity: 0.7;
}

.advent-menu-entry[data-age="2"] {
  opacity: 0.4;
}

.advent-calendar-box {
  flex-shrink: 0;
  width: 2.5em;
  text-align: center;
  border: 1px solid var(--border-color);
  border-radius: 3px;
  overflow: hidden;
}

.advent-calendar-day {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  padding: 0.2em 0;
  border-bottom: 1px solid var(--border-color);
}

.advent-calendar-month {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  background-color: var(--bg-primary);
  padding: 0.2em 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.advent-entry-name {
  font-size: 12px;
  color: var(--text-primary);
  line-height: 1.4;
  flex: 1;
  padding-top: 0.1em;
}

/* Mobile styles */
@media (max-width: 768px) {
  .advent-menu-toggle {
    width: 40px;
    height: 40px;
  }

  .advent-icon {
    font-size: 20px;
  }

  .advent-menu-dropdown {
    top: 50px;
    min-width: 200px;
    max-width: calc(100vw - 20px);
  }

  .advent-menu-header {
    font-size: 13px;
  }

  .advent-entry-day {
    font-size: 10px;
  }

  .advent-entry-name {
    font-size: 12px;
  }

  .advent-menu-blog-link {
    font-size: 12px;
    padding: 8px;
  }
}

/* ============================================
   Dark Mode Element Overrides
   ============================================ */

/* Links - already handled globally */

/* Select elements */
select {
  background-color: var(--input-bg);
  color: var(--text-primary);
  border-color: var(--input-border);
}

/* Textareas */
textarea {
  background-color: var(--input-bg);
  color: var(--text-primary);
  border-color: var(--input-border);
}

/* Secondary backgrounds for containers */
.rhyme-info {
  background-color: var(--bg-secondary);
  border-color: var(--border-color);
}

/* Table elements */
table,
td,
th {
  border-color: var(--border-color);
}

/* Search results */
#searchresults li {
  border-color: var(--border-color);
}

/* Definition tags */
.definitionTags a {
  background-color: var(--badge-bg);
  color: var(--badge-text);
  border-color: var(--border-dark);
}

/* Dictionary source badges (moliner, seco) */
.dict-badge {
  font-size: 11px;
  border: 1px solid var(--border-dark);
  border-radius: 4px;
  background-color: var(--badge-bg);
  color: var(--badge-text);
  padding: 2px 4px;
  vertical-align: super;
}

/* Code and monospace elements */
code {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-color);
  padding: 2px 4px;
  border-radius: 3px;
}

.ipa-notation,
.rhyme-pattern {
  color: var(--text-primary);
}
