/* Route page layout and controls */
:root {
  font-family: "Yu Gothic UI", Meiryo, sans-serif;
  color: #193d35;
  background: #f3f6f5;
  font-size: 16px;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
header {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 24px;
  background: white;
  border-bottom: 1px solid #d4e2dc;
}
h1 {
  font-size: 20px;
  margin: 0;
  flex: 1;
}
header a {
  font-size: 14px;
  color: #09694d;
  text-decoration: none;
}
header strong {
  font-size: 36px;
  color: #09694d;
}
main {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  min-height: calc(100dvh - 77px);
}
#scene {
  min-height: 500px;
  position: relative;
  touch-action: none;
  overflow: hidden;
}
#scene canvas {
  display: block;
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
}
#scene-error {
  position: absolute;
  inset: 25% 24px auto;
  background: white;
  color: #96432c;
  padding: 20px;
  z-index: 2;
  line-height: 1.8;
}
.view-controls {
  position: absolute;
  left: 20px;
  top: 20px;
  display: flex;
  gap: 6px;
  z-index: 1;
}
button,
input {
  font: inherit;
}
button {
  cursor: pointer;
  border: 1px solid #c7d9d0;
  background: white;
  color: #235947;
  border-radius: 8px;
  padding: 12px 14px;
  min-height: 44px;
}
button:disabled {
  opacity: 0.5;
  cursor: default;
}
button[aria-pressed="true"],
button.primary {
  background: #09694d;
  color: white;
  border-color: #09694d;
}
.walk-panel {
  background: #fff;
  padding: 28px 22px;
  z-index: 1;
  overflow: auto;
}
h2 {
  font-size: 20px;
  line-height: 1.6;
  margin: 0 0 14px;
}
.hint {
  display: block;
  font-size: 14px;
  line-height: 1.8;
  color: #61766c;
}
#walk-status {
  background: #e9f3ee;
  border-left: 3px solid #09694d;
  padding: 12px;
  font-size: 16px;
  line-height: 1.75;
}
label {
  display: grid;
  gap: 8px;
  margin: 20px 0;
  font-size: 16px;
  font-weight: 600;
}
label .hint {
  font-weight: 400;
}
input {
  width: 100%;
  min-height: 44px;
  padding: 10px;
  border: 1px solid #b7cec1;
  border-radius: 7px;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.progress-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 20px 0;
  font-size: 14px;
}
progress {
  width: 100%;
  height: 12px;
  accent-color: #09694d;
}
#step-count {
  white-space: nowrap;
}
#choose-route {
  color: #09694d;
}
a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 3px solid #178aca;
  outline-offset: 3px;
}
[hidden] {
  display: none !important;
}
@media (max-width: 700px) {
  header {
    gap: 10px;
    padding: 12px;
  }
  h1 {
    font-size: 16px;
  }
  header strong {
    font-size: 30px;
  }
  main {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  #scene {
    height: 52dvh;
    min-height: 300px;
  }
  .walk-panel {
    padding: 20px 16px;
  }
  .view-controls {
    top: 12px;
    left: 12px;
  }
  .view-controls button {
    font-size: 14px;
    padding: 10px;
  }
  header a {
    font-size: 12px;
  }
}

