:root {
  --es-grammar-blue: #245b9e;
  --es-grammar-red: #a82932;
  --es-grammar-red-dark: #7f2028;
  --es-grammar-yellow: #d3a514;
  --es-grammar-ink: #17202a;
  --es-grammar-muted: #5f6b76;
  --es-grammar-border: #dce2e6;
  --es-grammar-surface: #ffffff;
  --es-grammar-tint: #f6f8f8;
}

body.page-gramatica-es {
  background: var(--es-grammar-tint);
  color: var(--es-grammar-ink);
}

body.page-gramatica-es main.section.container {
  box-sizing: border-box;
  max-width: 840px;
  padding-top: 8rem;
  padding-bottom: 4rem;
}

.es-grammar-article {
  max-width: 760px;
  margin: 0 auto;
  color: var(--es-grammar-ink);
  line-height: 1.72;
}

.es-grammar-back {
  display: inline-block;
  margin-bottom: 0.75rem;
  color: var(--es-grammar-red-dark);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
}

.es-grammar-back::before {
  content: '\2190';
  margin-right: 0.4rem;
}

.es-topic-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0 0 1.75rem;
  padding: 0.7rem;
  border: 1px solid var(--es-grammar-border);
  border-radius: 8px;
  background: var(--es-grammar-surface);
}

.es-topic-nav a {
  padding: 0.42rem 0.72rem;
  border: 1px solid var(--es-grammar-border);
  border-radius: 6px;
  color: var(--es-grammar-red-dark);
  font-size: 0.83rem;
  font-weight: 700;
  line-height: 1.25;
  text-decoration: none;
  white-space: nowrap;
}

.es-topic-nav a:hover {
  border-color: var(--es-grammar-red);
  background: #fbf0f1;
}

.es-topic-nav a.active {
  border-color: var(--es-grammar-red);
  background: var(--es-grammar-red);
  color: #ffffff;
  pointer-events: none;
}

.es-grammar-kicker {
  margin: 0 0 0.4rem;
  color: var(--es-grammar-red-dark);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.es-grammar-article h1 {
  margin: 0 0 0.75rem;
  color: var(--es-grammar-blue);
  font-size: clamp(2rem, 5vw, 2.8rem);
  letter-spacing: 0;
}

.es-grammar-lead {
  max-width: 68ch;
  margin-bottom: 2.1rem;
  color: var(--es-grammar-muted);
  font-size: 1.06rem;
  line-height: 1.72;
}

.es-grammar-section {
  margin: 0;
  padding: 1.65rem 0;
  border-top: 1px solid var(--es-grammar-border);
}

.es-grammar-section:first-of-type {
  border-top: 2px solid var(--es-grammar-red);
}

.es-grammar-section h2 {
  margin: 0 0 0.75rem;
  color: var(--es-grammar-red-dark);
  font-size: 1.28rem;
  letter-spacing: 0;
}

.es-grammar-section p,
.es-grammar-section li {
  line-height: 1.72;
}

.es-grammar-section ul,
.es-grammar-section ol {
  margin-top: 0.75rem;
  padding-left: 1.3rem;
}

.es-grammar-section li + li {
  margin-top: 0.55rem;
}

.es-grammar-note {
  margin: 1rem 0;
  padding: 0.95rem 1rem;
  border: 1px solid #e3c7c9;
  border-left: 4px solid var(--es-grammar-red);
  border-radius: 6px;
  background: #fcf3f4;
}

.es-summary-list {
  margin-bottom: 0;
  padding: 1rem 1rem 1rem 2rem;
  border: 1px solid var(--es-grammar-border);
  border-top: 3px solid var(--es-grammar-yellow);
  border-radius: 6px;
  background: var(--es-grammar-surface);
}

.es-table-scroll {
  margin-top: 1rem;
  overflow-x: auto;
  border: 1px solid var(--es-grammar-border);
  border-radius: 6px;
  background: var(--es-grammar-surface);
}

.es-grammar-table {
  width: 100%;
  min-width: 590px;
  border-collapse: collapse;
}

.es-grammar-table th,
.es-grammar-table td {
  padding: 0.72rem 0.85rem;
  border-bottom: 1px solid var(--es-grammar-border);
  text-align: left;
  vertical-align: top;
}

.es-grammar-table th {
  background: #eef3f6;
  color: #34424d;
  font-size: 0.88rem;
}

.es-grammar-table td {
  font-size: 0.94rem;
}

.es-grammar-table tr:last-child td {
  border-bottom: 0;
}

.es-practice-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.75rem;
  color: var(--es-grammar-blue);
  font-weight: 700;
  text-decoration: none;
}

.es-practice-link:hover {
  text-decoration: underline;
}

