/* ─── Discussions ────────────────────────────────────────────────────────── */

/* ── Sheet layout ── */

.disc-sheet {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

.disc-sheet-topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.625rem 1.5rem;
    flex-shrink: 0;
}

.disc-sheet-topbar-meta {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    flex-wrap: wrap;
    min-width: 0;
}

.disc-sheet-topbar-info {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    color: var(--foreground-subtle);
}

.disc-sheet-topbar-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.disc-sheet-content {
    padding: 0 1.5rem 4rem;
}

.disc-sidebar-section {
    padding: 1.25rem 1.25rem 0.5rem;
    border-bottom: 1px solid var(--border);
}

.disc-sidebar-section:last-child {
    border-bottom: none;
}

.disc-sidebar-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.875rem;
}

.disc-sidebar-section-title {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--foreground-subtle);
    font-weight: 400;
}

.disc-sidebar-task-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.disc-sidebar-empty {
    padding: 0.5rem 0 0.75rem;
}

/* ── Index ── */

.disc-index {
}

.disc-index-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: 1rem;
}

.disc-tabs {
    display: flex;
    align-items: center;
    gap: 0.125rem;
}

.disc-tab {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    border-radius: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--foreground-subtle);
    transition:
        color 0.15s,
        background-color 0.15s;
    text-decoration: none;
}

.disc-tab svg {
    width: 1rem;
    height: 1rem;
}

.disc-tab:hover {
    color: var(--foreground);
    background-color: var(--surface);
}

.disc-tab.active {
    color: var(--foreground);
    font-weight: 500;
}

.disc-tab-count {
    font-size: 0.6875rem;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0 0.375rem;
    color: var(--foreground-subtle);
}

.disc-list {
    border: 1px solid var(--border);
    border-radius: 0.625rem;
    overflow: hidden;
}

.disc-empty {
    padding: 3rem;
    text-align: center;
}

/* ── List row ── */

.disc-row {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border);
    background-color: white;
    transition: background-color 0.1s;
}

.disc-row:last-child {
    border-bottom: none;
}
.disc-row:hover {
    background-color: var(--surface);
}

.disc-row-left {
    flex-shrink: 0;
    padding-top: 0.125rem;
}

.disc-status-icon svg {
    width: 1rem;
    height: 1rem;
}

.disc-status-icon.open {
    color: hsl(142, 70%, 38%);
}
.disc-status-icon.closed {
    color: var(--foreground-subtle);
}

.disc-row-body {
    flex: 1;
    min-width: 0;
}

.disc-row-title {
    font-family: var(--font-serif);
    font-size: 0.9375rem;
    color: var(--foreground);
    display: block;
    margin-bottom: 0.25rem;
    text-decoration: none;
}

.disc-row-title:hover {
    color: var(--accent);
}

.disc-row-meta {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    color: var(--foreground-subtle);
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.disc-row-right {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.disc-comment-count {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    color: var(--foreground-subtle);
}

.disc-comment-count svg {
    width: 0.875rem;
    height: 0.875rem;
}

/* ── Show page — reading layout ── */

.disc-read {
}

/* ── Subtle meta row (above the article card) ── */

.disc-read-meta-row {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--foreground-subtle);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.disc-meta-sep {
    display: inline-flex;
    align-items: center;
}

/* ── Tab bar (Discussion / Tasks / Activity) ── */

.disc-show-tab-bar {
    display: flex;
    align-items: center;
    gap: 0.125rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

.disc-show-tab {
    background: none;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--foreground-subtle);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.15s;
}

.disc-show-tab:hover {
    color: var(--foreground);
}

.disc-show-tab.active {
    color: var(--foreground);
    font-weight: 500;
    border-bottom-color: var(--accent);
}

/* ── Unified article card (discussion body only) ── */

.disc-article-card {
    position: relative;
    background: white;
    border: 1px solid var(--border);
    border-radius: 0.625rem;
    padding: 2rem 2.5rem;
    margin-bottom: 1.5rem;
}

/* ── Comments section (below the discussion card) ── */

.disc-comments-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.disc-comments-header {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--foreground-subtle);
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.25rem;
}

/* ── Comment card (each top-level comment isolated) ── */

.disc-comment-card {
    display: flex;
    gap: 0.875rem;
    background: white;
    border: 1px solid var(--border);
    border-radius: 0.625rem;
    padding: 1.25rem 1.5rem;
}

/* ── Article title (first thing inside the card) ── */

.disc-article-title {
    font-family: var(--font-serif);
    font-size: 2rem;
    font-weight: 400;
    color: var(--foreground);
    line-height: 1.25;
    margin-bottom: 1.25rem;
}

/* ── Badge ── */

.disc-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.25rem 0.625rem;
    border-radius: 999px;
    border: 1px solid;
}

