/* TaskVault — тёмная дизайн-система (Linear-style минимализм).
   Токены выверены по WCAG AA: весь текст ≥ 4.5:1 на своих поверхностях. */

:root {
    --bg-base:        #0a0a0b;
    --bg-surface:     #16191f;
    --bg-overlay:     #1d222a;
    --bg-hover:       #242a33;
    --bg-active:      #2b323d;

    --border:         #2c333e;
    --border-subtle:  #22272f;

    --text-primary:   #e2e5ea;
    --text-secondary: #9aa2ad;
    --text-muted:     #7e8794;
    --text-accent:    #ff4a5e;

    --accent:         #e02433;
    --accent-bright:  #ff5f6d;
    --accent-dim:     rgba(224,36,51,0.14);
    --accent-hover:   #c81f2d;

    --priority-low:      #99a1ab;
    --priority-low-bg:   rgba(153,161,171,0.14);
    --priority-normal:   #8fb0d8;
    --priority-normal-bg: rgba(143,176,216,0.14);
    --priority-high:     #d4a66a;
    --priority-high-bg:  rgba(212,166,106,0.14);

    --status-todo:        #c3c9d1;
    --status-todo-bg:     rgba(195,201,209,0.14);
    --status-progress:    #d99a78;
    --status-progress-bg: rgba(217,154,120,0.14);
    --status-done:        #8fbc83;
    --status-done-bg:     rgba(143,188,131,0.14);

    --danger:         #e07a6f;
    --danger-bg:      rgba(224,122,111,0.14);
    --success:        #8fbc83;
    --success-bg:     rgba(143,188,131,0.14);
    --info:           #a3b8d8;
    --info-bg:        rgba(163,184,216,0.12);
    --warning:        #d0a55e;
    --warning-bg:     rgba(208,165,94,0.14);

    --role-admin:      #d99a90;
    --role-admin-bg:   rgba(217,154,144,0.16);
    --role-contributor:#a3b8d8;
    --role-contributor-bg: rgba(163,184,216,0.14);
    --role-reader:     #99a1ab;
    --role-reader-bg:  rgba(153,161,171,0.14);

    --focus:           #e02433;

    --radius-sm:  6px;
    --radius-md:  10px;
    --radius-lg:  14px;

    --shadow-card: 0 1px 2px rgba(0,0,0,0.25), 0 4px 16px rgba(0,0,0,0.18);
    --shadow-pop:  0 8px 32px rgba(0,0,0,0.45);

    --font-ui:   'Onest', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --topbar-h: 56px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; scroll-behavior: smooth; }

body {
    font-family: var(--font-ui);
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--text-accent); text-decoration: none; }
a:hover { color: var(--accent-bright); text-decoration: underline; }

/* --- Focus (a11y): видимое кольцо на всех интерактивных --- */
:focus { outline: none; }
:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* --- Topbar: плотный, без glass-эффектов --- */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    gap: 0.75rem;
    z-index: 100;
}

.topbar__logo {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 1rem;
    color: var(--accent-bright);
    letter-spacing: -0.02em;
    white-space: nowrap;
    text-decoration: none;
}
.topbar__logo:hover { color: var(--text-accent); text-decoration: none; }
.topbar__logo span { color: var(--text-secondary); font-weight: 400; }

.topbar__nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: 1rem;
}
.topbar__navlink {
    font-size: 0.88rem;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    padding: 0.35rem 0.7rem;
    border-radius: var(--radius-sm);
    transition: color 0.15s, background 0.15s;
}
.topbar__navlink:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
    text-decoration: none;
}
.topbar__navlink.is-active {
    color: var(--text-primary);
    background: var(--bg-active);
}

.topbar__spacer { flex: 1; }

.topbar__user {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

.role-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.18rem 0.55rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-family: var(--font-mono);
    white-space: nowrap;
}
.role-badge::before {
    content: '';
    width: 5px; height: 5px;
    border-radius: 50%;
    background: currentColor;
}
.role-badge--admin       { color: var(--role-admin);       background: var(--role-admin-bg); }
.role-badge--contributor { color: var(--role-contributor); background: var(--role-contributor-bg); }
.role-badge--reader      { color: var(--role-reader);      background: var(--role-reader-bg); }

