:root {
    --border: #dde1e7;
    --text: #1f2430;
    --muted: #6b7280;
    --accent: #1b4f8c;
    --accent-soft: #eaf1fb;
    --bg: #f4f6f8;
    --surface: #ffffff;
    --sidebar-bg: #182338;
    --sidebar-text: #c3cbdb;
    --sidebar-text-dim: #7c879c;
    --sidebar-active: #24324d;
    --danger: #b42318;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
}

a { color: var(--accent); }

/* Top bar */
header.topbar {
    background: var(--sidebar-bg);
    color: #fff;
    padding: 0.6rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 48px;
}

header.topbar .brand {
    font-weight: 600;
    color: #fff;
    text-decoration: none;
    letter-spacing: 0.01em;
}

header.topbar .user {
    font-size: 0.85rem;
    color: var(--sidebar-text);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

header.topbar .user a { color: #fff; text-decoration: none; opacity: 0.8; }
header.topbar .user a:hover { opacity: 1; }

.link-button {
    background: none;
    border: none;
    color: #fff;
    opacity: 0.8;
    padding: 0;
    margin: 0;
    font-size: inherit;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
}
.link-button:hover { opacity: 1; }

.role-badge {
    background: rgba(255,255,255,0.12);
    border-radius: 4px;
    padding: 0.1rem 0.4rem;
    font-size: 0.75rem;
    margin-left: 0.35rem;
}

/* Shell: sidebar + content */
.shell {
    display: flex;
    align-items: stretch;
    min-height: calc(100vh - 48px);
}

.sidebar {
    width: 240px;
    min-width: 180px;
    max-width: 440px;
    flex: 0 0 auto;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    min-height: calc(100vh - 48px);
    padding: 1rem 0;
    overflow-x: hidden;
}

.sidebar.is-empty,
.sidebar.is-empty + .resize-handle { display: none; }

.resize-handle {
    flex: 0 0 5px;
    width: 5px;
    min-height: calc(100vh - 48px);
    cursor: col-resize;
    background: transparent;
    position: relative;
}

.resize-handle:hover,
.resize-handle:focus-visible {
    background: var(--accent);
    opacity: 0.4;
    outline: none;
}

body.sidebar-resizing {
    cursor: col-resize;
    user-select: none;
}
body.sidebar-resizing .resize-handle { background: var(--accent); opacity: 0.6; }

.sidebar-section { margin-bottom: 1.25rem; padding: 0 0.9rem; }

.sidebar-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--sidebar-text-dim);
    margin-bottom: 0.4rem;
    padding: 0 0.4rem;
}

.system-switcher select {
    width: 100%;
    background: var(--sidebar-active);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    padding: 0.4rem 0.5rem;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 0.1rem; }

.sidebar-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--sidebar-text);
    text-decoration: none;
    padding: 0.45rem 0.6rem;
    border-radius: 6px;
    font-size: 0.9rem;
}

