/* GiP Dashboard v2 — Linear/Vercel-inspired design system
   Dark-first, performance-focused, mobile-native */

/* === DESIGN TOKENS (Timeweb Cloud EXACT from DevTools) === */
:root {
    /* Surfaces — from DevTools CSS variables:
       --v-theme-background: rgb(18,18,18)        #121212
       --background-primary: #303035               cards/panels
       --background-primary-accent: rgb(38,37,42)  #26252a
       --background-secondary: #52525b             raised elements
       --v-theme-surface: rgb(72,72,80)            #484850
       --v-theme-surface-light: rgb(66,66,66)      #424242
       --border-primary: #27272a
       --v-theme-rich-grey: rgb(51,65,85)          #334155
       --v-theme-light-grey: rgb(82,82,91)         #52525b
    */
    --bg:           #121212;       /* --v-theme-background (page body) */
    --bg-main:      #303035;       /* --background-primary (main content) */
    --bg-elevated:  #484850;       /* --v-theme-surface (cards in content) */
    --bg-hover:     #52525b;       /* --background-secondary / --v-theme-light-grey */
    --bg-active:    #5a5a64;       /* active/pressed */
    --bg-input:     #26252a;       /* --background-primary-accent */
    --bg-sidebar:   #26252a;       /* --background-primary-accent */
    --bg-header:    #121212;       /* same as page bg */
    --bg-secondary: #26252a;       /* chat panel */

    /* Text — EXACT */
    --text-1:       #f4f4f5;       /* --text-primary */
    --text-2:       #a1a1aa;       /* --text-secondary */
    --text-3:       #71717a;       /* --v-theme-secondary: rgb(113,113,122) */

    /* Accent — Timeweb primary: rgb(96,165,250) = #60a5fa (blue) */
    --accent:       #60a5fa;
    --accent-soft:  rgba(96, 165, 250, 0.10);
    --accent-hover: rgba(96, 165, 250, 0.18);
    --accent-text:  #f4f4f5;

    /* Semantic — from DevTools */
    --danger:       #ef4444;       /* --v-theme-error: rgb(239,68,68) */
    --danger-soft:  rgba(239, 68, 68, 0.12);
    --warning:      #ea580c;       /* --v-theme-warning: rgb(234,88,12) */
    --warning-soft: rgba(234, 88, 12, 0.12);

    /* Datetime accent — bright yellow */
    --dt-color:     #FACC15;
    --dt-bright:    #FDE047;
    --dt-glow:      rgba(250, 204, 21, 0.35);

    /* Borders — EXACT */
    --border:       #27272a;       /* --border-primary */
    --border-hover: #3f3f46;       /* zinc-700 */
    --border-input: #27272a;

    /* Layout */
    --sidebar-w:    100px;
    --header-h:     52px;
    --bottom-nav-h: 56px;

    /* Radius — Timeweb uses generous rounding */
    --r-sm:   6px;
    --r-md:   8px;
    --r-lg:   12px;
    --r-xl:   16px;

    /* Shadows */
    --shadow-sm:  0 1px 3px rgba(0,0,0,0.4);
    --shadow-md:  0 4px 14px rgba(0,0,0,0.35);
    --shadow-lg:  0 12px 40px rgba(0,0,0,0.55);

    /* Animation */
    --dur-fast:   80ms;
    --dur-normal: 150ms;
    --dur-slow:   200ms;
    --ease-out:   cubic-bezier(0.25, 0.46, 0.45, 0.94);
    /* Typography */
    --font:      'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

/* === LIGHT MODE === */
/* Применяется через data-theme="light" на <html> ИЛИ автоматически по
 * prefers-color-scheme:light если юзер не выбрал явно (data-theme="auto").
 * Переключение — через toggle в header (JS сохраняет в localStorage). */
[data-theme="light"],
[data-theme="auto"] {
    /* no-op — default остаётся dark. Auto переключится ниже через media */
}

[data-theme="light"] {
    --bg:           #eeeef2;
    --bg-main:      #ffffff;
    --bg-elevated:  #ffffff;
    --bg-hover:     #f0f0f3;
    --bg-active:    #e8e8ec;
    --bg-input:     #ffffff;
    --bg-sidebar:   #eeeef2;
    --bg-header:    #ffffff;
    --bg-secondary: #f5f5f7;
    --text-1:       #1a1a2e;
    --text-2:       #555566;
    --text-3:       #8888a0;
    --accent:       #2563eb;
    --accent-text:  #ffffff;
    --border:       rgba(0, 0, 0, 0.08);
    --border-hover: rgba(0, 0, 0, 0.15);
    --border-input: rgba(0, 0, 0, 0.12);
    --accent-soft:  rgba(37, 99, 235, 0.08);
    --accent-hover: rgba(37, 99, 235, 0.14);
    --danger-soft:  rgba(244, 63, 94, 0.08);
    --warning-soft: rgba(245, 158, 11, 0.08);
    --shadow-sm:  0 1px 2px rgba(0,0,0,0.06);
    --shadow-md:  0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg:  0 12px 40px rgba(0,0,0,0.12);
}

/* Auto: следуй системному prefers-color-scheme */
@media (prefers-color-scheme: light) {
    [data-theme="auto"] {
        --bg:           #eeeef2;
        --bg-main:      #ffffff;
        --bg-elevated:  #ffffff;
        --bg-hover:     #f0f0f3;
        --bg-active:    #e8e8ec;
        --bg-input:     #ffffff;
        --bg-sidebar:   #eeeef2;
        --bg-header:    #ffffff;
        --bg-secondary: #f5f5f7;
        --text-1:       #1a1a2e;
        --text-2:       #555566;
        --text-3:       #8888a0;
        --accent:       #2563eb;
        --accent-text:  #ffffff;
        --border:       rgba(0, 0, 0, 0.08);
        --border-hover: rgba(0, 0, 0, 0.15);
        --border-input: rgba(0, 0, 0, 0.12);
        --accent-soft:  rgba(37, 99, 235, 0.08);
        --accent-hover: rgba(37, 99, 235, 0.14);
        --danger-soft:  rgba(244, 63, 94, 0.08);
        --warning-soft: rgba(245, 158, 11, 0.08);
        --shadow-sm:  0 1px 2px rgba(0,0,0,0.06);
        --shadow-md:  0 4px 12px rgba(0,0,0,0.08);
        --shadow-lg:  0 12px 40px rgba(0,0,0,0.12);
    }
}

/* === RESET + BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-1);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* === LAYOUT === */
.layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) 440px 1fr;
    grid-template-rows: var(--header-h) 1fr;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* === HEADER (dark top bar, full width) === */
.header {
    grid-column: 1 / -1;
    background: var(--bg-header);
    border-bottom: 1px solid #2e2e33;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px 0 20px;
    z-index: 10;
}
.header h1 {
    font-size: 16px;
    font-weight: 700;
    color: #60a5fa;
    letter-spacing: -0.01em;
}
.header .time {
    font-size: 15px;
    font-weight: 600;
    color: #60a5fa;
    font-variant-numeric: tabular-nums;
    text-shadow: none;
}

/* === SIDEBAR (floating tile, Timeweb-style) === */
.sidebar {
    grid-row: 2;
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 8px 12px;
    gap: 0;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 11;
    /* Floating tile — separate card on dark bg */
    margin: 10px;
    margin-right: 0;
    border-radius: 16px;
    border: 1px solid #2e2e33;
    box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}
.sidebar-logo {
    font-size: 22px;
    font-weight: 800;
    color: var(--accent-text);
    margin-bottom: 14px;
    padding: 2px 0;
    letter-spacing: -0.02em;
    text-decoration: none;
    display: block;
}
.sidebar a {
    width: 86px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 12px 6px 9px;
    border-radius: 12px;
    text-decoration: none;
    font-size: 1.35rem;
    color: var(--text-2);
    transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
    position: relative;
}
.sidebar a .sidebar-label {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.01em;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 82px;
    color: inherit;
}
.sidebar a:hover { background: rgba(255,255,255,0.06); color: var(--text-1); }
.sidebar a.active { background: rgba(255,255,255,0.08); color: var(--text-1); }
.sidebar-divider {
    width: 52px;
    height: 1px;
    background: #2e2e33;
    margin: 8px 0;
    flex-shrink: 0;
}
.sidebar-spacer { flex: 1; }

/* === CHAT PANEL (floating tile, like sidebar) === */
.chat-panel {
    grid-row: 2;
    display: flex;
    flex-direction: column;
    background: var(--bg-sidebar);
    overflow: hidden;
    min-height: 0;
    /* Floating tile */
    margin: 10px 0 10px 10px;
    border-radius: 16px;
    border: 1px solid #2e2e33;
    box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}

/* Top block: header + input (sticky top) */
.chat-panel-top {
    flex-shrink: 0;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
}
.chat-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px 6px;
}
.chat-panel-title {
    font-size: 13px;
    font-weight: 600;
    color: #60a5fa;
    letter-spacing: -0.01em;
}
.chat-panel-new {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--accent);
    width: 26px; height: 26px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--dur-fast), color var(--dur-fast);
}
.chat-panel-new:hover { background: var(--bg-hover); color: var(--text-1); }

/* Input area — inside top block */
.chat-panel .chat-input-area {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    padding: 6px 10px 10px;
    gap: 6px;
    border: none;
}
.chat-panel .chat-input {
    flex: 1;
    font-size: 13px;
    padding: 8px 10px;
    min-height: 36px;
    max-height: 120px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--bg);
    color: var(--text-1);
    resize: none;
    font-family: var(--font);
    line-height: 1.4;
}
.chat-panel .chat-input:focus {
    border-color: var(--accent);
    outline: none;
}
.chat-panel .chat-input::placeholder { color: var(--text-3); }
.chat-panel .chat-send-btn,
.chat-panel .chat-voice-btn {
    width: 34px; height: 34px;
    font-size: 14px;
    flex-shrink: 0;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--bg);
    color: var(--accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--dur-fast), color var(--dur-fast);
}
.chat-panel .chat-send-btn:hover,
.chat-panel .chat-voice-btn:hover {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--accent);
}

/* Messages — scrollable only on hover */
.chat-panel .chat-messages {
    flex: 1;
    overflow-y: hidden;
    padding: 10px;
    min-height: 0;
    scroll-behavior: smooth;
}
.chat-panel .chat-messages:hover {
    overflow-y: auto;
}
.chat-panel .chat-bubble {
    max-width: 95%;
    padding: 8px 10px;
    margin-bottom: 8px;
    font-size: 13px;
    line-height: 1.45;
    border-radius: var(--r-md);
}
.chat-panel .chat-bubble--user {
    background: var(--accent-soft);
    color: var(--text-1);
    margin-left: auto;
    border-bottom-right-radius: 4px;
}
.chat-panel .chat-bubble--assistant {
    background: var(--bg-elevated);
    color: var(--text-1);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

/* Email draft card */
.email-draft-card{background:var(--bg);border:1px solid var(--accent);border-radius:var(--r-md);overflow:hidden}
.email-draft-header{background:var(--accent-soft);color:var(--accent-text);padding:6px 12px;font-weight:600;font-size:13px}
.email-draft-meta{padding:8px 12px;font-size:12px;color:var(--text-2);border-bottom:1px solid var(--border)}
.email-draft-meta b{color:var(--text-1)}
.email-draft-body{padding:10px 12px;font-size:13px;color:var(--text-1);line-height:1.5;white-space:pre-line;max-height:300px;overflow-y:auto}
.email-draft-actions{padding:8px 12px;display:flex;gap:8px;border-top:1px solid var(--border)}

/* Welcome state */
.chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 2rem 1rem;
}
.chat-panel .chat-welcome-icon { font-size: 32px; margin-bottom: 8px; opacity: 0.6; }
.chat-panel .chat-welcome-text { font-size: 12px; max-width: 260px; color: var(--text-3); line-height: 1.5; }