.topbar__btn {
    font-size: 0.82rem;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 0.32rem 0.75rem;
    border-radius: var(--radius-sm);
    background: transparent;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.topbar__btn:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
    text-decoration: none;
}
.topbar__btn--admin {
    color: var(--text-accent);
    border-color: var(--accent-dim);
}
.topbar__btn--admin:hover {
    background: var(--accent-dim);
    border-color: var(--accent);
}

/* --- Layout --- */
.layout {
    display: flex;
    padding-top: var(--topbar-h);
    min-height: 100vh;
}

/* --- Flash --- */
.flash-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 360px;
}

.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    border-left: 3px solid;
    background: var(--bg-overlay);
    box-shadow: var(--shadow-card);
    animation: slideIn 0.25s ease;
}

.flash--success { border-color: var(--success); color: var(--success); }
.flash--danger  { border-color: var(--danger);  color: var(--danger); }
.flash--info    { border-color: var(--info);    color: var(--info); }
.flash--warning { border-color: var(--warning); color: var(--warning); }

@keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* --- Кнопки --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-ui);
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 0.12s ease, background 0.15s, border-color 0.15s, color 0.15s;
    text-decoration: none;
    white-space: nowrap;
}
.btn:active { transform: scale(0.98); }

.btn--primary {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
    box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.btn--primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #ffffff;
    text-decoration: none;
}

.btn--ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}
.btn--ghost:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
    background: var(--bg-hover);
    text-decoration: none;
}

.btn--danger {
    background: transparent;
    color: var(--danger);
    border-color: color-mix(in srgb, var(--danger) 55%, transparent);
}
.btn--danger:hover {
    background: var(--danger-bg);
    border-color: var(--danger);
    text-decoration: none;
}

.btn--sm { padding: 0.32rem 0.7rem; font-size: 0.85rem; }

/* --- Бейджи --- */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.32rem;
    padding: 0.22rem 0.6rem;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    font-family: var(--font-mono);
    white-space: nowrap;
}
.status-badge::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
}
.status-badge--todo        { color: var(--status-todo);     background: var(--status-todo-bg); }
.status-badge--in_progress { color: var(--status-progress); background: var(--status-progress-bg); }
.status-badge--done        { color: var(--status-done);     background: var(--status-done-bg); }

.priority-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.32rem;
    padding: 0.22rem 0.6rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    font-family: var(--font-mono);
    white-space: nowrap;
}
.priority-badge::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
}
.priority-badge--low      { color: var(--priority-low);    background: var(--priority-low-bg); }
.priority-badge--normal   { color: var(--priority-normal); background: var(--priority-normal-bg); }
.priority-badge--high     { color: var(--priority-high);   background: color-mix(in srgb, var(--priority-high) 14%, transparent); }
.priority-badge--critical { color: var(--danger); background: var(--danger-bg); }

.issue-id {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.18rem 0.6rem;
    border-radius: 999px;
    font-size: 0.74rem;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    background: var(--bg-active);
    border: 1px solid var(--border);
}

.deadline-overdue { color: var(--danger); font-weight: 600; }

.issue-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}

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

/* --- Страницы ошибок --- */
.error-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 1rem;
    text-align: center;
    padding: 2rem;
    padding-top: var(--topbar-h);
}
.error-page__code {
    font-family: var(--font-mono);
    font-size: 7rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.04em;
    color: transparent;
    -webkit-text-stroke: 2px var(--border);
}
.error-page__code--403 { -webkit-text-stroke: 2px var(--danger); }
.error-page__code--404 { -webkit-text-stroke: 2px var(--accent); }
.error-page__title { font-size: 1.35rem; color: var(--text-primary); font-weight: 700; }
.error-page__text { color: var(--text-secondary); font-size: 0.92rem; line-height: 1.6; }
.error-page__actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; }

