/* ============================================================================
   LEFT PANEL (sidebar) COLOURS — change these to recolour the left panel.
   --app-sidebar-bg is the panel background (same blue gradient as the login page).
   ============================================================================ */
:root {
    --sidebar-width: 280px;
    --app-primary: #1b4d89;
    --app-primary-dark: #143a66;
    --app-surface: #ffffff;
    --app-surface-muted: #f4f6fb;
    --app-border: #e2e8f0;
    --app-sidebar-bg: linear-gradient(180deg, #0f172a 0%, #1b4d89 55%, #2563eb 100%);
    --app-sidebar-surface: rgba(255, 255, 255, 0.07);
    --app-sidebar-text: #eaf1ff;
    --app-sidebar-muted: #b9c6e6;
    --app-sidebar-hover: rgba(255, 255, 255, 0.12);
    --app-sidebar-active: rgba(255, 255, 255, 0.16);
}

html,
body {
    height: 100%;
}

body {
    background-color: var(--app-surface-muted);
    color: #1f2937;
}

.app-shell {
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    height: 100vh;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    background: var(--app-sidebar-bg);
    position: sticky;
    top: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    /* Smoothly slide the panel in/out instead of vanishing abruptly. The panel clips its own
       overflow, so shrinking the width reads as the menu gliding inward. */
    transition: width .28s ease, min-width .28s ease, opacity .2s ease;
}

/* Hide/unhide toggle: collapse the panel width to zero (animated) so it glides away and frees
   the space, rather than disappearing in one frame. */
.app-shell.sidebar-collapsed #desktopSidebar {
    width: 0 !important;
    min-width: 0 !important;
    opacity: 0;
    border-right: 0;
    pointer-events: none;
}

/* Negligible, very light scrollbar for the left-nav (dark panel → faint white). */
#desktopSidebar nav {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}

#desktopSidebar nav::-webkit-scrollbar {
    width: 3px;
}

#desktopSidebar nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.16);
    border-radius: 3px;
}

#desktopSidebar nav::-webkit-scrollbar-track {
    background: transparent;
}

/* ◀ hide arrow inside the panel, beside the TeamPulse brand */
.sidebar-hide-btn {
    background: transparent;
    border: 0;
    color: var(--app-sidebar-muted);
    padding: .15rem .4rem;
    border-radius: .4rem;
    line-height: 1;
    cursor: pointer;
}

.sidebar-hide-btn:hover {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
}

/* ▶ show arrow in the top bar — only appears when the panel is hidden */
.sidebar-show-btn {
    display: none !important;
}

@media (min-width: 992px) {
    .app-shell.sidebar-collapsed .sidebar-show-btn {
        display: inline-flex !important;
    }
}

/* Compact "Powered by" footer */
.sidebar-powered {
    font-size: 0.7rem;
    line-height: 1.1;
}

/* Weekly / Long-Term switch: the selected side is solid blue, so hovering the OTHER side must
   go light blue (not solid) — otherwise hover looks identical to the selected state. */
.horizon-toggle .btn-outline-primary:hover,
.horizon-toggle .btn-outline-primary:focus {
    background-color: #cfe2ff;
    border-color: #9ec5fe;
    color: #0a58ca;
}

/* Mobile slide-out menu: match the desktop left panel's blue, instead of the default white
   offcanvas (which left the light nav text nearly invisible). */
#mobileSidebar {
    background: var(--app-sidebar-bg);
    color: var(--app-sidebar-text);
}

#mobileSidebar .offcanvas-header {
    background-color: var(--app-sidebar-surface);
    color: var(--app-sidebar-text);
    border-bottom-color: rgba(255, 255, 255, 0.12) !important;
}

#mobileSidebar .offcanvas-title {
    color: var(--app-sidebar-text);
}

#mobileSidebar .offcanvas-body {
    background: transparent;
}

#mobileSidebar .nav-link {
    color: var(--app-sidebar-text);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    transition: background-color 0.2s ease, color 0.2s ease;
}

#mobileSidebar .nav-link:hover,
#mobileSidebar .nav-link:focus {
    background-color: var(--app-sidebar-hover);
    color: #ffffff;
}

/* Section labels ("TEAMS") and placeholder text → muted light so they read on the blue. */
#mobileSidebar .text-uppercase,
#mobileSidebar .text-body-secondary {
    color: var(--app-sidebar-muted) !important;
}

#mobileSidebar .badge.text-bg-secondary {
    background-color: rgba(255, 255, 255, 0.18) !important;
    color: #eaf1ff !important;
}

/* The default close (×) icon is dark; make it white so it shows on the blue header. */
#mobileSidebar .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

.sidebar .badge.text-bg-secondary {
    background-color: rgba(255, 255, 255, 0.18) !important;
    color: #eaf1ff !important;
}

.sidebar .nav-scroll {
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1 1 auto;
}

.sidebar .sidebar-brand {
    background-color: var(--app-sidebar-surface);
    color: var(--app-sidebar-text);
}

.sidebar .sidebar-brand small {
    color: var(--app-sidebar-muted);
}

