:root {
  --shadow: 0 6px 20px rgba(20, 31, 50, 0.18);
  --btn-size: 56px;
  --radius: 14px;
  --focus: #1a73e8;
  --text: #17263a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f4f6f9;
}

.config-error {
  position: fixed;
  z-index: 60;
  top: 0;
  left: 0;
  right: 0;
  margin: 0;
  padding: 0.75rem 1rem;
  background: #b42318;
  color: #fff;
  font-weight: 600;
}

.app-shell {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #e9edf3;
}

.map-container,
.map-frame,
.map-image,
.map-object {
  width: 100%;
  height: 100%;
}

.map-frame,
.map-image,
.map-object {
  border: 0;
  display: block;
  background: #e9edf3;
}

.map-image {
  object-fit: contain;
  object-position: center;
}

.loading {
  color: #4d607a;
  margin: 1rem;
}

.title-bubble {
  position: fixed;
  z-index: 18;
  top: calc(14px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  color: #1e2a3a;
  border-radius: 999px;
  box-shadow: var(--shadow);
  padding: 0.65rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.2;
  text-align: center;
  max-width: min(72vw, 360px);
  white-space: nowrap;
}

.fab {
  position: fixed;
  z-index: 20;
  width: var(--btn-size);
  height: var(--btn-size);
  border: none;
  border-radius: 50%;
  background: #fff;
  color: #1e2a3a;
  box-shadow: var(--shadow);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
  touch-action: manipulation;
  padding: 0;
}

.fab:hover { transform: translateY(-1px); }
.fab:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.fab svg {
  flex: 0 0 auto;
}

.fab-pill {
  width: auto;
  min-width: var(--btn-size);
  border-radius: 999px;
  padding: 0 0.9rem;
}

.fab__label {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1;
}

.fab-signup {
  left: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
}

.fab-info {
  right: 16px;
  top: calc(16px + env(safe-area-inset-top));
}

.fab-share {
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal.is-open { display: flex; }

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 18, 30, 0.52);
}

.modal__panel {
  position: relative;
  z-index: 1;
  width: min(760px, 100%);
  max-height: min(90vh, 760px);
  overflow: auto;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 20px 50px rgba(15, 28, 48, 0.28);
  padding: 1rem 1rem 1.25rem;
}

.modal__panel--share {
  width: min(520px, 100%);
}

.modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.modal__title {
  margin: 0;
  font-size: 1.2rem;
  color: var(--text);
}

.close-btn {
  border: none;
  background: transparent;
  font-size: 1.55rem;
  line-height: 1;
  cursor: pointer;
  color: #4a5a72;
  padding: 0.2rem 0.4rem;
  border-radius: 8px;
}

.close-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.help-text {
  margin: 0.45rem 0 1rem;
  color: #4d607a;
  font-size: 0.95rem;
}

.share-actions {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.35rem;
}

.share-option {
  width: 100%;
  border: 1px solid #d8e0ec;
  border-radius: 12px;
  background: #fff;
  color: #1f314a;
  padding: 0.75rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  font: inherit;
}

.share-option:hover {
  border-color: #b8c7dd;
  background: #f8fbff;
}

.share-option:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.share-option__icon {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #edf3fd;
  font-size: 1.1rem;
}

.share-option__text {
  display: grid;
  gap: 0.1rem;
}

.share-option__text strong {
  color: #1f314a;
  font-size: 0.97rem;
}

.share-option__text small {
  color: #526580;
  font-size: 0.85rem;
}

.share-option--native {
  border-color: #b9d4ff;
  background: #eff5ff;
}

.share-option--disabled {
  display: none !important;
}

.share-option__icon svg {
  width: 1.15rem;
  height: 1.15rem;
}

.share-status {
  margin: 0.75rem 0 0;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  background: #eef6ff;
  border: 1px solid #bfd5f7;
  color: #1f4e87;
  font-size: 0.92rem;
}

.copy-fallback {
  margin-top: 0.65rem;
  display: grid;
  gap: 0.4rem;
}

.copy-fallback label {
  color: #2e425d;
  font-size: 0.9rem;
  font-weight: 600;
}

.copy-fallback input {
  width: 100%;
  border: 1px solid #cad5e5;
  border-radius: 10px;
  padding: 0.6rem 0.65rem;
  font-size: 0.92rem;
  color: #1f314a;
}

.qr-block {
  margin-top: 1rem;
  border-top: 1px solid #e5ebf4;
  padding-top: 0.95rem;
}

.qr-block__title {
  margin: 0 0 0.5rem;
  color: #253a57;
  font-size: 1rem;
}

.qr-code {
  min-height: 170px;
  border: 1px dashed #c8d5e8;
  border-radius: 12px;
  display: grid;
  place-items: center;
  padding: 0.8rem;
  background: #f9fbfe;
}

.qr-code img,
.qr-code canvas {
  width: min(220px, 70vw);
  height: auto;
  max-width: 100%;
}

.signup-form {
  display: grid;
  gap: 0.75rem;
}

.form-field {
  display: grid;
  gap: 0.35rem;
  color: #2e425d;
  font-weight: 600;
}

.form-field input {
  border: 1px solid #cad5e5;
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  font-size: 1rem;
}

.form-field input:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  border-color: var(--focus);
}

.action-btn {
  justify-self: start;
  border: none;
  background: #1e5bb8;
  color: #fff;
  border-radius: 10px;
  padding: 0.6rem 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

.action-btn:disabled {
  cursor: wait;
  opacity: 0.75;
}

.signup-status {
  margin: 0.15rem 0 0;
  padding: 0.7rem 0.8rem;
  border-radius: 10px;
  font-size: 0.95rem;
}

.signup-status--success {
  background: #ecfdf3;
  border: 1px solid #9ed8b5;
  color: #11552d;
}

.signup-status--error {
  background: #fff1f1;
  border: 1px solid #f3bbbb;
  color: #831616;
}

.signup-status--info {
  background: #eef6ff;
  border: 1px solid #bfd5f7;
  color: #1f4e87;
}

.is-hidden {
  display: none;
}

.ward-plan {
  color: #2e425d;
  line-height: 1.6;
  font-size: 0.98rem;
}

.ward-plan h1,
.ward-plan h2,
.ward-plan h3,
.ward-plan h4 {
  color: var(--text);
  line-height: 1.3;
  margin-top: 1rem;
}

.ward-plan ul,
.ward-plan ol {
  padding-left: 1.4rem;
}

.ward-plan a {
  color: #1e5bb8;
}

@media (max-width: 640px) {
  .title-bubble {
    top: calc(10px + env(safe-area-inset-top));
    padding: 0.5rem 0.8rem;
    font-size: 0.86rem;
    max-width: 62vw;
  }

  .fab-info {
    top: calc(64px + env(safe-area-inset-top));
  }

  .fab-pill {
    padding: 0 0.75rem;
    gap: 0.4rem;
  }

  .fab__label {
    font-size: 0.88rem;
  }

  .modal {
    padding: 10px;
  }

  .modal__panel {
    max-height: 92vh;
  }

  .share-option {
    padding: 0.75rem;
  }
}