.empty-state {
    text-align: center;
    padding: 3.5rem 1rem;
    color: var(--text-secondary);
    font-size: 0.92rem;
}
.empty-state__actions { margin-top: 1.25rem; }

/* --- Страницы --- */
.page {
    max-width: 1200px;
    margin: 0 auto;
    padding: calc(var(--topbar-h) + 2rem) 1.5rem 4rem;
}
.page--narrow { max-width: 820px; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.page-header__actions { display: flex; gap: 0.5rem; align-items: center; }
.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.015em;
    line-height: 1.25;
}
.page-subtitle { font-size: 0.88rem; color: var(--text-secondary); margin-top: 0.3rem; }
.section-title { font-size: 1.15rem; font-weight: 700; margin: 2rem 0 1rem; }
.project-key-big {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-accent);
    letter-spacing: 0.08em;
}

/* --- Stat-карточки --- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
    margin-bottom: 2rem;
}
.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.1rem 1.25rem;
    position: relative;
    overflow: hidden;
    transition: border-color 0.15s, transform 0.15s;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--stat-accent, var(--border));
    opacity: 0.9;
}
.stat-card:hover { border-color: var(--border); transform: translateY(-1px); }
.stat-card__value { font-size: 1.6rem; font-weight: 700; font-family: var(--font-mono); line-height: 1.2; }
.stat-card__label { font-size: 0.8rem; color: var(--text-secondary); margin-top: 0.25rem; }
.stat-card--total     { --stat-accent: var(--accent); }
.stat-card--projects  { --stat-accent: var(--priority-normal); }
.stat-card--todo      { --stat-accent: var(--status-todo); }
.stat-card--progress  { --stat-accent: var(--status-progress); }
.stat-card--done      { --stat-accent: var(--status-done); }
.stat-card--mine      { --stat-accent: var(--info); }
.stat-card--overdue   { --stat-accent: var(--danger); }

/* --- Карточки проектов --- */
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 0.75rem;
}
.project-card {
    display: block;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.15rem 1.3rem;
    transition: border-color 0.15s, transform 0.15s, background 0.15s;
}
.project-card:hover {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 3%, var(--bg-surface));
    transform: translateY(-2px);
    text-decoration: none;
}
.project-card__key {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-accent);
    letter-spacing: 0.08em;
}
.project-card__name {
    font-size: 0.98rem;
    font-weight: 600;
    margin-top: 0.3rem;
    color: var(--text-primary);
}
.project-card__meta {
    display: flex;
    gap: 0.4rem;
    font-size: 0.76rem;
    color: var(--text-secondary);
    margin-top: 0.45rem;
    font-family: var(--font-mono);
}

/* --- Фильтры --- */
.filter-bar {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.8rem 1rem;
    margin-bottom: 1rem;
}
.filter-form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.filter-input { max-width: 220px; }
.filter-select { max-width: 180px; }
.filter-reset { font-size: 0.78rem; color: var(--text-secondary); margin-left: 0.25rem; }

.issue-counts { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }

/* --- Участники проекта --- */
.members-panel { margin-bottom: 1rem; }
.members-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.6rem;
}
.member-remove { display: inline-flex; margin: 0; }
.member-add { display: flex; gap: 0.5rem; align-items: center; }
.member-add .filter-select { max-width: 240px; }

/* --- Пикер участников при создании проекта --- */
.member-picker__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.6rem;
}
.member-picker__row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.member-picker__row .filter-select { max-width: 260px; }

