/* LexiOrigin Stylesheet */

/* --- Custom Properties & Theme Setup --- */
:root {
  --font-heading: 'EB Garamond', 'Georgia', serif;
  --font-body: 'Lora', 'Georgia', serif;

  /* Light Theme Colors */
  --bg-main: #faf8f4;
  --text-main: #1a1410;
  --text-muted: #6b6259;
  
  --card-bg: rgba(255, 255, 255, 0.85);
  --card-border: rgba(26, 20, 16, 0.08);
  --card-border-hover: rgba(26, 20, 16, 0.15);
  --card-glow: rgba(99, 102, 241, 0.03);

  --primary-gradient: linear-gradient(135deg, #c85a1e 0%, #a0522d 50%, #8b4513 100%);
  --primary-hover-glow: rgba(200, 90, 30, 0.25);

  /* Origin Color Scheme (scholarly palette for light theme) */
  --col-germanic-h: 24;
  --col-germanic: hsl(var(--col-germanic-h), 75%, 45%);
  --bg-germanic: hsla(var(--col-germanic-h), 75%, 45%, 0.12);
  --border-germanic: hsla(var(--col-germanic-h), 75%, 45%, 0.3);

  --col-romance-h: 210;
  --col-romance: hsl(var(--col-romance-h), 70%, 45%);
  --bg-romance: hsla(var(--col-romance-h), 70%, 45%, 0.12);
  --border-romance: hsla(var(--col-romance-h), 70%, 45%, 0.3);

  --col-hellenic-h: 275;
  --col-hellenic: hsl(var(--col-hellenic-h), 65%, 45%);
  --bg-hellenic: hsla(var(--col-hellenic-h), 65%, 45%, 0.12);
  --border-hellenic: hsla(var(--col-hellenic-h), 65%, 45%, 0.3);

  --col-celtic-h: 120;
  --col-celtic: hsl(var(--col-celtic-h), 60%, 40%);
  --bg-celtic: hsla(var(--col-celtic-h), 60%, 40%, 0.12);
  --border-celtic: hsla(var(--col-celtic-h), 60%, 40%, 0.3);

  --col-arabic-h: 40;
  --col-arabic: hsl(var(--col-arabic-h), 75%, 45%);
  --bg-arabic: hsla(var(--col-arabic-h), 75%, 45%, 0.12);
  --border-arabic: hsla(var(--col-arabic-h), 75%, 45%, 0.3);

  --col-sanskrit-h: 350;
  --col-sanskrit: hsl(var(--col-sanskrit-h), 70%, 50%);
  --bg-sanskrit: hsla(var(--col-sanskrit-h), 70%, 50%, 0.12);
  --border-sanskrit: hsla(var(--col-sanskrit-h), 70%, 50%, 0.3);

  --col-hebrew-h: 180;
  --col-hebrew: hsl(var(--col-hebrew-h), 65%, 45%);
  --bg-hebrew: hsla(var(--col-hebrew-h), 65%, 45%, 0.12);
  --border-hebrew: hsla(var(--col-hebrew-h), 65%, 45%, 0.3);

  --col-japanese-h: 0;
  --col-japanese: hsl(var(--col-japanese-h), 75%, 45%);
  --bg-japanese: hsla(var(--col-japanese-h), 75%, 45%, 0.12);
  --border-japanese: hsla(var(--col-japanese-h), 75%, 45%, 0.3);

  --col-chinese-h: 130;
  --col-chinese: hsl(var(--col-chinese-h), 60%, 40%);
  --bg-chinese: hsla(var(--col-chinese-h), 60%, 40%, 0.12);
  --border-chinese: hsla(var(--col-chinese-h), 60%, 40%, 0.3);

  --col-other-h: 200;
  --col-other: hsl(var(--col-other-h), 15%, 50%);
  --bg-other: hsla(var(--col-other-h), 15%, 50%, 0.08);
  --border-other: hsla(var(--col-other-h), 15%, 50%, 0.2);

  /* Utilities */
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s ease;
}

/* --- Reset & Base Styles --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.is-hidden {
  display: none !important;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-body);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  line-height: 1.6;
}

/* --- Ambient Background Glows --- */
.bg-glow {
  position: absolute;
  width: 50vw;
  height: 50vw;
  max-width: 600px;
  max-height: 600px;
  border-radius: 50%;
  filter: blur(140px);
  opacity: 0.06;
  pointer-events: none;
  z-index: -1;
  animation: float-glow 20s infinite alternate ease-in-out;
}

.bg-glow-1 {
  background: #c85a1e;
  top: -10%;
  left: -10%;
  animation-delay: 0s;
}

.bg-glow-2 {
  background: #8b7355;
  bottom: 10%;
  right: -10%;
  animation-delay: 4s;
}

.bg-glow-3 {
  background: #9370db;
  top: 40%;
  left: 35%;
  width: 30vw;
  height: 30vw;
  animation-delay: 8s;
}
  height: 30vw;
  animation-delay: 8s;
}

