:root {
  --tb-green: #365945;
  --tb-green-hover: #4a6a57;
  --tb-green-active: #5b8d6c;
  --tb-outline-hover-color: #4a6a57;
  --tb-outline-active-color: #5b8d6c;
  --tb-outline-hover-bg: rgba(74, 106, 87, 0.14);
  --tb-outline-active-bg: rgba(91, 141, 108, 0.18);
  --tb-btn-font: 1rem;
  --tb-btn-radius: 6px;
  --tb-btn-height: 32px;
  --tb-btn-minw: 80px;
  --tb-btn-pad-x: 16px;
  --tb-btn-pad-y: 8px;
  --tb-focus-ring-gap: #f7f9f8;
  --tb-focus-ring-color: rgba(54, 89, 69, 0.45);
}

.topbar {
  display: block;
  width: 100%;
  align-self: stretch;
}

.topbar .tb-btn,
.topbar .tb-btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--tb-btn-minw);
  height: var(--tb-btn-height);
  padding: var(--tb-btn-pad-y) var(--tb-btn-pad-x);
  font-size: var(--tb-btn-font);
  font-weight: 400;
  border-radius: var(--tb-btn-radius);
  text-decoration: none;
  cursor: pointer;
  line-height: 1;
  box-sizing: border-box;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.topbar .tb-btn:disabled,
.topbar .tb-btn-outline:disabled,
.topbar .tb-btn[disabled],
.topbar .tb-btn-outline[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  filter: none;
  box-shadow: none;
}

.topbar .tb-btn {
  background: var(--tb-green);
  color: #fff;
  border: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.topbar .tb-btn:hover:not(:disabled) {
  background: var(--tb-green-hover);
}

.topbar .tb-btn:active:not(:disabled) {
  background: var(--tb-green-active);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.topbar .tb-btn:focus-visible {
  background: var(--tb-green-hover);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 0 0 2px var(--tb-focus-ring-gap), 0 0 0 5px var(--tb-focus-ring-color);
}

.topbar .tb-btn-outline {
  background: transparent;
  color: var(--tb-green);
  border: 2px solid currentColor;
  box-shadow: none;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.topbar .tb-btn-outline:hover:not(:disabled) {
  background: var(--tb-outline-hover-bg);
  color: var(--tb-outline-hover-color);
  border-color: var(--tb-outline-hover-color);
}

.topbar .tb-btn-outline:active:not(:disabled) {
  background: var(--tb-outline-active-bg);
  color: var(--tb-outline-active-color);
  border-color: var(--tb-outline-active-color);
}

.topbar .tb-btn-outline:focus-visible {
  border-color: var(--tb-outline-hover-color);
  box-shadow: 0 0 0 2px var(--tb-focus-ring-gap), 0 0 0 5px var(--tb-focus-ring-color);
}

@media (prefers-reduced-motion: reduce) {
  .topbar .tb-btn,
  .topbar .tb-btn-outline {
    transition: none;
  }
}

/* --- Shared Feedback Trigger & Overlay --- */

.topbar__center {
  justify-self: center;
  font-weight: 600;
  font-size: 1.25rem;
  letter-spacing: .2px;
  color: var(--tb-green);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  overflow: visible;
}

#feedbackTrigger {
  font: inherit;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 18px;
  cursor: pointer;
  line-height: 1;
  transition: background-color .16s ease, color .16s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: auto;
  height: auto;
}


.topbar__action {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.topbar__profile-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  border-radius: 999px;
  text-decoration: none;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  transition: background-color .16s ease;
  -webkit-tap-highlight-color: transparent;
}

.topbar__profile-trigger:hover {
  background: rgba(74, 106, 87, 0.12);
}

.topbar__profile-trigger:focus-visible {
  outline: 2px solid rgba(54, 89, 69, 0.45);
  outline-offset: 4px;
}

.topbar__profile-trigger .tb-nav-avatar {
  pointer-events: none;
}

#feedbackTrigger:hover {
  background: rgba(74, 106, 87, 0.12);
}

#feedbackTrigger:focus-visible {
  outline: 2px solid rgba(54, 89, 69, 0.45);
  outline-offset: 4px;
  background: transparent;
}

