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

body.home-page {
  font-family: Georgia, 'Times New Roman', serif;
  background: #f5f1eb;
  color: #2c2c2c;
  min-height: 100vh;
  margin: 0;
  padding: 2rem 1rem;
}

body.home-page #title-block-header {
  text-align: center;
  padding: 2.5rem 2rem 2rem;
  background: #2c3e50;
  color: #f5f1eb;
  border-radius: 8px;
  margin-bottom: 2rem;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
}

body.home-page h1.title {
  font-size: 2.4rem;
  letter-spacing: 0.02em;
  margin-bottom: 0.4rem;
}

body.home-page p.date {
  font-size: 0.9rem;
  opacity: 0.75;
  font-style: italic;
  margin: 0;
}

body.home-page main,
body.home-page > *:not(header) {
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
}

body.home-page h2 {
  font-size: 1.5rem;
  color: #2c3e50;
  border-bottom: 2px solid #c0a87a;
  padding-bottom: 0.3rem;
}

body.home-page h3 {
  font-size: 1.1rem;
  color: #5a4a30;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

body.home-page p {
  line-height: 1.7;
  margin-bottom: 0.8rem;
}

body.home-page ul {
  list-style: none;
  padding: 0;
}

body.home-page ul li {
  border-left: 3px solid #c0a87a;
  padding: 0.45rem 0.8rem;
  margin-bottom: 0.4rem;
  background: #fffdf8;
  border-radius: 0 4px 4px 0;
  transition: background 0.15s;
}

body.home-page ul li:hover {
  background: #f0e8d8;
}

body.home-page a {
  color: #2c5f8a;
  text-decoration: none;
}

body.home-page a:hover {
  text-decoration: underline;
}

body.home-page ul li a {
  display: block;
}

body.home-page code { white-space: pre-wrap; }
body.home-page span.smallcaps { font-variant: small-caps; }
body.home-page span.underline { text-decoration: underline; }
body.home-page div.column { display: inline-block; vertical-align: top; width: 50%; }
body.home-page div.hanging-indent { margin-left: 1.5em; text-indent: -1.5em; }
body.home-page ul.task-list { list-style: none; }

body.carbon-page {
  --bg-0: #fffaf1;
  --bg-1: #ffe8d2;
  --surface: rgba(255, 255, 255, 0.7);
  --text: #1b2a2f;
  --muted: #55646a;
  --grid: #c8d2d6;
  --line: #0f8a7b;
  --line-fallback: #f2994a;
  --axis: #26454f;
  --danger: #c0392b;
  --shadow: 0 20px 60px rgba(27, 42, 47, 0.16);
  margin: 0;
  min-height: 100vh;
  font-family: 'Space Grotesk', sans-serif;
  color: var(--text);
  background:
    radial-gradient(1300px 700px at 5% -10%, #fff3c9 0%, transparent 70%),
    radial-gradient(1000px 700px at 100% 0%, #ffd7b5 0%, transparent 65%),
    linear-gradient(135deg, var(--bg-0), var(--bg-1));
  display: grid;
  place-items: center;
  padding: clamp(1rem, 2.5vw, 2rem);
}

body.carbon-page main {
  width: min(1100px, 100%);
  background: var(--surface);
  border: 1px solid rgba(38, 69, 79, 0.12);
  border-radius: 24px;
  backdrop-filter: blur(6px);
  box-shadow: var(--shadow);
  padding: clamp(1rem, 3vw, 2rem);
  opacity: 0;
  transform: translateY(12px);
  animation: rise-in 700ms ease-out forwards;
}

body.carbon-page h1 {
  margin: 0;
  font-size: clamp(1.4rem, 3vw, 2.1rem);
  letter-spacing: 0.02em;
}

body.carbon-page p {
  margin: 0;
}

body.carbon-page .subtitle {
  margin-top: 0.35rem;
  color: var(--muted);
}

body.carbon-page .legend {
  margin-top: 0.8rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.95rem;
  opacity: 0;
  animation: rise-in 700ms ease-out 180ms forwards;
}

body.carbon-page .legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

body.carbon-page .swatch {
  width: 14px;
  height: 14px;
  border-radius: 999px;
}

body.carbon-page .swatch.actual {
  background: var(--line);
}

body.carbon-page .swatch.forecast {
  background: var(--line-fallback);
}

body.carbon-page .chart-wrap {
  margin-top: 1.2rem;
  border: 1px solid rgba(38, 69, 79, 0.12);
  border-radius: 16px;
  padding: 0.7rem;
  background: rgba(255, 255, 255, 0.65);
  opacity: 0;
  animation: rise-in 700ms ease-out 320ms forwards;
}

body.carbon-page #chart {
  width: 100%;
  min-height: 420px;
}

body.carbon-page .status {
  margin-top: 0.8rem;
  color: var(--muted);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.9rem;
}

body.carbon-page .error {
  color: var(--danger);
}

body.carbon-page .tooltip {
  position: fixed;
  z-index: 10;
  pointer-events: none;
  background: #18313a;
  color: #f7fbfc;
  border-radius: 10px;
  padding: 0.5rem 0.7rem;
  font-size: 0.8rem;
  font-family: 'IBM Plex Mono', monospace;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease;
}

body.carbon-page .tooltip.show {
  opacity: 1;
  transform: translateY(0);
}

@keyframes rise-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

body.food-page {
  margin: 0;
  font-family: 'Segoe UI', Arial, sans-serif;
  background: #1a1a2e;
  color: #eee;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body.food-page header {
  padding: 12px 20px;
  background: #16213e;
  border-bottom: 2px solid #e63946;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

body.food-page header h1 {
  margin: 0;
  font-size: 1.4rem;
  color: #fff;
  letter-spacing: 0.5px;
}

body.food-page #legend {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-shrink: 0;
}

body.food-page .legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  color: #ccc;
}

body.food-page .legend-dot {
  width: 11px;
  height: 11px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid rgba(255, 255, 255, 0.6);
  flex-shrink: 0;
}

body.food-page header span {
  font-size: 0.85rem;
  color: #aaa;
}

body.food-page #status {
  font-size: 0.82rem;
  color: #f4a261;
  white-space: nowrap;
}

