:root {
    --bg-work: linear-gradient(135deg, #1e0b11 0%, #0f081d 100%);
    --bg-short: linear-gradient(135deg, #0b1e14 0%, #08171d 100%);
    --bg-long: linear-gradient(135deg, #0b151e 0%, #080d1d 100%);
    
    --color-work-start: #ff416c;
    --color-work-end: #ff4b2b;
    --color-short-start: #11998e;
    --color-short-end: #38ef7d;
    --color-long-start: #00c6ff;
    --color-long-end: #0072ff;
    
    --grad-start: var(--color-work-start);
    --grad-end: var(--color-work-end);
    
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-hover: rgba(255, 255, 255, 0.06);
    --text: #ffffff;
    --text-dim: rgba(255, 255, 255, 0.4);
    --text-muted: rgba(255, 255, 255, 0.55);
    --panel-width: 360px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    margin: 0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg-work);
    color: var(--text);
    transition: background 1s ease;
    overflow-x: hidden;
    padding: 20px;
}

/* Thèmes dynamiques */
body.mode-work { background: var(--bg-work); --grad-start: var(--color-work-start); --grad-end: var(--color-work-end); }
body.mode-short { background: var(--bg-short); --grad-start: var(--color-short-start); --grad-end: var(--color-short-end); }
body.mode-long { background: var(--bg-long); --grad-start: var(--color-long-start); --grad-end: var(--color-long-end); }

.grad-start { stop-color: var(--grad-start); transition: stop-color 1s; }
.grad-end { stop-color: var(--grad-end); transition: stop-color 1s; }

/* ===== Layout ===== */
.app-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    max-width: 900px;
    width: 100%;
    animation: fadeIn 1s ease-out;
    justify-content: center;
}

/* ===== Side Panel ===== */
.side-panel {
    width: var(--panel-width);
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    flex-shrink: 0;
}

/* ===== Task Header ===== */
.task-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--glass-border);
}

.task-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: 0.3px;
    color: var(--text);
}

.task-title svg {
    opacity: 0.7;
}

.task-badge {
    background: var(--glass-border);
    border-radius: 10px;
    padding: 0px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

.task-collapse-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 4px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.task-collapse-btn:hover {
    background: var(--glass-hover);
    color: var(--text);
}

.task-collapse-btn svg {
    transition: transform 0.3s ease;
}

/* ===== Task Body (collapsible) ===== */
.task-body {
    padding: 0;
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.4s ease, padding 0.3s ease;
}

.task-body.collapsed {
    max-height: 0;
    padding: 0;
}

/* ===== Task Stats ===== */
.task-stats {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 20px 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.stat-sep {
    opacity: 0.3;
}

/* ===== Task List ===== */
.task-list {
    list-style: none;
    margin: 0;
    padding: 4px 12px;
    max-height: 300px;
    overflow-y: auto;
}

.task-list::-webkit-scrollbar {
    width: 4px;
}

.task-list::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 4px;
}

.task-empty {
    text-align: center;
    padding: 24px 16px;
    color: var(--text-dim);
    font-size: 0.85rem;
    font-weight: 400;
}

/* ===== Task Item ===== */
.task-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 8px;
    border-radius: 12px;
    transition: all 0.3s ease;
    animation: taskSlideIn 0.3s ease-out;
}

.task-item:hover {
    background: var(--glass-hover);
}

.task-item.completed {
    opacity: 0.5;
}

.task-item.completed .task-text {
    text-decoration: line-through;
    text-decoration-color: rgba(255,255,255,0.2);
}

@keyframes taskSlideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Check button */
.task-check {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 2px;
    flex-shrink: 0;
    margin-top: 1px;
    transition: all 0.3s;
    border-radius: 50%;
}

.task-check:hover {
    color: var(--text);
}

.task-item.completed .task-check {
    color: var(--color-short-start);
}

/* Task content */
.task-content {
    flex: 1;
    min-width: 0;
}

.task-text {
    font-size: 0.88rem;
    font-weight: 500;
    display: block;
    word-break: break-word;
}

/* Pomodoro bar */
.task-pomodoro-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}

.task-pomodoro-label {
    font-size: 0.7rem;
    color: var(--text-dim);
    flex-shrink: 0;
    min-width: 52px;
}

.task-progress-track {
    flex: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 4px;
    overflow: hidden;
}

.task-progress-fill {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--grad-start), var(--grad-end));
    transition: width 0.5s ease;
}

/* Delete button */
.task-delete {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 4px;
    border-radius: 8px;
    flex-shrink: 0;
    opacity: 0;
    transition: all 0.3s;
}

.task-item:hover .task-delete {
    opacity: 0.7;
}

.task-delete:hover {
    color: #ff416c;
    opacity: 1 !important;
    background: rgba(255, 65, 108, 0.1);
}

/* ===== Task Add Form ===== */
.task-add-form {
    padding: 8px 12px 12px;
}

.task-input-group {
    display: flex;
    gap: 6px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    padding: 4px;
    transition: border-color 0.3s;
}

.task-input-group:focus-within {
    border-color: rgba(255, 255, 255, 0.2);
}

.task-input {
    flex: 1;
    background: none;
    border: none;
    padding: 8px 10px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.88rem;
    color: var(--text);
    outline: none;
    min-width: 0;
}