.tb-nav-avatar {
  width: 1.5em;
  height: 1.5em;
  min-width: 1.5em;
  min-height: 1.5em;
  border-radius: 50%;
  box-sizing: border-box;
  padding: 1px;
  border: 1px solid var(--tb-green);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #e9efec;
}

.tb-nav-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 50%;
}

.tb-nav-label {
  display: inline-block;
}

.feedback-tip {
  position: absolute;
  top: calc(100%);
  left: 50%;
  transform: translate(-50%, 0);
  padding: 8px 12px;
  background: var(--tb-green);
  color: #fff;
  font-size: .9rem;
  font-weight: 400;
  border-radius: 16px;
  box-shadow: 0 6px 16px rgba(0,0,0,.18);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: none;
  pointer-events: none;
  z-index: 20;
}

.topbar__action:hover > .feedback-tip,
.topbar__action:focus-within > .feedback-tip,
#feedbackTrigger:hover + .feedback-tip,
#feedbackTrigger:focus-visible + .feedback-tip {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

html.feedback-open .feedback-tip {
  opacity: 0;
  visibility: hidden;
}

html.feedback-open .topbar__action:hover > .feedback-tip,
html.feedback-open .topbar__action:focus-within > .feedback-tip,
html.feedback-open #feedbackTrigger:hover + .feedback-tip,
html.feedback-open #feedbackTrigger:focus-visible + .feedback-tip {
  opacity: 0;
  visibility: hidden;
}

.feedback-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
  z-index: 20050;
}

.feedback-overlay[aria-hidden="false"] {
  display: flex;
}

.feedback-backdrop {
  position: absolute;
  inset: 0;
}

.feedback-panel {
  position: relative;
  background: #fff;
  border-radius: 16px;
  width: min(480px, 100%);
  max-height: calc(100vh - 120px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 18px 50px rgba(15,23,42,.35);
}

.feedback-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px;
  padding-bottom: 12px;
}

.feedback-header h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
  color: #1f2937;
}

.feedback-close {
  background: transparent;
  border: 0;
  color: #4b5563;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
}

.feedback-close:hover {
  background: rgba(229, 231, 235, .7);
}

.feedback-close:focus-visible {
  outline: 2px solid rgba(54, 89, 69, 0.45);
  outline-offset: 2px;
}

.feedback-lead {
  margin: 0 24px 16px;
  color: #4b5563;
  font-size: .95rem;
  line-height: 1.4;
}

#feedbackForm {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 0 24px 24px;
}

.feedback-field label {
  font-weight: 600;
  display: block;
  margin-bottom: 6px;
  color: #374151;
}

.feedback-field textarea {
  width: 100%;
  min-height: 70px;
  max-height: 140px;
  resize: vertical;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--ui-border, #d1d5db);
  background: var(--ui-bg, #fafafa);
  font: 1rem var(--font-family-base, 'Source Sans 3', sans-serif);
  line-height: 1.4;
  color: var(--ui-fg, #1f2937);
  box-sizing: border-box;
}

.feedback-field textarea:focus {
  outline: 2px solid rgba(54, 89, 69, 0.35);
  outline-offset: 2px;
  background: #fff;
}

@media (max-width: 500px) {
  .feedback-field textarea {
    min-height: calc(2 * 1.4em + 24px);
    max-height: calc(2 * 1.4em + 24px);
    height: calc(2 * 1.4em + 24px);
    resize: none;
    overflow-y: auto;
  }
  .feedback-actions .feedback-cancel {
    display: none;
  }
  .feedback-lead {
    display: none;
  }
}

.feedback-fieldset {
  border: 1px solid rgba(55,65,81,0.18);
  border-radius: 12px;
  padding: 16px;
  margin: 0;
}

.feedback-fieldset legend {
  font-weight: 600;
  padding: 0 6px;
  color: #374151;
}

.feedback-diagnostics {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow: auto;
  padding-right: 4px;
}

.feedback-diagnostic-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(209,213,219,0.6);
}

.feedback-diagnostic-item:last-child {
  border-bottom: 0;
}

.feedback-diagnostic-item input[type="checkbox"] {
  margin-top: 3px;
}

.feedback-diagnostic-label {
  flex: 1;
}

.feedback-diagnostic-label span {
  display: block;
  font-weight: 600;
  color: #1f2937;
}

.feedback-diagnostic-label small {
  display: block;
  margin-top: 2px;
  color: #4b5563;
  font-size: .85rem;
  line-height: 1.35;
}

.feedback-diagnostic-preview {
  display: block;
  margin-top: 4px;
  padding: 6px 8px;
  border-radius: 6px;
  background: #f3f4f6;
  font-family: monospace;
  font-size: .8rem;
  line-height: 1.3;
  color: #1f2937;
  word-break: break-word;
  max-height: 72px;
  overflow: auto;
}

.feedback-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 8px;
}

