:root {
  --comment-ink: #2d232e;
  --comment-amber: #ffab40;
  --comment-amber-deep: #b45309;
  --comment-paper: #fffdf8;
  --comment-line: #d5cfbd;
  --comment-danger: #b91c1c;
  --comment-focus: #6d1f62;
  --comment-motion-duration: 140ms;
}

.comments-toggle,
.comments-header-action {
  border: 1px solid var(--comment-line);
  border-radius: 0.5rem;
  background: var(--comment-paper);
  color: var(--comment-ink);
  cursor: pointer;
  font: 600 0.78rem/1 "Raleway", system-ui, sans-serif;
  padding: 0.5rem 0.65rem;
  white-space: nowrap;
}

.comments-toggle:hover,
.comments-header-action:hover {
  border-color: var(--comment-amber-deep);
}

.comments-toggle:focus-visible,
.comments-header-action:focus-visible {
  outline: 3px solid var(--comment-focus);
  outline-offset: 2px;
}

.comments-toggle[aria-pressed="true"] {
  background: var(--comment-amber);
  border-color: var(--comment-amber);
}

.comments-toggle:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.comments-count {
  display: inline-grid;
  min-width: 1.25rem;
  height: 1.25rem;
  margin-left: 0.2rem;
  padding: 0 0.25rem;
  place-items: center;
  border-radius: 999px;
  background: var(--comment-ink);
  color: #fff;
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.comments-status {
  max-width: 11rem;
  color: var(--comment-danger);
  font-size: 0.72rem;
  font-weight: 600;
}

[data-comment-target].comment-target-active {
  cursor: crosshair;
}

[data-comment-target].comment-target-active:hover {
  outline: 2px solid rgba(255, 171, 64, 0.82);
  outline-offset: 3px;
}

[data-comment-target].comment-target-active:focus-visible {
  outline: 3px solid var(--comment-amber-deep);
  outline-offset: 4px;
}

#comments-layer {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
}

.comment-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: rgba(45, 35, 46, 0.38);
  pointer-events: auto;
}

.comment-pin {
  position: fixed;
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  padding: 0;
  transform: translate(-50%, -100%);
  border: 2px solid #fff;
  border-radius: 0.45rem 0.45rem 0.45rem 0.15rem;
  background: var(--comment-amber);
  box-shadow: 0 2px 8px rgba(45, 35, 46, 0.28);
  color: var(--comment-ink);
  cursor: pointer;
  font: 800 0.68rem/1 "Raleway", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  pointer-events: auto;
  transition: box-shadow var(--comment-motion-duration) ease,
    filter var(--comment-motion-duration) ease;
}

.comment-pin[hidden] {
  display: none;
}

.comment-pin-resolved {
  background: #ded9ca;
  color: #625b63;
  filter: saturate(0.25);
}

.comment-cluster {
  border-radius: 999px;
  background: var(--comment-ink);
  color: #fff;
}

.comment-cluster::after,
.comment-pin-resolved::after {
  border-top-color: currentColor;
}

.comment-pin::after {
  content: "";
  position: absolute;
  left: -2px;
  bottom: -0.34rem;
  width: 0;
  height: 0;
  border-top: 0.42rem solid var(--comment-amber);
  border-right: 0.42rem solid transparent;
}

.comment-pin:focus-visible {
  outline: 3px solid var(--comment-focus);
  outline-offset: 3px;
}

.comment-composer {
  position: fixed;
  width: min(21rem, calc(100vw - 1.5rem));
  padding: 0.9rem;
  border: 1px solid var(--comment-line);
  border-radius: 0.65rem;
  background: var(--comment-paper);
  box-shadow: 0 16px 44px rgba(45, 35, 46, 0.22);
  color: var(--comment-ink);
  pointer-events: auto;
  transition: box-shadow var(--comment-motion-duration) ease,
    border-color var(--comment-motion-duration) ease;
}

.comment-composer-title {
  margin: 0 0 0.65rem;
  font-size: 0.88rem;
  font-weight: 800;
}

.comment-composer textarea {
  display: block;
  width: 100%;
  min-height: 5.5rem;
  resize: vertical;
  border: 1px solid var(--comment-line);
  border-radius: 0.45rem;
  background: #fff;
  color: var(--comment-ink);
  font: 400 0.88rem/1.45 "Raleway", system-ui, sans-serif;
  padding: 0.65rem;
}

.comment-composer textarea:focus-visible {
  border-color: var(--comment-amber-deep);
  outline: 3px solid var(--comment-focus);
  outline-offset: 1px;
}

.comment-composer-error {
  min-height: 1rem;
  margin: 0.45rem 0 0;
  color: var(--comment-danger);
  font-size: 0.75rem;
  font-weight: 600;
}

.comment-composer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
  margin-top: 0.5rem;
}