.disc-badge svg {
    width: 0.875rem;
    height: 0.875rem;
}

.disc-badge.open {
    background-color: hsl(142, 70%, 95%);
    color: hsl(142, 70%, 30%);
    border-color: hsl(142, 50%, 80%);
}

.disc-badge.closed {
    background-color: var(--surface);
    color: var(--foreground-subtle);
    border-color: var(--border);
}

.disc-inline-link {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.disc-inline-link:hover {
    color: var(--accent-hover);
}

/* ── Discussion body — inside unified card (no own card styles) ── */

.disc-body {
    margin-bottom: 0;
}

/* ── Legacy .disc-comment (kept for compatibility) ── */

.disc-comment {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

/* ── Divider (legacy) ── */

.disc-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2rem 0;
}

/* ── Activity section ── */

.disc-activity-label {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--foreground-subtle);
    margin-bottom: 1.5rem;
}

/* ── Vertical timeline ── */

.disc-timeline {
    position: relative;
    padding: 0.5rem 0;
}

/* The vertical line */
.disc-timeline::before {
    content: "";
    position: absolute;
    left: 0.9375rem;
    top: 0;
    bottom: 0;
    width: 1px;
    background-color: var(--border);
}

/* ── Single event row ── */

.disc-event {
    display: flex;
    align-items: flex-start;
    gap: 0.875rem;
    padding: 0.5rem 0;
    position: relative;
}

.disc-event-icon {
    flex-shrink: 0;
    width: 1.875rem;
    height: 1.875rem;
    border-radius: 50%;
    background-color: white;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.disc-event-icon svg {
    width: 0.875rem;
    height: 0.875rem;
    color: var(--foreground-subtle);
}

/* Icon color variants */
.disc-event-icon--comment-added,
.disc-event-icon--reply-added {
    border-color: hsl(214, 60%, 80%);
    background-color: hsl(214, 100%, 97%);
}
.disc-event-icon--comment-added svg,
.disc-event-icon--reply-added svg {
    color: hsl(214, 70%, 45%);
}

.disc-event-icon--task-spawned {
    border-color: hsl(142, 50%, 75%);
    background-color: hsl(142, 70%, 96%);
}
.disc-event-icon--task-spawned svg {
    color: hsl(142, 60%, 35%);
}

.disc-event-icon--status-changed {
    border-color: var(--border);
    background-color: var(--surface);
}

.disc-event-icon--assignee-id-changed {
    border-color: hsl(280, 50%, 80%);
    background-color: hsl(280, 80%, 97%);
}
.disc-event-icon--assignee-id-changed svg {
    color: hsl(280, 60%, 45%);
}

.disc-event-icon--due-date-changed {
    border-color: hsl(38, 70%, 75%);
    background-color: hsl(38, 100%, 96%);
}
.disc-event-icon--due-date-changed svg {
    color: hsl(38, 80%, 40%);
}

/* ── Event body ── */

.disc-event-body {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.25rem 0.375rem;
    padding-top: 0.3125rem;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--foreground-subtle);
}

.disc-event-actor {
    font-weight: 500;
    color: var(--foreground);
}

.disc-event-desc {
}

