/* ---------- Тема ---------- */

:root {
    color-scheme: light;

    --bg: #f4f6f9;
    --bg-glow: radial-gradient(1200px 600px at 15% -10%, #e5e9ff 0%, transparent 60%),
               radial-gradient(900px 500px at 90% 0%, #e6f7f4 0%, transparent 55%);
    --surface: #ffffff;
    --surface-2: #f7f8fb;
    --surface-3: #eef1f6;
    --border: #e3e7ee;
    --border-strong: #d3d9e4;
    --text: #131722;
    --text-dim: #667085;
    --text-faint: #98a2b3;
    --accent: #5b5ef4;
    --accent-soft: #ecedff;
    --accent-text: #ffffff;
    --ok: #12a678;
    --ok-soft: #e3f7f0;
    --warn: #e0850c;
    --warn-soft: #fdf1de;
    --danger: #e0435a;
    --danger-soft: #fdeaed;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
    --shadow-md: 0 4px 16px rgba(16, 24, 40, .08);
    --shadow-lg: 0 24px 60px rgba(16, 24, 40, .18);

    --p1: #8a94a6;
    --p2: #3aa9e0;
    --p3: #5b5ef4;
    --p4: #e0850c;
    --p5: #e0435a;

    --radius: 14px;
    --radius-sm: 10px;
    --header-h: 60px;
}

html[data-theme="dark"] {
    color-scheme: dark;

    --bg: #0d0f14;
    --bg-glow: radial-gradient(1200px 600px at 15% -10%, #1a1c3a 0%, transparent 60%),
               radial-gradient(900px 500px at 90% 0%, #102b2b 0%, transparent 55%);
    --surface: #161920;
    --surface-2: #1c2029;
    --surface-3: #232833;
    --border: #262b36;
    --border-strong: #333a48;
    --text: #e8ebf2;
    --text-dim: #99a2b3;
    --text-faint: #6c7688;
    --accent: #7b7ffb;
    --accent-soft: #21234a;
    --accent-text: #0d0f14;
    --ok: #2ed3a3;
    --ok-soft: #10302a;
    --warn: #f0a93a;
    --warn-soft: #33260f;
    --danger: #ff6178;
    --danger-soft: #351720;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 6px 20px rgba(0, 0, 0, .35);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, .55);

    --p1: #6d7688;
    --p2: #49b6e8;
    --p3: #7b7ffb;
    --p4: #f0a93a;
    --p5: #ff6178;
}

/* ---------- База ---------- */

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--bg);
    background-image: var(--bg-glow);
    background-attachment: fixed;
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: none;
}

button, input, select, textarea { font: inherit; color: inherit; }

/* Наши кнопки — flex, поэтому обычный [hidden] их не прячет. */
[hidden] { display: none !important; }

button { cursor: pointer; border: none; background: none; }

h1, h2, h3, p { margin: 0; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Шапка ---------- */

.header {
    position: sticky;
    top: 0;
    z-index: 20;
    height: var(--header-h);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 650;
    letter-spacing: -.01em;
    font-size: 16px;
}

.header__spacer { margin-right: auto; }

/* ---------- Переключатель досок ---------- */

.board-switch {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 34px;
    padding: 0 10px 0 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -.01em;
    max-width: 240px;
    transition: background .15s, border-color .15s;
}

.board-switch:hover { background: var(--surface-3); border-color: var(--border-strong); }
.board-switch span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-switch svg { flex: none; color: var(--text-faint); }

.menu {
    position: fixed;
    z-index: 60;
    width: 260px;
    padding: 6px;
    border-radius: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    animation: pop .12s ease-out;
    max-height: min(70vh, 460px);
    overflow-y: auto;
}

.menu__title {
    padding: 6px 10px 4px;
    font-size: 11.5px;
    font-weight: 650;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-faint);
}

.menu__item {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 9px 10px;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    text-align: left;
    transition: background .12s, color .12s;
}

.menu__item:hover { background: var(--surface-3); }
.menu__item:disabled { opacity: .4; cursor: not-allowed; }
.menu__item:disabled:hover { background: none; }
.menu__item--danger { color: var(--danger); }
.menu__item--danger:hover { background: var(--danger-soft); }
.menu__item--board.is-current { font-weight: 650; }

.menu__check { width: 14px; flex: none; color: var(--accent); font-weight: 700; }
.menu__name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.menu__count {
    flex: none;
    min-width: 22px;
    padding: 1px 7px;
    border-radius: 99px;
    background: var(--surface-3);
    color: var(--text-faint);
    font-size: 11.5px;
    font-weight: 600;
    text-align: center;
}

.menu__sep { height: 1px; margin: 6px 4px; background: var(--border); }

.brand__mark {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, var(--ok)));
    color: #fff;
}