/* --- Список задач --- */
.issue-list {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.issue-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.72rem 1rem 0.72rem 0.95rem;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    transition: background 0.12s;
    position: relative;
}
.issue-row::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 2px;
    background: var(--row-accent, transparent);
}
.issue-row[data-priority="low"]      { --row-accent: color-mix(in srgb, var(--priority-low) 30%, transparent); }
.issue-row[data-priority="normal"]   { --row-accent: color-mix(in srgb, var(--priority-normal) 55%, transparent); }
.issue-row[data-priority="high"]     { --row-accent: color-mix(in srgb, var(--priority-high) 75%, transparent); }
.issue-row[data-priority="critical"] { --row-accent: var(--danger); }
.issue-row:last-child { border-bottom: none; }
.issue-row:hover { background: var(--bg-hover); }
.issue-row:hover .issue-row__title { color: var(--accent-bright); }
.issue-row__link {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    color: inherit;
    text-decoration: none;
}
.issue-row__link:hover { text-decoration: none; }
.issue-row__title {
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.issue-row__deadline { font-size: 0.78rem; color: var(--text-secondary); font-family: var(--font-mono); }

/* --- Инлайн-смена статуса --- */
.status-form { display: inline-flex; margin: 0; }

/* --- Пагинация --- */
.pagination {
    display: flex;
    gap: 0.35rem;
    align-items: center;
    margin-top: 1.25rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
}
.pagination__link, .pagination__current {
    padding: 0.35rem 0.7rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}
.pagination__link:hover { color: var(--text-primary); border-color: var(--text-secondary); text-decoration: none; }
.pagination__current { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.pagination__info { color: var(--text-muted); margin-left: 0.5rem; }

/* --- Карточка задачи --- */
.issue-attrs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
    margin-bottom: 0.75rem;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.issue-body {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.5rem;
    margin-top: 1rem;
    font-size: 0.92rem;
}
.issue-body h1, .issue-body h2, .issue-body h3 { margin: 1rem 0 0.5rem; }
.issue-body p { margin: 0.5rem 0; }
.issue-body ul, .issue-body ol { margin: 0.5rem 0 0.5rem 1.5rem; }
.issue-body code {
    font-family: var(--font-mono);
    background: var(--bg-overlay);
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    font-size: 0.84em;
}
.issue-body pre {
    background: var(--bg-overlay);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 0.5rem 0;
}
.issue-body code pre, .issue-body pre code { font-family: var(--font-mono); font-size: 0.84rem; }
.issue-body blockquote {
    border-left: 3px solid var(--border);
    padding-left: 0.9rem;
    color: var(--text-secondary);
    margin: 0.5rem 0;
}
.issue-body a { text-decoration: underline; }
.issue-body img { max-width: 100%; border-radius: var(--radius-sm); }

/* --- Формы --- */
.form-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
}
.form-actions { display: flex; gap: 0.5rem; align-items: center; }

.comment {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.85rem 1.1rem;
    margin-bottom: 0.6rem;
}
.comment__header { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.4rem; }
.comment__date { font-size: 0.74rem; color: var(--text-muted); font-family: var(--font-mono); }
.comment__delete { margin-left: auto; }
.comment__delete-btn {
    background: none; border: none; cursor: pointer;
    font-size: 0.74rem; color: var(--text-muted); font-family: var(--font-mono);
    padding: 0.2rem 0.4rem;
}
.comment__delete-btn:hover { color: var(--danger); }
.comment__body { font-size: 0.88rem; white-space: pre-wrap; }

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px; height: 24px;
    border-radius: 50%;
    background: var(--bg-overlay);
    border: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 0.64rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    flex-shrink: 0;
}
.avatar--accent { color: var(--text-accent); border-color: var(--accent-dim); }

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-family: var(--font-mono);
    font-size: 0.76rem;
    color: var(--text-secondary);
}
.user-chip__name { color: var(--text-primary); }

/* --- Формы: поля --- */
.form-group { display: flex; flex-direction: column; gap: 0.4rem; }
.form-label { font-size: 0.8rem; color: var(--text-secondary); font-weight: 500; }

.form-control {
    background: var(--bg-overlay);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 0.9rem;
    padding: 0.55rem 0.8rem;
    transition: border-color 0.15s, box-shadow 0.15s;
    width: 100%;
}
.form-control:focus {
    outline: none;
    border-color: var(--focus);
    box-shadow: 0 0 0 3px var(--accent-dim);
}
.form-control::placeholder { color: var(--text-muted); }

.visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

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

/* --- Кастомный dropdown: заменяет нативный <select> (см. app.js enhanceSelects).
   Родной select остаётся в DOM скрытым — держит name/value/required и совместимость
   с автосабмитом/пикером участников, которые слушают его 'change'. --- */
