/* ===== Design Tokens (Modern SaaS) ===== */
:root {
    /* Brand */
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;

    /* Semantic */
    --color-success: #16a34a;
    --color-danger: #dc2626;
    --color-warning: #d97706;

    /* Surfaces */
    --color-bg: #f6f8fb;              /* app canvas */
    --color-surface: #ffffff;         /* cards/panels */
    --color-surface-2: #fbfcfe;       /* subtle raised hover surface */
    --color-bg-secondary: #eef2f7;    /* hovers, muted blocks */
    --color-bg-tertiary: #e8edf5;     /* stronger hover / separators */

    /* Text */
    --color-text: #0f172a;
    --color-text-muted: #64748b;

    /* Borders / rings */
    --color-border: #e6eaf2;
    --color-border-strong: #d7deea;
    --focus-ring: 0 0 0 3px rgba(37, 99, 235, 0.18);

    /* Highlights in text */
    --color-highlight-pending: rgba(37, 99, 235, 0.12);
    --color-highlight-approved: rgba(22, 163, 74, 0.12);
    --color-highlight-rejected: rgba(220, 38, 38, 0.10);

    /* Typography */
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', 'Courier New', monospace;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* Shape / elevation */
    --radius: 10px;
    --radius-lg: 14px;

    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 10px 28px rgba(16, 24, 40, 0.10);
    --shadow-lg: 0 2px 6px rgba(16, 24, 40, 0.08), 0 18px 48px rgba(16, 24, 40, 0.14);
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
    font-family: var(--font-sans);
    color: var(--color-text);
    background: var(--color-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; }
:focus { outline: none; }
:focus-visible { box-shadow: var(--focus-ring); border-radius: 10px; }

/* ===== Utilities ===== */
.hidden { display: none !important; }
.loading-spinner { text-align: center; padding: 3rem; color: var(--color-text-muted); }
.text-muted { color: var(--color-text-muted); font-size: 0.875rem; }
.text-danger { color: var(--color-danger); }
.text-success { color: var(--color-success); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    border: 1px solid transparent;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.05s;
    text-decoration: none;
    white-space: nowrap;
}
.btn:active:not(:disabled) { transform: translateY(0.5px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: var(--color-primary);
    color: #fff;
    border-color: rgba(255,255,255,0.0);
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.10);
}
.btn-primary:hover:not(:disabled) { background: var(--color-primary-hover); }

.btn-ghost {
    background: transparent;
    color: var(--color-text-muted);
    border-color: transparent;
}
.btn-ghost:hover:not(:disabled) {
    background: rgba(15, 23, 42, 0.04);
    color: var(--color-text);
}

.btn-danger { background: var(--color-danger); color: #fff; border-color: transparent; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-success { background: var(--color-success); color: #fff; border-color: transparent; }

.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8125rem; border-radius: 10px; }

/* Vote pills */
.vote-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 600;
    border: 1px solid var(--color-border);
    cursor: pointer;
    transition: all 0.15s;
    background: var(--color-surface);
    color: var(--color-text-muted);
    box-shadow: var(--shadow-sm);
}
.vote-btn:hover { background: var(--color-surface-2); border-color: var(--color-border-strong); }
.vote-btn.active-for   { background: #dcfce7; color: var(--color-success); border-color: rgba(22,163,74,0.45); box-shadow: none; }
.vote-btn.active-against { background: #fee2e2; color: var(--color-danger); border-color: rgba(220,38,38,0.45); box-shadow: none; }
.vote-btn.active-abstain { background: #fef9c3; color: var(--color-warning); border-color: rgba(217,119,6,0.45); box-shadow: none; }

/* ===== Forms ===== */
.form-group { display: flex; flex-direction: column; gap: 0.375rem; margin-bottom: 1rem; }
label { font-size: 0.875rem; font-weight: 600; color: var(--color-text); }
input[type="text"], input[type="email"], textarea, select {
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    font-size: 0.9375rem;
    font-family: var(--font-sans);
    background: var(--color-surface);
    color: var(--color-text);
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
    width: 100%;
    box-shadow: var(--shadow-sm);
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: rgba(37, 99, 235, 0.55);
    box-shadow: var(--focus-ring);
}
textarea { resize: vertical; min-height: 120px; }
.error-msg { color: var(--color-danger); font-size: 0.8125rem; margin-top: 0.25rem; }
.form-actions { display: flex; gap: 0.5rem; margin-top: 1.5rem; }
.copy-options-label { font-size: 0.875rem; font-weight: 600; color: var(--color-text-secondary); }
.copy-options { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.copy-options label { display: flex; align-items: center; gap: 0.375rem; font-size: 0.875rem; cursor: pointer; }

/* ===== Header ===== */
#app-header {
    background: rgba(255, 255, 255, 0.9);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03), 0 8px 24px rgba(16, 24, 40, 0.06);
    backdrop-filter: blur(8px);
}
.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    height: 60px;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}
.logo {
    font-weight: 800;
    font-size: 1.05rem;
    color: var(--color-text);
    text-decoration: none;
    letter-spacing: -0.02em;
}
#app-nav { display: flex; gap: 0.25rem; flex: 1; }
.nav-link {
    padding: 0.45rem 0.75rem;
    border-radius: 12px;
    text-decoration: none;
    color: var(--color-text-muted);
    font-size: 0.875rem;
    font-weight: 600;
    transition: background 0.15s, color 0.15s;
}
.nav-link:hover { background: rgba(15, 23, 42, 0.04); color: var(--color-text); }
#user-area { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }
#user-menu { display: flex; align-items: center; gap: 0.75rem; }
#user-name-display { font-size: 0.875rem; font-weight: 600; color: var(--color-text-muted); }

/* ===== Main Layout ===== */
#app-main { flex: 1; }

/* ===== Cards ===== */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}
.card + .card { margin-top: 1rem; }