.brand__sub {
    color: var(--text-faint);
    font-weight: 450;
    font-size: 13px;
}

.icon-btn {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    border: 1px solid transparent;
    transition: background .15s, color .15s, border-color .15s;
}

.icon-btn:hover { background: var(--surface-3); color: var(--text); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 38px;
    padding: 0 16px;
    border-radius: var(--radius-sm);
    font-weight: 550;
    font-size: 14px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-sm);
    transition: transform .1s, background .15s, border-color .15s, opacity .15s;
}

.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }

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

.btn--primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }

.btn--ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-dim); }
.btn--ghost:hover { background: var(--surface-3); color: var(--text); }

.btn--danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); background: transparent; box-shadow: none; }
.btn--danger:hover { background: var(--danger-soft); }

.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Переключатель колонок (мобилка) ---------- */

.tabs {
    display: none;
    gap: 4px;
    padding: 8px 12px 0;
    position: sticky;
    top: var(--header-h);
    z-index: 15;
    background: var(--bg);
}

.tabs__inner {
    display: flex;
    width: 100%;
    gap: 3px;
    padding: 4px;
    border-radius: 12px;
    background: var(--surface-3);
    border: 1px solid var(--border);
}

.tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 34px;
    border-radius: 9px;
    font-size: 13.5px;
    font-weight: 550;
    color: var(--text-dim);
    transition: background .15s, color .15s;
}

.tab[aria-selected="true"] {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

.tab__count {
    min-width: 20px;
    height: 18px;
    padding: 0 5px;
    border-radius: 99px;
    background: var(--surface-2);
    color: var(--text-faint);
    font-size: 11.5px;
    font-weight: 600;
    display: grid;
    place-items: center;
}

.tab[aria-selected="true"] .tab__count { background: var(--accent-soft); color: var(--accent); }

/* ---------- Доска ---------- */

.board {
    max-width: 1240px;
    margin: 0 auto;
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    /* Колонки одной высоты: пустое поле внизу — тоже зона, куда можно бросить карточку. */
    align-items: stretch;
    min-height: calc(100vh - var(--header-h) - 40px);
}

.column {
    background: color-mix(in srgb, var(--surface) 70%, transparent);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    min-height: 220px;
    transition: border-color .15s, background .15s;
}

.column.is-drop-target {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 7%, var(--surface));
}

.column.is-blocked {
    border-color: color-mix(in srgb, var(--danger) 45%, transparent);
    background: color-mix(in srgb, var(--danger) 5%, var(--surface));
}

.column__head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px 10px;
}

.column__dot { width: 8px; height: 8px; border-radius: 99px; flex: none; }
.column--todo .column__dot { background: var(--text-faint); }
.column--doing .column__dot { background: var(--accent); }
.column--done .column__dot { background: var(--ok); }

.column__title { font-weight: 600; font-size: 14.5px; letter-spacing: -.01em; }

.column__count {
    margin-left: auto;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-faint);
    background: var(--surface-3);
    border-radius: 99px;
    padding: 2px 9px;
}

.column__count.is-full { background: var(--danger-soft); color: var(--danger); }

.column__list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 4px 12px 14px;
    min-height: 60px;
    flex: 1;
}

.column__empty {
    padding: 22px 12px;
    text-align: center;
    color: var(--text-faint);
    font-size: 13px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
}

