:root {
    --bg: #0e0f11;
    --surface: #15171a;
    --surface-2: #1b1e22;
    --border: #262a30;
    --text: #e7e9ec;
    --muted: #8b929c;
    --accent: #6ea8fe;
    --danger: #e5707b;
    --low: #5b6470;
    --normal: #6ea8fe;
    --high: #e5707b;
    --radius: 8px;
}

[data-theme="light"] {
    --bg: #fbfbfc;
    --surface: #ffffff;
    --surface-2: #f4f5f7;
    --border: #e3e5e9;
    --text: #1a1c1f;
    --muted: #71767f;
    --accent: #2f6fd0;
    --danger: #c9384a;
    --low: #a6acb6;
    --normal: #2f6fd0;
    --high: #c9384a;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    height: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    font: 14px/1.5 ui-sans-serif, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
    margin: 0;
    font-weight: 600;
}

a {
    color: inherit;
    text-decoration: none;
}

.muted {
    color: var(--muted);
}

.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-wrap: wrap;
}

.brand {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.brand h1 {
    font-size: 15px;
    letter-spacing: 0.02em;
}

.brand .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    align-self: center;
}

.brand .muted {
    font-size: 12px;
}

.filters {
    display: flex;
    gap: 8px;
    margin-left: auto;
    flex-wrap: wrap;
}

.actions {
    display: flex;
    gap: 8px;
}

input,
select,
textarea,
button {
    font: inherit;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 7px 10px;
    outline: none;
    transition: border-color 0.15s ease, background 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
}

textarea {
    resize: vertical;
    min-height: 72px;
}

button {
    cursor: pointer;
}

button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #0c1220;
    font-weight: 600;
}

button.primary:hover {
    filter: brightness(1.08);
}

.ghost {
    background: transparent;
}

.ghost:hover {
    background: var(--surface-2);
    border-color: var(--accent);
}

a.ghost {
    display: inline-flex;
    align-items: center;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.icon {
    width: 34px;
    padding: 7px 0;
    text-align: center;
}

.board {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(4, minmax(240px, 1fr));
    gap: 14px;
    padding: 18px 20px 28px;
    overflow-x: auto;
    align-items: start;
}

.column {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 240px;
}

.column-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 2px;
}

.column-head h2 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.count {
    font-size: 11px;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0 7px;
    line-height: 17px;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 60px;
    border-radius: var(--radius);
    transition: background 0.15s ease, outline 0.15s ease;
    outline: 1px dashed transparent;
}

.stack.over {
    background: var(--surface);
    outline-color: var(--border);
}

.stack:empty {
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

.stack:empty::before {
    content: "перетащите сюда";
    color: var(--muted);
    font-size: 12px;
    margin: auto;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 11px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    cursor: grab;
}

.card:hover {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.card.dragging {
    opacity: 0.4;
}

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

.card-top h3 {
    font-size: 14px;
    line-height: 1.35;
    word-break: break-word;
}

.priority {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-top: 6px;
    flex: 0 0 auto;
}

.p-low {
    background: var(--low);
}

.p-normal {
    background: var(--normal);
}

.p-high {
    background: var(--high);
}

.body {
    margin: 0;
    font-size: 13px;
    color: var(--muted);
    word-break: break-word;
}

.card-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 12px;
}

.chip {
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 1px 8px;
    color: var(--muted);
}

.chip:hover {
    border-color: var(--accent);
    color: var(--text);
}

.chip.soft {
    background: var(--surface-2);
}

.time {
    margin-left: auto;
    font-size: 11px;
}

.card-tools {
    display: none;
    gap: 10px;
    align-items: center;
    border-top: 1px solid var(--border);
    padding-top: 8px;
}

.card:hover .card-tools {
    display: flex;
}

.card-tools form {
    margin: 0;
}

.link {
    background: none;
    border: none;
    padding: 0;
    font-size: 12px;
    color: var(--muted);
}

.link:hover {
    color: var(--text);
    text-decoration: underline;
}

.link.danger:hover {
    color: var(--danger);
}

.add-inline {
    background: transparent;
    border: 1px dashed var(--border);
    color: var(--muted);
    font-size: 13px;
    padding: 8px;
}

.add-inline:hover {
    color: var(--text);
    border-color: var(--accent);
}

dialog {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    padding: 0;
    width: min(520px, calc(100vw - 32px));
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.55);
}

.task-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 18px;
}

.task-form header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.task-form header h2 {
    font-size: 15px;
}

.task-form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.task-form label span {
    font-size: 12px;
    color: var(--muted);
}

.task-form .row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.task-form footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 4px;
}

@media (max-width: 900px) {
    .board {
        grid-template-columns: 1fr;
    }

    .filters {
        margin-left: 0;
        width: 100%;
    }

    .filters input[type="search"] {
        flex: 1;
    }

    .card-tools {
        display: flex;
    }
}