@keyframes float-glow {
  0% {
    transform: translate(0, 0) scale(1);
  }
  100% {
    transform: translate(50px, 40px) scale(1.15);
  }
}

/* --- App Layout --- */
.app-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 40px 24px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-header {
  text-align: center;
  margin-bottom: 40px;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}

.logo-icon {
  font-size: 2.5rem;
}

.logo h1 {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 2.8rem;
  letter-spacing: -1px;
  background: linear-gradient(to right, #1a1410, #6b6259);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tagline {
  font-size: 1.15rem;
  color: var(--text-muted);
  font-weight: 500;
}

.site-nav {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.site-nav a,
.footer-links a,
.text-link {
  color: var(--col-romance);
  text-decoration: none;
  font-weight: 600;
}

.site-nav a {
  padding: 7px 12px;
  border: 1px solid rgba(26, 20, 16, 0.08);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.45);
  color: var(--text-main);
  transition: var(--transition-fast);
}

.site-nav a:hover,
.footer-links a:hover,
.text-link:hover {
  color: var(--col-germanic);
}

.site-nav a:hover {
  border-color: rgba(200, 90, 30, 0.3);
  background: rgba(255, 255, 255, 0.75);
}

.app-main {
  display: flex;
  flex-direction: column;
  gap: 32px;
  flex: 1;
  width: 100%;
}

@media (max-width: 1024px) {
  .app-main {
    flex-direction: column;
  }
  .app-container {
    padding: 20px 16px;
  }
}

/* --- Glassmorphism Panels --- */
.glass-card {
  background: var(--card-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08), inset 0 1px 1px rgba(255, 255, 255, 0.8);
  padding: 32px;
  transition: var(--transition-smooth);
  display: flex;
  flex-direction: column;
}

.glass-card:hover {
  border-color: var(--card-border-hover);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12), 0 0 30px 0 var(--card-glow);
}

/* Collapsed Chat-Bar Style for Input Panel */
.panel-input {
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(26, 20, 16, 0.15);
  margin-bottom: 24px;
  order: -1;
  max-height: none;
}

.panel-input .panel-header {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 8px;
  gap: 8px;
}

.panel-input .panel-header h2 {
  display: none;
}

.panel-input .textarea-wrapper {
  margin-bottom: 0;
  max-height: 50px;
  overflow-y: auto;
  border-radius: 20px;
}

.panel-input textarea {
  min-height: 36px;
  max-height: none;
  font-size: 0.9rem;
  padding: 8px 12px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(26, 20, 16, 0.1);
  resize: none;
  overflow: hidden;
}

.panel-input .textarea-footer {
  display: none;
}

.panel-input #btn-analyze {
  display: none;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.panel-header h2 {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: -0.5px;
}

/* Sample Presets Section */
.sample-presets {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-md);
  border: 1px solid rgba(26, 20, 16, 0.08);
  flex-wrap: wrap;
}

.sample-presets .sample-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  text-transform: none;
  letter-spacing: normal;
}

.sample-presets .btn-sample {
  background: rgba(200, 90, 30, 0.15);
  border: 1px solid rgba(200, 90, 30, 0.3);
  color: var(--col-germanic);
}

.sample-presets .btn-sample:hover {
  background: rgba(200, 90, 30, 0.25);
  border-color: rgba(200, 90, 30, 0.5);
}

/* --- Input Section Styling --- */
.sample-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sample-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-sample {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 20px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-sample:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.textarea-wrapper {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(26, 20, 16, 0.08);
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  min-height: 380px;
  overflow: hidden;
  transition: var(--transition-fast);
}

.textarea-wrapper:focus-within {
  border-color: rgba(200, 90, 30, 0.4);
  box-shadow: 0 0 20px 0 rgba(200, 90, 30, 0.1);
}

/* Drag-and-drop active state */
.textarea-wrapper.drag-active {
  border-color: rgba(200, 90, 30, 0.6);
  border-style: dashed;
  box-shadow: 0 0 30px 0 rgba(200, 90, 30, 0.15);
}

.textarea-wrapper.drag-active #drag-overlay {
  opacity: 1;
  pointer-events: none;
}

