:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --card-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #38bdf8;
    --accent-glow: rgba(56, 189, 248, 0.5);
    --checked-color: #10b981;
    --danger: #f43f5e;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    position: relative;
    overflow-x: hidden;
}

.background-anim {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 50% 50%, rgba(56, 189, 248, 0.15), transparent 40%),
                radial-gradient(circle at 80% 20%, rgba(139, 92, 246, 0.15), transparent 30%);
    z-index: -1;
    animation: rotateBg 30s linear infinite;
}

@keyframes rotateBg {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.app-container {
    width: 100%;
    max-width: 500px;
    padding: 20px;
    padding-bottom: 40px;
}

/* ── Header ── */
header {
    margin-bottom: 28px;
    padding-top: 20px;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.header-top h1 {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(135deg, #38bdf8, #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 10px var(--accent-glow));
    line-height: 1.2;
}

.header-top p {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 300;
    margin-top: 2px;
}

.header-add-btn {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #38bdf8, #818cf8);
    color: white;
    border: none;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 4px 15px var(--accent-glow);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-add-btn:active {
    transform: scale(0.9);
}

/* ── Category Card ── */
.category {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.category-header h2 {
    font-size: 1.1rem;
    color: var(--accent);
    font-weight: 600;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    opacity: 0.45;
    padding: 4px;
    transition: opacity 0.2s;
}

.icon-btn:hover, .icon-btn:active { opacity: 1; }

/* ── Items ── */
.item-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 10px 10px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    transition: background 0.2s;
}

.item-check-area {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    cursor: pointer;
    min-width: 0;
}

.item input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    border: 2px solid var(--text-muted);
    border-radius: 6px;
    outline: none;
    cursor: pointer;
    position: relative;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.item input[type="checkbox"]:checked {
    background-color: var(--checked-color);
    border-color: var(--checked-color);
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}

.item input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 5px; height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: translate(-50%, -60%) rotate(45deg);
}

.item-name {
    font-size: 0.95rem;
    font-weight: 400;
    line-height: 1.3;
    transition: all 0.3s ease;
    word-break: break-word;
}

.item input[type="checkbox"]:checked ~ .item-name,
.item-check-area.checked .item-name {
    color: var(--text-muted);
    text-decoration: line-through;
    opacity: 0.6;
}

/* Item inline edit */
.item-edit-input {
    flex: 1;
    background: rgba(255,255,255,0.08);
    border: 1px solid var(--accent);
    border-radius: 8px;
    padding: 4px 8px;
    color: var(--text-main);
    font-size: 0.95rem;
    font-family: 'Outfit', sans-serif;
    outline: none;
}

.item-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

/* ── Add Item Button ── */
.add-item-btn {
    width: 100%;
    background: rgba(56, 189, 248, 0.07);
    color: var(--accent);
    border: 1px dashed rgba(56, 189, 248, 0.3);
    border-radius: 12px;
    padding: 9px;
    margin-top: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.add-item-btn:active {
    background: rgba(56, 189, 248, 0.15);
}

/* ── Loading ── */
.loading-state {
    text-align: center;
    color: var(--text-muted);
    padding: 40px;
    font-size: 1.1rem;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* ── Modal ── */
.modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9999 !important;
    display: flex !important;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1 !important;
    pointer-events: all !important;
}

.modal-sheet {
    width: 100%;
    max-width: 500px;
    background: #1e293b;
    border-top-left-radius: 28px;
    border-top-right-radius: 28px;
    padding: 16px 24px 40px;
    border-top: 1px solid rgba(255,255,255,0.1);
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-overlay.active .modal-sheet {
    transform: translateY(0);
}

/* On desktop — show as centered dialog, not bottom sheet */
@media (min-width: 600px) {
    .modal-overlay {
        align-items: center;
    }
    .modal-sheet {
        border-radius: 24px;
        transform: scale(0.92);
        max-width: 420px;
        padding: 28px 28px 28px;
    }
    .modal-overlay.active .modal-sheet {
        transform: scale(1);
    }
    .modal-handle { display: none; }
}

.modal-handle {
    width: 40px;
    height: 4px;
    background: rgba(255,255,255,0.2);
    border-radius: 4px;
    margin: 0 auto;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
    text-align: center;
}

.modal-input {
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 14px;
    padding: 14px 16px;
    color: var(--text-main);
    font-size: 1rem;
    font-family: 'Outfit', sans-serif;
    outline: none;
    transition: border-color 0.2s;
    width: 100%;
}

.modal-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.modal-actions {
    display: flex;
    gap: 12px;
}

.modal-btn {
    flex: 1;
    padding: 14px;
    border-radius: 14px;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
    cursor: pointer;
    transition: transform 0.15s, opacity 0.15s;
}

.modal-btn:active { transform: scale(0.97); }

.modal-btn.cancel {
    background: rgba(255,255,255,0.08);
    color: var(--text-muted);
}

.modal-btn.confirm {
    background: linear-gradient(135deg, #38bdf8, #818cf8);
    color: white;
    box-shadow: 0 4px 15px var(--accent-glow);
}