.sidebar .nav-link {
    color: var(--app-sidebar-text);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.sidebar .nav-link:hover,
.sidebar .nav-link:focus {
    background-color: var(--app-sidebar-hover);
    color: #ffffff;
}

.sidebar .nav>.nav-item>.nav-link {
    font-weight: 600;
}

.sidebar .nav .list-unstyled .nav-link {
    font-size: 0.9rem;
    color: var(--app-sidebar-muted);
    padding-left: 0.75rem;
}

.sidebar .nav .list-unstyled .nav-link:hover,
.sidebar .nav .list-unstyled .nav-link:focus {
    color: #ffffff;
    background-color: transparent;
}

.sidebar .text-uppercase {
    color: var(--app-sidebar-muted);
    letter-spacing: 0.08em;
}

.content-shell {
    width: 100%;
}

.top-header {
    position: sticky;
    top: 0;
    z-index: 1020;
    background-color: var(--app-surface);
    border-bottom: 1px solid var(--app-border);
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

.top-header .btn-outline-primary {
    --bs-btn-color: var(--app-primary);
    --bs-btn-border-color: var(--app-primary);
    --bs-btn-hover-bg: var(--app-primary);
    --bs-btn-hover-border-color: var(--app-primary);
    --bs-btn-hover-color: #ffffff;
}

.top-header .btn-outline-secondary {
    --bs-btn-color: #475569;
    --bs-btn-border-color: #cbd5f5;
    --bs-btn-hover-bg: #e2e8f0;
    --bs-btn-hover-border-color: #cbd5f5;
}

.dropdown-menu {
    border-radius: 0.75rem;
    border: 1px solid var(--app-border);
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
    padding: 0.5rem;
}

.dropdown-item {
    border-radius: 0.5rem;
    font-weight: 350;
    color: #1f2937;
}

.dropdown-item:hover,
.dropdown-item:focus {
    background-color: var(--app-surface-muted);
    color: var(--app-primary-dark);
}

.dropdown-item-text {
    color: #1f2937;
}

.dropdown-item-text.bg-light {
    background-color: #eef2ff !important;
}

.list-group-item-action {
    color: #1f2937;
}

.list-group-item-action:hover,
.list-group-item-action:focus {
    background-color: var(--app-surface-muted);
    color: var(--app-primary-dark);
}

.main-content {
    max-width: 100%;
}

.task-column {
    min-height: 360px;
}

.task-item {
    border-left: 3px solid transparent;
    background-color: #eef3ff;
}

.task-item[data-has-open-issue="true"] {
    border-left-color: var(--bs-warning);
}

.issue-flag {
    display: inline-flex;
}

.task-item[data-has-open-issue="false"] .issue-flag {
    display: none;
}

.login-shell {
    background: linear-gradient(180deg, #f8fafc 0%, var(--app-surface-muted) 100%);
}

#mobileProfilePanel .offcanvas-header {
    background-color: var(--app-surface);
    border-bottom: 1px solid var(--app-border);
}

#mobileProfilePanel .offcanvas-title {
    font-weight: 600;
    color: #0f172a;
}

#mobileProfilePanel .list-group {
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
    border: 1px solid var(--app-border);
}

#mobileProfilePanel .list-group-item {
    border: 0;
    padding: 0.9rem 1rem;
    font-weight: 500;
}

#mobileProfilePanel .list-group-item+.list-group-item {
    border-top: 1px solid var(--app-border);
}

#mobileProfilePanel .list-group-item-action:hover,
#mobileProfilePanel .list-group-item-action:focus {
    background-color: var(--app-surface-muted);
    color: var(--app-primary-dark);
}

#mobileProfilePanel .list-group-item-action:active {
    background-color: #e0e7ff;
}

.profile-dropdown {
    width: 280px;
    padding: 0.75rem;
    border-radius: 1rem;
    border: 1px solid var(--app-border);
    box-shadow: 0 16px 30px rgba(15, 23, 42, 0.18);
    max-height: calc(100vh - 90px);
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* Negligible, subtle scrollbar for the profile menu */
.profile-dropdown {
    scrollbar-width: thin;
    scrollbar-color: var(--app-border) transparent;
}

.profile-dropdown::-webkit-scrollbar {
    width: 4px;
}

.profile-dropdown::-webkit-scrollbar-thumb {
    background: var(--app-border);
    border-radius: 4px;
}

.profile-dropdown::-webkit-scrollbar-track {
    background: transparent;
}

.profile-summary {
    background-color: #eef3ff;
    border-radius: 0.85rem;
    padding: 0.9rem;
    margin-bottom: 0.75rem;
}

.profile-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: #ffffff;
    border: 2px solid #2563eb;
    color: #2563eb;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.profile-name {
    font-size: 1.05rem;
}

.profile-logout {
    border-radius: 0.6rem;
    border-color: #c7d2fe;
    color: #1e3a8a;
    background-color: #eef2ff;
}

.profile-logout:hover,
.profile-logout:focus {
    background-color: #dbe4ff;
    border-color: #c7d2fe;
    color: #1e3a8a;
}

.profile-dropdown .dropdown-item {
    padding: 0.65rem 0.75rem;
    font-size: 1.02rem;
}

.profile-dropdown .dropdown-divider {
    margin: 0.4rem 0.75rem;
}

#mobileSidebar .offcanvas-header {
    background-color: var(--app-sidebar-surface);
    color: var(--app-sidebar-text);
    border-bottom: 1px solid rgba(226, 232, 240, 0.15);
}

#mobileSidebar .offcanvas-title {
    color: var(--app-sidebar-text);
    font-weight: 600;
}

#mobileSidebar .btn-close {
    filter: invert(1);
}

#mobileSidebar .offcanvas-body {
    background-color: var(--app-sidebar-bg);
}

#mobileSidebar .nav-link {
    color: var(--app-sidebar-text);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    transition: background-color 0.2s ease, color 0.2s ease;
}

#mobileSidebar .nav-link:hover,
#mobileSidebar .nav-link:focus {
    background-color: var(--app-sidebar-hover);
    color: #ffffff;
}

#mobileSidebar .nav>.nav-item>.nav-link {
    font-weight: 600;
}

#mobileSidebar .list-unstyled .nav-link {
    font-size: 0.9rem;
    color: var(--app-sidebar-muted);
    padding-left: 0.75rem;
}

#mobileSidebar .list-unstyled .nav-link:hover,
#mobileSidebar .list-unstyled .nav-link:focus {
    color: #ffffff;
    background-color: transparent;
}

#mobileSidebar .text-uppercase,
#mobileSidebar .text-body-secondary {
    color: var(--app-sidebar-muted) !important;
    letter-spacing: 0.08em;
}

#mobileSidebar .nav-item.px-3.small {
    color: var(--app-sidebar-muted) !important;
}

.offcanvas-body {
    background-color: #eef3ff;
}

.task-item .task-check:not(:checked) {
    border: 2px solid var(--app-primary);
    box-shadow: 0 0 0 2px rgba(27, 77, 137, 0.15);
}

@media (min-width: 992px) {
    .app-shell {
        display: flex;
    }
}

.text-bg-purple {
    color: #FFFFFF !important;
    background-color: #563d7c !important;
}

/* ============ Phase 2: Team Management UI ============ */
:root {
    --tm-radius: 1rem;
    --tm-shadow: 0 4px 16px rgba(15, 23, 42, .06);
    --tm-shadow-hov: 0 10px 28px rgba(15, 23, 42, .12);
}

.rounded-4 {
    border-radius: var(--tm-radius) !important;
}

/* Stat tiles */
.stat-tile {
    display: flex;
    align-items: center;
    gap: .9rem;
    padding: 1rem 1.15rem;
    border-radius: var(--tm-radius);
    background: #fff;
    box-shadow: var(--tm-shadow);
    border: 1px solid var(--app-border);
    transition: transform .15s ease, box-shadow .15s ease;
}

.stat-tile:hover {
    transform: translateY(-2px);
    box-shadow: var(--tm-shadow-hov);
}

.stat-tile .stat-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    color: #fff;
    flex: 0 0 auto;
}

