/* ============================================================
   Archithek Frontend — Bayerisches Archivhaus
   A Bavarian municipal archive with warmth, prestige & elegance
   ============================================================ */

/* ---------- CSS Custom Properties / Themes ---------- */

:root,
[data-theme="light"] {
  /* Parchment surfaces */
  --color-bg:            #F7F3ED;
  --color-bg-secondary:  #FFFDF8;
  --color-bg-tertiary:   #EDE8DF;
  --color-bg-elevated:   #FFFEF9;

  /* Walnut text */
  --color-text:          #2C2016;
  --color-text-secondary:#5C4F3D;
  --color-text-muted:    #918474;

  /* Borders — warm gold-tinted */
  --color-border:        #D6CCBA;
  --color-border-light:  #E8E0D2;

  /* Brand (overridden inline from Organization) */
  --color-brand:         var(--org-color-primary, #7A2E2E);
  --color-brand-light:   color-mix(in srgb, var(--color-brand) 12%, #FFFDF8);
  --color-brand-dark:    color-mix(in srgb, var(--color-brand) 75%, #1A0A0A);
  --color-accent:        var(--org-color-secondary, #B8860B);

  /* Gold accent */
  --color-gold:          #B8960F;
  --color-gold-light:    #D4AF37;
  --color-gold-dim:      rgba(184, 150, 15, .15);

  /* Sidebar — dark walnut wood */
  --sidebar-bg:          #1C150E;
  --sidebar-text:        #BFB09A;
  --sidebar-text-active: #F5EFE4;
  --sidebar-hover:       #2A1F14;
  --sidebar-active-bg:   var(--color-brand);
  --sidebar-width:       272px;
  --sidebar-collapsed:   68px;

  /* Cards */
  --card-bg:             #FFFEF9;
  --card-shadow:         0 1px 3px rgba(44,32,22,.06), 0 1px 2px rgba(44,32,22,.04);
  --card-shadow-hover:   0 16px 40px rgba(44,32,22,.10), 0 4px 12px rgba(44,32,22,.06);

  /* Misc */
  --color-success:       #3D6B3D;
  --color-danger:        #8B2500;
  --color-warning:       #B8860B;
  --color-info:          #2C5F7C;
  --overlay:             rgba(28,21,14,.55);

  /* Radii & Motion */
  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  14px;
  --radius-xl:  22px;
  --radius-full:9999px;
  --ease:       cubic-bezier(.22, 1, .36, 1);
  --ease-out:   cubic-bezier(0, 0, .2, 1);
  --ease-spring:cubic-bezier(.34, 1.56, .64, 1);
  --dur-fast:   180ms;
  --dur:        300ms;
  --dur-slow:   500ms;
  --dur-reveal: 700ms;

  /* Navbar */
  --navbar-height: 64px;

  /* Typography
     --font-body   : long-form / reading text, classical serif (EB Garamond)
     --font-display: titles & hero headings (Playfair Display)
     --font-sans   : fallback for small UI micro-text where serif would hurt legibility
     --font-serif  : legacy alias, kept for existing var(--font-serif, …) usages */
  --font-body:    'EB Garamond', Garamond, 'Adobe Garamond Pro', Georgia, 'Times New Roman', serif;
  --font-display: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-sans:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif:   var(--font-body);
}

[data-theme="dark"] {
  --color-bg:            #0F0C08;
  --color-bg-secondary:  #181410;
  --color-bg-tertiary:   #1E1914;
  --color-bg-elevated:   #1A1612;
  --color-text:          #E2D9CC;
  --color-text-secondary:#A89A88;
  --color-text-muted:    #6B5F50;
  --color-border:        #2E271E;
  --color-border-light:  #252018;
  --color-gold:          #D4AF37;
  --color-gold-light:    #E5C453;
  --color-gold-dim:      rgba(212, 175, 55, .12);
  --sidebar-bg:          #0A0806;
  --sidebar-hover:       #1A1510;
  --card-bg:             #181410;
  --card-shadow:         0 1px 4px rgba(0,0,0,.4);
  --card-shadow-hover:   0 16px 40px rgba(0,0,0,.5);
  --overlay:             rgba(0,0,0,.75);
}

[data-theme="high-contrast"] {
  --color-bg:            #000000;
  --color-bg-secondary:  #000000;
  --color-bg-tertiary:   #111111;
  --color-bg-elevated:   #000000;
  --color-text:          #FFFFFF;
  --color-text-secondary:#FFFFFF;
  --color-text-muted:    #CCCCCC;
  --color-border:        #FFFFFF;
  --color-border-light:  #888888;
  --color-brand:         #FFD700;
  --color-brand-light:   #FFF3B0;
  --color-brand-dark:    #B8960F;
  --color-accent:        #FFD700;
  --color-gold:          #FFD700;
  --color-gold-light:    #FFE44D;
  --color-gold-dim:      rgba(255, 215, 0, .2);
  --sidebar-bg:          #000000;
  --sidebar-text:        #FFFFFF;
  --sidebar-text-active: #FFD700;
  --sidebar-hover:       #222222;
  --sidebar-active-bg:   #FFD700;
  --card-bg:             #000000;
  --card-shadow:         0 0 0 2px #FFFFFF;
  --card-shadow-hover:   0 0 0 3px #FFD700;
  --overlay:             rgba(0,0,0,.9);
}

/* ---------- Keyframe Animations ---------- */

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(28px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(.92); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes timelinePulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--color-brand); }
  50%      { box-shadow: 0 0 0 6px transparent; }
}

@keyframes floatUp {
  from { opacity: 0; transform: translateY(40px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes ornamentDraw {
  from { width: 0; }
  to   { width: 60px; }
}

/* ---------- Reset & Base ---------- */

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: 1.0625rem;      /* ~17px — Garamond reads a touch smaller than Inter at 16px */
  line-height: 1.65;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "liga", "kern", "onum";
}

/* Transition enablement after first paint — prevents FOUC flash */
body.transitions-ready *,
body.transitions-ready *::before,
body.transitions-ready *::after {
  transition: background-color var(--dur) var(--ease),
              color var(--dur) var(--ease),
              border-color var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease),
              opacity var(--dur) var(--ease);
}

a { color: var(--color-brand); text-decoration: none; transition: color var(--dur-fast) var(--ease); }
a:hover { color: var(--color-brand-dark); text-decoration: none; }

img { max-width: 100%; height: auto; display: block; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: transparent;
  color: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: var(--color-text);
}

::selection {
  background: var(--color-brand);
  color: #fff;
}

/* Skip to content */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 9999;
  padding: .5rem 1rem;
  background: var(--color-brand);
  color: #fff;
  border-radius: var(--radius-md);
  font-weight: 600;
}
.skip-link:focus {
  top: 1rem;
  text-decoration: none;
}

/* ---------- Typography ---------- */

h1, h2, h3, .heading-serif {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -.025em;
  line-height: 1.15;
  color: var(--color-text);
}

h1 { font-size: clamp(2rem, 5vw, 3rem); }
h2 { font-size: clamp(1.5rem, 3.5vw, 2rem); }
h3 { font-size: clamp(1.15rem, 2.5vw, 1.4rem); }
h4 {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.3;
}

p { margin-bottom: .75rem; }
p:last-child { margin-bottom: 0; }

.text-muted { color: var(--color-text-muted); }
.text-secondary { color: var(--color-text-secondary); }
.text-small { font-size: .85rem; }

/* Ornamental divider — gold line with diamond center */
.ornament-divider {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: 2rem 0;
  color: var(--color-gold);
}
.ornament-divider::before,
.ornament-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--color-gold-light), transparent);
}
.ornament-divider span {
  font-size: .6rem;
}

/* ---------- Layout: Sidebar + Content ---------- */

.app-layout {
  display: flex;
  min-height: 100vh;
}

.app-sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  background-image: linear-gradient(180deg, rgba(255,255,255,.03) 0%, transparent 40%, rgba(0,0,0,.15) 100%);
  color: var(--sidebar-text);
  z-index: 50;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid rgba(255,255,255,.04);
  /* No transition until layout is settled — prevents FOUC on page load */
}
body.transitions-ready .app-sidebar {
  transition: width var(--dur-slow) var(--ease), transform var(--dur-slow) var(--ease);
}

.app-sidebar.collapsed {
  width: var(--sidebar-collapsed);
}
.app-sidebar.collapsed .sidebar-label,
.app-sidebar.collapsed .sidebar-section-label,
.app-sidebar.collapsed .sidebar-header-text {
  display: none;
}
.app-sidebar.collapsed .sidebar-link {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}
.app-sidebar.collapsed .sidebar-logo {
  padding: .75rem;
  justify-content: center;
}
.app-sidebar.collapsed .sidebar-logo img {
  max-width: 36px;
}

.app-content-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}
body.transitions-ready .app-content-wrapper {
  transition: margin-left var(--dur-slow) var(--ease);
}

.app-sidebar.collapsed ~ .app-content-wrapper {
  margin-left: var(--sidebar-collapsed);
}

/* ---------- Sidebar ---------- */

.sidebar-header {
  padding: 1.5rem 1.25rem 1.25rem;
  border-bottom: 1px solid rgba(184,150,15,.15);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: .75rem;
  text-decoration: none;
  color: #F5EFE4;
}
.sidebar-logo:hover { color: #fff; }
.sidebar-logo img {
  max-height: 40px;
  max-width: 140px;
  object-fit: contain;
}
.sidebar-logo-text {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: #F5EFE4;
  text-decoration: none;
  white-space: nowrap;
}
.sidebar-logo-text:hover { color: #fff; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: .5rem 0;
}

.sidebar-section-label {
  padding: 1.25rem 1.25rem .4rem;
  font-size: .6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .16em;
  color: var(--color-gold);
  opacity: .7;
}

.sidebar-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(184,150,15,.2), transparent);
  margin: .5rem 1.25rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem 1.25rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .88rem;
  font-weight: 500;
  border-radius: 0;
  position: relative;
  transition: all var(--dur-fast) var(--ease);
}
.sidebar-link::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--color-gold);
  border-radius: 0 2px 2px 0;
  transform: scaleY(0);
  transition: transform var(--dur) var(--ease-spring);
}
.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: #F5EFE4;
  text-decoration: none;
}
.sidebar-link:hover::before {
  transform: scaleY(1);
}
.sidebar-link.active {
  background: color-mix(in srgb, var(--color-brand) 85%, black);
  color: var(--sidebar-text-active);
  font-weight: 600;
}
.sidebar-link.active::before {
  transform: scaleY(1);
  background: var(--color-gold-light);
}
.sidebar-link .material-symbols-outlined {
  font-size: 1.25rem;
  flex-shrink: 0;
  transition: transform var(--dur-fast) var(--ease);
}
.sidebar-link:hover .material-symbols-outlined {
  transform: scale(1.1);
}

.sidebar-footer {
  padding: .75rem 1rem;
  border-top: 1px solid rgba(184,150,15,.15);
}

.sidebar-collapse-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: .5rem;
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  transition: all var(--dur-fast) var(--ease);
}
.sidebar-collapse-btn:hover {
  background: var(--sidebar-hover);
  color: #F5EFE4;
}

/* Mobile sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 45;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.sidebar-overlay.visible {
  display: block;
  animation: fadeIn var(--dur) var(--ease);
}

/* ---------- Navbar ---------- */

.app-navbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--navbar-height);
  min-height: var(--navbar-height);
  max-height: var(--navbar-height);
  flex-shrink: 0;
  background: color-mix(in srgb, var(--color-bg-secondary) 92%, transparent);
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  border-bottom: 1px solid var(--color-border-light);
  display: flex;
  align-items: center;
  padding: 0 1.75rem;
  gap: 1rem;
  contain: layout style;
  overflow: hidden;
}

.navbar-mobile-toggle {
  display: none;
  padding: .5rem;
  border-radius: var(--radius-md);
  transition: background var(--dur-fast) var(--ease);
}
.navbar-mobile-toggle:hover {
  background: var(--color-bg-tertiary);
}

.navbar-search {
  display: flex;
  align-items: center;
  flex: 0 1 340px;
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 0 .85rem;
  height: 40px;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.navbar-search:focus-within {
  border-color: var(--color-brand);
  box-shadow: 0 0 0 3px var(--color-brand-light);
}
.navbar-search-icon {
  font-size: 1.15rem;
  color: var(--color-text-muted);
  flex-shrink: 0;
}
.navbar-search-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  padding: .4rem .5rem;
  font-size: .9rem;
}

.navbar-controls {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-left: auto;
}

.navbar-ai-link {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .65rem .9rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: color-mix(in srgb, var(--color-bg-elevated) 88%, white);
  color: var(--color-text);
  white-space: nowrap;
  transition: all var(--dur-fast) var(--ease);
}

.navbar-ai-link.active,
.navbar-ai-link:hover {
  border-color: color-mix(in srgb, var(--color-brand) 44%, var(--color-border));
  color: var(--color-brand);
  text-decoration: none;
}

/* Language switcher */
.navbar-lang-switcher {
  display: flex;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.lang-btn {
  padding: .3rem .65rem;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .05em;
  color: var(--color-text-muted);
  text-decoration: none;
  background: transparent;
  transition: all var(--dur-fast) var(--ease);
}
.lang-btn:hover {
  background: var(--color-bg-tertiary);
  text-decoration: none;
  color: var(--color-text);
}
.lang-btn.active {
  background: var(--color-brand);
  color: #fff;
}

/* Theme toggle */
.navbar-theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  transition: all var(--dur-fast) var(--ease);
}
.navbar-theme-toggle:hover {
  background: var(--color-bg-tertiary);
  border-color: var(--color-gold);
  color: var(--color-gold);
}
.navbar-theme-toggle .material-symbols-outlined {
  font-size: 1.15rem;
}

/* ---------- Time Range Slider ---------- */

.time-slider-wrapper {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex: 0 1 520px;
  min-width: 280px;
  padding: .35rem .65rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-bg-tertiary);
}

.time-slider-label {
  display: flex;
  align-items: center;
  gap: .35rem;
  font-size: .74rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}
.time-slider-icon {
  font-size: 1rem;
  color: var(--color-gold);
}
.time-slider-title {
  line-height: 1;
}

.time-slider-container {
  flex: 1;
  min-width: 110px;
}

#time-slider {
  height: 4px;
}

#time-slider .noUi-connect {
  background: var(--color-brand);
}
#time-slider .noUi-target {
  background: var(--color-border);
  border: none;
  border-radius: 3px;
  box-shadow: none;
}
#time-slider .noUi-handle {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--color-brand);
  border: 2px solid var(--color-bg-elevated);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  cursor: grab;
  top: -5.5px;
  right: -7.5px;
  transition: transform var(--dur-fast) var(--ease);
}
#time-slider .noUi-handle:hover {
  transform: scale(1.2);
}
#time-slider .noUi-handle::before,
#time-slider .noUi-handle::after {
  display: none;
}
#time-slider .noUi-tooltip {
  display: none;
}

.time-slider-range {
  flex-shrink: 0;
  font-size: .73rem;
  font-weight: 700;
  color: var(--color-text-secondary);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: .2rem .6rem;
  line-height: 1;
  min-width: 106px;
  text-align: center;
}

.time-slider-reset {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  flex-shrink: 0;
  border: 1px solid transparent;
  transition: all var(--dur-fast) var(--ease);
}
.time-slider-reset:hover {
  background: var(--color-bg-elevated);
  border-color: var(--color-border);
  color: var(--color-brand);
}
.time-slider-reset .material-symbols-outlined {
  font-size: 1rem;
}

/* ---------- Main Content Area ---------- */

.app-main {
  flex: 1;
  padding: 2.5rem 2.5rem 3rem;
  max-width: 1480px;
  width: 100%;
  animation: fadeIn var(--dur-slow) var(--ease);
}

/* ---------- Footer ---------- */

.app-footer {
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-tertiary);
  background-image: linear-gradient(to bottom, var(--color-bg-tertiary), color-mix(in srgb, var(--color-bg-tertiary) 90%, var(--sidebar-bg)));
  padding: 3rem 2.5rem 2rem;
  margin-top: auto;
  position: relative;
}
.app-footer::before {
  content: '';
  position: absolute;
  top: 0; left: 10%; right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--color-gold-light), transparent);
}

.footer-inner {
  max-width: 1200px;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 2.5rem;
}

.footer-brand h4 {
  font-family: var(--font-display);
  margin-bottom: .5rem;
}
.footer-brand p {
  color: var(--color-text-secondary);
  font-size: .9rem;
}

.footer-contact p {
  font-size: .85rem;
  color: var(--color-text-secondary);
  margin-bottom: .25rem;
}
.footer-contact a {
  color: var(--color-brand);
}

.footer-legal {
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.footer-legal a {
  font-size: .85rem;
  color: var(--color-text-secondary);
  transition: color var(--dur-fast) var(--ease);
}
.footer-legal a:hover {
  color: var(--color-brand);
}

.footer-bottom {
  grid-column: 1 / -1;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
  text-align: center;
  font-size: .8rem;
  color: var(--color-text-muted);
}

/* ---------- Hero Section (Home) ---------- */

.hero-section {
  position: relative;
  border-radius: var(--radius-xl);
  overflow: hidden;
  min-height: 380px;
  display: flex;
  align-items: flex-end;
  background: var(--color-bg-tertiary);
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  margin-bottom: 3rem;
  animation: scaleIn var(--dur-reveal) var(--ease);
}
.hero-section::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top,
    rgba(28,21,14,.85) 0%,
    rgba(28,21,14,.4) 40%,
    rgba(28,21,14,.15) 70%,
    rgba(28,21,14,.05) 100%);
  z-index: 0;
}
.hero-overlay {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 3.5rem 3rem;
  color: #F5EFE4;
}
.hero-title {
  color: #F5EFE4;
  font-size: clamp(2.2rem, 5vw, 3.5rem);
  margin-bottom: .5rem;
  text-shadow: 0 2px 12px rgba(0,0,0,.3);
  animation: fadeInUp var(--dur-reveal) var(--ease) .1s both;
}
.hero-subtitle {
  font-size: 1.1rem;
  opacity: .88;
  max-width: 600px;
  margin-bottom: 1.5rem;
  line-height: 1.7;
  animation: fadeInUp var(--dur-reveal) var(--ease) .25s both;
}
.hero-cta {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .7rem 1.75rem;
  background: var(--color-brand);
  color: #F5EFE4;
  font-weight: 600;
  font-size: .9rem;
  border-radius: var(--radius-full);
  text-decoration: none;
  transition: all var(--dur) var(--ease);
  animation: fadeInUp var(--dur-reveal) var(--ease) .4s both;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
}
.hero-cta:hover {
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(0,0,0,.3);
  color: #fff;
  background: var(--color-brand-dark);
}