body.food-page #loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(26, 26, 46, 0.72);
  z-index: 1000;
  pointer-events: none;
}

body.food-page .spinner {
  width: 44px;
  height: 44px;
  border: 5px solid rgba(255, 255, 255, 0.15);
  border-top-color: #e63946;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

body.food-page #map {
  flex: 1;
}

body.food-page .leaflet-popup-content-wrapper {
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

body.food-page .popup-content {
  min-width: 180px;
}

body.food-page .popup-content h3 {
  font-size: 1rem;
  margin-bottom: 4px;
  color: #e63946;
}

body.food-page .popup-content .cuisine {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #555;
  margin-bottom: 5px;
}

body.food-page .popup-content .meta {
  font-size: 0.82rem;
  color: #444;
  margin-bottom: 3px;
}

body.food-page .popup-content .meta.distance {
  font-weight: 600;
  color: #e63946;
  margin-bottom: 5px;
}

body.food-page .popup-content .meta a {
  color: #e63946;
  text-decoration: none;
}

body.food-page .popup-content .meta a:hover {
  text-decoration: underline;
}

body.food-page #locate-btn {
  margin-left: auto;
  padding: 5px 12px;
  background: #e63946;
  color: #fff;
  border: none;
  border-radius: 5px;
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

body.food-page #locate-btn:hover {
  background: #c1121f;
}

body.food-page #locate-btn:disabled {
  background: #555;
  cursor: default;
}

body.food-page #tod {
  display: flex;
  gap: 4px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 6px;
  padding: 3px;
  flex-shrink: 0;
}

body.food-page #tod label {
  padding: 3px 9px;
  border-radius: 4px;
  font-size: 0.78rem;
  color: #aaa;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, color 0.15s;
}

body.food-page #tod input {
  display: none;
}

body.food-page #tod input:checked + label {
  background: #e63946;
  color: #fff;
}