.column__foot { padding: 0 12px 12px; }

/* ---------- Карточка ---------- */

.card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 12px 10px 15px;
    box-shadow: var(--shadow-sm);
    cursor: grab;
    transition: box-shadow .15s, transform .1s, border-color .15s, opacity .15s;
    overflow: hidden;
}

.card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.card:active { cursor: grabbing; }
.card.is-dragging { opacity: .45; }

.card::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--card-accent, var(--p3));
}

.card__top { display: flex; align-items: flex-start; gap: 8px; }

.card__title {
    font-weight: 550;
    font-size: 14.5px;
    line-height: 1.35;
    letter-spacing: -.005em;
    word-break: break-word;
    flex: 1;
}

.card.is-done .card__title { color: var(--text-dim); text-decoration: line-through; text-decoration-color: var(--border-strong); }

.card__score {
    flex: none;
    display: flex;
    align-items: baseline;
    gap: 3px;
    height: 22px;
    padding: 0 8px;
    border-radius: 99px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 12.5px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.card__desc {
    margin-top: 6px;
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: pre-wrap;
    word-break: break-word;
}

.card__meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 22px;
    padding: 0 8px;
    border-radius: 7px;
    background: var(--surface-3);
    color: var(--text-dim);
    font-size: 12px;
    font-weight: 550;
    white-space: nowrap;
}

.chip--priority { background: color-mix(in srgb, var(--card-accent) 14%, transparent); color: var(--card-accent); }

.chip--next {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 650;
}

.chip--next::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 99px;
    background: currentColor;
    animation: pulse 2s ease-in-out infinite;
}

.chip--running { background: var(--ok-soft); color: var(--ok); }

@keyframes pulse { 50% { opacity: .35; } }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }

.card__actions {
    display: flex;
    gap: 2px;
    margin-left: auto;
}

.card__btn {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 7px;
    color: var(--text-faint);
    transition: background .15s, color .15s;
}

.card__btn:hover { background: var(--surface-3); color: var(--text); }
.card__btn:disabled { opacity: .3; cursor: not-allowed; }
.card__btn--done:hover { background: var(--ok-soft); color: var(--ok); }

.drop-line {
    height: 2px;
    border-radius: 2px;
    background: var(--accent);
    margin: -6px 0;
}

/* ---------- Модалки ---------- */

dialog {
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text);
    max-width: min(560px, calc(100vw - 24px));
    width: 100%;
}

dialog::backdrop { background: rgba(9, 11, 16, .55); backdrop-filter: blur(3px); }

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: pop .16s ease-out;
}

@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }

.modal__head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 20px 6px;
}

.modal__title { font-size: 17px; font-weight: 650; letter-spacing: -.015em; margin-right: auto; }

.modal__body { padding: 12px 20px 4px; max-height: min(70vh, 620px); overflow-y: auto; }

.modal__foot {
    display: flex;
    gap: 8px;
    padding: 16px 20px 18px;
    align-items: center;
}

.modal__foot .spacer { margin-left: auto; }

.task-meta {
    font-size: 12px;
    color: var(--text-faint);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 11px;
    margin-bottom: 16px;
    line-height: 1.5;
}

.field { margin-bottom: 16px; }

.field__label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 6px;
    letter-spacing: .01em;
}

.field__hint { font-size: 12px; color: var(--text-faint); margin-top: 6px; line-height: 1.4; }

.input, .textarea, .select {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    outline: none;
    transition: border-color .15s, box-shadow .15s, background .15s;
}