/* ---------- Hero Inline Search ---------- */

.hero-search-form {
  display: flex;
  align-items: center;
  gap: .6rem;
  max-width: 480px;
  background: rgba(255,255,255,.15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: var(--radius-full);
  padding: .5rem 1.25rem;
  margin-top: 1.25rem;
  animation: fadeInUp var(--dur-reveal) var(--ease) .5s both;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.hero-search-form:focus-within {
  background: rgba(255,255,255,.22);
  border-color: rgba(255,255,255,.5);
}
.hero-search-icon {
  color: rgba(255,255,255,.7);
  font-size: 1.2rem;
  flex-shrink: 0;
}
.hero-search-form input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  color: #F5EFE4;
  font-size: .95rem;
  padding: .3rem 0;
}
.hero-search-form input::placeholder {
  color: rgba(255,255,255,.55);
}

/* ---------- Dashboard Stats ---------- */

.dashboard-stats {
  margin-bottom: 3.5rem;
  animation: fadeInUp var(--dur-reveal) var(--ease) .2s both;
}
.dashboard-stats-header {
  margin-bottom: 1.5rem;
  position: relative;
  padding-bottom: .75rem;
}
.dashboard-stats-header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0;
  width: 60px;
  height: 2px;
  background: var(--color-gold);
}

.dashboard-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
}

.dashboard-stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  padding: 1.5rem 1rem;
  background: var(--card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--color-text);
  text-align: center;
  transition: all var(--dur) var(--ease);
  position: relative;
  overflow: hidden;
}
.dashboard-stat-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--color-brand), var(--color-gold));
  transform: scaleX(0);
  transition: transform var(--dur) var(--ease);
}
.dashboard-stat-card:hover {
  box-shadow: var(--card-shadow-hover);
  text-decoration: none;
  transform: translateY(-4px);
  border-color: var(--color-gold);
}
.dashboard-stat-card:hover::after {
  transform: scaleX(1);
}
.dashboard-stat-card--total {
  background: var(--color-brand);
  color: #F5EFE4;
  border-color: var(--color-brand);
}
.dashboard-stat-card--total .dashboard-stat-icon {
  color: rgba(255,255,255,.7);
}
.dashboard-stat-card--total .dashboard-stat-label {
  color: rgba(255,255,255,.8);
}
.dashboard-stat-card--total::after {
  background: var(--color-gold);
}

.dashboard-stat-icon {
  font-size: 1.6rem;
  color: var(--color-brand);
}

.dashboard-stat-number {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.02em;
}

.dashboard-stat-label {
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-text-muted);
}

/* ---------- Dashboard Recently Added ---------- */

.dashboard-recent {
  margin-bottom: 3.5rem;
  animation: fadeInUp var(--dur-reveal) var(--ease) .3s both;
}

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

.dashboard-recent-card {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  background: var(--card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--color-text);
  transition: all var(--dur) var(--ease);
  overflow: hidden;
}
.dashboard-recent-card:hover {
  box-shadow: var(--card-shadow-hover);
  text-decoration: none;
  transform: translateY(-3px);
  border-color: var(--color-brand);
}

.dashboard-recent-thumb {
  flex-shrink: 0;
  width: 72px;
  height: 72px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
}
.dashboard-recent-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.dashboard-recent-thumb .material-symbols-outlined {
  font-size: 1.75rem;
  color: var(--color-text-muted);
  opacity: .5;
}

.dashboard-recent-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: .2rem;
}

.dashboard-recent-badge {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--color-brand);
}

.dashboard-recent-title {
  font-family: var(--font-display);
  font-size: .95rem;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-recent-desc {
  font-size: .82rem;
  color: var(--color-text-secondary);
  line-height: 1.4;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- Stats Bar (legacy, kept for compatibility) ---------- */

.stats-bar {
  display: flex;
  gap: 1rem;
  margin-bottom: 3.5rem;
  overflow-x: auto;
  padding-bottom: .25rem;
  animation: fadeInUp var(--dur-reveal) var(--ease) .3s both;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .8rem 1.4rem;
  background: var(--card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--color-text);
  white-space: nowrap;
  font-weight: 600;
  font-size: .88rem;
  transition: all var(--dur) var(--ease);
  position: relative;
  overflow: hidden;
}
.stat-card:hover {
  box-shadow: var(--card-shadow-hover);
  text-decoration: none;
  transform: translateY(-3px);
  border-color: var(--color-gold);
}
.stat-icon {
  font-size: 1.35rem;
  color: var(--color-brand);
}

/* ---------- Home Collection Sections ---------- */

.home-collections {
  display: flex;
  flex-direction: column;
  gap: 4rem;
}

.home-collection-section {
  animation: floatUp var(--dur-reveal) var(--ease) both;
}
.home-collection-section:nth-child(1) { animation-delay: .1s; }
.home-collection-section:nth-child(2) { animation-delay: .2s; }
.home-collection-section:nth-child(3) { animation-delay: .3s; }
.home-collection-section:nth-child(4) { animation-delay: .4s; }

.section-header {
  display: flex;
  align-items: baseline;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  position: relative;
  padding-bottom: 1rem;
}
.section-header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0;
  width: 60px;
  height: 2px;
  background: var(--color-gold);
  animation: ornamentDraw var(--dur-slow) var(--ease) both;
}
.section-header h2 {
  margin: 0;
}
.section-description {
  color: var(--color-text-secondary);
  font-size: .9rem;
  margin: 0;
}
.section-view-all {
  margin-left: auto;
  font-size: .85rem;
  font-weight: 600;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  transition: all var(--dur-fast) var(--ease);
}
.section-view-all:hover {
  gap: .6rem;
}

/* ---------- Card Grid ---------- */

.card-grid {
  display: grid;
  gap: 1.5rem;
}
.card-grid--3 {
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}
.card-grid--4 {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

/* ---------- Entity Card ---------- */

.entity-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--card-shadow);
  transition: all var(--dur) var(--ease);
  position: relative;
  animation: floatUp var(--dur-reveal) var(--ease) both;
}
/* Staggered card reveal */
.card-grid .entity-card:nth-child(1) { animation-delay: .05s; }
.card-grid .entity-card:nth-child(2) { animation-delay: .1s; }
.card-grid .entity-card:nth-child(3) { animation-delay: .15s; }
.card-grid .entity-card:nth-child(4) { animation-delay: .2s; }
.card-grid .entity-card:nth-child(5) { animation-delay: .25s; }
.card-grid .entity-card:nth-child(6) { animation-delay: .3s; }
.card-grid .entity-card:nth-child(7) { animation-delay: .35s; }
.card-grid .entity-card:nth-child(8) { animation-delay: .4s; }
.card-grid .entity-card:nth-child(n+9) { animation-delay: .45s; }

.entity-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--color-brand), var(--color-gold));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--dur) var(--ease);
}
.entity-card:hover {
  box-shadow: var(--card-shadow-hover);
  transform: translateY(-6px);
}
.entity-card:hover::after {
  transform: scaleX(1);
}

.entity-card-link {
  display: block;
  text-decoration: none;
  color: inherit;
}
.entity-card-link:hover { text-decoration: none; }

.entity-card-image {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  background: var(--color-bg-tertiary);
  overflow: hidden;
  isolation: isolate;
}
.entity-card-image-bg,
.entity-card-image-main {
  position: absolute;
  inset: 0;
}
.entity-card-image-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(12, 18, 28, .12), rgba(12, 18, 28, .28));
}
.entity-card-image-bg img,
.entity-card-image-main img {
  width: 100%;
  height: 100%;
}
.entity-card-image-bg img {
  object-fit: cover;
  transform: scale(1.16);
  filter: blur(22px) saturate(.9);
  opacity: .9;
}
.entity-card-image-main {
  display: flex;
  align-items: center;
  justify-content: center;
}
.entity-card-image-main img {
  object-fit: contain;
  transition: transform var(--dur-slow) var(--ease);
}
.entity-card:hover .entity-card-image-main img {
  transform: scale(1.06);
}

.entity-card-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  background: linear-gradient(135deg, var(--color-bg-tertiary), var(--color-bg));
}
.entity-card-placeholder .material-symbols-outlined {
  font-size: 3rem;
  opacity: .3;
}

.entity-card-body {
  padding: 1.15rem 1.25rem;
}

.entity-card-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: .35rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.entity-card-date {
  font-size: .78rem;
  color: var(--color-gold);
  font-weight: 600;
  margin-bottom: .35rem;
  letter-spacing: .02em;
}

.entity-card-desc {
  font-size: .85rem;
  color: var(--color-text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
}

/* ---------- List View ---------- */

.list-header {
  margin-bottom: 2.5rem;
  animation: fadeInUp var(--dur-reveal) var(--ease) both;
}
.list-header h1 {
  margin-bottom: .25rem;
}
.list-description {
  color: var(--color-text-secondary);
  font-size: .95rem;
  margin-bottom: .35rem;
}
.list-count {
  display: inline-flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: .5rem;
  padding: .35rem .75rem;
  font-size: 1rem;
  color: var(--color-text-secondary);
  background: var(--color-surface-muted, rgba(0, 0, 0, .04));
  border-left: 3px solid var(--color-accent, currentColor);
  border-radius: 4px;
}
.list-count-number {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-text);
}
.list-count-label {
  font-weight: 500;
}
.list-count-loaded {
  color: var(--color-text-muted);
  font-size: .9rem;
}

.list-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--color-border-light);
}

.list-search {
  display: flex;
  align-items: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 0 .85rem;
  height: 40px;
  background: var(--color-bg-secondary);
  flex: 0 1 280px;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.list-search:focus-within {
  border-color: var(--color-brand);
  box-shadow: 0 0 0 3px var(--color-brand-light);
}
.list-search input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  padding: .4rem .5rem;
  font-size: .9rem;
}
.list-search .btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: .25rem;
  color: var(--color-text-muted);
  transition: color var(--dur-fast) var(--ease);
}
.list-search .btn-icon:hover {
  color: var(--color-brand);
}

.view-mode-toggle {
  display: flex;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.view-mode-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  text-decoration: none;
  color: var(--color-text-muted);
  transition: all var(--dur-fast) var(--ease);
}
.view-mode-btn:hover {
  background: var(--color-bg-tertiary);
  color: var(--color-text);
  text-decoration: none;
}
.view-mode-btn.active {
  background: var(--color-brand);
  color: #fff;
}
.view-mode-btn .material-symbols-outlined {
  font-size: 1.15rem;
}

.page-size-selector {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-left: auto;
  font-size: .85rem;
  color: var(--color-text-secondary);
}
.page-size-selector label {
  font-weight: 500;
}
.page-size-selector select {
  padding: .35rem .6rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-secondary);
  font-size: .85rem;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease);
}
.page-size-selector select:hover {
  border-color: var(--color-brand);
}

/* ---------- Table / List View ---------- */

.list-table-wrapper {
  overflow-x: auto;
}

.list-table {
  width: 100%;
  border-collapse: collapse;
}
.list-table thead th {
  text-align: left;
  padding: .85rem 1rem;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--color-text-muted);
  border-bottom: 2px solid var(--color-border);
}

.list-table-row {
  border-bottom: 1px solid var(--color-border-light);
  transition: background var(--dur-fast) var(--ease);
}
.list-table-row:hover {
  background: var(--color-bg-tertiary);
}
.list-table-row td {
  padding: .85rem 1rem;
  font-size: .9rem;
  vertical-align: middle;
}

.list-table-thumb {
  width: 60px;
}
.list-table-thumb img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: var(--radius-md);
  transition: transform var(--dur-fast) var(--ease);
}
.list-table-row:hover .list-table-thumb img {
  transform: scale(1.08);
}
.thumb-placeholder {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
}
.thumb-placeholder .material-symbols-outlined {
  font-size: 1.25rem;
}

.list-item-title {
  font-weight: 600;
  color: var(--color-text);
  transition: color var(--dur-fast) var(--ease);
}
.list-item-title:hover {
  color: var(--color-brand);
}
.list-item-date {
  color: var(--color-gold);
  white-space: nowrap;
  font-size: .83rem;
  font-weight: 600;
}
.list-item-desc {
  color: var(--color-text-secondary);
  font-size: .85rem;
  max-width: 400px;
}

/* ---------- Pagination ---------- */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border-light);
}

.pagination-info {
  font-size: .85rem;
  color: var(--color-text-muted);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: .35rem;
}

.pagination-btn {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .45rem .85rem;
  font-size: .85rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  text-decoration: none;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: all var(--dur-fast) var(--ease);
}
.pagination-btn:hover {
  background: var(--color-bg-tertiary);
  border-color: var(--color-border);
  text-decoration: none;
  color: var(--color-text);
}
.pagination-btn.active {
  background: var(--color-brand);
  color: #fff;
  border-color: var(--color-brand);
}
.pagination-btn .material-symbols-outlined {
  font-size: 1rem;
}

.pagination-ellipsis {
  padding: .4rem .3rem;
  color: var(--color-text-muted);
}

/* ---------- Breadcrumb ---------- */

.breadcrumb {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .84rem;
  margin-bottom: 1.75rem;
  color: var(--color-text-muted);
  animation: slideInRight var(--dur) var(--ease) both;
}
.breadcrumb a {
  color: var(--color-text-secondary);
  transition: color var(--dur-fast) var(--ease);
}
.breadcrumb a:hover {
  color: var(--color-brand);
}
.breadcrumb-sep {
  opacity: .35;
  font-size: .7rem;
}
.breadcrumb-current {
  color: var(--color-text);
  font-weight: 600;
}

/* ---------- Detail Page ---------- */

.detail-nav {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  animation: fadeIn var(--dur) var(--ease) both;
}
.detail-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .85rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  text-decoration: none;
  padding: .45rem .9rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  transition: all var(--dur) var(--ease);
}
.detail-nav-btn:hover {
  background: var(--color-bg-tertiary);
  text-decoration: none;
  border-color: var(--color-brand);
  color: var(--color-brand);
  transform: translateX(-2px);
}
.detail-nav-btn.next:hover {
  transform: translateX(2px);
}

/* Legacy layout class (kept for compat) */
.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 2rem;
  align-items: start;
}
.detail-layout--single {
  grid-template-columns: minmax(0, 1fr);
}
.detail-main-column {
  min-width: 0;
  animation: fadeInUp var(--dur-reveal) var(--ease) both;
}

/* ====== NEW detail body grid ====== */
.detail-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 2.5rem;
  align-items: start;
}
.detail-body--single {
  grid-template-columns: minmax(0, 1fr);
}
.detail-content {
  min-width: 0;
  animation: fadeInUp var(--dur-reveal) var(--ease) both;
}

/* Intro split: description + metadata side by side */
.detail-intro--split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: start;
}
.detail-desc-section {
  grid-column: 1;
}
.detail-meta-section {
  grid-column: 2;
}

.detail-timeline-sidebar {
  position: sticky;
  top: calc(var(--navbar-height) + 1.5rem);
  max-height: calc(100vh - var(--navbar-height) - 2rem);
  padding-left: 1.5rem;
  border-left: 2px solid var(--color-border-light);
  animation: fadeIn var(--dur-reveal) var(--ease) .3s both;
}

.detail-timeline-sidebar-inner {
  overflow-y: auto;
  max-height: inherit;
  padding-right: .5rem;
  padding-left: 8px;
}

.detail-section--timeline-sidebar {
  margin-bottom: 0;
}

/* Detail Hero — full-width banner */
.detail-hero {
  display: flex;
  gap: 2.5rem;
  margin-bottom: 2.5rem;
  align-items: flex-start;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 2rem 2.5rem;
  background: var(--color-bg-secondary);
  position: relative;
  overflow: hidden;
  animation: scaleIn var(--dur-reveal) var(--ease) .1s both;
}
.detail-hero::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--color-brand), var(--color-gold), var(--color-brand));
}

.detail-hero-image {
  flex-shrink: 0;
  width: 260px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,.1);
}
.detail-hero-image img {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  transition: transform var(--dur-slow) var(--ease);
}
.detail-hero:hover .detail-hero-image img {
  transform: scale(1.03);
}
/* Don't scale images that carry an annotation overlay - it would
   desynchronise the SVG polygons from the image on hover. */
.detail-hero:hover .detail-hero-image--annotated img {
  transform: none;
}

.detail-hero-image--media img {
  width: auto;
  max-width: 100%;
  max-height: 400px;
  aspect-ratio: auto;
  height: auto;
  object-fit: contain;
  margin: 0;
}
.detail-hero--media {
  flex-direction: column;
  gap: 1.5rem;
}
.detail-hero--media .detail-hero-text {
  order: 1;
  width: 100%;
}
.detail-hero--media .detail-hero-image {
  order: 2;
  width: 100%;
  max-width: none;
  display: flex;
  justify-content: center;
  margin: .5rem 0 1rem;
}
.detail-hero-text {
  flex: 1;
  min-width: 0;
}

.detail-entity-badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .75rem;
  font-weight: 700;
  color: var(--color-brand);
  background: var(--color-brand-light);
  padding: .3rem .85rem;
  border-radius: var(--radius-full);
  margin-bottom: .85rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  border: 1px solid color-mix(in srgb, var(--color-brand) 20%, transparent);
}
.detail-entity-badge .material-symbols-outlined {
  font-size: .95rem;
}

[data-theme="dark"] .detail-entity-badge {
  background: color-mix(in srgb, var(--color-brand) 18%, transparent);
}
[data-theme="high-contrast"] .detail-entity-badge {
  background: transparent;
  border: 2px solid var(--color-brand);
}

