:root {
    --color-primary: #6366f1;
    --color-primary-dark: #4f46e5;
    --color-secondary: #10b981;
    --color-danger: #ef4444;
    --color-text: #1f2937;
    --color-text-light: #6b7280;
    --color-bg: #f9fafb;
    --color-surface: #ffffff;
    --color-border: #e5e7eb;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
    --radius: 16px;
    --radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    touch-action: pan-y;
}

#app {
    max-width: 800px;
    margin: 0 auto;
    min-height: 100vh;
    position: relative;
}

/* =============== VIEWS =============== */
.view {
    display: none;
    flex-direction: column;
    min-height: 100vh;
    opacity: 0;
    transform: translateX(20px);
}

.view.active {
    display: flex;
    animation: slideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes slideIn {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* =============== HEADER =============== */
.app-header {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    flex: 1;
}

.app-header h2 {
    font-size: 20px;
    font-weight: 600;
    flex: 1;
    border: none;
    background: transparent;
    color: white;
    outline: none;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.app-header h2:focus {
    background: rgba(255, 255, 255, 0.15);
}

/* =============== BUTTONS =============== */
.btn-primary, .btn-secondary, .btn-icon {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
    touch-action: manipulation;
}

.btn-primary {
    background: white;
    color: var(--color-primary);
    box-shadow: var(--shadow-sm);
}

.btn-primary:active {
    transform: scale(0.96);
    box-shadow: none;
}

.btn-secondary {
    background: var(--color-border);
    color: var(--color-text);
}

.btn-secondary:active {
    transform: scale(0.96);
}

.btn-icon {
    padding: 10px;
    color: white;
}

.btn-icon:active {
    background: rgba(255, 255, 255, 0.2);
}

/* =============== LISTS CONTAINER =============== */
.lists-vertical-container {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.lists-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.list-item {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 20px 24px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-left: 4px solid transparent;
    animation: listAppear 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}

.list-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.list-item.drag-over {
    border-top: 3px solid var(--color-primary);
}

.list-drag-handle {
    cursor: grab;
    padding: 8px;
    margin-left: -8px;
    margin-right: 8px;
    color: var(--color-text-light);
    transition: var(--transition);
    touch-action: none;
}

.list-drag-handle:hover {
    color: var(--color-primary);
}

.list-drag-handle:active {
    cursor: grabbing;
}

.list-drag-handle svg {
    display: block;
}

@keyframes listAppear {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.list-item:hover {
    border-left-color: var(--color-primary);
    box-shadow: var(--shadow-md);
    transform: translateX(4px);
}

.list-item:active {
    transform: translateX(4px) scale(0.98);
}

.list-item-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.list-item-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text);
}

.list-item-count {
    font-size: 14px;
    color: var(--color-text-light);
    display: flex;
    align-items: center;
    gap: 6px;
}

.list-item-count svg {
    width: 16px;
    height: 16px;
}

.list-item-arrow {
    color: var(--color-text-light);
    transition: var(--transition);
}

.list-item:hover .list-item-arrow {
    color: var(--color-primary);
    transform: translateX(4px);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    text-align: center;
    padding: 60px 20px;
    color: var(--color-text-light);
}

.empty-state svg {
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 24px;
    font-weight: 600;
    color: var(--color-text);
    margin: 0;
}

.empty-state p {
    font-size: 16px;
    margin: 0;
}

.lists-container {
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    flex: 1;
}

.list-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: var(--transition);
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
}

.list-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
    opacity: 0;
    transition: var(--transition);
}

.list-card:active {
    transform: scale(0.98);
}

.list-card:hover::before,
.list-card:focus::before {
    opacity: 1;
}

.list-card h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.list-card .task-count {
    font-size: 14px;
    color: var(--color-text-light);
}

/* =============== TASKS VIEW =============== */
.tasks-container {
    flex: 1;
    padding: 20px;
}

.add-task-form {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    background: var(--color-surface);
    padding: 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

#new-task-input {
    flex: 1;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: 16px;
    transition: var(--transition);
    outline: none;
}

#new-task-input:focus {
    border-color: var(--color-primary);
}

.tasks-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tasks-separator {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 24px 0;
    padding: 0 8px;
}

.separator-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--color-border), transparent);
}

.separator-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    padding: 8px 16px;
    background: var(--color-bg);
    border-radius: 20px;
    border: 1px solid var(--color-border);
}

.separator-text svg {
    flex-shrink: 0;
}

.task-item {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: var(--transition);
    animation: taskAppear 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

.task-checkbox {
    width: 24px;
    height: 24px;
    border: 2px solid var(--color-border);
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
    position: relative;
}

.task-checkbox:active {
    transform: scale(0.9);
}

.task-item.completed .task-checkbox {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.task-item.completed .task-checkbox::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
}

.task-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.task-text {
    font-size: 16px;
    color: var(--color-text);
    outline: none;
    padding: 4px 8px;
    margin: -4px -8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    cursor: text;
    word-break: break-word;
}

.task-text:hover {
    background: rgba(0, 0, 0, 0.02);
}

.task-text:focus {
    background: var(--color-bg);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
    cursor: text;
}

.task-item.completed .task-text {
    text-decoration: line-through;
    color: var(--color-text-light);
}

.task-item.completed .task-text:focus {
    text-decoration: none;
}

.task-photo {
    max-width: 100%;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.task-photo:active {
    transform: scale(0.98);
}

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

.task-btn {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    color: var(--color-text-light);
}

.task-btn:active {
    transform: scale(0.9);
    background: var(--color-border);
}

/* =============== PHOTO EDITOR =============== */
.photo-editor-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 20px;
}

.canvas-wrapper {
    flex: 1;
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
}

#photo-canvas {
    max-width: 100%;
    max-height: 100%;
    display: block;
    touch-action: none;
}

.drawing-controls {
    background: var(--color-surface);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 16px;
}

#pen-color {
    width: 50px;
    height: 50px;
    border: 3px solid var(--color-border);
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
}

#pen-color:active {
    transform: scale(0.95);
}

#pen-size {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    border-radius: 4px;
    background: var(--color-border);
    outline: none;
}

#pen-size::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
    transition: var(--transition);
}

#pen-size::-webkit-slider-thumb:active {
    transform: scale(1.2);
}

#pen-size::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
    border: none;
}

/* =============== RESPONSIVE =============== */
@media (max-width: 640px) {
    .lists-container {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
        padding: 16px;
    }
    
    .app-header h1 {
        font-size: 24px;
    }
    
    .btn-primary .btn-text {
        display: none;
    }
    
    .lists-vertical-container {
        padding: 16px;
    }
    
    .list-item {
        padding: 16px 20px;
    }
    
    .list-item-name {
        font-size: 16px;
    }
    
    .list-item-count {
        font-size: 13px;
    }
    
    .tasks-separator {
        margin: 16px 0;
        gap: 12px;
    }
    
    .separator-text {
        font-size: 12px;
        padding: 6px 12px;
    }
    
    .separator-line {
        min-width: 20px;
    }
}

/* =============== LOADING =============== */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--color-text-light);
}

.loading::after {
    content: '';
    width: 40px;
    height: 40px;
    border: 4px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