.ss { position: relative; width: 100%; }
.ss--pill { width: auto; }

.ss__trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    text-align: left;
    cursor: pointer;
    font: inherit;
}
.ss__trigger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.ss__trigger:focus-visible {
    outline: none;
    border-color: var(--focus);
    box-shadow: 0 0 0 3px var(--accent-dim);
}
.ss__trigger[aria-invalid="true"] {
    border-color: var(--danger) !important;
    box-shadow: 0 0 0 3px var(--danger-bg);
}
.ss__label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ss__chevron {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    transition: transform 0.15s;
}
.ss.is-open .ss__chevron { transform: rotate(180deg); }
.status-select .ss__chevron { color: currentColor; opacity: 0.75; width: 11px; height: 11px; }

.ss__listbox {
    position: absolute;
    z-index: 60;
    top: calc(100% + 6px);
    left: 0;
    min-width: 100%;
    max-height: 280px;
    overflow-y: auto;
    background: var(--bg-overlay);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-pop);
    padding: 0.3rem;
    list-style: none;
}
.ss__listbox[hidden] { display: none; }
.ss--flip .ss__listbox { top: auto; bottom: calc(100% + 6px); }
.ss--pill .ss__listbox { min-width: 160px; }

.ss__option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.7rem;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-family: var(--font-ui);
    color: var(--text-primary);
    cursor: pointer;
    white-space: nowrap;
}
.ss__option.is-active { background: var(--bg-hover); }
.ss__option[aria-selected="true"] { color: var(--accent-bright); background: var(--accent-dim); }
.ss__option[aria-selected="true"].is-active { background: var(--accent-dim); }
.ss__option[aria-disabled="true"] { color: var(--text-muted); cursor: not-allowed; opacity: 0.5; }
.ss__dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--dot-color, currentColor);
    flex-shrink: 0;
}

@media (prefers-reduced-motion: reduce) {
    .ss__chevron, .ss__option { transition: none; }
}

/* --- Инлайн-смена статуса (кнопка-триггер кастомного дропдауна, см. .ss) --- */
.status-select {
    appearance: none;
    font-family: var(--font-mono);
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    padding: 0.22rem 0.6rem;
    border-radius: 999px;
    border: 1px solid transparent;
    cursor: pointer;
    color: inherit;
    transition: border-color 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}
.status-select:hover {
    border-color: color-mix(in srgb, currentColor 45%, transparent);
}
.status-select--todo        { color: var(--status-todo);     background: var(--status-todo-bg); }
.status-select--in_progress { color: var(--status-progress); background: var(--status-progress-bg); }
.status-select--done        { color: var(--status-done);     background: var(--status-done-bg); }

/* --- Админ: таблица пользователей --- */
.admin-content {
    max-width: 1000px;
    margin: 0 auto;
    padding: calc(var(--topbar-h) + 2rem) 2rem 4rem;
}
.admin-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.75rem;
}
.admin-title { font-size: 1.75rem; font-weight: 700; color: var(--text-primary); }
.admin-subtitle {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    margin-top: 0.15rem;
}

.create-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
}
.create-panel__title {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}
.create-panel__form {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.create-panel__field { display: flex; flex-direction: column; gap: 0.25rem; }
.create-panel__field label {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}
.create-panel__field input,
.create-panel__field .ss__trigger {
    background: var(--bg-overlay);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    padding: 0.38rem 0.6rem;
}
.create-panel__field input:focus,
.create-panel__field .ss__trigger:focus-visible {
    outline: none;
    border-color: var(--focus);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.users-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.users-table th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: var(--bg-overlay);
}
.users-table td {
    padding: 0.8rem 1rem;
    font-size: 0.88rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-subtle);
}
.users-table tr:last-child td { border-bottom: none; }
.users-table tr:hover td { background: var(--bg-hover); }
.username-cell { font-family: var(--font-mono); color: var(--text-primary); }
.cell-muted { color: var(--text-muted); font-family: var(--font-mono); }
.cell-date { color: var(--text-secondary); font-family: var(--font-mono); font-size: 0.78rem; }
.self-tag {
    font-size: 0.68rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
    padding: 0.12rem 0.45rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    margin-left: 0.4rem;
}
.btn--delete {
    background: transparent;
    color: var(--danger);
    border: 1px solid color-mix(in srgb, var(--danger) 55%, transparent);
    font-family: var(--font-mono);
    font-size: 0.74rem;
    padding: 0.28rem 0.6rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
}
.btn--delete:hover { background: var(--danger-bg); }
.actions-cell { display: flex; align-items: center; gap: 0.5rem; }

