/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scrollbar-gutter: stable;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  color: #333;
  max-width: 1056px;
  margin: 0 auto;
  padding: 20px;
}

/* Header and navigation */
header {
  border-bottom: 1px solid #e0e0e0;
  margin-bottom: 40px;
  padding-bottom: 16px;
}

nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

nav h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

nav h1 a {
  color: #000;
  text-decoration: none;
  font-size: inherit;
}

nav ul {
  list-style: none;
  display: flex;
  gap: 24px;
}

nav a {
  color: #666;
  text-decoration: none;
  font-size: 1.25rem;
}

nav a:hover {
  color: #000;
}

/* Landing page */
.landing {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 70vh;
  text-align: center;
}

.landing-content {
  max-width: 600px;
}

.landing-btn {
  display: inline-block;
  padding: 16px 40px;
  font-size: 1.2rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-decoration: none;
  border: 2px solid #000;
  background: transparent;
  color: #000;
  transition: all 0.15s ease;
}

.landing-btn:hover {
  background: #000;
  color: #fff;
}

.landing-link {
  display: block;
  margin-top: 32px;
  font-size: 0.9rem;
  color: #666;
  text-decoration: none;
  letter-spacing: 0.01em;
}

.landing-link:hover {
  color: #000;
}

/* View switcher */
.view-switcher {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
}

.view-switcher a {
  padding: 8px 16px;
  border: 1px solid #ddd;
  border-radius: 4px;
  text-decoration: none;
  color: #666;
  font-size: 0.9rem;
  transition: all 0.15s;
}

.view-switcher a:hover {
  border-color: #bbb;
  color: #333;
}

.view-switcher a.active {
  background: #333;
  border-color: #333;
  color: #fff;
}

/* Home page (lives list) */
.home {
}

.home h1 {
  font-size: 2.2rem;
  font-weight: 600;
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

.intro {
  font-size: 1.1rem;
  margin: 0 0 24px;
  color: #555;
  line-height: 1.5;
  min-height: 54px;
}

/* Filter controls */
.filters {
  margin-bottom: 32px;
  padding: 0;
  background: transparent;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
}

.filters-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.filters-header:hover {
  background: #f9f9f9;
}

.filters-title {
  font-weight: 600;
  font-size: 1rem;
  color: #333;
}

.filters-summary {
  margin-left: 12px;
  font-size: 0.9rem;
  color: #666;
}

.filters-header .reset-btn {
  margin-left: auto;
  margin-right: 12px;
}

.filters-expand-icon {
  font-size: 0.75rem;
  color: #888;
  transition: transform 0.2s;
}

.filters-content {
  padding: 0 16px 16px;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.2s ease;
  max-height: 500px;
  opacity: 1;
}

.filters-content.collapsed {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
}

.filters-content .filter-row:first-child {
  margin-top: 14px;
}

.filters h3 {
  display: none;
}

/* Order bar (above filters) */
.order-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.order-bar label {
  font-size: 0.9rem;
  color: #666;
  margin-right: 4px;
}

/* Shared button style for order/color controls */
.color-btn {
  padding: 5px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  color: #555;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.color-btn:hover {
  border-color: #bbb;
  background: #f5f5f5;
}

.color-btn.selected {
  background: #333;
  border-color: #333;
  color: #fff;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid #eee;
}

.filter-row:last-of-type {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.filter-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: #555;
}

.filter-row input[type="text"] {
  padding: 6px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: white;
  font-size: 0.85rem;
  transition: border-color 0.15s;
  height: 32px;
  box-sizing: border-box;
}

.filter-row input[type="text"]:focus {
  outline: none;
  border-color: #999;
}

.filter-row select {
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: white;
  font-size: 0.85rem;
  cursor: pointer;
}

.filter-row select:hover {
  border-color: #999;
}

/* Tag filter groups */
.filter-tags {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 0.85rem;
  color: #888;
  margin-right: 6px;
  font-weight: 500;
  min-width: 70px;
}

.tag {
  padding: 6px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  color: #555;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  line-height: 1;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tag:hover {
  border-color: #bbb;
  background: #f5f5f5;
}

.tag.selected {
  background: #333;
  border-color: #333;
  color: #fff;
}

.filter-stats {
  margin-top: 16px;
  font-size: 0.9rem;
  color: #888;
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Year range slider */
.year-slider-container {
  flex: 1;
  max-width: 400px;
  padding: 0 8px;
}

.year-slider-track {
  position: relative;
  height: 32px;
  display: flex;
  align-items: center;
  cursor: pointer;
}

/* Grey background track */
.year-slider-track::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 4px;
  background: #ddd;
  border-radius: 2px;
  top: 50%;
  transform: translateY(-50%);
}

/* Black range between handles */
.year-slider-range {
  position: absolute;
  height: 2px;
  background: #333;
  border-radius: 1px;
  pointer-events: none;
  top: 50%;
  transform: translateY(-50%);
}

.year-slider {
  position: absolute;
  width: 100%;
  height: 32px;
  background: transparent;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}

.year-slider::-webkit-slider-runnable-track {
  height: 4px;
  background: transparent;
}

.year-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: #333;
  border-radius: 50%;
  cursor: pointer;
  pointer-events: auto;
  margin-top: -7px;
}

