* {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

img.emoji {
  height: 1em;
  width: 1em;
  vertical-align: -0.125em;
}

body {
  max-width: 500px;
  margin: 18px auto 40px;
  padding: 13px 20px 20px;
  background: #f5f5f5;
}

h1 {
  text-align: center;
  color: #333;
  margin-top: 0;
  margin-bottom: 20px;
}

.calculator {
  background: white;
  padding: 30px;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.toggle-container {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 15px;
  margin-bottom: 25px;
}

.country-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 2px solid #e0e0e0;
  border-radius: 20px;
  background: white;
  cursor: pointer;
  user-select: none;
}

.country-wrapper.open,
.country-wrapper:focus-within {
  border-color: #0062cc;
}

.country-name {
  font-size: 14px;
  font-weight: 600;
}

.country-flag {
  font-size: 18.5px;
  line-height: 1;
}

.dropdown-arrow {
  font-size: 10px;
  color: #666;
}

.country-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  min-width: 220px;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 1000;
  cursor: default;
  overflow: hidden;
}

.country-wrapper.open .country-dropdown {
  display: block;
}

.country-search {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: none;
  border-bottom: 1px solid #eee;
  font-size: 14px;
  outline: none;
  font-family: inherit;
}

.country-options {
  max-height: 260px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.country-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
}

.country-option:hover,
.country-option.active {
  background: #f0f6ff;
}

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

.country-option .country-option-flag {
  font-size: 18px;
  line-height: 1;
}

.country-option-empty {
  padding: 12px;
  text-align: center;
  color: #888;
  font-size: 13px;
}

/* Custom search-enabled dropdown used for month/year selects.
   The underlying native <select> is kept in the DOM (hidden) so all
   existing .value / change-event code keeps working unchanged. */
.search-select {
  flex: 1;
  position: relative;
}

.search-select-native {
  display: none;
}

.search-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  background: white;
  font-size: 16px;
  cursor: pointer;
  user-select: none;
}

.search-select.open .search-select-trigger {
  border-color: #0062cc;
}

.search-select-arrow {
  font-size: 10px;
  color: #666;
}

.search-select-panel {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  min-width: 100%;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 1000;
  overflow: hidden;
}

.search-select.open .search-select-panel {
  display: block;
}

.search-select-search {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: none;
  border-bottom: 1px solid #eee;
  font-size: 14px;
  outline: none;
  font-family: inherit;
}

.search-select-options {
  max-height: 256px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-snap-type: y mandatory;
}

.search-select-option {
  padding: 8px 12px;
  font-size: 14px;
  line-height: 16px;
  cursor: pointer;
  scroll-snap-align: start;
}

.search-select-option:hover,
.search-select-option.active {
  background: #f0f6ff;
}

.search-select-option.hidden {
  display: none;
}

.toggle {
  display: flex;
  background: #e0e0e0;
  border-radius: 25px;
  padding: 4px;
}

.toggle button {
  padding: 10px 25px;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  background: transparent;
  color: #555;
  transition: all 0.2s;
}

.toggle button.active {
  background: #0062cc;
  color: white;
}

.toggle-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.index-help-wrap {
  position: relative;
}

.index-help {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #d0d0d0;
  color: white;
  font-size: 10px;
  font-weight: 700;
  line-height: 14px;
  text-align: center;
  cursor: help;
  user-select: none;
  transition: background 0.15s;
}

.index-help:hover,
.toggle-group.help-pinned .index-help {
  background: #999;
}

.index-help-popup {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: 300px;
  max-width: 90vw;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.5;
  color: #333;
  z-index: 1000;
  text-align: left;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s, visibility 0s 0.15s;
}

/* Bridge the 8px gap so moving the cursor from icon to popup doesn't drop hover. */
.index-help-popup::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 0;
  right: 0;
  height: 8px;
}

/* Hover: 300ms delay before appearing. */
.index-help-wrap:hover .index-help-popup {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.15s 0.3s, visibility 0s 0.3s;
}

/* After X is clicked, suppress hover-reopen until the cursor leaves the wrap. */
.index-help-wrap.help-dismissed:hover .index-help-popup {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s, visibility 0s 0.15s;
}

