:root {
  --bg: #f6f1e8;
  --surface: #fffdf8;
  --ink: #2c2416;
  --muted: #6b5f4e;
  --accent: #8b4513;
  --accent-hover: #6d3410;
  --border: #ddd3c4;
  --error: #9b2c2c;
  --success-bg: #e8f0e4;
  --success-ink: #2d5016;
  --error-bg: #fce8e8;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(44, 36, 22, 0.08);
  --font-serif: "Cormorant Garamond", Georgia, serif;
  --font-sans: "Source Sans 3", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}

html {
  overflow-x: clip;
}

.site-body {
  display: flex;
  flex-direction: column;
  overflow-x: clip;
  max-width: 100%;
}

.site-body > main {
  flex: 1 0 auto;
}

.container {
  width: min(960px, 100% - 2rem);
  max-width: 100%;
  margin-inline: auto;
}

h1, h2, h3 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.2;
}

h1 { font-size: 2rem; margin: 0 0 0.5rem; }
h2 { font-size: 1.35rem; margin: 0 0 0.75rem; }

a, p, li, h1, h2, h3, td, th {
  overflow-wrap: break-word;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  max-width: 100%;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-block: 1rem;
  min-width: 0;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
}

.logo span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logo-mark {
  flex-shrink: 0;
  border-radius: 6px;
}

.nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem 0.75rem;
  min-width: 0;
}

.nav-user {
  color: var(--muted);
  font-size: 0.9rem;
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-logout-form {
  display: inline;
  margin: 0;
}

.nav-logout-button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--accent);
  cursor: pointer;
}

.nav-logout-button:hover {
  text-decoration: underline;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 0.3rem;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}

.nav-toggle:hover {
  border-color: rgba(139, 69, 19, 0.35);
  background: #fff;
}