/* Chat notifications */
/* Delete button on chat messages */
.chat-del-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border: none;
    background: none;
    color: var(--text-3);
    font-size: 11px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}
.chat-bubble:hover .chat-del-btn,
.chat-notif:hover .chat-del-btn { opacity: 0.7; }
.chat-del-btn:hover { opacity: 1; background: var(--bg-hover); }

.chat-notif {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--r-md);
    padding: 10px 12px;
    margin-bottom: 6px;
    font-size: 12px;
    line-height: 1.4;
}
.chat-notif--email { border-left-color: #58a6ff; }
.chat-notif--reminder { border-left-color: #d29922; }
.chat-notif--project { border-left-color: #a371f7; }
.chat-notif--system { border-left-color: var(--text-3); }

.notif-header { font-weight: 600; margin-bottom: 4px; font-size: 12px; }
.notif-meta { font-size: 11px; color: var(--text-2); margin-bottom: 4px; line-height: 1.4; }
.notif-body { font-size: 12px; line-height: 1.4; margin: 6px 0; color: var(--text-1); white-space: pre-line; }

/* Email meta block — high-contrast white panel inside dark notification card */
.notif-email-meta {
    background: #f5f5f7;
    color: #0a0a0a;
    border-radius: 6px;
    padding: 8px 10px;
    margin: 6px 0;
    font-size: 12px;
    line-height: 1.5;
}
.notif-email-meta-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 2px;
}
.notif-email-meta-row:last-child { margin-bottom: 0; }
.notif-email-meta-label {
    color: #6b7280;
    font-size: 11px;
    font-weight: 600;
    min-width: 42px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.notif-email-meta-value {
    color: #0a0a0a;
    font-weight: 700;
    flex: 1;
    word-break: break-word;
}
.notif-email-meta-row--subject .notif-email-meta-value { font-size: 13px; }

/* Email body classification row: project + section + level (visual badges) */
.notif-class-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 6px 0 4px;
}
.notif-project-badge {
    font-size: 13px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    background: #60a5fa;
    color: #fff;
    white-space: nowrap;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* Unsure: same blue badge — uncertainty is shown by "?" suffix and confirm row */
.notif-project-badge--unsure {
    background: #60a5fa;
    color: #fff;
}
.notif-section-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(167, 139, 250, 0.18);
    border: 1px solid rgba(167, 139, 250, 0.4);
    color: #c4b5fd;
    white-space: nowrap;
}
.notif-level-badge {
    font-size: 14px;
    line-height: 1;
}

/* Email body text — larger, with subtle quote styling */
.notif-email-body {
    background: rgba(255,255,255,0.04);
    border-left: 3px solid var(--dt-color);
    padding: 6px 10px;
    margin: 6px 0;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-1);
}
.notif-email-body strong { color: #fff; font-weight: 700; }

/* Task suggestion line */
.notif-task-line {
    background: rgba(96, 165, 250, 0.08);
    border-radius: 4px;
    padding: 6px 10px;
    margin: 6px 0;
    font-size: 12px;
    color: var(--text-1);
    border-left: 3px solid #60a5fa;
}
.notif-task-line strong { color: #60a5fa; }
.notif-related-line {
    font-size: 11px;
    color: var(--text-3);
    margin-top: 4px;
    padding: 4px 10px;
    font-style: italic;
}
.notif-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.notif-btn {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    background: var(--bg-hover);
    color: var(--text-1);
    cursor: pointer;
    font-family: var(--font);
    transition: all var(--dur-fast);
}
.notif-btn:hover { background: var(--bg-active); border-color: var(--border-hover); }
.notif-btn--primary { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.notif-btn--primary:hover { background: var(--accent-hover); }
.notif-btn:disabled { opacity: 0.4; cursor: default; }
.notif-feedback { display: flex; gap: 6px; margin-top: 6px; }
.notif-fb-btn {
    background: none; border: none; cursor: pointer;
    font-size: 16px; opacity: 0.5; transition: opacity 0.15s;
}
.notif-fb-btn:hover { opacity: 1; }
.notif--acted { opacity: 0.5; }
.notif--acted .notif-btn, .notif--acted .notif-fb-btn { pointer-events: none; }

/* Thinking dots */
.chat-thinking { opacity: 0.7; }

/* Voice recording state */
.chat-voice-btn--recording {
    background: var(--danger) !important;
    color: #fff !important;
    border-color: var(--danger) !important;
    animation: chat-voice-pulse 1.5s ease-in-out infinite;
}

/* === MAIN === */
.main {
    grid-row: 2;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    /* Floating tile like sidebar & chat */
    background: var(--bg-sidebar);
    margin: 10px 10px 10px 10px;
    border-radius: 16px;
    border: 1px solid #2e2e33;
    box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}
/* Dashboard: lock main height so board fills it */
.main:has(.board) {
    overflow: hidden;
}

/* === STATS ROW === */
.stats-row {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
    flex-shrink: 0;
}
.stat-card-inline {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    min-width: 0;
    cursor: pointer;
    position: relative;
    transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
    user-select: none;
}
.stat-card-inline:hover { border-color: var(--border-hover); background: var(--bg-hover); }
.stat-card-inline .label { font-size: 12px; color: var(--text-1); display: flex; align-items: center; gap: 4px; }
.stat-card-inline .label::after { content: '\25BE'; font-size: 10px; opacity: 0.5; }
.stat-card-inline .value { font-size: 16px; font-weight: 600; color: var(--accent-text); }
.stat-card-inline.red .value { color: var(--danger); }
.stat-card-inline.red { border-color: rgba(244,63,94,0.2); }
.overdue-badge { font-size: 11px; color: var(--danger); font-weight: 600; background: color-mix(in srgb, var(--danger) 12%, transparent); padding: 2px 6px; border-radius: 6px; }

/* === STAT DROPDOWN === */
.stat-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    min-width: 280px;
    max-height: 400px;
    overflow-y: auto;
    background: var(--bg-elevated);
    border: 1px solid var(--border-hover);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    padding: 6px;
    animation: dropIn var(--dur-normal) var(--ease-out);
}
.stat-dropdown.open { display: block; }
@keyframes dropIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}
.stat-dropdown-filters {
    display: flex;
    gap: 4px;
    padding: 4px 4px 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 6px;
    flex-wrap: wrap;
}
.stat-filter-btn {
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: transparent;
    color: var(--text-3);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font);
    transition: all var(--dur-fast) var(--ease-out);
    white-space: nowrap;
}
.stat-filter-btn:hover { border-color: var(--border-hover); color: var(--text-1); }
.stat-filter-btn.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.stat-dropdown-list { display: flex; flex-direction: column; gap: 2px; }
.stat-dropdown-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--r-md);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    transition: background var(--dur-fast) var(--ease-out);
}
.stat-dropdown-item:hover { background: var(--bg-hover); }
.stat-dropdown-item-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-1);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.stat-dropdown-item-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
    flex-shrink: 0;
}
.stat-dropdown-item-badge--ok { background: var(--accent-soft); color: var(--accent-text); }
.stat-dropdown-item-badge--warn { background: var(--warning-soft); color: var(--warning); }
.stat-dropdown-item-badge--bad { background: var(--danger-soft); color: var(--danger); }
.stat-dropdown-item-health {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.stat-dropdown-item-health--green { background: var(--accent); }
.stat-dropdown-item-health--yellow { background: var(--warning); }
.stat-dropdown-item-health--red { background: var(--danger); }
.stat-dropdown-empty {
    padding: 16px;
    text-align: center;
    color: var(--text-3);
    font-size: 12px;
}

/* === SECTION === */
.section { margin-bottom: 0; flex: 1; display: flex; flex-direction: column; min-height: 0; }
.section-title {
    font-size: 12px;
    font-weight: 600;
    color: #60a5fa;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0;
    white-space: nowrap;
}

/* Section toolbar — single compact row */
.section-toolbar {
    display: flex;
    align-items: stretch;
    gap: 6px;
    margin-bottom: 6px;
    flex-shrink: 0;
}
.section-toolbar-search {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-hover);
    border-radius: var(--r-md);
    padding: 0 14px;
    height: 36px;
    min-width: 0;
}
.section-toolbar .view-tabs {
    margin-left: auto;
}
.section-toolbar-search span { color: var(--text-3); font-size: 13px; flex-shrink: 0; }
.section-toolbar-search input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-1);
    font-size: 13px;
    outline: none;
    min-width: 0;
}
.section-toolbar-search input::placeholder { color: var(--text-3); }
.section-toolbar-search kbd {
    font-size: 11px;
    padding: 2px 7px;
    border: 1px solid var(--border-hover);
    border-radius: 4px;
    color: var(--text-2);
    background: var(--bg-hover);
    flex-shrink: 0;
}
.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-lg);
    max-height: 300px;
    overflow-y: auto;
    z-index: 50;
    margin-top: 4px;
}
.search-item {
    padding: 6px 10px;
    font-size: 12px;
    color: var(--text-1);
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    line-height: 1.4;
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--bg-hover); }

/* Glass card removed — no more ::before/::after pseudo-elements */
.card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
}

/* === VIEW TABS === */
.view-tabs { display: flex; gap: 6px; }
.view-tab {
    padding: 0 14px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border-hover);
    background: var(--bg-elevated);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-1);
    cursor: pointer;
    border-radius: var(--r-md);
    transition: all var(--dur-fast) var(--ease-out);
    font-family: var(--font);
}
.view-tab:hover { background: var(--bg-hover); color: #fff; border-color: #52525b; }
.view-tab--active {
    background: var(--bg-hover);
    color: #fff;
    border-color: #52525b;
}

/* === SEARCH BAR === */
.search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    margin-bottom: 12px;
}
.search-bar span { color: var(--text-3); font-size: 14px; }
.search-bar input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 13px;
    color: var(--text-1);
    outline: none;
    font-family: var(--font);
}
.search-bar input::placeholder { color: var(--text-3); }
.search-bar kbd {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: var(--r-sm);
    background: var(--bg-hover);
    color: var(--text-3);
    border: 1px solid var(--border);
    font-family: var(--font-mono);
}

