.discussion-panel {
  min-width: 0;
  padding: 1.15rem;
}

.discussion-heading {
  margin-bottom: 1rem;
}

.discussion-heading > span {
  display: inline-grid;
  min-width: 1.75rem;
  height: 1.75rem;
  place-items: center;
  border-radius: 999px;
  background: #f2f4f7;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 850;
}

.discussion-list {
  display: grid;
  gap: .9rem;
}

.comment-thread-row {
  display: grid;
  min-width: 0;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: .65rem;
  border-left: 2px solid transparent;
  padding-left: .35rem;
}

.comment-thread-row.comment-depth-1 { margin-left: 1.1rem; border-left-color: #dbe4ff; }
.comment-thread-row.comment-depth-2 { margin-left: 2.2rem; border-left-color: #bac8ff; }
.comment-thread-row.comment-depth-3 { margin-left: 3.3rem; border-left-color: #91a7ff; }
.comment-thread-row.comment-depth-4 { margin-left: 4.4rem; border-left-color: #748ffc; }

.discussion-avatar {
  flex: 0 0 auto;
}

.discussion-comment-body {
  min-width: 0;
}

.discussion-comment-header {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
}

.discussion-author {
  display: flex;
  min-width: 0;
  align-items: baseline;
  flex-wrap: wrap;
  gap: .3rem .55rem;
}

.discussion-author strong {
  overflow-wrap: anywhere;
  font-size: .78rem;
}

.discussion-comment-header time {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: .68rem;
}

.reply-context {
  color: var(--blue);
  font-size: .65rem;
  font-weight: 700;
}

.discussion-text {
  margin-top: .35rem;
  color: var(--ink-2);
  overflow-wrap: anywhere;
  font-size: .82rem;
  line-height: 1.65;
}

.comment-reply-button {
  margin-top: .45rem;
  border: 0;
  background: transparent;
  color: var(--blue);
  padding: 0;
  font-size: .7rem;
  font-weight: 800;
}

.comment-reply-button:hover,
.comment-reply-button:focus-visible {
  text-decoration: underline;
}

.discussion-empty {
  margin: .2rem 0;
}

.comment-attachments {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .55rem;
  margin-top: .7rem;
}

.attachment-tile {
  display: grid;
  min-width: 0;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: .6rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  padding: .45rem;
  text-align: left;
}

.attachment-tile:hover,
.attachment-tile:focus-visible {
  border-color: #91a7ff;
  box-shadow: 0 0 0 3px #edf2ff;
}

.attachment-preview {
  display: grid;
  width: 48px;
  height: 48px;
  overflow: hidden;
  place-items: center;
  border-radius: 8px;
  background: #f2f4f7;
}

.attachment-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.attachment-file-icon {
  display: inline-grid;
  min-width: 34px;
  height: 30px;
  place-items: center;
  border-radius: 6px;
  background: #e9ecef;
  color: #475467;
  padding: 0 .35rem;
  font-size: .55rem;
  font-weight: 900;
  letter-spacing: .03em;
}

.attachment-file-icon.pdf { background: #fff0f0; color: #c92a2a; }
.attachment-file-icon.archive { background: #fff9db; color: #a15c00; }

.attachment-copy {
  display: grid;
  min-width: 0;
  gap: .12rem;
}

.attachment-copy strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .72rem;
}

.attachment-copy small {
  color: var(--muted);
  font-size: .62rem;
}

.attachment-action {
  grid-column: 2;
  color: var(--blue);
  font-size: .62rem;
  font-weight: 800;
}

.discussion-form {
  display: grid;
  gap: .65rem;
  margin-top: 1.2rem;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}

.discussion-form textarea {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: .7rem;
}

.reply-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  border: 1px solid #bac8ff;
  border-radius: 9px;
  background: #edf2ff;
  color: #364fc7;
  padding: .5rem .65rem;
  font-size: .7rem;
  font-weight: 750;
}

.reply-banner[hidden] { display: none; }

.reply-banner button {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: .68rem;
  font-weight: 850;
  text-decoration: underline;
}

.discussion-form-actions {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: .75rem;
}

.attachment-picker-wrap {
  display: flex;
  min-width: 0;
  align-items: center;
  flex-wrap: wrap;
  gap: .35rem .6rem;
}

.attachment-picker-wrap small {
  color: var(--muted);
  font-size: .64rem;
}

.attachment-queue {
  display: grid;
  gap: .45rem;
}

.attachment-queue[hidden],
.discussion-submit-error[hidden] {
  display: none;
}

.upload-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .35rem .75rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f8f9fb;
  padding: .55rem .65rem;
}

.upload-item-copy {
  display: grid;
  min-width: 0;
  gap: .15rem;
}

.upload-item-copy strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .7rem;
}

.upload-item-copy small {
  color: var(--muted);
  font-size: .62rem;
}

.upload-item progress {
  width: 100%;
  height: 5px;
  grid-column: 1 / -1;
  accent-color: var(--blue);
}

.upload-item.is-uploaded { border-color: #96f2d7; background: #f1fdf8; }
.upload-item.is-error { border-color: #ffc9c9; background: #fff5f5; }

.upload-actions {
  display: flex;
  align-items: center;
  gap: .45rem;
}

.upload-actions button {
  border: 0;
  background: transparent;
  color: var(--blue);
  padding: 0;
  font-size: .65rem;
  font-weight: 800;
}

.upload-actions button[data-upload-remove] { color: #c92a2a; }
.upload-actions button[hidden] { display: none; }

.attachment-viewer {
  width: min(1080px, calc(100% - 2rem));
  max-width: none;
  height: min(820px, calc(100vh - 2rem));
  max-height: none;
  overflow: hidden;
  border: 0;
  border-radius: 18px;
  background: #111827;
  color: #fff;
  padding: 0;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .42);
}

.attachment-viewer::backdrop {
  background: rgba(15, 23, 42, .76);
  backdrop-filter: blur(5px);
}

.attachment-viewer-shell {
  display: grid;
  height: 100%;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.attachment-viewer-header,
.attachment-viewer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .8rem 1rem;
}

.attachment-viewer-header {
  border-bottom: 1px solid #344054;
}

.attachment-viewer-header h2 {
  max-width: min(70vw, 720px);
  overflow: hidden;
  margin: .12rem 0 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .92rem;
}

.attachment-viewer-count {
  color: #98a2b3;
  font-size: .65rem;
}

.attachment-viewer-stage {
  display: grid;
  min-height: 0;
  place-items: center;
  overflow: hidden;
  background: #0b1220;
}

.attachment-viewer-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.attachment-pdf-view {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 0;
  place-items: center;
  overflow: auto;
  padding: 1rem;
}

.attachment-pdf-view canvas {
  display: block;
  max-width: 100%;
  background: #fff;
  box-shadow: 0 12px 35px rgba(0, 0, 0, .4);
}

.attachment-pdf-loading,
.attachment-pdf-error {
  display: grid;
  max-width: 460px;
  justify-items: center;
  gap: .9rem;
  color: #d0d5dd;
  padding: 2rem;
  text-align: center;
}

.attachment-pdf-loading > span {
  width: 2rem;
  height: 2rem;
  border: 3px solid #475467;
  border-top-color: #a6ff3d;
  border-radius: 50%;
  animation: attachment-pdf-spin .8s linear infinite;
}

.attachment-pdf-loading p,
.attachment-pdf-error p {
  margin: 0;
  font-size: .82rem;
  line-height: 1.6;
}

.attachment-pdf-error > div {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .5rem;
}

@keyframes attachment-pdf-spin {
  to { transform: rotate(360deg); }
}

.attachment-viewer-stage [hidden] { display: none; }

.attachment-no-preview {
  display: grid;
  max-width: 430px;
  justify-items: center;
  gap: 1rem;
  color: #d0d5dd;
  padding: 2rem;
  text-align: center;
}

.attachment-no-preview .attachment-file-icon {
  width: 82px;
  height: 68px;
  background: #344054;
  color: #fff;
  font-size: .72rem;
}

.attachment-no-preview p {
  margin: 0;
  font-size: .82rem;
  line-height: 1.6;
}

.attachment-viewer-footer {
  border-top: 1px solid #344054;
  flex-wrap: wrap;
}

.attachment-viewer-nav {
  display: flex;
  gap: .5rem;
}

.attachment-pdf-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
}

.attachment-pdf-controls > span {
  min-width: 3.5rem;
  color: #d0d5dd;
  font-size: .72rem;
  font-weight: 800;
  text-align: center;
}

.attachment-viewer-links {
  display: flex;
  gap: .5rem;
}

.attachment-viewer .button.ghost {
  border-color: #475467;
  background: transparent;
  color: #fff;
}

@media (max-width: 620px) {
  .comment-thread-row.comment-depth-1 { margin-left: .4rem; }
  .comment-thread-row.comment-depth-2 { margin-left: .8rem; }
  .comment-thread-row.comment-depth-3 { margin-left: 1.2rem; }
  .comment-thread-row.comment-depth-4 { margin-left: 1.6rem; }
  .comment-attachments { grid-template-columns: 1fr; }
  .discussion-form-actions { align-items: stretch; flex-direction: column; }
  .discussion-form-actions > .button { width: 100%; }
  .attachment-picker-wrap { align-items: stretch; flex-direction: column; }
  .attachment-viewer { width: 100%; height: 100%; max-height: 100%; border-radius: 0; }
  .attachment-viewer-header h2 { max-width: 62vw; }
  .attachment-viewer-footer { align-items: stretch; flex-direction: column; }
  .attachment-viewer-nav { display: grid; grid-template-columns: 1fr 1fr; }
  .attachment-pdf-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
  .attachment-viewer-links { display: grid; grid-template-columns: 1fr 1fr; }
  .attachment-viewer-footer .button { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  .attachment-viewer::backdrop { backdrop-filter: none; }
  .attachment-pdf-loading > span { animation: none; }
}

.comment-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; margin-top: .55rem; }
.comment-actions form { margin: 0; }
.comment-pin-label { width: fit-content; margin: .35rem 0; border-radius: 999px; background: #fff5d9; padding: .25rem .5rem; color: #8a5b00; font-size: .68rem; font-weight: 850; }