#drag-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(168, 85, 247, 0.05);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 1;
}

.drag-overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}

.drag-overlay-icon {
  font-size: 2rem;
  animation: bounce-upload 0.6s ease-in-out infinite;
}

@keyframes bounce-upload {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

#text-input {
  width: 100%;
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.8;
  padding: 20px;
  resize: none;
}

#text-input::placeholder {
  color: #9b8774;
}

.textarea-footer {
  display: flex;
  justify-content: space-between;
  padding: 12px 20px;
  border-top: 1px solid rgba(26, 20, 16, 0.05);
  background: rgba(0, 0, 0, 0.02);
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* --- Buttons --- */
.btn-primary {
  position: relative;
  background: var(--primary-gradient);
  border: none;
  outline: none;
  color: #ffffff;
  padding: 16px 28px;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 4px 12px rgba(200, 90, 30, 0.25);
  transition: var(--transition-smooth);
  overflow: hidden;
}
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 4px 20px 0 rgba(168, 85, 247, 0.2);
  transition: var(--transition-smooth);
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #a855f7 0%, #ec4899 50%, #6366f1 100%);
  opacity: 0;
  transition: opacity 0.5s ease;
  z-index: 1;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px 0 var(--primary-hover-glow);
}

.btn-primary:hover::before {
  opacity: 1;
}

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

.btn-primary > * {
  position: relative;
  z-index: 2;
}

.btn-icon {
  font-size: 1.2rem;
  transition: var(--transition-smooth);
}

.btn-primary:hover .btn-icon {
  transform: scale(1.15) rotate(10deg);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Icon-only buttons for export actions */
.btn-icon-small {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  cursor: pointer;
  transition: var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon-small:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Loading state for Analyze Button */
.btn-primary.loading {
  pointer-events: none;
}

.btn-primary.loading .btn-text,
.btn-primary.loading .btn-icon {
  opacity: 0;
}

.btn-loader {
  display: none;
  position: absolute;
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #ffffff;
  animation: spin 1s ease-in-out infinite;
  z-index: 3;
}

.btn-primary.loading .btn-loader {
  display: block;
}

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

/* --- Placeholder State Styling --- */
.placeholder-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex: 1;
  padding: 60px 20px;
  color: var(--text-muted);
}

.placeholder-icon {
  font-size: 3.5rem;
  margin-bottom: 20px;
  opacity: 0.4;
  animation: pulse-icon 3s infinite ease-in-out;
}

@keyframes pulse-icon {
  0%, 100% { transform: scale(1); opacity: 0.4; }
  50% { transform: scale(1.08); opacity: 0.6; }
}

.placeholder-state h3 {
  font-family: var(--font-heading);
  color: var(--text-main);
  font-size: 1.3rem;
  margin-bottom: 10px;
}

.placeholder-state p {
  max-width: 320px;
  font-size: 0.95rem;
}

/* Active Results Styling */
.results-active-container {
  display: flex;
  flex-direction: column;
  gap: 28px;
  flex: 1;
  animation: fadeIn 0.4s ease;
}

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

/* Stats Cards Grid - Now a Vertical List */
.stats-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 8px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid rgba(26, 20, 16, 0.08);
  border-radius: var(--radius-md);
  padding: 18px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  cursor: pointer;
  position: relative;
  overflow: visible;
  transition: var(--transition-smooth);
  min-width: 0;
  pointer-events: auto;
}

.stat-card:hover {
  background: rgba(255, 255, 255, 0.6);
  border-color: rgba(26, 20, 16, 0.12);
  transform: translateY(-2px);
}

