/* Tabi design system.
   Washi ground, ai-iro (indigo) ink, shu-iro (vermilion) for the one main action per screen.
   Token names stay the same in dark mode; their values flip for night drives. */

@font-face {
  font-family: 'Zen Kaku Gothic New';
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/zen-kaku-gothic-new-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Zen Kaku Gothic New';
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/zen-kaku-gothic-new-latin-700-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Shippori Mincho B1';
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/shippori-mincho-b1-latin-700-normal.woff2') format('woff2');
}

:root {
  color-scheme: light dark;

  /* Colour */
  --washi: #F7F2E7;        /* page ground */
  --washi-2: #EFE7D6;      /* raised surface, kinari */
  --line: #DCD1BB;         /* rules and borders */
  --ai: #1C2F4D;           /* ink: text, headings, icons */
  --ai-2: #55657E;         /* secondary text */
  --shu: #C2381C;          /* main action only */
  --on-shu: #FFFFFF;
  --focus: #2E6DB4;
  --scrim: rgb(14 22 38 / 0.45);
  --seigaiha: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='20'%3E%3Cg fill='%23F7F2E7' stroke='%231C2F4D' stroke-opacity='0.13' stroke-width='1.1'%3E%3Ccircle cx='0' cy='0' r='19.5'/%3E%3Ccircle cx='0' cy='0' r='14.5'/%3E%3Ccircle cx='0' cy='0' r='9.5'/%3E%3Ccircle cx='0' cy='0' r='4.5'/%3E%3Ccircle cx='40' cy='0' r='19.5'/%3E%3Ccircle cx='40' cy='0' r='14.5'/%3E%3Ccircle cx='40' cy='0' r='9.5'/%3E%3Ccircle cx='40' cy='0' r='4.5'/%3E%3Ccircle cx='20' cy='10' r='19.5'/%3E%3Ccircle cx='20' cy='10' r='14.5'/%3E%3Ccircle cx='20' cy='10' r='9.5'/%3E%3Ccircle cx='20' cy='10' r='4.5'/%3E%3Ccircle cx='0' cy='20' r='19.5'/%3E%3Ccircle cx='0' cy='20' r='14.5'/%3E%3Ccircle cx='0' cy='20' r='9.5'/%3E%3Ccircle cx='0' cy='20' r='4.5'/%3E%3Ccircle cx='40' cy='20' r='19.5'/%3E%3Ccircle cx='40' cy='20' r='14.5'/%3E%3Ccircle cx='40' cy='20' r='9.5'/%3E%3Ccircle cx='40' cy='20' r='4.5'/%3E%3C/g%3E%3C/svg%3E");

  /* Type */
  --font-body: 'Zen Kaku Gothic New', 'Noto Sans JP', 'Noto Sans CJK JP', system-ui, sans-serif;
  --font-display: 'Shippori Mincho B1', 'Noto Serif JP', 'Noto Serif CJK JP', Georgia, serif;
  --text-sm: 15px;
  --text: 17px;
  --text-lg: 20px;
  --text-time: 24px;       /* key times: 22px or more */
  --text-h2: 24px;
  --text-h1: 34px;

  /* Space and shape */
  --gap: 20px;
  --tap: 48px;
  --radius: 14px;
  --header-h: 60px;
  --nav-h: 68px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --washi: #0F1828;
    --washi-2: #18233A;
    --line: #2A3852;
    --ai: #ECE4D2;
    --ai-2: #A3AEC0;
    --shu: #F0623F;
    --on-shu: #1B0A04;
    --focus: #8AB8F0;
    --scrim: rgb(0 0 0 / 0.6);
    --seigaiha: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='20'%3E%3Cg fill='%230F1828' stroke='%23ECE4D2' stroke-opacity='0.1' stroke-width='1.1'%3E%3Ccircle cx='0' cy='0' r='19.5'/%3E%3Ccircle cx='0' cy='0' r='14.5'/%3E%3Ccircle cx='0' cy='0' r='9.5'/%3E%3Ccircle cx='0' cy='0' r='4.5'/%3E%3Ccircle cx='40' cy='0' r='19.5'/%3E%3Ccircle cx='40' cy='0' r='14.5'/%3E%3Ccircle cx='40' cy='0' r='9.5'/%3E%3Ccircle cx='40' cy='0' r='4.5'/%3E%3Ccircle cx='20' cy='10' r='19.5'/%3E%3Ccircle cx='20' cy='10' r='14.5'/%3E%3Ccircle cx='20' cy='10' r='9.5'/%3E%3Ccircle cx='20' cy='10' r='4.5'/%3E%3Ccircle cx='0' cy='20' r='19.5'/%3E%3Ccircle cx='0' cy='20' r='14.5'/%3E%3Ccircle cx='0' cy='20' r='9.5'/%3E%3Ccircle cx='0' cy='20' r='4.5'/%3E%3Ccircle cx='40' cy='20' r='19.5'/%3E%3Ccircle cx='40' cy='20' r='14.5'/%3E%3Ccircle cx='40' cy='20' r='9.5'/%3E%3Ccircle cx='40' cy='20' r='4.5'/%3E%3C/g%3E%3C/svg%3E");
  }
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--washi);
  color: var(--ai);
  font: 400 var(--text)/1.55 var(--font-body);
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; line-height: 1.2; margin: 0; text-wrap: balance; }
h1 { font-size: var(--text-h1); letter-spacing: 0.005em; }
h2 { font-size: var(--text-h2); }
h3 { font-size: var(--text-lg); }
p { margin: 0; }
a { color: inherit; }
svg.i { width: 24px; height: 24px; flex: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

/* Header: the only place the seigaiha appears */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: calc(var(--header-h) + var(--safe-top));
  padding: var(--safe-top) 6px 0 var(--gap);
  background: var(--washi);
  border-bottom: 1px solid var(--line);
  isolation: isolate;
}
.top::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--seigaiha) right bottom / 40px 20px;
  -webkit-mask-image: linear-gradient(to right, transparent 10%, #000 85%);
  mask-image: linear-gradient(to right, transparent 10%, #000 85%);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  min-width: 0;
  margin-right: auto;
  text-decoration: none;
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
}
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand .mark { width: 30px; height: 24px; flex: none; }
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px 4px 10px;
  border-radius: 999px;
  background: var(--washi-2);
  border: 1px solid var(--line);
  font-size: var(--text-sm);
  font-weight: 700;
  white-space: nowrap;
}
.status:empty { display: none; }
.status svg.i { width: 18px; height: 18px; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ai);
  cursor: pointer;
}

