/* Track Your Countries — styles
   Tokens: passport paper, stamp ink. Numbers carry the personality (mono),
   everything else stays quiet. */

:root {
  --paper: #F3F5F8;
  --card: #FFFFFF;
  --ink: #14204A;
  --ink-2: #4B5670;
  --ink-3: #8A93A8;
  --line: #D9DEE8;
  --stamp: #4F46C9;
  --stamp-soft: #ECEBFB;
  --red: #C0392B;
  --red-soft: #FBEAE8;
  --ok: #1E7F5C;
  --ok-soft: #E4F4EC;
  --warn: #B7791F;
  --warn-soft: #FBF1DC;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --radius: 14px;
  --nav-h: 64px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0F1420; --card: #171D2B; --ink: #E8ECF5; --ink-2: #A3ACC2; --ink-3: #6E778D;
    --line: #2A3345; --stamp: #8B85F0; --stamp-soft: #24244A; --red: #F07167; --red-soft: #3A2226;
    --ok: #4CC9A0; --ok-soft: #173229; --warn: #F2B84B; --warn-soft: #3A2E14;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--sans); font-size: 16px; line-height: 1.45;
  padding-bottom: calc(var(--nav-h) + var(--sab));
  overscroll-behavior-y: none; -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--stamp); outline-offset: 2px; }

main { max-width: 520px; margin: 0 auto; padding: calc(12px + var(--sat)) 16px 24px; }
.eyebrow { font-family: var(--mono); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
h1 { font-family: var(--sans); font-weight: 600; font-size: 26px; letter-spacing: -.01em; margin: 4px 0 6px; }
h2 { font-size: 17px; font-weight: 600; margin: 24px 0 10px; }
p { margin: 0 0 12px; color: var(--ink-2); }
p.strong { color: var(--ink); }
small, .muted { color: var(--ink-3); font-size: 13px; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
a { color: var(--stamp); }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

/* ---- cards ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card.flat { background: transparent; }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack { display: grid; gap: 8px; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 12px; padding: 12px 16px; font-weight: 600; min-height: 48px; width: 100%;
  transition: transform .08s ease, background .15s ease;
}
.btn:active { transform: scale(.985); }
.btn.primary { background: var(--stamp); border-color: var(--stamp); color: #fff; }
.btn.danger { color: var(--red); }
.btn.small { min-height: 38px; padding: 8px 12px; width: auto; font-size: 14px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--stamp); }
.btn:disabled { opacity: .55; cursor: default; }
.btnrow { display: flex; gap: 8px; }
.btnrow .btn { flex: 1; }
.iconbtn { background: none; border: 0; padding: 8px; color: var(--ink-2); border-radius: 10px; min-width: 40px; min-height: 40px; }
.link { background: none; border: 0; padding: 0; color: var(--stamp); font-weight: 600; }

/* ---- inputs ---- */
.input { width: 100%; border: 1px solid var(--line); background: var(--paper); border-radius: 12px; padding: 12px 14px; min-height: 48px; }
label.field { display: grid; gap: 6px; font-size: 14px; color: var(--ink-2); }
.check { display: flex; gap: 10px; align-items: center; font-size: 15px; color: var(--ink); }
.check input { width: 20px; height: 20px; accent-color: var(--stamp); }

/* ---- segmented control ---- */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--paper); }
.seg button { border: 0; background: transparent; padding: 8px 12px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }

/* ---- the stamp (signature element) ---- */
.stamp-wrap { display: grid; place-items: center; padding: 22px 0 10px; }
.stamp {
  --c: var(--stamp);
  position: relative; display: grid; place-items: center; text-align: center; gap: 2px;
  min-width: 240px; padding: 18px 22px; border: 3px double var(--c); border-radius: 18px;
  color: var(--c); transform: rotate(-4deg); font-family: var(--mono); text-transform: uppercase;
  letter-spacing: .14em; mix-blend-mode: multiply;
}
@media (prefers-color-scheme: dark) { .stamp { mix-blend-mode: normal; } }
.stamp::after {
  content: ""; position: absolute; inset: 5px; border: 1px solid var(--c); border-radius: 13px; opacity: .55; pointer-events: none;
}
.stamp .flag { font-size: 34px; line-height: 1; letter-spacing: 0; }
.stamp .name { font-size: 20px; font-weight: 600; letter-spacing: .08em; }
.stamp .date { font-size: 12px; opacity: .85; }
.stamp .tag { font-size: 11px; opacity: .8; }
.stamp.empty { --c: var(--ink-3); border-style: dashed; }
.stamp.empty::after { border-style: dashed; }
.stamp.pressed { animation: press .42s cubic-bezier(.2,.9,.3,1.2) both; }
@keyframes press {
  0% { transform: rotate(-14deg) scale(1.35); opacity: 0; }
  60% { opacity: 1; }
  100% { transform: rotate(-4deg) scale(1); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { .stamp.pressed { animation: none; } }

/* ---- last days strip ---- */
.strip { display: flex; gap: 6px; justify-content: center; margin: 14px 0 4px; }
.strip .d { display: grid; place-items: center; gap: 2px; font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.chip {
  display: inline-grid; place-items: center; min-width: 34px; height: 26px; padding: 0 6px; border-radius: 8px;
  font-family: var(--mono); font-size: 12px; font-weight: 600; letter-spacing: .06em;
  background: var(--cc, var(--line)); color: #fff;
}
.chip.none { background: transparent; border: 1px dashed var(--line); color: var(--ink-3); }

/* ---- status rows / bars ---- */
.status { display: grid; gap: 6px; padding: 12px 0; border-top: 1px solid var(--line); }
.status:first-of-type { border-top: 0; }
.bar { height: 8px; border-radius: 6px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--cc, var(--stamp)); border-radius: 6px; transition: width .4s ease; }
.bar.limit > i { background: var(--ok); }
.bar.limit.warn > i { background: var(--warn); }
.bar.limit.bad > i, .bar.bad > i { background: var(--red); }
.pill { display: inline-block; font-family: var(--mono); font-size: 12px; padding: 3px 8px; border-radius: 999px; background: var(--line); color: var(--ink-2); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--red-soft); color: var(--red); }
.pill.neutral { background: var(--stamp-soft); color: var(--stamp); }
.big { font-family: var(--mono); font-size: 40px; font-weight: 600; line-height: 1; letter-spacing: -.02em; }
.big small { font-size: 16px; color: var(--ink-3); font-weight: 400; letter-spacing: 0; }
details { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 10px; }
summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--ink-2); }
details p { font-size: 14px; margin-top: 8px; }
.test { display: grid; gap: 6px; padding: 10px 0; border-top: 1px dashed var(--line); }
.test:first-child { border-top: 0; }
.test .req { font-size: 13px; color: var(--ink-3); }

