.site-feedback-launch {
  position: fixed;
  left: 24px;
  bottom: calc(var(--app-footer-height, 52px) + 12px);
  z-index: 1890;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid rgba(125, 211, 252, 0.38);
  border-radius: 15px;
  background: linear-gradient(145deg, #0f3b5c, #102a43);
  color: #e0f2fe;
  box-shadow: 0 16px 36px rgba(8, 47, 73, 0.28);
  font:
    700 0.82rem/1 'Inter',
    sans-serif;
  cursor: pointer;
  transition:
    transform 160ms ease,
    left 250ms ease,
    box-shadow 160ms ease;
}

.site-feedback-launch:hover,
.site-feedback-launch:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 20px 42px rgba(8, 47, 73, 0.34);
}

.site-feedback-launch .material-symbols-outlined {
  color: #7dd3fc;
  font-size: 22px;
}

.site-feedback-launch-label {
  display: none;
}

body:has(#auth-modal:not(.hidden)) .site-feedback-launch,
body:has(#auth-public-view:not(.hidden)) .site-feedback-launch {
  display: none !important;
}

body:has(#tree-section.section-visible.mode-tree .print-tree-launch) .site-feedback-launch {
  left: 84px;
}

.site-feedback-modal {
  position: fixed;
  inset: 0;
  z-index: 6200;
  display: grid;
  place-items: center;
  padding: max(12px, env(safe-area-inset-top)) 12px
    max(12px, env(safe-area-inset-bottom));
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(12px);
}

.site-feedback-modal.hidden,
.site-feedback-screen-preview.hidden,
.site-feedback-success.hidden,
#site-feedback-form-view.hidden {
  display: none !important;
}

.site-feedback-capture-hidden {
  visibility: hidden !important;
  pointer-events: none !important;
}

.site-feedback-card {
  width: min(720px, 100%);
  max-height: calc(var(--app-visual-viewport-height, 100dvh) - 24px);
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid rgba(148, 163, 184, 0.26);
  border-radius: 24px;
  background: #f8fafc;
  color: #0f172a;
  box-shadow: 0 32px 90px rgba(2, 6, 23, 0.42);
}

.site-feedback-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid #dbe4ef;
  background: rgba(248, 250, 252, 0.96);
  backdrop-filter: blur(14px);
}

.site-feedback-header h2 {
  margin: 4px 0 0;
  color: #0f172a;
  font-size: clamp(1.18rem, 3vw, 1.55rem);
  line-height: 1.2;
}

.site-feedback-eyebrow {
  color: #0369a1;
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.site-feedback-close {
  display: grid;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #fff;
  color: #334155;
  cursor: pointer;
}

#site-feedback-form-view,
.site-feedback-success {
  padding: 20px 22px 24px;
}

.site-feedback-intro {
  margin: 0 0 16px;
  color: #475569;
  font-size: 0.9rem;
  line-height: 1.5;
}

#site-feedback-form {
  display: grid;
  gap: 15px;
}

.site-feedback-grid {
  display: grid;
  grid-template-columns: minmax(160px, 0.7fr) minmax(0, 1.3fr);
  gap: 12px;
}

#site-feedback-form
  label:not(.site-feedback-consent):not(.site-feedback-upload-btn) {
  display: grid;
  gap: 7px;
  color: #334155;
  font-size: 0.82rem;
  font-weight: 750;
}

#site-feedback-form input,
#site-feedback-form select,
#site-feedback-form textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
  color: #0f172a;
  font:
    500 0.92rem/1.45 'Inter',
    sans-serif;
}

#site-feedback-form textarea {
  resize: vertical;
}

#site-feedback-form input:focus,
#site-feedback-form select:focus,
#site-feedback-form textarea:focus {
  outline: 3px solid rgba(14, 165, 233, 0.18);
  border-color: #0284c7;
}

.site-feedback-screen-section,
.site-feedback-diagnostics-box {
  border: 1px solid #dbe4ef;
  border-radius: 16px;
  padding: 13px;
  background: #fff;
}

.site-feedback-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.site-feedback-section-head > div:first-child {
  display: grid;
  gap: 3px;
}

.site-feedback-section-head strong {
  font-size: 0.88rem;
}