.stat-tile .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
}

.stat-tile .stat-label {
    font-size: .78rem;
    color: #64748b;
    margin-top: .2rem;
}

.tile-indigo .stat-icon {
    background: linear-gradient(135deg, #6366f1, #4338ca);
}

.tile-blue .stat-icon {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
}

.tile-green .stat-icon {
    background: linear-gradient(135deg, #10b981, #047857);
}

.tile-amber .stat-icon {
    background: linear-gradient(135deg, #f59e0b, #b45309);
}

.tile-rose .stat-icon {
    background: linear-gradient(135deg, #f43f5e, #be123c);
}

.tile-slate .stat-icon {
    background: linear-gradient(135deg, #64748b, #334155);
}

/* Badges: status / priority / attendance */
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    font-size: .72rem;
    font-weight: 600;
    padding: .28rem .6rem;
    border-radius: 999px;
}

.badge-status.backlog {
    background: #e2e8f0;
    color: #475569
}

.badge-status.todo {
    background: #e0e7ff;
    color: #3730a3
}

.badge-status.inprogress {
    background: #dbeafe;
    color: #1e40af
}

.badge-status.blocked {
    background: #fee2e2;
    color: #b91c1c
}

.badge-status.inreview {
    background: #fef3c7;
    color: #92400e
}

.badge-status.done {
    background: #dcfce7;
    color: #166534
}

.badge-status.cancelled {
    background: #f1f5f9;
    color: #94a3b8
}

.badge-priority {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    font-size: .72rem;
    font-weight: 600;
    padding: .28rem .55rem;
    border-radius: 999px;
}

.badge-priority.low {
    background: #f1f5f9;
    color: #64748b
}

.badge-priority.medium {
    background: #e0f2fe;
    color: #0369a1
}

.badge-priority.high {
    background: #ffedd5;
    color: #c2410c
}

.badge-priority.urgent {
    background: #fee2e2;
    color: #b91c1c
}

.att-present {
    background: #dcfce7;
    color: #166534
}

.att-wfh {
    background: #dbeafe;
    color: #1e40af
}

.att-leave {
    background: #fef3c7;
    color: #92400e
}

.att-half {
    background: #e0e7ff;
    color: #3730a3
}

.att-absent {
    background: #fee2e2;
    color: #b91c1c
}

.att-off {
    background: #f8fafc;
    color: #cbd5e1
}

.att-future {
    background: #f8fafc;
    color: #e2e8f0
}

.att-none {
    background: #fff7ed;
    color: #9a3412;
    border: 1px dashed #fdba74
}

/* Avatars */
.avatar-xs {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #3b82f6);
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    margin-right: .35rem;
    /* Never let a long comment squeeze the avatar (which then shifts the row left). */
    flex-shrink: 0;
}

/* The text column beside the avatar must be allowed to shrink so long words wrap instead of
   pushing on the avatar. */
.comment-thread .d-flex > div {
    min-width: 0;
    overflow-wrap: anywhere;
}

.comment-thread a {
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* Kanban — vertical grid: 3 columns per row, wraps below, each column scrolls internally */
.kanban-scroll {
    padding-bottom: .5rem;
}

.kanban-board {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

@media (max-width: 992px) {
    .kanban-board {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .kanban-board {
        grid-template-columns: 1fr;
    }
}

.kanban-col {
    background: #f6f5fc;
    border: 1px solid var(--app-border);
    border-radius: var(--tm-radius);
    display: flex;
    flex-direction: column;
    max-height: 520px;
}

.kanban-col-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .7rem 1rem;
    font-weight: 600;
    border-top: 3px solid transparent;
    border-top-left-radius: var(--tm-radius);
    border-top-right-radius: var(--tm-radius);
}

.kanban-col-head.backlog {
    border-top-color: #94a3b8
}

.kanban-col-head.todo {
    border-top-color: #6366f1
}

.kanban-col-head.inprogress {
    border-top-color: #3b82f6
}

.kanban-col-head.blocked {
    border-top-color: #ef4444
}

.kanban-col-head.inreview {
    border-top-color: #f59e0b
}

.kanban-col-head.done {
    border-top-color: #10b981
}

.kanban-count {
    background: #e2e8f0;
    color: #475569;
    border-radius: 999px;
    padding: .05rem .55rem;
    font-size: .75rem;
}

.kanban-col-body {
    padding: .6rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: .6rem;
}

.kanban-empty {
    text-align: center;
    color: #cbd5e1;
    font-size: .8rem;
    padding: 1rem 0;
}

.task-card {
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: .85rem;
    padding: .75rem .85rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .05);
    transition: box-shadow .15s ease, transform .15s ease;
}

.task-card:hover {
    box-shadow: var(--tm-shadow-hov);
    transform: translateY(-1px);
}

.task-card.overdue {
    border-left: 3px solid #ef4444;
}

.task-card .task-title {
    font-weight: 600;
    color: #0f172a;
    text-decoration: none;
    display: block;
    font-size: .92rem;
}

.task-card .task-title:hover {
    color: var(--app-primary);
}

.task-card .task-team {
    font-size: .72rem;
    color: #64748b;
    margin-top: .25rem;
}

.task-card .task-meta {
    margin-top: .5rem;
}

.task-card .task-assignee {
    display: inline-flex;
    align-items: center;
    font-size: .75rem;
    color: #475569;
}

.move-select {
    font-size: .72rem;
    padding: .1rem 1.4rem .1rem .4rem;
    height: auto;
    width: auto;
    border-radius: 999px;
}

/* Week grid */
.week-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: .5rem;
}

.week-cell {
    border-radius: .75rem;
    padding: .6rem .4rem;
    text-align: center;
    border: 1px solid var(--app-border);
    min-height: 92px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .15rem;
}

.week-cell.is-today {
    outline: 2px solid #3b82f6;
    outline-offset: 1px;
}

.week-cell .week-day {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    opacity: .8;
}

.week-cell .week-date {
    font-size: 1.15rem;
    font-weight: 700;
}

.week-cell .week-status {
    font-size: .72rem;
    font-weight: 600;
}

@media (max-width:640px) {
    .week-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Review grid */
.review-grid .att-chip {
    border: none;
    border-radius: .55rem;
    padding: .35rem .1rem;
    width: 100%;
    font-size: .72rem;
    font-weight: 700;
    cursor: pointer;
}

.review-grid .att-chip.disputed {
    outline: 2px solid #f59e0b;
}

.review-grid .att-chip:disabled {
    opacity: .5;
    cursor: default;
}

/* Detail list */
.detail-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: .4rem .8rem;
    margin: 0;
}

.detail-list dt {
    color: #64748b;
    font-size: .8rem;
    font-weight: 500;
}

.detail-list dd {
    margin: 0;
    font-size: .88rem;
    font-weight: 600;
}

/* Rating */
.rating-row {
    display: flex;
    gap: .35rem;
}

.rating-row input {
    display: none;
}

.rating-row label {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--app-border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: 600;
}

.rating-row input:checked+label {
    background: var(--app-primary);
    color: #fff;
    border-color: var(--app-primary);
}

/* Sidebar section header */
.sidebar .nav-section,
#mobileSidebar .nav-section {
    color: var(--app-sidebar-muted);
    font-size: .7rem;
    letter-spacing: .1em;
    text-transform: uppercase;
    padding: .75rem .75rem .25rem;
}

/* Dashboard */
.dash-hero {
    background: linear-gradient(135deg, #1b4d89, #2563eb);
    color: #fff;
    border-radius: var(--tm-radius);
    padding: 1.5rem 1.75rem;
    box-shadow: var(--tm-shadow);
}

.dash-hero h3 {
    font-weight: 700;
}

.mini-bar {
    height: 8px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
}

.mini-bar>span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #6366f1);
}

.quick-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .85rem 1rem;
    border-radius: .85rem;
    background: #fff;
    border: 1px solid var(--app-border);
    text-decoration: none;
    color: #0f172a;
    transition: all .15s ease;
    height: 100%;
}

.quick-link:hover {
    transform: translateY(-2px);
    box-shadow: var(--tm-shadow-hov);
    color: var(--app-primary);
}

.quick-link .qi {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #fff;
    flex: 0 0 auto;
}

/* ============ Pastel theme — three surface layers ============
   The page sits DARKER than the cards, so every card reads as a distinct surface
   without relying on a shadow. Nested surfaces go one step LIGHTER, which is what
   makes a task card read as sitting *on* its parent flow card.
     surface-0  page background   (darkest)
     surface-1  card
     surface-2  nested card / comment thread   (lightest)
   Ink is darkened alongside the surfaces so secondary text stays >= 4.5:1 (WCAG AA). */
:root {
    --surface-0: #dcd9ea;
    --surface-1: #f1eff9;
    --surface-2: #faf9fd;
    --border-1: #c3bcdd;
    --border-2: #d8d2ec;
    --ink-1: #241f38;
    --ink-2: #574f70;
    --accent: #5b4bc4;
    --accent-soft: #e4e0f7;
}

body {
    background: linear-gradient(180deg, #e2dff0 0%, var(--surface-0) 100%);
    color: var(--ink-1);
}

.text-body-secondary {
    color: var(--ink-2) !important;
}

/* Every card carries a real border — separation must not depend on a shadow. */
.card {
    --bs-card-bg: var(--surface-1);
    background-color: var(--surface-1);
    border: 1px solid var(--border-1);
}

.card .card-header {
    background-color: transparent;
    border-bottom-color: var(--border-2);
}

/* Pastel card variants — deepened one step, each with a matching border. */
.card-pastel-green {
    background-color: #cdead9 !important;
    border-color: #9bd3b0 !important;
}

.card-pastel-lavender {
    background-color: #ded4f8 !important;
    border-color: #bcabef !important;
}

.card-pastel-pink {
    background-color: #f8d2e2 !important;
    border-color: #eda8c6 !important;
}

.card-pastel-amber {
    background-color: #f8e5b6 !important;
    border-color: #e9c877 !important;
}

.card-pastel-blue {
    background-color: #cbe1f8 !important;
    border-color: #9cc5ef !important;
}

.card-pastel-purple {
    background-color: #e6d3f4 !important;
    border-color: #cfaee8 !important;
}

/* Stat tiles: deeper pastel tint matching their accent. */
.stat-tile {
    background: var(--surface-1);
    border: 1px solid var(--border-1);
}

.stat-tile.tile-indigo {
    background: #d9d3f7;
    border-color: #b7abec;
}

.stat-tile.tile-blue {
    background: #cbe1f8;
    border-color: #9cc5ef;
}

.stat-tile.tile-green {
    background: #cdead9;
    border-color: #9bd3b0;
}

.stat-tile.tile-amber {
    background: #f8e5b6;
    border-color: #e9c877;
}

.stat-tile.tile-rose {
    background: #f8d1dd;
    border-color: #eda6bb;
}

.stat-tile.tile-slate {
    background: #dbe1eb;
    border-color: #b6c1d3;
}

.quick-link {
    background: var(--surface-1);
    border-color: var(--border-1);
    color: var(--ink-1);
}

.kanban-col {
    background: var(--surface-1);
    border-color: var(--border-1);
}

.kanban-col-body .card,
.task-card {
    background: var(--surface-2);
    border-color: var(--border-2);
}

/* Team pill / tag */
.team-pill {
    display: inline-flex;
    align-items: center;
    font-size: .72rem;
    font-weight: 600;
    padding: .2rem .6rem;
    border-radius: 999px;
    background: #ddd7f2;
    color: #43349b;
    border: 1px solid #bfb3e6;
}

/* Inline comment threads on agenda / progress tasks */
.comment-thread {
    background: #faf9ff;
    border: 1px solid #ece8f8;
    border-radius: .6rem;
    padding: .5rem .65rem;
    display: flex;
    flex-direction: column;
    gap: .25rem;
}

/* ============ Markdown body ============ */
.md-body {
    color: var(--ink-1);
    overflow-wrap: anywhere;
}

.md-body> :last-child {
    margin-bottom: 0;
}

.md-body p {
    margin-bottom: .4rem;
}

.md-body ul,
.md-body ol {
    margin-bottom: .4rem;
    padding-left: 1.2rem;
}

.md-body code {
    background: rgba(91, 75, 196, .10);
    color: #3f2fa5;
    padding: .1rem .35rem;
    border-radius: 4px;
    font-size: .85em;
}

.md-body pre {
    background: #241f38;
    color: #ede9fb;
    padding: .7rem .9rem;
    border-radius: 10px;
    overflow-x: auto;
    margin-bottom: .5rem;
}

.md-body pre code {
    background: none;
    color: inherit;
    padding: 0;
}

.md-body blockquote {
    border-left: 3px solid var(--accent);
    padding-left: .75rem;
    margin: .4rem 0;
    color: var(--ink-2);
}

.md-body table {
    width: 100%;
    margin-bottom: .5rem;
    border-collapse: collapse;
}

.md-body table {
    border: 2px solid #222;
}

.md-body th,
.md-body td {
    border: 1.5px solid #222;
    padding: .3rem .5rem;
}

.md-body img {
    max-width: 100%;
}

.md-body.md-clamp {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* @mention chip */
.mention {
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-soft);
    padding: 0 .3rem;
    border-radius: 4px;
}

/* ============ Markdown editor ============ */
.md-editor {
    position: relative;
}

.md-editor .md-tabs {
    display: flex;
    gap: .25rem;
    margin-bottom: .25rem;
}

.md-editor .md-tab {
    font-size: .72rem;
    padding: .1rem .5rem;
    border-radius: 6px;
    border: 1px solid transparent;
    background: none;
    color: var(--ink-2);
    cursor: pointer;
}

.md-editor .md-tab.active {
    background: var(--accent-soft);
    border-color: var(--border-1);
    color: var(--accent);
    font-weight: 600;
}

.md-editor .md-preview {
    display: none;
    min-height: 60px;
    padding: .5rem .75rem;
    background: var(--surface-2);
    border: 1px solid var(--border-1);
    border-radius: .5rem;
}

.md-editor .md-hint {
    font-size: .7rem;
    color: var(--ink-2);
    margin-top: .2rem;
}

/* @ autocomplete popup */
.mention-pop {
    position: absolute;
    z-index: 1080;
    min-width: 220px;
    max-height: 220px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid var(--border-1);
    border-radius: .6rem;
    box-shadow: 0 12px 24px rgba(36, 31, 56, .18);
    padding: .25rem;
    display: none;
}

.mention-pop .mi {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .35rem .5rem;
    border-radius: .4rem;
    cursor: pointer;
    font-size: .85rem;
}

.mention-pop .mi:hover,
.mention-pop .mi.active {
    background: var(--accent-soft);
}

.mention-pop .mi .av {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .7rem;
    font-weight: 700;
    flex: 0 0 auto;
}

.mention-pop .mi .hd {
    color: var(--ink-2);
    font-size: .75rem;
}

/* ============ Notification centre ============ */
.notif-fab {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 1045;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #6d5ce0, #4936b8);
    color: #fff;
    font-size: 1.35rem;
    box-shadow: 0 10px 24px rgba(73, 54, 184, .42);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .15s ease, box-shadow .15s ease;
}

.notif-fab:hover {
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 14px 30px rgba(73, 54, 184, .5);
}

.notif-fab:focus-visible {
    outline: 3px solid #a99cf0;
    outline-offset: 2px;
}

.notif-fab .notif-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 22px;
    height: 22px;
    padding: 0 5px;
    border-radius: 999px;
    background: #e11d48;
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

.notif-fab .notif-badge.show {
    display: flex;
}

@keyframes notif-pop {
    0% {
        transform: scale(1);
    }

    40% {
        transform: scale(1.35);
    }

    100% {
        transform: scale(1);
    }
}

.notif-fab .notif-badge.pop {
    animation: notif-pop .45s ease;
}

.notif-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 400px;
    max-width: 92vw;
    z-index: 1050;
    background: var(--surface-1);
    border-left: 1px solid var(--border-1);
    box-shadow: -12px 0 32px rgba(36, 31, 56, .18);
    transform: translateX(105%);
    transition: transform .22s ease;
    display: flex;
    flex-direction: column;
}

.notif-panel.open {
    transform: translateX(0);
}

.notif-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(36, 31, 56, .32);
    z-index: 1046;
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s ease;
}

.notif-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.notif-head {
    padding: 1rem 1.1rem .6rem;
    border-bottom: 1px solid var(--border-2);
}

.notif-body {
    overflow-y: auto;
    flex: 1 1 auto;
    padding: .5rem;
}

.notif-row {
    display: flex;
    gap: .7rem;
    padding: .7rem .75rem;
    border-radius: .7rem;
    text-decoration: none;
    color: var(--ink-1);
    border: 1px solid transparent;
    margin-bottom: .3rem;
}

.notif-row:hover {
    background: var(--surface-2);
    border-color: var(--border-2);
    color: var(--ink-1);
}

.notif-row .na {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .8rem;
    color: #fff;
    background: var(--accent);
}

.notif-row .nt {
    font-size: .87rem;
    line-height: 1.3;
}

.notif-row .nb {
    font-size: .78rem;
    color: var(--ink-2);
    margin-top: .1rem;
}

.notif-row .nm {
    font-size: .7rem;
    color: var(--ink-2);
    margin-top: .2rem;
}

/* Unread reads as unread: bold, opaque, accent bar. Read fades back. */
.notif-row.unread {
    background: var(--surface-2);
    border-color: var(--border-1);
    border-left: 3px solid var(--accent);
}

.notif-row.unread .nt {
    font-weight: 700;
}

.notif-row.read {
    opacity: .62;
}

.notif-row.read .nt {
    font-weight: 400;
}

.notif-row.read .na {
    background: #a49bbd;
}

.notif-empty {
    text-align: center;
    color: var(--ink-2);
    padding: 3rem 1rem;
}

.notif-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    flex: 0 0 auto;
    align-self: center;
}

