:root {
    --bg-glass: rgba(18, 18, 21, 0.8);
    --bg-cell: #0c0c0e;
    --color-primary-glow: rgba(139, 92, 246, 0.3);
}

body {
    margin: 0;
    background-color: var(--color-bg-base);
    color: var(--color-text-primary);
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

html.electron body {
    padding-top: 0;
}

.ambient-bg {
    position: absolute;
    inset: 0;
    z-index: -1;
    background-size: cover;
    background-position: center;
    opacity: 0.06;
    filter: blur(120px) saturate(1.2);
    transition: background-image 1s ease-in-out;
    pointer-events: none;
}

.calendar-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 3rem;
    max-width: 1920px;
    width: 100%;
    margin: 0 auto;
}

.calendar-controls {
    padding: 1.5rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.month-selector {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.month-title {
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    background: linear-gradient(to right, #fff, #a1a1aa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    min-width: 350px;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    width: 44px;
    height: 44px;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.icon-btn:hover {
    background: var(--color-primary);
    border-color: var(--color-primary);
    transform: translateY(-2px);
}

.controls-right {
    display: flex;
    gap: 1rem;
}

.view-toggles {
    display: flex;
    background: #0f0f12;
    padding: 4px;
    border-radius: 99px;
    border: 1px solid var(--border-subtle);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.toggle-item {
    padding: 10px 24px;
    border-radius: 99px;
    border: none;
    background: transparent;
    color: var(--color-text-secondary);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.toggle-item.active {
    background: var(--color-primary);
    color: white;
    box-shadow: 0 2px 10px var(--color-primary-glow);
}

.calendar-board {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    background: var(--color-bg-elevated);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.weekdays-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(255, 255, 255, 0.02);
    flex-shrink: 0;
}

.weekday-header {
    padding: 16px;
    text-align: center;
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--color-text-secondary);
    letter-spacing: 0.1em;
    border-right: 1px solid var(--border-subtle);
}

.weekday-header:last-child {
    border-right: none;
}

.days-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    width: 100%;
    overflow-y: auto;
    flex: 1;

    grid-auto-rows: minmax(180px, 1fr);
    background: var(--color-bg-base);
}

.day-cell {
    position: relative;
    background: var(--bg-cell);
    border-right: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    padding: 12px;
    transition: background 0.2s;
    overflow: hidden;
}

.day-cell:nth-child(7n) {
    border-right: none;
}

.day-cell.empty {
    background: rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

.day-cell:hover {
    background: #16161a;
}

.day-cell.today {
    background: rgba(139, 92, 246, 0.03);
    box-shadow: inset 0 0 0 1px var(--color-primary);
}

.day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    z-index: 2;
    pointer-events: none;
}

.day-number {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text-secondary);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.day-cell.today .day-number {
    background: var(--color-primary);
    color: white;
    box-shadow: 0 0 15px var(--color-primary-glow);
}

.today-label {
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--color-primary);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    display: none;
}

.day-cell.today .today-label {
    display: block;
}

.events-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    z-index: 2;
    padding-right: 4px;
}

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

.events-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.anime-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 0.8rem;
    color: #d4d4d8;
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.anime-chip::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--color-primary);
    opacity: 0;
    transition: opacity 0.2s;
}

.anime-chip:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    padding-left: 14px;
}

.anime-chip:hover::before {
    opacity: 1;
}

.chip-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
    margin-right: 8px;
}

.chip-ep {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--color-text-secondary);
    background: rgba(0, 0, 0, 0.4);
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

.cell-backdrop {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    opacity: 0;
    transition: opacity 0.4s ease;
    filter: grayscale(100%) brightness(0.25);
    z-index: 1;
    pointer-events: none;
}

.day-cell:hover .cell-backdrop {
    opacity: 1;
}

.loader {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: #18181b;
    border: 1px solid var(--border-subtle);
    padding: 12px 24px;
    border-radius: 99px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transform: translateY(100px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 1000;
}

.loader.active {
    transform: translateY(0);
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s infinite linear;
}

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

@media (max-width: 768px) {
    body {
        height: auto;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .calendar-wrapper {
        padding: 1rem;
        height: auto;
        overflow: visible;
        display: block;
    }

    .calendar-controls {
        flex-direction: column;
        gap: 1rem;
        padding-bottom: 1rem;
    }

    .month-selector {
        width: 100%;
        justify-content: space-between;
        gap: 0.5rem;
    }

    .month-title {
        font-size: 1.5rem;
        min-width: auto;
        text-align: center;
        flex: 1;
    }

    .controls-right {
        width: 100%;
        justify-content: center;
    }

    .calendar-board {
        border: none;
        background: transparent;
        box-shadow: none;
        overflow: visible;
    }

    .weekdays-grid {
        display: none;
    }

    .days-grid {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        background: transparent;
        height: auto;
        overflow: visible;
    }

    .day-cell.empty {
        display: none;
    }

    .day-cell {
        border: 1px solid var(--border-subtle);
        border-radius: var(--radius-lg);
        background: var(--color-bg-elevated);
        min-height: auto;
        padding: 1rem;
    }

    .day-cell:nth-child(7n) {
        border-right: 1px solid var(--border-subtle);
    }

    .day-header {
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        padding-bottom: 0.5rem;
        margin-bottom: 0.8rem;
    }

    .day-number {
        background: rgba(255, 255, 255, 0.05);
    }

    .anime-chip {
        padding: 12px;
        font-size: 0.95rem;
    }

    .cell-backdrop {
        display: none;
    }
}