.site-feedback-section-head > div:first-child span {
  color: #64748b;
  font-size: 0.75rem;
}

.site-feedback-screen-actions {
  display: flex;
  gap: 8px;
}

.site-feedback-screen-actions button,
.site-feedback-upload-btn,
#site-feedback-submit,
.site-feedback-success button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid #bae6fd;
  border-radius: 11px;
  background: #f0f9ff;
  color: #075985;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}

.site-feedback-upload-btn input {
  display: none;
}

.site-feedback-screen-preview {
  display: grid;
  gap: 9px;
  margin-top: 12px;
}

.site-feedback-screen-preview img {
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #0f172a;
}

.site-feedback-screen-preview button {
  justify-self: end;
  border: 0;
  background: transparent;
  color: #b91c1c;
  font-size: 0.76rem;
  font-weight: 800;
  cursor: pointer;
}

.site-feedback-diagnostics-box summary {
  color: #334155;
  font-size: 0.84rem;
  font-weight: 800;
  cursor: pointer;
}

.site-feedback-diagnostics-box p {
  margin: 9px 0;
  color: #64748b;
  font-size: 0.75rem;
}

.site-feedback-diagnostics-box pre {
  max-height: 190px;
  margin: 0;
  overflow: auto;
  border-radius: 10px;
  padding: 10px;
  background: #0f172a;
  color: #bae6fd;
  font:
    500 0.7rem/1.45 ui-monospace,
    monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.site-feedback-consent {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  color: #475569;
  font-size: 0.76rem;
  line-height: 1.45;
}

.site-feedback-consent input {
  width: 18px !important;
  height: 18px;
  flex: 0 0 auto;
  margin-top: 1px;
}

.site-feedback-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.site-feedback-footer a {
  color: #0369a1;
  font-size: 0.78rem;
  font-weight: 700;
}

#site-feedback-submit,
.site-feedback-success button {
  border-color: #0369a1;
  background: #0369a1;
  color: #fff;
}

#site-feedback-submit:disabled {
  cursor: wait;
  opacity: 0.65;
}

.site-feedback-success {
  display: grid;
  place-items: center;
  gap: 11px;
  min-height: 300px;
  text-align: center;
}

.site-feedback-success > .material-symbols-outlined {
  color: #16a34a;
  font-size: 54px;
}

.site-feedback-success h3,
.site-feedback-success p {
  margin: 0;
}

.site-feedback-success p {
  color: #475569;
}

.site-feedback-success code {
  padding: 10px 14px;
  border-radius: 10px;
  background: #e0f2fe;
  color: #075985;
  font-size: 1rem;
  font-weight: 900;
}

body.print-tree-preview-open .site-feedback-launch,
body.site-feedback-open .site-feedback-launch {
  visibility: hidden;
  pointer-events: none;
}

@media (max-width: 640px) {
  .site-feedback-launch {
    left: 14px;
    bottom: calc(
      var(--app-footer-height, 84px) + 10px + env(safe-area-inset-bottom)
    );
    width: 46px;
    min-width: 46px;
    height: 46px;
    min-height: 46px;
    padding: 0;
    border-radius: 14px;
    justify-content: center;
  }
  
  body:has(#tree-section.section-visible.mode-tree .print-tree-launch) .site-feedback-launch {
    left: 68px;
  }

  .site-feedback-launch-label {
    display: none;
  }

  .site-feedback-modal {
    place-items: stretch;
    padding: 0;
  }

  .site-feedback-card {
    width: 100%;
    height: var(--app-visual-viewport-height, 100dvh);
    max-height: var(--app-visual-viewport-height, 100dvh);
    border: 0;
    border-radius: 0;
  }

  .site-feedback-header {
    padding: max(13px, env(safe-area-inset-top)) 14px 12px;
  }

  #site-feedback-form-view,
  .site-feedback-success {
    padding: 15px 14px calc(18px + env(safe-area-inset-bottom));
  }

  .site-feedback-grid {
    grid-template-columns: 1fr;
  }

  .site-feedback-section-head,
  .site-feedback-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .site-feedback-screen-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .site-feedback-footer #site-feedback-submit {
    width: 100%;
  }

  body.tree-canvas-expanded .site-feedback-launch {
    bottom: calc(14px + env(safe-area-inset-bottom));
  }
}