/* Screen area */
main {
  display: block;
  max-width: 640px;
  margin: 0 auto;
  padding: 28px var(--gap) calc(var(--nav-h) + var(--safe-bottom) + 40px);
}
main:focus { outline: none; }
.view > * + * { margin-top: 16px; }
.view > h1 + * { margin-top: 10px; }
.muted { color: var(--ai-2); }
.lede { font-size: var(--text-lg); line-height: 1.45; }
.time { font-size: var(--text-time); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.card {
  padding: 18px var(--gap);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--washi-2);
}
.card > * + * { margin-top: 8px; }
.stack > * + * { margin-top: 12px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 22px;
  border: 1.5px solid var(--ai);
  border-radius: 12px;
  background: transparent;
  color: var(--ai);
  font: 700 var(--text)/1.2 var(--font-body);
  text-decoration: none;
  cursor: pointer;
}
.btn-primary { background: var(--shu); border-color: var(--shu); color: var(--on-shu); }
.btn-block { display: flex; width: 100%; }

/* Bottom navigation */
.tabs {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding-bottom: var(--safe-bottom);
  background: var(--washi);
  border-top: 1px solid var(--line);
}
.tabs a {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: var(--nav-h);
  color: var(--ai-2);
  font-size: 14px;
  font-weight: 400;
  text-decoration: none;
}
.tabs svg.i { width: 26px; height: 26px; }
.tabs a[aria-current='page'] { color: var(--ai); font-weight: 700; }
.tabs a[aria-current='page'] svg.i { stroke-width: 2.4; }
/* Active tab: a short ink bar, like a noren rod */
.tabs a[aria-current='page']::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 50%;
  width: 36px;
  height: 4px;
  margin-left: -18px;
  border-radius: 0 0 4px 4px;
  background: var(--ai);
}

