:root {
  --paper: #EFEBE1;
  --paper-2: #E7E2D6;
  --ink: #2A2620;
  --muted: #6B655C;
  --teal: #2C5F58;
  --teal-d: #1F4A45;
  --teal-s: #D7E4DF;
  --card: #F6F1E6;
  --line: #D4CFC3;
  --err: #9A4F12;
  --radius: 8px;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
[hidden] { display: none !important; }

html { height: 100%; }
body {
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", sans-serif;
  background: var(--paper);
  color: var(--ink);
  letter-spacing: 0;
  overscroll-behavior: none;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
  opacity: 0.28;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}
body.reordering {
  overflow: hidden;
  touch-action: none;
  user-select: none;
}

.paper {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: max(8px, env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  position: relative;
}
.paper::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.18;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.15' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 120px 120px;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 -16px 14px;
  padding: 10px 16px 12px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 8;
  background: var(--paper);
}
.brand { display: flex; flex-direction: column; gap: 0; }
.brand-name {
  margin: 0;
  font-family: Helvetica, "Helvetica Neue", Arial, sans-serif;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0.01em;
  font-style: normal;
}

.badge {
  font-size: 11px;
  background: var(--teal-s);
  color: var(--teal-d);
  padding: 4px 10px;
  border-radius: 3px;
  font-weight: 700;
}

h1 {
  font-size: 28px;
  margin: 0 0 8px;
  letter-spacing: 0.02em;
  font-weight: 700;
}
.nav {
  display: grid;
  grid-template-columns: 3.2em 1fr 3.2em;
  align-items: center;
  min-height: 44px;
  margin: 0 -8px 10px;
}
.nav h1 { text-align: center; font-size: 17px; margin: 0; letter-spacing: 0.02em; }
.nav .back {
  width: auto;
  padding: 10px 4px;
  font-size: 14px;
  line-height: 1;
  text-align: left;
}

.time-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1.5px solid var(--teal);
  color: var(--teal-d);
  border-radius: 4px;
  padding: 8px 8px 8px 16px;
  box-shadow: var(--shadow);
  margin-bottom: 10px;
}
.time-label { font-size: 13px; font-weight: 700; }
.origin-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1.5px solid var(--line);
  color: var(--ink);
  border-radius: 4px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.origin-pill.ok { border-color: var(--teal); }
.origin-pill.bad { border-color: var(--err); }
.origin-retry {
  margin-left: auto;
  border: 0;
  background: none;
  color: var(--teal);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.stop.fixed {
  border-color: var(--teal);
  background: var(--paper-2);
}
.stop.fixed .drag { display: none; }
.stop.fixed .ord { background: var(--ink); }
.kind-here {
  color: #F6F3EC;
  background: var(--ink);
}
.origin-pill #origin-status {
  font-size: 13px;
  font-weight: 600;
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.origin-pill.bad #origin-status { color: var(--err); }
#geo-msg { margin-top: -8px; margin-bottom: 12px; }

.time-pill input {
  appearance: none;
  border: 0;
  background: var(--teal);
  color: #fff;
  font: inherit;
  font-weight: 700;
  font-size: 16px;
  border-radius: 3px;
  padding: 8px 12px;
  min-width: 7.2em;
}
.time-pill input::-webkit-calendar-picker-indicator { filter: invert(1); opacity: 0.9; }

.token-field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 16px;
  padding: 8px 10px;
  min-height: 52px;
  cursor: text;
}
.token-field:focus-within { border-color: var(--teal); }
.chips { display: contents; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 6px 4px 10px;
  font-size: 13px;
  font-weight: 600;
  animation: pop 0.18s ease-out;
  max-width: 100%;
}
.chip-tag { font-size: 11px; color: var(--teal); font-weight: 700; }
.chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 9em; }
.chip button {
  border: 0;
  background: transparent;
  color: var(--muted);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
}
.ghost-input {
  flex: 1 1 7em;
  min-width: 7em;
  margin: 0;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 16px;
  padding: 8px 4px;
  color: var(--ink);
  outline: none;
}
.ghost-input::placeholder { color: var(--muted); }
.token-field .count {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.hint { margin: 8px 0 0; font-size: 12px; color: var(--muted); min-height: 1em; }

.mic-wrap { text-align: center; margin: 16px 0 4px; }
.mic {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  border: 2px solid var(--teal-d);
  background: var(--teal);
  color: #fff;
  box-shadow: none;
  cursor: pointer;
}
.mic:active { transform: scale(0.97); }
.mic.listening {
  animation: pulse 1.2s ease-out infinite;
  background: var(--teal-d);
}
.mic-caption { margin: 10px 0 0; color: var(--muted); font-size: 13px; font-weight: 600; }
.mic-status {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--muted);
  min-height: 1.2em;
  word-break: break-all;
}

.screen {
  padding-bottom: 8px;
}
.cta {
  width: 100%;
  margin-top: 12px;
  background: var(--teal);
  color: #fff;
  border: 0;
  border-radius: var(--radius);
  padding: 16px;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: none;
  cursor: pointer;
  position: sticky;
  bottom: calc(8px + env(safe-area-inset-bottom));
  z-index: 5;
}
.cta:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.ghost {
  width: 100%;
  margin-top: 10px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font: inherit;
  cursor: pointer;
}

.back {
  border: 0;
  background: none;
  color: var(--teal);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 0;
  cursor: pointer;
}

