:root {
    --bg: var(--tg-theme-bg-color, #ffffff);
    --text: var(--tg-theme-text-color, #1a1a1a);
    --hint: var(--tg-theme-hint-color, #999999);
    --link: var(--tg-theme-link-color, #2AABEE);
    --btn: var(--tg-theme-button-color, #2AABEE);
    --btn-text: var(--tg-theme-button-text-color, #ffffff);
    --secondary-bg: var(--tg-theme-secondary-bg-color, #f0f0f0);
    --section-bg: var(--tg-theme-section-bg-color, #ffffff);
    --radius: 12px;
    --radius-sm: 8px;
    --urg-critical: #e24b4a;
    --urg-fast: #ef9f27;
    --urg-medium: #2AABEE;
    --urg-low: #b4b2a9;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    padding-bottom: 70px;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}

.screen { display: none; padding: 12px 16px; min-height: calc(100vh - 70px); }
.screen.active { display: block; }

h2 { font-size: 20px; font-weight: 700; margin-bottom: 12px; }
h4 { font-size: 14px; font-weight: 600; margin-bottom: 8px; color: var(--hint); }

/* Board header */
.board-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.icon-btn {
    width: 36px; height: 36px; border-radius: 50%; border: none;
    background: var(--btn); color: var(--btn-text);
    font-size: 20px; font-weight: 600; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}

/* ═══ Kanban ═══ */
.kanban-board {
    display: flex; gap: 10px; overflow-x: auto;
    padding-bottom: 8px; scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    min-height: calc(100vh - 150px);
}
.kanban-col {
    min-width: 240px; max-width: 280px; flex-shrink: 0;
    scroll-snap-align: start;
    background: var(--secondary-bg); border-radius: var(--radius);
    padding: 10px 8px; display: flex; flex-direction: column;
}
.kanban-col.drag-over { outline: 2px dashed var(--btn); outline-offset: -2px; }
.kanban-col-header {
    display: flex; align-items: center; gap: 6px;
    margin-bottom: 8px; padding: 0 4px;
}
.col-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.col-name { font-size: 13px; font-weight: 700; }
.col-count {
    font-size: 11px; color: var(--hint); background: var(--bg);
    padding: 1px 7px; border-radius: 8px; margin-left: auto;
}
.kanban-items { display: flex; flex-direction: column; gap: 6px; flex: 1; min-height: 40px; }

.kanban-card {
    background: var(--bg); border-radius: var(--radius-sm);
    padding: 10px; cursor: pointer;
    border-left: 4px solid var(--hint);
    transition: transform 0.1s, box-shadow 0.15s;
    touch-action: pan-y;
    position: relative;
}
.kanban-card:active { transform: scale(0.97); }
.kanban-card.drag-source { opacity: 0.3; }
.kanban-card .kc-title { font-size: 13px; font-weight: 600; line-height: 1.3; }
.kanban-card .kc-row { display: flex; align-items: center; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.kanban-card .kc-tag {
    font-size: 10px; padding: 2px 6px; border-radius: 6px;
    background: var(--secondary-bg); color: var(--hint);
}
.kanban-card .kc-avatar {
    width: 20px; height: 20px; border-radius: 50%;
    background: var(--btn); color: var(--btn-text);
    font-size: 10px; font-weight: 600;
    display: flex; align-items: center; justify-content: center;
}
.kanban-card .kc-comments { font-size: 10px; color: var(--hint); }

.drag-clone {
    position: fixed; z-index: 200; pointer-events: none;
    opacity: 0.9; transform: rotate(2deg) scale(1.03);
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    max-width: 260px;
}

/* Urgency border colors */
.urg-border-critical { border-left-color: var(--urg-critical); }
.urg-border-fast { border-left-color: var(--urg-fast); }
.urg-border-medium { border-left-color: var(--urg-medium); }
.urg-border-low { border-left-color: var(--urg-low); }

/* Column colors */
.col-new { background: #b4b2a9; }
.col-in_progress { background: #2AABEE; }
.col-review { background: #ef9f27; }
.col-done { background: #1d9e75; }

/* ═══ Task List ═══ */
.task-list { display: flex; flex-direction: column; gap: 6px; }
.task-card {
    background: var(--secondary-bg); border-radius: var(--radius-sm);
    padding: 10px 12px; display: flex; align-items: center; gap: 10px;
    cursor: pointer; border-left: 4px solid var(--hint);
}
.task-card:active { transform: scale(0.98); }
.task-card .tc-info { flex: 1; min-width: 0; }
.task-card .tc-title { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-card .tc-meta { font-size: 11px; color: var(--hint); margin-top: 2px; }
.task-card .tc-meta span { margin-right: 8px; }
.task-card.done .tc-title { text-decoration: line-through; color: var(--hint); }

/* ═══ Forms ═══ */
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 12px; color: var(--hint); margin-bottom: 4px; font-weight: 500; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
    border: 1px solid var(--secondary-bg); background: var(--secondary-bg);
    color: var(--text); font-size: 14px; outline: none; font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--btn);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Urgency selector */
.urgency-selector { display: flex; gap: 4px; }
.urg-btn {
    flex: 1; padding: 6px 4px; border-radius: var(--radius-sm);
    border: 1.5px solid var(--secondary-bg); background: var(--secondary-bg);
    color: var(--text); font-size: 11px; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 3px;
}
.urg-btn.active { border-color: var(--btn); background: var(--btn); color: var(--btn-text); }
.urg-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.urg-dot.critical { background: var(--urg-critical); }
.urg-dot.fast { background: var(--urg-fast); }
.urg-dot.medium { background: var(--urg-medium); }
.urg-dot.low { background: var(--urg-low); }

/* Status selector */
.status-selector { display: flex; gap: 4px; }
.st-btn {
    flex: 1; padding: 6px 4px; border-radius: var(--radius-sm);
    border: 1.5px solid var(--secondary-bg); background: var(--secondary-bg);
    color: var(--text); font-size: 11px; cursor: pointer; text-align: center;
}
.st-btn.active { border-color: var(--btn); background: var(--btn); color: var(--btn-text); }

.btn-primary {
    width: 100%; padding: 12px; border: none; border-radius: var(--radius);
    background: var(--btn); color: var(--btn-text);
    font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn-primary:active { opacity: 0.8; }
.btn-danger {
    width: 100%; padding: 12px; border: none; border-radius: var(--radius);
    background: #e24b4a; color: #fff;
    font-size: 15px; font-weight: 600; cursor: pointer;
}
.form-actions { display: flex; gap: 8px; margin-top: 8px; }
.form-actions .btn-primary, .form-actions .btn-danger { flex: 1; }

/* ═══ Modal ═══ */
.modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    z-index: 100; display: flex; align-items: flex-end;
}
.modal-backdrop {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
}
.modal-content {
    position: relative; width: 100%; background: var(--bg);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 16px; max-height: 90vh; overflow-y: auto;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-header h3 { font-size: 18px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 22px; color: var(--hint); cursor: pointer; padding: 4px; }

/* ═══ Comments ═══ */
.comments-section { margin-top: 16px; border-top: 1px solid var(--secondary-bg); padding-top: 12px; }
.comment-item { margin-bottom: 10px; }
.comment-item .cm-header { font-size: 11px; color: var(--hint); margin-bottom: 2px; }
.comment-item .cm-header b { color: var(--text); }
.comment-item .cm-text { font-size: 13px; line-height: 1.4; }
.comment-input { display: flex; gap: 6px; margin-top: 8px; }
.comment-input input {
    flex: 1; padding: 8px 12px; border-radius: 20px;
    border: 1px solid var(--secondary-bg); background: var(--secondary-bg);
    color: var(--text); font-size: 13px; outline: none;
}
.comment-input input:focus { border-color: var(--btn); }
.comment-input button {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--btn); color: var(--btn-text);
    border: none; font-size: 16px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}

/* ═══ Bottom Nav ═══ */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--section-bg); border-top: 0.5px solid var(--secondary-bg);
    display: flex; justify-content: space-around; padding: 6px 0 env(safe-area-inset-bottom, 8px);
    z-index: 50;
}
.nav-btn {
    display: flex; flex-direction: column; align-items: center;
    background: none; border: none; padding: 4px 8px; cursor: pointer; min-width: 50px;
}
.nav-icon { font-size: 20px; }
.nav-label { font-size: 10px; color: var(--hint); margin-top: 2px; }
.nav-btn.active .nav-label { color: var(--btn); font-weight: 600; }

.empty-state { text-align: center; color: var(--hint); padding: 40px 20px; font-size: 14px; }