/* Update banner */
.update {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 12px);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--radius);
  background: var(--ai);
  color: var(--washi);
  font: 700 var(--text)/1.3 var(--font-body);
  text-align: left;
  cursor: pointer;
}

/* Toasts */
.toasts {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 12px);
  z-index: 30;
  display: grid;
  justify-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  max-width: 100%;
  padding: 14px 20px;
  border-radius: 12px;
  background: var(--ai);
  color: var(--washi);
  font-weight: 700;
  animation: rise 180ms ease-out;
}
body:has(.update) .toasts { bottom: calc(var(--nav-h) + var(--safe-bottom) + 80px); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* Bottom sheet */
.sheet {
  width: 100%;
  max-width: 640px;
  max-height: 88dvh;
  margin: auto auto 0;
  padding: 20px var(--gap) calc(28px + var(--safe-bottom));
  border: 0;
  border-radius: 20px 20px 0 0;
  background: var(--washi);
  color: var(--ai);
  overflow: auto;
}
.sheet::backdrop { background: var(--scrim); }
.sheet[open] { animation: rise 200ms ease-out; }
.sheet:focus { outline: none; }
.sheet-close { position: absolute; top: 12px; right: 10px; }

/* Full-screen sheet: the Japanese address for staff or a taxi driver */
.sheet-full {
  max-width: none;
  max-height: none;
  height: 100dvh;
  margin: 0;
  border-radius: 0;
  padding-top: calc(16px + var(--safe-top));
}
.ja-sheet { display: grid; gap: 20px; padding-top: 40px; }
.ja-name { font-size: 28px; font-weight: 700; line-height: 1.3; }
.ja-big { font-size: 40px; font-weight: 700; line-height: 1.45; word-break: break-all; }
.ja-phone { font-size: var(--text-time); font-weight: 700; font-variant-numeric: tabular-nums; }
.ja-empty { font-family: var(--font-display); font-size: 28px; font-weight: 700; line-height: 1.3; }
.ja-sheet .btn { justify-self: start; }

/* Screen pieces shared by Today, Trip, Day and Stays */
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.view > section > h2 { font-size: var(--text-lg); margin-bottom: 10px; }
.view > section { margin-top: 28px; }
.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ai-2);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.02em;
}
.eyebrow svg.i { width: 20px; height: 20px; }
.view > .eyebrow + h1 { margin-top: 4px; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; color: var(--ai-2); }
.meta > span { display: inline-flex; align-items: center; gap: 6px; }
.meta svg.i { width: 20px; height: 20px; }
p.meta { gap: 8px; }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.btn-small { min-height: var(--tap); padding: 0 16px; font-size: var(--text-sm); gap: 8px; }
.btn-small svg.i { width: 20px; height: 20px; }
.btn-quiet { border-color: transparent; color: var(--ai-2); }
.btn[disabled], .icon-btn[disabled] { opacity: 0.3; cursor: default; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.actions .btn { flex: 1 1 auto; }
.back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: var(--tap);
  margin: -12px 0 0 -6px;
  color: var(--ai-2);
  font-weight: 700;
  text-decoration: none;
}
.link-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap);
  font-weight: 700;
  text-decoration: none;
}
.link-row svg.i { width: 20px; height: 20px; }
.chip {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--washi);
  font-size: var(--text-sm);
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
}
.card > .chip { justify-self: start; }
.chip-booked { border-color: var(--ai-2); }
.chip-not-booked, .chip-opens-soon { border-color: var(--shu); color: var(--shu); }
.chip-today { margin-left: 8px; background: var(--ai); border-color: var(--ai); color: var(--washi); vertical-align: 2px; }

