/* Shared tool platform chrome — share chips, capability strip, toast, nav */

.ts-tool-share {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.65rem;
  margin: 0.75rem 0 0;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  background: rgba(10, 124, 110, 0.08);
  border: 1px solid rgba(10, 124, 110, 0.2);
  font-size: 0.88rem;
  max-width: 100%;
}

.ts-tool-share__label {
  font-weight: 700;
  color: var(--color-primary, #0a7c6e);
}

.ts-tool-share__path {
  font-size: 0.9em;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.06);
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-all;
}

.ts-tool-share__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 2.5rem;
  border: 1px solid var(--color-primary, #0a7c6e);
  background: #fff;
  color: var(--color-primary, #0a7c6e);
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.ts-tool-share__btn:hover,
.ts-tool-share__btn:focus-visible {
  background: var(--color-primary, #0a7c6e);
  color: #fff;
  outline: none;
}

.ts-tool-share__also {
  font-size: 0.78rem;
  color: var(--color-text-muted, #5f7168);
}

.ts-tool-caps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin: 0.75rem 0 1rem;
  font-size: 0.82rem;
  color: var(--color-text-muted, #5f7168);
}

.ts-tool-caps__item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 100%;
  line-height: 1.35;
}

.ts-tool-caps__item i {
  color: var(--color-primary, #0a7c6e);
  flex-shrink: 0;
}

/* Resurvey form switcher — shared across Form-1…31 */
.ts-resurvey-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 1rem;
  max-width: 100%;
}

.ts-resurvey-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 2.5rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--color-text-muted, #5f7168);
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #d5ddd9);
  border-radius: 999px;
  white-space: nowrap;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.ts-resurvey-nav a:hover,
.ts-resurvey-nav a:focus-visible,
.ts-resurvey-nav a.is-active {
  color: var(--color-primary, #0a7c6e);
  border-color: var(--color-primary, #0a7c6e);
  background: rgba(10, 124, 110, 0.08);
  outline: none;
}

.ts-resurvey-nav a.is-active {
  font-weight: 700;
}

/*
 * Toast fallback — single vertical anchor (bottom) only.
 * Never set top+bottom together or the banner stretches full viewport height.
 * Always solid background + white text (pale token colors were unreadable).
 */
.app-toast.ts-tool-toast {
  position: fixed;
  z-index: 10070;
  top: auto !important;
  left: 50% !important;
  right: auto !important;
  bottom: max(1.25rem, env(safe-area-inset-bottom, 0px) + 1rem) !important;
  transform: translateX(-50%) translateY(120%);
  width: max-content;
  max-width: min(92vw, 28rem);
  height: auto !important;
  max-height: min(40vh, 12rem);
  margin: 0;
  padding: 0.8rem 1.1rem;
  border-radius: 10px;
  border: 0;
  background: #1a2420;
  color: #fff !important;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.45;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
  opacity: 0;
  pointer-events: none;
  overflow: auto;
  box-sizing: border-box;
  text-align: center;
  -webkit-font-smoothing: antialiased;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.app-toast.ts-tool-toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.app-toast.ts-tool-toast.success {
  background: #0a7c6e !important;
  color: #fff !important;
}

.app-toast.ts-tool-toast.warning {
  background: #b45309 !important;
  color: #fff !important;
}

.app-toast.ts-tool-toast.error {
  background: #b91c1c !important;
  color: #fff !important;
}

.app-toast.ts-tool-toast.info {
  background: #1e3a5f !important;
  color: #fff !important;
}

[data-theme="dark"] .ts-tool-share {
  background: rgba(63, 184, 164, 0.12);
  border-color: rgba(63, 184, 164, 0.3);
}

[data-theme="dark"] .ts-tool-share__btn {
  background: transparent;
  color: #3fb8a4;
  border-color: #3fb8a4;
}

[data-theme="dark"] .ts-resurvey-nav a {
  background: transparent;
  color: #9db5aa;
  border-color: #2d3730;
}

[data-theme="dark"] .ts-resurvey-nav a:hover,
[data-theme="dark"] .ts-resurvey-nav a:focus-visible,
[data-theme="dark"] .ts-resurvey-nav a.is-active {
  color: #3fb8a4;
  border-color: #3fb8a4;
  background: rgba(63, 184, 164, 0.12);
}

/* Mobile: share chip, caps, resurvey nav, toast */
@media (max-width: 767px) {
  .ts-tool-share {
    gap: 0.4rem;
    padding: 0.55rem 0.65rem;
    font-size: 0.84rem;
  }

  .ts-tool-share__btn {
    flex: 1 1 auto;
    min-width: min(100%, 7rem);
  }

  .ts-tool-caps {
    gap: 0.4rem 0.75rem;
    margin: 0.65rem 0 0.85rem;
    font-size: 0.78rem;
  }

  .ts-resurvey-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    gap: 0.35rem;
    margin-bottom: 0.85rem;
    padding-bottom: 0.15rem;
    /* edge fade hint */
    mask-image: linear-gradient(90deg, #000 0%, #000 calc(100% - 1.25rem), transparent 100%);
  }

  .ts-resurvey-nav a {
    flex: 0 0 auto;
    scroll-snap-align: start;
    min-height: 2.65rem;
    padding: 0.45rem 0.85rem;
    font-size: 0.8rem;
  }

  .app-toast.ts-tool-toast {
    left: 50% !important;
    right: auto !important;
    bottom: calc(var(--mobile-tab-height, 3.65rem) + env(safe-area-inset-bottom, 0px) + 0.75rem) !important;
    top: auto !important;
    transform: translateX(-50%) translateY(120%);
    max-width: min(92vw, 28rem);
    width: max-content;
    height: auto !important;
  }

  .app-toast.ts-tool-toast.visible {
    transform: translateX(-50%) translateY(0);
  }
}
