:root {
  --bg: #f4efe5;
  --bg-accent: #dfd2b1;
  --panel: rgba(255, 251, 243, 0.92);
  --panel-strong: #fffdf7;
  --text: #21302a;
  --muted: #61706a;
  --line: rgba(33, 48, 42, 0.12);
  --brand: #1f5f4a;
  --brand-strong: #174635;
  --brand-soft: #cfe4d8;
  --gold: #c6892f;
  --shadow: 0 18px 40px rgba(53, 59, 43, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 999px;
  --font-display: "Avenir Next", "Segoe UI", sans-serif;
  --font-body: "Trebuchet MS", "Gill Sans", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(198, 137, 47, 0.16), transparent 24%),
    radial-gradient(circle at top right, rgba(31, 95, 74, 0.2), transparent 20%),
    linear-gradient(180deg, #f7f1e4 0%, var(--bg) 48%, #efe4ce 100%);
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.hero {
  display: block;
}

.hero__card,
.panel {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

h1,
h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.03em;
}

.section-heading p,
.hero__meta p {
  color: var(--muted);
}

.hero__card {
  border-radius: var(--radius-xl);
  padding: 26px;
  width: 100%;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 249, 236, 0.88)),
    linear-gradient(135deg, rgba(31, 95, 74, 0.1), rgba(198, 137, 47, 0.08));
}

.hero__card {
  display: grid;
  gap: 20px;
}

.profile-card {
  display: grid;
  gap: 18px;
  padding: 20px;
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgba(31, 95, 74, 0.08), rgba(198, 137, 47, 0.12)),
    rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(33, 48, 42, 0.08);
}

.profile-card__identity {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.profile-card__eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
}

.profile-card__intro p:last-child {
  margin: 8px 0 0;
  color: var(--muted);
}

.profile-card__link {
  display: inline-block;
  color: var(--brand);
  text-decoration: none;
  overflow-wrap: anywhere;
  max-width: 100%;
}

.profile-card__link:hover {
  text-decoration: underline;
}

.profile-photo {
  appearance: none;
  width: 96px;
  height: 96px;
  border-radius: 28px;
  overflow: hidden;
  background: rgba(31, 95, 74, 0.08);
  border: 1px solid rgba(33, 48, 42, 0.08);
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
}

.profile-photo__image,
.profile-photo__fallback {
  width: 100%;
  height: 100%;
}

.profile-photo__image {
  display: block;
  object-fit: cover;
}

.profile-photo__fallback {
  display: grid;
  place-items: center;
  padding: 12px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.profile-card__fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.profile-field {
  display: grid;
  gap: 8px;
}

.profile-field--wide {
  grid-column: 1 / -1;
}

.profile-field span {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--muted);
}

.profile-field input,
.profile-field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.84);
  color: var(--text);
  resize: vertical;
}

.profile-card__photo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.profile-card__editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.profile-card__intro {
  min-width: 0;
}

.profile-card__intro h2,
.profile-card__intro p,
.profile-card__intro a {
  overflow-wrap: anywhere;
}

.hero__stats {
  display: grid;
  grid-template-columns: minmax(320px, 1.35fr) minmax(240px, 0.8fr);
  gap: 18px;
  align-items: stretch;
}

.stat-ring-card,
.summary-card {
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(33, 48, 42, 0.08);
  border-radius: var(--radius-lg);
}

.stat-ring-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 22px;
  align-items: center;
  padding: 18px 22px;
}

.stat-ring {
  position: relative;
  width: 180px;
  aspect-ratio: 1;
}

.stat-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.stat-ring circle {
  fill: none;
  stroke-width: 12;
}

.stat-ring__track {
  stroke: rgba(31, 95, 74, 0.12);
}

.stat-ring__value {
  stroke: var(--brand);
  stroke-linecap: round;
  stroke-dasharray: 301.59;
  stroke-dashoffset: 301.59;
  transition: stroke-dashoffset 220ms ease;
}

.stat-ring__label {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
}

.stat-ring__label strong {
  font-size: 2.4rem;
  line-height: 1;
}

.stat-toggle {
  border: 0;
  background: transparent;
  color: inherit;
  font-family: var(--font-display);
  font-size: 2.4rem;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}

.stat-toggle--want {
  font-size: clamp(2rem, 4vw, 3.2rem);
  text-align: left;
  color: #335d8f;
}

.stat-ring__label span {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
}

.hero__meta {
  text-align: left;
}

.hero__meta p {
  margin: 0;
}

.summary-card {
  padding: 24px;
  display: grid;
  align-content: center;
  gap: 10px;
  background:
    linear-gradient(180deg, rgba(245, 247, 251, 0.92), rgba(255, 247, 240, 0.92));
}

.summary-card__eyebrow {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
}

.summary-card strong {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1;
}

.summary-card p {
  margin: 0;
  color: var(--muted);
}

.flag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  overflow: hidden;
  padding-top: 8px;
  margin-top: 4px;
  border-top: 1px solid rgba(33, 48, 42, 0.08);
  width: 100%;
  grid-column: 1 / -1;
}

.flag-chip {
  flex: 0 0 auto;
  min-width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(33, 48, 42, 0.08);
  font-size: 1.3rem;
}

.flag-chip--want {
  background: rgba(232, 239, 250, 0.96);
}

.dashboard {
  margin-top: 22px;
  display: grid;
  gap: 22px;
}

.panel {
  border-radius: var(--radius-xl);
  padding: 24px;
}

.controls-panel {
  display: grid;
  gap: 16px;
}

.map-panel {
  overflow: hidden;
}