/* === KANBAN BOARD === */
.board {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    flex: 1;
    min-height: 0;
}
.board-col {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.board-col-header {
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.board-col-header--overdue { color: var(--danger); }
.board-col-header--today { color: var(--text-1); }
.board-col-header--future { color: var(--text-2); }
.board-col-count {
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 10px;
    background: var(--bg-hover);
    color: var(--text-3);
    font-weight: 500;
}
.board-col-header--overdue .board-col-count { background: var(--danger-soft); color: var(--danger); }
.board-col-header--today .board-col-count { background: var(--accent-soft); color: var(--accent-text); }
.board-col-body {
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: hidden;
    flex: 1;
    min-height: 0;
}
.board-col-body:hover {
    overflow-y: auto;
}
.board-col-empty {
    text-align: center;
    padding: 24px 12px;
    color: var(--text-3);
    font-size: 12px;
}
.board-subheader {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 6px 6px 2px;
}

/* Blink — use color change instead of opacity (less distracting) */
.blink { color: var(--danger); }

/* === TICKET === */
.ticket {
    position: relative;
    background: #63636e;
    border: 1px solid #111113;
    border-radius: var(--r-md);
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.ticket:hover { background: #6e6e7a; border-color: #111113; }
.ticket--today { border-left: 3px solid var(--accent); }
.ticket--overdue { border-left: 3px solid var(--danger); }
.ticket--urgent {
    background: rgba(248, 81, 73, 0.12) !important;
    border: 1px solid rgba(248, 81, 73, 0.4) !important;
    border-left: 4px solid #f85149 !important;
}
.ticket--urgent .ticket-row2 { color: #f85149; font-weight: 600; }
/* When urgent marker overlaps with overdue (red-on-red), text becomes
 * illegible and visually "spills" out of the tile. Switch urgent styling
 * to amber in overdue column so both states coexist clearly. */
.ticket--overdue.ticket--urgent {
    background: rgba(251, 188, 5, 0.10) !important;
    border-left: 4px solid #fbbc05 !important;
}
.ticket--overdue.ticket--urgent .ticket-row2 {
    color: #fbbc05;
}
.ticket--done { opacity: 0.4; }
.ticket--done:hover { opacity: 0.65; }
.ticket--dragging {
    opacity: 0.5;
    transform: rotate(1deg);
    box-shadow: var(--shadow-lg);
    transition: opacity 0.15s, transform 0.15s;
}

/* Row 1: number · time · project · actions */
.ticket-row1 {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px 4px;
}
.ticket-num {
    font-size: 13px;
    font-weight: 600;
    color: #60a5fa;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.ticket-sep {
    width: 1px;
    height: 14px;
    background: #111113;
    flex-shrink: 0;
}
.ticket-time-badge {
    font-size: 13px;
    font-weight: 700;
    color: var(--dt-color);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.ticket-project-badge {
    font-size: 13px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 3px;
    background: #60a5fa;
    color: #fff;
    white-space: nowrap;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ticket-date-badge {
    font-size: 13px;
    font-weight: 600;
    color: var(--danger);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.ticket-spacer { flex: 1; }

/* Action buttons — visible on card */
.ticket-btn {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px; height: 26px;
    padding: 0;
    background: transparent;
    border: 1px solid #3f3f46;
    cursor: pointer;
    color: var(--text-2);
    border-radius: var(--r-sm);
    font-size: 12px;
    transition: all var(--dur-fast) var(--ease-out);
}
.ticket-btn:hover { background: transparent; color: var(--text-1); border-color: #60a5fa; }
.ticket-btn--del:hover { color: var(--danger); border-color: var(--danger); }

/* Row 2: description text */
.ticket-row2 {
    padding: 2px 10px 8px;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.45;
    color: var(--text-1);
}

/* Create task button */
.board-create-btn {
    width: 100%;
    padding: 8px;
    margin-bottom: 4px;
    background: var(--bg-elevated);
    border: 1px dashed var(--border);
    border-radius: var(--r-md);
    color: var(--text-3);
    font-size: 12px;
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--dur-fast);
}
.board-create-btn:hover {
    border-color: var(--accent);
    color: var(--accent-text);
    background: var(--accent-soft);
}

/* Create task button in chat panel */
.chat-create-task-btn {
    flex-shrink: 0;
    width: calc(100% - 16px);
    margin: 6px 8px 8px;
    padding: 8px;
    background: var(--accent-soft);
    border: 1px solid rgba(78, 201, 176, 0.2);
    border-radius: var(--r-md);
    color: var(--accent-text);
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--dur-fast);
}
.chat-create-task-btn:hover {
    background: var(--accent-hover);
    border-color: var(--accent);
}

/* Create task modal */
.create-task-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
}
.create-task-overlay.active {
    display: flex;
}
.create-task-dialog {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    width: 460px;
    max-width: 90vw;
    padding: 16px;
    box-shadow: var(--shadow-lg);
}
.create-task-dialog h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-1);
    margin-bottom: 12px;
}
.create-task-dialog label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 4px;
    margin-top: 10px;
}
.create-task-dialog input,
.create-task-dialog textarea,
.create-task-dialog select {
    width: 100%;
    padding: 8px 10px;
    font-size: 13px;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-1);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    outline: none;
    box-sizing: border-box;
}
.create-task-dialog input:focus,
.create-task-dialog textarea:focus,
.create-task-dialog select:focus {
    border-color: var(--accent);
}
.create-task-dialog textarea {
    min-height: 60px;
    resize: vertical;
}
.create-task-row {
    display: flex;
    gap: 8px;
}
.create-task-row > div { flex: 1; }
.create-task-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 14px;
}
.create-task-actions button {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--r-md);
    cursor: pointer;
    font-family: var(--font);
    border: none;
}
.ct-btn-cancel {
    background: var(--bg-hover);
    color: var(--text-2);
}
.ct-btn-cancel:hover { background: var(--bg-active); }
.ct-btn-create {
    background: var(--accent);
    color: #000;
}
.ct-btn-create:hover { opacity: 0.85; }

/* Drag-over state */
.board-col-body--dragover {
    background: var(--accent-soft);
    border-radius: var(--r-md);
    outline: 2px dashed var(--accent);
    outline-offset: -2px;
    transition: background 0.15s, outline 0.15s;
}

/* === DEPENDENCY DRAG HANDLE (n8n-style) === */
.dep-handle {
    position: absolute;
    right: 4px;
    bottom: 4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0;
    cursor: crosshair;
    transition: opacity 0.15s, transform 0.15s;
    z-index: 6;
}
.ticket:hover .dep-handle { opacity: 0.7; }
.dep-handle:hover {
    transform: scale(1.6);
    opacity: 1;
}

/* Link badge on tickets */
.ticket-link-badge {
    font-size: 11px;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.15s;
    padding: 0 2px;
}
.ticket-link-badge:hover {
    opacity: 1;
}

/* === DEPENDENCY LINK MODE === */
body.dep-link-mode { cursor: crosshair !important; user-select: none; }
body.dep-link-mode .ticket { cursor: crosshair !important; }
body.dep-link-mode .ticket:hover { box-shadow: inset 0 0 0 2px var(--accent) !important; }
body.dep-drag-mode { cursor: crosshair !important; user-select: none; }
body.dep-drag-mode .ticket:hover { box-shadow: inset 0 0 0 2px var(--accent) !important; }
body.dep-drag-mode .dep-handle { pointer-events: none; }

/* === FLOATING PICKER === */
.floating-picker {
    position: fixed;
    z-index: 9999;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-lg);
    padding: 8px;
    min-width: 240px;
}
.floating-picker-body { display: flex; flex-direction: column; gap: 6px; }
.fp-input {
    font-size: 14px;
    padding: 8px 10px;
    border: 1px solid var(--border-input);
    border-radius: var(--r-md);
    background: var(--bg-input);
    color: var(--text-1);
    outline: none;
    width: 100%;
    font-family: var(--font);
}
.fp-input:focus { border-color: var(--accent); }
.fp-buttons { display: flex; gap: 6px; justify-content: flex-end; }
.fp-ok {
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    border-radius: var(--r-md);
    background: var(--accent);
    color: #000;
    cursor: pointer;
    font-family: var(--font);
}
.fp-ok:hover { opacity: 0.85; }
.fp-cancel {
    padding: 6px 10px;
    font-size: 13px;
    border: none;
    border-radius: var(--r-md);
    background: var(--bg-hover);
    color: var(--text-2);
    cursor: pointer;
    font-family: var(--font);
}
.fp-cancel:hover { background: var(--bg-active); }

/* === MODAL === */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-lg);
    width: min(480px, 92vw);
    max-height: 85vh;
    overflow-y: auto;
    animation: modalIn var(--dur-slow) var(--ease-out);
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 15px; font-weight: 600; color: var(--text-1); flex: 1; margin-right: 12px; }
.modal-close {
    width: 32px; height: 32px;
    border: none;
    background: var(--bg-hover);
    border-radius: var(--r-md);
    cursor: pointer;
    font-size: 16px;
    color: var(--text-3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--dur-fast) var(--ease-out);
}
.modal-close:hover { background: var(--bg-active); color: var(--text-1); }
.modal-body { padding: 16px 20px; }
.modal-field { margin-bottom: 14px; }
.modal-field-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-3);
    margin-bottom: 4px;
}
.modal-field-value { font-size: 14px; color: var(--text-1); }
.modal-edit-text {
    width: 100%;
    font-size: 14px;
    color: var(--text-1);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 8px;
    font-family: var(--font);
    resize: vertical;
    min-height: 50px;
}
.modal-edit-text:focus { border-color: var(--accent); outline: none; }
.modal-btn--save { background: var(--accent-soft); color: var(--accent-text); }
.modal-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.modal-tag { padding: 3px 8px; border-radius: var(--r-sm); font-size: 12px; font-weight: 500; background: var(--accent-soft); color: var(--accent-text); }
.modal-tag--overdue { background: var(--danger-soft); color: var(--danger); }
.modal-snooze-row { display: flex; gap: 6px; flex-wrap: wrap; }
.modal-snooze-btn {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--bg);
    color: var(--text-2);
    font-size: 13px;
    cursor: pointer;
    font-family: var(--font);
    transition: all var(--dur-fast) var(--ease-out);
    min-height: 44px;
}
.modal-snooze-btn:hover { background: var(--bg-hover); border-color: var(--border-hover); color: var(--text-1); }
.modal-input {
    flex: 1;
    padding: 8px 10px;
    border-radius: var(--r-md);
    border: 1px solid var(--border-input);
    font-size: 14px;
    background: var(--bg-input);
    color: var(--text-1);
    font-family: var(--font);
}
.modal-input:focus { border-color: var(--accent); outline: none; }
.modal-actions {
    display: flex;
    gap: 8px;
    padding: 12px 20px 16px;
    border-top: 1px solid var(--border);
}
.modal-btn {
    padding: 8px 14px;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text-1);
    font-size: 13px;
    cursor: pointer;
    font-family: var(--font);
    transition: all var(--dur-fast) var(--ease-out);
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.modal-btn:hover { background: var(--bg-hover); }
.modal-btn--complete {
    background: var(--accent-soft);
    border-color: transparent;
    color: var(--accent-text);
    font-weight: 600;
}
.modal-btn--complete:hover { background: var(--accent); color: #000; }
.modal-btn--primary {
    background: var(--accent);
    border-color: transparent;
    color: #000;
    font-weight: 600;
}
.modal-btn--primary:hover { background: var(--accent-hover); }

/* === TOAST === */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    border-radius: var(--r-lg);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    color: var(--text-1);
    font-size: 13px;
    font-weight: 500;
    z-index: 20000;
    animation: toastIn var(--dur-normal) var(--ease-out);
}
@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(8px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text-1);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font);
    transition: all var(--dur-fast) var(--ease-out);
    min-height: 44px;
}
.btn:hover { background: var(--bg-hover); }
.btn-accent { background: var(--accent); border-color: transparent; color: #000; font-weight: 600; }
.btn-accent:hover { opacity: 0.85; }
.btn-secondary { background: var(--bg-hover); border-color: transparent; color: var(--text-2); }

/* Pill buttons (like action icons in ticket header) */
.btn-icon {
    width: 44px; height: 44px;
    padding: 0;
    border: none;
    background: transparent;
    border-radius: var(--r-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-3);
    font-size: 14px;
    transition: all var(--dur-fast) var(--ease-out);
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text-1); }