.sidebar-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar-link.active { background: var(--accent); color: #fff; font-weight: 500; }

.sidebar-link .count {
    font-size: 0.75rem;
    background: rgba(255,255,255,0.12);
    border-radius: 10px;
    padding: 0.05rem 0.45rem;
}
.sidebar-link.active .count { background: rgba(255,255,255,0.25); }

/* Content */
.content {
    flex: 1 1 auto;
    padding: 1.5rem 2rem;
    max-width: 1100px;
}

.page-header { margin-bottom: 1.25rem; }
.page-header h1 { margin: 0 0 0.2rem 0; font-size: 1.35rem; }

h2 { font-size: 1.05rem; margin: 1.75rem 0 0.75rem; }

.flash {
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* Cards / grid */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0.9rem;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem 1.15rem;
}

a.card-link { text-decoration: none; color: inherit; display: block; transition: border-color 0.15s; }
a.card-link:hover { border-color: var(--accent); }

.card-title { font-weight: 600; font-size: 1rem; }
.card .meta, .meta { font-size: 0.85rem; color: var(--muted); margin-top: 0.2rem; }
.card-stats { display: flex; gap: 1.25rem; margin-top: 0.75rem; padding-top: 0.6rem; border-top: 1px solid var(--border); }
.card-stat { display: flex; flex-direction: column; gap: 0.1rem; }
.card-stat-value { font-size: 1.05rem; font-weight: 700; color: var(--accent); line-height: 1.1; }
.card-stat-label { font-size: 0.72rem; color: var(--muted); }

/* Stat tiles */
.stat-row { display: flex; gap: 0.9rem; margin: 1.25rem 0; flex-wrap: wrap; }
.stat-tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    text-decoration: none;
    color: inherit;
    min-width: 140px;
    flex: 1 1 140px;
}
.stat-tile:hover { border-color: var(--accent); }
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 0.85rem; color: var(--muted); margin-top: 0.15rem; }

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    font-size: 0.9rem;
}
.data-table th, .data-table td {
    text-align: left;
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--border);
}
.data-table th { background: #f8f9fb; font-size: 0.78rem; text-transform: uppercase; color: var(--muted); letter-spacing: 0.03em; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background-color 0.12s ease; }
.data-table tbody tr:hover { background-color: var(--accent-soft); }

.count {
    font-size: 0.75rem;
    color: var(--muted);
    font-weight: 400;
}

.badge {
    display: inline-block;
    font-size: 0.72rem;
    border-radius: 4px;
    padding: 0.05rem 0.4rem;
    margin-left: 0.4rem;
}
.badge-draft { background: #fff3cd; color: #7a5c00; }
.badge-final { background: #e6f4ea; color: #1e7b34; }

/* Attachment cards (uploaded reports/scripts/documentation/generated documents) */
.attachment-list { display: flex; flex-direction: column; gap: 0.7rem; margin-bottom: 1.25rem; }

.attachment-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.9rem 1.1rem;
    display: flex;
    gap: 0.9rem;
    align-items: flex-start;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.attachment-card:hover { border-color: var(--accent); box-shadow: 0 2px 12px rgba(27,79,140,0.08); }

.attachment-icon {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.attachment-icon-clickable {
    cursor: pointer;
    transition: background-color 0.12s ease, color 0.12s ease;
}
.attachment-icon-clickable:hover,
.attachment-icon-clickable.is-active {
    background: var(--accent);
    color: #fff;
}
.attachment-icon-clickable:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Preview toggle triggered by the file-type icon, not a visible "Предпросмотр" link */
.preview-toggle-icon-driven > summary { display: none; }

.page-header-with-icon { display: flex; gap: 0.9rem; align-items: flex-start; }
.page-header-with-icon .page-header-body { flex: 1 1 auto; min-width: 0; }
.attachment-icon-lg { width: 48px; height: 48px; font-size: 0.74rem; margin-top: 0.1rem; }

.attachment-body { flex: 1 1 auto; min-width: 0; }

.attachment-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.attachment-title { font-weight: 600; font-size: 0.98rem; }
.attachment-meta { font-size: 0.82rem; color: var(--muted); margin-top: 0.2rem; }
.attachment-desc { font-size: 0.88rem; margin: 0.45rem 0 0; color: var(--text); }
.attachment-desc-empty { color: var(--muted); font-style: italic; }

/* Double-click-to-edit (title/description on attachment cards and the document page) */
form.inline-edit { display: contents; }
[data-display] {
    cursor: text;
    border-radius: 4px;
    padding: 0.05rem 0.25rem;
    margin: -0.05rem -0.25rem;
}
[data-display]:hover { background: var(--accent-soft); }
.inline-edit-input {
    width: 100%;
    font: inherit;
    font-weight: inherit;
    color: inherit;
    padding: 0.2rem 0.4rem;
    border: 1px solid var(--accent);
    border-radius: 4px;
    background: #fff;
}
textarea.inline-edit-input { resize: vertical; min-height: 3.2em; margin-top: 0.45rem; }
.inline-edit-input-h1 { font-size: 1.35rem; font-weight: 700; }

.attachment-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex: 0 0 auto;
    font-size: 0.8rem;
}
.attachment-actions a,
.attachment-delete-btn {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.65rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: background-color 0.12s ease, color 0.12s ease;
}
.attachment-actions a {
    color: var(--accent);
    background: var(--accent-soft);
}
.attachment-actions a:hover { background: var(--accent); color: #fff; }

.attachment-delete-btn {
    background: #fdeceb;
    color: var(--danger);
    margin: 0;
}
.attachment-delete-btn:hover { background: var(--danger); color: #fff; }

.attachment-card .preview-toggle { margin: 0.9rem 0 0; }

/* Feature panel — visually separates a distinct capability (e.g. document generation
   + preview) from the surrounding list/table content on the same page. */
.feature-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 10px;
    padding: 1.1rem 1.25rem 1.3rem;
    margin: 1.25rem 0 1.75rem;
}
.feature-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.feature-panel-header h2 { margin: 0; font-size: 1.05rem; }
.feature-panel-header form,
.feature-panel-header button { margin: 0; }
.feature-panel .attachment-list { margin-bottom: 0; }
.feature-panel > .empty { margin: 0; }

/* Forms */
form.stacked p { margin: 0.6rem 0; display: flex; flex-direction: column; gap: 0.25rem; }
form.stacked label { font-size: 0.85rem; color: var(--muted); }
form.stacked input, form.stacked select, form.stacked textarea {
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
}
form.stacked ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
form.stacked ul label { display: flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; color: var(--text); cursor: pointer; }
form.stacked ul input[type="radio"] { width: auto; padding: 0; }

.login-form { max-width: 360px; }

.totp-qr { max-width: 220px; margin: 1rem 0; }
.totp-qr svg { width: 100%; height: auto; }

button, input[type="submit"] {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    cursor: pointer;
    margin-top: 0.5rem;
}

a.btn-secondary {
    display: inline-flex;
    align-items: center;
    background: #fff;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 6px;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    cursor: pointer;
    margin-top: 0.5rem;
    text-decoration: none;
}

.doc-preview {
    width: 100%;
    height: 75vh;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}

.doc-preview-image {
    display: block;
    max-width: 100%;
    height: 75vh;
    margin: 0 auto;
    object-fit: contain;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}

.empty { color: var(--muted); font-style: italic; }
.errorlist { color: var(--danger); font-size: 0.85rem; }

/* Collapsible preview */
.preview-toggle { margin: 1.25rem 0; }
.preview-toggle summary {
    cursor: pointer;
    list-style: none;
    font-size: 1.05rem;
    font-weight: 600;
    padding: 0.4rem 0;
    user-select: none;
}
.preview-toggle summary::-webkit-details-marker { display: none; }
.preview-toggle .chevron {
    display: inline-block;
    transition: transform 0.15s;
    margin-right: 0.3rem;
    color: var(--muted);
}
.preview-toggle[open] .chevron { transform: rotate(90deg); }
.preview-toggle .preview-body { margin-top: 0.5rem; }
.report-preview { height: 55vh; }

/* Tabs */
.tab-nav { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.1rem; flex-wrap: wrap; }
.tab-btn {
    background: none;
    color: var(--muted);
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    margin: 0 0 -1px 0;
    padding: 0.6rem 0.9rem;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.is-active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

/* Evidence lock (per-item) */
.lock-note {
    background: #fff3cd;
    border: 1px solid #f0d58c;
    color: #7a5c00;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    margin-top: 0.6rem;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.badge-locked { background: #fff3cd; color: #7a5c00; }

.toolbar-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin: 1rem 0;
}
.toolbar-row form { margin: 0; }
.toolbar-row button,
.toolbar-row .btn-link-primary,
.toolbar-row .btn-secondary { margin-top: 0; }

.card-actions {
    margin-top: 0.6rem;
    display: flex;
    gap: 1rem;
    font-size: 0.85rem;
    align-items: center;
}

.inline-form { display: inline; margin: 0; }

.btn-secondary {
    background: #fff;
    color: var(--accent);
    border: 1px solid var(--accent);
}

.btn-sm {
    padding: 0.2rem 0.6rem;
    font-size: 0.78rem;
    margin-top: 0;
}

/* Hover menu on component name (Показать на схеме / Изменить) — positioned by hover-menu.js
   as position:fixed, so it is never clipped by the table/row and flips above the trigger
   when there isn't room below (e.g. for the last row in a list). */
.name-hover-wrap {
    position: relative;
    display: inline-block;
}
.name-hover-menu {
    display: none;
    position: fixed;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.18);
    padding: 0.3rem;
    white-space: nowrap;
    z-index: 100;
}
.name-hover-menu.is-open { display: flex; }
.name-hover-menu a {
    display: block;
    padding: 0.4rem 0.7rem;
    border-radius: 4px;
    font-size: 0.85rem;
    text-decoration: none;
}
.name-hover-menu a:hover { background: var(--accent-soft); }

/* Scrollable document list */
.doc-list-scroll {
    max-height: 420px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
}
.doc-list-scroll .data-table { border: none; border-radius: 0; }
.doc-list-scroll .data-table thead th {
    position: sticky;
    top: 0;
    background: #f8f9fb;
    z-index: 1;
}

/* Scrollable evidence list + draggable vertical divider */
.evidence-scroll {
    height: 320px;
    min-height: 120px;
    max-height: 900px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem;
    background: var(--bg);
}
.evidence-scroll .card:last-child { margin-bottom: 0; }

.h-resize-handle {
    height: 5px;
    margin: 2px 0;
    cursor: row-resize;
    background: transparent;
    border-radius: 3px;
}
.h-resize-handle:hover,
.h-resize-handle:focus-visible {
    background: var(--accent);
    opacity: 0.4;
    outline: none;
}
body.evidence-resizing { cursor: row-resize; user-select: none; }
body.evidence-resizing .h-resize-handle { background: var(--accent); opacity: 0.6; }

.btn-link-primary {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    border-radius: 6px;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    text-decoration: none;
}
.btn-link-primary:hover { opacity: 0.9; }

.btn-danger {
    background: var(--danger);
}
.btn-danger:hover { opacity: 0.9; }

/* Structural scheme editor */
.scheme-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin: 1rem 0;
}
.scheme-toolbar button,
.scheme-toolbar a.btn-secondary { margin-top: 0; }
.toolbar-sep { width: 1px; height: 22px; background: var(--border); }

.scheme-workspace {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.scheme-canvas-wrap {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
}

#scheme-image-viewport {
    width: 100%;
    height: 78vh;
    min-height: 420px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fbfcfe;
}

#scheme-image-stage {
    position: relative;
    display: inline-block;
    transform-origin: top left;
}

#scheme-image {
    display: block;
    max-width: none;
    user-select: none;
}

#scheme-hotspots {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.scheme-hotspot {
    position: absolute;
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
}
.scheme-hotspot:hover { border-color: rgba(27,79,140,0.55); background: rgba(27,79,140,0.08); }
.scheme-hotspot.active { border-color: #1b4f8c; background: rgba(27,79,140,0.16); }

.scheme-hotspot-link { border: 2px dashed transparent; border-radius: 3px; }
.scheme-hotspot-link:hover { border-color: rgba(176,88,0,0.6); background: rgba(176,88,0,0.1); }
.scheme-hotspot-link.active { border-color: #b05800; background: rgba(176,88,0,0.18); }

.badge-link { background: #fde8d6; color: #a04b00; }

.scheme-resize-handle {
    flex: 0 0 5px;
    width: 5px;
    min-height: 420px;
    align-self: stretch;
    cursor: col-resize;
    background: transparent;
    border-radius: 3px;
}
.scheme-resize-handle:hover,
.scheme-resize-handle:focus-visible {
    background: var(--accent);
    opacity: 0.4;
    outline: none;
}
body.scheme-panel-resizing { cursor: col-resize; user-select: none; }
body.scheme-panel-resizing .scheme-resize-handle { background: var(--accent); opacity: 0.6; }

.scheme-side-panel-wrap {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.scheme-legend {
    display: flex;
    gap: 0.9rem;
    font-size: 0.78rem;
    color: var(--text-muted, #5a6472);
}
.scheme-legend-item { display: inline-flex; align-items: center; gap: 0.35rem; }
.scheme-legend-swatch { width: 14px; height: 14px; border-radius: 3px; border: 2px solid; display: inline-block; }
.scheme-legend-swatch-component { border-color: #1b4f8c; background: rgba(27,79,140,0.16); }
.scheme-legend-swatch-link { border-style: dashed; border-color: #b05800; background: rgba(176,88,0,0.18); }

.scheme-side-panel {
    flex: 0 0 auto;
    width: 300px;
    min-width: 220px;
    max-width: 640px;
    height: 72vh;
    min-height: 420px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    padding: 1rem;
    font-size: 0.85rem;
}
.scheme-side-panel h4 { font-size: 0.85rem; margin: 0.9rem 0 0.3rem; }
.side-panel-title { font-weight: 600; font-size: 1rem; margin-bottom: 0.15rem; }
.side-mini-table { font-size: 0.8rem; margin: 0.4rem 0; }
.side-mini-table td { padding: 0.2rem 0.5rem; }
.side-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.side-list li { border-bottom: 1px solid var(--border); padding-bottom: 0.3rem; }

.btn-danger-link {
    background: none;
    border: none;
    color: var(--danger);
    padding: 0;
    margin: 0;
    font-size: 0.85rem;
    text-decoration: underline;
    cursor: pointer;
}

/* Activity feed (Лента) */
.activity-feed { list-style: none; margin: 0; padding: 0; }
.activity-item {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}
.activity-item:last-child { border-bottom: none; }
.activity-actor { font-weight: 600; }
.activity-verb { color: var(--muted); }
.activity-extra { color: var(--muted); font-style: italic; }
.activity-date { margin-left: auto; color: var(--muted); font-size: 0.76rem; white-space: nowrap; }

.feed-resize-handle {
    height: 5px;
    margin: 0.5rem 0 2px;
    cursor: row-resize;
    background: transparent;
    border-radius: 3px;
}
.feed-resize-handle:hover,
.feed-resize-handle:focus-visible {
    background: var(--accent);
    opacity: 0.4;
    outline: none;
}
body.panel-resizing .feed-resize-handle { background: var(--accent); opacity: 0.6; }

.activity-feed-scroll {
    height: 260px;
    min-height: 120px;
    max-height: 900px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0 0.75rem;
    background: var(--surface);
}
.activity-feed-scroll .activity-feed { padding: 0; }

/* Generic two-column detail layout (object card + resizable side panel) */
.detail-layout {
    display: flex;
    gap: 0;
    margin-top: 0.25rem;
}
.detail-main { flex: 1 1 auto; min-width: 0; }

.detail-resize-handle {
    flex: 0 0 5px;
    width: 5px;
    cursor: col-resize;
    background: transparent;
    border-radius: 3px;
    align-self: stretch;
    margin: 0 0.25rem;
}
.detail-resize-handle:hover,
.detail-resize-handle:focus-visible {
    background: var(--accent);
    opacity: 0.4;
    outline: none;
}
body.panel-resizing { cursor: col-resize; user-select: none; }
body.panel-resizing .detail-resize-handle { background: var(--accent); opacity: 0.6; }

.detail-side-panel {
    flex: 0 0 auto;
    width: 380px;
    min-width: 280px;
    max-width: 720px;
}
.detail-side-panel h2 { margin-top: 0; }

/* Comments */
.comment-thread { display: flex; flex-direction: column; gap: 1rem; margin-top: 0.75rem; }

.comment { display: flex; gap: 0.65rem; align-items: flex-start; }

.comment-avatar {
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.comment-is-deleted .comment-avatar { background: var(--border); color: var(--muted); }
.comment-deleted-text { color: var(--muted); font-style: italic; margin: 0.2rem 0 0.35rem; }

.comment-meta { display: flex; align-items: baseline; gap: 0.5rem; }
.comment-author { font-size: 0.85rem; font-weight: 600; }
.comment-date { font-size: 0.76rem; color: var(--muted); }

.comment-text {
    font-size: 0.9rem;
    line-height: 1.55;
    margin: 0.2rem 0 0.35rem;
    white-space: pre-line;
}

.comment-actions { margin-bottom: 0.2rem; display: flex; gap: 0.9rem; align-items: center; }
.comment-reply-toggle,
.comment-delete-btn {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font-size: 0.78rem;
    color: var(--muted);
    cursor: pointer;
}
.comment-reply-toggle:hover { color: var(--accent); text-decoration: underline; }
.comment-delete-btn:hover { color: var(--danger); text-decoration: underline; }

.comment-reply-form { margin: 0.5rem 0 0.25rem; }
.comment-reply-form textarea,
.comment-new-form textarea {
    width: 100%;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.88rem;
    font-family: inherit;
    resize: vertical;
}
.comment-form-actions { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.4rem; }
.comment-form-actions button { margin-top: 0; }

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

.comment-new-form { margin-top: 1rem; max-width: 640px; }

.emoji-trigger {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    width: 28px;
    height: 28px;
    padding: 0;
    margin-top: 0;
    font-size: 0.95rem;
    line-height: 1;
    cursor: pointer;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.emoji-trigger:hover { background: var(--accent-soft); border-color: var(--accent); }

.emoji-picker {
    position: fixed;
    z-index: 100;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.18);
    padding: 0.4rem;
    display: grid;
    grid-template-columns: repeat(8, 1.8rem);
    gap: 0.1rem;
}
.emoji-picker[hidden] { display: none; }
.emoji-picker-item {
    background: none;
    border: none;
    font-size: 1.05rem;
    line-height: 1.8rem;
    cursor: pointer;
    border-radius: 4px;
    padding: 0;
    margin: 0;
}
.emoji-picker-item:hover { background: var(--accent-soft); }