.year-slider::-moz-range-track {
  height: 4px;
  background: transparent;
}

.year-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: #333;
  border-radius: 50%;
  cursor: pointer;
  pointer-events: auto;
  border: none;
}

.year-slider-labels,
.age-slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: #666;
  margin-top: 4px;
}

/* Age range slider (reuses year slider styles) */
.age-slider-container {
  flex: 1;
  max-width: 400px;
  padding: 0 8px;
}

.age-slider-track {
  position: relative;
  height: 32px;
  display: flex;
  align-items: center;
  cursor: pointer;
}

.age-slider-track::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 4px;
  background: #ddd;
  border-radius: 2px;
  top: 50%;
  transform: translateY(-50%);
}

.age-slider-range {
  position: absolute;
  height: 2px;
  background: #333;
  border-radius: 1px;
  pointer-events: none;
  top: 50%;
  transform: translateY(-50%);
}

.age-slider {
  position: absolute;
  width: 100%;
  height: 32px;
  background: transparent;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}

.age-slider::-webkit-slider-runnable-track {
  height: 4px;
  background: transparent;
}

.age-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: #333;
  border-radius: 50%;
  cursor: pointer;
  pointer-events: auto;
  margin-top: -7px;
}

.age-slider::-moz-range-track {
  height: 4px;
  background: transparent;
}

.age-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: #333;
  border-radius: 50%;
  cursor: pointer;
  pointer-events: auto;
  border: none;
}

/* Slider label alignment - position sliders consistently */
.filter-label.slider-label {
  margin-left: auto;
  width: 90px;
  text-align: right;
}

/* Disabled state for age slider when "Living" is selected */
.age-slider-container.disabled {
  opacity: 0.4;
}

.age-slider-container.disabled .age-slider::-webkit-slider-thumb {
  pointer-events: none;
}

.age-slider-container.disabled .age-slider::-moz-range-thumb {
  pointer-events: none;
}

.filter-label.age-label.disabled {
  opacity: 0.4;
}

.reset-btn {
  padding: 4px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  color: #888;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.reset-btn:hover {
  border-color: #999;
  color: #555;
}

.lives-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  min-height: 400px;
}

.lives-list h2 {
  margin-bottom: 30px;
  font-size: 1.5rem;
  grid-column: 1 / -1;
}

/* Life preview cards */
.life-preview {
  display: flex;
  flex-direction: column;
  border: 1px solid #e0e0e0;
  padding: 20px 22px;
  border-radius: 6px;
  background: #fff;
  transition: all 0.2s ease;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  min-height: 180px;
}

.life-preview:hover {
  border-color: #bbb;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.life-preview h3 {
  margin-bottom: 10px;
  font-size: 1.15rem;
  font-weight: 600;
  color: #000;
  line-height: 1.3;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 0.8rem;
  color: #666;
}

.meta span {
  padding: 3px 8px;
  background: #f5f5f5;
  border-radius: 3px;
  white-space: nowrap;
}

.meta .years {
  background: #e8f4e8;
  color: #2d5a2d;
  font-weight: 500;
}

.meta .country,
.meta .region {
  background: #e8f0f8;
  color: #2d4a5a;
}

.meta .lifestyle {
  background: #f8f0e8;
  color: #5a4a2d;
}