.feedback-actions button {
  min-width: 120px;
  height: 44px;
  border-radius: 8px;
  border: 0;
  font: 1rem var(--font-family-base, 'Source Sans 3', sans-serif);
  cursor: pointer;
  transition: background-color .18s ease, color .18s ease;
}

.feedback-actions .feedback-cancel {
  background: #fff;
  border: 1px solid rgba(55,65,81,0.2);
  color: #374151;
}

.feedback-actions .feedback-cancel:hover {
  background: rgba(229,231,235,0.6);
}

.feedback-actions .feedback-submit {
  background: var(--tb-green);
  color: #fff;
}

.feedback-actions .feedback-submit:disabled {
  opacity: .6;
  cursor: not-allowed;
}

.feedback-actions .feedback-submit:hover:not(:disabled) {
  background: var(--tb-green-hover);
}

.feedback-actions .feedback-submit:focus-visible {
  outline: 2px solid rgba(54, 89, 69, 0.45);
  outline-offset: 2px;
}

.feedback-attachments {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.feedback-screenshot__add,
.feedback-screenshot__remove,
.feedback-screenshot__remove-icon {
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(55,65,81,0.28);
  padding: 0 14px;
  background: #fff;
  font: 0.95rem var(--font-family-base, 'Source Sans 3', sans-serif);
  color: #1f2937;
  cursor: pointer;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease;
}

.feedback-screenshot__add:hover,
.feedback-screenshot__remove:hover,
.feedback-screenshot__remove-icon:hover {
  background: rgba(229,231,235,0.65);
}

.feedback-screenshot__remove {
  border-color: rgba(220,38,38,0.45);
  color: #b91c1c;
  padding: 0 10px;
}

.feedback-screenshot__remove:hover,
.feedback-screenshot__remove-icon:hover {
  background: rgba(254,226,226,0.7);
}

.feedback-screenshot__preview {
  position: relative;
  display: none;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(209,213,219,0.9);
  background: #fff;
  width: 72px;
  height: 36px;
  flex-shrink: 0;
  display: grid;
  grid-template-rows: 1fr auto;
}

.feedback-screenshot__preview img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.feedback-screenshot__preview::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 3px solid rgba(54, 89, 69, 0.35);
  border-radius: inherit;
  opacity: 1;
  pointer-events: none;
}

.feedback-screenshot__preview button.feedback-screenshot__remove-icon {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  padding: 0;
  border: none;
  background: rgba(255,255,255,0.85);
  color: rgba(220,38,38,0.8);
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.feedback-screenshot.has-screenshot .feedback-screenshot__preview {
  display: block;
}

@media (max-width: 560px) {
  .feedback-panel {
    max-height: calc(100vh - 48px);
  }

  .feedback-header,
  .feedback-lead,
  #feedbackForm {
    padding-left: 18px;
    padding-right: 18px;
  }

  .feedback-actions {
    flex-direction: column-reverse;
  }

  .feedback-actions button {
    width: 100%;
  }
}
html.feedback-open,
html.feedback-open body {
  overflow: hidden;
  height: 100%;
}