.nav-toggle-bar {
  display: block;
  width: 1.15rem;
  height: 2px;
  margin-inline: auto;
  border-radius: 1px;
  background: currentColor;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.site-header.is-nav-open .nav-toggle-bar:nth-child(1) {
  transform: translateY(0.45rem) rotate(45deg);
}

.site-header.is-nav-open .nav-toggle-bar:nth-child(2) {
  opacity: 0;
}

.site-header.is-nav-open .nav-toggle-bar:nth-child(3) {
  transform: translateY(-0.45rem) rotate(-45deg);
}

@media (prefers-reduced-motion: reduce) {
  .nav-toggle-bar {
    transition: none;
  }
}

.main-content {
  padding-block: 2rem 4rem;
  min-width: 0;
  max-width: 100%;
}

.lede, .meta, .help {
  color: var(--muted);
}

.lede { margin-top: 0; }
.meta { font-size: 0.9rem; margin: 0.25rem 0 0; }
.breadcrumb { font-size: 0.9rem; margin: 0 0 0.5rem; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.btn {
  display: inline-block;
  padding: 0.55rem 1.1rem;
  font: inherit;
  font-weight: 500;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
}

.btn:hover {
  background: var(--accent-hover);
  text-decoration: none;
}

.btn-secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.btn-secondary:hover {
  background: rgba(139, 69, 19, 0.08);
}

.btn-danger {
  background: var(--error);
}

.btn-danger:hover {
  background: #7a2222;
}

.btn-small {
  padding: 0.35rem 0.75rem;
  font-size: 0.875rem;
}

.auth-card, .narrow {
  max-width: 420px;
  margin: 2rem auto;
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.narrow {
  max-width: 560px;
}

.auth-footer {
  margin-top: 1.5rem;
  text-align: center;
  color: var(--muted);
}

.stack-form .field,
.auth-card .field {
  margin-bottom: 1rem;
}

label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.35rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="file"],
select,
textarea {
  /* Base look lives in forms.css; keep a minimal fallback here. */
  width: 100%;
  padding: 0.55rem 0.65rem;
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(139, 69, 19, 0.35);
  border-color: var(--accent);
}

.field-error input,
.field-error select,
.field-error textarea {
  border-color: var(--error);
}

.error, .form-errors {
  color: var(--error);
  font-size: 0.875rem;
  margin: 0.25rem 0 0;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.messages {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
}

.message {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
}

.message-success, .message.info {
  background: var(--success-bg);
  color: var(--success-ink);
}

.message-error {
  background: var(--error-bg);
  color: var(--error);
}

.card-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 1rem;
}

.card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0;
  font-size: 1.25rem;
}

.card h2 a {
  color: var(--ink);
}

.card-actions {
  flex-shrink: 0;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.subnav {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.subnav::-webkit-scrollbar {
  display: none;
}

.subnav-link {
  font-weight: 500;
  flex-shrink: 0;
  white-space: nowrap;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  padding: 1rem;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.stat-value {
  display: block;
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 600;
}

.stat-label {
  color: var(--muted);
  font-size: 0.875rem;
}

.quick-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 2rem;
}

@media (max-width: 700px) {
  .two-col {
    grid-template-columns: 1fr;
  }

  .page-header {
    flex-direction: column;
  }

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

.member-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.member-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
}

.member-info {
  flex: 1;
  min-width: 0;
}

.member-info .meta {
  display: block;
}

.member-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.role-form select {
  width: auto;
  min-width: 7rem;
}

.badge {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.5rem;
  background: var(--border);
  border-radius: 4px;
  color: var(--muted);
}

.file-link {
  font-size: 0.9rem;
}

.inline-form {
  display: inline;
}

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

.subnav-link-active {
  font-weight: 600;
  text-decoration: underline;
}

.search-form {
  margin-bottom: 1.5rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.search-input-row {
  display: flex;
  gap: 0.5rem;
}

.search-input {
  flex: 1;
  padding: 0.55rem 0.65rem;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.search-scope {
  border: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
}

.scope-option {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
  cursor: pointer;
}

.search-summary {
  color: var(--muted);
  margin: 0 0 1.25rem;
}

.search-section {
  margin-bottom: 2rem;
}

.search-section h2 {
  font-size: 1.15rem;
  margin-bottom: 0.75rem;
}

.search-result-card h3 {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  margin: 0 0 0.35rem;
}

.match-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.5rem 0;
}

.match-tag {
  font-size: 0.75rem;
  padding: 0.15rem 0.45rem;
  background: rgba(139, 69, 19, 0.12);
  color: var(--accent);
  border-radius: 4px;
}

.search-snippet {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0.35rem 0 0;
  line-height: 1.45;
}

.snippet-label {
  font-weight: 600;
  color: var(--ink);
}

mark {
  background: #f5e6a8;
  padding: 0 0.1em;
  border-radius: 2px;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.filter-label {
  font-size: 0.9rem;
  color: var(--muted);
  margin-right: 0.25rem;
}

.filter-pill {
  display: inline-block;
  padding: 0.3rem 0.75rem;
  font-size: 0.875rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  text-decoration: none;
}

.filter-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.filter-pill-active {
  background: rgba(139, 69, 19, 0.12);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 500;
}

.document-list-filters {
  margin-bottom: 1.25rem;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.document-list-filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.85rem 1rem;
}

.document-list-filters .filter-field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.document-list-filters .filter-field select {
  width: 100%;
  padding: 0.45rem 0.55rem;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
}

.document-list-filters-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.85rem;
}

.doc-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.5rem 0 0;
}

.doc-tags:empty {
  display: none;
}

.doc-tag {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

.doc-tag-transcribed {
  background: #e8eef5;
  color: #2c4a6e;
}

.doc-tag-modern {
  background: #ede8f5;
  color: #4a2c6e;
}

.doc-tag-no-transcription {
  background: rgba(107, 95, 78, 0.12);
  color: var(--muted);
}

.work-transcription-toggle {
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.field-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  margin-bottom: 0;
}

.field-checkbox .field-checkbox-copy label {
  display: block;
  font-weight: 500;
  cursor: pointer;
}

.field-checkbox .field-hint {
  margin: 0.2rem 0 0;
}

.work-checkbox-input {
  width: 1rem;
  height: 1rem;
  margin-top: 0.15rem;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.transcription-progress {
  margin-bottom: 1.25rem;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.transcription-progress-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 0.85rem;
}

.transcription-progress-title {
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
}

.transcription-progress-summary {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.transcription-progress-meta {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.transcription-progress-continue {
  flex-shrink: 0;
}

.transcription-progress-bar {
  display: flex;
  width: 100%;
  height: 0.65rem;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(107, 95, 78, 0.12);
}

.transcription-progress-segment {
  height: 100%;
  min-width: 0;
  transition: width 0.2s ease;
}

.transcription-progress-segment--complete {
  background: #5a7a48;
}

.transcription-progress-segment--partial {
  background: #c49a3a;
}

.transcription-progress-segment--none {
  background: rgba(107, 95, 78, 0.28);
}

.transcription-progress-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1.25rem;
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.875rem;
}

.transcription-progress-legend a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--ink);
  text-decoration: none;
}

.transcription-progress-legend a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.transcription-progress-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  flex-shrink: 0;
}

.transcription-progress-dot--complete {
  background: #5a7a48;
}

.transcription-progress-dot--partial {
  background: #c49a3a;
}

.transcription-progress-dot--none {
  background: rgba(107, 95, 78, 0.45);
}

.transcription-progress-dot--excluded {
  background: rgba(107, 95, 78, 0.22);
  box-shadow: inset 0 0 0 1px rgba(107, 95, 78, 0.35);
}

.transcription-progress-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  margin: 0.85rem 0 0;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
}

.transcription-progress-steps div {
  display: flex;
  gap: 0.45rem;
  align-items: baseline;
}

.transcription-progress-steps dt {
  margin: 0;
  font-weight: 600;
  color: var(--muted);
}

.transcription-progress-steps dd {
  margin: 0;
  color: var(--ink);
}

.entity-page {
  width: min(100% - 1rem, 960px);
  max-width: 100%;
  margin-inline: auto;
  padding: 1rem 0.5rem 2rem;
  min-width: 0;
}

.entity-header {
  margin-bottom: 0.75rem;
  min-width: 0;
}

.entity-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.entity-tabs::-webkit-scrollbar {
  display: none;
}

.entity-tab {
  padding: 0.65rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  flex-shrink: 0;
  white-space: nowrap;
}

.entity-tab:hover {
  color: var(--accent);
  text-decoration: none;
}

.entity-tab-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.entity-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.entity-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}

.entity-list li,
.entity-list-row {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.entity-list-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.relationship-group-heading {
  margin: 1.25rem 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted, #666);
}

.relationship-group-heading:first-child {
  margin-top: 0;
}

.panel-heading {
  margin: 1.25rem 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
}

.panel-heading:first-child {
  margin-top: 0;
}

.entity-two-col {
  display: grid;
  grid-template-columns: 1fr min(300px, 35%);
  gap: 1rem;
  align-items: start;
}

.entity-aside {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.panel-toolbar {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.text-link {
  font-weight: 500;
}

@media (max-width: 768px) {
  .container {
    width: 100%;
    padding-left: max(1.25rem, env(safe-area-inset-left, 0px));
    padding-right: max(1.25rem, env(safe-area-inset-right, 0px));
  }

  .site-header {
    position: relative;
    z-index: 50;
  }

  .site-header .header-inner {
    padding-block: 1rem;
    padding-left: max(1.5rem, env(safe-area-inset-left, 0px));
    padding-right: max(1.5rem, env(safe-area-inset-right, 0px));
  }

  .header-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "logo toggle"
      "nav nav";
    align-items: center;
    gap: 0.75rem;
  }

  .logo {
    grid-area: logo;
    font-size: 1.15rem;
  }

  .nav-toggle {
    display: flex;
    grid-area: toggle;
  }

  .nav {
    grid-area: nav;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    width: 100%;
    margin-inline: 0;
    padding: 0.5rem 0.25rem 0.85rem;
    border-top: 1px solid var(--border);
  }

  .site-header.is-nav-open .nav {
    display: flex;
  }

  .nav > .language-switcher,
  .nav > a,
  .nav > .nav-user,
  .nav > .nav-logout-form {
    padding: 0.8rem 0.35rem;
  }

  .nav > * + * {
    border-top: 1px solid rgba(44, 36, 22, 0.08);
  }

  .nav-user {
    display: block;
    max-width: none;
    font-size: 0.875rem;
    color: var(--muted);
    overflow-wrap: anywhere;
    white-space: normal;
  }

  .nav a {
    font-weight: 500;
    color: var(--ink);
  }

  .nav a:hover {
    color: var(--accent);
  }

  .nav-logout-form {
    display: block;
  }

  .nav-logout-button {
    display: block;
    width: 100%;
    padding: 0;
    text-align: left;
    font-weight: 500;
  }

  .nav-register-btn {
    display: block;
    width: 100%;
    text-align: center;
    margin-top: 0.35rem;
  }

  .language-switcher {
    width: 100%;
  }

  .language-dropdown {
    width: 100%;
  }

  .language-toggle {
    width: 100%;
    justify-content: flex-start;
  }

  .language-menu {
    left: 0;
    right: auto;
    width: 100%;
    min-width: 0;
  }

  .main-content {
    padding-block: 1.25rem 2.5rem;
  }

  .entity-two-col {
    grid-template-columns: 1fr;
  }
}

/* Collapsible filter / control panels on small screens */
.mobile-collapsible-panel > summary {
  display: none;
  list-style: none;
}

.mobile-collapsible-panel > summary::-webkit-details-marker {
  display: none;
}

.mobile-collapsible-summary {
  display: none;
}

@media (min-width: 901px) {
  .mobile-collapsible-panel--filters,
  .mobile-collapsible-panel--viewport {
    display: contents;
  }

  .mobile-collapsible-panel > summary,
  .mobile-collapsible-summary {
    display: none !important;
  }

  .mobile-collapsible-panel--viewport > :not(summary) {
    display: flex !important;
  }
}

@media (max-width: 900px) {
  .mobile-collapsible-panel {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: hidden;
  }

  .mobile-collapsible-panel > summary.mobile-collapsible-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.8rem 1rem;
    font-family: var(--font-serif);
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink);
    cursor: pointer;
    user-select: none;
    list-style: none;
  }

  .mobile-collapsible-panel > summary.mobile-collapsible-summary::after {
    content: "";
    flex-shrink: 0;
    width: 0.45rem;
    height: 0.45rem;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(45deg);
    margin-top: -0.15rem;
    transition: transform 0.2s ease;
  }

  .mobile-collapsible-panel[open] > summary.mobile-collapsible-summary::after {
    transform: rotate(-135deg);
    margin-top: 0.15rem;
  }

  .mobile-collapsible-panel--filters:not([open]) {
    margin-bottom: 0.75rem;
  }

  .mobile-collapsible-panel--filters[open] > :not(summary) {
    border-top: 1px solid var(--border);
    max-height: min(62vh, 28rem);
    overflow-y: auto;
  }

  .mobile-collapsible-panel--filters .filters-heading {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .mobile-collapsible-panel--viewport {
    position: absolute;
    z-index: 4;
    border: none;
    background: transparent;
    box-shadow: none;
    overflow: visible;
  }

  .mobile-collapsible-panel--viewport > summary.mobile-collapsible-summary {
    padding: 0.55rem 0.85rem;
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    font-weight: 600;
    background: rgba(255, 252, 247, 0.96);
    border: 1px solid rgba(44, 36, 22, 0.12);
    border-radius: 999px;
    box-shadow: 0 2px 10px rgba(44, 36, 22, 0.1);
  }

  .mobile-collapsible-panel--viewport[open] > summary.mobile-collapsible-summary {
    border-radius: var(--radius) var(--radius) 0 0;
    border-bottom: none;
  }

  .mobile-collapsible-panel--viewport[open] > :not(summary) {
    border: 1px solid rgba(44, 36, 22, 0.12);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    background: rgba(255, 252, 247, 0.96);
    box-shadow: 0 4px 16px rgba(44, 36, 22, 0.12);
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.language-switcher {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.language-dropdown {
  position: relative;
}

.language-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  list-style: none;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.language-toggle::-webkit-details-marker {
  display: none;
}

.language-toggle::marker {
  content: "";
}

.language-toggle:hover,
.language-dropdown[open] > .language-toggle {
  border-color: rgba(139, 69, 19, 0.35);
  background: #fff;
  box-shadow: 0 2px 6px rgba(44, 36, 22, 0.08);
}

.language-globe {
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
  color: var(--accent);
}

.language-toggle-code {
  min-width: 1.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.language-menu {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  z-index: 40;
  min-width: 11.5rem;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(44, 36, 22, 0.12);
}

.language-menu-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid transparent;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.language-menu-item:hover {
  background: rgba(139, 69, 19, 0.06);
  border-color: rgba(139, 69, 19, 0.1);
}

.language-menu-item.is-active {
  background: rgba(139, 69, 19, 0.08);
  border-color: rgba(139, 69, 19, 0.14);
  color: var(--accent);
}

.language-menu-label {
  flex: 1;
}

.language-menu-check {
  width: 0.45rem;
  height: 0.75rem;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(45deg) translate(-2px, -1px);
  flex-shrink: 0;
}

.language-flag {
  width: 1.15rem;
  height: 0.78rem;
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px rgba(44, 36, 22, 0.12);
  flex-shrink: 0;
}

.language-flag--en {
  background: url("../img/flags/gb.a6ac66500ead.svg") center / cover no-repeat;
  background-color: #012169;
}

.language-flag--es {
  background: linear-gradient(
    to bottom,
    #aa151b 0 25%,
    #f1bf00 25% 75%,
    #aa151b 75% 100%
  );
}

.language-flag--gl {
  background:
    linear-gradient(135deg, transparent 42%, #0057b8 42%, #0057b8 58%, transparent 58%),
    linear-gradient(45deg, transparent 42%, #0057b8 42%, #0057b8 58%, transparent 58%),
    #fff;
}

@media (max-width: 640px) {
  .language-toggle-code {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .language-toggle {
    padding: 0.45rem 0.55rem;
  }

  .nav .language-toggle {
    padding: 0.55rem 0.65rem;
  }

  .language-menu {
    left: 0;
    right: auto;
    width: 100%;
    min-width: 0;
  }
}

.site-footer {
  flex-shrink: 0;
  margin-top: auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
  max-width: 100%;
  overflow-x: clip;
}

.site-footer-inner {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 2rem;
  padding: 2.25rem 0 1.75rem;
  min-width: 0;
}

.site-footer-logo {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
}

.site-footer-logo:hover {
  color: var(--accent);
  text-decoration: none;
}

.site-footer-tagline {
  margin: 0.45rem 0 0;
  max-width: 24rem;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--muted);
}

.site-footer-nav {
  display: flex;
  justify-content: flex-end;
  gap: 2.5rem;
}

.site-footer-heading {
  margin: 0 0 0.65rem;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.site-footer-links {
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-footer-links li + li {
  margin-top: 0.4rem;
}

.site-footer-links a {
  font-size: 0.92rem;
  color: var(--ink);
  text-decoration: none;
}

.site-footer-links a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.site-footer-bottom {
  border-top: 1px solid var(--border);
  background: rgba(139, 69, 19, 0.03);
}

.site-footer-bottom-inner {
  padding: 0.85rem 0;
}

.site-footer-copy {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

@media (max-width: 640px) {
  .site-footer-inner {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .site-footer-nav {
    justify-content: flex-start;
  }
}