/* ============ Agenda: master flow card + nested task cards ============ */
.agenda-flow-card {
    background: var(--surface-1);
    border: 1px solid var(--border-1);
    border-radius: 16px;
    margin-bottom: 1.1rem;
}

.agenda-flow-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: .5rem;
    padding: .9rem 1.1rem;
    border-bottom: 1px solid var(--border-2);
}

.agenda-flow-body {
    padding: .9rem 1.1rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

.agenda-task-card {
    background: var(--surface-2);
    border: 1px solid var(--border-2);
    border-radius: 12px;
    transition: box-shadow .15s ease;
    /* When a save jumps back to #ptask_<id>, keep the card clear of the sticky top bar. */
    scroll-margin-top: 90px;
}

.agenda-task-card:hover {
    box-shadow: 0 6px 16px rgba(36, 31, 56, .10);
}

.atc-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .6rem;
    padding: .65rem .85rem;
}

.atc-title {
    font-weight: 600;
    text-decoration: none;
    color: var(--ink-1);
}

.atc-title:hover {
    color: var(--accent);
}

.atc-body {
    padding: .65rem .85rem .8rem;
    border-top: 1px dashed var(--border-2);
}

.atc-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    margin-bottom: .45rem;
}

.atc-toggle {
    border: none;
    background: none;
    color: var(--ink-2);
    padding: .1rem .3rem;
    line-height: 1;
}