.disc-event-link {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.disc-event-link:hover {
    color: var(--accent-hover);
}

.disc-event-time {
    margin-left: 0.25rem;
    opacity: 0.7;
}

.disc-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background-color: var(--accent);
    color: white;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.disc-avatar-sm {
    width: 1.5rem;
    height: 1.5rem;
    font-size: 0.625rem;
}

.disc-comment-content {
    flex: 1;
    min-width: 0;
}

.disc-comment-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.disc-comment-author {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--foreground);
}

.disc-comment-time {
}

.disc-comment-action {
    margin-left: auto;
}

.disc-comment-body {
}

/* ── Replies ── */

.disc-replies {
    margin-top: 1rem;
    padding-left: 1rem;
    border-left: 2px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.disc-reply {
    display: flex;
    gap: 0.625rem;
    align-items: flex-start;
}

.disc-reply-content {
    flex: 1;
    min-width: 0;
}

/* ── Reply toggle ── */

.disc-reply-toggle {
    margin-top: 0.75rem;
}

.disc-reply-trigger {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--accent);
    cursor: pointer;
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.disc-reply-trigger::-webkit-details-marker {
    display: none;
}
.disc-reply-trigger:hover {
    color: var(--accent-hover);
}

.disc-reply-form {
    margin-top: 0.75rem;
}

/* ── Comment compose — inside unified card ── */

.disc-card-compose {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

/* ── Legacy compose (outside card) ── */

.disc-comment-compose {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.disc-comment-compose-avatar {
    padding-top: 0.25rem;
    flex-shrink: 0;
}

.disc-comment-compose-body {
    flex: 1;
    min-width: 0;
}

.disc-compose-actions {
    margin-top: 0.75rem;
    display: flex;
    justify-content: flex-start;
}

.disc-compose-actions--card {
    justify-content: flex-end;
}

/* ── Quote pending block (in compose) ── */

.disc-quote-pending {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    background-color: hsl(45, 100%, 96%);
    border: 1px solid hsl(45, 70%, 80%);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--foreground-subtle);
}

.disc-quote-pending-label {
    font-weight: 500;
    white-space: nowrap;
    color: hsl(40, 60%, 40%);
}

.disc-quote-pending-text {
    flex: 1;
    color: var(--foreground);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-style: italic;
}

.disc-quote-pending-remove {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    color: var(--foreground-subtle);
    padding: 0;
    flex-shrink: 0;
}

.disc-quote-pending-remove:hover {
    color: var(--foreground);
}

/* ── Floating quote button ── */

.disc-quote-btn {
    position: absolute;
    background-color: var(--foreground);
    color: white;
    border: none;
    border-radius: 0.5rem;
    padding: 0.25rem 0.625rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    cursor: pointer;
    z-index: 10;
    white-space: nowrap;
}

.disc-quote-btn:hover {
    background-color: var(--accent);
}

/* ── Highlight in body ── */

.disc-quote-highlight {
    background-color: hsl(45, 100%, 80%);
    border-radius: 0.25rem;
    cursor: pointer;
    padding: 0.05em 0;
}

.disc-quote-highlight:hover {
    background-color: hsl(45, 100%, 70%);
}

/* ── Quote reference in comment ── */

.disc-comment-quote {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--foreground-subtle);
    border-left: 2px solid hsl(45, 70%, 65%);
    background-color: hsl(45, 100%, 97%);
    padding: 0.375rem 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 0 0.5rem 0.5rem 0;
    font-style: italic;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Hover popover for highlights ── */

.disc-quote-popover {
    background-color: var(--foreground);
    color: white;
    border-radius: 0.5rem;
    padding: 0.375rem 0.625rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    display: flex;
    gap: 0.5rem;
    align-items: center;
    pointer-events: none;
    z-index: 100;
    white-space: nowrap;
}

.disc-quote-popover-author {
    font-weight: 500;
}
.disc-quote-popover-time {
    opacity: 0.7;
}

/* ── Closed banner ── */

.disc-closed-banner {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--foreground-subtle);
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.625rem;
    padding: 0.625rem 1rem;
    margin-bottom: 1rem;
}

/* ── Editor (write/preview tabs) ── */

.disc-editor {
    border: 1px solid var(--border);
    border-radius: 0.625rem;
    overflow: hidden;
}

/* ── Toolbar ── */

.disc-editor-toolbar {
    display: flex;
    align-items: center;
    gap: 0.125rem;
    padding: 0.375rem 0.5rem;
    border-bottom: 1px solid var(--border);
    background-color: var(--surface);
}

.disc-toolbar-btn {
    background: none;
    border: none;
    border-radius: 0.5rem;
    padding: 0.25rem 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--foreground-subtle);
    cursor: pointer;
    transition:
        color 0.1s,
        background-color 0.1s;
    line-height: 1;
}