.es-grammar-article a:focus-visible,
.es-topic-nav a:focus-visible,
#spanishGrammarExplorer a:focus-visible,
#spanishGrammarExplorer summary:focus-visible,
#spanishGrammarSearch:focus-visible {
  outline: 3px solid rgba(168, 41, 50, 0.22);
  outline-offset: 2px;
}

/* Explorer */
#spanishGrammarExplorer {
  max-width: 1040px;
}

.es-explorer-header {
  max-width: 900px;
  margin: 0 auto 2rem;
}

.es-explorer-header h1 {
  margin: 0 0 0.5rem;
  color: var(--es-grammar-blue);
  font-size: clamp(2rem, 5vw, 2.8rem);
  letter-spacing: 0;
}

.es-explorer-intro {
  max-width: 70ch;
  margin: 0;
  color: var(--es-grammar-muted);
  line-height: 1.7;
}

.es-explorer-tools {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  align-items: end;
  gap: 1rem;
  margin-top: 1.25rem;
}

.es-grammar-search {
  position: relative;
}

.es-grammar-search i {
  position: absolute;
  top: 50%;
  left: 1rem;
  color: #687681;
  transform: translateY(-50%);
  pointer-events: none;
}

.es-grammar-search input {
  box-sizing: border-box;
  width: 100%;
  min-height: 48px;
  padding: 0.75rem 1rem 0.75rem 2.75rem;
  border: 1px solid #bbc6cd;
  border-radius: 6px;
  background: #ffffff;
  color: var(--es-grammar-ink);
  font: inherit;
}

.es-topic-filter {
  display: inline-flex;
  margin: 0;
  padding: 3px;
  border: 1px solid var(--es-grammar-border);
  border-radius: 6px;
  background: #ffffff;
}

.es-topic-filter legend,
.es-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.es-topic-filter label {
  position: relative;
  flex: 1;
  cursor: pointer;
}

.es-topic-filter input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.es-topic-filter span {
  display: block;
  padding: 0.55rem 0.72rem;
  border-radius: 4px;
  color: var(--es-grammar-muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}

.es-topic-filter input:checked + span {
  background: var(--es-grammar-red);
  color: #ffffff;
}

.es-search-status {
  min-height: 1.5rem;
  margin: 0.55rem 0 0;
  color: var(--es-grammar-muted);
  font-size: 0.9rem;
}

.es-grammar-accordion {
  max-width: 900px;
  min-width: 0;
  margin: 0 auto;
}

.es-level {
  margin-bottom: 1rem;
  overflow: hidden;
  border: 1px solid var(--es-grammar-border);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 2px 7px rgba(23, 32, 42, 0.04);
}

.es-level > summary,
.es-group > summary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  cursor: pointer;
  list-style: none;
}

.es-level > summary::-webkit-details-marker,
.es-group > summary::-webkit-details-marker {
  display: none;
}

.es-level > summary::after,
.es-group > summary::after {
  content: '+';
  position: static;
  inset: auto;
  display: block;
  width: 1em;
  height: 1em;
  border: 0;
  background: none;
  margin-left: auto;
  color: var(--es-grammar-red);
  font-family: Arial, sans-serif;
  font-size: 1.3rem;
  line-height: 1;
  text-align: center;
  transform: none !important;
}

.es-level[open] > summary::after,
.es-group[open] > summary::after {
  content: '\2212';
  transform: none !important;
}

.es-level > summary h2 {
  margin: 0;
  color: var(--es-grammar-ink);
  font-size: 1.2rem;
  letter-spacing: 0;
}

.es-level-content {
  padding: 0 1rem 1rem;
}

.es-group {
  border-top: 1px solid var(--es-grammar-border);
}

.es-group > summary {
  color: var(--es-grammar-red-dark);
  font-weight: 700;
}

.es-group:not(.live) > summary {
  color: #697781;
}

.es-topic-list {
  margin: 0 0 0.75rem;
  padding: 0.75rem 1rem 0.75rem 2rem;
  border-left: 3px solid #e1bdc0;
  background: #fcf7f7;
}

.es-topic-list li + li {
  margin-top: 0.4rem;
}

.es-topic-list a {
  color: var(--es-grammar-red-dark);
  font-weight: 600;
  text-decoration: none;
}

.es-topic-list a:hover {
  text-decoration: underline;
}

.es-topic-planned {
  color: #75818a;
}

.es-topic-planned::after {
  content: ' · previsto';
  color: #929ca3;
  font-size: 0.82em;
}

.es-topic-hidden,
.es-group-hidden,
.es-level-hidden {
  display: none !important;
}

@media (max-width: 700px) {
  .es-explorer-tools {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .es-topic-filter {
    width: 100%;
  }

  .es-topic-nav {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
  }

  .es-level > summary h2 {
    min-width: 0;
    font-size: 1.05rem;
    overflow-wrap: anywhere;
  }

  .es-grammar-section {
    padding-block: 1.35rem;
  }
}
