:root {
  --ocean: #0b3d4a;
  --ocean-deep: #072c36;
  --coral: #e07a5f;
  --coral-soft: #f0a48f;
  --surface: #f7f4ef;
  --surface-2: #efe9df;
  --ink: #1a2a30;
  --muted: #5c6f76;
  --line: rgba(11, 61, 74, 0.12);
  --ok: #2f6f5e;
  --danger: #b23a3a;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(11, 61, 74, 0.08);
  --max: 820px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 64px;
  --font-display: "Fraunces", Georgia, serif;
  --font-ui: "Source Sans 3", "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body {
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 12px);
}

.topo {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(224, 122, 95, 0.12), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(11, 61, 74, 0.1), transparent 50%),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 28px,
      rgba(11, 61, 74, 0.025) 28px,
      rgba(11, 61, 74, 0.025) 29px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 28px,
      rgba(11, 61, 74, 0.02) 28px,
      rgba(11, 61, 74, 0.02) 29px
    );
}

.app {
  position: relative;
  z-index: 1;
  width: min(100%, var(--max));
  margin: 0 auto;
  padding: 20px 18px 28px;
}

.boot {
  padding: 48px 0;
  text-align: center;
  color: var(--muted);
}

.brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.4rem, 8vw, 3.4rem);
  letter-spacing: -0.03em;
  color: var(--ocean);
  margin: 0;
  line-height: 1.05;
}

.lede {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.hero {
  padding: 18px 0 8px;
  animation: rise 0.45s ease both;
}

.fraction {
  margin: 22px 0 6px;
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 10vw, 4rem);
  font-weight: 600;
  color: var(--ocean);
  letter-spacing: -0.04em;
  line-height: 1;
}

.fraction span {
  color: var(--coral);
}

.section-title {
  margin: 28px 0 12px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.continent-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.continent-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  align-items: center;
  padding: 12px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  width: 100%;
  font: inherit;
  text-align: left;
  color: inherit;
  animation: rise 0.4s ease both;
}

.continent-link {
  cursor: pointer;
  border-radius: 8px;
  padding-left: 4px;
  padding-right: 4px;
  transition: background 0.15s ease;
}

.continent-link:hover,
.continent-link:focus-visible {
  background: rgba(11, 61, 74, 0.05);
  outline: none;
}

.continent-link:active {
  background: rgba(11, 61, 74, 0.08);
}

.continent-row:nth-child(1) { animation-delay: 0.04s; }
.continent-row:nth-child(2) { animation-delay: 0.08s; }
.continent-row:nth-child(3) { animation-delay: 0.12s; }
.continent-row:nth-child(4) { animation-delay: 0.16s; }
.continent-row:nth-child(5) { animation-delay: 0.2s; }
.continent-row:nth-child(6) { animation-delay: 0.24s; }
.continent-row:nth-child(7) { animation-delay: 0.28s; }

.continent-name {
  font-weight: 600;
  color: var(--ocean);
}

.continent-count {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 0.95rem;
}

.bar {
  grid-column: 1 / -1;
  height: 6px;
  border-radius: 999px;
  background: rgba(11, 61, 74, 0.08);
  overflow: hidden;
}

.bar > i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--ocean), var(--coral));
  transition: width 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.auth-card {
  margin-top: 28px;
  max-width: 420px;
}

.auth-toggle {
  display: flex;
  gap: 8px;
  margin: 20px 0 16px;
  background: var(--surface-2);
  padding: 4px;
  border-radius: 999px;
}

.auth-toggle button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  padding: 10px 12px;
  border-radius: 999px;
  cursor: pointer;
}

.auth-toggle button.active {
  background: var(--ocean);
  color: #fff;
}

label {
  display: block;
  margin: 12px 0 6px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ocean);
}

input[type="email"],
input[type="password"],
input[type="search"],
input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 12px;
  padding: 13px 14px;
  font: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus {
  border-color: rgba(11, 61, 74, 0.45);
  box-shadow: 0 0 0 3px rgba(11, 61, 74, 0.1);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 12px;
  padding: 13px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease, background 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  width: 100%;
  margin-top: 18px;
  background: var(--coral);
  color: #fff;
}

.btn-primary:hover {
  background: #d46b50;
}