.disc-toolbar-btn:hover {
    color: var(--foreground);
    background-color: var(--border);
}

.disc-toolbar-sep {
    width: 1px;
    height: 1rem;
    background-color: var(--border);
    margin: 0 0.25rem;
    flex-shrink: 0;
}

.disc-editor-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    background-color: var(--surface);
}

.disc-editor-tab {
    background: none;
    border: none;
    padding: 0.5rem 1rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--foreground-subtle);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.15s;
}

.disc-editor-tab:hover {
    color: var(--foreground);
}

.disc-editor-tab.active {
    color: var(--foreground);
    border-bottom-color: var(--accent);
}

.disc-editor-textarea {
    width: 100%;
    padding: 0.75rem;
    border: none;
    background-color: white;
    color: var(--foreground);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    line-height: 1.6;
    resize: vertical;
    outline: none;
    display: block;
}

.disc-preview-pane {
    padding: 0.75rem;
    min-height: 5rem;
    background-color: white;
}

/* ── Form ── */

.disc-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.disc-form-title-field {
}

.disc-title-input {
    width: 100%;
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 400;
    color: var(--foreground);
    background: none;
    border: none;
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 0;
    outline: none;
    transition: border-color 0.15s;
}

.disc-title-input:focus {
    border-bottom-color: var(--accent);
}
.disc-title-input::placeholder {
    color: var(--foreground-subtle);
}

.disc-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.disc-form-col {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.disc-form-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* ── Buttons ── */

.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.8125rem;
}

/* ── Page title (new/edit) ── */

.disc-page-title {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 400;
    color: var(--foreground);
    margin-bottom: 1.5rem;
}

/* ── Comment form footer ── */

.disc-comment-form-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

/* ── Prose (rendered markdown) ── */

.prose {
    font-family: var(--font-serif);
    font-size: 0.9375rem;
    line-height: 1.65;
    color: var(--foreground);
}

.disc-body.prose {
    font-size: 0.9375rem;
    line-height: 1.65;
}

.prose p {
    margin-bottom: 1em;
}
.prose p:last-child {
    margin-bottom: 0;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4,
.prose h5,
.prose h6 {
    font-family: var(--font-serif);
    font-weight: 500;
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    line-height: 1.3;
}

.prose h1 {
    font-size: 1.5em;
}
.prose h2 {
    font-size: 1.25em;
}
.prose h3 {
    font-size: 1.125em;
}

.prose ul,
.prose ol {
    padding-left: 1.5em;
    margin-bottom: 1em;
}

.prose li {
    margin-bottom: 0.25em;
}

.prose code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.1em 0.35em;
}

.prose pre {
    background-color: hsl(220, 14%, 10%);
    border-radius: 0.625rem;
    padding: 1rem;
    overflow-x: auto;
    margin-bottom: 1em;
}

.prose pre code {
    background: none;
    border: none;
    padding: 0;
    color: hsl(220, 15%, 85%);
    font-size: 0.875em;
}

.prose blockquote {
    border-left: 3px solid var(--border);
    padding-left: 1em;
    color: var(--foreground-muted);
    font-style: italic;
    margin-bottom: 1em;
}

.prose a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.prose hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5em 0;
}

.prose table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1em;
    font-size: 0.9em;
}

.prose th,
.prose td {
    border: 1px solid var(--border);
    padding: 0.5rem 0.75rem;
    text-align: left;
}

.prose th {
    background-color: var(--surface);
    font-family: var(--font-mono);
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