.excerpt {
  color: #555;
  margin-top: auto;
  font-size: 0.9rem;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Responsive adjustments for lives list */
@media (max-width: 700px) {
  .lives-list {
    grid-template-columns: 1fr;
  }

  .life-preview {
    min-height: auto;
  }

  .filters {
    padding: 16px;
  }

  .filter-row {
    gap: 8px 12px;
  }
}

/* Individual life page */
.life {
  max-width: 680px;
  margin: 0 auto;
}

.life-header {
  margin-bottom: 40px;
  padding-bottom: 20px;
  border-bottom: 1px solid #e0e0e0;
}

.life-header-with-map {
  max-width: none;
  width: calc(100vw - 40px);
  max-width: 1100px;
  margin-left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 48px;
  align-items: flex-start;
}

.life-header-with-map .life-info {
  flex: 1;
  min-width: 0;
}

.life-header-with-map .life-map {
  flex: 0 0 550px;
  margin: 0;
}

.life-header-with-map #map {
  height: 320px;
  cursor: pointer;
}

.life-header h1 {
  margin-bottom: 16px;
  font-size: 2.1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.life-meta {
  color: #666;
  font-size: 1.1rem;
}

.life-meta p {
  margin: 4px 0;
}

.life-meta a {
  color: #666;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.life-meta a:hover {
  color: #000;
}

.life-narrative {
  max-width: 680px;
  font-size: 1.05rem;
  line-height: 1.85;
  margin-bottom: 40px;
  color: #222;
}

.life-narrative p {
  margin-bottom: 1.3rem;
}

.life-events {
  margin: 40px 0;
  padding: 20px;
  background: #f5f5f5;
  border-radius: 5px;
}

.life-events h2 {
  margin-bottom: 15px;
  font-size: 1.3rem;
}

.life-events ul {
  list-style-position: inside;
  padding-left: 10px;
}

.life-events li {
  margin: 8px 0;
}

.life-navigation {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid #e0e0e0;
}

.life-navigation a {
  color: #666;
  text-decoration: none;
  font-size: 0.9rem;
}

.life-navigation a:hover {
  color: #000;
}

/* Life navigation buttons */
.life-nav-buttons {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.nav-btn {
  display: inline-block;
  padding: 10px 20px;
  background: transparent;
  color: #000;
  text-decoration: none;
  border: 1px solid #000;
  font-size: 0.9rem;
  transition: all 0.15s ease;
}

.nav-btn:hover {
  background: #000;
  color: #fff;
}

.nav-btn.disabled {
  background: transparent;
  border-color: #ccc;
  color: #999;
  cursor: not-allowed;
}

.nav-btn.disabled:hover {
  background: transparent;
  color: #999;
}

/* Life map */
.life-map {
  margin: 0;
  padding: 0;
  background: transparent;
}

#map {
  height: 160px;
  width: 100%;
}

/* Responsive: stack on mobile */
@media (max-width: 600px) {
  .life-header-with-map {
    flex-direction: column;
    gap: 20px;
  }

  .life-header-with-map .life-map {
    flex: none;
    width: 100%;
  }

  .life-header-with-map #map {
    height: 200px;
  }
}

/* About page */
.about {
  max-width: 680px;
  margin: 0 auto;
}

.about h1 {
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 24px;
}

.about h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-top: 48px;
  margin-bottom: 20px;
  letter-spacing: -0.01em;
}

.about p {
  font-size: 1.05rem;
  line-height: 1.8;
  color: #333;
  margin-bottom: 1.4rem;
}

