.app-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-block: 12px;
}

.shell {
  display: grid;
  grid-template-columns: minmax(320px, 388px) 1fr;
  flex: 1 1 auto;
  min-height: 0;
  height: 0;
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  padding: 24px;
  border-right: 1px solid rgba(167, 177, 161, 0.32);
  background: rgba(250, 248, 242, 0.92);
  backdrop-filter: blur(10px);
}

.panel__content {
  flex: 1 1 0;
  height: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 14px;
  padding-bottom: 12px;
  scrollbar-gutter: stable;
}

.panel__header {
  margin-bottom: 28px;
}

.panel__brand {
  margin-bottom: 22px;
}

.panel h1 {
  margin: 0;
  font-family: var(--rg-font-display);
  font-size: clamp(28px, 3vw, 38px);
  line-height: 1.08;
}

.intro {
  margin: 12px 0 0;
  color: var(--rg-color-text-secondary);
  line-height: 1.7;
}

.panel__section {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid rgba(167, 177, 161, 0.32);
}

.panel__section h2 {
  margin: 0 0 12px;
  font-size: 15px;
}

.section-note {
  margin: 10px 0 0;
  color: var(--rg-color-text-secondary);
  font-size: 13px;
  line-height: 1.6;
}

.panel__section--guide .section-note:first-of-type {
  margin-top: 0;
}

.guide-panel,
.debug-panel {
  overflow: hidden;
}

.guide-panel__summary,
.debug-panel__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
  font-size: 15px;
  font-weight: 700;
}

.guide-panel__summary::-webkit-details-marker,
.debug-panel__summary::-webkit-details-marker {
  display: none;
}

.guide-panel__summary::after,
.debug-panel__summary::after {
  content: "表示";
  flex: 0 0 auto;
  color: var(--rg-color-text-secondary);
  font-size: 12px;
  font-weight: 700;
}

.guide-panel[open] .guide-panel__summary::after,
.debug-panel[open] .debug-panel__summary::after {
  content: "非表示";
}

.guide-panel__body,
.debug-panel__body {
  padding-top: 12px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.segmented__button,
.action-button {
  width: 100%;
}

.segmented__button {
  justify-content: center;
  background: rgba(232, 239, 227, 0.72);
  color: var(--rg-color-text-primary);
}

.segmented__button.is-active {
  border-color: transparent;
  background: linear-gradient(135deg, var(--rg-color-brand-primary), var(--rg-color-brand-primary-hover));
  color: var(--rg-color-text-inverse);
  box-shadow: 0 10px 24px rgba(63, 88, 52, 0.24);
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.status-list {
  display: grid;
  gap: 12px;
  margin: 0;
}

.status-list div {
  padding: 12px 14px;
  border: 1px solid rgba(167, 177, 161, 0.22);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.68);
}

.status-list dt {
  margin: 0 0 6px;
  color: var(--rg-color-text-secondary);
  font-size: 12px;
  font-weight: 700;
}

.status-list dd {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.debug-panel__body {
  min-height: 0;
}

.debug-panel[open] .debug-panel__body {
  max-height: none;
  overflow: visible;
  padding-right: 0;
}

.debug-panel .status-list {
  margin-top: 14px;
}

.debug-panel .message {
  margin-top: 14px;
}

.message {
  min-height: 22px;
  margin-top: 18px;
  padding: 10px 12px;
  border-radius: 12px;
  background: transparent;
  color: var(--rg-color-text-secondary);
  font-size: 13px;
  line-height: 1.6;
}

.message:empty {
  display: none;
}

.message.is-info {
  background: rgba(47, 91, 120, 0.1);
  color: #214651;
}

.message.is-success {
  background: rgba(60, 104, 72, 0.12);
  color: #234d33;
}

.message.is-error {
  background: rgba(154, 60, 52, 0.12);
  color: #7c1f19;
}

.panel__legal {
  flex: 0 0 auto;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(167, 177, 161, 0.24);
}

.panel__legal-note {
  margin: 0;
  color: rgba(89, 101, 93, 0.92);
  font-size: 11px;
  line-height: 1.6;
}

.panel__legal-note + .panel__legal-note {
  margin-top: 6px;
}

.panel__legal a {
  color: var(--rg-color-link);
  text-decoration-color: rgba(89, 101, 93, 0.4);
  text-underline-offset: 2px;
}

.stage {
  position: relative;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0));
}

.map {
  position: absolute;
  inset: 0;
}

.crosshair {
  position: absolute;
  inset: 0;
  z-index: 900;
  pointer-events: none;
}