.btn-ghost {
  background: transparent;
  color: var(--ocean);
  border: 1px solid var(--line);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(178, 58, 58, 0.25);
}

.msg {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.92rem;
}

.msg.error {
  background: rgba(178, 58, 58, 0.08);
  color: var(--danger);
}

.msg.ok {
  background: rgba(47, 111, 94, 0.1);
  color: var(--ok);
}

.sticky-tools {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 8px 0 12px;
  background: linear-gradient(180deg, var(--surface) 70%, rgba(247, 244, 239, 0));
  backdrop-filter: blur(4px);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-top: 10px;
  padding: 4px;
  background: var(--surface-2);
  border-radius: 12px;
}

.segmented button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 10px 6px;
  border-radius: 10px;
  cursor: pointer;
}

.segmented button.active {
  background: #fff;
  color: var(--ocean);
  box-shadow: var(--shadow);
}

.visit-filter {
  margin-top: 8px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ocean);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
}

.filter-chip span {
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
}

.hint {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
  transform: translateX(-50%) translateY(16px);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(92vw, 420px);
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--ocean);
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.toast-text {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 500;
}

.toast-action {
  border: 0;
  background: transparent;
  color: var(--coral-soft);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 2px;
}

.install-hint {
  margin-top: 22px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.55);
}

.install-copy strong {
  display: block;
  color: var(--ocean);
  font-size: 1rem;
}

.install-copy p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.install-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.install-btn {
  width: auto;
  margin-top: 0;
  padding-inline: 16px;
}

.install-hint .btn-ghost {
  margin-top: 12px;
}

.install-actions .btn-ghost {
  margin-top: 0;
}

.group {
  margin: 10px 0 16px;
  border-bottom: 1px solid var(--line);
}

.group-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 700;
  color: var(--ocean);
  cursor: pointer;
  text-align: left;
}

.group-head .meta {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.group-body {
  display: none;
  padding-bottom: 8px;
  animation: expand 0.25s ease both;
}

.group.open .group-body {
  display: block;
}

.country-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 10px 4px;
  border: 0;
  border-top: 1px solid rgba(11, 61, 74, 0.06);
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: var(--ink);
}

.country-row:active {
  background: rgba(11, 61, 74, 0.04);
}

.flag {
  width: 2rem;
  text-align: center;
  font-size: 1.35rem;
  line-height: 1;
}

.country-name {
  flex: 1;
  font-weight: 500;
}

.check {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(11, 61, 74, 0.2);
  display: grid;
  place-items: center;
  color: transparent;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.18s ease;
}

.country-row.visited .check {
  background: var(--coral);
  border-color: var(--coral);
  color: #fff;
  transform: scale(1.05);
  animation: pop 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.check svg {
  width: 14px;
  height: 14px;
}

.account-panel {
  margin-top: 18px;
}

.account-email {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ocean);
  word-break: break-word;
}

.account-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 24px;
}

.copyright {
  margin-top: 36px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}

.home-action {
  margin-top: 18px;
  width: auto;
}

.back-link {
  display: inline-flex;
  align-items: center;
  border: 0;
  background: transparent;
  color: var(--ocean);
  font: inherit;
  font-weight: 600;
  padding: 0;
  margin-bottom: 10px;
  cursor: pointer;
}

.visited-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 8px 4px;
  border-top: 1px solid rgba(11, 61, 74, 0.06);
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 8px 12px calc(8px + var(--safe-bottom));
  background: rgba(247, 244, 239, 0.92);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.tabbar.hidden {
  display: none;
}

.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 8px;
  border-radius: 12px;
  cursor: pointer;
  display: grid;
  place-items: center;
  min-height: 48px;
}

.tab svg {
  width: 24px;
  height: 24px;
}

.tab.active {
  color: var(--ocean);
  background: rgba(11, 61, 74, 0.08);
}

.hidden {
  display: none !important;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes expand {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pop {
  0% {
    transform: scale(0.7);
  }
  70% {
    transform: scale(1.12);
  }
  100% {
    transform: scale(1.05);
  }
}

@media (min-width: 768px) {
  .app {
    padding-top: 36px;
  }

  .tabbar {
    width: min(100%, var(--max));
    left: 50%;
    transform: translateX(-50%);
    border-radius: 16px 16px 0 0;
  }
}