.resolve-list { display: grid; gap: 16px; }
.block {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
}
.block h2 { margin: 0 0 10px; font-size: 15px; letter-spacing: 0.04em; }
.opt {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 10px 8px;
  border-radius: 4px;
  cursor: pointer;
}
.opt + .opt { border-top: 1px dashed var(--line); }
.opt input { accent-color: var(--teal); margin-top: 4px; }
.opt .name { font-weight: 700; }
.opt .addr { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--teal-d);
  background: var(--teal-s);
  padding: 2px 8px;
  border-radius: 999px;
  align-self: center;
}
.kind {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px 4px 6px;
  border-radius: 3px;
  align-self: center;
  white-space: nowrap;
  line-height: 1;
}
.kind-ico { width: 16px; height: 16px; flex: 0 0 16px; }
.kind-rail { color: #1F4A45; background: #D7E4DF; }
.kind-bus { color: #7A3E0B; background: #E8D7B8; }
.nm-wrap { display: flex; align-items: center; gap: 8px; min-width: 0; }
.nm-wrap .nm { font-weight: 700; }
.nm-wrap .kind { flex: 0 0 auto; }

.route-list { list-style: none; margin: 0; padding: 0; }
.stop {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 8px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
}
.stop .ord {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--teal); color: #fff;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
}
.stop .nm { font-weight: 700; }
.drag {
  border: 0; background: transparent; color: var(--muted);
  font-size: 18px; cursor: grab; padding: 4px 6px;
}
.leg {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 6px 12px 6px 18px;
  color: var(--muted);
  font-size: 13px;
}
.leg .spine {
  width: 2px;
  height: 28px;
  background: var(--teal);
  margin: 0 auto;
  border-radius: 2px;
}
.leg-time { font-size: 12px; font-weight: 700; color: var(--teal-d); }
.map-btn {
  border: 1px solid var(--teal);
  background: #fff;
  color: var(--teal-d);
  border-radius: 3px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 10px;
  text-decoration: none;
  cursor: pointer;
}

.error { color: var(--err); font-size: 13px; margin: 12px 0 0; }
.status { color: var(--muted); font-size: 13px; margin: 12px 0 0; }
.fine { font-size: 12px; color: var(--muted); line-height: 1.5; margin: 10px 4px 0; }
.cta-stack { margin-top: 8px; }

.overlay {
  position: fixed; inset: 0;
  background: rgba(26, 46, 43, 0.45);
  display: grid; place-items: end center;
  padding: 16px;
  z-index: 20;
}
.overlay[hidden] { display: none; }

.overlay-card {
  width: min(430px, 100%);
  background: var(--card);
  border-radius: 8px 8px 4px 4px;
  padding: 20px;
  max-height: 80dvh;
  overflow: auto;
}
.hop-links { display: grid; gap: 8px; }
.hop-links a {
  display: block;
  background: var(--teal-s);
  color: var(--teal-d);
  text-decoration: none;
  border-radius: 12px;
  padding: 14px;
  font-weight: 700;
}



.stop {
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.stop.lifting {
  box-shadow: 0 12px 28px rgba(42, 38, 32, 0.22);
  transform: scale(1.04);
  touch-action: none;
  pointer-events: none;
}
.stop.placeholder {
  background: var(--paper-2);
  border-style: dashed;
  opacity: 0.85;
}
.stop.drop-target {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
}
.route-status {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
}
.drag {
  touch-action: none;
}

@keyframes pop { from { transform: scale(0.92); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pulse {
  0% { box-shadow: none; }
  50% { filter: brightness(0.92); }
  100% { box-shadow: none; }
}


.quick-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  margin: 0 0 12px;
}
.quick-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1.5px solid var(--teal);
  background: #fff;
  color: var(--teal-d);
  border-radius: 4px;
  padding: 5px 12px 5px 6px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  max-width: 100%;
}
.quick-btn.set { background: var(--teal-s); }
.quick-label {
  background: var(--teal);
  color: #fff;
  border-radius: 3px;
  padding: 3px 8px;
  font-size: 11px;
  letter-spacing: 0.04em;
}
.quick-status {
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  max-width: 8.5em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.quick-btn.set .quick-status { color: var(--teal-d); }
.quick-edit {
  border: 0;
  background: none;
  color: var(--teal);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 2px;
  cursor: pointer;
}

.chip-tag {
  font-size: 10px;
  font-weight: 700;
  background: var(--teal);
  color: #fff;
  border-radius: 3px;
  padding: 2px 6px;
  letter-spacing: 0.04em;
}

.sheet-search {
  width: 100%;
  border: 1.5px solid var(--teal);
  background: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  font-size: 16px;
  margin: 4px 0 8px;
  color: var(--ink);
  outline: none;
}
.sheet-search::-webkit-search-cancel-button { -webkit-appearance: none; }
.place-results { display: grid; gap: 0; margin: 4px 0 8px; min-height: 8px; }
.place-opt {
  display: grid;
  gap: 2px;
  text-align: left;
  width: 100%;
  border: 0;
  background: transparent;
  border-top: 1px dashed var(--line);
  padding: 12px 8px;
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  color: inherit;
}
.place-opt:first-child { border-top: 0; }
.place-opt .name { font-weight: 700; }
.place-opt .addr { font-size: 12px; color: var(--muted); }
.place-opt:hover, .place-opt:focus { background: var(--teal-s); outline: none; }

@media (min-width: 720px) {
  .paper { padding-top: 36px; }
}