/* Today */
.countdown { font-size: var(--text-lg); font-weight: 700; }
.countdown-num { font-family: var(--font-display); font-size: 64px; line-height: 1; font-variant-numeric: tabular-nums; }
.when { font-size: var(--text-lg); font-weight: 700; }
.preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 4px 4px 14px;
  border: 1px dashed var(--ai-2);
  border-radius: 12px;
  font-weight: 700;
}
.preview .btn { margin-left: auto; }
.leave { border: 2px solid var(--ai); }
.leave .time-xl { font-size: 48px; font-weight: 700; line-height: 1.05; font-variant-numeric: tabular-nums; }
.leave .eyebrow { font-size: var(--text); color: var(--ai); }
.leave-name { font-size: var(--text-lg); font-weight: 700; line-height: 1.35; }
.leave .btn { margin-top: 16px; }
.food { display: flex; gap: 12px; align-items: flex-start; }
.food > * + * { margin-top: 0; }
.stay-name { display: flex; align-items: center; gap: 10px; font-size: var(--text-lg); font-weight: 700; line-height: 1.35; }
.stay .actions { margin-top: 16px; }
.stay .actions .btn { flex: 1 1 100%; }

/* Stop lists (Today and Day) */
.stops { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.stop {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.stop-icon { padding-top: 2px; color: var(--ai-2); }
.stop-body { min-width: 0; }
.stop-body > * + * { margin-top: 2px; }
.stop-time { font-size: var(--text-time); font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stop-name { font-weight: 700; font-size: var(--text-lg); line-height: 1.35; }
.nav-btn { margin: -6px -8px 0 0; }
.wish { margin-top: 10px; padding: 10px 14px; border-left: 3px solid var(--ai); background: var(--washi-2); border-radius: 0 10px 10px 0; }
.wish-head { font-size: var(--text-sm); font-weight: 700; color: var(--ai-2); }
.wish ul { margin: 4px 0 0; padding-left: 20px; }
.stop-edit { grid-template-columns: 28px 1fr; }
.stop-tools { grid-column: 2; display: flex; gap: 4px; margin: 2px 0 -6px -12px; }
.stop-tools .icon-btn { border-radius: 12px; }
.stop-tools .btn-small { margin-left: auto; border-color: var(--line); }
.stops + .btn { margin-top: 16px; }

/* Trip list */
.days { list-style: none; margin: 16px 0 0; padding: 0; border-top: 1px solid var(--line); }
.day-row {
  display: grid;
  grid-template-columns: 52px 1fr 20px;
  gap: 14px;
  align-items: center;
  min-height: 72px;
  padding: 12px 6px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}
.day-row[aria-current='date'] {
  margin: -1px -10px 0;
  padding: 14px 16px 14px 12px;
  border: 2px solid var(--ai);
  border-radius: var(--radius);
  background: var(--washi-2);
}
.day-date { display: grid; text-align: center; line-height: 1.2; }
.dow { font-size: var(--text-sm); color: var(--ai-2); font-weight: 700; }
.dnum { font-size: var(--text); font-weight: 700; white-space: nowrap; }
.day-body { display: grid; gap: 2px; min-width: 0; }
.day-title { font-weight: 700; font-size: var(--text-lg); line-height: 1.3; }
.day-plan { color: var(--ai-2); font-size: var(--text-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day-row .meta { font-size: var(--text-sm); gap: 2px 14px; }
.day-row .meta svg.i { width: 18px; height: 18px; }
svg.chev { width: 20px; height: 20px; color: var(--ai-2); }

/* Day detail */
.facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; }
.facts dt { color: var(--ai-2); font-weight: 700; font-size: var(--text-sm); padding-top: 2px; }
.facts dd { margin: 0; }
.card > .btn-small { margin-top: 14px; }

/* Stays */
.stays { list-style: none; margin: 20px 0 0; padding: 0; display: grid; gap: 14px; }
.stay-row { display: grid; gap: 6px; }
.stay-row > * + * { margin-top: 0; }
.stay-row h2 { display: flex; align-items: center; gap: 10px; font-size: var(--text-lg); }
.stay-row .chip { justify-self: start; }
.stay-row .btn { margin-top: 8px; }

/* Forms */
.form { display: grid; gap: 18px; }
.form h2 { padding-right: 48px; }
.field { display: grid; gap: 6px; }
.field label { font-weight: 700; }
.label-lg { font-family: var(--font-display); font-size: var(--text-lg); }
.hint { font-size: var(--text-sm); margin-top: -4px; }
input, select, textarea {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--washi-2);
  color: var(--ai);
  font: 400 var(--text)/1.4 var(--font-body);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--ai); outline: none; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.error { color: var(--shu); font-weight: 600; margin-top: -4px; }
.error[hidden] { display: none; }