/* Optional 3D walking view */
body.is-walking {
  overflow: hidden;
}
#stair-arrival {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(340px, calc(100% - 32px));
  max-height: 60dvh;
  overflow: auto;
  padding: 26px 22px;
  border-radius: 20px;
  background: #fffffff5;
  border: 1px solid #d4e2dc;
  box-shadow: 0 12px 40px #17352f40;
  text-align: center;
  pointer-events: auto;
  z-index: 2;
}
#stair-title {
  margin: 0;
  font-size: 24px;
  overflow-wrap: anywhere;
}
#stair-floors {
  margin: 14px 0 22px;
  font-size: 30px;
  font-weight: 800;
}
#stair-confirm {
  width: 100%;
  min-height: 56px;
  font-size: 22px;
}
#arrival-nearby {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid #d4e2dc;
  text-align: left;
}
#arrival-nearby h3 {
  margin: 0 0 10px;
  font-size: 15px;
}
#arrival-nearby-list {
  display: grid;
  gap: 8px;
}
#arrival-nearby-list a {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 10px;
  background: #edf5f0;
  color: #174d3c;
  text-decoration: none;
}
#arrival-nearby-list span {
  color: #557166;
  font-size: 13px;
}
#hud-extra-panel {
  z-index: 3;
}
@media (max-height: 500px) {
  #stair-arrival {
    padding: 14px 18px;
  }
  #stair-floors {
    margin: 6px 0 12px;
    font-size: 24px;
  }
}
.is-walking > header,
.is-walking .walk-panel,
.is-walking .view-controls {
  display: none;
}
.is-walking main {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: block;
  min-height: 0;
  height: 100dvh;
}
.is-walking #scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
}
#walk-hud {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  color: #153e31;
}
.walk-hud-top,
.walk-hud-bottom {
  position: absolute;
  left: max(16px, env(safe-area-inset-left));
  right: max(16px, env(safe-area-inset-right));
  max-width: 620px;
  margin: 0 auto;
  padding: 14px 18px;
  border: 1px solid #ffffffa6;
  border-radius: 14px;
  background: #fffffff2;
  box-shadow: 0 6px 24px #193d3520;
  pointer-events: auto;
}
.walk-hud-top {
  top: max(12px, env(safe-area-inset-top));
}
.walk-hud-bottom {
  bottom: max(12px, env(safe-area-inset-bottom));
}
.walk-hud-place {
  display: flex;
  gap: 16px;
  align-items: center;
}
#hud-floor {
  font-size: 42px;
  line-height: 1;
  color: #09694d;
}
.hud-caption {
  font-size: 12px;
  color: #547363;
}
#hud-location {
  margin: 4px 0 0;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.4;
}
.hud-progress-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
}
#hud-progress-text {
  flex-shrink: 0;
  font-size: 14px;
}
#hud-progress {
  flex: 1;
  min-width: 0;
}
#hud-destination {
  margin: 8px 0 0;
  font-size: 14px;
  color: #547363;
}
#hud-status {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.6;
}
.hud-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.hud-buttons button {
  flex: 1;
  font-size: 14px;
  padding: 10px;
  white-space: nowrap;
}
@media (max-height: 500px) and (min-width: 600px) {
  .walk-hud-top {
    right: auto;
    max-width: 44%;
  }
  .walk-hud-bottom {
    left: auto;
    max-width: 48%;
  }
}
#hud-journey {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
}
#hud-journey li {
  font-size: 13px;
  padding: 5px 9px;
  border-radius: 6px;
  background: #edf2ef;
  color: #62776d;
}
#hud-journey li[aria-current="step"] {
  background: #09694d;
  color: white;
  font-weight: 700;
}
#hud-journey li.passed {
  color: #09694d;
  background: #d9ebdf;
}
#journey-details {
  margin-top: 10px;
  font-size: 14px;
}
#journey-details summary {
  cursor: pointer;
  padding: 5px 0;
  color: #09694d;
}
#journey-instructions {
  max-height: 22dvh;
  overflow: auto;
  margin: 8px 0;
  padding-left: 24px;
  line-height: 1.9;
}
#journey-settings {
  width: min(500px, calc(100% - 28px));
  max-height: 85dvh;
  border: 0;
  border-radius: 14px;
  padding: 24px;
  color: #193d35;
}
#journey-settings::backdrop {
  background: #0e251ec0;
}
#journey-settings label {
  margin: 14px 0;
}
.walk-floor-switch {
  display: flex;
  gap: 5px;
  align-items: center;
}
.walk-floor-switch button {
  min-width: 44px;
  padding: 9px 12px;
  font-size: 14px;
  font-weight: 700;
}
.walk-hud-top > .walk-floor-switch {
  margin-bottom: 12px;
}
.walk-hud-top > .walk-floor-switch button {
  flex: 1;
}
@media (max-width: 700px) {
  body > header {
    flex-wrap: wrap;
  }
  body > header > .walk-floor-switch {
    flex-basis: 100%;
  }
  body > header > .walk-floor-switch button {
    flex: 1;
  }
}
.walk-hud-top {
  padding: 12px 16px;
  max-width: 560px;
}
.walk-hud-top .hud-progress-row {
  margin-top: 0;
}
#hud-next-instruction {
  margin: 9px 0 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