.atc-toggle:hover {
    color: var(--accent);
}

.atc-toggle i {
    transition: transform .18s ease;
    display: inline-block;
}

.atc-toggle[aria-expanded="false"] i {
    transform: rotate(-90deg);
}

/* Inline comment threads on agenda / progress tasks */
.comment-thread {
    background: var(--surface-2);
    border: 1px solid var(--border-2);
    border-radius: .6rem;
    padding: .5rem .6rem;
}

.comment-thread .avatar-xs {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: .62rem;
    font-weight: 700;
    margin-right: .35rem;
}

/* Pencil edit affordance on task cards */
.task-edit {
    opacity: 0;
    transition: opacity .15s ease;
    color: var(--ink-2);
}

.task-card:hover .task-edit,
.task-edit:focus-visible {
    opacity: 1;
}

.task-edit:hover {
    color: var(--accent);
}

/* ============ Team dashboard insights ============ */
.team-rail {
    display: flex;
    flex-direction: column;
    gap: .35rem;
}

.team-rail a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .5rem;
    padding: .7rem .9rem;
    border-radius: .7rem;
    text-decoration: none;
    color: var(--ink-1);
    border: 1px solid transparent;
}

.team-rail a:hover {
    background: var(--surface-2);
    border-color: var(--border-2);
}