/* ---- calendar ---- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 10px; }
.cal-head .title { font-weight: 600; font-size: 18px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .wd { text-align: center; font-family: var(--mono); font-size: 11px; color: var(--ink-3); padding-bottom: 4px; }
.cal .day {
  position: relative; aspect-ratio: 1 / 1.15; border: 1px solid var(--line); border-radius: 10px; background: var(--card);
  display: grid; grid-template-rows: auto 1fr; padding: 4px; text-align: left;
}
.cal .day.out { opacity: .35; }
.cal .day.today { border-color: var(--stamp); box-shadow: inset 0 0 0 1px var(--stamp); }
.cal .day.future { background: transparent; }
.cal .day .n { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.cal .day .chip { justify-self: center; align-self: center; min-width: 30px; height: 22px; font-size: 11px; }
.cal .day .also { position: absolute; right: 4px; bottom: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--cc2, var(--ink-3)); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; margin: 12px 0; font-size: 13px; color: var(--ink-2); }
.legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 4px; background: var(--cc); margin-right: 6px; vertical-align: -1px; }

/* ---- lists ---- */
.list { display: grid; }
.list .item { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-top: 1px solid var(--line); background: none; border-left: 0; border-right: 0; border-bottom: 0; width: 100%; text-align: left; }
.list .item:first-child { border-top: 0; }
.list .item .flag { font-size: 22px; width: 30px; text-align: center; }
.list .item .code { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }

/* ---- bottom sheet ---- */
#sheet { position: fixed; inset: 0; z-index: 30; display: none; }
#sheet.open { display: block; }
#sheet .backdrop { position: absolute; inset: 0; background: rgba(10, 14, 30, .45); }
#sheet .panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 88vh; overflow: auto; background: var(--card);
  border-radius: 20px 20px 0 0; padding: 12px 16px calc(20px + var(--sab)); max-width: 560px; margin: 0 auto;
  animation: up .22s ease-out;
}
@keyframes up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { #sheet .panel { animation: none; } }
#sheet .grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 0 auto 12px; }
#sheet h3 { margin: 4px 0 10px; font-size: 18px; }

/* ---- toast ---- */
#toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--sab) + 12px); transform: translateX(-50%); z-index: 40;
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; }
#toast.show { opacity: 1; }

/* ---- tab bar ---- */
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; height: calc(var(--nav-h) + var(--sab));
  padding-bottom: var(--sab); background: var(--card); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr); max-width: 100%;
}
nav.tabs button { border: 0; background: none; display: grid; place-items: center; gap: 2px; color: var(--ink-3); font-size: 11px; font-weight: 600; }
nav.tabs button svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
nav.tabs button[aria-current="page"] { color: var(--stamp); }
body.onboarding nav.tabs { display: none; }
body.onboarding { padding-bottom: 24px; }

/* ---- onboarding ---- */
.steps { font-family: var(--mono); font-size: 12px; color: var(--ink-3); letter-spacing: .1em; }
.hero-stamps { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 18px 0 8px; }
.hero-stamps .stamp { min-width: 0; padding: 10px 14px; transform: rotate(-6deg); }
.hero-stamps .stamp:nth-child(2) { transform: rotate(3deg); --c: var(--red); }
.hero-stamps .stamp:nth-child(3) { transform: rotate(-2deg); --c: var(--ok); }
.hero-stamps .stamp .name { font-size: 14px; }
.hero-stamps .stamp .date { font-size: 10px; }
.disclaimer { font-size: 13px; color: var(--ink-3); border-left: 3px solid var(--line); padding-left: 10px; }
.install-steps { display: grid; gap: 8px; font-size: 15px; }
.install-steps div { display: flex; gap: 10px; align-items: flex-start; }
.install-steps b { font-family: var(--mono); color: var(--stamp); min-width: 18px; }
.searchbox { position: sticky; top: 0; background: var(--card); padding-bottom: 8px; }
.picker { max-height: 52vh; overflow: auto; }
.tag { display: inline-block; font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--stamp); background: var(--stamp-soft); padding: 2px 8px; border-radius: 6px; }
.tag.grey { color: var(--ink-3); background: var(--line); }