body.food-page .popup-eaten-btn {
  margin-top: 8px;
  width: 100%;
  padding: 5px 0;
  background: #e63946;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
}

body.food-page .popup-eaten-btn:hover {
  background: #c1121f;
}

body.food-page .popup-eaten-btn.visited,
body.food-page .popup-eaten-btn.visited:hover {
  background: #2dc653;
  cursor: default;
}

body.map-zones-page {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body.map-zones-page #map {
  flex: 1;
  min-height: calc(100vh - 3.5rem);
}

body.map-zones-page img.huechange {
  filter: hue-rotate(240deg);
}

body.map-zones-page .marker {
  background-color: red;
  width: 4px;
  height: 4px;
  display: block;
  position: relative;
  border-radius: 6px;
  border: 2px solid #fff;
}

body.plaqueattack-page {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body.plaqueattack-page #map {
  flex: 1;
  min-height: calc(100vh - 3.5rem);
  width: 100%;
}

body.wikipedia-tts-page {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem;
  font-family: system-ui, sans-serif;
  background: #f5f5f5;
  color: #222;
}

body.wikipedia-tts-page h1 {
  margin: 0 0 0.25rem;
  font-size: 1.8rem;
  color: #333;
}

body.wikipedia-tts-page .subtitle {
  color: #666;
  margin: 0 0 2rem;
  font-size: 0.95rem;
}

body.wikipedia-tts-page .card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  padding: 1.5rem;
  width: 100%;
  max-width: 720px;
}

body.wikipedia-tts-page .search-row {
  display: flex;
  gap: 0.5rem;
  position: relative;
}

body.wikipedia-tts-page #article-input {
  flex: 1;
  padding: 0.65rem 0.9rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

body.wikipedia-tts-page #article-input:focus {
  border-color: #2a7ae2;
}

body.wikipedia-tts-page #fetch-btn {
  padding: 0.65rem 1.2rem;
  background: #2a7ae2;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}

body.wikipedia-tts-page #fetch-btn:hover {
  background: #1a5cbf;
}

body.wikipedia-tts-page #fetch-btn:disabled {
  background: #90b4e8;
  cursor: default;
}

body.wikipedia-tts-page #suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 5rem;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  z-index: 10;
  display: none;
  margin: 0;
  padding: 0;
}

body.wikipedia-tts-page #suggestions li {
  list-style: none;
  padding: 0.6rem 0.9rem;
  cursor: pointer;
  font-size: 0.95rem;
}

body.wikipedia-tts-page #suggestions li:hover {
  background: #f0f4ff;
}

body.wikipedia-tts-page #suggestions li + li {
  border-top: 1px solid #f0f0f0;
}

body.wikipedia-tts-page .section-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.9rem;
  font-size: 0.9rem;
  color: #555;
}

body.wikipedia-tts-page .controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.2rem;
  align-items: center;
}

body.wikipedia-tts-page .controls button {
  padding: 0.5rem 1rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: #fafafa;
  cursor: pointer;
  font-size: 0.95rem;
  transition: background 0.15s;
}

body.wikipedia-tts-page .controls button:hover {
  background: #e8eef8;
  border-color: #99b4d8;
}

body.wikipedia-tts-page .controls button:disabled {
  opacity: 0.4;
  cursor: default;
}

body.wikipedia-tts-page .controls button.primary {
  background: #2a7ae2;
  color: #fff;
  border-color: #2a7ae2;
}

body.wikipedia-tts-page .controls button.primary:hover {
  background: #1a5cbf;
}

body.wikipedia-tts-page .controls button.danger {
  background: #e24444;
  color: #fff;
  border-color: #c43030;
}

body.wikipedia-tts-page .controls button.danger:hover {
  background: #c43030;
}

body.wikipedia-tts-page .rate-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: #555;
  margin-left: auto;
}

body.wikipedia-tts-page #rate-slider {
  width: 90px;
  accent-color: #2a7ae2;
}

body.wikipedia-tts-page .voice-row {
  margin-top: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: #555;
}

body.wikipedia-tts-page #voice-select {
  flex: 1;
  padding: 0.4rem 0.6rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.9rem;
}

