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

.lang-toggle {
  position: fixed;
  top: 16px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 100;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 4px 8px;
}

.lang-btn {
  background: none;
  border: none;
  color: #64748b;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

.lang-btn:hover { color: #1e293b; background: #e2e8f0; }

.lang-btn.active {
  color: #6366f1;
  background: #e0e7ff;
}

.lang-divider {
  color: #cbd5e1;
  font-size: 0.85rem;
  user-select: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #ffffff;
  color: #1e293b;
  min-height: 100vh;
  scrollbar-gutter: stable;
}

header {
  background: #f8fafc;
  padding: 24px 32px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

h1 {
  font-size: 4.81rem;
  font-weight: 700;
  color: #0f172a;
  margin-top: 15vh;
  margin-bottom: 72px;
  letter-spacing: -0.5px;
}

/* Section labels */
.section-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  margin-bottom: 10px;
  width: 100%;
  max-width: 688px;
}


.section-label strong {
  display: block;
  font-size: 0.95rem;
  color: #1e293b;
  margin-bottom: 2px;
}

.section-label p {
  font-size: 0.8rem;
  color: #94a3b8;
}

/* Lookup bar */
.lookup-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid #e2e8f0;
  width: 100%;
  max-width: 640px;
}

.lookup-bar .lookup-inputs {
  display: flex;
  gap: 12px;
  width: 100%;
}

.lookup-bar input {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #0f172a;
  font-size: 1rem;
  flex: 1;
  outline: none;
  transition: border-color 0.2s;
}

.lookup-bar input:focus { border-color: #6366f1; }
.lookup-bar input::placeholder { color: #94a3b8; font-size: 0.85rem; }

.year-result {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  font-size: 0.9rem;
  width: 100%;
}

.year-result.hidden { display: none; }
.year-result.loading { color: #94a3b8; font-style: italic; }
.year-result.error   { color: #ef4444; border-color: #fca5a5; }

.year-badge {
  background: #6366f1;
  color: white;
  font-weight: 700;
  font-size: 1rem;
  padding: 4px 12px;
  border-radius: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

.year-desc { color: #475569; line-height: 1.4; }

/* Folder tabs */
.browse-tabs {
  display: flex;
  gap: 4px;
  width: 100%;
  justify-content: center;
  align-items: flex-end;
}

.tab-btn {
  padding: 9px 24px;
  border-radius: 8px 8px 0 0;
  border: 1px solid #e2e8f0;
  border-bottom: none;
  background: #f1f5f9;
  color: #94a3b8;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  bottom: -1px;
  transition: color 0.15s, background 0.15s;
}

.tab-btn:not(.active):hover { background: #e2e8f0; color: #64748b; }

.tab-btn.active {
  background: #ffffff;
  color: #0f172a;
  border-color: #e2e8f0;
  border-bottom-color: #ffffff;
  z-index: 1;
}

.tab-panel {
  width: 100%;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 20px 24px;
  position: relative;
  z-index: 0;
}

.tab-panel.hidden { display: none; }

/* Country selector */
.country-selector-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 600px;
  margin: 14px auto 0;
}

.country-selector {
  position: relative;
  width: 100%;
}

.country-selector input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #0f172a;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.country-selector input:focus { border-color: #6366f1; }
.country-selector input::placeholder { color: #94a3b8; font-size: 0.85rem; }

.country-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 20;
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}

.country-dropdown.hidden { display: none; }

.country-option {
  padding: 9px 14px;
  font-size: 0.875rem;
  color: #334155;
  cursor: pointer;
  transition: background 0.1s;
}

.country-option:hover,
.country-option.highlighted { background: #f1f5f9; color: #0f172a; }

.country-option.disabled {
  color: #94a3b8;
  cursor: not-allowed;
}

/* Selected country tags */
.country-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-height: 28px;
}

.country-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.country-tag button {
  padding: 0;
  background: none;
  border: none;
  color: inherit;
  font-size: 0.75rem;
  opacity: 0.7;
  cursor: pointer;
  line-height: 1;
}

.country-tag button:hover { opacity: 1; }

.country-count {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-left: 4px;
}

/* Country header cells (no image, just name badge) */
.country-header {
  justify-content: center;
  padding: 20px 8px;
}

.country-header span {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: none;
  text-align: center;
}

/* Search bar */
.search-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  width: 100%;
}

.search-bar span { color: #94a3b8; font-size: 0.9rem; }

.search-bar input {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #0f172a;
  font-size: 1rem;
  width: 180px;
  outline: none;
  transition: border-color 0.2s;
}

.search-bar input:focus { border-color: #6366f1; }
.search-bar input::placeholder { color: #94a3b8; font-size: 0.85rem; }

/* Buttons */
button {
  padding: 10px 24px;
  border-radius: 8px;
  border: none;
  background: #6366f1;
  color: white;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

button:hover    { background: #4f46e5; }
button:disabled { background: #e2e8f0; color: #94a3b8; cursor: not-allowed; }

/* Status */
.status {
  text-align: center;
  padding: 24px 32px;
  color: #64748b;
  font-size: 1rem;
}

.status.loading::before {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid #e2e8f0;
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 10px;
  vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }
.status.error { color: #ef4444; }
.hidden { display: none; }

/* Results */
.results {
  padding: 24px 0 40px;
  overflow-x: auto;
}

/* History table */
.history-table {
  width: 100%;
  min-width: 900px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
}

/* Each row: year column + 7 continent columns */
.history-row {
  display: grid;
  grid-template-columns: 72px repeat(7, 1fr);
  border-bottom: 1px solid #e2e8f0;
}

.history-row:last-child { border-bottom: none; }
.history-row.row-even { background: #f8fafc; }

/* Header row with maps */
.header-row {
  background: #f1f5f9;
}

.year-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 4px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #6366f1;
  border-right: 1px solid #e2e8f0;
  text-align: center;
  line-height: 1.3;
}

/* Continent header cells (map + name) */
.cont-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  border-right: 1px solid #e2e8f0;
  text-align: center;
}

.cont-header:last-child { border-right: none; }

.cont-header img {
  width: 100%;
  max-width: 110px;
  height: 90px;
  object-fit: contain;
  display: block;
  margin-bottom: 8px;
}

.cont-header span {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 4px;
}

/* Continent name badge colors */
.cont-header[data-continent="Africa"]       span { background: #78350f; color: #fde68a; }
.cont-header[data-continent="Asia"]          span { background: #14532d; color: #86efac; }
.cont-header[data-continent="Europe"]        span { background: #1e3a8a; color: #93c5fd; }
.cont-header[data-continent="North America"] span { background: #4c1d95; color: #c4b5fd; }
.cont-header[data-continent="South America"] span { background: #7f1d1d; color: #fca5a5; }
.cont-header[data-continent="Oceania"]       span { background: #164e63; color: #67e8f9; }
.cont-header[data-continent="Antarctica"]    span { background: #475569; color: #f1f5f9; }

/* Event cells */
.event-cell {
  padding: 10px 10px;
  border-right: 1px solid #f1f5f9;
  vertical-align: top;
}

.event-cell:last-child { border-right: none; }

/* Left border accent per continent */
.event-cell[data-continent="Africa"]       { border-left: 2px solid #d97706; }
.event-cell[data-continent="Asia"]          { border-left: 2px solid #16a34a; }
.event-cell[data-continent="Europe"]        { border-left: 2px solid #2563eb; }
.event-cell[data-continent="North America"] { border-left: 2px solid #7c3aed; }
.event-cell[data-continent="South America"] { border-left: 2px solid #dc2626; }
.event-cell[data-continent="Oceania"]       { border-left: 2px solid #0891b2; }
.event-cell[data-continent="Antarctica"]    { border-left: 2px solid #94a3b8; }

/* Event items */
.event-item {
  font-size: 0.78rem;
  color: #334155;
  line-height: 1.4;
  padding: 2px 0 6px;
}

.event-item + .event-item {
  border-top: 1px solid #e2e8f0;
  padding-top: 6px;
  margin-top: 2px;
}

.event-text { display: block; }

.details-btn {
  display: none;
  margin-top: 5px;
  padding: 3px 10px;
  font-size: 0.68rem;
  font-weight: 600;
  background: #6366f1;
  color: white;
  border-radius: 4px;
  border: none;
  cursor: pointer;
}

.event-item:hover .details-btn { display: inline-block; }
.details-btn:hover              { background: #4f46e5; }
.details-btn:disabled           { background: #e2e8f0; color: #94a3b8; cursor: not-allowed; }

/* Empty state */
.empty-row {
  padding: 40px;
  text-align: center;
  color: #94a3b8;
  font-size: 0.875rem;
  font-style: italic;
}

/* Details panel (slides up from bottom) */
.details-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 40;
}

.details-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  border-radius: 16px 16px 0 0;
  z-index: 50;
  max-height: 55vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.25s ease;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.08);
}

.details-panel.hidden { display: none; }

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.details-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.details-title {
  font-size: 1rem;
  font-weight: 700;
  color: #0f172a;
  flex: 1;
  margin-right: 16px;
}

.details-close {
  padding: 4px 10px;
  font-size: 0.9rem;
  background: #f1f5f9;
  color: #64748b;
  border-radius: 6px;
  border: none;
}

.details-close:hover { background: #e2e8f0; color: #0f172a; }

.details-body {
  padding: 20px 24px;
  overflow-y: auto;
}

.details-loading {
  color: #94a3b8;
  font-style: italic;
  text-align: center;
  padding: 20px 0;
}

.details-error { color: #ef4444; }

.detail-meta {
  display: flex;
  gap: 24px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.detail-meta span {
  font-size: 0.875rem;
  color: #64748b;
}

.detail-meta strong { color: #334155; }

.detail-summary {
  font-size: 0.95rem;
  color: #334155;
  line-height: 1.6;
  margin-bottom: 16px;
}

.detail-section {
  margin-bottom: 14px;
}

.detail-section h4 {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #6366f1;
  margin-bottom: 8px;
}

.detail-section ul {
  list-style: none;
  padding: 0;
  min-height: unset;
}

.detail-section ul li {
  font-size: 0.875rem;
  color: #334155;
  padding: 4px 0 4px 14px;
  border-bottom: none;
  position: relative;
  display: block;
  opacity: 1;
}

.detail-section ul li::before {
  content: '›';
  position: absolute;
  left: 0;
  color: #6366f1;
}

.detail-section ul li:hover .details-btn { display: none; }
