* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

@media (prefers-reduced-motion: no-preference) {
    * {
        scroll-behavior: smooth;
    }
}

:root {
    --bg-primary: #f5f7fa;
    --bg-secondary: #ffffff;
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --accent: #667eea;
    --success: #48bb78;
    --danger: #f56565;
    --shadow: rgba(0, 0, 0, 0.1);
    --border: #e2e8f0;
}

[data-theme="dark"] {
    --bg-primary: #1a202c;
    --bg-secondary: #2d3748;
    --text-primary: #f7fafc;
    --text-secondary: #a0aec0;
    --shadow: rgba(0, 0, 0, 0.3);
    --border: #4a5568;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    transition: background 0.4s cubic-bezier(0.4, 0, 0.2, 1), color 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-tap-highlight-color: transparent;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    padding-bottom: 100px;
    min-height: 100vh;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.header-title svg {
    flex-shrink: 0;
}

.list-title-input {
    font-size: 28px;
    font-weight: 700;
    border: none;
    background: transparent;
    color: var(--text-primary);
    outline: none;
    padding: 4px 8px;
    border-radius: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex: 1;
    min-width: 0;
}

.list-title-input:hover {
    background: var(--bg-primary);
}

.list-title-input:focus {
    background: var(--bg-primary);
    box-shadow: 0 0 0 2px var(--accent);
}

.theme-toggle {
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 12px;
    width: 48px;
    height: 48px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.theme-toggle svg {
    position: absolute;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-toggle .icon-sun {
    opacity: 0;
    transform: rotate(180deg) scale(0);
}

[data-theme="dark"] .theme-toggle .icon-moon {
    opacity: 0;
    transform: rotate(-180deg) scale(0);
}

[data-theme="dark"] .theme-toggle .icon-sun {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

.theme-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px var(--shadow);
}

.theme-toggle:active {
    transform: scale(0.95);
}

.input-section {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

#itemInput {
    flex: 1;
    padding: 16px 20px;
    font-size: 16px;
    border: 2px solid var(--border);
    border-radius: 16px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px var(--shadow);
}

#itemInput:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 4px 12px var(--shadow);
    transform: translateY(-2px);
}

#addBtn {
    width: 56px;
    height: 56px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

#addBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

#addBtn:active {
    transform: scale(0.95);
}

#addBtn svg {
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#addBtn:hover svg {
    transform: rotate(90deg);
}

.item-list {
    list-style: none;
}

.item {
    position: relative;
    background: var(--bg-secondary);
    border-radius: 16px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px var(--shadow);
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    touch-action: pan-y;
}

.item:hover {
    box-shadow: 0 4px 12px var(--shadow);
}

.item-background {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.item-background svg {
    width: 32px;
    height: 32px;
    stroke-width: 2.5;
}

.item-background.swipe-right {
    background: var(--success);
    color: white;
}

.item-background.swipe-left {
    background: var(--danger);
    color: white;
}

.item-background.swipe-delete {
    background: linear-gradient(90deg, transparent, rgba(139, 92, 246, 0.15));
    color: #8b5cf6;
}

.item-content {
    position: relative;
    display: flex;
    align-items: center;
    padding: 20px;
    gap: 16px;
    background: var(--bg-secondary);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: grab;
    will-change: transform;
}

.item-content:active {
    cursor: grabbing;
}

.item.dragging {
    opacity: 1;
    transform: scale(1.08);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
    z-index: 1000;
    position: relative;
}

.item.drag-over {
    border-top: 3px solid var(--accent);
}

.item-list.dragging-active .item:not(.dragging) {
    filter: blur(2px);
    opacity: 0.6;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.checkbox-wrapper {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: 3px solid var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
}

.checkbox-wrapper:hover {
    border-color: var(--success);
    transform: scale(1.1);
}

.item.completed .checkbox-wrapper {
    background: var(--success);
    border-color: var(--success);
}

.checkbox-wrapper svg {
    position: absolute;
    width: 18px;
    height: 18px;
    stroke: white;
    stroke-width: 3;
    opacity: 0;
    transform: scale(0) rotate(-90deg);
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.item.completed .checkbox-wrapper svg {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

.item-text {
    flex: 1;
    font-size: 16px;
    line-height: 1.5;
    word-break: break-word;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.item.completed .item-text {
    text-decoration: line-through;
    opacity: 0.5;
}

.drag-handle {
    flex-shrink: 0;
    color: var(--text-secondary);
    cursor: grab;
    padding: 8px;
    margin: -8px;
    touch-action: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.drag-handle svg {
    width: 20px;
    height: 20px;
    stroke-width: 2;
}

.drag-handle:hover {
    color: var(--accent);
    transform: scale(1.2);
}

.drag-handle:active {
    cursor: grabbing;
}

.stats {
    display: flex;
    justify-content: space-between;
    margin-top: 24px;
    padding: 16px 20px;
    background: var(--bg-secondary);
    border-radius: 16px;
    box-shadow: 0 2px 8px var(--shadow);
    font-size: 14px;
    color: var(--text-secondary);
}

@media (max-width: 480px) {
    .container {
        padding: 16px;
    }
    
    h1 {
        font-size: 24px;
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes slideOut {
    from {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateX(-100%) scale(0.8);
    }
}

.item {
    animation: slideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.item.removing {
    animation: slideOut 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 8px 0;
    box-shadow: 0 -4px 12px var(--shadow);
    z-index: 100;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 12px;
    margin: 0 4px;
}

.nav-item svg {
    width: 24px;
    height: 24px;
    stroke-width: 2;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item span {
    font-size: 12px;
    font-weight: 500;
}

.nav-item:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.nav-item.active {
    color: var(--accent);
}

.nav-item.active svg {
    transform: scale(1.1);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 20px;
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal.active .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 24px;
    font-weight: 700;
}

.modal-close {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-close svg {
    width: 20px;
    height: 20px;
}

.modal-close:hover {
    background: var(--danger);
    color: white;
    transform: rotate(90deg);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.save-current-btn {
    width: 100%;
    padding: 16px 20px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 20px;
}

.save-current-btn svg {
    width: 20px;
    height: 20px;
}

.save-current-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.save-current-btn:active {
    transform: scale(0.98);
}

.saved-lists {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.saved-list-item {
    background: var(--bg-primary);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.saved-list-item:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 12px var(--shadow);
}

.saved-list-info {
    flex: 1;
}

.saved-list-name {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 4px;
}

.saved-list-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

.saved-list-actions {
    display: flex;
    gap: 8px;
}

.saved-list-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.saved-list-btn svg {
    width: 18px;
    height: 18px;
}

.saved-list-btn:hover {
    transform: scale(1.1);
}

.saved-list-btn.delete:hover {
    background: var(--danger);
    color: white;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state p {
    font-size: 16px;
}