/* ---------- Event date (shown above the title on event detail pages) ---------- */
.detail-event-date {
  display: inline-flex;
  align-items: baseline;
  gap: .55rem;
  margin: 0 0 .65rem;
  padding: .1rem 0;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 2.2vw, 1.85rem);
  font-weight: 600;
  color: var(--color-gold);
  letter-spacing: .01em;
  line-height: 1.2;
}
.detail-event-date-icon.material-symbols-outlined {
  font-size: 1.2rem;
  color: var(--color-gold);
  transform: translateY(2px);
  opacity: .9;
}
.detail-event-date-value {
  display: inline-flex;
  align-items: baseline;
  gap: .35rem;
  flex-wrap: wrap;
}
.detail-event-date-sep {
  color: var(--color-text-muted);
  font-weight: 400;
  padding: 0 .1rem;
}

[data-theme="high-contrast"] .detail-event-date {
  color: var(--color-text);
}

.detail-subtitle {
  font-size: 1.05rem;
  color: var(--color-text-secondary);
  margin-top: .6rem;
  line-height: 1.7;
}
.detail-subtitle > *:first-child { margin-top: 0; }
.detail-subtitle > *:last-child { margin-bottom: 0; }

.detail-section {
  margin-bottom: 3rem;
}

.section-title {
  font-size: 1.35rem;
  margin-bottom: 1.25rem;
  padding-bottom: .6rem;
  border-bottom: none;
  position: relative;
}
.section-title::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0;
  width: 48px;
  height: 2px;
  background: var(--color-gold);
}

.detail-description {
  font-size: 1.05rem;
  line-height: 1.85;
  color: var(--color-text-secondary);
}
.detail-description > *:first-child { margin-top: 0; }
.detail-description > *:last-child { margin-bottom: 0; }

/* ---------- Rich-text prose (render_richtext output) ----------
   The global reset strips margins/padding from every element. Rich-text
   content (from the Unfold/Trix WYSIWYG in the admin) therefore renders
   without paragraph spacing, list indents or heading breathing room.
   `.rt-prose` puts those back inside any container that receives
   `{{ foo|render_richtext }}` on the frontend. */

.rt-prose > *:first-child { margin-top: 0 !important; }
.rt-prose > *:last-child  { margin-bottom: 0 !important; }

/* Paragraphs & soft breaks */
.rt-prose p {
  margin: 0 0 0.9em;
}
.rt-prose p:empty { display: none; }
.rt-prose br + br { display: none; }            /* collapse multi-breaks */

/* Headings inside rich-text — smaller than page headings */
.rt-prose h1,
.rt-prose h2,
.rt-prose h3,
.rt-prose h4,
.rt-prose h5,
.rt-prose h6 {
  font-family: var(--font-display);
  color: var(--color-text);
  font-weight: 700;
  line-height: 1.25;
  margin: 1.6em 0 0.5em;
  letter-spacing: -0.01em;
}
.rt-prose h1 { font-size: 1.55rem; }
.rt-prose h2 { font-size: 1.35rem; }
.rt-prose h3 { font-size: 1.2rem; }
.rt-prose h4 { font-size: 1.05rem; }
.rt-prose h5,
.rt-prose h6 { font-size: 1rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-text-secondary); }

/* Inline emphasis */
.rt-prose strong,
.rt-prose b   { font-weight: 700; color: var(--color-text); }
.rt-prose em,
.rt-prose i   { font-style: italic; }
.rt-prose u   { text-decoration: underline; text-underline-offset: 0.15em; }
.rt-prose s,
.rt-prose del { text-decoration: line-through; color: var(--color-text-muted); }
.rt-prose mark {
  background: var(--color-gold-dim);
  color: inherit;
  padding: 0 0.15em;
  border-radius: 2px;
}
.rt-prose small { font-size: 0.85em; color: var(--color-text-muted); }

/* Links restore underline inside prose so they're discoverable */
.rt-prose a {
  color: var(--color-brand);
  text-decoration: underline;
  text-underline-offset: 0.15em;
  text-decoration-thickness: 0.08em;
  text-decoration-color: color-mix(in srgb, var(--color-brand) 40%, transparent);
  transition: color var(--dur-fast) var(--ease), text-decoration-color var(--dur-fast) var(--ease);
}
.rt-prose a:hover {
  color: var(--color-brand-dark);
  text-decoration-color: currentColor;
}

/* Lists */
.rt-prose ul,
.rt-prose ol {
  margin: 0.6em 0 1em;
  padding-left: 1.4em;
}
.rt-prose ul { list-style: disc outside; }
.rt-prose ol { list-style: decimal outside; }
.rt-prose li { margin-bottom: 0.3em; }
.rt-prose li::marker { color: var(--color-gold); }
.rt-prose li > ul,
.rt-prose li > ol { margin: 0.3em 0 0.3em; }

/* Block quote */
.rt-prose blockquote {
  margin: 1.25em 0;
  padding: 0.35em 1.1em;
  border-left: 3px solid var(--color-gold);
  color: var(--color-text-secondary);
  font-style: italic;
  background: color-mix(in srgb, var(--color-gold) 5%, transparent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.rt-prose blockquote > *:last-child { margin-bottom: 0; }

/* Inline code & code blocks */
.rt-prose code {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.92em;
  background: var(--color-bg-tertiary);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border-light);
}
.rt-prose pre {
  margin: 1em 0;
  padding: 0.85em 1em;
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.92em;
  line-height: 1.5;
}
.rt-prose pre code {
  background: transparent;
  border: 0;
  padding: 0;
  font-size: 1em;
}

/* Horizontal rule */
.rt-prose hr {
  border: 0;
  height: 1px;
  background: var(--color-border);
  margin: 1.5em 0;
}

/* Tables (in case editor / pasted content produces them) */
.rt-prose table {
  border-collapse: collapse;
  width: 100%;
  margin: 1em 0;
  font-size: 0.95em;
}
.rt-prose th,
.rt-prose td {
  border: 1px solid var(--color-border);
  padding: 0.45em 0.7em;
  text-align: left;
  vertical-align: top;
}
.rt-prose th {
  background: var(--color-bg-tertiary);
  font-weight: 700;
  color: var(--color-text);
}

/* Embedded figures & images inside prose */
.rt-prose img,
.rt-prose figure {
  max-width: 100%;
  margin: 1em 0;
  border-radius: var(--radius-md);
}
.rt-prose figcaption {
  font-size: 0.85em;
  color: var(--color-text-muted);
  margin-top: 0.35em;
  font-style: italic;
}

/* Compact prose — for cards/timeline entries where we want tighter spacing */
.rt-prose--compact p         { margin-bottom: 0.5em; }
.rt-prose--compact ul,
.rt-prose--compact ol        { margin: 0.35em 0 0.5em; padding-left: 1.25em; }
.rt-prose--compact li        { margin-bottom: 0.15em; }
.rt-prose--compact blockquote{ margin: 0.6em 0; padding: 0.25em 0.8em; }
.rt-prose--compact h1,
.rt-prose--compact h2,
.rt-prose--compact h3,
.rt-prose--compact h4        { margin: 0.9em 0 0.3em; font-size: 1.05rem; }

/* ---------- Metadata Grid ---------- */

.metadata-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}

.metadata-item {
  padding: .75rem 0;
  border-bottom: 1px solid var(--color-border-light);
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.metadata-item:last-child {
  border-bottom: none;
}
.metadata-item dt {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-text-muted);
}
.metadata-item dd {
  font-size: .95rem;
  color: var(--color-text);
  word-break: break-word;
  font-weight: 500;
}

/* When metadata is in a standalone section (not split), use multi-column */
.detail-body--single .metadata-grid {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0 2rem;
}

/* Nested meta (from render_value filter) */
.meta-list { margin: 0; }
.meta-row { display: flex; gap: .5rem; margin-bottom: .15rem; }
.meta-label { font-weight: 600; font-size: .8rem; color: var(--color-text-muted); min-width: 100px; }
.meta-value { font-size: .85rem; }
.meta-list-items { list-style: disc; padding-left: 1.25rem; font-size: .85rem; }

/* ---------- Timeline ---------- */

.timeline {
  position: relative;
  padding-left: 2.25rem;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, var(--color-gold), var(--color-border));
}

.timeline-entry {
  position: relative;
  padding-bottom: 2rem;
  animation: slideInRight var(--dur) var(--ease) both;
}
.timeline-entry:nth-child(1) { animation-delay: .05s; }
.timeline-entry:nth-child(2) { animation-delay: .1s; }
.timeline-entry:nth-child(3) { animation-delay: .15s; }
.timeline-entry:nth-child(4) { animation-delay: .2s; }
.timeline-entry:nth-child(5) { animation-delay: .25s; }
.timeline-entry:nth-child(n+6) { animation-delay: .3s; }
.timeline-entry:last-child {
  padding-bottom: 0;
}

.timeline-marker {
  position: absolute;
  left: -2.25rem;
  top: .35rem;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-brand);
  border: 3px solid var(--color-bg);
  z-index: 1;
  transition: transform var(--dur-fast) var(--ease);
}
.timeline-entry:hover .timeline-marker {
  transform: scale(1.3);
  animation: timelinePulse 1.2s ease infinite;
}

.timeline-content {
  padding-left: .6rem;
}

.timeline-date {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: .15rem;
}

.timeline-label {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-gold);
  margin-bottom: .3rem;
}

.timeline-link {
  display: inline-block;
  font-size: .9rem;
  font-weight: 500;
  color: var(--color-brand);
  margin-bottom: .15rem;
  transition: color var(--dur-fast) var(--ease);
}
.timeline-link:hover {
  text-decoration: underline;
}
.timeline-link-text {
  font-size: .9rem;
  color: var(--color-text-secondary);
}

.timeline-desc {
  font-size: .83rem;
  color: var(--color-text-secondary);
  margin: 0;
  line-height: 1.5;
}

/* Compact (sidebar) timeline */
.timeline--compact {
  padding-left: 1.5rem;
}
.timeline--compact::before {
  left: 4px;
}
.timeline--compact .timeline-entry {
  padding-bottom: 1.25rem;
}
.timeline--compact .timeline-marker {
  left: -1.5rem;
  width: 10px;
  height: 10px;
}
.timeline--compact .timeline-date {
  font-size: .88rem;
}
.timeline--compact .timeline-label {
  font-size: .68rem;
}
.timeline--compact .timeline-link,
.timeline--compact .timeline-link-text {
  font-size: .82rem;
}
.timeline--compact .timeline-desc {
  font-size: .76rem;
}

/* ---------- Relation Groups ---------- */

.relation-group {
  margin-bottom: 1.75rem;
}

.relation-group-title {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: .85rem;
}
.relation-group-title .material-symbols-outlined {
  font-size: 1.2rem;
  color: var(--color-brand);
}
.relation-count {
  font-size: .8rem;
  font-weight: 400;
  color: var(--color-text-muted);
}

.relation-cards {
  display: flex;
  gap: .85rem;
  overflow-x: auto;
  padding-bottom: .5rem;
  scroll-snap-type: x mandatory;
}

.relation-card {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .65rem .95rem;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--color-text);
  white-space: nowrap;
  min-width: 190px;
  scroll-snap-align: start;
  flex-shrink: 0;
  transition: all var(--dur) var(--ease);
}
.relation-card:hover {
  border-color: var(--color-brand);
  box-shadow: var(--card-shadow);
  text-decoration: none;
  transform: translateY(-2px);
}

.relation-card-thumb {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  object-fit: cover;
  flex-shrink: 0;
}
.relation-card-icon {
  font-size: 1.5rem;
  color: var(--color-text-muted);
  flex-shrink: 0;
}
.relation-card-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.relation-card-title {
  font-size: .85rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}
.relation-card-meta {
  font-size: .74rem;
  color: var(--color-text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

/* ---------- Tags ---------- */

.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.tag-badge {
  display: inline-flex;
  align-items: center;
  padding: .3rem .8rem;
  font-size: .8rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--tag-color, var(--color-brand)) 12%, var(--color-bg-secondary));
  color: var(--tag-color, var(--color-brand));
  border: 1px solid color-mix(in srgb, var(--tag-color, var(--color-brand)) 25%, transparent);
  transition: all var(--dur-fast) var(--ease);
}
.tag-badge:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--tag-color, var(--color-brand)) 20%, transparent);
}

[data-theme="high-contrast"] .tag-badge {
  background: transparent;
  border: 2px solid var(--tag-color, var(--color-brand));
  color: var(--color-text);
}

/* ---------- Media Gallery ---------- */

.media-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.media-gallery-item {
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-bg-tertiary);
  transition: all var(--dur) var(--ease);
}
.media-gallery-item:hover {
  box-shadow: var(--card-shadow-hover);
  transform: translateY(-3px);
}
.media-gallery-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.media-gallery-img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: clamp(180px, 35vh, 320px);
  height: auto;
  object-fit: contain;
  cursor: pointer;
  margin: 0 auto;
  transition: transform var(--dur) var(--ease);
}
.media-gallery-item:hover .media-gallery-img {
  transform: scale(1.03);
}

.media-gallery-file {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: 1rem;
  color: var(--color-brand);
  font-size: .9rem;
  font-weight: 500;
}

.media-gallery-caption {
  padding: .5rem .75rem;
  font-size: .8rem;
  color: var(--color-text-secondary);
}

/* ---------- Collection Slideshow ---------- */

.collection-slideshow {
  position: relative;
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
  padding: 1.25rem 3.75rem;
  overflow: hidden;
}
.collection-slideshow::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--color-brand), var(--color-gold), var(--color-brand));
}

.collection-track-wrap {
  overflow: hidden;
}

.collection-track {
  display: flex;
  width: 100%;
  transition: transform var(--dur-slow) var(--ease);
}

.collection-slide {
  min-width: 100%;
  display: grid;
  gap: .85rem;
  align-content: start;
}

.collection-slide-header {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  color: var(--color-brand);
  text-decoration: none;
  font-weight: 600;
  width: fit-content;
  transition: color var(--dur-fast) var(--ease);
}
.collection-slide-header:hover {
  color: var(--color-brand-dark);
  text-decoration: underline;
}

.collection-slide-media {
  min-height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--color-bg) 65%, black 2%);
  border: 1px solid var(--color-border);
  overflow: hidden;
}

.collection-slide-media img,
.collection-slide-media video {
  width: 100%;
  max-height: min(68vh, 680px);
  object-fit: contain;
  background: #0e0e0e;
}

.collection-audio-wrap,
.collection-empty-media {
  width: 100%;
  min-height: 200px;
  display: grid;
  place-items: center;
  gap: .6rem;
  padding: 1rem;
}

.collection-media-icon {
  font-size: 2rem;
  color: var(--color-brand);
}

.collection-file-link {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .8rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-brand);
  color: var(--color-brand);
  text-decoration: none;
  font-weight: 600;
  transition: all var(--dur-fast) var(--ease);
}
.collection-file-link:hover {
  background: var(--color-brand-light);
}

.collection-slide-description {
  color: var(--color-text-secondary);
  margin: 0;
}

.collection-slide-rights {
  margin: 0;
  font-size: .85rem;
  color: var(--color-text-muted);
}
.collection-slide-rights a {
  color: var(--color-brand);
}

.collection-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-bg-elevated);
  color: var(--color-text);
  cursor: pointer;
  display: grid;
  place-items: center;
  z-index: 2;
  transition: all var(--dur-fast) var(--ease);
}
.collection-nav:hover {
  background: var(--color-brand);
  color: #fff;
  border-color: var(--color-brand);
}

.collection-nav[disabled] {
  cursor: default;
  opacity: .3;
}
.collection-nav[disabled]:hover {
  background: var(--color-bg-elevated);
  color: var(--color-text);
  border-color: var(--color-border);
}

.collection-nav-prev { left: .85rem; }
.collection-nav-next { right: .85rem; }

.collection-indicators {
  margin-top: .85rem;
  display: flex;
  gap: .45rem;
  overflow-x: auto;
  padding-bottom: .35rem;
}

.collection-indicator {
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
  border-radius: var(--radius-md);
  border: 2px solid var(--color-border);
  background: var(--color-bg-secondary);
  display: grid;
  place-items: center;
  cursor: pointer;
  overflow: hidden;
  transition: all var(--dur-fast) var(--ease);
}
.collection-indicator:hover {
  border-color: var(--color-text-muted);
}

.collection-indicator img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.collection-indicator.active {
  border-color: var(--color-brand);
  box-shadow: 0 0 0 2px var(--color-brand-light);
}

.collection-empty-state {
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: .85rem;
  color: var(--color-text-secondary);
}

/* ---------- Rights Info ---------- */

.detail-rights {
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  border: 1px solid var(--color-border-light);
}
.detail-rights .section-title {
  border-bottom: none;
  padding-bottom: 0;
  font-size: 1.1rem;
}
.detail-rights .section-title::after {
  display: none;
}

.rights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: .85rem;
}
.rights-item {
  font-size: .85rem;
}
.rights-item dt {
  font-weight: 700;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--color-text-muted);
  margin-bottom: .2rem;
}
.rights-item dd {
  color: var(--color-text-secondary);
}
.rights-item a {
  color: var(--color-brand);
}

/* ---------- Places Map ---------- */

.places-map-section {
  margin-bottom: 2.5rem;
  animation: scaleIn var(--dur-reveal) var(--ease) .15s both;
}

.places-map {
  width: 100%;
  height: 420px;
  border-radius: var(--radius-xl);
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  overflow: hidden;
}

.places-map-marker {
  width: 28px;
  height: 28px;
  background: var(--color-brand);
  border: 3px solid var(--color-bg-elevated);
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease);
}
.places-map-marker:hover {
  transform: rotate(-45deg) scale(1.2);
}

