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

:root {
    --bg: #202124;
    --surface: #292a2d;
    --surface2: #35363a;
    --border: #3c4043;
    --text: #e8eaed;
    --text2: #9aa0a6;
    --accent: #8ab4f8;
    --accent-dim: rgba(138,180,248,0.08);
    --yellow: #fdd663;
    --red: #f28b82;
}

html, body { height: 100%; overscroll-behavior: none; }

body {
    font-family: 'Google Sans', Roboto, -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.4;
    -webkit-tap-highlight-color: transparent;
}

.tasks-app { max-width: 600px; margin: 0 auto; min-height: 100dvh; }

/* ─── Header ─── */
.tasks-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 16px 8px; border-bottom: 1px solid var(--border);
}
.tasks-header h1 { font-size: 18px; font-weight: 500; }
.header-actions {
    display: flex; align-items: center; gap: 8px;
}

.header-actions select {
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    padding: 5px 28px 5px 10px; color: var(--text2); font-size: 11px; font-family: inherit;
    height: 30px;
    appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239aa0a6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    cursor: pointer;
}

/* Live toggle */
.live-toggle {
    display: flex; align-items: center; gap: 6px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    padding: 5px 10px; color: var(--text2); font-size: 11px; font-weight: 600;
    font-family: inherit; cursor: pointer; text-transform: uppercase; letter-spacing: 0.5px;
    transition: all 0.2s; height: 30px;
}
.live-toggle:hover { border-color: var(--text2); }
.live-toggle.on { border-color: #ef4444; color: #ef4444; background: rgba(239,68,68,0.08); }

.live-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--text2); transition: background 0.2s;
}
.live-toggle.on .live-dot {
    background: #ef4444;
    animation: live-pulse 1.5s ease-in-out infinite;
}

@keyframes live-pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
    50% { opacity: 0.7; box-shadow: 0 0 0 4px rgba(239,68,68,0); }
}

/* ─── Add task ─── */
.add-task { padding: 4px 8px; border-bottom: 1px solid var(--border); }
.add-task-btn {
    display: flex; align-items: center; gap: 12px; width: 100%;
    padding: 12px 8px; background: none; border: none; color: var(--accent);
    font-size: 14px; font-family: inherit; cursor: pointer; border-radius: 8px;
}
.add-task-btn:hover { background: var(--accent-dim); }

.add-form { padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface); }
.add-form-row { display: flex; align-items: center; gap: 12px; }
.add-form-row input {
    flex: 1; background: none; border: none; color: var(--text);
    font-size: 14px; font-family: inherit; outline: none; padding: 8px 0;
}
.add-form-details { padding-left: 36px; }
.add-form-details input, .add-form-details select {
    background: none; border: none; border-bottom: 1px solid var(--border);
    color: var(--text2); font-size: 13px; font-family: inherit; padding: 6px 0; width: 100%; outline: none;
}
.add-form-details input:focus, .add-form-details select:focus { border-bottom-color: var(--accent); color: var(--text); }
.add-form-meta { display: flex; gap: 8px; margin-top: 8px; }
.add-form-meta input, .add-form-meta select { flex: 1; min-width: 0; }
.add-form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* ─── Task row ─── */
.task-row {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 14px 16px; border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}
.task-row:hover { background: var(--accent-dim); }

/* Checkbox */
.task-check {
    width: 24px; height: 24px; flex-shrink: 0; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--text2); transition: color 0.15s; margin-top: 1px;
}
.task-check:hover { color: var(--accent); }
.task-check svg { width: 24px; height: 24px; }
.task-check.checked { color: var(--accent); }

/* Middle (title + desc) */
.task-mid { flex: 1; min-width: 0; cursor: text; }

.task-title {
    font-size: 14px; color: var(--text); word-break: break-word;
    outline: none; border-radius: 4px; padding: 2px 4px; margin: -2px -4px;
}
.task-title.editing {
    background: var(--surface2);
    box-shadow: 0 0 0 1px var(--accent);
}

.task-row.done .task-title { text-decoration: line-through; color: var(--text2); }

.task-desc {
    font-size: 12px; color: var(--text2); margin-top: 2px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    outline: none; border-radius: 4px; padding: 2px 4px; margin-left: -4px;
    cursor: text;
}
.task-desc-placeholder {
    color: var(--text2);
    opacity: 0.4;
    font-style: italic;
}

.task-desc.editing {
    background: var(--surface2);
    box-shadow: 0 0 0 1px var(--accent);
    white-space: pre-wrap;
    overflow: visible;
}

.task-desc-edit {
    width: 100%;
    background: var(--surface2);
    border: none;
    box-shadow: 0 0 0 1px var(--accent);
    border-radius: 4px;
    color: var(--text);
    font-size: 12px;
    font-family: inherit;
    padding: 6px 8px;
    margin-top: 2px;
    margin-left: -4px;
    line-height: 1.5;
    resize: none;
    overflow: hidden;
    outline: none;
}

.task-chips { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.task-chip { font-size: 11px; color: var(--text2); background: var(--surface2); padding: 1px 6px; border-radius: 4px; }
.task-chip.overdue { color: var(--red); }
.task-chip.cat { color: var(--accent); }

/* Star */
.task-star {
    background: none; border: none; color: var(--text2); cursor: pointer;
    padding: 4px; flex-shrink: 0; line-height: 0; transition: color 0.15s;
}
.task-star svg { width: 20px; height: 20px; }
.task-star:hover { color: var(--yellow); }
.task-star.on { color: var(--yellow); }

/* ─── Drag ─── */
.task-row.dragging { opacity: 0.3; }
.task-row.drag-over { border-top: 2px solid var(--accent); }

/* ─── Completed ─── */
.completed-section { border-top: 1px solid var(--border); }
.completed-toggle {
    display: flex; align-items: center; gap: 4px; width: 100%;
    padding: 12px 16px; background: none; border: none; color: var(--text2);
    font-size: 13px; font-family: inherit; cursor: pointer; text-align: left;
}
.completed-toggle:hover { background: var(--accent-dim); }
.toggle-arrow { transition: transform 0.2s; }
.toggle-arrow.open { transform: rotate(90deg); }
.completed-list .task-row { opacity: 0.6; }

/* ─── Buttons ─── */
.text-btn {
    background: none; border: none; color: var(--text2); font-size: 13px;
    font-family: inherit; cursor: pointer; padding: 8px 16px; border-radius: 4px;
}
.text-btn:hover { background: var(--surface2); }
.text-btn.primary { color: var(--accent); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text2); }

@media (max-width: 640px) {
    .add-form-meta { flex-direction: column; }
}