.task-input::placeholder {
    color: var(--text-dim);
    font-weight: 300;
}

.task-pomodoro-input {
    width: 48px;
    background: none;
    border: none;
    padding: 8px 2px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.82rem;
    color: var(--text-dim);
    text-align: center;
    outline: none;
    border-left: 1px solid var(--glass-border);
}

.task-pomodoro-input::-webkit-inner-spin-button,
.task-pomodoro-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.task-pomodoro-input::placeholder {
    color: var(--text-dim);
}

.task-add-btn {
    background: linear-gradient(135deg, var(--grad-start), var(--grad-end));
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.3s;
}

.task-add-btn svg {
    pointer-events: none;
}

.task-add-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(255, 65, 108, 0.3);
}

/* ===== Timer (unchanged) ===== */
.glass-container {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    padding: 3rem;
    border-radius: 30px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    text-align: center;
    width: 320px;
    flex-shrink: 0;
}

.modes {
    display: flex;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.03);
    padding: 6px;
    border-radius: 15px;
    margin-bottom: 2.5rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.mode-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    padding: 8px 16px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.mode-btn.active {
    background: var(--glass-border);
    color: #fff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.timer-wrapper {
    position: relative;
    width: 280px;
    height: 280px;
    margin: 0 auto 2.5rem;
}

.progress-ring {
    transform: rotate(-90deg);
}

.progress-ring__circle {
    transition: stroke-dashoffset 0.3s linear;
    stroke-linecap: round;
}

.timer-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
}

#timer {
    font-size: 4.2rem;
    font-weight: 800;
    letter-spacing: -2px;
}

#status-text {
    font-size: 0.75rem;
    letter-spacing: 4px;
    color: rgba(255, 255, 255, 0.4);
    margin-top: -5px;
    text-transform: uppercase;
    font-weight: 600;
}

.controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    align-items: center;
}

.btn-primary {
    background: linear-gradient(135deg, var(--grad-start), var(--grad-end));
    border: none;
    color: white;
    padding: 15px 40px;
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: 2px;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.3);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-primary:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 15px 30px -5px rgba(255, 65, 108, 0.4);
}

.btn-secondary {
    background: var(--glass-border);
    border: none;
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: rotate(45deg);
}

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

/* ===== Drag & Drop ===== */

/* Poignée de drag */
.task-drag-handle {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: grab;
    padding: 4px 2px;
    border-radius: 6px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s;
    margin-top: 1px;
}

.task-item:hover .task-drag-handle {
    opacity: 0.5;
}

.task-drag-handle:hover {
    opacity: 1 !important;
    color: var(--text);
}

.task-drag-handle svg {
    pointer-events: none;
}

/* État dragging */
.task-item.dragging {
    opacity: 0.4;
    background: rgba(255, 255, 255, 0.05);
}

/* Indicateurs de drop */
.task-item.drag-over-up {
    border-top: 2px solid var(--color-work-start);
}
.task-item.drag-over-down {
    border-bottom: 2px solid var(--color-work-start);
}

/* Boutons ↑↓ mobiles */
.task-mobile-moves {
    display: none;
    flex-direction: column;
    gap: 1px;
    flex-shrink: 0;
    margin-top: 1px;
}

.task-move-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.task-move-btn:hover:not(.disabled) {
    color: var(--text);
    background: var(--glass-hover);
}

.task-move-btn.disabled {
    opacity: 0.2;
    cursor: default;
}

.task-move-btn svg {
    pointer-events: none;
}

/* Sur mobile : on cache la poignée et on affiche ↑↓ */
@media (max-width: 768px) {
    .task-drag-handle {
        display: none;
    }
    .task-mobile-moves {
        display: flex;
    }
}

/* ===== Responsive mobile ===== */
@media (max-width: 768px) {
    body {
        padding: 12px;
        align-items: flex-start;
        padding-top: 20px;
        overflow-y: auto;
    }

    .app-layout {
        flex-direction: column-reverse;
        align-items: stretch;
        gap: 16px;
    }

    .glass-container {
        width: 100%;
        padding: 2rem 1.5rem;
    }

    .timer-wrapper {
        width: 220px;
        height: 220px;
        margin-bottom: 1.5rem;
    }

    .timer-wrapper svg {
        width: 220px;
        height: 220px;
    }

    .timer-wrapper .progress-ring__circle,
    .timer-wrapper .progress-ring__circle-bg {
        r: 92;
        cx: 110;
        cy: 110;
    }

    #timer {
        font-size: 3.4rem;
    }

    .side-panel {
        width: 100%;
    }

    .task-list {
        max-height: 240px;
    }
}

@media (max-width: 480px) {
    .glass-container {
        padding: 1.5rem 1rem;
    }

    .timer-wrapper {
        width: 180px;
        height: 180px;
    }

    .timer-wrapper svg {
        width: 180px;
        height: 180px;
    }

    .timer-wrapper .progress-ring__circle,
    .timer-wrapper .progress-ring__circle-bg {
        r: 72;
        cx: 90;
        cy: 90;
    }

    #timer {
        font-size: 2.8rem;
    }

    .btn-primary {
        padding: 12px 30px;
        font-size: 0.85rem;
    }
}