/* ===== Page containers ===== */
.page-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.page-title { font-size: 1.5rem; font-weight: 800; color: var(--color-text); letter-spacing: -0.02em; }

/* ===== Login view ===== */
.login-container {
    max-width: 420px;
    margin: 5rem auto;
    padding: 0 1.5rem;
}
.login-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 18px;
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
}
.login-card h1 { font-size: 1.5rem; font-weight: 900; margin-bottom: 0.5rem; letter-spacing: -0.02em; }
.login-card .subtitle { color: var(--color-text-muted); margin-bottom: 2rem; font-size: 0.9375rem; }
.otp-display {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: 0.3em;
    font-family: var(--font-mono);
    text-align: center;
    padding: 1rem;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: 14px;
    margin: 1rem 0;
}

/* ===== Document list ===== */
.doc-grid { display: grid; gap: 1rem; }
.doc-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    padding: 1.25rem;
    text-decoration: none;
    color: inherit;
    display: block;
    transition: box-shadow 0.15s, border-color 0.15s, transform 0.05s;
    box-shadow: var(--shadow-sm);
}
.doc-card:hover {
    box-shadow: var(--shadow);
    border-color: rgba(37, 99, 235, 0.35);
}
.doc-card-title { font-size: 1.0625rem; font-weight: 800; margin-bottom: 0.375rem; color: var(--color-text); letter-spacing: -0.01em; }
.doc-card-meta { font-size: 0.8125rem; color: var(--color-text-muted); display: flex; gap: 1rem; flex-wrap: wrap; }

.status-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border: 1px solid transparent;
}
.status-draft    { background: #f1f5f9; color: #64748b; border-color: rgba(100,116,139,0.25); }
.status-open     { background: #dbeafe; color: #1d4ed8; border-color: rgba(29,78,216,0.25); }
.status-voting   { background: #fef3c7; color: #92400e; border-color: rgba(146,64,14,0.25); }
.status-resolved { background: #dcfce7; color: #15803d; border-color: rgba(21,128,61,0.25); }
.status-archived { background: #f1f5f9; color: #94a3b8; border-color: rgba(148,163,184,0.25); }

/* Used in your uploaded HTML (was missing) */
.status-pending  { background: #e0f2fe; color: #075985; border-color: rgba(7,89,133,0.25); }

/* ===== Document view ===== */
.doc-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 1.5rem;
    align-items: start;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.75rem 1.5rem;
}
.doc-text-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow);
}
.doc-text-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: linear-gradient(to bottom, rgba(246,248,251,0.9), rgba(255,255,255,0));
}
.doc-text-header h2 { font-size: 1.0625rem; font-weight: 900; letter-spacing: -0.01em; }
.doc-text-body {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.75;
    overflow-x: auto;
}

/* Lines */
.doc-line {
    display: flex;
    align-items: baseline;
    padding: 0.2rem 0;
    border-bottom: 1px solid rgba(15, 23, 42, 0.03);
}
.doc-line:hover { background: rgba(15, 23, 42, 0.03); }

.line-num {
    min-width: 52px;
    text-align: right;
    padding: 0.1rem 0.75rem 0.1rem 0.5rem;
    color: rgba(100,116,139,0.9);
    user-select: none;
    font-size: 0.75rem;
    flex-shrink: 0;
}
.line-text {
    padding: 0.1rem 1rem 0.1rem 0;
    flex: 1;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Highlight blocks: add a subtle left rail for modern “annotation” feel */
.line-highlighted-pending,
.line-highlighted-approved,
.line-highlighted-rejected {
    position: relative;
    border-radius: 6px;
}
.line-highlighted-pending  { background: var(--color-highlight-pending); box-shadow: inset 3px 0 0 rgba(37,99,235,0.55); }
.line-highlighted-approved { background: var(--color-highlight-approved); box-shadow: inset 3px 0 0 rgba(22,163,74,0.55); }
.line-highlighted-rejected { background: var(--color-highlight-rejected); box-shadow: inset 3px 0 0 rgba(220,38,38,0.45); }

.line-text.has-variant { cursor: pointer; border-radius: 4px; }
.line-text.has-variant:hover { text-decoration: underline; text-decoration-color: rgba(37,99,235,0.65); }

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    border-top: 1px solid var(--color-border);
    background: rgba(246,248,251,0.65);
}
.pagination-info { color: var(--color-text-muted); font-size: 0.875rem; font-weight: 600; }

/* Sidebar */
.doc-sidebar { display: flex; flex-direction: column; gap: 1rem; position: sticky; top: 84px; }
.sidebar-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow);
}
.sidebar-header {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--color-border);
    font-weight: 900;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(246,248,251,0.65);
}
.sidebar-body { padding: 0.85rem; }