.places-map-popup {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  font-family: var(--font-sans);
  font-size: .88rem;
  color: #2C2016;
  line-height: 1.4;
}
.places-map-popup strong {
  font-family: var(--font-display);
  font-size: 1rem;
}
.places-map-popup-img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: 6px;
}
.places-map-popup-link {
  font-size: .82rem;
  font-weight: 600;
  color: var(--color-brand, #7A2E2E);
  text-decoration: none;
}
.places-map-popup-link:hover {
  text-decoration: underline;
}

@media (max-width: 768px) {
  .places-map {
    height: 300px;
    border-radius: var(--radius-lg);
  }
}

@media (max-width: 480px) {
  .places-map {
    height: 240px;
  }
}

/* ---------- 3D Terrain ---------- */

.terrain3d-section {
  margin-bottom: 2.5rem;
  animation: scaleIn var(--dur-reveal) var(--ease) both;
}

.terrain3d-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.terrain3d-title {
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  gap: .4rem;
}

.terrain3d-time-control {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.terrain3d-time-label {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--color-gold);
  min-width: 55px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.terrain3d-slider {
  width: 180px;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  outline: none;
}
.terrain3d-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--color-gold);
  border: 2px solid var(--color-bg-elevated);
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
  cursor: grab;
}
.terrain3d-slider::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--color-gold);
  border: 2px solid var(--color-bg-elevated);
  cursor: grab;
}

.terrain3d-time-hint {
  display: flex;
  align-items: center;
  gap: .25rem;
  font-size: .78rem;
  color: var(--color-text-muted);
  font-weight: 600;
}

.terrain3d-canvas-wrap {
  position: relative;
  width: 100%;
  height: 500px;
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 1px solid var(--color-border);
  background: var(--color-bg-tertiary);
}

.terrain3d-canvas-wrap canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* Info panel overlay */
.terrain3d-info {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 260px;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-shadow: 0 8px 32px rgba(0,0,0,.15);
  z-index: 5;
  animation: fadeInUp var(--dur) var(--ease) both;
}

.terrain3d-info-close {
  position: absolute;
  top: .5rem;
  right: .5rem;
  width: 26px; height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  cursor: pointer;
  color: var(--color-text-muted);
  transition: all var(--dur-fast) var(--ease);
}
.terrain3d-info-close:hover {
  background: var(--color-bg-tertiary);
  color: var(--color-text);
}
.terrain3d-info-close .material-symbols-outlined { font-size: .9rem; }

.terrain3d-info-img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: var(--radius-md);
  margin-bottom: .75rem;
}

.terrain3d-info-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: .2rem;
}

.terrain3d-info-year {
  font-size: .78rem;
  color: var(--color-gold);
  font-weight: 700;
  margin-bottom: .35rem;
}

.terrain3d-info-desc {
  font-size: .82rem;
  color: var(--color-text-secondary);
  line-height: 1.5;
  margin-bottom: .6rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.terrain3d-info-link {
  font-size: .82rem;
  font-weight: 600;
  color: var(--color-brand);
}

@media (max-width: 768px) {
  .terrain3d-canvas-wrap {
    height: 350px;
  }
  .terrain3d-info {
    left: .5rem;
    right: .5rem;
    width: auto;
    top: auto;
    bottom: .5rem;
  }
  .terrain3d-time-control {
    flex-wrap: wrap;
  }
  .terrain3d-slider {
    width: 120px;
  }
}

@media (max-width: 480px) {
  .terrain3d-canvas-wrap {
    height: 280px;
    border-radius: var(--radius-lg);
  }
}

/* 3D Map markers */
.terrain3d-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: transform .2s var(--ease);
}
.terrain3d-marker:hover {
  transform: translateY(-4px) scale(1.08);
}

.terrain3d-marker-pin {
  width: 36px;
  height: 36px;
  border-radius: 50% 50% 50% 0;
  background: var(--color-brand, #7A2E2E);
  display: flex;
  align-items: center;
  justify-content: center;
  transform: rotate(-45deg);
  box-shadow: 0 3px 10px rgba(0,0,0,.35);
  border: 2px solid rgba(255,255,255,.9);
}
.terrain3d-marker-pin .material-symbols-outlined {
  transform: rotate(45deg);
  font-size: 1.1rem;
  color: #fff;
}

.terrain3d-marker-label {
  margin-top: 4px;
  font-size: .68rem;
  font-weight: 700;
  color: var(--color-text, #2C2016);
  background: rgba(255,255,255,.88);
  padding: .15rem .5rem;
  border-radius: 999px;
  white-space: nowrap;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
  text-align: center;
}
[data-theme="dark"] .terrain3d-marker-label {
  background: rgba(20,16,12,.85);
  color: #EDE5D5;
}

/* Active pin state */
.terrain3d-marker--active .terrain3d-marker-pin {
  background: var(--color-gold, #C9A84C);
  transform: rotate(-45deg) scale(1.15);
  box-shadow: 0 4px 16px rgba(201,168,76,.4);
}
.terrain3d-marker--active .terrain3d-marker-label {
  font-weight: 800;
  background: var(--color-brand, #7A2E2E);
  color: #fff;
}

/* Terrain info relations line */
.terrain3d-info-relations {
  font-size: .75rem;
  font-weight: 700;
  color: var(--color-gold, #C9A84C);
  margin-bottom: .4rem;
}

/* ====== Orbit Container ====== */

.orbit-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 6;
  overflow: hidden;
}

/* Hidden markers when orbit is active */
.terrain3d-marker--hidden {
  opacity: 0 !important;
  pointer-events: none !important;
  transform: scale(.5) !important;
  transition: all .4s var(--ease, cubic-bezier(.22,1,.36,1)) !important;
}

/* ====== Orbit Cards ====== */

@keyframes orbitIn {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.2); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.orbit-card {
  position: absolute;
  z-index: 6;
  pointer-events: auto;
  cursor: pointer;
  transform: translate(-50%, -50%);
  animation: orbitIn .45s var(--ease, cubic-bezier(.22,1,.36,1)) both;
}

.orbit-card--exit {
  opacity: 0 !important;
  transform: translate(-50%, -50%) scale(.15) !important;
  transition: all .3s cubic-bezier(.22,1,.36,1) !important;
  animation: none !important;
}

.orbit-card-link {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem .7rem .45rem .45rem;
  background: var(--color-bg-secondary, #FFFDF8);
  border: 1px solid var(--color-border, #D6CCBA);
  border-radius: 999px;
  text-decoration: none;
  color: var(--color-text, #2C2016);
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
  transition: all .2s cubic-bezier(.22,1,.36,1);
  max-width: 200px;
}
.orbit-card-link:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(0,0,0,.25);
  border-color: var(--color-brand, #7A2E2E);
  text-decoration: none;
}

[data-theme="dark"] .orbit-card-link {
  background: rgba(30,24,18,.92);
  border-color: rgba(201,168,76,.25);
  color: #EDE5D5;
}

.orbit-card-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--color-bg-tertiary, #EDE8DF);
  display: flex;
  align-items: center;
  justify-content: center;
}
.orbit-card-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.orbit-card-icon .material-symbols-outlined {
  font-size: 1rem;
  color: var(--color-brand, #7A2E2E);
}

.orbit-card-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: .05rem;
}

.orbit-card-type {
  font-size: .55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--color-gold, #C9A84C);
}

.orbit-card-title {
  font-size: .72rem;
  font-weight: 600;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 120px;
}

/* 3D Terrain standalone page */
.terrain3d-page {
  animation: fadeInUp var(--dur-reveal) var(--ease) both;
}
.terrain3d-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.terrain3d-page-header h1 { margin-bottom: .25rem; }
.terrain3d-page-subtitle {
  color: var(--color-text-secondary);
  font-size: .9rem;
  max-width: 500px;
  line-height: 1.6;
}
.terrain3d-canvas-wrap--full {
  height: calc(100vh - 250px);
  min-height: 400px;
}
.terrain3d-legend {
  position: absolute;
  bottom: 1rem;
  left: 1rem;
  display: flex;
  gap: 1rem;
  z-index: 4;
}
.terrain3d-legend-item {
  display: flex;
  align-items: center;
  gap: .3rem;
  font-size: .72rem;
  font-weight: 600;
  color: var(--color-text-muted);
  background: color-mix(in srgb, var(--color-bg-secondary) 85%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: .35rem .65rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border-light);
}

@media (max-width: 768px) {
  .terrain3d-canvas-wrap--full { height: 60vh; min-height: 300px; }
  .terrain3d-page-header { flex-direction: column; }
  .terrain3d-legend { flex-direction: column; gap: .35rem; }
}

/* ---------- Search Page ---------- */

.search-header {
  margin-bottom: 2.5rem;
  animation: fadeInUp var(--dur-reveal) var(--ease) both;
}
.search-header h1 {
  margin-bottom: 1.25rem;
}

.search-form {
  margin-bottom: 1rem;
}
.search-input-large {
  display: flex;
  align-items: center;
  gap: .6rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: .6rem 1.5rem;
  max-width: 620px;
  background: var(--color-bg-secondary);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.search-input-large:focus-within {
  border-color: var(--color-brand);
  box-shadow: 0 0 0 4px var(--color-brand-light);
}
.search-input-large .material-symbols-outlined {
  font-size: 1.3rem;
  color: var(--color-text-muted);
}
.search-input-large input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 1.05rem;
  padding: .3rem 0;
}

.search-results-count {
  font-size: .9rem;
  color: var(--color-text-muted);
}

.search-group {
  margin-bottom: 2rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  animation: floatUp var(--dur-reveal) var(--ease) both;
}
.search-group:nth-child(1) { animation-delay: .05s; }
.search-group:nth-child(2) { animation-delay: .1s; }
.search-group:nth-child(3) { animation-delay: .15s; }
.search-group:nth-child(4) { animation-delay: .2s; }
.search-group:nth-child(n+5) { animation-delay: .25s; }

.search-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.35rem;
  cursor: pointer;
  background: var(--color-bg-secondary);
  user-select: none;
  transition: background var(--dur-fast) var(--ease);
}
.search-group-header:hover {
  background: var(--color-bg-tertiary);
}
.search-group-header h2 {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: 1.15rem;
  margin: 0;
}
.search-group-header .material-symbols-outlined {
  font-size: 1.3rem;
}
.search-group-count {
  font-size: .85rem;
  font-weight: 400;
  color: var(--color-text-muted);
}
.search-group-chevron {
  color: var(--color-text-muted);
  transition: transform var(--dur-fast) var(--ease);
}

.search-group-body {
  padding: 1.35rem;
}

.search-group-more {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  margin-top: 1rem;
  font-size: .9rem;
  font-weight: 600;
  transition: gap var(--dur-fast) var(--ease);
}
.search-group-more:hover {
  gap: .6rem;
}

/* ---------- Empty State ---------- */

.empty-state {
  text-align: center;
  padding: 5rem 2rem;
  color: var(--color-text-muted);
}
.empty-state .material-symbols-outlined {
  font-size: 4rem;
  opacity: .3;
  margin-bottom: 1.25rem;
  display: block;
}
.empty-state p {
  font-size: 1.1rem;
  font-family: var(--font-display);
}

/* ---------- Detail Map ---------- */

.detail-map {
  width: 100%;
  height: 380px;
  border-radius: var(--radius-lg);
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
}
.detail-map--compact {
  height: 210px;
}
.detail-location-card {
  margin-bottom: 1rem;
  padding: .9rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg-secondary);
}
.detail-location-card-head {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin-bottom: .75rem;
  font-size: .88rem;
  font-weight: 600;
  color: var(--color-text-secondary);
}
.detail-location-card-head .material-symbols-outlined {
  font-size: 1rem;
  color: var(--color-brand);
}

/* ---------- Masonry Grid ---------- */

.masonry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.5rem;
}
.masonry-sizer {
  grid-column: span 1;
}
.masonry-item {
  break-inside: avoid;
}

/* ---------- Responsive ---------- */

@media (max-width: 1024px) {
  .app-sidebar {
    transform: translateX(-100%);
    width: 290px;
  }
  .app-sidebar.mobile-open {
    transform: translateX(0);
  }
  .app-sidebar.collapsed {
    width: 290px;
    transform: translateX(-100%);
  }
  .app-sidebar.collapsed.mobile-open {
    transform: translateX(0);
  }
  .app-sidebar.collapsed .sidebar-label,
  .app-sidebar.collapsed .sidebar-section-label,
  .app-sidebar.collapsed .sidebar-header-text {
    display: initial;
  }
  .app-sidebar.collapsed .sidebar-link {
    justify-content: flex-start;
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }

  .app-content-wrapper {
    margin-left: 0;
  }
  .app-sidebar.collapsed ~ .app-content-wrapper {
    margin-left: 0;
  }

  .navbar-mobile-toggle {
    display: flex;
  }

  .sidebar-collapse-btn {
    display: none;
  }

  .time-slider-wrapper {
    display: none;
  }

  .detail-hero {
    flex-direction: column;
  }
  .detail-hero-image {
    width: 100%;
    max-width: 400px;
  }
  .detail-hero--media .detail-hero-image {
    max-width: none;
  }

  .detail-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .detail-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .detail-intro--split {
    grid-template-columns: 1fr;
  }
  .detail-desc-section,
  .detail-meta-section {
    grid-column: 1;
  }

  .detail-timeline-sidebar {
    position: static;
    max-height: none;
    border-left: 0;
    border-top: 1px solid var(--color-border-light);
    padding-left: 0;
    padding-top: 1.5rem;
  }

  .detail-timeline-sidebar-inner {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  .collection-slide-media {
    min-height: 280px;
  }
}

@media (max-width: 768px) {
  .app-main {
    padding: 1.5rem 1.25rem 2rem;
  }

  .navbar-ai-link span:last-child {
    display: none;
  }

  .app-navbar {
    padding: 0 1rem;
  }

  h1 { font-size: 1.85rem; }
  h2 { font-size: 1.4rem; }

  .hero-title { font-size: 2rem; }
  .hero-section { min-height: 260px; }
  .hero-overlay { padding: 2.5rem 1.75rem; }

  .stats-bar { gap: .65rem; }
  .stat-card { padding: .6rem .85rem; font-size: .82rem; }

  .dashboard-stats-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: .75rem;
  }
  .dashboard-stat-card { padding: 1rem .75rem; }
  .dashboard-stat-number { font-size: 1.5rem; }

  .dashboard-recent-grid {
    grid-template-columns: 1fr;
  }

  .footer-inner {
    grid-template-columns: 1fr;
  }

  .list-controls {
    flex-direction: column;
    align-items: stretch;
  }
  .list-search {
    flex: 1;
  }
  .page-size-selector {
    margin-left: 0;
  }

  .metadata-grid {
    grid-template-columns: 1fr;
  }

  .detail-hero {
    padding: 1.25rem;
  }

  .collection-slideshow {
    padding: .85rem 2.8rem;
  }
  .collection-nav {
    width: 2.1rem;
    height: 2.1rem;
  }
  .collection-nav-prev { left: .4rem; }
  .collection-nav-next { right: .4rem; }
}

@media (max-width: 480px) {
  .app-main {
    padding: 1rem;
  }

  .card-grid--3,
  .card-grid--4 {
    grid-template-columns: 1fr;
  }

  .navbar-search {
    flex: 1;
    min-width: 0;
  }
  .navbar-lang-switcher {
    display: none;
  }

  .hero-section {
    border-radius: var(--radius-lg);
    min-height: 220px;
    background-attachment: scroll;
  }
  .hero-overlay { padding: 2rem 1.25rem; }
  .hero-title { font-size: 1.6rem; }

  .detail-hero {
    border-radius: var(--radius-lg);
    padding: 1rem;
    gap: 1.25rem;
  }

  .stats-bar {
    flex-wrap: nowrap;
  }
  .stat-card {
    min-width: 140px;
  }

  .section-header {
    flex-direction: column;
    gap: .5rem;
  }
  .section-view-all {
    margin-left: 0;
  }

  .detail-nav {
    gap: .5rem;
  }
  .detail-nav-btn {
    padding: .35rem .65rem;
    font-size: .8rem;
  }
}

/* ---------- Card Bookmark Button ---------- */

.card-bookmark-btn {
  position: absolute;
  top: .6rem;
  right: .6rem;
  z-index: 3;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: #fff;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  opacity: 0;
  transform: scale(.85);
}
.entity-card:hover .card-bookmark-btn,
.card-bookmark-btn:focus-visible {
  opacity: 1;
  transform: scale(1);
}
.card-bookmark-btn:hover {
  background: var(--color-brand);
  transform: scale(1.1);
}
.card-bookmark-btn.active {
  opacity: 1;
  background: var(--color-brand);
  color: #fff;
}
.card-bookmark-btn .material-symbols-outlined {
  font-size: 1.15rem;
}

@keyframes bookmarkPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.35); }
  100% { transform: scale(1); }
}
.bookmark-pop {
  animation: bookmarkPop .4s var(--ease-spring);
}

.entity-card {
  position: relative;
}

/* ---------- Detail User Actions (Bookmark + Rating) ---------- */

.detail-user-actions {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

.bookmark-btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .5rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: .85rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}
.bookmark-btn:hover {
  border-color: var(--color-brand);
  color: var(--color-brand);
  background: var(--color-brand-light);
}
.bookmark-btn.active {
  background: var(--color-brand);
  border-color: var(--color-brand);
  color: #fff;
}
.bookmark-btn .bookmark-icon {
  font-size: 1.15rem;
  transition: transform var(--dur-fast) var(--ease);
}
.bookmark-btn:hover .bookmark-icon,
.bookmark-btn.active .bookmark-icon {
  transform: scale(1.15);
}

/* ---------- Star Rating ---------- */

.star-rating {
  display: flex;
  align-items: center;
  gap: .65rem;
}

.star-rating-label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.star-rating-stars {
  display: flex;
  gap: .15rem;
}

.star-btn {
  padding: .15rem;
  color: var(--color-border);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  border-radius: var(--radius-sm);
}
.star-btn .material-symbols-outlined {
  font-size: 1.4rem;
  display: block;
}
.star-btn:hover {
  color: var(--color-gold);
  transform: scale(1.2);
}
.star-btn.active {
  color: var(--color-gold);
}

@keyframes ratingPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.06); }
  100% { transform: scale(1); }
}
.rating-pulse .star-rating-stars {
  animation: ratingPulse .4s var(--ease);
}

/* ---------- Toast Notifications ---------- */