/* === SKELETON LOADING === */
.skeleton {
    background: var(--bg-hover);
    border-radius: var(--r-md);
    animation: shimmer 1.5s infinite;
}
.skeleton-ticket { height: 72px; margin-bottom: 4px; }
@keyframes shimmer {
    0% { opacity: 0.6; }
    50% { opacity: 0.3; }
    100% { opacity: 0.6; }
}

/* === FILTERS === */
.filters { margin-bottom: 12px; }
.filters select {
    padding: 8px 12px;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text-1);
    font-size: 13px;
    font-family: var(--font);
}

/* === AGENDA CONTAINER === */
.agenda-container { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.agenda-empty { color: var(--text-3); }

/* === CUSTOM SCROLLBAR === */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* === TASK LIST VIEW === */
.task-list { display: flex; flex-direction: column; gap: 2px; }
.task-list-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease-out);
}
.task-list-item:hover { background: var(--bg-hover); }
.task-list-item--done { opacity: 0.4; }
.task-list-item--overdue { border-left: 3px solid var(--danger); }
.task-list-check {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 28px;
}
.task-list-content { flex: 1; min-width: 0; }
.task-list-title { font-size: 13px; font-weight: 500; color: var(--text-1); }
.task-list-meta { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.task-list-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }

/* === CALENDAR VIEW === */
.cal-header { font-size: 14px; font-weight: 600; color: var(--text-1); padding: 8px 4px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-weekday { text-align: center; font-size: 11px; font-weight: 600; color: var(--text-3); padding: 4px 0; }
.cal-cell {
    position: relative;
    min-height: 72px;
    padding: 6px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: border-color 120ms ease;
}
.cal-cell:hover { border-color: var(--text-3); }
.cal-cell--empty { background: transparent; border-color: transparent; cursor: default; }
.cal-cell--empty:hover { border-color: transparent; }
.cal-cell--today { border-color: var(--accent); }
.cal-cell--today .cal-day-num { color: var(--accent); font-weight: 700; }
.cal-cell--has-tasks { background: color-mix(in srgb, var(--accent) 6%, var(--bg-elevated)); }
.cal-day-num { display: block; font-size: 13px; font-weight: 500; color: var(--text-1); }
.cal-dot-count {
    display: inline-block;
    margin-top: 4px;
    padding: 1px 6px;
    font-size: 10px;
    font-weight: 600;
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 15%, transparent);
    border-radius: 8px;
}
.cal-day-label { font-weight: 600; font-size: 14px; color: var(--text-1); padding: 8px 12px; border-bottom: 1px solid var(--border); }
.cal-day-detail { margin-top: 8px; }
.cal-task {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 12px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 80ms;
}
.cal-task:hover { background: var(--bg-hover); }
.cal-task--done { opacity: 0.4; }
.cal-task--done .cal-task-title { text-decoration: line-through; }
.cal-task-time { font-size: 12px; font-weight: 600; color: var(--dt-color); min-width: 36px; text-shadow: 0 0 6px var(--dt-glow); }
.cal-task-title { font-size: 13px; color: var(--text-1); flex: 1; min-width: 0; cursor: pointer; }

/* === RESPONSIVE: TABLET === */
@media (max-width: 1024px) {
    .board { grid-template-columns: 1fr 1fr; }
    .board-col--future { grid-column: 1 / -1; }
}

/* === RESPONSIVE: MOBILE === */
@media (max-width: 640px) {
    .layout {
        grid-template-columns: 1fr;
        grid-template-rows: var(--header-h) 1fr var(--bottom-nav-h);
    }
    .sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 50;
        height: var(--bottom-nav-h);
        flex-direction: row;
        justify-content: space-around;
        width: 100%;
        border-right: none;
        border-top: 1px solid var(--border);
        padding: 4px 0;
        gap: 0;
    }
    .sidebar-logo, .sidebar-divider, .sidebar-spacer { display: none; }
    .sidebar a { width: auto; padding: 4px 8px; font-size: 1.1rem; }
    .sidebar a .sidebar-label { display: none; }
    .header { grid-column: 1 / -1; }
    .chat-panel {
        position: fixed;
        left: 0; right: 0;
        bottom: var(--bottom-nav-h);
        top: var(--header-h);
        width: 100%;
        z-index: 49;
    }
    .header h1 { font-size: 14px; }
    .main { padding: 12px; padding-bottom: calc(12px + var(--bottom-nav-h) + 52px); }
    .board { grid-template-columns: 1fr; }
    .board-col { max-height: none; }
    .board-col--future { grid-column: auto; }
    .stats-row { flex-direction: column; }
    .toast { bottom: calc(var(--bottom-nav-h) + 12px); }
    .search-bar kbd { display: none; }
    .ticket-action { opacity: 0.7; }

    /* Prevent iOS auto-zoom on inputs */
    input, textarea, select { font-size: 16px !important; }

    /* Floating picker full-width on mobile */
    .floating-picker { min-width: auto; width: calc(100vw - 32px); left: 16px !important; }

    /* Ticket assignee truncation */
    .ticket-assignee { max-width: 90px; overflow: hidden; text-overflow: ellipsis; }

    /* Stats compact */
    .stat-card-inline .label { font-size: 11px; }
    .stat-card-inline .value { font-size: 14px; }
}

/* === STATS PAGE === */
.chart-container { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px; margin-bottom: 12px; }

/* === INBOX BADGE (sidebar) === */
.sidebar a { position: relative; }
.inbox-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    animation: badgePulse 0.3s var(--ease-out);
}
@keyframes badgePulse {
    0% { transform: scale(0); }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* === INBOX PAGE === */
.inbox-page { display: flex; flex-direction: column; gap: 12px; }
.inbox-header {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.inbox-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-1);
    margin: 0;
}
.inbox-stats {
    display: flex;
    gap: 12px;
    font-size: 13px;
    color: var(--text-3);
}
.inbox-stat--accent { color: var(--accent-text); }
.inbox-filters {
    margin-left: auto;
    display: flex;
    gap: 4px;
}
.inbox-filter-btn {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
    font-family: var(--font);
    transition: all var(--dur-fast) var(--ease-out);
}
.inbox-filter-btn:hover { background: var(--bg-hover); color: var(--text-1); }
.inbox-filter-btn.active {
    background: var(--accent-soft);
    border-color: transparent;
    color: var(--accent-text);
    font-weight: 600;
}

/* Email card */
.email-card {
    padding: 12px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease-out);
}
.email-card:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
}
.email-card + .email-card { margin-top: 4px; }
.email-card-row1 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    margin-bottom: 4px;
}
.email-direction {
    width: 22px;
    height: 22px;
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}
.email-direction--in {
    background: var(--accent-soft);
    color: var(--accent-text);
}
.email-direction--out {
    background: rgba(59, 130, 246, 0.12);
    color: #60a5fa;
}
.email-from {
    font-weight: 600;
    color: var(--text-1);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.email-project-tag {
    padding: 2px 8px;
    border-radius: var(--r-sm);
    background: var(--accent-soft);
    color: var(--accent-text);
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
}
.email-date {
    color: var(--text-3);
    font-size: 12px;
    flex-shrink: 0;
}
.email-subject {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-1);
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.email-summary {
    font-size: 13px;
    color: var(--text-2);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Inbox empty state */
.inbox-empty {
    text-align: center;
    padding: 48px 16px;
    color: var(--text-3);
}
.inbox-empty-icon {
    font-size: 40px;
    margin-bottom: 12px;
}
.inbox-empty-hint {
    font-size: 12px;
    margin-top: 6px;
    color: var(--text-3);
    opacity: 0.7;
}

/* Email modal (wider) */
.modal--wide {
    width: min(640px, 94vw);
}
.email-modal-meta {
    font-size: 12px;
    color: var(--text-3);
    margin-top: 4px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.email-modal-content {
    font-size: 14px;
    color: var(--text-1);
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 50vh;
    overflow-y: auto;
}
.email-modal-feedback {
    display: flex;
    gap: 6px;
}
.modal-btn--positive {
    background: var(--accent-soft);
    border-color: transparent;
    color: var(--accent-text);
}
.modal-btn--positive:hover { background: var(--accent); color: #000; }
.modal-btn--negative {
    background: var(--danger-soft);
    border-color: transparent;
    color: var(--danger);
}
.modal-btn--negative:hover { background: var(--danger); color: #fff; }
.modal-btn--accent {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text);
    font-weight: 600;
}
.modal-btn--accent:hover {
    background: var(--accent);
    color: var(--accent-text);
    opacity: 0.88;
}
.modal-btn--sent {
    opacity: 0.5;
    pointer-events: none;
}

/* Email graph context section */
.email-graph-section {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}
.email-graph-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.email-graph-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-text);
}
.email-graph-stats {
    font-size: 11px;
    color: var(--text-3);
}
.email-graph-content {
    font-size: 13px;
    color: var(--text-2);
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 30vh;
    overflow-y: auto;
    padding: 10px 12px;
    background: var(--bg);
    border-radius: var(--r-md);
    border: 1px solid var(--border);
}

/* ==================== RAG Panel ==================== */

/* Panel container — grid column 3, 50% width */
.rag-panel {
    position: fixed;
    top: 0; right: 0;
    width: 430px; max-width: 90vw;
    height: 100vh;
    border-left: 2px solid var(--accent);
    padding: 16px;
    overflow-y: auto;
    overflow-x: auto;
    background: var(--bg);
    display: none;
    flex-direction: column;
    gap: 8px;
    z-index: 100;
    box-shadow: -4px 0 24px rgba(0,0,0,0.3);
    transform: translateX(100%);
    transition: transform 0.25s ease;
}
.layout.rag-open .rag-panel { display: flex; transform: translateX(0); }

/* Panel header */
.rag-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.rag-panel-title { font-size: 14px; font-weight: 600; color: var(--text-1); }
.rag-panel-close {
    background: none; border: none; color: var(--text-3); font-size: 18px;
    cursor: pointer; padding: 4px 8px; border-radius: var(--r-sm);
    transition: all var(--dur-fast) var(--ease-out);
}
.rag-panel-close:hover { background: var(--bg-hover); color: var(--text-1); }
.rag-panel-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Project selector */
.rag-project-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.rag-project-label {
    font-size: 12px;
    color: var(--text-2);
    white-space: nowrap;
    flex-shrink: 0;
    font-weight: 500;
}
#ragProjectSelect {
    flex: 1;
    min-width: 0;
    background: var(--bg-input);
    color: var(--text-1);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 6px 8px;
    font-size: 12px;
    font-family: var(--font);
    cursor: pointer;
    transition: border-color var(--dur-fast) var(--ease-out);
}
#ragProjectSelect:focus-visible { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: -2px; }
#ragProjectSelect:hover { border-color: var(--border-hover); }

/* Header toggle button */
/* Small button (toolbar) */
.btn-sm {
    background: var(--bg-elevated);
    border: 1px solid var(--border-hover);
    border-radius: var(--r-md);
    padding: 0 14px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    color: var(--text-1);
    font-size: 13px;
    font-weight: 500;
    flex-shrink: 0;
    transition: all var(--dur-fast) var(--ease-out);
    text-decoration: none;
}
.btn-sm:hover { background: var(--bg-hover); color: #fff; border-color: #52525b; }

.rag-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 4px 10px;
    cursor: pointer;
    color: var(--text-2);
    font-size: 14px;
    margin-left: 12px;
    flex-shrink: 0;
    transition: all var(--dur-fast) var(--ease-out);
}
.rag-toggle:hover { background: var(--bg-hover); color: var(--text-1); border-color: var(--border-hover); }
.rag-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.layout.rag-open .rag-toggle { background: var(--accent-soft); color: var(--accent); border-color: rgba(0,217,126,0.3); }

/* Details/summary for doc sections */
.rag-details { border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; }
.rag-details-summary {
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-1);
    cursor: pointer;
    background: var(--bg-elevated);
    transition: background var(--dur-fast) var(--ease-out);
}
.rag-details-summary:hover { background: var(--bg-hover); }
.rag-details-summary { display: flex; align-items: center; justify-content: space-between; }