.variant-card {
    padding: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 14px;
    cursor: pointer;
    transition: box-shadow 0.15s, border-color 0.15s, background 0.15s;
    margin-bottom: 0.5rem;
    background: var(--color-surface);
    box-shadow: var(--shadow-sm);
}
.variant-card:hover {
    box-shadow: var(--shadow);
    border-color: rgba(37, 99, 235, 0.35);
    background: var(--color-surface-2);
}
.variant-card-title { font-weight: 900; font-size: 0.875rem; margin-bottom: 0.25rem; letter-spacing: -0.01em; }
.variant-card-meta { font-size: 0.75rem; color: var(--color-text-muted); font-weight: 600; }

.vote-mini { display: flex; gap: 0.5rem; margin-top: 0.5rem; font-size: 0.75rem; font-weight: 800; align-items: center; }
.vote-mini-for { color: var(--color-success); }
.vote-mini-against { color: var(--color-danger); }
.vote-mini-abstain { color: var(--color-warning); }
.comment-bubble { font-size: 0.75rem; font-weight: 400; color: var(--color-muted); }
.comment-bubble.comment-heat-orange { font-weight: 700; color: #d97706; }
.comment-bubble.comment-heat-red { font-weight: 700; color: #dc2626; }

/* ===== Variant detail ===== */
.variant-layout {
    max-width: 900px;
    margin: 0 auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
.variant-nav-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.variant-nav-arrows {
    display: flex;
    gap: 0.25rem;
}
.variant-nav-arrow {
    font-size: 1.5rem;
    line-height: 1;
    padding: 0.3rem 0.7rem;
    color: var(--color-text-muted);
}
.nav-arrow-label {
    font-size: 0.75rem;
    font-weight: 600;
    vertical-align: middle;
}
.variant-nav-arrow:hover:not(:disabled) {
    color: var(--color-primary);
    background: rgba(37, 99, 235, 0.07);
}
.proposal-heading {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--color-text);
}
.diff-block {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.6;
    border: 1px solid var(--color-border);
    border-radius: 16px;
    overflow: hidden;
    background: var(--color-surface);
    box-shadow: var(--shadow);
}
.diff-del {
    background: #fee2e2;
    color: #991b1b;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #fecaca;
    white-space: pre-wrap;
    word-break: break-word;
}
.diff-del::before { content: '- '; font-weight: 900; }
.diff-ins {
    background: #dcfce7;
    color: #15803d;
    padding: 0.5rem 0.75rem;
    white-space: pre-wrap;
    word-break: break-word;
}
.diff-ins::before { content: '+ '; font-weight: 900; }
.diff-context {
    background: var(--color-bg-secondary);
    padding: 0.5rem 0.75rem;
    color: var(--color-text-muted);
    border-top: 1px solid var(--color-border);
    font-size: 0.75rem;
}

/* Line context preview */
.line-preview-section {
    margin-top: 1.25rem;
    border-top: 1px solid var(--color-border);
    padding-top: 1rem;
}
.line-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}
.line-preview-block {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow-x: auto;
    max-height: 18rem;
    overflow-y: auto;
    background: var(--color-surface);
}
.preview-line {
    display: flex;
    border-bottom: 1px solid var(--color-border);
    min-height: 1.6rem;
}
.preview-line:last-child { border-bottom: none; }
.preview-lnum {
    min-width: 3rem;
    padding: 0.2rem 0.5rem;
    text-align: right;
    color: var(--color-text-muted);
    background: var(--color-bg-secondary);
    border-right: 1px solid var(--color-border);
    user-select: none;
    flex-shrink: 0;
}
.preview-ltext {
    padding: 0.2rem 0.6rem;
    white-space: pre-wrap;
    word-break: break-all;
    flex: 1;
}
mark.preview-del {
    background: #fee2e2;
    color: #991b1b;
    border-radius: 2px;
}
mark.preview-ins {
    background: #dcfce7;
    color: #15803d;
    border-radius: 2px;
}

/* Vote section */
.vote-section { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.vote-count-display { font-size: 0.8125rem; color: var(--color-text-muted); font-weight: 600; }

/* Comments */
.comment-sort-bar { display: flex; gap: 0.375rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.comment-thread { display: flex; flex-direction: column; gap: 0.75rem; }
.comment {
    background: var(--color-surface);
    border-radius: 16px;
    padding: 0.75rem 1rem;
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
}
.comment-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.5rem; }
.comment-author { font-weight: 900; font-size: 0.875rem; }
.comment-time { color: var(--color-text-muted); font-size: 0.75rem; font-weight: 600; }
.comment-text { font-size: 0.9rem; line-height: 1.6; white-space: pre-wrap; }
.comment-replies {
    margin-left: 1.5rem;
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    border-left: 2px solid var(--color-border);
    padding-left: 0.75rem;
}
.reply { background: var(--color-surface); border-radius: 14px; padding: 0.6rem 0.9rem; border: 1px solid var(--color-border); box-shadow: var(--shadow-sm); }
.comment-actions { margin-top: 0.5rem; display: flex; gap: 0.5rem; }

/* Comment form */
.comment-form textarea { min-height: 80px; }

/* ===== Activity feed ===== */
.activity-list { display: flex; flex-direction: column; gap: 0.5rem; }
.activity-item {
    display: flex;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--color-surface);
    border-radius: 16px;
    border: 1px solid var(--color-border);
    font-size: 0.875rem;
    box-shadow: var(--shadow-sm);
}
.activity-icon { font-size: 1.1rem; flex-shrink: 0; }
.activity-body { flex: 1; }
.activity-time { color: var(--color-text-muted); font-size: 0.75rem; font-weight: 600; }

/* ===== Modal ===== */
#modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.55);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    backdrop-filter: blur(6px);
}
#modal-box {
    background: var(--color-surface);
    border-radius: 18px;
    padding: 2rem;
    max-width: 560px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255,255,255,0.08);
}
.modal-close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.25rem;
    line-height: 1;
    border: none;
    background: rgba(15, 23, 42, 0.04);
    cursor: pointer;
    color: var(--color-text-muted);
    border-radius: 12px;
    width: 36px;
    height: 36px;
}
.modal-close-btn:hover { background: rgba(15, 23, 42, 0.08); color: var(--color-text); }
.modal-title { font-size: 1.125rem; font-weight: 900; margin-bottom: 1.25rem; letter-spacing: -0.01em; }