.crosshair__h,
.crosshair__v,
.crosshair__dot {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.crosshair__h {
  width: 32px;
  height: 2px;
  background: rgba(31, 41, 35, 0.55);
}

.crosshair__v {
  width: 2px;
  height: 32px;
  background: rgba(31, 41, 35, 0.55);
}

.crosshair__dot {
  width: 10px;
  height: 10px;
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: 50%;
  background: var(--rg-color-status-danger);
  box-shadow: 0 0 0 4px rgba(154, 60, 52, 0.18);
}

.guide-overlay {
  position: absolute;
  inset: 0;
  z-index: 850;
  pointer-events: none;
}

.loading-indicator {
  position: absolute;
  inset: 0;
  z-index: 1100;
  display: grid;
  place-items: center;
  background: rgba(245, 245, 241, 0.36);
  backdrop-filter: blur(2px);
}

.loading-indicator[hidden] {
  display: none !important;
}

.loading-indicator__content {
  min-width: 220px;
  padding: 22px 24px;
  border-radius: var(--rg-radius-lg);
  background: rgba(31, 41, 35, 0.82);
  color: #fffdf9;
  text-align: center;
  box-shadow: var(--rg-shadow-soft);
}

.loading-indicator__text {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
}

.loading-indicator__spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto;
  border: 4px solid rgba(255, 253, 249, 0.22);
  border-top-color: #fffdf9;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.leaflet-container {
  background: #eef1eb;
  font-family: var(--rg-font-ui);
}

.leaflet-control-zoom {
  border: 0;
  box-shadow: var(--rg-shadow-card);
}

.leaflet-control-zoom a {
  color: var(--rg-color-text-primary);
}

.export-host {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  overflow: visible;
  opacity: 0;
  pointer-events: none;
}

.export-surface {
  position: relative;
  overflow: hidden;
  background: #f5f0e6;
}

.export-map {
  position: relative;
  width: 100%;
  height: 100%;
}

@media (max-width: 760px) {
  .app-page {
    padding-block: 10px;
    gap: 10px;
  }

  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: auto;
  }

  .panel {
    height: auto;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid rgba(167, 177, 161, 0.32);
  }

  .panel__content {
    overflow: visible;
  }

  .stage {
    height: auto;
    min-height: 66vh;
  }
}

@media (max-width: 640px) {
  .panel {
    padding: 18px;
  }

  .action-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 761px) {
  .app-page {
    min-height: 100dvh;
    height: 100dvh;
  }

  .shell {
    min-height: 0;
    height: auto;
  }

  .panel,
  .stage {
    height: 100%;
  }
}

.segmented__button.is-active {
  border-color: var(--rg-color-brand-primary-border);
  background: rgba(232, 239, 227, 0.92);
  color: var(--rg-color-brand-primary-hover);
  box-shadow: inset 0 0 0 1px rgba(77, 107, 63, 0.14);
}

@media (max-width: 760px) {
  .app-page {
    min-height: auto;
    height: auto;
    overflow: visible;
  }

  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto;
    gap: 14px;
    flex: 0 0 auto;
    min-height: 0;
    height: auto;
  }

  .panel {
    min-height: 0;
    height: auto;
    overflow: visible;
    border-right: 0;
    border-bottom: 0;
    padding-bottom: 0;
  }

  .panel__content {
    flex: 0 0 auto;
    height: auto;
    min-height: 0;
    overflow: visible;
    padding-right: 0;
    padding-bottom: 0;
  }

  .panel__legal {
    position: static;
    margin-top: 0;
    padding: 16px 24px 0;
    border-top: 1px solid rgba(167, 177, 161, 0.24);
    background: rgba(250, 248, 242, 0.92);
  }

  .shell > .debug-panel {
    margin-top: 0;
    padding: 16px 24px 0;
    border-top: 1px solid rgba(167, 177, 161, 0.24);
    background: rgba(250, 248, 242, 0.92);
  }

  .stage {
    position: relative;
    min-height: 300px;
    height: clamp(300px, 46dvh, 420px);
    overflow: hidden;
  }

  .map {
    position: absolute;
    inset: 0;
  }

  .guide-panel__summary {
    cursor: pointer;
  }
}

@media (max-width: 640px) {
  .app-page {
    padding-block: 10px;
    gap: 10px;
  }

  .panel {
    padding: 18px;
  }

  .panel__header {
    margin-bottom: 18px;
  }

  .intro {
    margin-top: 8px;
    font-size: 13px;
    line-height: 1.6;
  }

  .panel__content {
    padding-right: 0;
  }

  .panel__section {
    margin-top: 16px;
    padding-top: 14px;
  }

  .guide-panel__summary,
  .debug-panel__summary {
    font-size: 14px;
  }

  .section-note {
    margin-top: 8px;
    font-size: 12px;
    line-height: 1.5;
  }

  .panel__legal {
    padding: 14px 18px 0;
  }

  .stage {
    min-height: 260px;
    height: clamp(260px, 42dvh, 340px);
  }

  .action-grid {
    grid-template-columns: 1fr;
  }
}
