:root {
  --surface-base: #ffffff;
  --surface-subtle: #f2f2ef;
  --surface-card: #ffffff;
  --text-primary: #353535;
  --text-secondary: #969696;
  --accent-main: #5e7d90;
  --accent-alert: #e37a7a;
  --line: #d8d8d8;
  --status-connected: #81ba45;
  --status-disconnected: #ca697a;
  --shadow-soft: 0 2px 10px rgba(32, 29, 27, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --surface-base: #111111;
    --surface-subtle: #2b2b2b;
    --surface-card: #2b2b2b;
    --text-primary: #ffffff;
    --text-secondary: #969696;
    --accent-main: #31556c;
    --accent-alert: #ca697a;
    --line: #4d4842;
    --status-connected: #99c970;
    --status-disconnected: #e58ca2;
    --shadow-soft: 0 2px 10px rgba(0, 0, 0, 0.35);
  }

  .brand-logo,
  .status-icon {
    /* External SVG via <img> cannot be filled directly; force white rendering in dark mode. */
    filter: brightness(0) saturate(100%) invert(100%);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Kaku Gothic Pro", "Yu Gothic", "Helvetica Neue", Arial, sans-serif;
  color: var(--text-primary);
  background: var(--surface-subtle);
}

.page-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 14px 10px 28px;
}

.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.locale-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.locale-trigger {
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.locale-caret {
  font-size: 11px;
  transform: translateY(-1px);
}

.locale-current {
  min-width: 20px;
  text-align: left;
}

.locale-globe {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.locale-globe svg {
  width: 14px;
  height: 14px;
}

.locale-menu {
  position: absolute;
  top: 22px;
  left: 0;
  background: var(--surface-base);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  padding: 4px;
  display: grid;
  gap: 2px;
  min-width: 62px;
  z-index: 20;
}

.locale-option {
  border: none;
  background: transparent;
  color: var(--text-primary);
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  font-weight: 700;
  font-size: 13px;
  padding: 6px 8px;
}

.locale-option:hover,
.locale-option.active {
  background: var(--surface-subtle);
}

.brand-logo {
  width: 76px;
  height: auto;
}

.status-banner {
  background: var(--accent-alert);
  color: #ffffff;
  border-radius: 16px;
  padding: 10px 12px 8px;
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
}

.status-banner p {
  margin: 0;
  max-width: 100%;
  font-size: 15px;
  line-height: 1.35;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: pre-line;
  word-break: keep-all;
}

.pill-btn {
  border: none;
  border-radius: 999px;
  background: var(--accent-main);
  color: #ffffff;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  padding: 10px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.safety-jump-btn {
  background: #ffffff;
  color: #e37a7a;
  min-width: 130px;
  justify-self: end;
  padding: 5px 14px;
  font-size: 11px;
}

.connection-banner {
  display: none;
  border-radius: 12px;
  margin-bottom: 8px;
  padding: 8px 10px;
  background: #d7c339;
  color: #171311;
  font-size: 12px;
}

.connection-banner.is-visible {
  display: block;
}

.map-section {
  position: relative;
}

.map-wrapper {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

#map {
  width: 100%;
  height: 48vh;
  min-height: 368px;
}

.icon-btn {
  border: none;
  cursor: pointer;
  background: transparent;
  color: var(--accent-main);
}

.map-expand-btn {
  position: absolute;
  left: 10px;
  bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 8px;
  background: var(--surface-base);
  box-shadow: var(--shadow-soft);
}

.map-expand-btn .icon-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
}

.map-expand-btn svg,
.copy-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}

.hidden {
  display: none !important;
}

.summary-address-link-row {
  padding-top: 2px;
  padding-bottom: 4px;
}

.summary-address-link-row .summary-value-wrap {
  justify-content: end;
  justify-items: end;
}

.show-address-link {
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-main);
  text-decoration: underline;
  text-decoration-skip-ink: auto;
  letter-spacing: -0.02em;
}

.show-address-link:hover {
  text-decoration-thickness: 2px;
}

.show-address-link:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (prefers-color-scheme: dark) {
  .show-address-link {
    color: #8ab4c9;
  }

  .show-address-link:hover {
    color: #a0c5d9;
  }
}

.address-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.4);
}