/* ===== Profile ===== */
.profile-container { max-width: 480px; margin: 0 auto; padding: 2rem 1.5rem; }

/* ===== Footer ===== */
.app-footer {
    border-top: 1px solid var(--color-border);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    background: rgba(255,255,255,0.65);
    backdrop-filter: blur(6px);
}
.footer-credit { color: var(--color-primary); font-style: italic; font-weight: 600; }

/* ===== Alerts / notices ===== */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 16px;
    font-size: 0.875rem;
    margin-bottom: 1rem;
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    background: var(--color-surface);
}
.alert-error   { background: #fff1f2; color: #991b1b; border-color: rgba(220,38,38,0.18); }
.alert-success { background: #ecfdf5; color: #166534; border-color: rgba(22,163,74,0.18); }
.alert-info    { background: #eff6ff; color: #1e40af; border-color: rgba(37,99,235,0.18); }

/* ===== Empty states ===== */
.empty-state { text-align: center; padding: 3rem 1.5rem; color: var(--color-text-muted); }
.empty-state h3 { font-size: 1rem; font-weight: 900; margin-bottom: 0.5rem; color: var(--color-text); }

/* ===== File drop zone ===== */
.dropzone {
    border: 2px dashed var(--color-border-strong);
    border-radius: 16px;
    padding: 0.75rem 1rem;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    transition: border-color 0.15s, background 0.15s;
    background: rgba(255,255,255,0.6);
}
.dropzone.drag-over {
    border-color: rgba(37, 99, 235, 0.55);
    background: rgba(37, 99, 235, 0.08);
    color: var(--color-primary);
}
.dropzone .link-style { color: var(--color-primary); cursor: pointer; text-decoration: underline; }
.format-notice {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.375rem;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}
.format-notice label { font-weight: normal; cursor: pointer; display: flex; align-items: center; gap: 0.3rem; }

/* ===== Propose modal: selected text preview ===== */
.selected-text-collapsible { margin-bottom: 1rem; }
.selected-text-collapsible summary {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--color-text);
    cursor: pointer;
    padding-bottom: 0.375rem;
}
.selected-text-preview {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    padding: 0.5rem 0.75rem;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 8rem;
    overflow-y: auto;
    color: var(--color-text);
    margin: 0;
}

/* ===== Variant card extras ===== */
.variant-num { font-size: 0.75rem; font-weight: 800; color: var(--color-text-muted); }
.author-tip { cursor: default; border-bottom: 1px dotted rgba(100,116,139,0.8); }
.variant-card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 0.25rem; }
.card-footer-right { display: flex; align-items: center; gap: 0.5rem; }

.goto-link {
    font-size: 0.75rem;
    color: var(--color-primary);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    font-weight: 700;
}
.goto-link:hover { text-decoration: underline; }

.overlap-indicator {
    font-size: 0.7rem;
    color: #b45309;
    cursor: pointer;
    white-space: nowrap;
    font-weight: 800;
}
.overlap-indicator:hover { text-decoration: underline; }

.variant-card.overlap-highlight {
    border-color: rgba(217, 119, 6, 0.55);
    background: #fffbeb;
    box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.18);
}

