:root {
  --bg: #0a101a;
  --panel: #121c2a;
  --panel-2: #172338;
  --text: #f3f6fa;
  --muted: #9aa8bd;
  --accent: #4cc9f0;
  --danger: #ff4d6d;
  --border: #2a3a52;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Noto Sans", "Helvetica Neue", sans-serif;
}

body.modal-open {
  overflow: hidden;
}

a { color: var(--accent); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.brand {
  margin: 0;
  display: flex;
  align-items: center;
}

.brand-logo {
  display: block;
  height: 36px;
  width: auto;
}

.offline-banner {
  padding: 10px 12px;
  text-align: center;
  background: #7d2e2e;
  color: #fff;
  font-weight: 700;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 950;
}

.report-page {
  min-height: 100vh;
}

.map-shell {
  position: relative;
  min-height: 100vh;
}

#map {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

.floating-head {
  position: fixed;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 550;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(10, 16, 26, 0.92);
  backdrop-filter: blur(8px);
  overflow: visible;
}

.floating-head h1 {
  margin: 0;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-menu {
  width: auto;
  min-width: 44px;
  min-height: 44px;
  padding: 8px 11px;
  font-size: 1.15rem;
  background: #1f304d;
}

.site-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 690;
  min-width: 220px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(10, 16, 26, 0.96);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}

.site-menu[hidden] {
  display: none !important;
}

.menu-item-btn {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 11px 12px;
  text-decoration: none;
  color: #e5efff;
  border-bottom: 1px solid #283a54;
  font-size: 0.95rem;
  cursor: pointer;
}

.menu-item-btn:last-child {
  border-bottom: 0;
}

.menu-item-btn:hover,
.menu-item-btn:focus-visible {
  background: rgba(47, 111, 237, 0.18);
  outline: none;
}

.map-actions {
  position: fixed;
  right: 12px;
  top: 92px;
  width: min(48vw, 220px);
  z-index: 560;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.map-actions .btn {
  min-height: 36px;
  padding: 7px 10px;
  font-size: 0.9rem;
}

.geo-status {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 86px;
  z-index: 560;
  background: rgba(10, 16, 26, 0.92);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.9rem;
}

.map-direction-confirm {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 138px;
  z-index: 565;
  border: 1px solid #3f6ea0;
  border-radius: 12px;
  background: rgba(12, 24, 39, 0.95);
  box-shadow: var(--shadow);
  padding: 10px;
}

.map-direction-confirm-title {
  font-size: 0.98rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.map-direction-confirm-title strong {
  color: #e7f0ff;
}

.map-direction-confirm-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.map-direction-confirm-actions .btn {
  min-height: 44px;
}

.report-trigger {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 600;
  border: 1px solid #ff7f95;
  background: var(--danger);
  color: #fff;
  border-radius: 14px;
  min-height: 58px;
  font-size: 1.15rem;
  font-weight: 800;
  box-shadow: var(--shadow);
}

.sent-notice {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 84px;
  z-index: 620;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(6, 60, 42, 0.94);
  border: 1px solid rgba(37, 200, 141, 0.75);
  color: #ffffff;
  font-size: 0.95rem;
  line-height: 1.35;
  box-shadow: var(--shadow);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
}

.submitted-popup {
  font-size: 0.88rem;
  line-height: 1.35;
}

.submitted-popup-title {
  font-weight: 800;
  color: #dbe7ff;
  margin-bottom: 2px;
}

.submitted-popup-id {
  color: #9ab0d7;
  margin-bottom: 8px;
}

.submitted-popup-row {
  margin-bottom: 5px;
}

.submitted-popup-media {
  margin-top: 8px;
}

.popup-media-list {
  display: grid;
  gap: 8px;
}

.popup-media-btn {
  width: 100%;
  text-align: left;
  border: 1px solid #2a3a52;
  border-radius: 10px;
  background: #0f1623;
  color: #e9f1ff;
  padding: 6px;
}

.popup-media-btn span {
  display: block;
  margin-top: 6px;
  font-size: 0.8rem;
}

.popup-media-thumb {
  display: block;
  width: 100%;
  height: 116px;
  border-radius: 8px;
  object-fit: cover;
  background: #0a101a;
}

.popup-empty-media {
  color: #9aa8bd;
  font-size: 0.84rem;
}

.leaflet-popup.dynamic-tip-popup .leaflet-popup-tip-container {
  left: var(--tip-left, 50%) !important;
  margin-left: 0 !important;
  transform: translateX(-50%);
}

.media-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 980;
  background: rgba(7, 10, 16, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.media-modal-backdrop[hidden] {
  display: none !important;
}

.media-modal-sheet {
  width: 100%;
  max-width: 760px;
  max-height: 90vh;
  background: #0f1826;
  border: 1px solid #2a3a52;
  border-radius: 18px;
  overflow: auto;
}

.info-modal-sheet {
  max-width: 720px;
}

.info-modal-body {
  white-space: pre-wrap;
  color: #e9f1ff;
  line-height: 1.5;
}

.info-modal-body h3 {
  margin-top: 0;
}

.media-modal-head {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: rgba(15, 24, 38, 0.96);
  border-bottom: 1px solid #2a3a52;
}

.media-modal-head h2 {
  margin: 0;
  font-size: 1rem;
}

.media-preview-body {
  padding: 12px;
}

.media-preview-image,
.media-preview-video {
  width: 100%;
  max-height: calc(90vh - 96px);
  border-radius: 12px;
  object-fit: contain;
  background: #05080d;
}

.direction-handle-icon {
  background: transparent;
  border: 0;
}

.direction-handle-icon span {
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #ffd166;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 920;
  background: rgba(7, 10, 16, 0.64);
  display: flex;
  align-items: flex-end;
  pointer-events: none;
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal-sheet {
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  background: linear-gradient(180deg, #101927 0%, #0f1826 100%);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  border-top: 1px solid var(--border);
  box-shadow: var(--shadow);
  pointer-events: auto;
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: rgba(15, 24, 38, 0.96);
  border-bottom: 1px solid var(--border);
}

.modal-head h2 {
  margin: 0;
  font-size: 1rem;
}

.flow-progress {
  padding: 8px 12px 0;
  font-size: 0.86rem;
  color: var(--muted);
  pointer-events: auto;
}

.modal-form {
  padding: 12px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  display: grid;
  gap: 10px;
}

.step {
  padding: 12px;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.step h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.grid-1,
.grid-2 {
  display: grid;
  gap: 8px;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
  display: block;
  font-size: 0.94rem;
  color: var(--text);
}

input,
textarea,
select,
button {
  font-family: inherit;
}

input,
textarea,
select {
  width: 100%;
  margin-top: 6px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0f1623;
  color: var(--text);
  font-size: 16px;
}

input[type="radio"],
input[type="checkbox"] {
  width: auto;
  margin-right: 6px;
}

.btn {
  border: 1px solid var(--border);
  background: #1a2a44;
  color: #fff;
  border-radius: 12px;
  padding: 11px;
  font-size: 0.95rem;
  font-weight: 700;
}

.btn.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px rgba(76, 201, 240, 0.28);
}

.btn-primary { background: #2f6fed; }
.btn-secondary { background: #1f304d; }
.btn-alert { background: var(--danger); }
.btn-chip { background: #16243a; }
.btn-close { background: #1f304d; }

.btn-next {
  width: 100%;
  min-height: 52px;
  margin-top: 10px;
  font-size: 1rem;
}

.flow-actions .btn {
  min-height: 50px;
}

.time-quick-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.direction-confirm {
  margin-top: 10px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #3f6ea0;
  background: rgba(21, 44, 72, 0.7);
}

.direction-confirm-title {
  font-weight: 700;
  margin-bottom: 8px;
}

.direction-confirm-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.direction-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.direction-grid button {
  min-height: 44px;
  font-size: 0.9rem;
  line-height: 1.2;
  padding: 10px 6px;
}

.photo-list {
  display: grid;
  gap: 8px;
}

.photo-item {
  padding: 8px;
  border: 1px dashed #355175;
  border-radius: 10px;
}

.check-row {
  margin-top: 2px;
  color: var(--muted);
}

.check-row.required {
  color: #fff;
}

.hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.direction-summary {
  padding: 10px;
  border: 1px solid #335071;
  border-radius: 10px;
  background: rgba(15, 26, 42, 0.7);
  font-size: 0.92rem;
}

.direction-summary strong {
  color: #e7f0ff;
}

.option-cards {
  margin-top: 6px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.option-cards button {
  min-height: 58px;
  border: 1px solid var(--border);
  background: #122035;
  color: #fff;
  border-radius: 12px;
  padding: 8px 10px;
  text-align: left;
  font-weight: 700;
}

.option-cards button span {
  display: block;
  margin-top: 3px;
  font-size: 0.8rem;
  color: #b7c7de;
  font-weight: 500;
}

.option-cards button.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px rgba(76, 201, 240, 0.25);
}

.option-cards-small {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.option-cards-small button {
  text-align: center;
  min-height: 52px;
}

.error-box,
.panel-result,
.warning-box {
  padding: 12px;
  border-radius: 12px;
}

.error-box {
  background: rgba(255, 77, 109, 0.16);
  border: 1px solid rgba(255, 77, 109, 0.45);
}

.panel-result {
  background: rgba(0, 208, 132, 0.14);
  border: 1px solid rgba(0, 208, 132, 0.35);
}

.warning-box {
  background: rgba(255, 209, 102, 0.16);
  border: 1px solid rgba(255, 209, 102, 0.45);
  color: #ffe7ad;
}

.modal-submit {
  position: sticky;
  bottom: 0;
  z-index: 5;
  padding: 10px 0 max(6px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(15, 24, 38, 0.2), rgba(15, 24, 38, 0.95));
}

.modal-submit .btn {
  width: 100%;
  min-height: 56px;
  font-size: 1.08rem;
}

.leaflet-bottom.leaflet-left .leaflet-control {
  margin-bottom: 86px;
}

.hp-field {
  position: absolute;
  left: -9999px;
  opacity: 0;
  pointer-events: none;
}

#publicMap {
  height: calc(100vh - 110px);
  width: 100%;
}

.public-map-page {
  background: radial-gradient(circle at 20% 0%, #101e33 0%, #0a101a 48%);
}

.public-map-page .top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 16, 26, 0.94);
}

.public-map-page .top-bar h1 {
  margin: 0;
}

.legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px;
  color: var(--muted);
}

.dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
}

.dot-seen { background: #ff2d2d; }
.dot-heard { background: #4cc9f0; }
.dot-both { background: #ffd166; }
.dot-unknown { background: #adb5bd; }

@media (min-width: 900px) {
  .floating-head,
  .geo-status,
  .map-direction-confirm,
  .report-trigger,
  .map-actions,
  .sent-notice {
    max-width: 580px;
    left: 50%;
    transform: translateX(-50%);
  }

  .map-actions {
    top: 90px;
    width: min(34vw, 260px);
    right: calc(50% - 290px);
  }

  .modal-sheet {
    max-width: 760px;
    margin: 0 auto;
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
  }

  .media-modal-sheet {
    max-width: 760px;
    margin: 0 auto;
  }
}