.address-dialog {
  background: var(--surface-card);
  border-radius: 16px;
  box-shadow: var(--shadow-soft);
  padding: 18px 16px;
  width: min(100%, 360px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.address-dialog-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.address-dialog-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
}

.address-dialog-text {
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
  color: var(--text-primary);
  min-width: 0;
}

.address-dialog-copy {
  width: 24px;
  height: 24px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.address-dialog-copy svg {
  width: 18px;
  height: 18px;
}

.address-dialog-close {
  align-self: stretch;
  font-size: 14px;
}

.map-open-btn {
  margin-top: 10px;
  width: 100%;
}

.card {
  background: var(--surface-card);
  border-radius: 16px;
  box-shadow: var(--shadow-soft);
  padding: 14px 12px;
  margin-top: 10px;
}

.tab-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--line);
  border-radius: 999px;
  padding: 2px;
  margin-bottom: 14px;
}

.tab-btn {
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  min-height: 26px;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--accent-main);
  color: #ffffff;
}

.tab-panel {
  width: 100%;
}

.tab-panel#summaryPanel {
  --summary-label-col: 88px;
}

.summary-row {
  display: grid;
  grid-template-columns: var(--summary-label-col) minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 7px 0;
}

.summary-row.two-col {
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.summary-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.summary-value-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.summary-value {
  font-size: 12px;
  line-height: 1.4;
  word-break: break-word;
  min-width: 0;
}

.summary-coord-row .summary-value {
  font-size: 12px;
}

.summary-head-row {
  padding-top: 10px;
  padding-bottom: 2px;
}

.right-label {
  text-align: right;
}

.summary-row.two-col.summary-state-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
  padding-top: 3px;
  padding-bottom: 8px;
  column-gap: 8px;
}

.status-main {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
  align-self: center;
}

.copy-btn {
  width: 24px;
  height: 24px;
  color: var(--text-secondary);
  justify-self: end;
}

.status-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.status-icon {
  width: 36px;
  height: 36px;
}

.speed-inline-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 12px;
  line-height: 1.25;
  min-width: 0;
  justify-self: center;
  align-self: center;
}

#speedInline {
  font-weight: 700;
  white-space: pre-line;
  line-height: 1.15;
}

.speed-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--status-connected);
}

.speed-arrow svg {
  width: 24px;
  height: 24px;
  display: block;
}

.device-status-wrap {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  justify-self: end;
  text-align: right;
  min-height: 0;
  align-self: center;
}

.device-status.connected {
  color: var(--status-connected);
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
  line-height: 1.15;
}

.device-status.disconnected {
  color: var(--status-disconnected);
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
  line-height: 1.15;
}

.summary-elapsed-row {
  border-top: 1px solid var(--line);
  margin-top: 2px;
  padding-top: 10px;
  grid-template-columns: var(--summary-label-col) minmax(0, 1fr);
}

.summary-time-row {
  margin-top: 2px;
  padding-top: 10px;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.time-item {
  min-width: 0;
}

.elapsed-label {
  font-size: 11px;
  white-space: normal;
  margin-bottom: 2px;
}

.elapsed-value {
  font-size: 18px;
  font-weight: 700;
  text-align: left;
  letter-spacing: 0.01em;
}

.timeline-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.timeline-item {
  display: grid;
  grid-template-columns: 110px 1fr 1fr 1.2fr;
  gap: 6px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
}

.timeline-time {
  font-size: 12px;
  font-weight: 700;
}

.timeline-event {
  display: block;
  margin-top: 3px;
}

.ended-card h2,
.guidance-card h2 {
  font-size: 20px;
  margin: 0 0 10px;
}

.ended-card p,
.guidance-card p {
  margin: 0 0 8px;
  font-size: 13px;
  line-height: 1.45;
}

.guidance-btn {
  width: 100%;
  margin-top: 10px;
}

.map-wrapper.is-fullscreen {
  border-radius: 0;
}

body.no-scroll {
  overflow: hidden;
}

.map-wrapper.is-pseudo-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  border-radius: 0;
  background: var(--surface-base);
}

.map-wrapper.is-pseudo-fullscreen #map {
  height: 100dvh;
  min-height: 100dvh;
}

@media (min-width: 768px) {
  .page-shell {
    width: min(100%, 1160px);
    padding: 16px 18px 36px;
  }

  .active-card {
    padding: 16px 20px;
  }

  #map {
    height: 60vh;
    min-height: 483px;
  }

  .timeline-item {
    grid-template-columns: 140px 1fr 1fr 1.5fr;
    font-size: 12px;
  }
}

@media (min-width: 1024px) {
  .content-grid {
    display: grid;
    grid-template-columns: 1.35fr 1fr;
    gap: 12px;
  }

  #map {
    height: 67vh;
  }
}