.input:focus, .textarea:focus, .select:focus {
    border-color: var(--accent);
    background: var(--surface);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.textarea { resize: vertical; min-height: 84px; line-height: 1.5; }

.select { appearance: none; background-image: none; cursor: pointer; }

/* Приоритет — сегменты */

.segments { display: flex; gap: 6px; }

.segment {
    flex: 1;
    height: 40px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 550;
    display: grid;
    place-items: center;
    transition: all .15s;
}

.segment:hover { border-color: var(--border-strong); }

.segment[aria-pressed="true"] {
    background: color-mix(in srgb, var(--seg-color) 14%, var(--surface));
    border-color: var(--seg-color);
    color: var(--seg-color);
    font-weight: 650;
}

.hours-presets { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

.preset {
    height: 30px;
    padding: 0 11px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-dim);
    font-size: 12.5px;
    font-weight: 550;
    transition: all .15s;
}

.preset:hover { border-color: var(--border-strong); color: var(--text); }
.preset[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* Настройки */

.setting-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-bottom: 12px;
    background: var(--surface-2);
}

.mode-option {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    cursor: pointer;
    margin-bottom: 8px;
    transition: all .15s;
}

.mode-option:hover { border-color: var(--border-strong); }

.mode-option.is-active {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

.mode-option input { margin-top: 3px; accent-color: var(--accent); }

.mode-option__name { font-weight: 600; font-size: 13.5px; }
.mode-option__formula {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 12.5px;
    color: var(--text-dim);
    margin-top: 3px;
}
.mode-option__note { font-size: 12px; color: var(--text-faint); margin-top: 3px; }

.number-row { display: flex; align-items: center; gap: 10px; }
.number-row .input { width: 92px; text-align: center; font-variant-numeric: tabular-nums; }

/* Статистика */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.stat {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
}

.stat__value { font-size: 20px; font-weight: 680; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat__label { font-size: 12px; color: var(--text-faint); margin-top: 2px; }

.chart {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 110px;
    padding: 10px 2px 0;
    border-bottom: 1px solid var(--border);
}

.chart__bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; gap: 4px; }

.chart__fill {
    border-radius: 5px 5px 2px 2px;
    background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 55%, transparent));
    min-height: 2px;
    transition: height .3s;
}

.chart__value { font-size: 10.5px; text-align: center; color: var(--text-faint); font-variant-numeric: tabular-nums; }

.chart-labels { display: flex; gap: 4px; margin-top: 6px; }
.chart-labels span { flex: 1; text-align: center; font-size: 10px; color: var(--text-faint); }

.section-title {
    font-size: 12.5px;
    font-weight: 650;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin: 18px 0 10px;
}

.archive-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
}

.archive-item__date { margin-left: auto; color: var(--text-faint); font-size: 12px; white-space: nowrap; }

/* ---------- Вход ---------- */

.login { max-width: min(420px, calc(100vw - 24px)); }
.login .modal__head { gap: 12px; padding-top: 22px; }
.login::backdrop { background: rgba(9, 11, 16, .72); backdrop-filter: blur(6px); }

.input--code {
    font-size: 22px;
    letter-spacing: .4em;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* ---------- Тосты ---------- */

.toasts {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    pointer-events: none;
    width: min(440px, calc(100vw - 24px));
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 15px;
    border-radius: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    font-size: 13.5px;
    font-weight: 500;
    animation: toast-in .2s ease-out;
    max-width: 100%;
}

.toast--warn { border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.toast--error { border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.toast--ok { border-color: color-mix(in srgb, var(--ok) 45%, transparent); }

@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } }

/* ---------- Адаптив ---------- */

@media (max-width: 880px) {
    .header { padding: 0 10px; gap: 6px; }
    .brand__sub { display: none; }
    .brand__name { display: none; }
    .board-switch { max-width: 42vw; }
    .menu { width: calc(100vw - 16px); }
    .btn--new span { display: none; }
    .btn--new { padding: 0; width: 38px; }

    .tabs { display: flex; }

    .board {
        grid-template-columns: 1fr;
        padding: 12px;
        gap: 12px;
        min-height: auto;
    }

    .column { background: transparent; border: none; }
    .column__head { display: none; }
    .column__list { padding: 0; gap: 10px; }
    .column { display: none; }
    .column.is-active { display: flex; }

    .card { padding: 13px 13px 11px 16px; }
    .card__btn { width: 32px; height: 32px; }

    .modal { border-radius: 16px 16px 0 0; }
    dialog { max-width: 100vw; margin: auto auto 0; }
    .modal__body { max-height: 68vh; }
}

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