/* Fonts live on this site: Google Fonts and most CDNs are unreliable from inside China. */
@font-face { font-family: Mali; font-weight: 700; font-display: swap; src: url(/fonts/mali-thai-700.woff2) format("woff2"); unicode-range: U+0E00-0E7F, U+200C-200D, U+25CC; }
@font-face { font-family: Mali; font-weight: 700; font-display: swap; src: url(/fonts/mali-latin-700.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: Plex; font-weight: 400; font-display: swap; src: url(/fonts/plex-thai-400.woff2) format("woff2"); unicode-range: U+0E00-0E7F, U+200C-200D, U+25CC; }
@font-face { font-family: Plex; font-weight: 600 700; font-display: swap; src: url(/fonts/plex-thai-600.woff2) format("woff2"); unicode-range: U+0E00-0E7F, U+200C-200D, U+25CC; }
@font-face { font-family: Plex; font-weight: 400; font-display: swap; src: url(/fonts/plex-latin-400.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: Plex; font-weight: 600 700; font-display: swap; src: url(/fonts/plex-latin-600.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F; }

:root {
  color-scheme: light;
  --paper: #f7f1e5;
  --dot: #dfd3bd;
  --card: #fffdf8;
  --ink: #241f1b;
  --muted: #5a5149;
  --line: #e3d8c6;
  --line2: #cdbea4;
  --cn: #b83c22;
  --cn-soft: #f9e1d8;
  --jp: #2b4c7e;
  --jp-soft: #dfe7f2;
  --th: #7c6210;
  --gold: #f2d98a;
  --teal: #2e6f75;
  --ok: #24705a;
  --ok-soft: #dcefe6;
  --warn: #8a5a06;
  --warn-soft: #f9ebc8;
  --hard: 3px 3px 0 var(--ink);
  --hand: Mali, "Sukhumvit Set", Thonburi, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background-color: var(--paper);
  background-image: radial-gradient(var(--dot) 1.2px, transparent 1.300px);
  background-size: 22px 22px;
  color: var(--ink);
  font: 17px/1.55 Plex, -apple-system, BlinkMacSystemFont, "Sukhumvit Set", Thonburi, "Noto Sans Thai", "PingFang SC", "Hiragino Sans", sans-serif;
  overflow-wrap: anywhere;
}
main { max-width: 640px; margin: 0 auto; padding: 18px 16px calc(100px + env(safe-area-inset-bottom)); }
h1, h2, h3, .big, dialog h2 { font-family: var(--hand); font-weight: 700; }
h1 { font-size: 31px; line-height: 1.25; margin: 0 0 22px; }
h2 { font-size: 21px; line-height: 1.3; margin: 30px 0 10px; }
h3 { font-size: 18px; line-height: 1.35; margin: 0; }
p { margin: 0; }
a { color: var(--jp); font-weight: 600; }
.kicker { display: block; color: var(--cn); font: 600 14px/1.4 Plex, "PingFang SC", "Hiragino Sans", "Noto Sans CJK SC", sans-serif; letter-spacing: .14em; }
.muted { color: var(--muted); font-size: 15px; }
.small { font-size: 14px; }
.right { margin-left: auto; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stack { display: grid; gap: 10px; }
[hidden] { display: none !important; }

.card {
  background: var(--card);
  border: 1.500px solid var(--line2);
  border-radius: 16px;
  padding: 14px;
}
button.card { display: block; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; }
button.card.stack { display: grid; }
.hero {
  position: relative; margin: 0 0 16px; padding: 16px;
  border: 2px solid var(--ink); border-radius: 18px; box-shadow: var(--hard);
}
/* A strip of washi tape holds the main card to the page */
.hero::before {
  content: ""; position: absolute; top: -11px; left: 50%; width: 92px; height: 22px; margin-left: -46px;
  background: var(--gold); opacity: .88; transform: rotate(-2.500deg);
}
.hero-art { display: block; width: 100%; height: auto; margin-bottom: 8px; }
.big { font-size: 33px; line-height: 1.2; }

button, .btn { font: inherit; }
.btn {
  min-height: 46px; padding: 8px 16px; border-radius: 14px; border: 1.500px solid var(--ink);
  background: var(--card); color: var(--ink); cursor: pointer; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none;
}
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.danger { color: var(--cn); border-color: var(--cn); }
.btn.small { min-height: 40px; padding: 4px 12px; font-size: 15px; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .55; }
.fab {
  position: fixed; right: max(16px, calc(50vw - 304px)); z-index: 5;
  bottom: calc(84px + env(safe-area-inset-bottom));
  min-height: 54px; padding: 10px 20px; border-radius: 27px; border: 2px solid var(--ink);
  background: var(--cn); color: #fff; font-weight: 700; cursor: pointer; box-shadow: var(--hard);
}

.nav {
  position: fixed; inset: auto 0 0 0; z-index: 6; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card); border-top: 2px solid var(--ink); padding-bottom: env(safe-area-inset-bottom);
}
.nav button {
  background: none; border: 0; color: var(--muted); min-height: 62px; cursor: pointer;
  display: grid; justify-items: center; align-content: center; gap: 2px; font-size: 14px;
}
.nav svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.800; stroke-linejoin: round; stroke-linecap: round; }
.nav button.on { color: var(--cn); font-weight: 700; }

.banner { background: var(--warn-soft); color: var(--warn); padding: 8px 16px; text-align: center; font-size: 15px; font-weight: 600; }
.toast {
  position: fixed; z-index: 30; left: 16px; right: 16px; bottom: calc(150px + env(safe-area-inset-bottom));
  max-width: 480px; margin: 0 auto; padding: 12px 16px; border-radius: 14px;
  background: var(--ink); color: var(--paper); text-align: center;
}

.pill {
  display: inline-block; padding: 1px 10px; border-radius: 99px; font-size: 14px; font-weight: 600;
  background: #efe7d6; color: var(--ink); white-space: nowrap;
}
/* Booked and paid look like a passport stamp */
.pill.ok { background: none; color: var(--ok); border: 2px solid var(--ok); border-radius: 8px; transform: rotate(-3deg); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--cn-soft); color: var(--cn); }
.tag { font-size: 14px; font-weight: 700; }
.tag.จีน { color: var(--cn); }
.tag.ญี่ปุ่น { color: var(--jp); }
.tag.ไทย { color: var(--th); }

.bar { height: 9px; border-radius: 9px; background: #efe7d6; overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--teal); }
.bar.over > i { background: var(--cn); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  min-height: 44px; padding: 6px 14px; border-radius: 99px; border: 1.500px solid var(--ink);
  background: var(--card); color: var(--ink); cursor: pointer; font-weight: 600;
}
.chip.on { background: var(--ink); color: var(--paper); }

/* Each day takes the look of the country it is spent in */
.day { position: relative; overflow: hidden; }
.day[data-country="จีน"], .day[data-country="ญี่ปุ่น"] { padding-top: 26px; }
.day[data-country="จีน"]::before, .day[data-country="ญี่ปุ่น"]::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 14px; }
.day[data-country="จีน"]::before { background: url(/art/fret.svg) 0 0 / 21px 14px; }
.day[data-country="ญี่ปุ่น"]::before { background: url(/art/seigaiha.svg) 0 0 / 28px 14px; }
.day > .row:first-child { flex-wrap: nowrap; }
.day > .row:first-child > div { flex: 1; min-width: 0; }
.day-mark { width: 30px; height: 36px; object-fit: contain; flex: none; }
.day.now { border: 2px solid var(--ink); box-shadow: var(--hard); overflow: visible; }
.day.now::before { border-radius: 14px 14px 0 0; }
.move { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 10px; background: var(--paper); border-radius: 10px; }
.move img { width: 24px; height: 24px; }
.stop { padding: 10px 0; border-top: 1.500px dashed var(--line2); }
.stop:first-child { border-top: 0; }
.stop time { font-weight: 700; margin-right: 6px; color: var(--teal); }
.local { font-size: 20px; font-weight: 600; }
.ref { font-size: 19px; font-weight: 700; letter-spacing: .03em; }

/* The route reads as one line travelled, with a stop for each leg */
.route { margin-bottom: 18px; }
.route h2 { margin: 0 0 6px; }
.leg {
  position: relative; display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 10px;
  width: 100%; min-height: 66px; padding: 8px 0; background: none; border: 0; color: inherit; text-align: left; cursor: pointer;
}
.leg + .leg::before { content: ""; position: absolute; left: 19px; top: -10px; height: 20px; border-left: 2px dashed var(--line2); }
.leg img { box-sizing: border-box; width: 40px; height: 40px; padding: 7px; border-radius: 50%; border: 2px solid var(--ink); background: var(--gold); }
.leg[data-country="จีน"] img { background: var(--cn-soft); }
.leg[data-country="ญี่ปุ่น"] img { background: var(--jp-soft); }
.leg-text { display: grid; min-width: 0; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th, .table td { padding: 8px 4px; border-top: 1px solid var(--line); text-align: right; }
.table th { border-top: 0; font-size: 14px; font-weight: 600; color: var(--muted); }
.table th:first-child, .table td:first-child { text-align: left; }
.pos { color: var(--ok); font-weight: 700; }
.neg { color: var(--cn); font-weight: 700; }

details.card > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; min-height: 30px; }
details.card > summary::-webkit-details-marker { display: none; }
.check { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; cursor: pointer; }
.check input { width: 25px; height: 25px; margin: 1px 0 0; flex: none; accent-color: var(--ok); }
.done { color: var(--muted); }

dialog {
  width: min(100%, 560px); max-width: 100%; max-height: 92dvh; margin: auto auto 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  border: 0; border-top: 2px solid var(--ink); border-radius: 22px 22px 0 0; background: var(--paper); color: var(--ink);
}
dialog::backdrop { background: rgb(36 31 27 / 55%); }
@media (min-width: 620px) { dialog { margin: auto; border: 2px solid var(--ink); border-radius: 20px; padding-bottom: 18px; } }
form { display: grid; gap: 12px; }
.f { display: grid; gap: 4px; font-size: 15px; font-weight: 600; }
.dateparts { display: grid; grid-template-columns: 1fr 1.2fr 1.2fr; gap: 8px; }
.two:has(> [hidden]) { grid-template-columns: 1fr; }
input:not([type=checkbox]), select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; font: inherit; font-size: 17px; font-weight: 400;
  background: var(--card); color: var(--ink); border: 1.500px solid var(--line2); border-radius: 12px;
}
input.amount { font-size: 28px; font-weight: 700; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid var(--teal); outline-offset: 1px;
}
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions { display: flex; gap: 10px; margin-top: 4px; }
.actions .primary { flex: 1; }
.stoprow { display: grid; gap: 8px; padding: 12px; border: 1.500px dashed var(--line2); border-radius: 14px; }
.err { color: var(--cn); font-size: 15px; font-weight: 600; }

.login { min-height: 82dvh; display: grid; align-content: center; gap: 16px; max-width: 400px; margin: auto; }
.login .code { font-size: 26px; text-align: center; letter-spacing: .15em; }
@media (prefers-reduced-motion: no-preference) { .bar > i { transition: width .25s; } }