/* Normative toggle switch */
.rag-norm-toggle {
    position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; margin-left: 8px;
}
.rag-norm-toggle input { opacity: 0; width: 0; height: 0; }
.rag-norm-toggle-slider {
    position: absolute; inset: 0; background: var(--bg-hover); border: 1px solid var(--border);
    border-radius: 10px; cursor: pointer; transition: background 0.2s;
}
.rag-norm-toggle-slider::before {
    content: ''; position: absolute; width: 14px; height: 14px; left: 2px; top: 2px;
    background: var(--text-3); border-radius: 50%; transition: transform 0.2s, background 0.2s;
}
.rag-norm-toggle input:checked + .rag-norm-toggle-slider { background: var(--accent-soft); border-color: var(--accent); }
.rag-norm-toggle input:checked + .rag-norm-toggle-slider::before { transform: translateX(16px); background: var(--accent); }

/* Document list */
.rag-doc-list { max-height: 200px; overflow-y: auto; }
.rag-doc-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    font-size: 12px;
    color: var(--text-1);
    border-radius: var(--r-sm);
    transition: background var(--dur-fast) var(--ease-out);
}
.rag-doc-item:hover { background: var(--bg-hover); }
.rag-doc-icon { font-size: 11px; flex-shrink: 0; }
.rag-doc-name {
    flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    min-width: 0;
}
.rag-doc-chunks { color: var(--text-3); font-size: 11px; flex-shrink: 0; }
.rag-doc-del {
    background: none; border: none; color: var(--text-3); cursor: pointer;
    padding: 4px; border-radius: var(--r-sm); flex-shrink: 0;
    transition: all var(--dur-fast) var(--ease-out);
}
.rag-doc-del:hover { color: var(--danger); background: var(--danger-soft); }
.rag-doc-del:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Empty state */
.rag-empty-state {
    padding: 12px;
    text-align: center;
    color: var(--text-3);
    font-size: 12px;
}

/* Upload dropzone */
.rag-dropzone {
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 12px 14px;
    text-align: center;
    color: var(--text-3);
    font-size: 12px;
    cursor: pointer;
    background: var(--bg-hover);
    transition: all var(--dur-normal) var(--ease-out);
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.rag-dropzone:hover { border-color: var(--border-hover); }
.rag-dropzone.drag-over {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: inset 0 0 0 1px var(--accent);
}
.rag-upload-label {
    color: var(--accent);
    cursor: pointer;
    text-decoration: none;
    font-weight: 500;
}
.rag-upload-label:hover { text-decoration: underline; }
.rag-dropzone-loading { color: var(--text-2); }
.rag-dropzone-success { color: var(--accent); }
.rag-dropzone-error { color: var(--danger); }
.rag-dropzone-disabled {
    opacity: 0.4;
    pointer-events: none;
    cursor: default;
}

/* Document actions row (dropzone + sync button) */
.rag-doc-actions {
    display: flex;
    gap: 6px;
    align-items: stretch;
    padding: 8px 10px;
}
.rag-doc-actions .rag-dropzone { flex: 1; min-width: 0; }

/* YaDisk sync button */
.rag-sync-btn {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    color: var(--text-2);
    font-size: 11px;
    font-family: var(--font);
    padding: 8px 10px;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all var(--dur-fast) var(--ease-out);
}
.rag-sync-btn:hover { background: var(--bg-hover); color: var(--text-1); border-color: var(--border-hover); }
.rag-sync-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rag-sync-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Normative total footer */
.rag-norm-total {
    padding: 6px 10px;
    font-size: 11px;
    color: var(--text-3);
    border-top: 1px solid var(--border);
}

/* Query input */
.rag-query { display: flex; gap: 6px; }
.rag-query input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-1);
    padding: 8px 12px;
    border-radius: var(--r-md);
    font-size: 13px;
    font-family: var(--font);
    transition: border-color var(--dur-fast) var(--ease-out);
    min-width: 0;
}
.rag-query input::placeholder { color: var(--text-3); }
.rag-query input:focus { border-color: var(--accent); outline: none; }
.rag-query input:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.rag-query-btn {
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: var(--r-md);
    padding: 8px 14px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    flex-shrink: 0;
    transition: all var(--dur-fast) var(--ease-out);
}
.rag-query-btn:hover { filter: brightness(0.9); }
.rag-query-btn:active { transform: scale(0.97); }
.rag-query-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Progress */
.rag-progress-container { padding: 6px 0; }
.rag-progress { height: 2px; background: var(--border); border-radius: 1px; overflow: hidden; }
.rag-progress-bar {
    height: 100%;
    background: var(--accent);
    transition: width var(--dur-slow) var(--ease-out);
    animation: rag-shimmer 1.5s ease-in-out infinite;
}
@keyframes rag-shimmer { 50% { opacity: 0.6; } }
.rag-progress-label { font-size: 11px; color: var(--text-3); margin-top: 4px; }

/* Answer sections (accordion) */
.rag-section {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
}
.rag-section--synthesis { border-color: rgba(0,217,126,0.3); }
.rag-section--normative { border-color: rgba(245,158,11,0.3); }
.rag-section-toggle {
    width: 100%;
    background: none;
    border: none;
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-1);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
    transition: background var(--dur-fast) var(--ease-out);
}
.rag-section-toggle:hover { background: var(--bg-hover); }
.rag-section-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.rag-section-arrow { font-size: 10px; color: var(--text-3); transition: transform var(--dur-fast); }
.rag-section-body { padding: 0 14px 14px; }
.rag-section-body[hidden] { display: none; }
.rag-answer-text {
    font-size: 13px;
    line-height: 1.65;
    color: var(--text-1);
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    min-width: 0;
}
.rag-answer-text ul { margin: 6px 0; padding-left: 18px; }
.rag-answer-text li { margin-bottom: 4px; }
.rag-answer-text strong { color: var(--text-1); font-weight: 600; }