.about a {
  color: #000;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

.about a:hover {
  text-decoration-thickness: 2px;
}

.about-note {
  background: #f8f8f8;
  border-radius: 6px;
  padding: 20px 24px;
  margin: 32px 0;
  font-size: 0.95rem;
  line-height: 1.7;
  color: #555;
}

.about-note strong {
  color: #333;
}

.about-buttons {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 56px;
  padding-top: 40px;
  border-top: 1px solid #e0e0e0;
  flex-wrap: wrap;
}

.about-buttons .button {
  display: inline-block;
  padding: 14px 32px;
  background: transparent;
  color: #000;
  text-decoration: none;
  border: 2px solid #000;
  font-size: 1rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

.about-buttons .button:hover {
  background: #000;
  color: #fff;
}

.about-buttons .button.primary {
  background: #000;
  color: #fff;
}

.about-buttons .button.primary:hover {
  background: #333;
}

/* Blog */
.blog {
  max-width: 680px;
  margin: 0 auto;
}

.blog h1 {
  font-size: 2.2rem;
  font-weight: 600;
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

.blog-posts {
  margin-top: 40px;
}

.blog-preview {
  padding: 32px 0;
  border-bottom: 1px solid #e0e0e0;
}

.blog-preview:first-child {
  padding-top: 0;
}

.blog-preview:last-child {
  border-bottom: none;
}

.blog-preview h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.blog-preview h2 a {
  color: #000;
  text-decoration: none;
}

.blog-preview h2 a:hover {
  text-decoration: underline;
}

.blog-date {
  font-size: 0.9rem;
  color: #888;
  margin-bottom: 12px;
}

.blog-excerpt {
  font-size: 1rem;
  line-height: 1.7;
  color: #444;
  margin-bottom: 12px;
}

.read-more {
  font-size: 0.9rem;
  color: #666;
  text-decoration: none;
}

.read-more:hover {
  color: #000;
  text-decoration: underline;
}

/* Blog post (individual) */
.post {
  max-width: 680px;
  margin: 0 auto;
}

.post h1 {
  font-size: 2.2rem;
  font-weight: 600;
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

.post-date {
  font-size: 1rem;
  color: #888;
  margin-bottom: 32px;
}

.post-content {
  font-size: 1.05rem;
  line-height: 1.85;
  color: #222;
}

.post-content p {
  margin-bottom: 1.4rem;
}

.post-content ol, .post-content ul {
  padding-left: 2em;
  margin-top: -0.5rem;
  margin-bottom: 1.4rem;
}

.post-content h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-top: 48px;
  margin-bottom: 20px;
  letter-spacing: -0.01em;
}

.post-content h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-top: 32px;
  margin-bottom: 16px;
}

.post-content a {
  color: #000;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.post-content a:hover {
  text-decoration-thickness: 2px;
}

.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 0.9rem;
  border: 1px solid #ddd;
}

.post-content th,
.post-content td {
  padding: 12px 14px;
  text-align: left;
  border: 1px solid #ddd;
}

.post-content thead th {
  font-weight: 600;
  background: #f5f5f5;
  color: #333;
  border-bottom: 2px solid #ccc;
  text-align: center;
}

.post-content tbody tr:nth-child(even) {
  background: #fafafa;
}

.post-content tbody tr:hover {
  background: #f0f0f0;
}

.post-content td:first-child,
.post-content th:first-child {
  white-space: nowrap;
  font-weight: 500;
}

.post-content td:nth-child(2),
.post-content th:nth-child(2) {
  white-space: nowrap;
}

.post-content td:nth-child(3),
.post-content td:nth-child(4) {
  white-space: nowrap;
}

.post-content td:not(:first-child) {
  text-align: right;
}

.post-content th[colspan] {
  text-align: center;
}

.post-content th[rowspan] {
  vertical-align: middle;
}

.post-content tfoot td {
  background: #f5f5f5;
  border-top: 2px solid #ccc;
}

.post-content tfoot td[colspan] {
  text-align: right;
}

.post-content th .unit {
  font-weight: 400;
  font-size: 0.85em;
  color: #666;
}

.post-content th.sortable {
  cursor: pointer;
  user-select: none;
}

.post-content th.sortable:hover {
  background: #e8e8e8;
}

#sensitivity-table th:nth-child(n+3):nth-child(-n+5),
#sensitivity-table td:nth-child(n+3):nth-child(-n+5) {
  width: 20%;
}

.post-content th.sortable::after {
  content: ' ↓';
  font-size: 0.8em;
  color: #999;
}

.post-content th.sort-desc::after {
  content: ' ↓';
  color: #333;
}

.post-navigation {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid #e0e0e0;
}

.post-navigation a {
  color: #666;
  text-decoration: none;
  font-size: 0.9rem;
}

.post-navigation a:hover {
  color: #000;
}

/* Footer */
footer {
  margin-top: 60px;
  padding-top: 16px;
  border-top: 1px solid #e0e0e0;
  text-align: center;
  color: #999;
  font-size: 0.8rem;
}