/* On narrow screens the icon sits well left of centre, and an absolutely-
   positioned popup anchored to it overflows the viewport. Re-anchor to
   the viewport but match the white card's left/right edges (body has
   max-width 500px + 20px horizontal padding, border-box, centred), so
   the popup lines up with the card visually. Hover doesn't apply on
   touch so we lose nothing by detaching from the icon. */
@media (max-width: 480px) {
  .index-help-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: calc(min(100vw, 500px) - 40px);
    max-width: none;
    max-height: calc(100vh - 64px);
    overflow-y: auto;
  }
  /* The hover-bridging ::before is meaningless when the popup is detached
     from the icon, and would intercept taps if left in place. */
  .index-help-popup::before {
    display: none;
  }
}

/* Click-pinned: appear immediately, stay until X is clicked. */
.toggle-group.help-pinned .index-help-popup {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.15s, visibility 0s;
  padding-right: 36px;
}

.index-help-popup p {
  margin: 0 0 8px 0;
}

.index-help-popup p:last-child {
  margin-bottom: 0;
}

.index-help-popup strong {
  color: #0062cc;
}

.index-help-close {
  display: none;
  position: absolute;
  top: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e74c3c;
  color: white;
  border: none;
  padding: 0;
  font-size: 13px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  cursor: pointer;
}

.index-help-close:hover {
  background: #c0392b;
}

.toggle-group.help-pinned .index-help-close {
  display: block;
}

.date-section {
  margin-bottom: 20px;
}

.date-section label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: #333;
}

.date-inputs {
  display: flex;
  gap: 10px;
}

.date-inputs select {
  flex: 1;
  padding: 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
}

.date-inputs select:focus {
  outline: none;
  border-color: #0062cc;
}

.amount-input {
  margin-top: 10px;
  position: relative;
}

.amount-input span {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #666;
  font-size: 16px;
  font-weight: 600;
}

.amount-input input {
  width: 100%;
  padding: 12px 12px 12px 28px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 16px;
}

/* Hide native number-input spinner arrows. */
.amount-input input[type="number"]::-webkit-outer-spin-button,
.amount-input input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.amount-input input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.amount-input input:focus {
  outline: none;
  border-color: #0062cc;
}

.amount-input input.result-amount {
  background: #f0f7ff;
  border-color: #0062cc;
  font-weight: 600;
  color: #0062cc;
}

.calculate-btn {
  width: 100%;
  padding: 15px;
  background: #0062cc;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 10px;
  transition: background 0.2s;
}

.calculate-btn:hover {
  background: #0056b3;
}

.result {
  margin-top: 25px;
  padding: 20px;
  background: #f8f9fa;
  border-radius: 8px;
  text-align: center;
  display: none;
}

.result.show {
  display: block;
}

.result-value {
  font-size: 36px;
  font-weight: 700;
  color: #0062cc;
}

.result-description {
  margin-top: 10px;
  color: #666;
  font-size: 14px;
}

.equivalent {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid #e0e0e0;
  color: #333;
}

.data-source {
  margin-top: 14px;
  font-size: 12px;
  color: #595959;
  text-align: center;
  line-height: 1.5;
}

.data-source a {
  color: #595959;
  text-decoration: underline;
}

.data-notice-fixed {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 12px 15px;
  background: #fff3cd;
  border-bottom: 2px solid #ffc107;
  color: #856404;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  z-index: 1000;
  display: none;
}

.data-notice-fixed.show {
  display: block;
}

.data-notice {
  margin-top: 15px;
  padding: 12px 15px;
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 8px;
  color: #856404;
  font-size: 13px;
  line-height: 1.5;
  display: none;
}

.data-notice.show {
  display: block;
}

/* Smaller persistent notice slotted into the From section for
   countries with a currency-redenomination caveat (currently only RU). */
.country-notice {
  margin-top: 6px;
  margin-bottom: 8px;
  padding: 6px 10px;
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 6px;
  color: #856404;
  font-size: 12px;
  line-height: 1.4;
  display: none;
}