/* Sources */
.rag-sources-details { margin-top: 10px; }
.rag-sources-summary {
    font-size: 12px; color: var(--accent); cursor: pointer; padding: 6px 0;
    font-weight: 500;
}
.rag-sources-summary:hover { text-decoration: underline; }
.rag-sources-list { padding-top: 4px; }
.rag-source-item {
    display: flex;
    align-items: baseline;
    gap: 6px;
    padding: 4px 0;
    font-size: 11px;
    border-bottom: 1px solid var(--border);
}
.rag-source-item:last-child { border-bottom: none; }
.rag-source-num {
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: 50%;
    width: 1.4em;
    height: 1.4em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
    flex-shrink: 0;
}
.rag-source-item--expandable { cursor: pointer; }
.rag-source-item--expandable:hover { background: var(--bg-hover); }
.rag-source-item--open { background: var(--bg-active); }
.rag-source-name { font-weight: 500; color: var(--text-1); min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rag-source-loc {
    color: var(--text-3); white-space: nowrap; flex-shrink: 0;
    font-size: 10px;
}
.rag-source-evidence {
    font-size: 11px;
    color: var(--text-2);
    padding: 6px 8px 8px 26px;
    line-height: 1.5;
    background: var(--bg-active);
    border-bottom: 1px solid var(--border);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 200px;
    overflow-y: auto;
}

/* Answer reference markers */
.rag-ref {
    color: var(--accent);
    font-weight: 600;
    font-size: 0.85em;
    cursor: default;
}
.rag-expand-ref {
    color: var(--accent);
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
}
.rag-expand-ref:hover { color: var(--accent-text); }

/* Contradiction banner */
.rag-contradiction {
    background: var(--warning-soft);
    border: 1px solid rgba(245,158,11,0.4);
    border-radius: var(--r-lg);
    padding: 10px 12px;
    font-size: 12px;
    color: var(--text-1);
    font-weight: 500;
    line-height: 1.5;
}

/* Error */
.rag-error {
    padding: 12px;
    background: var(--danger-soft);
    border: 1px solid rgba(244,63,94,0.3);
    border-radius: var(--r-lg);
    font-size: 13px;
    color: var(--text-1);
    line-height: 1.5;
}

/* Timing footer */
.rag-timing {
    font-size: 12px;
    color: var(--text-3);
    padding-top: 8px;
    border-top: 1px solid var(--border);
    font-variant-numeric: tabular-nums;
}

/* Mobile: fullscreen overlay */
@media (max-width: 640px) {
    .rag-panel {
        width: 100%;
        max-width: 100%;
        top: calc(var(--header-h) + env(safe-area-inset-top, 0px));
        bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
        height: auto;
    }
    .layout.rag-open { grid-template-columns: 1fr; }
    .rag-query input { font-size: 16px !important; padding: 12px; }
    .rag-query-btn { width: 44px; height: 44px; }
    .rag-dropzone { font-size: 12px; padding: 10px; }
    .rag-sync-btn { padding: 8px 12px; font-size: 12px; }
}

/* === APK-ONLY OVERRIDES (GiP-Android WebView) === */
/* Applied only when JS detects GiP-Android user agent and adds .gip-apk to <html> */

/* APK: compact board — stacked collapsible columns */
.gip-apk .board { gap: 4px; }
.gip-apk .board-col {
    border-radius: var(--r-md);
    max-height: none;
}
.gip-apk .board-col-header {
    padding: 6px 10px;
    font-size: 11px;
    cursor: pointer;
    user-select: none;
}
.gip-apk .board-col-header::after {
    content: '▾';
    margin-left: auto;
    font-size: 10px;
    transition: transform 0.2s;
}
.gip-apk .board-col.collapsed .board-col-header::after {
    transform: rotate(-90deg);
}
.gip-apk .board-col.collapsed .board-col-body {
    display: none;
}
.gip-apk .board-col-body { padding: 2px; gap: 1px; }
.gip-apk .board-col-empty { padding: 10px 8px; font-size: 11px; }

/* APK: ultra-compact tickets */
.gip-apk .ticket {
    border: none;
    border-radius: 0;
    border-bottom: 1px solid var(--border);
}
.gip-apk .ticket:last-child { border-bottom: none; }
.gip-apk .ticket--today,
.gip-apk .ticket--overdue { border-left: 2px solid; }
.gip-apk .ticket--today { border-left-color: var(--accent); }
.gip-apk .ticket--overdue { border-left-color: var(--danger); }

.gip-apk .ticket-check {
    width: 22px; height: 22px;
    margin: -2px 0 0 -2px;
}
.gip-apk .check-circle {
    width: 14px; height: 14px;
    border-width: 1.5px;
    font-size: 8px;
}
.gip-apk .ticket-inline-time { font-size: 10px; }
.gip-apk .ticket-inline-project { font-size: 10px; }
.gip-apk .ticket-sep { margin: 0 2px; font-size: 10px; }
.gip-apk .ticket-text { font-size: 11px; }

.gip-apk .ticket-assignee { font-size: 9px; }
.gip-apk .ticket-action {
    width: 22px; height: 22px;
    opacity: 0.6;
}
.gip-apk .ticket-action svg { width: 12px; height: 12px; }

/* APK: search bar compact */
.gip-apk .search-bar { padding: 4px 8px; }
.gip-apk .search-bar input { font-size: 12px !important; }
.gip-apk .search-bar kbd { display: none; }

/* === CHAT PAGE === */

.chat-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 52px);
    max-width: 800px;
    margin: 0 auto;
    padding: 0 16px;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.chat-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-1);
    margin: 0;
}

.chat-new-btn {
    background: var(--bg-elevated);
    color: var(--text-2);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease);
}
.chat-new-btn:hover {
    background: var(--bg-hover);
    color: var(--text-1);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
    scrollbar-gutter: stable;
}

.chat-timing {
    font-size: 11px;
    color: var(--text-3);
    margin-top: 6px;
    text-align: right;
}

/* Timestamp в правом-нижнем углу каждого сообщения */
.chat-bubble { position: relative; padding-bottom: 18px !important; }
.chat-bubble .chat-time {
    position: absolute;
    right: 8px;
    bottom: 3px;
    font-size: 10px;
    color: var(--text-3);
    opacity: 0.75;
    pointer-events: none;
    user-select: none;
    font-variant-numeric: tabular-nums;
}
.chat-bubble--user .chat-time { color: var(--text-2); }

.chat-thinking {
    color: var(--text-3);
    font-style: italic;
}

.chat-dots span {
    animation: chatDotPulse 1.4s infinite;
    font-weight: bold;
    font-size: 18px;
}
.chat-dots span:nth-child(2) { animation-delay: 0.2s; }
.chat-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatDotPulse {
    0%, 80%, 100% { opacity: 0.2; }
    40% { opacity: 1; }
}

.chat-input-area {
    display: flex;
    gap: 8px;
    padding: 12px 0 16px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    background: var(--bg-elevated);
    color: var(--text-1);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    min-height: 40px;
    max-height: 200px;
    outline: none;
    transition: border-color var(--dur-fast) var(--ease);
}
.chat-input:focus {
    border-color: var(--accent);
}
.chat-input::placeholder {
    color: var(--text-3);
}

.chat-send-btn {
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: var(--r-md);
    width: 40px;
    height: 40px;
    font-size: 18px;
    cursor: pointer;
    flex-shrink: 0;
    transition: opacity var(--dur-fast) var(--ease);
}
.chat-send-btn:hover { opacity: 0.85; }
.chat-send-btn:disabled { opacity: 0.4; cursor: default; }

.chat-voice-btn {
    background: var(--bg-elevated);
    color: var(--text-2);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    width: 40px;
    height: 40px;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--dur-fast) var(--ease);
}
.chat-voice-btn:hover { border-color: var(--accent); color: var(--text-1); }
.chat-voice-btn:disabled { opacity: 0.4; cursor: default; }
@keyframes chat-voice-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(229, 62, 62, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(229, 62, 62, 0); }
}

.chat-file-btn {
    background: var(--bg);
    color: var(--accent);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    width: 34px;
    height: 34px;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--dur-fast) var(--ease);
}
.chat-file-btn:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

.chat-file-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    margin: 0 0 4px;
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    border-radius: var(--r-sm);
    font-size: 11px;
    color: var(--text-1);
    width: 100%;
    box-sizing: border-box;
}
.chat-file-pill-close {
    background: none;
    border: none;
    color: var(--text-3);
    cursor: pointer;
    font-size: 14px;
    margin-left: auto;
}

.chat-drop-active {
    outline: 2px dashed var(--accent);
    outline-offset: -4px;
}

/* Mobile */
@media (max-width: 768px) {
    .chat-page { padding: 0 8px; }
    .chat-bubble { max-width: 92%; }
    .chat-input { font-size: 16px !important; }
    .chat-send-btn { width: 44px; height: 44px; }
    .chat-voice-btn { width: 44px; height: 44px; }
    .chat-file-btn { width: 44px; height: 44px; }
}


/* ==================== Notes ==================== */

.notes-page { padding: 0 4px; }

.notes-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.notes-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-1);
    margin: 0;
    white-space: nowrap;
}
.notes-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.notes-btn {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--bg);
    color: var(--text-2);
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--dur-fast) var(--ease);
}
.notes-btn:hover { border-color: var(--accent); color: var(--text-1); }
.notes-btn--accent {
    background: var(--accent);
    color: var(--accent-text, #fff);
    border-color: var(--accent);
    font-weight: 600;
}
.notes-btn--accent:hover { opacity: 0.9; }

.notes-btn--mic {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 10px;
}
.notes-btn--mic svg { flex-shrink: 0; }
.notes-btn--recording {
    background: #e53e3e;
    color: #fff;
    border-color: #e53e3e;
    animation: chat-voice-pulse 1.5s infinite;
}

.notes-search {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--bg);
    color: var(--text-1);
    font-size: 13px;
    width: 180px;
    max-width: 100%;
    transition: border-color var(--dur-fast) var(--ease);
}
.notes-search:focus {
    outline: none;
    border-color: var(--accent);
}

/* Filters */
.notes-filters {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}
.notes-filter {
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--bg);
    color: var(--text-3);
    font-size: 12px;
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease);
}
.notes-filter:hover { color: var(--text-1); border-color: var(--border-hover, var(--border)); }
.notes-filter.active {
    background: var(--accent);
    color: var(--accent-text, #fff);
    border-color: var(--accent);
}
.notes-project-select {
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--bg);
    color: var(--text-2);
    font-size: 12px;
    cursor: pointer;
}

/* Grid */
.notes-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
}
.notes-empty {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-3);
    padding: 48px 16px;
    font-size: 14px;
}

/* Card — same look as task tickets (.ticket) */
.note-card {
    position: relative;
    background: #63636e;
    border: 1px solid #111113;
    border-radius: var(--r-md);
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
    /* Fixed height + flex column so footer (project + date) sticks to bottom and aligns across all cards */
    display: flex;
    flex-direction: column;
    min-height: 180px;
}
.note-card:hover { background: #6e6e7a; border-color: #111113; }
.note-card--pinned { border-left: 3px solid var(--accent); }
.note-card--saving {
    opacity: 0.6;
    pointer-events: none;
    animation: note-saving-pulse 1.2s infinite;
}
@keyframes note-saving-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.7; }
}

/* Row 1: icon · topic · spacer · actions (like ticket-row1) */
.note-card-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px 4px;
}
.note-type-icon { font-size: 13px; flex-shrink: 0; }
.note-pin-icon { font-size: 12px; flex-shrink: 0; }
.note-topic {
    font-size: 11px;
    font-weight: 600;
    border-radius: 3px;
    padding: 1px 6px;
    color: #fff;
    white-space: nowrap;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.note-actions {
    margin-left: auto;
    display: flex;
    gap: 4px;
    align-items: center;
}
.note-actions button {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px; height: 26px;
    padding: 0;
    background: transparent;
    border: 1px solid #3f3f46;
    cursor: pointer;
    color: var(--text-2);
    border-radius: var(--r-sm);
    font-size: 12px;
    transition: all var(--dur-fast) var(--ease-out);
}
.note-actions button:hover {
    background: transparent;
    color: var(--text-1);
    border-color: #60a5fa;
}
.note-actions button[title*="Удалить"]:hover {
    color: var(--danger);
    border-color: var(--danger);
}

/* Title */
.note-title {
    padding: 0 10px 2px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-1);
    line-height: 1.35;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Preview body text — fills remaining space so footer sticks to bottom.
   Earlier version used `-webkit-line-clamp: 4` inside a flex-grow box which
   rendered clamped lines bleeding through the next line (visible as two
   overlapping strings). Switched to a fixed max-height based on line-height
   so truncation is pixel-precise. On hover the card expands max-height to
   reveal the full note and allows wheel scroll without ever clipping into
   the footer (footer stays pinned by margin-top:auto on .note-footer). */
.note-preview {
    --np-line-h: 1.4;
    --np-lines: 4;
    flex: 0 1 auto;
    padding: 0 10px 6px;
    font-size: 13px;
    color: #ffffff;
    line-height: var(--np-line-h);
    max-height: calc(var(--np-line-h) * var(--np-lines) * 1em);
    overflow: hidden;
    white-space: pre-wrap;
    word-wrap: break-word;
    transition: max-height var(--dur-fast) var(--ease-out);
}
.note-card:hover .note-preview {
    /* Keep card height fixed (grid neighbors don't shift); just allow wheel
       scroll within the current 4-line window. Full view is one click away
       via the modal. overscroll-behavior:contain prevents the page from
       scrolling past the note boundaries. */
    overflow-y: auto;
    overscroll-behavior: contain;
}
/* Thinner, subtler scrollbar inside the preview on hover */
.note-preview::-webkit-scrollbar { width: 6px; }
.note-preview::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18);
    border-radius: 3px;
}
.note-preview::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.3); }
.note-preview::-webkit-scrollbar-track { background: transparent; }