#hud-controls-toggle {
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 5;
  pointer-events: auto;
  box-shadow: 0 3px 14px #193d3520;
  font-size: 14px;
}
#hud-look {
  position: absolute;
  left: max(16px, env(safe-area-inset-left));
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 5;
  min-height: 48px;
  padding: 12px 16px;
  border-color: #9fbdb1;
  background: #fffffff2;
  color: #174d3c;
  pointer-events: auto;
  box-shadow: 0 3px 14px #193d3520;
}
#hud-extra-panel {
  position: absolute;
  top: max(140px, calc(env(safe-area-inset-top) + 120px));
  bottom: calc(max(12px, env(safe-area-inset-bottom)) + 56px);
  left: max(16px, env(safe-area-inset-left));
  right: max(16px, env(safe-area-inset-right));
  max-width: 560px;
  margin: 0 auto;
  padding: 18px;
  overflow: auto;
  border-radius: 14px;
  background: #fffffff5;
  box-shadow: 0 6px 24px #193d3530;
  pointer-events: auto;
}
#hud-extra-panel > .walk-floor-switch {
  margin-bottom: 16px;
}
#hud-extra-panel > .walk-floor-switch button {
  flex: 1;
}
#hud-extra-panel .walk-hud-bottom {
  position: static;
  max-width: none;
  margin-top: 14px;
  padding: 14px 0 0;
  background: none;
  box-shadow: none;
  border: 0;
  border-top: 1px solid #d4e2dc;
  border-radius: 0;
}
@media (max-height: 500px) and (min-width: 600px) {
  .walk-hud-top {
    right: auto;
    max-width: 44%;
  }
  #hud-extra-panel {
    top: 12px;
    left: auto;
    max-width: 48%;
  }
}
@media (max-width: 760px) {
  body > header {
    padding-top: max(12px, env(safe-area-inset-top));
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
  button,
  .walk-floor-switch button,
  header a {
    min-height: 44px;
  }
  header a {
    display: inline-flex;
    align-items: center;
  }
  input {
    font-size: 16px;
  }
  .walk-panel {
    padding-bottom: max(24px, env(safe-area-inset-bottom));
  }
  .walk-hud-top {
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    padding: 10px 12px;
  }
  #hud-controls-toggle {
    min-height: 48px;
    padding: 12px 18px;
  }
  #hud-extra-panel {
    padding: 14px;
    overscroll-behavior: contain;
  }
  .hud-buttons {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .hud-buttons button {
    white-space: normal;
    overflow-wrap: anywhere;
  }
  #journey-settings {
    padding: 18px;
    max-height: calc(
      100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom)
    );
    overflow: auto;
    overscroll-behavior: contain;
  }
  #journey-details summary {
    min-height: 44px;
    padding: 12px 0;
  }
}

#manual-walk-controls {
  position: absolute;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 24px);
  padding: 12px 16px;
  border-radius: 14px;
  background: #fffffff2;
  text-align: center;
  pointer-events: auto;
}
#manual-walk-controls p {
  margin: 0 0 8px;
  font-size: 14px;
}
#manual-walk-controls button {
  min-width: 90px;
  min-height: 44px;
}

/* Flat route map and selection screen */
body {
  padding-bottom: 84px;
}
main {
  min-height: calc(100dvh - 161px);
}
#route-flat,
#route-solid {
  position: absolute;
  inset: 0;
}
#route-flat-map {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  background: #f3f6f5;
}
.flat-zoom {
  position: absolute;
  bottom: 16px;
  right: 16px;
  display: flex;
  gap: 6px;
}
.route-view-dock {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 16px max(12px, env(safe-area-inset-bottom));
  background: white;
  border-top: 1px solid #d4e2dc;
  z-index: 10;
  text-align: center;
}
.route-view-dock button {
  width: min(100%, 560px);
  font-size: 18px;
  font-weight: 700;
}
.is-walking .route-view-dock {
  display: none;
}
#route-directions {
  padding-left: 22px;
  line-height: 1.8;
}
#route-directions li {
  margin-bottom: 10px;
}
#route-solid canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
@media (max-width: 760px) {
  header {
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px;
  }
  #scene {
    min-height: 58dvh;
  }
  .view-controls {
    top: 12px;
    left: 12px;
  }
}