.line-text.hover-highlight {
    background: rgba(37, 99, 235, 0.16);
    outline: 1px solid rgba(37, 99, 235, 0.55);
    border-radius: 6px;
    cursor: default;
}

/* ===== User search dropdown (access modal) ===== */
.user-search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 200;
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    max-height: 220px;
    overflow-y: auto;
}
.user-search-result {
    display: flex;
    flex-direction: column;
    padding: 0.6rem 0.85rem;
    cursor: pointer;
    border-bottom: 1px solid rgba(15, 23, 42, 0.04);
}
.user-search-result:last-child { border-bottom: none; }
.user-search-result:hover { background: rgba(15, 23, 42, 0.03); }
.user-search-name { font-size: 0.875rem; font-weight: 800; }
.user-search-meta { font-size: 0.75rem; color: var(--color-text-muted); font-weight: 600; }
.invite-role-select { width: auto; }

/* ===== Selection info (propose modal) ===== */
.selection-info {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    padding: 0.45rem 0.75rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
}

/* ===== Voting countdown banner ===== */
.voting-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: var(--radius);
    padding: 0.5rem 0.875rem;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #92400e;
}

.voting-schedule-notice {
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #92400e;
}

/* ===== Toast notifications ===== */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 360px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #fff;
    border: 1px solid var(--color-border);
    border-left: 4px solid #f59e0b;
    border-radius: var(--radius);
    padding: 0.625rem 0.875rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    font-size: 0.875rem;
    pointer-events: all;
    animation: toast-in 0.2s ease-out;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(0.5rem); }
    to   { opacity: 1; transform: translateY(0); }
}