.team-rail a.active {
    background: var(--accent-soft);
    border-color: var(--border-1);
    font-weight: 700;
    color: var(--accent);
}

.td-bar-track {
    height: 8px;
    border-radius: 999px;
    background: var(--border-2);
    overflow: hidden;
}

.td-bar-track>span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: var(--accent);
}

.tput-chart {
    display: flex;
    align-items: flex-end;
    gap: .3rem;
    height: 130px;
}

.tput-chart .tput-bar {
    flex: 1 1 0;
    background: linear-gradient(180deg, #7c6ce8, #4936b8);
    border-radius: 6px 6px 0 0;
    min-height: 3px;
}

.mix-bar {
    display: flex;
    height: 22px;
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid var(--border-1);
}

.mix-bar>span {
    display: block;
    height: 100%;
}

.workload-row {
    display: grid;
    grid-template-columns: 130px 1fr 40px;
    align-items: center;
    gap: .6rem;
    margin-bottom: .45rem;
    font-size: .85rem;
}

/* ============ Meetings ============ */
.schedule-hero {
    background: linear-gradient(135deg, #1b4d89, #2563eb);
    color: #fff;
    border-radius: var(--tm-radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--tm-shadow);
}

.schedule-hero-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: rgba(255, 255, 255, .18);
    font-size: 1.5rem;
    flex-shrink: 0;
}

.instant-card {
    background: linear-gradient(135deg, var(--accent-soft), var(--surface-1));
    border: 1px solid var(--border-1) !important;
}

.instant-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
    font-size: 1.2rem;
    flex-shrink: 0;
}

/* Calendar grid: lift it off the flat white sheet */
.calendar-grid {
    --bs-table-bg: transparent;
    background: transparent;
}

.calendar-grid th {
    background: var(--surface-2);
    border-color: var(--border-2);
    padding: .5rem .35rem;
}

.calendar-grid td {
    border-color: var(--border-2);
    transition: background-color .12s ease;
}

.calendar-grid td:hover {
    background: var(--surface-2);
}

/* ============ Login ============ */
.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1b4d89 55%, #2563eb 100%);
}

.login-shell .container {
    max-width: 960px;
}

.login-wrap {
    display: flex;
    justify-content: center;
}

.login-card {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    max-width: 900px;
    background: var(--surface-1);
    border-radius: 1.25rem;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(2, 6, 23, .45);
}

.login-brand {
    background: linear-gradient(150deg, #1b4d89, #2563eb 70%, #4f46e5);
    color: #fff;
    padding: 2.5rem 2.25rem;
    display: flex;
    align-items: center;
}

.login-logo {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    background: rgba(255, 255, 255, .16);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    margin-bottom: 1.1rem;
    overflow: hidden;
}

.login-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 6px;
}

/* Brand logo in the sidebar / mobile header */
.brand-logo {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    object-fit: contain;
    flex-shrink: 0;
}

.login-points {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: .92rem;
}

.login-points li {
    padding: .35rem 0;
    color: rgba(255, 255, 255, .85);
}

.login-form {
    padding: 2.75rem 2.5rem;
}

.login-form .input-group-text {
    border-right: 0;
    color: var(--ink-2);
}

.login-form .form-control {
    border-left: 0;
}

.login-form .input-group:focus-within .input-group-text {
    border-color: #86b7fe;
}

@media (max-width: 767.98px) {
    .login-card {
        grid-template-columns: 1fr;
        max-width: 460px;
    }

    .login-brand {
        display: none;
    }

    .login-form {
        padding: 2rem 1.5rem;
    }
}


/* ============ Wiki ============ */
.wiki-hero {
    background: linear-gradient(135deg, #4936b8, #6d28d9 60%, #2563eb);
    color: #fff;
    border-radius: var(--tm-radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--tm-shadow);
}

.wiki-hero-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: rgba(255, 255, 255, .18);
    font-size: 1.5rem;
    flex-shrink: 0;
}

.wiki-space-card {
    display: flex;
    align-items: center;
    gap: .9rem;
    padding: 1rem 1.1rem;
    background: var(--surface-1);
    border: 1px solid var(--border-1);
    border-radius: var(--tm-radius);
    text-decoration: none;
    color: var(--ink-1);
    height: 100%;
    transition: transform .12s ease, box-shadow .12s ease;
}

.wiki-space-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--tm-shadow-hov);
    color: var(--ink-1);
}

.wiki-space-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 1.35rem;
    flex-shrink: 0;
}

.wiki-space-card.is-global .wiki-space-icon {
    background: linear-gradient(135deg, #1b4d89, #2563eb);
    color: #fff;
}

.wiki-space-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 11px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 1.15rem;
}

.wiki-space-badge.is-global {
    background: linear-gradient(135deg, #1b4d89, #2563eb);
    color: #fff;
}

/* Two-pane layout: fixed tree on the left, content stretches to fill the rest */
.wiki-layout {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
}

.wiki-sidebar {
    position: sticky;
    top: 84px;
    background: var(--surface-1);
    border: 1px solid var(--border-1);
    border-radius: var(--tm-radius);
    padding: .85rem;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
}

.wiki-content {
    min-width: 0;
}

/* On-this-page contents — a compact collapsible card above the document */
.wiki-toc {
    background: var(--surface-1);
    border: 1px solid var(--border-1);
    border-radius: .8rem;
    padding: .5rem .9rem;
    margin-bottom: .9rem;
}

.wiki-toc>summary {
    cursor: pointer;
    font-weight: 600;
    font-size: .85rem;
    color: var(--ink-2);
    list-style: none;
}

.wiki-toc>summary::-webkit-details-marker {
    display: none;
}

.wiki-toc-nav {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem .9rem;
    margin-top: .5rem;
}

.wiki-toc-item {
    color: var(--ink-2);
    text-decoration: none;
    font-size: .82rem;
}

.wiki-toc-item:hover {
    color: var(--accent);
}

.wiki-toc-item.lvl-h3 {
    padding-left: .9rem;
    font-size: .78rem;
    opacity: .85;
}

/* Page action toolbar — comfortable spacing between controls */
.wiki-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
}