/* --- Живой поиск проектов --- */
.search-full {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
}
.search-full__input {
    flex: 1;
    max-width: none;
    font-size: 0.95rem;
}
.search-full__hint {
    font-size: 0.76rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    white-space: nowrap;
}

/* --- Markdown-редактор: табы и превью --- */
.md-tabs {
    display: inline-flex;
    gap: 0.25rem;
    background: var(--bg-overlay);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 0.2rem;
}
.md-tab {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    padding: 0.3rem 0.85rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}
.md-tab:hover { color: var(--text-primary); }
.md-tab.is-active { color: var(--text-primary); background: var(--bg-active); }
.md-hint {
    font-size: 0.74rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}
.is-hidden { display: none; }

/* --- Модалка редактирования / подтверждение --- */
.edit-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.edit-overlay.is-open { display: flex; }
.edit-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem 1.75rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-pop, var(--shadow-card));
}
.edit-panel__title { font-size: 1rem; font-weight: 700; color: var(--text-primary); margin-bottom: 0.25rem; }
.edit-panel__hint { font-size: 0.7rem; color: var(--text-muted); font-family: var(--font-mono); }
.edit-panel .form-group { margin-bottom: 0.9rem; }
.edit-panel__actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 0.5rem;
}
.confirm-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0.75rem 0 1.25rem;
}