/* Individual card hover glows by origin */
.stat-card[data-origin="Germanic"]:hover {
  box-shadow: 0 5px 20px -5px hsla(var(--col-germanic-h), 95%, 60%, 0.15);
  border-color: hsla(var(--col-germanic-h), 95%, 60%, 0.25);
}
.stat-card[data-origin="Romance"]:hover {
  box-shadow: 0 5px 20px -5px hsla(var(--col-romance-h), 95%, 60%, 0.15);
  border-color: hsla(var(--col-romance-h), 95%, 60%, 0.25);
}
.stat-card[data-origin="Latinate"]:hover {
  box-shadow: 0 5px 20px -5px hsla(var(--col-romance-h), 95%, 60%, 0.15);
  border-color: hsla(var(--col-romance-h), 95%, 60%, 0.25);
}
.stat-card[data-origin="Hellenic"]:hover {
  box-shadow: 0 5px 20px -5px hsla(var(--col-hellenic-h), 95%, 65%, 0.15);
  border-color: hsla(var(--col-hellenic-h), 95%, 65%, 0.25);
}
.stat-card[data-origin="Celtic"]:hover {
  box-shadow: 0 5px 20px -5px hsla(var(--col-celtic-h), 95%, 60%, 0.15);
  border-color: hsla(var(--col-celtic-h), 95%, 60%, 0.25);
}
.stat-card[data-origin="Arabic"]:hover {
  box-shadow: 0 5px 20px -5px hsla(var(--col-arabic-h), 95%, 60%, 0.15);
  border-color: hsla(var(--col-arabic-h), 95%, 60%, 0.25);
}
.stat-card[data-origin="Sanskrit"]:hover {
  box-shadow: 0 5px 20px -5px hsla(var(--col-sanskrit-h), 95%, 65%, 0.15);
  border-color: hsla(var(--col-sanskrit-h), 95%, 65%, 0.25);
}
.stat-card[data-origin="Hebrew"]:hover {
  box-shadow: 0 5px 20px -5px hsla(var(--col-hebrew-h), 95%, 60%, 0.15);
  border-color: hsla(var(--col-hebrew-h), 95%, 60%, 0.25);
}
.stat-card[data-origin="Japanese"]:hover {
  box-shadow: 0 5px 20px -5px hsla(var(--col-japanese-h), 95%, 60%, 0.15);
  border-color: hsla(var(--col-japanese-h), 95%, 60%, 0.25);
}
.stat-card[data-origin="Chinese"]:hover {
  box-shadow: 0 5px 20px -5px hsla(var(--col-chinese-h), 95%, 60%, 0.15);
  border-color: hsla(var(--col-chinese-h), 95%, 60%, 0.25);
}
.stat-card[data-origin="Other"]:hover {
  box-shadow: 0 5px 20px -5px hsla(var(--col-other-h), 15%, 65%, 0.15);
  border-color: hsla(var(--col-other-h), 15%, 65%, 0.2);
}

/* Radial Progress Ring */
.stat-circle-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  flex-shrink: 0;
}

.progress-ring {
  transform: rotate(-90deg);
}

.progress-ring__background {
  stroke: rgba(26, 20, 16, 0.08);
}

.progress-ring__circle {
  stroke-dasharray: 201; /* 2 * PI * r = 2 * 3.14159 * 32 = 201.06 */
  stroke-dashoffset: 201;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Specific ring stroke colors */
#ring-germanic { stroke: var(--col-germanic); }
#ring-romance { stroke: var(--col-romance); }
#ring-latinate { stroke: var(--col-romance); }
#ring-hellenic { stroke: var(--col-hellenic); }
#ring-celtic { stroke: var(--col-celtic); }
#ring-arabic { stroke: var(--col-arabic); }
#ring-sanskrit { stroke: var(--col-sanskrit); }
#ring-hebrew { stroke: var(--col-hebrew); }
#ring-japanese { stroke: var(--col-japanese); }
#ring-chinese { stroke: var(--col-chinese); }
#ring-other { stroke: var(--col-other); }

.stat-percentage {
  position: absolute;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--text-main);
  text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.stat-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.stat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
  vertical-align: middle;
}

.dot-germanic { background-color: var(--col-germanic); }
.dot-romance { background-color: var(--col-romance); }
.dot-latinate { background-color: var(--col-romance); }
.dot-hellenic { background-color: var(--col-hellenic); }
.dot-celtic { background-color: var(--col-celtic); }
.dot-arabic { background-color: var(--col-arabic); }
.dot-sanskrit { background-color: var(--col-sanskrit); }
.dot-hebrew { background-color: var(--col-hebrew); }
.dot-japanese { background-color: var(--col-japanese); }
.dot-chinese { background-color: var(--col-chinese); }
.dot-other { background-color: var(--col-other); }

