:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #38bdf8;
    --accent-hover: #0ea5e9;
    --danger-color: #ef4444;
    --success-color: #22c55e;
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 1rem;
    background-image:
        radial-gradient(circle at 10% 20%, rgba(56, 189, 248, 0.1) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(168, 85, 247, 0.1) 0%, transparent 20%);
}

.container {
    width: 100%;
    max-width: 1200px;
}

header {
    text-align: center;
    margin-bottom: 1.5rem;
    animation: fadeInDown 0.8s ease-out;
}

h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 600;
    background: linear-gradient(to right, #38bdf8, #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: clamp(0.9rem, 2vw, 1.1rem);
}

/* Input Section (Primary) */
.input-section {
    display: flex;
    gap: 1rem;
    max-width: 600px;
    margin: 0 auto 1.5rem;
    animation: fadeInUp 0.8s ease-out 0.2s backwards;
}

textarea {
    flex: 1;
    background: var(--card-bg);
    border: var(--glass-border);
    padding: 1rem 1.5rem;
    border-radius: 1rem;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    resize: none;
    min-height: 3.5rem;
    line-height: 1.5;
}

textarea:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

#add-btn {
    background: var(--accent-color);
    border: none;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 1rem;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

#add-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3);
}

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 600px;
    margin: 0 auto 1rem;
    animation: fadeInUp 0.8s ease-out 0.3s backwards;
    padding: 0 0.5rem;
}

.filter-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.stat-chip {
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 2rem;
    padding: 0.4rem 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.stat-chip:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.stat-chip.active {
    border-width: 1px;
    font-weight: 600;
}

.stat-all.active {
    border-color: #38bdf8;
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.1);
}

.stat-pending.active {
    border-color: #f59e0b;
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.1);
}

.stat-completed.active {
    border-color: #22c55e;
    color: #22c55e;
    background: rgba(34, 197, 94, 0.1);
}

.chip-count {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 1rem;
    padding: 0.1rem 0.4rem;
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 1.2rem;
    text-align: center;
}

.stat-chip.active .chip-count {
    background: currentColor;
    color: var(--bg-color);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover,
.icon-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--accent-color);
}

/* Search Panel */
.search-panel {
    max-width: 600px;
    margin: 0 auto 1.5rem;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-panel.visible {
    max-height: 300px;
    opacity: 1;
    margin-bottom: 2rem;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--card-bg);
    border: var(--glass-border);
    border-radius: 1rem;
    padding: 0.75rem 1rem;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.search-box:focus-within {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.search-icon {
    color: var(--text-secondary);
    margin-right: 0.75rem;
    flex-shrink: 0;
}

#search-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    font-family: 'Outfit', sans-serif;
}

#search-input::placeholder {
    color: var(--text-secondary);
}

.clear-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.clear-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* Hashtag Cloud */
.hashtag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
    min-height: 0;
    transition: all 0.3s ease;
    justify-content: center;
}

.hashtag-cloud:empty {
    display: none;
}

.hashtag-chip {
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: 1rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
    color: #38bdf8;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.hashtag-chip:hover {
    background: rgba(56, 189, 248, 0.2);
    transform: translateY(-1px);
}

.hashtag-chip.active {
    background: #38bdf8;
    color: var(--bg-color);
    font-weight: 600;
}

.hashtag-count {
    font-size: 0.75rem;
    opacity: 0.8;
}

/* Todo Grid */
.todo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
    gap: 1.5rem;
    animation: fadeInUp 0.8s ease-out 0.4s backwards;
}

.todo-card {
    background: var(--card-bg);
    border: var(--glass-border);
    border-radius: 1.5rem;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    min-height: 180px;
    max-height: 350px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    position: relative;
    cursor: grab;
}

.todo-card.hidden {
    display: none;
}

.todo-card:active {
    cursor: grabbing;
}

.todo-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.2);
}

.todo-card.completed {
    opacity: 0.8;
    background: rgba(15, 23, 42, 0.6);
    border-color: rgba(34, 197, 94, 0.3);
}

.todo-card:not(.completed) {
    border-color: rgba(56, 189, 248, 0.3);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(56, 189, 248, 0.1);
}

.todo-card.completed .todo-text {
    text-decoration: line-through;
    color: var(--text-secondary);
}