/* Rich text editor */
.wiki-rte-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .25rem;
    padding: .5rem;
    border: 1px solid var(--border-1);
    border-bottom: 0;
    border-radius: .7rem .7rem 0 0;
    background: var(--surface-2);
    position: sticky;
    top: 68px;
    z-index: 5;
}

.wiki-rte-toolbar .rte-block {
    width: auto;
    min-width: 120px;
}

.wiki-rte-toolbar .rte-size {
    width: auto;
    min-width: 90px;
}

.rte-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 .5rem;
    border: 1px solid transparent;
    border-radius: .45rem;
    background: transparent;
    color: var(--ink-1);
    cursor: pointer;
    font-size: .95rem;
    position: relative;
}

.rte-btn:hover {
    background: var(--surface-1);
    border-color: var(--border-1);
    color: var(--accent);
}

.rte-color {
    overflow: hidden;
}

.rte-color input[type=color] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.rte-sep {
    width: 1px;
    height: 22px;
    background: var(--border-1);
    margin: 0 .25rem;
}

.wiki-rte {
    border: 1px solid var(--border-1);
    border-radius: 0 0 .7rem .7rem;
    padding: 1.5rem 1.75rem;
    /* Open at ~A4 page height so it reads like a document page, then grow with the content. */
    min-height: 1123px;
    background: #fff;   /* white editing surface */
    box-shadow: 0 1px 6px rgba(15, 23, 42, .06);
    outline: none;
    overflow-wrap: anywhere;
}

/* Markdown editor: same white surface, border and A4 page height as the Doc editor. */
.wiki-md-input {
    min-height: 1123px;
    padding: 1.5rem 1.75rem;
    background: #fff;
    border: 1px solid var(--border-1);
    border-radius: .7rem;
    box-shadow: 0 1px 6px rgba(15, 23, 42, .06);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .9rem;
    line-height: 1.6;
    /* Auto-grows with content (JS), so no internal scrollbar — it behaves like the Doc page. */
    resize: none;
    overflow-y: hidden;
}

/* Keep the surface white and border steady on focus (no blue Bootstrap glow), matching Doc. */
.wiki-md-input:focus {
    background: #fff;
    border-color: var(--border-1);
    box-shadow: 0 1px 6px rgba(15, 23, 42, .06);
    outline: none;
}

#wikiMdEditor .md-preview {
    min-height: 1123px;
    padding: 1.5rem 1.75rem;
    background: #fff;
    border: 1px solid var(--border-1);
    border-radius: .7rem;
}

/* WYSIWYG: headings look the same in the editor as on the rendered page */
.wiki-rte h1 {
    font-size: 1.7rem;
    font-weight: 700;
    margin: 1rem 0 .5rem;
}

.wiki-rte h2 {
    font-size: 1.35rem;
    font-weight: 700;
    margin: .9rem 0 .5rem;
}

.wiki-rte h3 {
    font-size: 1.12rem;
    font-weight: 700;
    margin: .8rem 0 .4rem;
}

.wiki-rte blockquote {
    border-left: 3px solid var(--accent);
    padding-left: .75rem;
    margin: .5rem 0;
    color: var(--ink-2);
}

.wiki-rte pre {
    background: #241f38;
    color: #ede9fb;
    padding: .7rem .9rem;
    border-radius: 8px;
    overflow-x: auto;
}

.wiki-rte:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 .18rem var(--accent-soft);
}

.wiki-rte table {
    border-collapse: collapse;
    border: 2px solid #222;
}

.wiki-rte td,
.wiki-rte th {
    border: 1.5px solid #222;
    padding: .3rem .5rem;
    min-width: 2rem;
}

/* Links are clickable while editing (open in a new tab on click). */
.wiki-rte a {
    cursor: pointer;
}

.wiki-rte img {
    max-width: 100%;
}

/* Image resize handles (8-way) */
.wiki-img-resizer {
    position: absolute;
    display: none;
    z-index: 40;
    outline: 1.5px solid var(--accent);
    pointer-events: none;
}

.wiki-rz-handle {
    position: absolute;
    width: 11px;
    height: 11px;
    background: #fff;
    border: 1.5px solid var(--accent);
    border-radius: 2px;
    pointer-events: auto;
}

.wiki-rz-handle.rz-nw {
    top: -6px;
    left: -6px;
    cursor: nwse-resize;
}

.wiki-rz-handle.rz-n {
    top: -6px;
    left: calc(50% - 6px);
    cursor: ns-resize;
}

.wiki-rz-handle.rz-ne {
    top: -6px;
    right: -6px;
    cursor: nesw-resize;
}

.wiki-rz-handle.rz-e {
    top: calc(50% - 6px);
    right: -6px;
    cursor: ew-resize;
}

.wiki-rz-handle.rz-se {
    bottom: -6px;
    right: -6px;
    cursor: nwse-resize;
}

.wiki-rz-handle.rz-s {
    bottom: -6px;
    left: calc(50% - 6px);
    cursor: ns-resize;
}

.wiki-rz-handle.rz-sw {
    bottom: -6px;
    left: -6px;
    cursor: nesw-resize;
}

.wiki-rz-handle.rz-w {
    top: calc(50% - 6px);
    left: -6px;
    cursor: ew-resize;
}

.wiki-rte img {
    cursor: default;
}

/* Live collaboration presence */
.wiki-presence {
    background: var(--accent-soft);
    border: 1px solid var(--border-1);
    border-radius: .6rem;
    padding: .45rem .75rem;
    font-size: .85rem;
    color: var(--ink-1);
}

.wiki-presence.wiki-presence-live {
    animation: wikiPulse 1s ease;
}

.wiki-presence-chip {
    background: var(--surface-1);
    border: 1px solid var(--border-1);
    border-radius: 999px;
    padding: .05rem .5rem;
    font-weight: 600;
}

@keyframes wikiPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(91, 75, 196, .4);
    }

    100% {
        box-shadow: 0 0 0 .5rem rgba(91, 75, 196, 0);
    }
}