.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  pointer-events: none;
}

.toast {
  padding: .7rem 1.25rem;
  border-radius: var(--radius-lg);
  font-size: .88rem;
  font-weight: 600;
  color: #fff;
  background: var(--color-text);
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(12px) scale(.95);
  transition: all var(--dur) var(--ease);
}
.toast--visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.toast--success { background: var(--color-success); }
.toast--error   { background: var(--color-danger); }
.toast--info    { background: var(--color-text); }

/* ---------- My Recherche Page ---------- */

.mycol-page {
  animation: fadeInUp var(--dur-reveal) var(--ease) both;
}

.mycol-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}
.mycol-header-text h1 { margin-bottom: .3rem; }

.mycol-subtitle {
  color: var(--color-text-secondary);
  font-size: .88rem;
  line-height: 1.6;
  max-width: 600px;
}

.mycol-actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}

.mycol-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .45rem .9rem;
  border-radius: var(--radius-full);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  text-decoration: none;
  border: 1px solid transparent;
}
.mycol-btn .material-symbols-outlined { font-size: 1rem; }
.mycol-btn--primary { background: var(--color-brand); color: #fff; }
.mycol-btn--primary:hover { background: var(--color-brand-dark); transform: translateY(-1px); box-shadow: 0 3px 10px rgba(0,0,0,.12); text-decoration: none; color: #fff; }
.mycol-btn--secondary { background: var(--color-bg-tertiary); color: var(--color-text); border-color: var(--color-border); }
.mycol-btn--secondary:hover { border-color: var(--color-brand); color: var(--color-brand); }

.mycol-btn-text { display: inline-flex; align-items: center; gap: .35rem; padding: .4rem .6rem; font-size: .78rem; font-weight: 600; cursor: pointer; color: var(--color-text-muted); transition: color var(--dur-fast) var(--ease); background: none; border: none; }
.mycol-btn-text .material-symbols-outlined { font-size: .95rem; }
.mycol-btn-text--danger:hover { color: var(--color-danger); }

/* ---------- Workspace: Folders + Items ---------- */

.mycol-workspace {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

/* -- Folder Panel -- */
.mycol-folders {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: sticky;
  top: calc(var(--navbar-height) + 1rem);
  transition: box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.mycol-folders--drop-active {
  border-color: var(--color-brand);
  box-shadow: 0 0 0 3px var(--color-brand-light);
}

.mycol-folders-header {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--color-border-light);
}
.mycol-folders-count {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--color-brand);
}
.mycol-folders-count-label {
  font-size: .72rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.mycol-folder-add-btn {
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.mycol-folder-add-btn:hover { background: var(--color-bg-tertiary); color: var(--color-brand); }
.mycol-folder-add-btn .material-symbols-outlined { font-size: 1.15rem; }

.mycol-folder-list {
  padding: .35rem 0;
  max-height: 50vh;
  overflow-y: auto;
}

.mycol-folder-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  width: 100%;
  padding: .55rem 1rem;
  font-size: .84rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  border: none; background: none;
  text-align: left;
  position: relative;
}
.mycol-folder-item .material-symbols-outlined { font-size: 1.15rem; flex-shrink: 0; }
.mycol-folder-item:hover { background: var(--color-bg-tertiary); color: var(--color-text); }
.mycol-folder-item.active { background: var(--color-brand-light); color: var(--color-brand); font-weight: 600; }
.mycol-folder-item.active .material-symbols-outlined { color: var(--color-brand); }
.mycol-folder-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mycol-folder-count {
  font-size: .68rem; font-weight: 700; color: var(--color-text-muted);
  background: var(--color-bg-tertiary); border-radius: var(--radius-full);
  min-width: 20px; text-align: center; padding: .1rem .35rem; line-height: 1.2;
}

.mycol-folder-dragover {
  background: var(--color-brand-light) !important;
  color: var(--color-brand) !important;
  box-shadow: inset 0 0 0 2px var(--color-brand);
  border-radius: var(--radius-md);
}

.mycol-folder-item-wrap {
  display: flex;
  align-items: center;
}
.mycol-folder-item-wrap .mycol-folder-item { flex: 1; }
.mycol-folder-actions {
  display: flex;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease);
  padding-right: .4rem;
}
.mycol-folder-item-wrap:hover .mycol-folder-actions { opacity: 1; }
.mycol-folder-action-btn {
  display: flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: var(--radius-sm);
  color: var(--color-text-muted); cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.mycol-folder-action-btn .material-symbols-outlined { font-size: .85rem; }
.mycol-folder-action-btn:hover { color: var(--color-brand); background: var(--color-bg-tertiary); }
.mycol-folder-action-btn--del:hover { color: var(--color-danger); }

.mycol-folders-footer {
  padding: .5rem .75rem;
  border-top: 1px solid var(--color-border-light);
}

/* -- Main Items Area -- */
.mycol-main { min-width: 0; }

.mycol-controls {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.mycol-filter-group {
  display: flex;
  gap: .3rem;
}
.mycol-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .3rem .6rem;
  border-radius: var(--radius-full);
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--color-bg-secondary);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  transition: all var(--dur-fast) var(--ease);
}
.mycol-filter-btn .material-symbols-outlined { font-size: .95rem; }
.mycol-filter-btn:hover { border-color: var(--color-brand); color: var(--color-brand); }
.mycol-filter-btn.active { background: var(--color-brand); border-color: var(--color-brand); color: #fff; }

.mycol-drag-hint {
  display: flex; align-items: center; gap: .3rem;
  font-size: .72rem; color: var(--color-text-muted); font-weight: 500;
}
.mycol-drag-hint .material-symbols-outlined { font-size: .9rem; }

.mycol-sort-group { margin-left: auto; }
.mycol-sort-group select {
  padding: .3rem .55rem; border: 1px solid var(--color-border);
  border-radius: var(--radius-md); background: var(--color-bg-secondary);
  font-size: .8rem; cursor: pointer;
}

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

.mycol-card {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--dur) var(--ease);
  animation: floatUp var(--dur-reveal) var(--ease) both;
  cursor: grab;
}
.mycol-card:hover { box-shadow: var(--card-shadow-hover); transform: translateY(-3px); }
.mycol-card--dragging { opacity: .4; transform: scale(.95) rotate(1deg); }
.mycol-card--removing { opacity: 0; transform: scale(.88) translateY(10px); }

.mycol-card-remove {
  position: absolute; top: .4rem; right: .4rem; z-index: 3;
  width: 26px; height: 26px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-full); background: rgba(0,0,0,.5); color: #fff;
  cursor: pointer; opacity: 0; transition: all var(--dur-fast) var(--ease);
}
.mycol-card:hover .mycol-card-remove { opacity: 1; }
.mycol-card-remove:hover { background: var(--color-danger); transform: scale(1.1); }
.mycol-card-remove .material-symbols-outlined { font-size: .9rem; }

.mycol-card-link {
  display: flex; gap: .85rem; padding: .85rem;
  text-decoration: none; color: var(--color-text);
}
.mycol-card-link:hover { text-decoration: none; }

.mycol-card-thumb {
  flex-shrink: 0; width: 64px; height: 64px;
  border-radius: var(--radius-md); overflow: hidden;
  background: var(--color-bg-tertiary);
  display: flex; align-items: center; justify-content: center;
}
.mycol-card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.mycol-card-thumb .material-symbols-outlined { font-size: 1.5rem; color: var(--color-text-muted); opacity: .4; }

.mycol-card-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.mycol-card-badge { font-size: .6rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--color-brand); }
.mycol-card-title { font-family: var(--font-display); font-size: .9rem; font-weight: 600; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mycol-card-stars { display: flex; gap: .05rem; }
.mycol-star { font-size: .8rem; color: var(--color-border); }
.mycol-star--active { color: var(--color-gold); }

/* Empty states */
.mycol-empty, .mycol-empty-folder {
  text-align: center; padding: 4rem 2rem; color: var(--color-text-muted);
}
.mycol-empty .material-symbols-outlined, .mycol-empty-folder .material-symbols-outlined {
  font-size: 3.5rem; opacity: .25; margin-bottom: .75rem; display: block;
}
.mycol-empty p, .mycol-empty-folder p {
  font-size: .95rem; max-width: 440px; margin: 0 auto; line-height: 1.7;
}

/* Sidebar badge */
.sidebar-badge {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 .35rem;
  border-radius: var(--radius-full);
  background: var(--color-brand);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  line-height: 1;
}

@media (max-width: 1024px) {
  .mycol-workspace {
    grid-template-columns: 1fr;
  }
  .mycol-folders {
    position: static;
  }
  .mycol-folder-list {
    display: flex;
    gap: .25rem;
    padding: .35rem .5rem;
    overflow-x: auto;
    max-height: none;
  }
  .mycol-folder-item {
    white-space: nowrap;
    padding: .4rem .75rem;
    border-radius: var(--radius-full);
    border: 1px solid var(--color-border);
  }
  .mycol-folder-item.active {
    border-color: var(--color-brand);
  }
  .mycol-folder-actions { display: none; }
}

@media (max-width: 768px) {
  .mycol-header { flex-direction: column; gap: 1rem; }
  .mycol-grid { grid-template-columns: 1fr; }
  .mycol-drag-hint { display: none; }
  .detail-user-actions { flex-direction: column; align-items: flex-start; gap: .75rem; }
  .toast-container { bottom: 1rem; right: 1rem; left: 1rem; }
}

/* ---------- Accessibility Panel ---------- */

.a11y-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(28,21,14,.01);
  backdrop-filter: blur(0);
  -webkit-backdrop-filter: blur(0);
  pointer-events: none;
  opacity: 0;
  transition: all var(--dur) var(--ease);
}
.a11y-overlay--visible {
  pointer-events: auto;
  opacity: 1;
  background: rgba(28,21,14,.35);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.a11y-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 360px;
  max-width: 90vw;
  z-index: 9999;
  background: var(--color-bg-secondary);
  border-left: 1px solid var(--color-border);
  box-shadow: -8px 0 32px rgba(0,0,0,.1);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--dur-slow) var(--ease);
  overflow: hidden;
}
.a11y-panel--open {
  transform: translateX(0);
}

.a11y-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--color-border-light);
}
.a11y-panel-title {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
}
.a11y-panel-title .material-symbols-outlined {
  font-size: 1.3rem;
  color: var(--color-brand);
}
.a11y-panel-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  transition: all var(--dur-fast) var(--ease);
}
.a11y-panel-close:hover {
  background: var(--color-bg-tertiary);
  color: var(--color-text);
}

.a11y-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
}

.a11y-group {
  margin-bottom: 1.15rem;
}

.a11y-label {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .8rem;
  font-weight: 700;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: .5rem;
}
.a11y-label .material-symbols-outlined {
  font-size: 1.05rem;
  color: var(--color-brand);
}

.a11y-slider-row {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.a11y-slider-min,
.a11y-slider-max {
  font-size: .65rem;
  font-weight: 700;
  color: var(--color-text-muted);
  flex-shrink: 0;
  width: 28px;
  text-align: center;
}
.a11y-slider-min { font-size: .6rem; }
.a11y-slider-max { font-size: .85rem; }

.a11y-range {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  background: var(--color-border);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}
.a11y-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-brand);
  border: 2px solid var(--color-bg-elevated);
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
  cursor: grab;
  transition: transform var(--dur-fast) var(--ease);
}
.a11y-range::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}
.a11y-range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-brand);
  border: 2px solid var(--color-bg-elevated);
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
  cursor: grab;
}

.a11y-value {
  font-size: .75rem;
  font-weight: 700;
  color: var(--color-brand);
  min-width: 42px;
  text-align: right;
  flex-shrink: 0;
}

.a11y-divider {
  height: 1px;
  background: var(--color-border-light);
  margin: 1rem 0;
}

/* Toggle switch */
.a11y-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: .3rem 0;
}
.a11y-label-inline {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .84rem;
  font-weight: 600;
  color: var(--color-text);
}
.a11y-label-inline .material-symbols-outlined {
  font-size: 1.1rem;
  color: var(--color-brand);
}

.a11y-toggle {
  position: absolute;
  opacity: 0;
  width: 0; height: 0;
}
.a11y-toggle-track {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--color-border);
  border-radius: 12px;
  flex-shrink: 0;
  transition: background var(--dur-fast) var(--ease);
}
.a11y-toggle-track::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
  transition: transform var(--dur-fast) var(--ease-spring);
}
.a11y-toggle:checked + .a11y-toggle-track {
  background: var(--color-brand);
}
.a11y-toggle:checked + .a11y-toggle-track::after {
  transform: translateX(20px);
}

.a11y-panel-footer {
  display: flex;
  gap: .4rem;
  padding: .85rem 1.25rem;
  border-top: 1px solid var(--color-border-light);
  flex-wrap: wrap;
}
.a11y-footer-btn {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .4rem .7rem;
  font-size: .75rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.a11y-footer-btn .material-symbols-outlined { font-size: .9rem; }
.a11y-footer-btn:hover {
  border-color: var(--color-brand);
  color: var(--color-brand);
}

/* ---------- Accessibility Overrides ---------- */

/* Card image aspect ratio */
.entity-card-image {
  aspect-ratio: calc(4 / (3 * var(--a11y-card-ratio, 1)));
}

/* Timeline scaling */
.timeline {
  font-size: calc(1rem * var(--a11y-timeline-scale, 1));
}

/* Reduce motion */
.a11y-reduce-motion *,
.a11y-reduce-motion *::before,
.a11y-reduce-motion *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}

/* Highlight links */
.a11y-highlight-links a:not(.sidebar-link):not(.entity-card-link):not(.mycol-card-link) {
  text-decoration: underline !important;
  text-decoration-thickness: 2px !important;
  text-underline-offset: 2px !important;
}

/* Dyslexia-friendly font */
.a11y-dyslexia-font body,
.a11y-dyslexia-font h1,
.a11y-dyslexia-font h2,
.a11y-dyslexia-font h3,
.a11y-dyslexia-font .heading-serif,
.a11y-dyslexia-font .entity-card-title,
.a11y-dyslexia-font .mycol-card-title,
.a11y-dyslexia-font .dashboard-recent-title,
.a11y-dyslexia-font .timeline-date,
.a11y-dyslexia-font .amodal-title,
.a11y-dyslexia-font .a11y-panel-title {
  font-family: var(--font-sans) !important;
  letter-spacing: .01em;
}

/* Big cursor */
.a11y-big-cursor,
.a11y-big-cursor * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32'%3E%3Cpath d='M5 2 L5 28 L12 21 L20 28 L23 23 L16 16 L26 16 Z' fill='black' stroke='white' stroke-width='2'/%3E%3C/svg%3E") 5 2, auto !important;
}

/* ---------- Custom Modal ---------- */

.amodal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(28,21,14,.01);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  opacity: 0;
  transition: all var(--dur) var(--ease);
  padding: 1rem;
}
.amodal-overlay--visible {
  opacity: 1;
  background: rgba(28,21,14,.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.amodal {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 64px rgba(0,0,0,.18), 0 8px 24px rgba(0,0,0,.08);
  width: 100%;
  max-width: 420px;
  transform: scale(.92) translateY(16px);
  transition: transform var(--dur) var(--ease-spring);
  overflow: hidden;
}
.amodal-overlay--visible .amodal {
  transform: scale(1) translateY(0);
}

.amodal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem 0;
}
.amodal-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
}
.amodal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.amodal-close:hover {
  background: var(--color-bg-tertiary);
  color: var(--color-text);
}

.amodal-body {
  padding: .75rem 1.5rem 0;
  font-size: .9rem;
  color: var(--color-text-secondary);
  line-height: 1.6;
}
.amodal-body p { margin: 0; }

.amodal-input-wrap {
  padding: 1rem 1.5rem 0;
}
.amodal-input {
  width: 100%;
  padding: .65rem .9rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  font-size: .95rem;
  outline: none;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.amodal-input:focus {
  border-color: var(--color-brand);
  box-shadow: 0 0 0 3px var(--color-brand-light);
}
.amodal-input--error {
  border-color: var(--color-danger) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-danger) 15%, transparent) !important;
  animation: headShake .4s var(--ease);
}

@keyframes headShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

.amodal-footer {
  display: flex;
  justify-content: flex-end;
  gap: .6rem;
  padding: 1.25rem 1.5rem;
}

.amodal-btn {
  padding: .5rem 1.15rem;
  border-radius: var(--radius-full);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  border: 1px solid transparent;
}
.amodal-btn--cancel {
  background: var(--color-bg-tertiary);
  color: var(--color-text-secondary);
  border-color: var(--color-border);
}
.amodal-btn--cancel:hover {
  background: var(--color-bg);
  border-color: var(--color-text-muted);
}
.amodal-btn--confirm {
  background: var(--color-brand);
  color: #fff;
}
.amodal-btn--confirm:hover {
  background: var(--color-brand-dark);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(0,0,0,.12);
}
.amodal-btn--danger {
  background: var(--color-danger);
  color: #fff;
}
.amodal-btn--danger:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(0,0,0,.12);
}

/* ---------- Image Annotations ---------- */

/* Shrink-wrap box around the annotated image so the SVG overlay
   matches the actual image dimensions (not the outer flex container). */
.annotation-image-box {
  position: relative;
  display: inline-block;
  line-height: 0;
  max-width: 100%;
  overflow: visible;
}
.annotation-image-box > img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-lg);
}

/* Allow annotation cards to render outside the rounded hero frame. */
.detail-hero-image--annotated {
  overflow: visible;
}

.annotation-wrap {
  position: relative;
  overflow: visible;
}

.annotation-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

.annotation-poly {
  fill: rgba(201,168,76,.08);
  stroke: rgba(201,168,76,.35);
  stroke-width: 0.3;
  pointer-events: all;
  cursor: pointer;
  transition: fill .3s, stroke .3s;
}
.annotation-poly:hover,
.annotation-poly--active {
  fill: rgba(201,168,76,.2);
  stroke: rgba(201,168,76,.7);
  stroke-width: 0.5;
}