.route-selecting {
  padding-bottom: 0;
}
.route-selecting > header strong,
.route-selecting > header .walk-floor-switch,
.route-selecting #scene,
.route-selecting #walk-hud,
.route-selecting .view-controls,
.route-selecting .route-view-dock,
.route-selecting .walk-panel {
  display: none !important;
}
.route-selecting main {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  min-height: calc(100dvh - 74px);
  padding: 24px 16px max(24px, env(safe-area-inset-bottom));
}
.route-selecting .route-selection {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  width: min(100%, 520px);
  padding: clamp(22px, 5vw, 38px);
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.route-selection-intro {
  display: none;
}
.route-selecting .route-selection-intro {
  display: block;
}
.route-selection-intro h2 {
  margin: 0 0 8px;
  font-size: clamp(22px, 5vw, 30px);
  line-height: 1.35;
}
.route-selection-intro p {
  margin: 0;
  color: var(--secondary);
  line-height: 1.6;
}
.route-selecting .route-selection label {
  margin: 0;
  gap: 8px;
  font-size: 14px;
}
.route-selecting .route-selection select {
  min-height: 54px;
  font-size: 16px;
}
.route-selecting .route-selection > span {
  display: none;
}
.route-selecting .route-selection > button {
  min-height: 54px;
  width: 100%;
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 800;
}
.route-selecting #route-selection-error {
  margin: 0;
}

/* Shared visual styling */
:root {
  font-family:
    -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN",
    "Yu Gothic UI", Meiryo, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}
body > header {
  min-height: 74px;
  gap: 16px;
  border-color: var(--line);
  background: var(--surface);
}
body > header a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 11px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
}
body > header a:hover {
  background: var(--accent-soft);
}
body > header h1 {
  color: var(--ink);
  font-size: 20px;
  letter-spacing: -0.025em;
}
body > header strong {
  color: var(--accent);
}
button {
  min-height: 44px;
  border-color: var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: var(--surface);
}
button:hover:not(:disabled) {
  border-color: var(--accent);
}
button[aria-pressed="true"],
button.primary {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}
.walk-floor-switch button[aria-pressed="true"] {
  color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.walk-panel {
  color: var(--ink);
  background: var(--surface);
}
.hint {
  color: var(--secondary);
}
input {
  border-color: var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: var(--surface-soft);
}
#walk-status {
  border-color: var(--accent);
  color: var(--ink);
  background: var(--accent-soft);
}
progress {
  accent-color: var(--accent);
}
#choose-route {
  color: var(--accent);
}
.flat-zoom button {
  min-width: 44px;
  min-height: 44px;
}
@media (max-width: 700px) {
  body > header {
    padding: 10px 14px;
  }
  body > header a {
    font-size: 13px;
  }
}
@media (prefers-color-scheme: dark) {
  button.primary,
  button[aria-pressed="true"] {
    color: #071f3c;
  }
}

/* Route selection form */
.route-selection {
  grid-column: 1 / -1;
  display: flex;
  align-items: end;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.route-selection label {
  display: grid;
  flex: 1;
  min-width: 0;
  gap: 3px;
  color: var(--secondary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
}
.route-selection select {
  width: 100%;
  min-height: 44px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  background: var(--surface-soft);
  font-size: 14px;
  letter-spacing: 0;
}
.route-selection button {
  min-height: 44px;
  padding-inline: 16px;
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  white-space: nowrap;
}
#route-selection-error {
  flex-basis: 100%;
  margin: 0;
  color: var(--danger);
}
@media (max-width: 760px) {
  body > header h1 {
    font-size: 16px;
    white-space: nowrap;
  }
  body > header strong {
    font-size: 24px;
  }
  body > header [data-platform-link] {
    font-size: 11px;
    white-space: nowrap;
  }
}

/* Route result: keep the map and directions ahead of optional 3D controls. */
.route-selecting #change-route,
body:not(.route-selecting) .route-selection {
  display: none;
}
body:not(.route-selecting) .view-controls,
body:not(.route-selecting) .walk-panel .hint,
body:not(.route-selecting) #walk-status {
  display: none;
}
body:not(.is-walking) #walking-controls {
  display: none;
}
body:not(.route-selecting) .route-view-dock {
  background: transparent;
  border-color: transparent;
}
body:not(.route-selecting) .route-view-dock button {
  width: min(100%, 320px);
  min-height: 48px;
  border: 1px solid var(--accent);
  border-radius: 12px;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 15px;
}
body.single-floor-route > header .walk-floor-switch,
body:not(.single-floor-route):not(.route-selecting) > header strong {
  display: none;
}
@media (max-width: 700px) {
  body:not(.route-selecting) > header {
    gap: 6px 10px;
  }
  body:not(.route-selecting) > header [data-platform-link] {
    display: none;
  }
  body:not(.route-selecting) > header .walk-floor-switch {
    flex-basis: 100%;
    order: 1;
  }
  body:not(.route-selecting):not(.is-walking) #scene {
    height: 42dvh;
    min-height: 320px;
  }
  body:not(.route-selecting) .walk-panel {
    padding: 16px;
  }
}