body.wikipedia-tts-page #status {
  margin-top: 1rem;
  margin-bottom: 0;
  font-size: 0.9rem;
  color: #777;
  min-height: 1.2em;
}

body.wikipedia-tts-page #status.error {
  color: #c43030;
}

body.wikipedia-tts-page #status.ok {
  color: #287a2a;
}

body.wikipedia-tts-page #article-content {
  margin-top: 1.2rem;
  max-height: 320px;
  overflow-y: auto;
  font-size: 0.92rem;
  line-height: 1.65;
  color: #333;
  background: #f9f9f9;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 1rem;
  display: none;
}

body.wikipedia-tts-page .article-section {
  margin-bottom: 1rem;
}

body.wikipedia-tts-page .section-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}

body.wikipedia-tts-page .section-label input[type='radio'] {
  flex-shrink: 0;
  accent-color: #2a7ae2;
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}

body.wikipedia-tts-page #article-content h2 {
  margin: 0;
  font-size: 1.15rem;
  color: #222;
}

body.wikipedia-tts-page #article-content h3 {
  margin: 0;
  font-size: 1.05rem;
  color: #333;
}

body.wikipedia-tts-page #article-content h4,
body.wikipedia-tts-page #article-content h5,
body.wikipedia-tts-page #article-content h6 {
  margin: 0;
  font-size: 0.98rem;
  color: #444;
}

body.wikipedia-tts-page #article-content p {
  margin-top: 0.4rem;
  margin-bottom: 0;
  white-space: pre-wrap;
}

body.wikipedia-tts-page .intro-label span {
  font-size: 0.85rem;
  font-style: italic;
  color: #888;
}

body.wikipedia-tts-page #article-content.highlight span.speaking {
  background: #ffe08a;
  border-radius: 3px;
}

body.wikipedia-tts-page .progress-bar-wrap {
  margin-top: 0.8rem;
  height: 6px;
  background: #e0e0e0;
  border-radius: 3px;
  display: none;
}

body.wikipedia-tts-page #progress-bar {
  height: 100%;
  width: 0%;
  background: #2a7ae2;
  border-radius: 3px;
  transition: width 0.3s;
}

@media (max-width: 640px) {
  body.carbon-page #chart {
    min-height: 340px;
  }

  body.food-page header {
    padding: 8px 12px;
    gap: 6px;
    flex-wrap: wrap;
  }

  body.food-page header h1 {
    font-size: 1.05rem;
    flex: 1;
  }

  body.food-page header > span:not(#status) {
    display: none;
  }

  body.food-page #locate-btn {
    margin-left: 0;
    padding: 4px 9px;
    font-size: 0.75rem;
  }

  body.food-page #tod label {
    padding: 3px 7px;
    font-size: 0.72rem;
  }

  body.food-page #legend {
    order: 3;
    width: 100%;
    gap: 10px;
  }

  body.food-page .legend-item {
    font-size: 0.72rem;
  }

  body.food-page #status {
    order: 4;
    width: 100%;
  }
}

.site-footer {
    margin-top: 4rem;
    padding-top: 1rem;
    border-top: 1px solid #ddd;
    font-size: 0.9rem;
    color: #666;
    text-align: center;
}

.site-footer a {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dotted #999;
}

.site-footer a:hover {
    color: #0055aa;
    border-bottom-style: solid;
}

body.carbon-page .site-footer,
body.wikipedia-tts-page .site-footer {
  width: min(1100px, 100%);
}

body.food-page .site-footer,
body.map-zones-page .site-footer,
body.plaqueattack-page .site-footer {
  margin-top: 0;
  padding: 0.85rem 1rem 1rem;
  border-top-color: rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.82);
  background: rgba(0, 0, 0, 0.18);
}

body.food-page .site-footer a,
body.map-zones-page .site-footer a,
body.plaqueattack-page .site-footer a {
  border-bottom-color: rgba(255, 255, 255, 0.5);
}

body.food-page .site-footer a:hover,
body.map-zones-page .site-footer a:hover,
body.plaqueattack-page .site-footer a:hover {
  color: #fff;
}