.map-stage {
  position: relative;
  overflow: hidden;
  border-radius: calc(var(--radius-xl) - 6px);
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.92), transparent 18%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.68), rgba(248, 241, 224, 0.3));
  min-height: min(48vw, 480px);
}

.world-map-host {
  width: 100%;
  min-height: inherit;
  display: grid;
  place-items: center;
}

.world-map-host svg {
  width: 100%;
  height: auto;
  display: block;
  background: transparent;
  min-height: inherit;
}

.map-loading {
  color: var(--muted);
  padding: 24px;
}

.world-map-host [id] {
  fill: rgba(84, 102, 95, 0.38);
  stroke: rgba(255, 255, 255, 0.72);
  stroke-width: 0.55;
  vector-effect: non-scaling-stroke;
  transition: fill 180ms ease, opacity 180ms ease, transform 180ms ease;
  cursor: pointer;
}

.world-map-host [id]:hover {
  fill: #2d7b62;
}

.world-map-host .map-country--visible {
  fill: #2f6f5b;
}

.world-map-host .map-country--visited {
  fill: #d3983f;
}

.world-map-host .map-country--visited.map-country--visible {
  fill: #195440;
}

.world-map-host .mainland,
.world-map-host .mainland + path {
  pointer-events: inherit;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.94rem;
}

.map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.legend-dot {
  width: 12px;
  height: 12px;
  display: inline-block;
  border-radius: 50%;
  background: rgba(33, 48, 42, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.88);
}

.legend-dot--visible {
  background: var(--brand);
}

.legend-dot--visited {
  background: var(--gold);
}

.legend-dot--want {
  background: #5e86b2;
}

.controls-top {
  display: flex;
  justify-content: flex-end;
}

.search input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.8);
}

.countries-search {
  display: block;
  margin-bottom: 16px;
}

.search input:focus,
button:focus-visible,
.import-button:focus-visible {
  outline: 3px solid rgba(31, 95, 74, 0.2);
  outline-offset: 2px;
}

.filter-row,
.actions,
.continent-stats,
.countries-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.filter-chip,
button,
.import-button {
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  cursor: pointer;
  transition: transform 180ms ease, background-color 180ms ease, border-color 180ms ease;
}

button,
.import-button {
  background: var(--brand);
  color: #fff;
}

button:hover,
.import-button:hover,
.filter-chip:hover {
  transform: translateY(-1px);
}

.secondary-button {
  background: #497764;
}

.ghost-button,
.filter-chip {
  background: rgba(255, 255, 255, 0.75);
  color: var(--text);
  border: 1px solid var(--line);
}

.filter-chip.active {
  background: var(--brand-soft);
  border-color: rgba(31, 95, 74, 0.35);
  color: var(--brand-strong);
}

.import-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#importInput,
#profilePhotoInput {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.section-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 16px;
}

.section-heading p {
  margin: 0;
}

.continent-stat {
  flex: 1 1 140px;
  min-width: 140px;
  padding: 16px;
  border-radius: var(--radius-lg);
  background: var(--panel-strong);
  border: 1px solid var(--line);
}

.continent-stat strong {
  display: block;
  font-size: 1.4rem;
  margin-bottom: 4px;
}

.continent-stat span {
  color: var(--muted);
}

.continent-stat__bar {
  margin-top: 12px;
  height: 10px;
  border-radius: var(--radius-sm);
  background: rgba(31, 95, 74, 0.08);
  overflow: hidden;
}

.continent-stat__bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--gold));
}

.countries-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.country-card {
  width: 100%;
  text-align: left;
  padding: 18px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid var(--line);
  color: var(--text);
  min-height: 146px;
  display: grid;
  gap: 10px;
  align-content: start;
}

.country-card.visited {
  background: linear-gradient(180deg, rgba(207, 228, 216, 0.95), rgba(255, 250, 242, 0.92));
  border-color: rgba(31, 95, 74, 0.35);
}

.country-card.want-to-go {
  background: linear-gradient(180deg, rgba(228, 236, 247, 0.96), rgba(255, 250, 242, 0.92));
  border-color: rgba(94, 134, 178, 0.35);
}

.country-card__flag {
  font-size: 1.8rem;
}

.country-card__name {
  font-family: var(--font-display);
  font-size: 1.06rem;
  font-weight: 700;
}

.country-card__continent,
.country-card__status {
  color: var(--muted);
  font-size: 0.92rem;
}

.country-card__status {
  margin-top: auto;
  font-weight: 700;
}

.country-card.visited .country-card__status {
  color: var(--brand-strong);
}

.country-card.want-to-go .country-card__status {
  color: #335d8f;
}

.country-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.country-card__action {
  flex: 1 1 120px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  border: 1px solid var(--line);
}

.country-card__action--visited.is-active {
  background: var(--gold);
  color: #fff;
  border-color: rgba(198, 137, 47, 0.55);
}

.country-card__action--want.is-active {
  background: #5e86b2;
  color: #fff;
  border-color: rgba(94, 134, 178, 0.55);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 860px) {
  .profile-card__fields,
  .hero__stats,
  .stat-ring-card {
    grid-template-columns: 1fr;
  }

  .profile-card__photo-actions {
    justify-content: center;
  }

  .profile-card__editor-actions {
    justify-content: center;
  }

  .stat-ring-card,
  .hero__meta {
    justify-items: center;
    text-align: center;
  }

  .flag-list {
    justify-content: center;
  }

  .controls-top {
    justify-content: stretch;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 12px;
  }

  .hero__card,
  .panel {
    padding: 20px;
  }

  .profile-card {
    padding: 18px;
  }

  .countries-grid {
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  }

  .map-legend {
    font-size: 0.86rem;
    gap: 10px;
  }
}