/* Annotation info card */
.annotation-card {
  position: absolute;
  z-index: 5;
  transform: translate(-50%, -100%) translateY(-12px);
  pointer-events: none;
  opacity: 0;
  transition: opacity .25s var(--ease), transform .25s var(--ease);
}
.annotation-card--visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -100%) translateY(-16px);
}

.annotation-card-inner {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: .55rem .75rem;
  box-shadow: 0 8px 28px rgba(0,0,0,.18);
  white-space: nowrap;
  min-width: 120px;
  max-width: 260px;
  position: relative;
  line-height: 1.35;
}
/* Arrow at bottom */
.annotation-card-inner::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 12px;
  height: 12px;
  background: var(--color-bg-secondary);
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

.annotation-card--pinned .annotation-card-inner {
  border-color: var(--color-gold);
}

.annotation-card-header {
  display: flex;
  align-items: center;
  gap: .4rem;
}

.annotation-card-icon {
  font-size: 1rem;
  color: var(--color-brand);
  flex-shrink: 0;
}

.annotation-card-label {
  font-size: .82rem;
  font-weight: 700;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
}

.annotation-card-link {
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  color: var(--color-gold);
  flex-shrink: 0;
  transition: background .15s;
}
.annotation-card-link:hover {
  background: var(--color-gold-dim);
}
.annotation-card-link .material-symbols-outlined {
  font-size: .9rem;
}

.annotation-card-entity {
  font-size: .7rem;
  color: var(--color-text-muted);
  margin-top: .15rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Hint overlay */
.annotation-hint {
  position: absolute;
  bottom: .75rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: .35rem;
  padding: .4rem .85rem;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #F0E8DA;
  border-radius: var(--radius-full);
  font-size: .75rem;
  font-weight: 600;
  line-height: 1.2;
  pointer-events: none;
  transition: opacity .5s var(--ease);
}
.annotation-hint .material-symbols-outlined {
  font-size: .95rem;
}
.annotation-hint--hidden {
  opacity: 0;
}

@media (max-width: 768px) {
  .annotation-card {
    transform: translate(-50%, -100%) translateY(-8px);
  }
  .annotation-card--visible {
    transform: translate(-50%, -100%) translateY(-10px);
  }
  .annotation-card-inner {
    padding: .4rem .6rem;
  }
  .annotation-card-label {
    font-size: .75rem;
  }
}

/* ---------- Scroll to Top ---------- */

.scroll-top-btn {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 100;
  width: 44px; height: 44px;
  border-radius: var(--radius-full);
  background: var(--color-brand);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  opacity: 0;
  transform: translateY(12px) scale(.8);
  pointer-events: none;
  transition: all var(--dur) var(--ease);
}
.scroll-top-btn--visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.scroll-top-btn:hover {
  transform: translateY(-3px) scale(1.08);
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
}

/* ---------- QR + Copy Link buttons ---------- */

.qr-code-btn,
.copy-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  transition: all var(--dur-fast) var(--ease);
}
.qr-code-btn:hover,
.copy-link-btn:hover {
  border-color: var(--color-brand);
  color: var(--color-brand);
  background: var(--color-brand-light);
}
.qr-code-btn .material-symbols-outlined,
.copy-link-btn .material-symbols-outlined {
  font-size: 1.15rem;
}

/* ---------- Skeleton Loading ---------- */

@keyframes skeletonShimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton-active {
  position: relative;
}
.skeleton-active::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg,
    var(--color-bg-tertiary) 25%,
    var(--color-border-light) 37%,
    var(--color-bg-tertiary) 63%
  );
  background-size: 200% 100%;
  animation: skeletonShimmer 1.4s ease infinite;
  border-radius: inherit;
  z-index: 1;
}

.skeleton-loader {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  padding: 1rem 0;
}
.skeleton-card {
  height: 200px;
  border-radius: var(--radius-lg);
  background: linear-gradient(90deg,
    var(--color-bg-tertiary) 25%,
    var(--color-border-light) 37%,
    var(--color-bg-tertiary) 63%
  );
  background-size: 200% 100%;
  animation: skeletonShimmer 1.4s ease infinite;
}

/* ---------- Infinite Scroll ---------- */

.infinite-scroll-sentinel {
  min-height: 20px;
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}
.infinite-scroll-sentinel--loading {
  opacity: 1;
}

/* ---------- On This Day ---------- */

.on-this-day {
  margin-bottom: 3rem;
  animation: fadeInUp var(--dur-reveal) var(--ease) .15s both;
}

.on-this-day-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.on-this-day-card {
  display: flex;
  gap: .85rem;
  padding: .85rem;
  background: var(--card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--color-text);
  transition: all var(--dur) var(--ease);
  position: relative;
  overflow: hidden;
}
.on-this-day-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--color-gold);
}
.on-this-day-card:hover {
  box-shadow: var(--card-shadow-hover);
  transform: translateY(-2px);
  text-decoration: none;
}

.on-this-day-icon {
  flex-shrink: 0;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md);
  background: var(--color-gold-dim);
  color: var(--color-gold);
}
.on-this-day-icon .material-symbols-outlined { font-size: 1.3rem; }

.on-this-day-info { flex: 1; min-width: 0; }
.on-this-day-badge {
  font-size: .6rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--color-gold);
}
.on-this-day-title {
  font-family: var(--font-display);
  font-size: .92rem; font-weight: 600; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- Print ---------- */

@media print {
  .app-sidebar,
  .app-navbar,
  .sidebar-overlay,
  .detail-nav,
  .pagination,
  .list-controls,
  .collection-nav,
  .collection-indicators,
  .scroll-top-btn,
  .a11y-panel,
  .a11y-overlay,
  .toast-container,
  .card-bookmark-btn,
  .detail-user-actions,
  .hero-search-form,
  .qr-code-btn,
  .copy-link-btn {
    display: none !important;
  }
  .app-content-wrapper {
    margin-left: 0 !important;
  }
  .app-main {
    padding: 1cm;
    max-width: none;
  }
  body {
    background: #fff;
    color: #000;
    font-size: 11pt;
    line-height: 1.5;
  }
  h1 { font-size: 20pt; }
  h2 { font-size: 16pt; }
  h3 { font-size: 13pt; }
  .detail-hero {
    border: none;
    padding: 0;
    gap: 1cm;
  }
  .detail-hero-image {
    max-width: 6cm;
    box-shadow: none;
  }
  .entity-card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
  }
  .card-grid { gap: .5cm; }
  a { color: #000; text-decoration: underline; }
  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 8pt;
    color: #666;
  }
  .entity-card-link::after,
  .sidebar-link::after,
  .mycol-card-link::after {
    content: none;
  }
  .metadata-grid { grid-template-columns: 1fr 1fr; }
  .detail-layout { grid-template-columns: 1fr; }
  .detail-body { grid-template-columns: 1fr; }
  .detail-intro--split { grid-template-columns: 1fr 1fr; }
  .detail-timeline-sidebar { border-left: none; padding-left: 0; border-top: 1pt solid #ccc; padding-top: .5cm; }
}

/* ============================================================
   Lightbox V2 — fullscreen viewer with zoom, pan, slideshow
   ============================================================ */

.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(8, 8, 10, .96);
  display: flex;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur) var(--ease), visibility var(--dur) var(--ease);
  color: #f0e8da;
  font-family: var(--font-sans);
  user-select: none;
  -webkit-user-select: none;
}
.lightbox-overlay--open {
  opacity: 1;
  visibility: visible;
}
.lightbox-overlay:fullscreen,
.lightbox-overlay:-webkit-full-screen {
  background: #000;
}

/* ---------- Toolbar (top) ---------- */
.lightbox-toolbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9003;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  gap: 1rem;
  background: linear-gradient(180deg, rgba(0,0,0,.55) 0%, rgba(0,0,0,0) 100%);
  pointer-events: none;
}
.lightbox-toolbar-left,
.lightbox-toolbar-right {
  display: flex;
  align-items: center;
  gap: .5rem;
  pointer-events: auto;
}

.lightbox-counter {
  color: rgba(240, 232, 218, .85);
  font-size: .85rem;
  font-weight: 500;
  letter-spacing: .04em;
  background: rgba(0, 0, 0, .35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: .35rem .85rem;
  border-radius: var(--radius-full);
  min-width: 3rem;
  text-align: center;
}
.lightbox-counter:empty { display: none; }

/* ---------- Buttons ---------- */
.lightbox-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .16);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background var(--dur-fast) var(--ease),
              transform  var(--dur-fast) var(--ease),
              color      var(--dur-fast) var(--ease);
}
.lightbox-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, .22);
  transform: scale(1.06);
}
.lightbox-btn:disabled {
  opacity: .35;
  cursor: not-allowed;
}
.lightbox-btn .material-symbols-outlined {
  font-size: 1.3rem;
}
.lightbox-btn--active {
  color: var(--color-gold);
  background: rgba(201, 168, 76, .18);
  border-color: rgba(201, 168, 76, .5);
}

/* ---------- Side nav ---------- */
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 9002;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .15);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background var(--dur-fast) var(--ease),
              transform  var(--dur-fast) var(--ease);
}
.lightbox-nav:hover {
  background: rgba(255, 255, 255, .22);
  transform: translateY(-50%) scale(1.08);
}
.lightbox-nav--prev { left: 1.25rem; }
.lightbox-nav--next { right: 1.25rem; }

/* ---------- Stage & canvas (image) ---------- */
.lightbox-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  cursor: default;
}
.lightbox-overlay--zoomed .lightbox-stage { cursor: grab; }
.lightbox-canvas--panning .lightbox-stage { cursor: grabbing; }

.lightbox-canvas {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
  --lb-inverse-scale: 1;
  opacity: 0;
  transition: opacity .25s var(--ease);
}
.lightbox-overlay--has-image .lightbox-canvas {
  opacity: 1;
}
.lightbox-canvas--animate {
  transition: transform .22s var(--ease), opacity .25s var(--ease);
}

.lightbox-img {
  display: block;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  -webkit-user-drag: none;
  user-select: none;
  border-radius: 0;
  background: #0b0b0c;
}

/* ---------- Annotation overlay (inside canvas) ---------- */
.lightbox-annotation-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}
.lightbox-annotation-svg .annotation-poly {
  fill: rgba(201, 168, 76, .12);
  stroke: rgba(201, 168, 76, .55);
  stroke-width: 0.35;
  vector-effect: non-scaling-stroke;
  pointer-events: all;
  cursor: pointer;
  transition: fill var(--dur-fast) var(--ease),
              stroke var(--dur-fast) var(--ease);
}
.lightbox-annotation-svg .annotation-poly:hover,
.lightbox-annotation-svg .annotation-poly--active {
  fill: rgba(201, 168, 76, .28);
  stroke: rgba(201, 168, 76, .9);
}
.lightbox-overlay--annotations-hidden .lightbox-annotation-svg,
.lightbox-overlay--annotations-hidden .lightbox-annotation-cards { display: none; }

/* Cards live inside the transformed canvas but counter-scale so they
   stay readable at any zoom level. */
.lightbox-annotation-cards {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}
.lightbox-annotation-card {
  position: absolute;
  transform: translate(-50%, -100%) translateY(-10px) scale(var(--lb-inverse-scale, 1));
  transform-origin: 50% 100%;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s var(--ease);
  z-index: 3;
}
.lightbox-annotation-card--visible {
  opacity: 1;
  pointer-events: auto;
}
.lightbox-annotation-card-inner {
  background: rgba(24, 22, 20, .92);
  border: 1px solid rgba(201, 168, 76, .35);
  border-radius: var(--radius-lg);
  padding: .55rem .75rem;
  box-shadow: 0 10px 32px rgba(0, 0, 0, .5);
  color: #f3ecdd;
  min-width: 140px;
  max-width: 280px;
  position: relative;
  line-height: 1.35;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.lightbox-annotation-card-inner::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  width: 12px;
  height: 12px;
  background: inherit;
  border-right: 1px solid rgba(201, 168, 76, .35);
  border-bottom: 1px solid rgba(201, 168, 76, .35);
  transform: translateX(-50%) rotate(45deg);
}
.lightbox-annotation-card--pinned .lightbox-annotation-card-inner {
  border-color: var(--color-gold);
}
.lightbox-annotation-card-head {
  display: flex;
  align-items: center;
  gap: .4rem;
}
.lightbox-annotation-card-head .material-symbols-outlined {
  font-size: 1rem;
  color: var(--color-gold);
  flex-shrink: 0;
}
.lightbox-annotation-card-title {
  font-size: .82rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lightbox-annotation-card-link {
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  color: var(--color-gold);
  transition: background var(--dur-fast) var(--ease);
}
.lightbox-annotation-card-link:hover { background: rgba(201, 168, 76, .2); }
.lightbox-annotation-card-link .material-symbols-outlined { font-size: .9rem; }
.lightbox-annotation-card-entity {
  font-size: .72rem;
  color: rgba(240, 232, 218, .7);
  margin-top: .2rem;
}

/* ---------- Bottom controls ---------- */
.lightbox-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9003;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.2rem 1rem 1.35rem;
  background: linear-gradient(0deg, rgba(0,0,0,.6) 0%, rgba(0,0,0,0) 100%);
  flex-wrap: wrap;
  pointer-events: none;
}
.lightbox-controls-group {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  pointer-events: auto;
  padding: .25rem .5rem;
  background: rgba(0, 0, 0, .35);
  border-radius: var(--radius-full);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.lightbox-controls-zoom .lightbox-btn,
.lightbox-controls-slideshow .lightbox-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
}
.lightbox-controls-zoom .lightbox-btn:hover:not(:disabled),
.lightbox-controls-slideshow .lightbox-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, .12);
  transform: none;
}
.lightbox-interval {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .78rem;
  color: rgba(240, 232, 218, .8);
  padding: 0 .4rem;
}
.lightbox-interval-select {
  background: rgba(255, 255, 255, .1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: var(--radius-md);
  padding: .15rem .35rem;
  font-size: .78rem;
  cursor: pointer;
}
.lightbox-interval-select option { color: #111; }
.lightbox-caption {
  max-width: 60ch;
  font-size: .82rem;
  color: rgba(240, 232, 218, .8);
  text-align: center;
  pointer-events: auto;
  display: none;
}
.lightbox-caption--visible { display: block; }

/* ---------- Progress bar for slideshow ---------- */
.lightbox-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(255, 255, 255, .08);
  overflow: hidden;
  opacity: 0;
  transition: opacity .2s var(--ease);
  z-index: 9004;
}
.lightbox-overlay--playing .lightbox-progress { opacity: 1; }
.lightbox-progress span {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--color-gold), var(--color-brand));
  transform: scaleX(0);
  transform-origin: 0 50%;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .lightbox-btn { width: 38px; height: 38px; }
  .lightbox-nav { width: 40px; height: 40px; }
  .lightbox-nav--prev { left: .5rem; }
  .lightbox-nav--next { right: .5rem; }
  .lightbox-toolbar { padding: .5rem .65rem; }
  .lightbox-controls { gap: .5rem; padding: .85rem .5rem 1rem; }
  .lightbox-controls-zoom .lightbox-btn,
  .lightbox-controls-slideshow .lightbox-btn { width: 32px; height: 32px; }
  .lightbox-interval-label { display: none; }
  .lightbox-caption { font-size: .75rem; max-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .lightbox-canvas--animate { transition: none; }
  .lightbox-btn, .lightbox-nav { transition: none; }
}

/* ============================================================
   Citation Modal
   ============================================================ */

.citation-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 8500;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur) var(--ease), visibility var(--dur) var(--ease);
}
.citation-modal-overlay--open {
  opacity: 1;
  visibility: visible;
}

.citation-modal {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  width: 95vw;
  max-width: 580px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  animation: floatUp var(--dur) var(--ease) both;
}

.citation-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--color-border-light);
}

.citation-modal-title {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin: 0;
  color: var(--color-text);
}
.citation-modal-title .material-symbols-outlined {
  color: var(--color-gold);
  font-size: 1.3rem;
}

.citation-modal-close {
  background: none;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  border-radius: var(--radius-full);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.citation-modal-close:hover {
  background: var(--color-bg-tertiary);
  color: var(--color-text);
}

.citation-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--color-border-light);
  padding: 0 1.5rem;
}

.citation-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--color-text-muted);
  font-family: var(--font-sans);
  font-size: .85rem;
  font-weight: 600;
  padding: .75rem 1rem;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.citation-tab:hover {
  color: var(--color-text);
}
.citation-tab.active {
  color: var(--color-brand);
  border-bottom-color: var(--color-brand);
}

.citation-body {
  padding: 1.5rem;
}

.citation-panel {
  display: none;
}
.citation-panel.active {
  display: block;
}

.citation-text {
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  font-size: .88rem;
  line-height: 1.6;
  color: var(--color-text);
  margin-bottom: 1rem;
}
.citation-text p {
  margin: 0;
}
.citation-text--mono {
  font-family: 'Courier New', Courier, monospace;
  font-size: .82rem;
}
.citation-text--mono pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.citation-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  font-family: var(--font-sans);
  font-size: .82rem;
  font-weight: 600;
  padding: .5rem 1rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.citation-copy-btn .material-symbols-outlined {
  font-size: 1rem;
}
.citation-copy-btn:hover {
  border-color: var(--color-brand);
  color: var(--color-brand);
  background: var(--color-brand-light);
}
.citation-copy-btn--success {
  border-color: var(--color-success);
  color: var(--color-success);
  background: color-mix(in srgb, var(--color-success) 8%, var(--color-bg-secondary));
}

/* Citation action button in detail-user-actions */
.cite-btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: .45rem .9rem;
  font-size: .82rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}
.cite-btn:hover {
  border-color: var(--color-brand);
  color: var(--color-brand);
  background: var(--color-brand-light);
}
.cite-btn .material-symbols-outlined {
  font-size: 1.15rem;
  transition: transform var(--dur-fast) var(--ease);
}
.cite-btn:hover .material-symbols-outlined {
  transform: scale(1.15);
}

/* ============================================================
   QR Code Modal
   ============================================================ */

.qr-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 8500;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur) var(--ease), visibility var(--dur) var(--ease);
}
.qr-modal-overlay--open {
  opacity: 1;
  visibility: visible;
}