/* Wiki-link inline span — like Obsidian [[link]] */
.note-wiki-link {
    color: #93c5fd;
    background: rgba(96, 165, 250, 0.1);
    padding: 0 3px;
    border-radius: 3px;
    cursor: pointer;
    font-weight: 600;
    border-bottom: 1px dashed rgba(96, 165, 250, 0.5);
    transition: background var(--dur-fast);
}
.note-wiki-link:hover {
    background: rgba(96, 165, 250, 0.25);
    color: #fff;
}

/* Backlinks panel inside modal */
.note-backlinks {
    border-top: 1px solid var(--border);
    padding-top: 10px;
}
.note-backlinks-header {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 6px;
}
.note-backlinks-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 200px;
    overflow-y: auto;
}
.note-backlink-item {
    padding: 6px 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-left: 3px solid #60a5fa;
    border-radius: 4px;
    cursor: pointer;
    transition: background var(--dur-fast);
}
.note-backlink-item:hover {
    background: rgba(96, 165, 250, 0.1);
}
.note-backlink-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-1);
}
.note-backlink-date {
    font-size: 11px;
    color: var(--text-3);
    margin-left: 8px;
    font-variant-numeric: tabular-nums;
}
.note-backlink-excerpt {
    font-size: 11px;
    color: var(--text-3);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Tag chips row — between preview and footer */
.note-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px 10px 0;
    flex-shrink: 0;
}
.note-tag-chip {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 10px;
    background: rgba(96, 165, 250, 0.15);
    border: 1px solid rgba(96, 165, 250, 0.35);
    color: #93c5fd;
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--dur-fast), border-color var(--dur-fast);
}
.note-tag-chip:hover {
    background: rgba(96, 165, 250, 0.3);
    border-color: #60a5fa;
    color: #fff;
}

/* Footer: date+time (left) + project badge (bottom-right) — always at card bottom */
.note-footer {
    margin-top: auto;
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px 8px;
    font-size: 14px;
    font-weight: 700;
    color: var(--dt-color);
    font-variant-numeric: tabular-nums;
}
.note-project-badge {
    font-size: 12px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 3px;
    background: #60a5fa;
    color: #fff;
    white-space: nowrap;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Type selector in modal */
.note-type-selector {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}
.note-type-selector button {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--bg);
    color: var(--text-2);
    cursor: pointer;
    font-size: 13px;
    transition: all var(--dur-fast) var(--ease);
}
.note-type-selector button:hover { border-color: var(--text-3); }
.note-type-selector button.active {
    border-color: var(--accent);
    color: #000;
    background: var(--accent);
    font-weight: 600;
}

/* Notes responsive */
@media (max-width: 768px) {
    .notes-grid { grid-template-columns: repeat(3, 1fr); }
    .notes-search { width: 120px; }
    .notes-header { gap: 8px; }
}
@media (max-width: 480px) {
    .notes-grid { grid-template-columns: 1fr; }
    .notes-search { width: 100%; }
    .notes-header-actions { flex-wrap: wrap; }
}


/* ==================== Skills page ==================== */
.skills-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.skill-card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 12px; }
.skill-card--disabled { opacity: 0.5; }
.skill-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.skill-card-name { font-weight: 600; font-size: 13px; color: var(--text-1); }
.skill-card-actions { display: flex; gap: 4px; }
.skill-card-actions button { background: none; border: none; cursor: pointer; font-size: 14px; opacity: 0.6; }
.skill-card-actions button:hover { opacity: 1; }
.skill-card-desc { font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.skill-card-triggers { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.skill-tag { font-size: 10px; padding: 1px 6px; background: var(--accent-soft); color: var(--accent-text); border-radius: 3px; }
.skill-type-badge { font-size: 10px; padding: 1px 6px; background: var(--bg-hover); color: var(--text-3); border-radius: 3px; }
.skill-card { cursor: pointer; transition: border-color var(--dur-fast); }
.skill-card:hover { border-color: var(--border-hover); }
.skill-card--open { border-color: var(--accent); }
.skill-card-details { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.skill-detail-section { margin-bottom: 8px; }
.skill-detail-label { font-size: 11px; font-weight: 600; color: var(--text-2); margin-bottom: 2px; }
.skill-detail-text { font-size: 12px; color: var(--text-1); line-height: 1.45; }

/* ==================== RAG mode (fusion) ==================== */

.chat-rag-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 10px 0;
    font-size: 12px;
    color: var(--text-2);
}
.chat-rag-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}
.chat-rag-toggle input[type="checkbox"] {
    cursor: pointer;
    accent-color: var(--accent);
}
.chat-rag-toggle-label { color: var(--text-2); }
.chat-rag-toggle input:checked + .chat-rag-toggle-label { color: var(--text-1); }
.chat-rag-project-select {
    font-size: 12px;
    padding: 2px 8px;
    height: 26px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--bg);
    color: var(--text-1);
    cursor: pointer;
}
.chat-rag-hint {
    font-size: 11px;
    color: var(--text-3);
}
.chat-rag-hint--warn { color: #d97706; }

/* RAG answer block — verbatim passthrough from AEC RAG */
.rag-block {
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--r-md);
    background: var(--bg);
    padding: 10px 12px;
    margin: 0 0 8px;
}
.rag-block-header {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 6px;
}
.rag-block-body {
    font-size: 13px;
    color: var(--text-1);
    line-height: 1.5;
    white-space: pre-wrap;   /* preserve AEC RAG's line breaks verbatim */
    word-wrap: break-word;
}
.rag-block-sources {
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-3);
}
.rag-block-sources ul { margin: 3px 0 0; padding-left: 18px; }
.rag-block-sources li { margin: 1px 0; }
.rag-block-divider {
    height: 1px;
    background: var(--border);
    margin: 10px 0 8px;
    opacity: 0.6;
}
.rag-block--empty {
    border-left-color: var(--text-3);
    opacity: 0.85;
}
.rag-block--empty .rag-block-body {
    color: var(--text-3);
    font-style: italic;
}

/* ==================== Timeline ==================== */

.timeline-page { padding: 0 4px; }

/* ==================== Phase 2: UI Polish ==================== */

/* Smooth theme switch — блокировка transitions на .no-transitions
 * (JS добавляет на <html> на момент переключения темы). */
html, body, .ticket, .btn, .notif-card, input, select, textarea {
    transition:
        background-color var(--dur-slow) var(--ease-out),
        color            var(--dur-slow) var(--ease-out),
        border-color     var(--dur-slow) var(--ease-out);
}

html.no-transitions *, html.no-transitions *::before, html.no-transitions *::after {
    transition: none !important;
}

/* Reduced motion — respect user preference */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus-visible — клавиатурный focus должен быть всегда виден.
 * Не ломаем mouse-focus (убираем outline только на :focus:not(:focus-visible)). */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--r-sm);
}
:focus:not(:focus-visible) { outline: none; }

/* Skeleton loader — показываем во время загрузки данных.
 * Используется как .skeleton (полоски), .skeleton-line (строка), etc. */
@keyframes skeleton-shimmer {
    0%   { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-hover) 0%,
        var(--bg-elevated) 50%,
        var(--bg-hover) 100%
    );
    background-size: 800px 100%;
    animation: skeleton-shimmer 1.4s linear infinite;
    border-radius: var(--r-sm);
    color: transparent;
    user-select: none;
}
.skeleton-line {
    height: 14px;
    margin: 6px 0;
}
.skeleton-line--wide  { width: 100%; }
.skeleton-line--half  { width: 50%; }
.skeleton-line--short { width: 30%; }
.skeleton-card {
    padding: 16px;
    background: var(--bg-elevated);
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

/* Theme toggle button — стандартный icon-button для хедера */
.theme-toggle {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-2);
    width: 32px; height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background var(--dur-normal) var(--ease-out),
                color      var(--dur-normal) var(--ease-out),
                transform  var(--dur-fast)   var(--ease-out);
}
.theme-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-1);
    transform: rotate(20deg);
}
.theme-toggle:active {
    transform: scale(0.95);
}

/* ==================== Phase 2 extended: list transitions + empty state ==================== */

/* List item enter-animation. Применяется когда новая карточка появляется
 * в доске / в списке уведомлений. Используем CSS класс .entering — JS
 * добавляет его на momentary, потом убирает через requestAnimationFrame. */
@keyframes list-item-enter {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}
.ticket, .chat-notif, .timeline-event {
    animation: list-item-enter 180ms var(--ease-out);
}
/* Для больших list'ов отключаем если юзер хочет меньше движения */
@media (prefers-reduced-motion: reduce) {
    .ticket, .chat-notif, .timeline-event {
        animation: none;
    }
}

/* Hover-lift для кликабельных карточек — даёт тактильный feedback */
.ticket, .notif-card, .note-card {
    transition:
        background-color var(--dur-slow) var(--ease-out),
        transform        var(--dur-fast) var(--ease-out),
        box-shadow       var(--dur-fast) var(--ease-out),
        border-color     var(--dur-slow) var(--ease-out);
}
.ticket:hover:not(.ticket--done) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-hover);
}

/* Empty state — для пустых списков (Kanban, заметки, timeline, ...) */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    color: var(--text-2);
    min-height: 200px;
}
.empty-state-icon {
    font-size: 48px;
    line-height: 1;
    margin-bottom: 16px;
    opacity: 0.6;
    user-select: none;
}
.empty-state-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-1);
    margin-bottom: 8px;
}
.empty-state-hint {
    font-size: 13px;
    color: var(--text-3);
    max-width: 320px;
    line-height: 1.5;
}
.empty-state-cta {
    margin-top: 16px;
    padding: 8px 16px;
    background: var(--accent);
    color: var(--accent-text);
    border: none;
    border-radius: var(--r-md);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--dur-normal) var(--ease-out);
}
.empty-state-cta:hover {
    background: var(--accent-hover);
}

/* Button pulse при create-action — feedback что действие сработало */
@keyframes pulse-ok {
    0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); }
    100% { box-shadow: 0 0 0 12px rgba(34, 197, 94, 0); }
}
.pulse-ok {
    animation: pulse-ok 600ms ease-out;
}

/* Toast-уведомления — для feedback после действий (задача создана, и т.д.) */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10000;
    pointer-events: none;
}
.toast {
    background: var(--bg-elevated);
    color: var(--text-1);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--r-md);
    padding: 12px 16px;
    box-shadow: var(--shadow-md);
    font-size: 13px;
    min-width: 220px;
    max-width: 380px;
    opacity: 0;
    transform: translateX(20px);
    transition:
        opacity var(--dur-slow) var(--ease-out),
        transform var(--dur-slow) var(--ease-out);
    pointer-events: auto;
}
.toast.show {
    opacity: 1;
    transform: translateX(0);
}
.toast--success { border-left-color: #22c55e; }
.toast--error   { border-left-color: var(--danger); }
.toast--warning { border-left-color: var(--warning); }

/* ==================== Illustrated empty-state ==================== */
.board-col-empty--illustrated {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 20px;
    text-align: center;
    color: var(--text-2);
    min-height: 180px;
    opacity: 0.85;
}
.board-col-empty-illo {
    width: 64px;
    height: 64px;
    color: var(--text-3);
    opacity: 0.6;
    margin-bottom: 12px;
}
.board-col-empty-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-1);
    margin-bottom: 4px;
}
.board-col-empty-hint {
    font-size: 12px;
    color: var(--text-3);
    max-width: 220px;
    line-height: 1.4;
}