.comment-composer-actions button {
  border: 1px solid transparent;
  border-radius: 0.4rem;
  background: transparent;
  color: var(--comment-ink);
  cursor: pointer;
  font: 600 0.78rem/1 "Raleway", system-ui, sans-serif;
  padding: 0.52rem 0.7rem;
}

.comment-composer-actions [data-comment-submit] {
  background: var(--comment-amber);
  border-color: var(--comment-amber);
}

.comment-composer-actions button:focus-visible {
  outline: 3px solid var(--comment-focus);
  outline-offset: 2px;
}

.comment-thread,
.comment-chooser {
  position: fixed;
  width: min(25rem, calc(100vw - 1.5rem));
  max-height: calc(100vh - 1.5rem);
  overflow: auto;
  padding: 1rem;
  border: 1px solid var(--comment-line);
  border-top: 4px solid var(--comment-amber);
  border-radius: 0.55rem;
  background: var(--comment-paper);
  box-shadow: 0 18px 48px rgba(45, 35, 46, 0.26);
  color: var(--comment-ink);
  pointer-events: auto;
  transition: box-shadow var(--comment-motion-duration) ease,
    border-color var(--comment-motion-duration) ease;
}

.comment-thread {
  z-index: 2;
}

.comment-thread-unplaced {
  border-top-color: #8b7f69;
}

.comment-thread-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}

.comment-thread-title,
.comment-chooser-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
}

.comment-thread-snapshot {
  margin: 0.4rem 0 0.85rem;
  padding: 0.55rem 0.65rem;
  border-left: 3px solid var(--comment-line);
  background: #f5f1e7;
  color: #625b63;
  font-size: 0.74rem;
  line-height: 1.35;
}

.comment-message-list {
  display: grid;
  gap: 0.65rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.comment-message {
  padding: 0.7rem;
  border: 1px solid #e3ddcd;
  border-radius: 0.45rem;
  background: #fff;
}

.comment-message-author {
  margin: 0 0 0.35rem;
  color: var(--comment-amber-deep);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.comment-message-body {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.comment-message-deleted {
  color: #766e76;
  font-style: italic;
}

.comment-message-history {
  margin: 0.4rem 0 0;
  color: #625b63;
  font-size: 0.66rem;
  line-height: 1.35;
}

.comment-message-time {
  font-variant-numeric: tabular-nums;
}

.comment-message-actions,
.comment-thread-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.comment-action {
  border: 1px solid var(--comment-line);
  border-radius: 0.35rem;
  background: #fff;
  color: var(--comment-ink);
  cursor: pointer;
  font: 700 0.72rem/1 "Raleway", system-ui, sans-serif;
  padding: 0.45rem 0.6rem;
}

.comment-action:hover {
  border-color: var(--comment-amber-deep);
}

.comment-action:focus-visible {
  outline: 3px solid var(--comment-focus);
  outline-offset: 2px;
}

.comment-thread-close {
  flex: 0 0 auto;
}

.comment-reply {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 0.45rem;
  margin-top: 0.85rem;
}

.comment-reply textarea,
.comment-edit-body {
  width: 100%;
  min-height: 4rem;
  border: 1px solid var(--comment-line);
  border-radius: 0.4rem;
  color: var(--comment-ink);
  font: 400 0.82rem/1.4 "Raleway", system-ui, sans-serif;
  padding: 0.55rem;
  resize: vertical;
}

.comment-reply textarea:focus-visible,
.comment-edit-body:focus-visible {
  border-color: var(--comment-amber-deep);
  outline: 3px solid var(--comment-focus);
  outline-offset: 1px;
}

.comment-inline-error {
  margin: 0.4rem 0 0;
  color: var(--comment-danger);
  font-size: 0.72rem;
  font-weight: 700;
}

.comment-chooser-list {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.comment-chooser-list .comment-action {
  width: 100%;
  text-align: left;
  line-height: 1.3;
}

@media (max-width: 900px) {
  .dash-header {
    flex-wrap: wrap;
    gap: 0.7rem;
  }

  .comments-status {
    flex: 1 0 100%;
    max-width: none;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 640px) {
  .dash-header {
    padding: 0.9rem 1rem;
  }

  .dash-logo {
    width: min(16rem, 100%);
    height: auto;
  }

  .dash-title {
    flex: 1 1 12rem;
    min-width: 0;
    padding-left: 0.75rem;
    font-size: 1rem;
  }

  .freshness {
    flex: 1 1 9rem;
  }

  .dash-brand {
    margin-left: 0;
  }

  .signout-btn {
    margin-left: 0;
  }

  .comment-thread {
    inset-inline: 0;
    bottom: 0;
    left: 0 !important;
    top: auto !important;
    width: 100%;
    max-height: calc(100dvh - max(0.75rem, env(safe-area-inset-top)));
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 0.85rem 0.85rem 0 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .comment-pin,
  .comment-composer,
  .comment-chooser,
  .comment-thread {
    --comment-motion-duration: 0ms;
    animation: none !important;
    transition-duration: 0ms !important;
    scroll-behavior: auto !important;
  }
}