.todo-content {
    flex: 1;
    word-break: break-word;
    overflow-wrap: break-word;
    max-height: calc(1.6em * 5);
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 0.5rem;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.todo-content::-webkit-scrollbar {
    width: 6px;
}

.todo-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.todo-content::-webkit-scrollbar-thumb {
    background: rgba(56, 189, 248, 0.3);
    border-radius: 3px;
}

.todo-content::-webkit-scrollbar-thumb:hover {
    background: rgba(56, 189, 248, 0.5);
}

.todo-content {
    scrollbar-width: thin;
    scrollbar-color: rgba(56, 189, 248, 0.3) rgba(255, 255, 255, 0.05);
}

.todo-text {
    font-size: clamp(1rem, 2vw, 1.1rem);
    line-height: 1.6;
}

/* Markdown Styles */
.todo-text h1,
.todo-text h2,
.todo-text h3 {
    margin: 0.5em 0 0.3em 0;
    font-weight: 600;
}

.todo-text h1 {
    font-size: 1.5em;
}

.todo-text h2 {
    font-size: 1.3em;
}

.todo-text h3 {
    font-size: 1.1em;
}

.todo-text p {
    margin: 0.5em 0;
}

.todo-text ul,
.todo-text ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.todo-text li {
    margin: 0.25em 0;
}

.todo-text code {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.2em 0.4em;
    border-radius: 0.3em;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.todo-text pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 1em;
    border-radius: 0.5em;
    overflow-x: auto;
    margin: 0.5em 0;
}

.todo-text pre code {
    background: none;
    padding: 0;
}

.todo-text a {
    color: var(--accent-color);
    text-decoration: none;
}

.todo-text a:hover {
    text-decoration: underline;
}

.todo-text strong {
    font-weight: 600;
}

.todo-text em {
    font-style: italic;
}

.todo-text blockquote {
    border-left: 3px solid var(--accent-color);
    padding-left: 1em;
    margin: 0.5em 0;
    opacity: 0.8;
}

/* Hashtag in text */
.hashtag {
    color: var(--accent-color);
    font-weight: 600;
    cursor: pointer;
    background: rgba(56, 189, 248, 0.1);
    padding: 0 0.2em;
    border-radius: 0.2em;
}

.hashtag:hover {
    background: rgba(56, 189, 248, 0.2);
    text-decoration: none;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    gap: 0.5rem;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.date {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.card-actions {
    display: flex;
    gap: 0.5rem;
}

.edit-btn,
.delete-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    opacity: 0;
    transform: translateX(10px);
}

.todo-card:hover .edit-btn,
.todo-card:hover .delete-btn {
    opacity: 1;
    transform: translateX(0);
}

.edit-btn:hover {
    color: var(--accent-color);
    background: rgba(56, 189, 248, 0.1);
}

.delete-btn:hover {
    color: var(--danger-color);
    background: rgba(239, 68, 68, 0.1);
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.todo-card.new-item {
    animation: scaleIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.check-icon {
    position: absolute;
    top: 1rem;
    right: 1rem;
    color: var(--success-color);
    opacity: 0;
    transform: scale(0);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.todo-card.completed .check-icon {
    opacity: 1;
    transform: scale(1);
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 1rem;
}

.modal-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 2rem;
    border-radius: 1.5rem;
    max-width: 400px;
    width: 100%;
    text-align: center;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}

.modal-overlay.visible .modal {
    transform: scale(1);
}

.modal h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.modal p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.edit-modal textarea {
    width: 100%;
    min-height: 120px;
    margin-bottom: 1.5rem;
    text-align: left;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.btn-cancel,
.btn-confirm {
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-cancel {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.btn-cancel:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-confirm {
    background: var(--accent-color);
    color: white;
}

.btn-confirm:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

.sortable-ghost {
    opacity: 0.4;
    background: rgba(56, 189, 248, 0.1);
    border: 2px dashed var(--accent-color);
}

@media (max-width: 768px) {
    .todo-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .edit-btn,
    .delete-btn {
        opacity: 1;
        transform: translateX(0);
    }
}

@media (max-width: 480px) {
    .input-section {
        flex-direction: column;
    }

    .toolbar {
        flex-direction: column;
        gap: 1rem;
    }

    #add-btn {
        width: 100%;
    }
}