.stat-name {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--text-main);
  white-space: nowrap;
}

.stat-description {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Legend Section */
.legend-panel {
  padding: 14px 20px;
  border-radius: var(--radius-md);
  background: rgba(26, 20, 16, 0.02);
  border: 1px dashed rgba(26, 20, 16, 0.08);
}

.legend-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.legend-header > div,
.legend-header-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.export-actions {
  display: flex;
  gap: 8px;
}

.legend-header h3 {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 600;
}

.legend-tip {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Highlight Output Container */
.highlight-display-wrapper {
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(26, 20, 16, 0.08);
  border-radius: var(--radius-md);
  padding: 24px;
  max-height: 400px;
  overflow-y: auto;
  line-height: 1.9;
  font-size: 1.05rem;
  position: relative;
  transition: var(--transition-smooth);
}

.highlight-output-content {
  white-space: pre-wrap; /* Keeps indentation and spacing */
  word-break: break-word;
}

/* Expanded contraction styling */
.contraction-expanded {
  display: inline;
  border-bottom: 2px dotted rgba(26, 20, 16, 0.2);
  position: relative;
}

.contraction-expanded .highlight-word {
  margin: 0 2px;
}

/* --- Word Highlight Styles --- */
.highlight-word {
  display: inline-block;
  position: relative;
  padding: 2px 6px;
  margin: 1px 0px;
  border-radius: 4px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: opacity 0.25s ease, background-color 0.25s ease, border-color 0.25s ease, transform 0.15s ease;
}

.highlight-word:hover {
  transform: translateY(-1px) scale(1.02);
  z-index: 10;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

/* Origin classes */
.word-Germanic {
  background-color: var(--bg-germanic);
  border-color: var(--border-germanic);
  color: var(--col-germanic);
  font-weight: 600;
}
.word-Germanic:hover {
  background-color: hsla(var(--col-germanic-h), 75%, 45%, 0.2);
  border-color: hsla(var(--col-germanic-h), 75%, 45%, 0.6);
}

.word-Romance {
  background-color: var(--bg-romance);
  border-color: var(--border-romance);
  color: var(--col-romance);
  font-weight: 600;
}
.word-Romance:hover {
  background-color: hsla(var(--col-romance-h), 70%, 45%, 0.2);
  border-color: hsla(var(--col-romance-h), 70%, 45%, 0.6);
}

.word-Latinate {
  background-color: var(--bg-romance);
  border-color: var(--border-romance);
  color: var(--col-romance);
  font-weight: 600;
}
.word-Latinate:hover {
  background-color: hsla(var(--col-romance-h), 70%, 45%, 0.2);
  border-color: hsla(var(--col-romance-h), 70%, 45%, 0.6);
}

.word-Hellenic {
  background-color: var(--bg-hellenic);
  border-color: var(--border-hellenic);
  color: var(--col-hellenic);
  font-weight: 600;
}
.word-Hellenic:hover {
  background-color: hsla(var(--col-hellenic-h), 65%, 45%, 0.2);
  border-color: hsla(var(--col-hellenic-h), 65%, 45%, 0.6);
}

.word-Celtic {
  background-color: var(--bg-celtic);
  border-color: var(--border-celtic);
  color: var(--col-celtic);
  font-weight: 600;
}
.word-Celtic:hover {
  background-color: hsla(var(--col-celtic-h), 60%, 40%, 0.2);
  border-color: hsla(var(--col-celtic-h), 60%, 40%, 0.6);
}

.word-Arabic {
  background-color: var(--bg-arabic);
  border-color: var(--border-arabic);
  color: var(--col-arabic);
  font-weight: 600;
}
.word-Arabic:hover {
  background-color: hsla(var(--col-arabic-h), 75%, 45%, 0.2);
  border-color: hsla(var(--col-arabic-h), 75%, 45%, 0.6);
}

.word-Sanskrit {
  background-color: var(--bg-sanskrit);
  border-color: var(--border-sanskrit);
  color: var(--col-sanskrit);
  font-weight: 600;
}
.word-Sanskrit:hover {
  background-color: hsla(var(--col-sanskrit-h), 70%, 50%, 0.2);
  border-color: hsla(var(--col-sanskrit-h), 70%, 50%, 0.6);
}

.word-Hebrew {
  background-color: var(--bg-hebrew);
  border-color: var(--border-hebrew);
  color: var(--col-hebrew);
  font-weight: 600;
}
.word-Hebrew:hover {
  background-color: hsla(var(--col-hebrew-h), 65%, 45%, 0.2);
  border-color: hsla(var(--col-hebrew-h), 65%, 45%, 0.6);
}

.word-Japanese {
  background-color: var(--bg-japanese);
  border-color: var(--border-japanese);
  color: var(--col-japanese);
  font-weight: 600;
}
.word-Japanese:hover {
  background-color: hsla(var(--col-japanese-h), 75%, 45%, 0.2);
  border-color: hsla(var(--col-japanese-h), 75%, 45%, 0.6);
}

.word-Chinese {
  background-color: var(--bg-chinese);
  border-color: var(--border-chinese);
  color: var(--col-chinese);
  font-weight: 600;
}
.word-Chinese:hover {
  background-color: hsla(var(--col-chinese-h), 60%, 40%, 0.2);
  border-color: hsla(var(--col-chinese-h), 60%, 40%, 0.6);
}

.word-Other {
  background-color: var(--bg-other);
  border-color: var(--border-other);
  color: var(--col-other);
  font-weight: 500;
}
.word-Other:hover {
  background-color: hsla(var(--col-other-h), 15%, 50%, 0.15);
  border-color: hsla(var(--col-other-h), 15%, 50%, 0.5);
}

/* Isolation state when hovering a specific category card */
.results-active-container.isolate-Germanic .highlight-word:not(.word-Germanic),
.results-active-container.isolate-Romance .highlight-word:not(.word-Romance):not(.word-Latinate),
.results-active-container.isolate-Latinate .highlight-word:not(.word-Latinate):not(.word-Romance),
.results-active-container.isolate-Hellenic .highlight-word:not(.word-Hellenic),
.results-active-container.isolate-Celtic .highlight-word:not(.word-Celtic),
.results-active-container.isolate-Arabic .highlight-word:not(.word-Arabic),
.results-active-container.isolate-Sanskrit .highlight-word:not(.word-Sanskrit),
.results-active-container.isolate-Hebrew .highlight-word:not(.word-Hebrew),
.results-active-container.isolate-Japanese .highlight-word:not(.word-Japanese),
.results-active-container.isolate-Chinese .highlight-word:not(.word-Chinese),
.results-active-container.isolate-Other .highlight-word:not(.word-Other) {
  opacity: 0.15;
  filter: grayscale(40%);
}

.results-active-container.isolate-Germanic .highlight-word.word-Germanic,
.results-active-container.isolate-Romance .highlight-word.word-Romance,
.results-active-container.isolate-Romance .highlight-word.word-Latinate,
.results-active-container.isolate-Latinate .highlight-word.word-Latinate,
.results-active-container.isolate-Latinate .highlight-word.word-Romance,
.results-active-container.isolate-Hellenic .highlight-word.word-Hellenic,
.results-active-container.isolate-Celtic .highlight-word.word-Celtic,
.results-active-container.isolate-Arabic .highlight-word.word-Arabic,
.results-active-container.isolate-Sanskrit .highlight-word.word-Sanskrit,
.results-active-container.isolate-Hebrew .highlight-word.word-Hebrew,
.results-active-container.isolate-Japanese .highlight-word.word-Japanese,
.results-active-container.isolate-Chinese .highlight-word.word-Chinese,
.results-active-container.isolate-Other .highlight-word.word-Other {
  opacity: 1;
  transform: scale(1.02);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Locked state (persistent filtering) - same visual as isolate but persists */
.results-active-container.locked-Germanic .highlight-word:not(.word-Germanic),
.results-active-container.locked-Romance .highlight-word:not(.word-Romance):not(.word-Latinate),
.results-active-container.locked-Latinate .highlight-word:not(.word-Latinate):not(.word-Romance),
.results-active-container.locked-Hellenic .highlight-word:not(.word-Hellenic),
.results-active-container.locked-Celtic .highlight-word:not(.word-Celtic),
.results-active-container.locked-Arabic .highlight-word:not(.word-Arabic),
.results-active-container.locked-Sanskrit .highlight-word:not(.word-Sanskrit),
.results-active-container.locked-Hebrew .highlight-word:not(.word-Hebrew),
.results-active-container.locked-Japanese .highlight-word:not(.word-Japanese),
.results-active-container.locked-Chinese .highlight-word:not(.word-Chinese),
.results-active-container.locked-Other .highlight-word:not(.word-Other) {
  opacity: 0.15;
  filter: grayscale(40%);
}

.results-active-container.locked-Germanic .highlight-word.word-Germanic,
.results-active-container.locked-Romance .highlight-word.word-Romance,
.results-active-container.locked-Romance .highlight-word.word-Latinate,
.results-active-container.locked-Latinate .highlight-word.word-Latinate,
.results-active-container.locked-Latinate .highlight-word.word-Romance,
.results-active-container.locked-Hellenic .highlight-word.word-Hellenic,
.results-active-container.locked-Celtic .highlight-word.word-Celtic,
.results-active-container.locked-Arabic .highlight-word.word-Arabic,
.results-active-container.locked-Sanskrit .highlight-word.word-Sanskrit,
.results-active-container.locked-Hebrew .highlight-word.word-Hebrew,
.results-active-container.locked-Japanese .highlight-word.word-Japanese,
.results-active-container.locked-Chinese .highlight-word.word-Chinese,
.results-active-container.locked-Other .highlight-word.word-Other {
  opacity: 1;
  transform: scale(1.02);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Visual indicator for locked stat card */
.stat-card.locked {
  border-color: rgba(26, 20, 16, 0.18);
  background: rgba(255, 255, 255, 0.7);
  box-shadow: inset 0 0 0 1px rgba(26, 20, 16, 0.1);
}

/* --- Floating Tooltips --- */
.app-tooltip {
  position: fixed;
  background: rgba(250, 248, 244, 0.98);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(26, 20, 16, 0.15);
  color: var(--text-main);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15), 0 0 20px rgba(200, 90, 30, 0.08);
  pointer-events: none;
  opacity: 0;
  transform: scale(0.96) translateY(5px);
  transition: opacity 0.18s cubic-bezier(0.4, 0, 0.2, 1), transform 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 9999;
  max-width: 340px;
  max-height: 380px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.app-tooltip.visible {
  opacity: 1;
  transform: scale(1) translateY(0);
}

/* Tooltip scrollbar styling */
.app-tooltip::-webkit-scrollbar {
  width: 6px;
}

.app-tooltip::-webkit-scrollbar-track {
  background: transparent;
}

.app-tooltip::-webkit-scrollbar-thumb {
  background: rgba(26, 20, 16, 0.15);
  border-radius: 3px;
}

.app-tooltip::-webkit-scrollbar-thumb:hover {
  background: rgba(26, 20, 16, 0.25);
}

.app-tooltip-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 2px;
}

.app-tooltip-origin {
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 4px;
}

.app-tooltip-origin.Germanic {
  background-color: var(--bg-germanic);
  border: 1px solid var(--border-germanic);
  color: var(--col-germanic);
}

.app-tooltip-origin.Romance {
  background-color: var(--bg-romance);
  border: 1px solid var(--border-romance);
  color: var(--col-romance);
}

.app-tooltip-origin.Latinate {
  background-color: var(--bg-romance);
  border: 1px solid var(--border-romance);
  color: var(--col-romance);
}

.app-tooltip-origin.Hellenic {
  background-color: var(--bg-hellenic);
  border: 1px solid var(--border-hellenic);
  color: var(--col-hellenic);
}

.app-tooltip-origin.Celtic {
  background-color: var(--bg-celtic);
  border: 1px solid var(--border-celtic);
  color: var(--col-celtic);
}

.app-tooltip-origin.Arabic {
  background-color: var(--bg-arabic);
  border: 1px solid var(--border-arabic);
  color: var(--col-arabic);
}

.app-tooltip-origin.Sanskrit {
  background-color: var(--bg-sanskrit);
  border: 1px solid var(--border-sanskrit);
  color: var(--col-sanskrit);
}

.app-tooltip-origin.Hebrew {
  background-color: var(--bg-hebrew);
  border: 1px solid var(--border-hebrew);
  color: var(--col-hebrew);
}

.app-tooltip-origin.Japanese {
  background-color: var(--bg-japanese);
  border: 1px solid var(--border-japanese);
  color: var(--col-japanese);
}

.app-tooltip-origin.Chinese {
  background-color: var(--bg-chinese);
  border: 1px solid var(--border-chinese);
  color: var(--col-chinese);
}

.app-tooltip-origin.Other {
  background-color: var(--bg-other);
  border: 1px solid var(--border-other);
  color: var(--col-other);
}

.app-tooltip-reason {
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

/* Tooltip Override Controls */
.app-tooltip-override {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(26, 20, 16, 0.08);
}

.override-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 6px;
  font-weight: 600;
}

.override-buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
}

.override-btn {
  background: rgba(26, 20, 16, 0.05);
  border: 1px solid rgba(26, 20, 16, 0.12);
  color: var(--text-main);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.override-btn:hover {
  background: rgba(26, 20, 16, 0.12);
  color: var(--text-main);
  border-color: rgba(26, 20, 16, 0.2);
}

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

/* Tooltip Definition Display */
.tooltip-definition {
  margin-top: 8px;
  padding: 8px;
  border-radius: 4px;
  background: rgba(26, 20, 16, 0.03);
  border: 1px solid rgba(26, 20, 16, 0.08);
  font-size: 0.8rem;
  line-height: 1.5;
}

.tooltip-definition-loading {
  margin-top: 8px;
  padding: 6px 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

.tooltip-definition-not-found {
  margin-top: 8px;
  padding: 6px 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

.tooltip-pronunciation {
  display: flex;
  gap: 12px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.phonetic {
  color: var(--col-latinate);
  font-style: italic;
  font-weight: 500;
}

.syllables {
  color: var(--col-hellenic);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-weight: 600;
}

.tooltip-part-of-speech {
  margin: 4px 0;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.tooltip-def-text {
  color: var(--text-main);
  margin-top: 4px;
  line-height: 1.6;
}


/* --- Footer --- */
.app-footer {
  text-align: center;
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid rgba(26, 20, 16, 0.05);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.content-section {
  background: rgba(255, 255, 255, 0.48);
  border: 1px solid rgba(26, 20, 16, 0.08);
  border-radius: var(--radius-lg);
  padding: 28px;
}

.info-section {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px;
}

.guides-section {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.section-intro {
  max-width: 760px;
}

.guide-card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.guide-card {
  min-height: 170px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  border: 1px solid rgba(26, 20, 16, 0.08);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.62);
  color: var(--text-main);
  text-decoration: none;
  transition: var(--transition-fast);
}

.guide-card:hover {
  border-color: rgba(200, 90, 30, 0.28);
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(26, 20, 16, 0.08);
}

.guide-card-kicker,
.guide-kicker {
  color: var(--col-germanic);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.guide-card strong {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  line-height: 1.15;
}

.guide-card span:last-child {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.section-copy h2,
.content-page h2,
.content-page h3 {
  font-family: var(--font-heading);
  color: var(--text-main);
}

.section-copy h2,
.content-page h2 {
  font-size: 1.6rem;
  margin-bottom: 10px;
}

.section-copy p,
.content-page p,
.content-page li {
  color: var(--text-muted);
  font-size: 0.98rem;
}

.feature-list,
.content-page ul {
  padding-left: 20px;
}

.feature-list li,
.content-page li {
  margin-bottom: 8px;
}

.page-shell {
  max-width: 980px;
}

.content-page {
  gap: 14px;
}

.content-page h3 {
  font-size: 1.2rem;
  margin-top: 12px;
}

.guide-article {
  text-align: left;
}

.guide-article h2 {
  font-size: 2rem;
}

.guide-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 18px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(26, 20, 16, 0.08);
}

.guide-table th,
.guide-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid rgba(26, 20, 16, 0.08);
  vertical-align: top;
}

.guide-table th {
  background: rgba(200, 90, 30, 0.08);
  color: var(--text-main);
  font-size: 0.9rem;
}

.guide-table td {
  color: var(--text-muted);
  font-size: 0.92rem;
}

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

.related-guides {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(26, 20, 16, 0.08);
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
}

.related-guides h3 {
  width: 100%;
  margin: 0;
}

.related-guides a {
  color: var(--col-romance);
  text-decoration: none;
  font-weight: 700;
}

.related-guides a:hover {
  color: var(--col-germanic);
}

.guide-hub-section {
  margin-top: 10px;
}

.guide-hub-section h3 {
  margin-bottom: 12px;
}

.guide-hub-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 760px) {
  .info-section {
    grid-template-columns: 1fr;
  }

  .guide-card-grid {
    grid-template-columns: 1fr;
  }

  .content-section,
  .content-page {
    padding: 22px;
  }
}

@media (min-width: 761px) and (max-width: 1100px) {
  .guide-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