/* Notes/Inbox/General empty state — единый стиль */
.notes-empty, .inbox-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    color: var(--text-2);
    min-height: 240px;
}
.notes-empty-illo, .inbox-empty-illo {
    width: 88px;
    height: 88px;
    color: var(--text-3);
    opacity: 0.5;
    margin-bottom: 20px;
}
.notes-empty-title, .inbox-empty-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-1);
    margin-bottom: 8px;
}
.notes-empty-hint, .inbox-empty-hint {
    font-size: 13px;
    color: var(--text-3);
    max-width: 320px;
    line-height: 1.5;
}

/* Kanban skeleton pre-load — 3 колонки в grid */
.board-skeleton-wrap {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 8px 0;
}
.skeleton-col {
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.skeleton-col-header {
    height: 22px;
    width: 60%;
}
@media (max-width: 700px) {
    .board-skeleton-wrap { grid-template-columns: 1fr; }
}

/* ==================== Motion: mount/unmount ==================== */
/* Без JS-библиотек — чистый CSS. Ticket exit-animation запускается
 * когда JS добавляет класс .leaving ПЕРЕД удалением из DOM. */
@keyframes ticket-leave {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
        max-height: 200px;
    }
    to {
        opacity: 0;
        transform: translateY(-8px) scale(0.95);
        max-height: 0;
        margin-bottom: 0;
        padding-top: 0;
        padding-bottom: 0;
        border-width: 0;
    }
}
.ticket.leaving, .chat-notif.leaving {
    animation: ticket-leave 260ms var(--ease-out) forwards;
    overflow: hidden;
}

/* Стейблер для view-tab переключений */
@keyframes view-fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.agenda-container > * {
    animation: view-fade-in 220ms var(--ease-out);
}
@media (prefers-reduced-motion: reduce) {
    .agenda-container > *,
    .ticket.leaving, .chat-notif.leaving {
        animation: none;
    }
}

/* Enhanced button interaction */
button, .btn {
    transition:
        background-color var(--dur-normal) var(--ease-out),
        border-color     var(--dur-normal) var(--ease-out),
        transform        var(--dur-fast)   var(--ease-out),
        box-shadow       var(--dur-fast)   var(--ease-out);
}
button:active:not(:disabled), .btn:active:not(:disabled) {
    transform: scale(0.97);
}

/* Tabs — smoothly slide indicator */
.view-tab {
    position: relative;
    transition: color var(--dur-normal) var(--ease-out);
}
.view-tab::after {
    content: "";
    position: absolute;
    bottom: -2px;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--accent);
    transform: translateX(-50%);
    transition: width var(--dur-slow) var(--ease-out);
}
.view-tab--active::after { width: 60%; }

/* ==================== Onboarding Tour ==================== */
.tour-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 9998;
    backdrop-filter: blur(2px);
    animation: view-fade-in 180ms var(--ease-out);
}
.tour-highlight {
    position: absolute;
    z-index: 9999;
    border: 2px solid var(--accent);
    border-radius: var(--r-md);
    box-shadow:
        0 0 0 9999px rgba(0, 0, 0, 0.02),
        0 0 20px rgba(96, 165, 250, 0.5);
    pointer-events: none;
    animation: view-fade-in 220ms var(--ease-out);
}
.tour-tooltip {
    position: absolute;
    z-index: 10000;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 20px;
    max-width: 320px;
    min-width: 280px;
    box-shadow: var(--shadow-lg);
    animation: view-fade-in 260ms var(--ease-out);
}
.tour-counter {
    font-size: 11px;
    color: var(--text-3);
    font-weight: 600;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
    text-transform: uppercase;
}
.tour-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-1);
    margin-bottom: 8px;
}
.tour-body {
    font-size: 13px;
    color: var(--text-2);
    line-height: 1.5;
    margin-bottom: 16px;
}
.tour-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}
.tour-skip, .tour-next {
    padding: 8px 16px;
    border-radius: var(--r-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--dur-normal) var(--ease-out);
    border: 1px solid var(--border);
}
.tour-skip {
    background: transparent;
    color: var(--text-2);
}
.tour-skip:hover {
    background: var(--bg-hover);
    color: var(--text-1);
}
.tour-next {
    background: var(--accent);
    color: var(--accent-text);
    border-color: var(--accent);
}
.tour-next:hover {
    background: var(--accent-hover);
}

/* ==================== Command Palette (Cmd+K) ==================== */
.cmdk-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 10500;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 15vh;
    animation: cmdk-fade 120ms var(--ease-out);
}
@keyframes cmdk-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.cmdk-panel {
    width: 92%;
    max-width: 620px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: cmdk-pop 180ms var(--ease-out);
}
@keyframes cmdk-pop {
    from { transform: translateY(-8px) scale(0.98); opacity: 0; }
    to   { transform: translateY(0)     scale(1);    opacity: 1; }
}
.cmdk-input {
    width: 100%;
    padding: 18px 20px;
    font-size: 15px;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border);
    color: var(--text-1);
    outline: none;
    font-family: inherit;
}
.cmdk-input::placeholder { color: var(--text-3); }
.cmdk-list {
    max-height: 360px;
    overflow-y: auto;
    padding: 6px 0;
}
.cmdk-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 16px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-1);
    transition: background var(--dur-fast) var(--ease-out);
}
.cmdk-item--active, .cmdk-item:hover {
    background: var(--accent-soft);
}
.cmdk-item-icon {
    font-size: 15px;
    width: 22px;
    text-align: center;
}
.cmdk-item-title { flex: 1; }
.cmdk-item-keys {
    display: flex;
    gap: 3px;
    font-size: 11px;
    color: var(--text-3);
}
.cmdk-item-keys kbd,
.cmdk-footer kbd,
.cmdk-help-table kbd {
    display: inline-block;
    padding: 2px 6px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-2);
    line-height: 1.2;
}
.cmdk-footer {
    display: flex;
    gap: 14px;
    padding: 10px 16px;
    background: var(--bg-hover);
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-3);
}

/* Help overlay */
.cmdk-panel--help {
    padding: 24px;
    max-width: 500px;
}
.cmdk-help-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-1);
}
.cmdk-help-table {
    width: 100%;
    border-collapse: collapse;
}
.cmdk-help-table td {
    padding: 7px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-2);
}
.cmdk-help-table td:last-child {
    text-align: right;
    white-space: nowrap;
}
.cmdk-help-table .cmdk-kbd-cell { min-width: 100px; }
.cmdk-close-btn {
    padding: 8px 18px;
    background: var(--accent);
    color: var(--accent-text);
    border: none;
    border-radius: var(--r-sm);
    font-weight: 500;
    cursor: pointer;
}
.cmdk-close-btn:hover { background: var(--accent-hover); }

/* Inline button spinner — показывается .btn.is-loading */
.btn.is-loading, button.is-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}
.btn.is-loading::after, button.is-loading::after {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    width: 16px; height: 16px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    color: var(--accent);
    animation: btn-spin 600ms linear infinite;
}
@keyframes btn-spin {
    to { transform: rotate(360deg); }
}

/* Form validation inline */
.form-error {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--danger);
    min-height: 16px;
}
.form-group input.is-invalid,
.form-group textarea.is-invalid,
.form-group select.is-invalid {
    border-color: var(--danger);
    background: var(--danger-soft);
}

/* Landmark-скрытые визуально, но видимые для screen readers */
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Skeleton для note-card — имитирует размер реальной карточки */
.skeleton-note-card {
    height: 120px;
    border-radius: var(--r-md);
    margin-bottom: 12px;
}
/* Skeleton для inbox */
.skeleton-inbox-item {
    height: 72px;
    border-radius: var(--r-md);
    margin-bottom: 10px;
}
/* Skeleton для chat notification */
.skeleton-chat-msg {
    height: 100px;
    border-radius: var(--r-md);
    margin-bottom: 12px;
    max-width: 480px;
}

/* ================================================================
   2026 polish — ambient gradient mesh, scroll progress, spring hover
   ================================================================ */

/* Animated gradient mesh background — subtle, respects motion preferences.
   Only on dashboard (body.dashboard-page). Uses @property + modern
   registerProperty-enabled animation for smooth gradient shift. */
@property --mesh-1 {
    syntax: '<percentage>';
    inherits: false;
    initial-value: 0%;
}
@property --mesh-2 {
    syntax: '<percentage>';
    inherits: false;
    initial-value: 100%;
}

body.dashboard-page::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.4;
    background:
        radial-gradient(at var(--mesh-1, 15%) 20%, oklch(from var(--accent, #6366f1) l c h / 0.15) 0, transparent 40%),
        radial-gradient(at var(--mesh-2, 85%) 80%, oklch(270 0.12 0.45 / 0.12) 0, transparent 40%);
    animation: mesh-drift 30s ease-in-out infinite alternate;
}

@keyframes mesh-drift {
    0% { --mesh-1: 15%; --mesh-2: 85%; }
    50% { --mesh-1: 55%; --mesh-2: 30%; }
    100% { --mesh-1: 15%; --mesh-2: 85%; }
}

@media (prefers-reduced-motion: reduce) {
    body.dashboard-page::before { animation: none; }
}

/* Scroll-driven progress bar at top of page.
   Native 2024+: animation-timeline: scroll(). Non-supporting browsers
   gracefully get a static bar. */
.scroll-progress {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 2px;
    z-index: 10000;
    background: transparent;
    pointer-events: none;
}
.scroll-progress::after {
    content: '';
    display: block;
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--accent, #6366f1), oklch(72% 0.2 300));
    transform-origin: left;
    transform: scaleX(var(--sp, 0));
}
@supports (animation-timeline: scroll()) {
    .scroll-progress::after {
        transform: scaleX(0);
        animation: sp-fill linear;
        animation-timeline: scroll(root);
    }
    @keyframes sp-fill { to { transform: scaleX(1); } }
}

/* Spring-bouncy hover for primary CTAs (feels tactile) */
@supports (transition-timing-function: linear(0, 1)) {
    .btn-primary, .btn.btn-accent, gip-button[variant="primary"] button {
        transition-timing-function: linear(
            0, 0.229 3.5%, 0.454 7%, 0.668 10.7%, 0.84 14.4%, 0.947 18.3%,
            0.992 22.3%, 1.009 26.7%, 1.003 31.2%, 0.992 37.3%, 0.997 43.7%, 1
        );
    }
}