.toast-link {
    color: var(--color-primary);
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.toast-dismiss {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    font-size: 1rem;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
}

/* ===== Prominent activity item (voting_scheduled) ===== */
.activity-item-voting {
    background: #fef3c7;
    border-left: 3px solid #f59e0b;
    border-radius: var(--radius);
    padding-left: calc(1rem - 3px);
}

/* ===== Review layout ===== */
.review-layout {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    gap: 1.25rem;
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
    align-items: start;
}
.review-text-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow);
    position: sticky;
    top: 84px;
    max-height: calc(100vh - 100px);
    display: flex;
    flex-direction: column;
}
.review-text-panel .doc-text-body { flex: 1; overflow-y: auto; }
.review-proposals-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow);
}
.review-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--color-border);
    background: linear-gradient(to bottom, rgba(246,248,251,0.9), rgba(255,255,255,0));
    font-size: 0.875rem;
}
#review-list { padding: 0.5rem; display: flex; flex-direction: column; gap: 0.5rem; }
.review-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 0.75rem 0.875rem;
    box-shadow: var(--shadow-sm);
}
.review-card-header { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.25rem; flex-wrap: wrap; }
.review-card-title { font-weight: 600; font-size: 0.875rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.review-card-meta { font-size: 0.8rem; margin-bottom: 0.5rem; }
.review-overlap-badge { font-size: 0.7rem; font-weight: 800; color: #b45309; background: #fef3c7; padding: 0.1rem 0.35rem; border-radius: 5px; flex-shrink: 0; }
.review-actions { display: flex; gap: 0.375rem; flex-wrap: wrap; }
.review-btn {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    border: 1.5px solid transparent;
    cursor: pointer;
    background: var(--color-bg-secondary);
    color: var(--color-text-muted);
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.review-btn:hover { background: var(--color-bg-tertiary); color: var(--color-text); }
.review-btn-voting { border-color: rgba(22,163,74,0.25); }
.review-btn-voting.review-btn-active { background: #dcfce7; color: #15803d; border-color: #16a34a; }
.review-btn-conflict { border-color: rgba(217,119,6,0.25); }
.review-btn-conflict.review-btn-active { background: #fef3c7; color: #b45309; border-color: #d97706; }
.review-btn-danger { border-color: rgba(220,38,38,0.2); }
.review-btn-danger.review-btn-active { background: #fee2e2; color: #b91c1c; border-color: #dc2626; }

/* ===== Conflict Resolution ===== */
.conflict-groups { display: flex; flex-direction: column; gap: 1.25rem; margin-bottom: 1.5rem; }
.conflict-group {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
}
.conflict-group-resolved { border-color: rgba(22,163,74,0.35); background: #f0fdf4; }
.conflict-group-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.conflict-badge { font-size: 0.75rem; font-weight: 700; padding: 0.15rem 0.5rem; border-radius: 20px; }
.conflict-badge-ok { background: #dcfce7; color: #15803d; }
.conflict-badge-warn { background: #fef3c7; color: #b45309; }

.conflict-list { display: flex; flex-direction: column; }
.conflict-dropzone {
    height: 16px;
    border-radius: 4px;
    transition: height 0.1s, background 0.1s;
    position: relative;
}
.conflict-dropzone.active {
    height: 28px;
    background: rgba(37, 99, 235, 0.1);
    border: 2px dashed rgba(37, 99, 235, 0.45);
}
.conflict-dropzone.active::after { content: 'Drop here to reorder'; position: absolute; left: 50%; transform: translateX(-50%); font-size: 0.7rem; color: var(--color-primary); top: 4px; }

.conflict-card {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.625rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    cursor: grab;
    user-select: none;
}
.conflict-card:active { cursor: grabbing; }
.conflict-card.dragging { opacity: 0.4; }
.conflict-card.drop-target { border-color: #f59e0b; background: #fffbeb; box-shadow: 0 0 0 3px rgba(245,158,11,0.25); }
.conflict-card-child { margin-left: 2rem; background: var(--color-bg-secondary); border-style: dashed; }
.conflict-card-unordered { border-color: #fca5a5; background: #fff7f7; }

.conflict-drag-handle { color: var(--color-text-muted); font-size: 1rem; flex-shrink: 0; cursor: grab; }
.conflict-order-badge { font-size: 0.75rem; font-weight: 800; background: var(--color-primary); color: #fff; border-radius: 20px; padding: 0.1rem 0.45rem; flex-shrink: 0; }
.conflict-child-badge { font-size: 0.7rem; font-weight: 700; color: #b45309; background: #fef3c7; border-radius: 4px; padding: 0.1rem 0.35rem; flex-shrink: 0; white-space: nowrap; }
.conflict-card-body { display: flex; align-items: center; gap: 0.3rem; flex: 1; min-width: 0; }
.conflict-card-title { font-weight: 600; font-size: 0.875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conflict-card-meta { font-size: 0.78rem; white-space: nowrap; flex-shrink: 0; }
.conflict-remove-child { margin-left: auto; flex-shrink: 0; background: none; border: none; cursor: pointer; color: var(--color-text-muted); font-size: 1rem; padding: 0 0.25rem; line-height: 1; }
.conflict-remove-child:hover { color: var(--color-danger); }

.conflict-unordered-label { font-size: 0.8125rem; color: var(--color-danger); font-weight: 600; padding: 0.5rem 0 0.25rem; }

.conflict-ready-btn { display: block; width: 100%; margin-top: 1rem; font-size: 1rem; padding: 0.75rem; }
.btn-success { background: #16a34a; color: #fff; border-color: #16a34a; }
.btn-success:hover { background: #15803d; border-color: #15803d; }
.btn-warning { background: #d97706; color: #fff; border-color: #d97706; }
.btn-warning:hover { background: #b45309; border-color: #b45309; }
.btn-lg { font-size: 1rem; padding: 0.75rem 1.5rem; }
.review-final-badge { font-size: 0.75rem; font-weight: 700; background: #dcfce7; color: #15803d; border-radius: 20px; padding: 0.2rem 0.6rem; align-self: center; }

/* ===== Final Voting Walkthrough ===== */
.fv-list { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 2rem; }
.fv-group { border: 2px solid #d97706; border-radius: 6px; padding: 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; }
.fv-group-header { font-weight: 700; font-size: 0.85rem; color: #92400e; padding-bottom: 0.4rem; border-bottom: 1px solid #fde68a; margin-bottom: 0.25rem; }
.fv-card { border: 1px solid var(--color-border); border-radius: 6px; padding: 0.9rem 1rem; background: var(--color-surface); }
.fv-card-child { margin-left: 1.75rem; border-color: #fbbf24; background: #fffbeb; }
.fv-card-header { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.6rem; font-size: 0.875rem; }
.fv-card-num { font-variant-numeric: tabular-nums; }
.fv-card-title { font-weight: 600; }
.fv-card-meta { font-size: 0.8rem; }
.fv-order-badge { display: inline-flex; align-items: center; justify-content: center; background: #1d4ed8; color: #fff; border-radius: 50%; width: 1.5em; height: 1.5em; font-size: 0.75rem; font-weight: 700; flex-shrink: 0; }
.fv-child-note { font-size: 0.75rem; color: #92400e; font-style: italic; }
.fv-status-badge { font-size: 0.7rem; font-weight: 600; padding: 0.1rem 0.45rem; border-radius: 10px; text-transform: uppercase; letter-spacing: 0.03em; }
.fv-status-pending    { background: #dbeafe; color: #1e40af; }
.fv-status-conflict   { background: #fef3c7; color: #92400e; }
.fv-status-rejected   { background: #fee2e2; color: #991b1b; }
.fv-card-texts { display: grid; grid-template-columns: 5rem 1fr; gap: 0.25rem 0.5rem; margin-bottom: 0.75rem; align-items: start; font-size: 0.85rem; }
.fv-label { font-weight: 700; font-size: 0.75rem; color: var(--color-text-muted); padding-top: 0.2rem; }
.fv-text { background: var(--color-bg); border: 1px solid var(--color-border); border-radius: 4px; padding: 0.3rem 0.5rem; white-space: pre-wrap; word-break: break-word; max-height: 8rem; overflow-y: auto; }
.fv-inputs { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; font-size: 0.875rem; border-top: 1px dashed var(--color-border); padding-top: 0.6rem; }
.fv-inputs label { display: flex; align-items: center; gap: 0.35rem; font-weight: 600; }
.fv-num-input { width: 5rem; padding: 0.3rem 0.5rem; border: 1px solid var(--color-border); border-radius: 4px; font-size: 0.875rem; text-align: right; }
.fv-saved-indicator { font-size: 0.85rem; color: #16a34a; font-weight: 600; }
.fv-docvote { border: 2px solid var(--color-border); border-radius: 8px; padding: 1.25rem 1.25rem 1rem; margin-top: 1.5rem; }
.fv-docvote-title { margin: 0 0 0.25rem; font-size: 1rem; }
.fv-progress { font-size: 0.8125rem; color: var(--color-text-muted); padding: 0.25rem 0 0.1rem; }
.fv-progress-done { color: #16a34a; font-weight: 600; }
.review-final-tally { font-size: 0.8125rem; font-weight: 600; color: var(--color-text); margin: 0.1rem 0 0.3rem; letter-spacing: 0.03em; }

/* Child ordering in conflict resolution */
.conflict-child-order-badge { display: inline-flex; align-items: center; justify-content: center; width: 1.2rem; height: 1.2rem; border-radius: 50%; background: var(--color-warning); color: #fff; font-size: 0.65rem; font-weight: 700; margin-right: 0.15rem; flex-shrink: 0; }
.conflict-dropzone-child { height: 5px; margin: 1px 0 1px 2rem; border-radius: 3px; }
.conflict-dropzone-child.active { height: 14px; background: rgba(37,99,235,0.12); border: 1px dashed var(--color-primary); }

/* Final voting: majority percentage */
.fv-majority { font-size: 0.8125rem; font-weight: 700; margin-top: 0.3rem; min-height: 1.1em; }
.fv-majority-pass { color: var(--color-success); }
.fv-majority-split { color: var(--color-warning); }
.fv-majority-fail { color: var(--color-danger); }

/* Final voting: child skipped when parent passes */
.fv-card-child-skipped { opacity: 0.5; background: var(--color-bg-secondary) !important; }
.fv-card-child-skipped .fv-card-texts,
.fv-card-child-skipped .fv-inputs,
.fv-card-child-skipped .fv-majority { display: none; }
.fv-skip-note { font-size: 0.75rem; color: var(--color-text-muted); font-style: italic; font-weight: 600; }

/* Final voting: result badge on parent cards */
.fv-result-badge { font-size: 0.7rem; font-weight: 700; padding: 0.1rem 0.45rem; border-radius: 10px; }
.fv-result-passed { background: #dcfce7; color: #15803d; }
.fv-result-failed { background: #fee2e2; color: #991b1b; }

/* Final voting: audit trail */
.fv-audit { margin-top: 0.5rem; }
.fv-audit-btn { background: none; border: none; color: var(--color-primary); cursor: pointer; font-size: 0.75rem; padding: 0; text-decoration: underline; }
.fv-audit-list { margin-top: 0.4rem; border: 1px solid var(--color-border); border-radius: 6px; overflow: hidden; }
.fv-audit-entry { padding: 0.35rem 0.65rem; font-size: 0.75rem; border-bottom: 1px solid var(--color-border); }
.fv-audit-entry:last-child { border-bottom: none; }
.fv-audit-time { color: var(--color-text-muted); margin-right: 0.4rem; }

/* Nav activity badge */
.nav-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 1.1rem; height: 1.1rem; border-radius: 10px; background: var(--color-danger); color: #fff; font-size: 0.65rem; font-weight: 700; padding: 0 0.2rem; margin-left: 0.2rem; vertical-align: middle; }
.nav-badge.hidden { display: none; }

/* Resolved text view */
.resolved-text-view { font-family: var(--font-mono); font-size: 0.875rem; line-height: 1.6; border: 1px solid var(--color-border); border-radius: 8px; padding: 1rem; background: var(--color-bg-secondary); max-height: 70vh; overflow-y: auto; }
.rt-line { display: flex; align-items: baseline; }
.rt-linenum { min-width: 3rem; color: var(--color-text-muted); font-size: 0.75rem; text-align: right; padding-right: 0.75rem; flex-shrink: 0; }
.rt-text { white-space: pre-wrap; word-break: break-word; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .doc-layout {
        grid-template-columns: 1fr;
        padding: 1rem;
    }
    .doc-sidebar { position: static; top: auto; }
    .header-inner { padding: 0 1rem; gap: 1rem; }
    #app-nav .nav-link { padding: 0.4rem 0.55rem; font-size: 0.8125rem; }
    .page-container { padding: 1.25rem 1rem; }
    .login-card { padding: 1.75rem 1.25rem; }
    .variant-layout { padding: 1rem; }
    .review-layout { grid-template-columns: 1fr; }
    .review-text-panel { position: static; max-height: 50vh; }
}

@media (max-width: 480px) {
    .header-inner { flex-wrap: wrap; gap: 0.5rem; height: auto; min-height: 60px; padding: 0.5rem 1rem; }
    #app-nav { order: 3; flex: none; width: 100%; justify-content: flex-start; }
    #user-name-display { display: none; }
    .doc-text-body { font-size: 0.75rem; }
}

.access-row-blocked > span:first-child { text-decoration: line-through; opacity: 0.6; }
.variant-card:focus-visible { outline: 2px solid var(--color-primary, #2563eb); outline-offset: 2px; }
.alert-neutral { background: var(--color-bg-secondary); color: var(--color-text-muted, #475569); border: 1px solid var(--color-border); }
.conflict-kbd { display: inline-flex; gap: 0.25rem; margin-left: auto; }
.conflict-kbd button { padding: 0 0.4rem; font-size: 0.75rem; line-height: 1.5; }

/* ===== Reduce motion ===== */
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; scroll-behavior: auto !important; }
}