.wiki-tree {
    display: flex;
    flex-direction: column;
    gap: .05rem;
}

.wiki-tree .wiki-tree {
    margin-left: .65rem;
    border-left: 1px dashed var(--border-2);
    padding-left: .35rem;
}

.wiki-tree-row {
    display: flex;
    align-items: center;
    gap: .15rem;
    border-radius: .5rem;
}

.wiki-tree-row:hover {
    background: var(--surface-2);
}

.wiki-tree-link {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .35rem .5rem;
    border-radius: .5rem;
    color: var(--ink-1);
    text-decoration: none;
    font-size: .88rem;
    flex: 1 1 auto;
    min-width: 0;
}

.wiki-tree-link:hover {
    color: var(--accent);
}

.wiki-tree-link.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

.wiki-tree-link i {
    color: var(--ink-2);
    flex-shrink: 0;
}

.wiki-tree-link.active i {
    color: var(--accent);
}

.wiki-tree-add {
    flex-shrink: 0;
    opacity: 0;
    color: var(--ink-2);
    padding: .2rem .35rem;
    border-radius: .4rem;
    text-decoration: none;
    font-size: .8rem;
    transition: opacity .12s ease;
}

.wiki-tree-row:hover .wiki-tree-add,
.wiki-tree-add:focus-visible {
    opacity: 1;
}

.wiki-tree-add:hover {
    background: var(--accent-soft);
    color: var(--accent);
}

.wiki-page-card {
    background: var(--surface-1);
    border: 1px solid var(--border-1);
    border-radius: var(--tm-radius);
    padding: 1.5rem 1.75rem;
    box-shadow: var(--tm-shadow);
}

.wiki-docref {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    background: var(--accent-soft);
    color: var(--accent);
    padding: .05rem .4rem;
    border-radius: .35rem;
    font-size: .78rem;
}

.wiki-recent-card {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .7rem .85rem;
    background: var(--surface-1);
    border: 1px solid var(--border-1);
    border-radius: .8rem;
    text-decoration: none;
    color: var(--ink-1);
}

.wiki-recent-card:hover {
    border-color: var(--accent);
    color: var(--ink-1);
}

.wiki-recent-card>i:first-child {
    color: var(--accent);
    font-size: 1.2rem;
}

/* Rich document typography */
.wiki-doc-body {
    font-size: 1rem;
    line-height: 1.7;
}

.wiki-doc-body h1,
.wiki-doc-body h2,
.wiki-doc-body h3 {
    font-weight: 700;
    margin: 1.4rem 0 .6rem;
    scroll-margin-top: 90px;
}

.wiki-doc-body h1 {
    font-size: 1.6rem;
}

.wiki-doc-body h2 {
    font-size: 1.3rem;
    border-bottom: 1px solid var(--border-2);
    padding-bottom: .3rem;
}

.wiki-doc-body h3 {
    font-size: 1.1rem;
}

.wiki-doc-body p {
    margin: 0 0 .9rem;
}

.wiki-doc-body ul,
.wiki-doc-body ol {
    margin: 0 0 .9rem 1.25rem;
}

.wiki-doc-body li {
    margin-bottom: .25rem;
}

.wiki-doc-body code {
    background: var(--surface-2);
    padding: .1rem .35rem;
    border-radius: .3rem;
    font-size: .88em;
}

.wiki-doc-body pre {
    background: #1e1b2e;
    color: #e9e6f5;
    padding: .9rem 1rem;
    border-radius: .6rem;
    overflow-x: auto;
}

.wiki-doc-body pre code {
    background: transparent;
    padding: 0;
    color: inherit;
}

.wiki-doc-body blockquote {
    border-left: 3px solid var(--accent);
    background: var(--surface-2);
    margin: 0 0 .9rem;
    padding: .5rem .9rem;
    border-radius: 0 .5rem .5rem 0;
    color: var(--ink-2);
}

/* Each rendered table sits in this scroll box (added by RenderHtml). A wide table scrolls
   horizontally inside it instead of overflowing the page. */
.wiki-table-wrap {
    max-width: 100%;
    overflow-x: auto;
    margin: 0 0 1rem;
}

.wiki-doc-body table {
    /* Fill the full width when the content is narrow; grow past it (the wrapper then scrolls)
       when the content is wide. */
    min-width: 100%;
    border-collapse: collapse;
    border: 2px solid #222;
    margin: 0;
}

.wiki-doc-body th,
.wiki-doc-body td {
    border: 1.5px solid #222;
    padding: .45rem .6rem;
    text-align: left;
}

.wiki-doc-body th {
    background: var(--surface-2);
}

.wiki-doc-body img {
    max-width: 100%;
    border-radius: .5rem;
}

.wiki-link {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid var(--accent-soft);
}

.wiki-link:hover {
    border-bottom-color: var(--accent);
}

.wiki-link-new {
    color: #b45309;
    border-bottom-style: dashed;
}

/* Discussion */
.wiki-comment {
    display: flex;
    gap: .6rem;
    padding: .7rem 0;
    border-bottom: 1px solid var(--border-2);
}

.wiki-comment:last-of-type {
    border-bottom: 0;
}

.wiki-comment>div {
    min-width: 0;
}

.wiki-comment .avatar-xs {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: .78rem;
    font-weight: 700;
    flex-shrink: 0;
}

/* Keep long titles / content inside their boxes (wrap or ellipsis instead of overflowing) */
.wiki-recent-card>div {
    min-width: 0;
}

.wiki-recent-card .fw-semibold {
    overflow-wrap: anywhere;
}

.wiki-comment .md-body,
.comment-thread .md-body,
.comment-thread .small {
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Diff */
.wiki-diff {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .84rem;
    border: 1px solid var(--border-1);
    border-radius: .6rem;
    overflow: hidden;
}

.diff-line {
    display: flex;
    gap: .5rem;
    padding: .1rem .6rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.diff-sign {
    width: 1ch;
    color: var(--ink-2);
    flex-shrink: 0;
}

.diff-add {
    background: rgba(22, 163, 74, .14);
}

.diff-add .diff-sign {
    color: #15803d;
}

.diff-del {
    background: rgba(220, 38, 38, .12);
}

.diff-del .diff-sign {
    color: #b91c1c;
}

@media (max-width: 1100px) {
    .wiki-layout {
        grid-template-columns: 220px minmax(0, 1fr);
    }
}

@media (max-width: 767.98px) {
    .wiki-layout {
        grid-template-columns: 1fr;
    }

    .wiki-sidebar {
        position: static;
        max-height: none;
    }
}