.qr-modal {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  width: 95vw;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  animation: floatUp var(--dur) var(--ease) both;
  text-align: center;
}

.qr-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--color-border-light);
}

.qr-modal-title {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin: 0;
  color: var(--color-text);
}
.qr-modal-title .material-symbols-outlined {
  color: var(--color-gold);
  font-size: 1.3rem;
}

.qr-modal-close {
  background: none;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  border-radius: var(--radius-full);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.qr-modal-close:hover {
  background: var(--color-bg-tertiary);
  color: var(--color-text);
}

.qr-modal-body {
  padding: 2rem 1.5rem 1rem;
}

.qr-modal-body canvas {
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-light);
  max-width: 100%;
  height: auto;
}

.qr-modal-hint {
  font-size: .82rem;
  color: var(--color-text-muted);
  margin-top: 1rem;
  margin-bottom: 0;
  line-height: 1.5;
}

.qr-modal-footer {
  padding: 1rem 1.5rem 1.5rem;
}

.qr-download-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  font-family: var(--font-sans);
  font-size: .82rem;
  font-weight: 600;
  padding: .55rem 1.1rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.qr-download-btn .material-symbols-outlined {
  font-size: 1rem;
}
.qr-download-btn:hover {
  border-color: var(--color-brand);
  color: var(--color-brand);
  background: var(--color-brand-light);
}

/* QR action button in detail-user-actions */
.qr-btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: .45rem .9rem;
  font-size: .82rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}
.qr-btn:hover {
  border-color: var(--color-brand);
  color: var(--color-brand);
  background: var(--color-brand-light);
}
.qr-btn .material-symbols-outlined {
  font-size: 1.15rem;
  transition: transform var(--dur-fast) var(--ease);
}
.qr-btn:hover .material-symbols-outlined {
  transform: scale(1.15);
}
}

/* ============================================================
   Knowledge Graph — Interactive Network Visualization
   ============================================================ */

.knowledge-graph-section {
  margin-bottom: 3rem;
}

.kg-toggle {
  display: flex;
  align-items: center;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  padding: .6rem 0;
  color: var(--color-text);
  gap: .25rem;
}
.kg-toggle:hover {
  color: var(--color-brand);
}
.kg-section-title {
  flex: 1;
  text-align: left;
  margin-bottom: 0;
  padding-bottom: 0;
  font-size: 1.35rem;
}
.kg-section-title::after {
  display: none;
}
.kg-toggle-icon {
  font-size: 1.5rem;
  transition: transform .25s ease;
}
.kg-collapsible-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height .4s ease;
}
.kg-collapsible-content.kg-open {
  max-height: 800px;
  overflow: visible;
}