.country-notice.show {
  display: block;
}

.cumulative-chart {
  margin-top: 18px;
  padding: 18px 16px 12px;
  background: white;
  border: 1px solid #ececec;
  border-radius: 8px;
  display: none;
}
.cumulative-chart.show { display: block; }
.cumulative-chart-title {
  font-size: 20px;
  font-weight: bold;
  color: #333;
  margin: 0 0 12px;
  text-align: center;
}
.cumulative-chart-sub {
  font-size: 12px;
  color: #777;
  margin: 0 0 14px;
}
.chart-wrap { position: relative; }
.chart-svg { display: block; width: 100%; height: auto; }
.chart-area-line {
  fill: none;
  stroke: #0062cc;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chart-area-fill { fill: url(#cumulativeAreaGrad); }
.chart-axis { stroke: #e6e6e6; stroke-width: 1; }
.chart-tick-label { font-size: 10px; fill: #888; }
.chart-endpoint { fill: #0062cc; }
.chart-endpoint-ring { fill: white; stroke: #0062cc; stroke-width: 2; }
.chart-endpoint-label {
  font-size: 11px;
  font-weight: 600;
  fill: #0062cc;
}
.chart-hover-line {
  stroke: #0062cc;
  stroke-width: 1;
  stroke-dasharray: 3 3;
  opacity: 0;
  pointer-events: none;
}
.chart-hover-dot {
  fill: white;
  stroke: #0062cc;
  stroke-width: 2;
  opacity: 0;
  pointer-events: none;
}
.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: white;
  border: 1px solid #0062cc;
  border-radius: 6px;
  padding: 6px 9px;
  font-size: 12px;
  color: #222;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  opacity: 0;
  transform: translate(-50%, -110%);
  transition: opacity 0.1s;
  white-space: nowrap;
}
.chart-tooltip strong { color: #0062cc; }
.chart-tooltip .tip-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}
.chart-tooltip .tip-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cumulative-chart { position: relative; }

.chart-expand-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  padding: 6px;
  background: white;
  border: 1px solid #d4d4d4;
  border-radius: 6px;
  cursor: pointer;
  color: #555;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: border-color 0.15s, color 0.15s;
}
.chart-expand-btn:hover { border-color: #0062cc; color: #0062cc; }
.chart-expand-btn:focus-visible { outline: 2px solid #0062cc; outline-offset: 2px; }
.chart-expand-btn svg { width: 16px; height: 16px; display: block; pointer-events: none; }

.chart-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 42px;
  height: 42px;
  padding: 0;
  background: #dc3545;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  color: white;
  z-index: 3;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  transition: background 0.15s, transform 0.1s;
}
.chart-close-btn:hover { background: #c82333; }
.chart-close-btn:active { transform: scale(0.95); }
.chart-close-btn:focus-visible { outline: 3px solid rgba(220, 53, 69, 0.4); outline-offset: 2px; }
.chart-close-btn svg { width: 20px; height: 20px; pointer-events: none; }

.cumulative-chart.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 9999;
  margin: 0;
  border: none;
  border-radius: 0;
  background: white;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding:
    max(20px, calc(env(safe-area-inset-top, 0px) + 16px))
    max(20px, calc(env(safe-area-inset-right, 0px) + 16px))
    max(20px, calc(env(safe-area-inset-bottom, 0px) + 16px))
    max(20px, calc(env(safe-area-inset-left, 0px) + 16px));
}
.cumulative-chart.fullscreen .cumulative-chart-title {
  font-size: 22px;
  margin: 0 56px 12px 56px;
}
.cumulative-chart.fullscreen .cumulative-chart-sub {
  font-size: 13px;
  margin: 0 56px 14px 0;
}
.cumulative-chart.fullscreen .chart-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
}
.cumulative-chart.fullscreen .chart-svg {
  width: 100%;
  height: 100%;
}
.cumulative-chart.fullscreen .chart-expand-btn { display: none; }
.cumulative-chart.fullscreen .chart-close-btn { display: flex; }

/* Fullscreen-only summary box: the headline inflation between the two
   selected points, shown prominently at the top. Hidden in normal mode. */
.chart-fs-summary { display: none; }
.cumulative-chart.fullscreen .chart-fs-summary {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  align-self: center;
  width: min(560px, 100%);
  margin: 0 0 14px;
  padding: 14px 22px;
  background: #f0f7ff;
  border: 1px solid #cfe2fb;
  border-radius: 12px;
  text-align: center;
}
.chart-fs-summary .fs-sum-value {
  font-size: 34px;
  font-weight: 700;
  line-height: 1.1;
  color: #0062cc;
}
.chart-fs-summary .fs-sum-range {
  font-size: 14px;
  color: #555;
}
.chart-fs-summary .fs-sum-equiv {
  font-size: 13px;
  color: #333;
}
.chart-fs-summary .fs-sum-equiv strong { color: #0062cc; }
@media (min-width: 768px) {
  .cumulative-chart.fullscreen .chart-fs-summary .fs-sum-value { font-size: 42px; }
  .cumulative-chart.fullscreen .chart-fs-summary .fs-sum-range { font-size: 15px; }
  .cumulative-chart.fullscreen .chart-fs-summary .fs-sum-equiv { font-size: 14px; }
}

body.chart-fullscreen-open { overflow: hidden; }

@media (min-width: 768px) {
  .cumulative-chart.fullscreen {
    padding:
      max(32px, calc(env(safe-area-inset-top, 0px) + 24px))
      max(40px, calc(env(safe-area-inset-right, 0px) + 24px))
      max(32px, calc(env(safe-area-inset-bottom, 0px) + 24px))
      max(40px, calc(env(safe-area-inset-left, 0px) + 24px));
  }
  .cumulative-chart.fullscreen .cumulative-chart-title { font-size: 26px; }
  .cumulative-chart.fullscreen .cumulative-chart-sub { font-size: 14px; }
}

/* ------------------------------------------------------------------ */
/* Country landing pages (/inflation-in-india and friends).           */
/* Unused on the homepage, which has no .country-* elements.          */
/* ------------------------------------------------------------------ */

.crumbs {
  font-size: 12px;
  color: #595959;
  margin-bottom: 10px;
  text-align: center;
}

/* The homepage carries an empty #crumbs so the country swap has somewhere to
   write. It must take up no room until it holds something. */
.crumbs:empty {
  display: none;
}

.crumbs a {
  color: #0062cc;
  text-decoration: none;
}

.crumbs a:hover {
  text-decoration: underline;
}

.country-intro {
  color: #333;
  font-size: 15px;
  line-height: 1.6;
  margin: 0 0 20px;
}

.country-section,
.country-links {
  background: white;
  padding: 22px 24px;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  margin-top: 18px;
}

.country-section h2,
.country-links h2 {
  font-size: 17px;
  color: #333;
  margin: 0 0 12px;
}

.country-section p {
  font-size: 14px;
  line-height: 1.6;
  color: #333;
  margin: 0 0 10px;
}

.country-section p:last-child {
  margin-bottom: 0;
}

/* Four columns of numbers do not fit a narrow phone; let the table
   scroll inside its own box rather than widening the page. */
.country-table-wrap {
  overflow-x: auto;
  margin-top: 14px;
}

.country-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.country-table th,
.country-table td {
  padding: 8px 10px;
  text-align: right;
  border-bottom: 1px solid #e0e0e0;
  white-space: nowrap;
}

.country-table th:first-child,
.country-table td:first-child {
  text-align: left;
}

.country-table th {
  font-size: 12px;
  color: #595959;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.country-table tbody tr:last-child td {
  border-bottom: none;
}

.country-links h3 {
  font-size: 12px;
  color: #595959;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 16px 0 8px;
}

.country-links h3:first-of-type {
  margin-top: 0;
}

.country-links ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.country-links li {
  font-size: 14px;
}

.country-links a {
  color: #0062cc;
  text-decoration: none;
}

.country-links a:hover {
  text-decoration: underline;
}

.country-links p {
  margin: 14px 0 0;
  font-size: 14px;
}