/* --- Вход --- */
.auth-page {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-base);
    padding: 2rem 1rem;
}
/* Фоновое видео: рабочий процесс разработчика, размытие через CSS */
.auth-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    filter: blur(7px) saturate(1.05) brightness(0.75);
    transform: scale(1.08); /* прячет светлые кромки от блюра по краям */
    pointer-events: none;
}
.auth-page::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    background: linear-gradient(180deg, rgba(10,10,11,0.62), rgba(10,10,11,0.72));
    pointer-events: none;
}
.auth-wrapper {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    width: 100%;
    max-width: 400px;
}
@media (prefers-reduced-motion: reduce) {
    .auth-bg { display: none; } /* остаётся тёмный фон + постер-фолбэк не нужен */
}
.auth-logo {
    display: block;
    width: 294px; /* 70% от 420px */
    max-width: 90vw;
    height: auto;
    background: transparent;
}
/* Низкие вьюпорты: прокрутки нет (фон фиксирован), поэтому контент обязан влезать */
@media (max-height: 640px) {
    .auth-page { padding: 1rem; }
    .auth-logo { display: none; }
    .auth-wrapper { gap: 0; }
}
@media (max-height: 460px) {
    .auth-card { padding: 1.25rem 1.75rem; }
    .auth-brand { margin-bottom: 0.75rem; }
}
.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem 2.25rem;
    box-shadow: var(--shadow-card);
}
.auth-brand { text-align: center; margin-bottom: 2rem; }
.auth-brand__logo {
    font-family: var(--font-mono);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--accent-bright);
    letter-spacing: -0.03em;
}
.auth-brand__logo span { color: var(--text-secondary); font-weight: 400; }
.auth-brand__sub { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.3rem; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.btn--full { width: 100%; justify-content: center; padding: 0.65rem; font-size: 0.9rem; }

/* --- Адаптивность --- */
@media (max-width: 1100px) {
    .topbar { gap: 0.5rem; padding: 0 1rem; }
    .topbar__nav { margin-left: 0.5rem; }
    .topbar__btn { padding: 0.32rem 0.55rem; }
    .topbar__btn--admin span, .topbar__btn .btn-label { display: none; }
    .topbar__user .topbar__username { display: none; }
}

@media (max-width: 820px) {
    .topbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
    .topbar::-webkit-scrollbar { display: none; }
    .topbar__user { display: none; }
    .btn--primary .btn-label { display: inline; }
}

@media (max-width: 640px) {
    html { font-size: 14.5px; }
    .topbar { padding: 0 0.75rem; }
    .topbar__nav { margin-left: 0.25rem; }
    .topbar__navlink { padding: 0.35rem 0.55rem; }
    .btn--primary .btn-label { display: none; }
    .page { padding: calc(var(--topbar-h) + 1.25rem) 1rem 3rem; }
    .admin-content { padding: calc(var(--topbar-h) + 1.25rem) 1rem 3rem; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .form-actions { flex-wrap: wrap; }
    .filter-form > * { flex: 1 1 140px; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .users-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

    /* Строка задачи: заголовок на своей строке, мета переносится ниже —
       иначе на 320px хвост (дедлайн) обрезается overflow:hidden у .issue-list */
    .issue-row { flex-wrap: wrap; row-gap: 0.45rem; padding: 0.4rem 0.85rem; }
    .issue-row__link { flex: 1 1 100%; min-width: 0; padding: 0.35rem 0; min-height: 44px; align-items: center; }
    .issue-row__title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
    .status-form { flex: 0 0 auto; }

    /* 16px в полях ввода — iOS не зумит страницу при фокусе.
       Важно: именно 16px (не rem) — при root 14.5px значения в rem дают <16px. */
    .form-control { font-size: 16px; }
    .create-panel__field input { font-size: 16px; }

    /* --- Мобильный UX: тач-цели ≥ 44px (Apple HIG / WCAG 2.5.5) --- */
    a, button, select, input, textarea { -webkit-tap-highlight-color: rgba(224, 36, 51, 0.18); }
    .btn, .btn--sm, .topbar__btn, .topbar__navlink, .md-tab, .status-select,
    .filter-reset, .pagination__link, .comment__delete-btn { touch-action: manipulation; }

    .btn { min-height: 44px; padding: 0.6rem 1.1rem; }
    .btn--sm { min-height: 44px; padding: 0.55rem 1rem; }
    .btn--full { min-height: 48px; }

    /* Топбар: элементы растягиваются до удобной высоты нажатия */
    .topbar__logo, .topbar__btn, .topbar__navlink, .logout-form button {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        align-self: center;
        justify-content: center;
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }
    /* Иконки без подписи: квадратная цель нажатия */
    .topbar__btn { min-width: 44px; }

    /* Инлайн-смена статуса — главное действие списка задач */
    .status-select {
        min-height: 44px;
        font-size: 0.82rem;
        padding: 0.4rem 0.8rem;
    }

    .md-tab { min-height: 44px; padding: 0.5rem 1rem; }
    .filter-reset {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }
    .pagination__link { min-height: 44px; display: inline-flex; align-items: center; padding: 0.5rem 1rem; }
    .comment__delete-btn { min-height: 40px; min-width: 44px; padding: 0.4rem 0.6rem; font-size: 0.8rem; }

    /* Явный отклик на нажатие (hover-стейтов на таче нет) */
    .issue-row:active { background: var(--bg-hover); }
    .project-card:active { border-color: var(--accent); }

    /* Крупнее цели нажатия в топбаре */
    .topbar__navlink, .topbar__btn { padding-top: 0.45rem; padding-bottom: 0.45rem; }

    /* Flash на всю ширину, не перекрывает контент справа */
    .flash-container { left: 0.75rem; right: 0.75rem; bottom: 0.75rem; max-width: none; }
}

/* --- Низкие/ландшафтные вьюпорты --- */
/* Логин: видео-фон фиксирован, прокрутка отключена на всех разрешениях */
.edit-overlay { overflow-y: auto; }
.edit-panel { margin: auto; }

/* --- Скроллбар --- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* --- Reduced motion (a11y) --- */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