.knowledge-graph-container {
  position: relative;
  width: 100%;
  min-height: 400px;
  background: var(--color-bg-secondary, #FFFDF8);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg, 12px);
  overflow: hidden;
}
.knowledge-graph-container svg {
  display: block;
}

/* Links */
.kg-link {
  stroke: var(--color-border);
  stroke-opacity: .5;
}
[data-theme="dark"] .kg-link {
  stroke: rgba(255,255,255,.2);
}

/* Node labels */
.kg-label {
  font-family: var(--font-sans);
  font-size: 11px;
  fill: var(--color-text-secondary, #5C4F3D);
  pointer-events: none;
  user-select: none;
}
[data-theme="dark"] .kg-label {
  fill: #ccc;
}

/* Tooltip */
.kg-tooltip {
  position: absolute;
  background: var(--card-bg, #FFFEF9);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm, 6px);
  padding: .5rem .75rem;
  font-size: .85rem;
  pointer-events: none;
  z-index: 10;
  box-shadow: var(--card-shadow);
  transition: opacity .15s ease;
  max-width: 220px;
  color: var(--color-text);
}
.kg-tooltip-type {
  font-size: .75rem;
  color: var(--color-text-muted, #918474);
}

/* Legend */
.kg-legend {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  padding: .75rem 0;
  font-size: .8rem;
  color: var(--color-text-secondary);
}
.kg-legend-item {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
}
.kg-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* ============================================================
   Recommendations — "Das koennte Sie auch interessieren"
   ============================================================ */

.recommendations-section {
  margin-bottom: 3rem;
}

.recommendations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.recommendation-card {
  display: flex;
  gap: .75rem;
  background: var(--card-bg, #FFFEF9);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md, 8px);
  padding: .75rem;
  text-decoration: none;
  color: var(--color-text);
  transition: box-shadow .2s ease, border-color .2s ease;
}
.recommendation-card:hover {
  box-shadow: var(--card-shadow-hover);
  border-color: var(--color-brand);
}

.recommendation-thumb {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  border-radius: var(--radius-sm, 6px);
  overflow: hidden;
  background: var(--color-bg-tertiary, #EDE8DF);
  display: flex;
  align-items: center;
  justify-content: center;
}
.recommendation-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.recommendation-thumb--empty .material-symbols-outlined {
  font-size: 28px;
  color: var(--color-text-muted);
}

.recommendation-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}

.recommendation-badge {
  display: inline-block;
  align-self: flex-start;
  font-size: .7rem;
  font-weight: 600;
  color: #fff;
  padding: .15rem .5rem;
  border-radius: 3px;
  line-height: 1.3;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.recommendation-title {
  font-size: .95rem;
  font-weight: 500;
  line-height: 1.3;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.recommendation-tags-count {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  font-size: .75rem;
  color: var(--color-text-muted);
}
.recommendation-tags-count .material-symbols-outlined {
  font-size: 14px;
}

@media (max-width: 600px) {
  .recommendations-grid {
    grid-template-columns: 1fr;
  }
  .knowledge-graph-container {
    min-height: 300px;
  }
}

/* ============================================================
   QUIZ — Archithek Knowledge Quiz
   Warm, elegant, archive-themed quiz experience
   ============================================================ */

/* ---------- Quiz Animations ---------- */

@keyframes quiz-slideIn {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes quiz-correct-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(39, 174, 96, .4); }
  50%  { box-shadow: 0 0 0 10px rgba(39, 174, 96, 0); }
  100% { box-shadow: 0 0 0 0 rgba(39, 174, 96, 0); }
}

@keyframes quiz-wrong-shake {
  0%, 100% { transform: translateX(0); }
  15%      { transform: translateX(-6px); }
  30%      { transform: translateX(6px); }
  45%      { transform: translateX(-4px); }
  60%      { transform: translateX(4px); }
  75%      { transform: translateX(-2px); }
  90%      { transform: translateX(2px); }
}

@keyframes quiz-trophy-bounce {
  0%   { transform: scale(0); opacity: 0; }
  50%  { transform: scale(1.15); opacity: 1; }
  70%  { transform: scale(.95); }
  100% { transform: scale(1); }
}

@keyframes quiz-feedback-enter {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes quiz-score-pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* ---------- 1. Quiz Page Layout ---------- */

.quiz-page {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1rem;
  min-height: 60vh;
}

.quiz-phase {
  animation: fadeInUp var(--dur-slow, 500ms) var(--ease, ease) both;
}

.quiz-phase--enter {
  opacity: 0;
}

/* ---------- 2. Settings Screen ---------- */

.quiz-settings {
  text-align: center;
}

.quiz-settings-header {
  margin-bottom: 2rem;
}

.quiz-hero-icon {
  font-size: 3rem;
  color: var(--color-gold, #B8960F);
  display: block;
  margin-bottom: .75rem;
}

.quiz-settings-header h1 {
  margin: 0 0 .5rem;
  color: var(--color-text);
}

.quiz-hero-subtitle {
  color: var(--color-text-muted);
  font-size: 1.05rem;
  margin: 0;
}

.quiz-settings-card {
  max-width: 700px;
  margin: 0 auto;
  background: var(--card-bg, #FFFEF9);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg, 14px);
  padding: 2rem;
  box-shadow: var(--card-shadow);
  text-align: left;
}

.quiz-settings-section-title {
  text-align: center;
  margin-top: 0;
  margin-bottom: 1.5rem;
  color: var(--color-text);
}

.quiz-setting-group {
  margin-bottom: 1.5rem;
}

.quiz-setting-label {
  display: block;
  font-weight: 600;
  font-size: .9rem;
  color: var(--color-text-secondary);
  margin-bottom: .75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ---------- 3. Difficulty & Number Pills ---------- */

.quiz-difficulty-pills,
.quiz-num-pills {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.quiz-pill {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1.1rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-full, 9999px);
  background: transparent;
  color: var(--color-text-secondary);
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--dur-fast, 180ms) var(--ease, ease);
  font-family: inherit;
}

.quiz-pill .material-symbols-outlined {
  font-size: 1.15rem;
}

.quiz-pill:hover {
  border-color: var(--color-brand);
  color: var(--color-brand);
  background: color-mix(in srgb, var(--color-brand) 6%, transparent);
}

.quiz-pill--active {
  border-color: var(--color-brand);
  background: var(--color-brand);
  color: #fff;
}

.quiz-pill--active:hover {
  background: var(--color-brand-dark, var(--color-brand));
  border-color: var(--color-brand-dark, var(--color-brand));
  color: #fff;
}

/* ---------- 4. Category Toggles ---------- */

.quiz-category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: .75rem;
}

.quiz-category-toggle {
  cursor: pointer;
}

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

.quiz-category-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
  padding: .85rem .75rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md, 8px);
  background: var(--color-bg-secondary, #FFFDF8);
  font-size: .85rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  text-align: center;
  transition: all var(--dur-fast, 180ms) var(--ease, ease);
}

.quiz-category-card .material-symbols-outlined {
  font-size: 1.5rem;
  color: var(--color-text-muted);
  transition: color var(--dur-fast, 180ms) var(--ease, ease);
}

.quiz-category-toggle:hover .quiz-category-card {
  border-color: var(--color-brand);
}

.quiz-category-toggle input:checked + .quiz-category-card {
  border-color: var(--color-brand);
  background: color-mix(in srgb, var(--color-brand) 8%, var(--color-bg-secondary, #FFFDF8));
  color: var(--color-text);
}

.quiz-category-toggle input:checked + .quiz-category-card .material-symbols-outlined {
  color: var(--color-brand);
}

/* ---------- 5. Start Button ---------- */

.quiz-start-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  width: 100%;
  margin-top: 1rem;
  padding: .9rem 2rem;
  font-size: 1.05rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: var(--radius-md, 8px);
  background: var(--color-brand);
  color: #fff;
  cursor: pointer;
  transition: all var(--dur, 300ms) var(--ease, ease);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--color-brand) 30%, transparent);
}

.quiz-start-btn .material-symbols-outlined {
  font-size: 1.25rem;
}

.quiz-start-btn:hover {
  background: var(--color-brand-dark, var(--color-brand));
  box-shadow: 0 4px 16px color-mix(in srgb, var(--color-brand) 40%, transparent);
  transform: translateY(-1px);
}

.quiz-start-btn:active {
  transform: translateY(0);
}

/* ---------- 6. Progress Bar ---------- */

.quiz-progress {
  height: 4px;
  background: var(--color-border-light, #E8E0D2);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.quiz-progress-bar {
  height: 100%;
  background: var(--color-brand);
  border-radius: 2px;
  width: 0%;
  transition: width var(--dur, 300ms) var(--ease, ease);
}

/* ---------- 7. Question Header ---------- */

.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: .5rem;
}

.quiz-question-counter {
  font-size: .9rem;
  font-weight: 500;
  color: var(--color-text-secondary);
}

.quiz-score-display {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .9rem;
  font-weight: 600;
  color: var(--color-gold, #B8960F);
}

.quiz-score-display .material-symbols-outlined {
  font-size: 1.15rem;
  color: var(--color-gold, #B8960F);
}

/* ---------- 8. Question Card ---------- */

.quiz-question-card {
  max-width: 800px;
  margin: 0 auto;
  background: var(--card-bg, #FFFEF9);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg, 14px);
  padding: 2rem;
  box-shadow: var(--card-shadow);
  position: relative;
}

.quiz-card-enter {
  animation: quiz-slideIn var(--dur, 300ms) var(--ease, ease) both;
}

.quiz-question-text {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0 0 .75rem;
  line-height: 1.5;
}

.quiz-question-description {
  font-size: 1rem;
  color: var(--color-text-secondary);
  margin: 0 0 1.25rem;
  line-height: 1.6;
}

.quiz-connection-entities {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1.25rem;
  justify-content: center;
}

.quiz-connection-tag {
  display: inline-flex;
  align-items: center;
  padding: .4rem 1rem;
  border: 1.5px solid var(--color-gold, #B8960F);
  border-radius: var(--radius-full, 9999px);
  background: var(--color-gold-dim, rgba(184, 150, 15, .15));
  color: var(--color-gold, #B8960F);
  font-weight: 600;
  font-size: .95rem;
}

/* ---------- 9. Question Image ---------- */

.quiz-question-image-wrap {
  text-align: center;
  margin-bottom: 1.25rem;
}

.quiz-question-image {
  max-width: 100%;
  max-height: 350px;
  border-radius: var(--radius-md, 8px);
  object-fit: cover;
  box-shadow: 0 4px 16px rgba(44, 32, 22, .1);
}

/* ---------- 10. Answer Options ---------- */

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: .6rem;
  margin-top: .5rem;
}

.quiz-option-btn {
  display: flex;
  align-items: center;
  gap: .75rem;
  width: 100%;
  text-align: left;
  padding: 1rem 1.25rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md, 8px);
  background: var(--color-bg-secondary, #FFFDF8);
  color: var(--color-text);
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--dur-fast, 180ms) var(--ease, ease);
}

.quiz-option-btn:hover:not(.quiz-option--disabled) {
  border-color: var(--color-brand);
  background: color-mix(in srgb, var(--color-brand) 5%, var(--color-bg-secondary, #FFFDF8));
  transform: translateX(4px);
}

.quiz-option-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: var(--radius-sm, 4px);
  background: var(--color-bg-tertiary, #EDE8DF);
  color: var(--color-text-muted);
  font-size: .8rem;
  font-weight: 600;
}

.quiz-option-label {
  flex: 1;
  min-width: 0;
}

/* Correct answer */
.quiz-option--correct {
  border-color: #27AE60 !important;
  background: rgba(39, 174, 96, .08) !important;
  color: #1E8449;
  animation: quiz-correct-pulse .6s ease;
}

.quiz-option--correct .quiz-option-key {
  background: #27AE60;
  color: #fff;
}

.quiz-option--correct::after {
  content: 'check';
  font-family: 'Material Symbols Outlined';
  font-size: 1.25rem;
  color: #27AE60;
  margin-left: auto;
}

/* Wrong answer */
.quiz-option--wrong {
  border-color: #C0392B !important;
  background: rgba(192, 57, 43, .08) !important;
  color: #A93226;
  animation: quiz-wrong-shake .5s ease;
}

.quiz-option--wrong .quiz-option-key {
  background: #C0392B;
  color: #fff;
}

.quiz-option--wrong::after {
  content: 'close';
  font-family: 'Material Symbols Outlined';
  font-size: 1.25rem;
  color: #C0392B;
  margin-left: auto;
}

/* Disabled (after answering) */
.quiz-option--disabled {
  cursor: default;
  opacity: .7;
  pointer-events: none;
}

.quiz-option--correct.quiz-option--disabled,
.quiz-option--wrong.quiz-option--disabled {
  opacity: 1;
}

/* ---------- 11. Feedback Overlay ---------- */

.quiz-feedback {
  text-align: center;
  padding: 1.5rem;
  margin-top: 1.5rem;
  border-radius: var(--radius-md, 8px);
  background: var(--color-bg-secondary, #FFFDF8);
  border: 1px solid var(--color-border-light);
}

.quiz-feedback--enter {
  animation: quiz-feedback-enter var(--dur, 300ms) var(--ease, ease) both;
}

.quiz-feedback-icon .material-symbols-outlined {
  font-size: 2.5rem;
}

.quiz-icon--correct {
  color: #27AE60;
}

.quiz-icon--wrong {
  color: #C0392B;
}

.quiz-feedback-text {
  font-size: 1.15rem;
  font-weight: 600;
  margin: .5rem 0;
  color: var(--color-text);
}

.quiz-feedback-detail {
  font-size: .95rem;
  color: var(--color-text-secondary);
  margin-bottom: .75rem;
}

.quiz-feedback-correct-label {
  color: var(--color-text-muted);
}

.quiz-feedback-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: .75rem;
}

.quiz-view-link {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  color: var(--color-brand);
  font-size: .9rem;
  font-weight: 500;
  text-decoration: none;
  transition: color var(--dur-fast, 180ms) ease;
}

.quiz-view-link:hover {
  color: var(--color-brand-dark, var(--color-brand));
  text-decoration: underline;
}

.quiz-view-link .material-symbols-outlined {
  font-size: 1rem;
}

.quiz-next-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .6rem 1.4rem;
  border: none;
  border-radius: var(--radius-md, 8px);
  background: var(--color-brand);
  color: #fff;
  font-size: .95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--dur-fast, 180ms) var(--ease, ease);
}

.quiz-next-btn .material-symbols-outlined {
  font-size: 1.1rem;
}

.quiz-next-btn:hover {
  background: var(--color-brand-dark, var(--color-brand));
  transform: translateY(-1px);
}

/* ---------- 12. Results Screen ---------- */

.quiz-results {
  text-align: center;
}

.quiz-results-card {
  max-width: 600px;
  margin: 0 auto;
  background: var(--card-bg, #FFFEF9);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg, 14px);
  padding: 2.5rem 2rem;
  box-shadow: var(--card-shadow);
  animation: scaleIn var(--dur-slow, 500ms) var(--ease, ease) both;
}

.quiz-results-trophy {
  margin-bottom: 1rem;
}

.quiz-trophy-icon {
  font-size: 4rem;
  display: inline-block;
  animation: quiz-trophy-bounce .7s var(--ease-spring, cubic-bezier(.34, 1.56, .64, 1)) both;
}

.quiz-trophy--gold {
  filter: drop-shadow(0 4px 12px rgba(184, 150, 15, .4));
}

.quiz-trophy--silver {
  filter: drop-shadow(0 4px 12px rgba(150, 150, 150, .3));
}

.quiz-trophy--bronze {
  filter: drop-shadow(0 4px 12px rgba(180, 120, 60, .3));
}

.quiz-results-card h2 {
  margin: 0 0 .75rem;
  color: var(--color-text);
}

.quiz-results-score {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-gold, #B8960F);
  margin: 0 0 .5rem;
}

.quiz-results-message {
  font-size: 1rem;
  color: var(--color-text-secondary);
  margin: 0 0 2rem;
}

.quiz-results-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}

.quiz-home-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .6rem 1.4rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md, 8px);
  background: transparent;
  color: var(--color-text-secondary);
  font-size: .95rem;
  font-weight: 500;
  text-decoration: none;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--dur-fast, 180ms) var(--ease, ease);
}

.quiz-home-btn:hover {
  border-color: var(--color-brand);
  color: var(--color-brand);
}

.quiz-home-btn .material-symbols-outlined {
  font-size: 1.1rem;
}

/* ---------- Review List ---------- */

.quiz-review {
  text-align: left;
  margin-top: 1.5rem;
  border-top: 1px solid var(--color-border-light);
  padding-top: 1.25rem;
}

.quiz-review-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.quiz-review-item {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  padding: .5rem .75rem;
  border-radius: var(--radius-sm, 4px);
  font-size: .9rem;
  line-height: 1.4;
  color: var(--color-text-secondary);
}

.quiz-review--correct {
  background: rgba(39, 174, 96, .06);
}

.quiz-review--wrong {
  background: rgba(192, 57, 43, .06);
}

.quiz-review-icon--correct {
  color: #27AE60;
  font-size: 1.15rem;
  flex-shrink: 0;
}

.quiz-review-icon--wrong {
  color: #C0392B;
  font-size: 1.15rem;
  flex-shrink: 0;
}

.quiz-review-text {
  flex: 1;
  min-width: 0;
}

/* ---------- Loading & Error States ---------- */

.quiz-loading {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--color-text-muted);
}

.quiz-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--color-border-light, #E8E0D2);
  border-top-color: var(--color-brand);
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spin .8s linear infinite;
}

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

.quiz-error {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--color-danger, #8B2500);
  font-size: 1rem;
}

/* ---------- 14. Responsive ---------- */

@media (max-width: 640px) {
  .quiz-page {
    padding: 1rem .75rem;
  }

  .quiz-settings-card {
    padding: 1.25rem;
  }

  .quiz-question-card {
    padding: 1.25rem;
  }

  .quiz-category-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: .5rem;
  }

  .quiz-category-card {
    padding: .65rem .5rem;
    font-size: .8rem;
  }

  .quiz-option-btn {
    padding: .85rem 1rem;
    font-size: .95rem;
  }

  .quiz-option-key {
    width: 24px;
    height: 24px;
    font-size: .75rem;
  }

  .quiz-question-image {
    max-height: 220px;
  }

  .quiz-results-card {
    padding: 1.5rem 1.25rem;
  }

  .quiz-trophy-icon {
    font-size: 3rem;
  }

  .quiz-difficulty-pills,
  .quiz-num-pills {
    justify-content: center;
  }
}

/* ---------- 15. Dark Mode Adjustments ---------- */

[data-theme="dark"] .quiz-option--correct {
  background: rgba(39, 174, 96, .15) !important;
  color: #58D68D;
}

[data-theme="dark"] .quiz-option--correct .quiz-option-key {
  background: #27AE60;
  color: #fff;
}

[data-theme="dark"] .quiz-option--correct::after {
  color: #58D68D;
}

[data-theme="dark"] .quiz-option--wrong {
  background: rgba(192, 57, 43, .15) !important;
  color: #EC7063;
}

[data-theme="dark"] .quiz-option--wrong .quiz-option-key {
  background: #C0392B;
  color: #fff;
}

[data-theme="dark"] .quiz-option--wrong::after {
  color: #EC7063;
}

[data-theme="dark"] .quiz-icon--correct {
  color: #58D68D;
}

[data-theme="dark"] .quiz-icon--wrong {
  color: #EC7063;
}

[data-theme="dark"] .quiz-review--correct {
  background: rgba(39, 174, 96, .1);
}

[data-theme="dark"] .quiz-review--wrong {
  background: rgba(192, 57, 43, .1);
}

[data-theme="dark"] .quiz-review-icon--correct {
  color: #58D68D;
}

[data-theme="dark"] .quiz-review-icon--wrong {
  color: #EC7063;
}

[data-theme="dark"] .quiz-question-image {
  box-shadow: 0 4px 16px rgba(0, 0, 0, .3);
}

/* ---------- Quiz Question Heading ---------- */
.quiz-question-heading {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  text-align: center;
  margin: 0 0 1.25rem;
  color: var(--color-text);
  line-height: 1.4;
}

/* ---------- Quiz Statement Card (True/False) ---------- */
.quiz-statement-card {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  background: var(--color-surface, #F7F3ED);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-gold, #C5A55A);
  border-radius: var(--radius-md, 8px);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  font-size: 1.1rem;
  line-height: 1.6;
}
.quiz-statement-card .material-symbols-outlined {
  color: var(--color-gold, #C5A55A);
  font-size: 1.5rem;
  flex-shrink: 0;
  margin-top: .15rem;
}
.quiz-statement-card p {
  margin: 0;
  font-style: italic;
}
[data-theme="dark"] .quiz-statement-card {
  background: rgba(197, 165, 90, .08);
  border-color: rgba(197, 165, 90, .3);
}

/* ---------- Quiz Clue Card (Person Identify) ---------- */
.quiz-clue-card {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  background: var(--color-surface, #F7F3ED);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-brand, #6B4C2A);
  border-radius: var(--radius-md, 8px);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  font-size: 1.1rem;
  line-height: 1.6;
}
.quiz-clue-card .material-symbols-outlined {
  color: var(--color-brand, #6B4C2A);
  font-size: 1.5rem;
  flex-shrink: 0;
  margin-top: .15rem;
}
.quiz-clue-card p {
  margin: 0;
}
[data-theme="dark"] .quiz-clue-card {
  background: rgba(107, 76, 42, .1);
  border-color: rgba(107, 76, 42, .4);
}

/* ---------- Quiz Connection Entities ---------- */
.quiz-connection-entities {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  justify-content: center;
  margin-bottom: 1.5rem;
}
.quiz-connection-tag {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: var(--color-surface, #F7F3ED);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: .5rem 1.25rem;
  font-size: 1rem;
  font-weight: 500;
}
.quiz-connection-tag .material-symbols-outlined {
  font-size: 1.1rem;
  color: var(--color-brand);
}

/* ============================================================
   NEW TIMELINE — .tl  (replaces old .timeline)
   ============================================================ */

/* Container */
.tl {
  position: relative;
  padding: .5rem 0 .5rem 3rem;
}

/* Vertical track line */
.tl-track {
  position: absolute;
  left: 14px;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--color-gold) 0%, var(--color-border) 100%);
  opacity: .6;
}

/* Single timeline item */
.tl-item {
  position: relative;
  padding-bottom: 1.75rem;
  animation: fadeInUp .4s var(--ease, ease) both;
}
.tl-item--last {
  padding-bottom: 0;
}

/* Node (dot on the track) */
.tl-node {
  position: absolute;
  left: -2.95rem;
  top: .15rem;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.tl-dot {
  display: block;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--color-gold, #C5A55A);
  border: 3px solid var(--color-bg, #fff);
  box-shadow: 0 0 0 2px var(--color-gold, #C5A55A);
  transition: transform .25s ease, box-shadow .25s ease;
}
.tl-item:hover .tl-dot {
  transform: scale(1.35);
  box-shadow: 0 0 0 4px rgba(197, 165, 90, .25);
}
.tl-item--first .tl-dot {
  width: 15px;
  height: 15px;
  background: var(--color-brand, #6B4C2A);
  box-shadow: 0 0 0 3px var(--color-brand, #6B4C2A);
}

/* Card */
.tl-card {
  background: var(--card-bg, #FFFEF9);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md, 8px);
  padding: .85rem 1rem;
  margin-left: .25rem;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.tl-item:hover .tl-card {
  border-color: var(--color-gold, #C5A55A);
  box-shadow: 0 2px 12px rgba(197, 165, 90, .1);
}

/* Card header — date + badge on one line */
.tl-card-header {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  flex-wrap: wrap;
  margin-bottom: .35rem;
}

/* Date */
.tl-date {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.3;
}

/* Category badge */
.tl-badge {
  display: inline-block;
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--color-gold, #C5A55A);
  background: rgba(197, 165, 90, .1);
  padding: .15rem .55rem;
  border-radius: 3px;
  line-height: 1.4;
  white-space: nowrap;
}

/* Linked entity row */
.tl-card-body {
  margin-top: .25rem;
}
.tl-entity-link {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .95rem;
  font-weight: 500;
  color: var(--color-brand, #6B4C2A);
  text-decoration: none;
  transition: color .2s ease;
  line-height: 1.4;
}
.tl-entity-link:hover {
  color: var(--color-gold, #C5A55A);
  text-decoration: underline;
}
.tl-entity-icon {
  font-size: 1rem;
  opacity: .7;
}
.tl-entity-text {
  font-size: .95rem;
  color: var(--color-text-secondary);
}

/* Description */
.tl-card-desc {
  font-size: .88rem;
  color: var(--color-text-secondary);
  line-height: 1.55;
  margin-top: .35rem;
}

/* ---- Sidebar compact variant ---- */
.tl--sidebar {
  padding-left: 2.25rem;
}
.tl--sidebar .tl-track {
  left: 10px;
  width: 2px;
}
.tl--sidebar .tl-node {
  left: -2.2rem;
  width: 22px;
  height: 22px;
}
.tl--sidebar .tl-dot {
  width: 10px;
  height: 10px;
  border-width: 2px;
  box-shadow: 0 0 0 1.5px var(--color-gold);
}
.tl--sidebar .tl-item--first .tl-dot {
  width: 12px;
  height: 12px;
  box-shadow: 0 0 0 2px var(--color-brand);
}
.tl--sidebar .tl-item {
  padding-bottom: 1rem;
}
.tl--sidebar .tl-card {
  padding: .65rem .75rem;
}
.tl--sidebar .tl-date {
  font-size: 1rem;
}
.tl--sidebar .tl-badge {
  font-size: .6rem;
  padding: .1rem .4rem;
}
.tl--sidebar .tl-entity-link,
.tl--sidebar .tl-entity-text {
  font-size: .88rem;
}
.tl--sidebar .tl-card-desc {
  font-size: .82rem;
}

/* Dark mode */
[data-theme="dark"] .tl-card {
  background: rgba(255, 255, 255, .04);
  border-color: rgba(255, 255, 255, .1);
}
[data-theme="dark"] .tl-item:hover .tl-card {
  border-color: var(--color-gold);
  box-shadow: 0 2px 16px rgba(197, 165, 90, .08);
}
[data-theme="dark"] .tl-dot {
  border-color: var(--color-bg, #0F0C08);
}
[data-theme="dark"] .tl-badge {
  background: rgba(197, 165, 90, .15);
}
[data-theme="dark"] .tl-track {
  opacity: .4;
}

/* Mobile */
@media (max-width: 768px) {
  .tl {
    padding-left: 2.25rem;
  }
  .tl-node {
    left: -2.25rem;
  }
  .tl-card {
    padding: .75rem .85rem;
  }
  .tl-date {
    font-size: 1.05rem;
  }
}

/* ============================================================
   High Contrast — full override for readability
   ============================================================ */

/* Navbar */
[data-theme="high-contrast"] .app-navbar {
  background: #000;
  border-bottom-color: #FFD700;
}
[data-theme="high-contrast"] .navbar-search {
  background: #111;
  border-color: #FFD700;
  color: #fff;
}
[data-theme="high-contrast"] .navbar-search-input {
  color: #fff;
}
[data-theme="high-contrast"] .navbar-search-input::placeholder {
  color: #999;
}
[data-theme="high-contrast"] .navbar-theme-toggle {
  border-color: #FFD700;
  color: #FFD700;
  background: #000;
}
[data-theme="high-contrast"] .navbar-theme-toggle:hover {
  background: #FFD700;
  color: #000;
}
[data-theme="high-contrast"] .navbar-lang-switcher {
  border-color: #FFD700;
}
[data-theme="high-contrast"] .lang-btn {
  color: #FFD700;
  background: #000;
}
[data-theme="high-contrast"] .lang-btn:hover {
  background: #222;
  color: #fff;
}
[data-theme="high-contrast"] .lang-btn.active {
  background: #FFD700;
  color: #000;
}

/* Sidebar */
[data-theme="high-contrast"] .app-sidebar {
  background: #000;
  border-right: 2px solid #FFD700;
}
[data-theme="high-contrast"] .sidebar-link {
  color: #fff;
}
[data-theme="high-contrast"] .sidebar-link:hover {
  background: #222;
  color: #FFD700;
}
[data-theme="high-contrast"] .sidebar-link.active {
  background: #FFD700;
  color: #000;
}
[data-theme="high-contrast"] .sidebar-link.active .material-symbols-outlined {
  color: #000;
}
[data-theme="high-contrast"] .sidebar-divider {
  border-color: #444;
}
[data-theme="high-contrast"] .sidebar-section-label {
  color: #999;
}

/* Cards */
[data-theme="high-contrast"] .entity-card,
[data-theme="high-contrast"] .dashboard-stat-card,
[data-theme="high-contrast"] .recommendation-card,
[data-theme="high-contrast"] .relation-card {
  background: #000;
  border: 2px solid #FFD700;
  color: #fff;
}
[data-theme="high-contrast"] .entity-card:hover,
[data-theme="high-contrast"] .recommendation-card:hover {
  border-color: #fff;
  box-shadow: 0 0 0 2px #FFD700;
}

/* Detail hero */
[data-theme="high-contrast"] .detail-hero {
  background: #000;
  border-color: #FFD700;
}
[data-theme="high-contrast"] .detail-hero::before {
  background: #FFD700;
}

/* Buttons (bookmark, QR, etc.) */
[data-theme="high-contrast"] .bookmark-btn,
[data-theme="high-contrast"] .qr-btn {
  color: #FFD700;
  border-color: #FFD700;
  background: #000;
}
[data-theme="high-contrast"] .bookmark-btn:hover,
[data-theme="high-contrast"] .qr-btn:hover {
  background: #FFD700;
  color: #000;
}

/* Star rating */
[data-theme="high-contrast"] .star-btn {
  color: #FFD700;
}

/* Metadata */
[data-theme="high-contrast"] .metadata-item {
  border-bottom-color: #444;
}
[data-theme="high-contrast"] .metadata-item dt {
  color: #FFD700;
}
[data-theme="high-contrast"] .metadata-item dd {
  color: #fff;
}

/* Timeline */
[data-theme="high-contrast"] .tl-card {
  background: #111;
  border-color: #FFD700;
}
[data-theme="high-contrast"] .tl-dot {
  background: #FFD700;
  border-color: #000;
  box-shadow: 0 0 0 2px #FFD700;
}
[data-theme="high-contrast"] .tl-track {
  background: #FFD700;
  opacity: 1;
}
[data-theme="high-contrast"] .tl-date {
  color: #FFD700;
}
[data-theme="high-contrast"] .tl-entity-link {
  color: #FFD700;
}

/* Section titles */
[data-theme="high-contrast"] .section-title::after {
  background: #FFD700;
}

/* Detail nav buttons */
[data-theme="high-contrast"] .detail-nav-btn {
  color: #FFD700;
  border-color: #FFD700;
}
[data-theme="high-contrast"] .detail-nav-btn:hover {
  background: #FFD700;
  color: #000;
}

/* Time slider */
[data-theme="high-contrast"] .time-slider-wrapper {
  border-color: #FFD700;
}
[data-theme="high-contrast"] .noUi-connect {
  background: #FFD700;
}

/* Knowledge graph */
[data-theme="high-contrast"] .knowledge-graph-container {
  background: #000;
  border-color: #FFD700;
}

/* Quiz */
[data-theme="high-contrast"] .quiz-pill--active {
  background: #FFD700;
  color: #000;
}
[data-theme="high-contrast"] .quiz-option-btn {
  background: #000;
  border-color: #FFD700;
  color: #fff;
}
[data-theme="high-contrast"] .quiz-option-btn:hover {
  background: #111;
}
[data-theme="high-contrast"] .quiz-start-btn {
  background: #FFD700;
  color: #000;
}

/* Media gallery */
[data-theme="high-contrast"] .media-gallery-item {
  border: 2px solid #FFD700;
}

/* Footer */
[data-theme="high-contrast"] .app-footer {
  background: #000;
  border-top-color: #FFD700;
  color: #fff;
}
[data-theme="high-contrast"] .app-footer a {
  color: #FFD700;
}

/* Search */
[data-theme="high-contrast"] .hero-search-form {
  background: #111;
  border-color: #FFD700;
}
[data-theme="high-contrast"] .hero-search-form input {
  color: #fff;
}

/* Links everywhere */
[data-theme="high-contrast"] a {
  color: #FFD700;
}
[data-theme="high-contrast"] a:hover {
  color: #fff;
}

/* Breadcrumb */
[data-theme="high-contrast"] .breadcrumb a {
  color: #FFD700;
}

/* Pagination */
[data-theme="high-contrast"] .pagination-btn {
  color: #FFD700;
  border-color: #FFD700;
}
[data-theme="high-contrast"] .pagination-btn--active {
  background: #FFD700;
  color: #000;
}

/* Scrollbar */
[data-theme="high-contrast"] ::-webkit-scrollbar-thumb {
  background: #FFD700;
}

/* Dashboard stats */
[data-theme="high-contrast"] .dashboard-stat-number {
  color: #FFD700;
}

/* Accessibility panel */
[data-theme="high-contrast"] .a11y-panel {
  background: #000;
  border-color: #FFD700;
}
[data-theme="high-contrast"] .a11y-panel input[type="range"]::-webkit-slider-thumb {
  background: #FFD700;
}
