:root {
    --font-main: 'Outfit', sans-serif;

    /* Aesthetic Palette - True Black & Purple */
    --bg-gradient-1: #000000;
    --bg-gradient-2: #050505;
    --bg-gradient-3: #120a1f;

    --glass-bg: rgba(10, 10, 10, 0.7);
    --glass-border: rgba(157, 78, 221, 0.2);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.8);

    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.85);
    --text-muted: rgba(255, 255, 255, 0.5);

    --accent-color: #9d4edd;
    --danger-color: #ff4d6d;
    --success-color: #06d6a0;

    /* Timer Mode Specifics */
    --timer-accent-1: #9d4edd;
    /* Focus Purple */
    --timer-accent-2: #5a189a;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

/* Custom Aesthetic Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(157, 78, 221, 0.3);
    border-radius: 10px;
    transition: all 0.3s;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(157, 78, 221, 0.6);
}

/* Standard scrollbar for Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(157, 78, 221, 0.3) transparent;
}

body {
    font-family: var(--font-main);
    min-height: 100vh;
    overflow-x: hidden;
    overflow-x: hidden;
    overflow-y: auto;
    /* Restore scroll */
    -webkit-overflow-scrolling: touch;
    /* Maintain smooth touch scroll */
    display: block;
    color: var(--text-primary);
    background: #000000;
}

/* Dynamic Background */
.background-gradient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(-45deg, #000000, #0a0a0a, #1a0b2e, #240046);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    z-index: -1;
}

@keyframes gradientBG {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* Glassmorphism Containers */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: var(--glass-shadow);
}

.glass-panel-inner {
    background: rgba(0, 0, 0, 0.4);
    /* Darker inner panel */
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* App Layout */
.app-container {
    width: 95%;
    max-width: 1200px;
    height: clamp(600px, 90vh, 900px);
    display: flex;
    flex-direction: column;
    padding: clamp(1rem, 3vw, 2.5rem);
    position: relative;
    overflow: hidden;
}

.app-header {
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: end;
}

.app-header h1 {
    font-weight: 700;
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    letter-spacing: -1px;
    background: linear-gradient(to right, #fff, #e0aaff);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

#current-date {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Tab Navigation */
.tab-navigation {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.5rem;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s;
}

.tab-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    font-weight: 600;
}

.tab-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
}

.main-content {
    display: flex;
    gap: clamp(1rem, 2vw, 2rem);
    height: 100%;
    overflow-y: auto;
    /* Allow scrolling if side-by-side content overflows height */
    overflow-x: hidden;
}

.task-section {
    flex: 3;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.pomodoro-section {
    flex: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    /* Start from top to avoid clipping top if overflow */
    padding-top: clamp(1rem, 5vh, 4rem);
    gap: clamp(1rem, 3vh, 2rem);
    min-height: min-content;
}

/* Task List Styles */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.badge {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 500;
}

.input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 1.5rem;
    height: 3.5rem;
    /* Enforce consistent height */
}

.input-group>* {
    height: 100%;
}

#new-task-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 1rem;
    border-radius: 12px;
    color: white;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
}

#new-task-input::placeholder {
    color: var(--text-muted);
}

#new-task-input:focus {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
}

#add-task-btn {
    background: white;
    color: #e73c7e;
    border: none;
    width: 3.5rem;
    min-width: 3.5rem;
    /* Prevent shrinking */
    flex-shrink: 0;
    /* Prevent shrinking */
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#add-task-btn:hover {
    transform: scale(1.05);
}

#add-task-btn:active {
    transform: scale(0.95);
}

.task-list-container {
    flex: 1;
    overflow-y: auto;
    padding-right: 5px;
}

/* Custom Scrollbar */
.task-list-container::-webkit-scrollbar {
    width: 6px;
}

.task-list-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.task-list-container::-webkit-scrollbar-track {
    background: transparent;
}

.task-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.task-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 1rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    animation: slideInRight 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.task-item:hover {
    transform: translateX(5px);
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.task-item.checked {
    background: rgba(0, 0, 0, 0.1);
    opacity: 0.7;
}

.task-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
    cursor: pointer;
}

.checkbox-custom {
    width: 22px;
    height: 22px;
    border: 2px solid rgba(255, 255, 255, 0.6);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.task-item.checked .checkbox-custom {
    background: var(--success-color);
    border-color: var(--success-color);
}

.task-item.checked .checkbox-custom::after {
    content: '✓';
    color: #333;
    font-weight: 800;
    font-size: 0.8rem;
}

.task-text {
    font-size: 1.05rem;
    transition: all 0.3s;
}

.task-item.checked .task-text {
    text-decoration: line-through;
    color: var(--text-muted);
}

.delete-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
    padding: 5px;
}

.task-item:hover .delete-btn {
    opacity: 1;
}

.delete-btn:hover {
    color: var(--danger-color);
    transform: scale(1.1);
}

/* Pomodoro Styles */
.timer-display-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: clamp(1rem, 4vh, 3rem);
}

.timer-circle {
    position: relative;
    width: clamp(180px, 25vh, 280px);
    /* Scales with height */
    height: clamp(180px, 25vh, 280px);
    display: flex;
    justify-content: center;
    align-items: center;
    filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.1));
}

.progress-ring {
    transform: rotate(-90deg);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.progress-ring__circle {
    stroke-dasharray: 691;
    /* 2 * PI * 110 */
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 0.5s linear, stroke 0.3s;
    stroke-linecap: round;
}

.progress-ring__outer-orbit {
    animation: rotateClockwise 60s linear infinite;
    transform-origin: center;
}

.progress-ring__inner-glow {
    transition: fill 0.3s ease;
    animation: breathe 4s ease-in-out infinite;
    transform-origin: center;
}

@keyframes rotateClockwise {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes breathe {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.6;
    }

    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

.timer-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: clamp(2.5rem, 8vh, 3.8rem);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    margin: 0;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
    letter-spacing: 0;
    z-index: 10;
    line-height: 1;
    white-space: nowrap;
}

.timer-colon {
    position: relative;
    top: -0.1em;
    display: inline-block;
}

.timer-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: center;
    height: 60px;
}

.btn-primary {
    background: white;
    color: #10002b;
    border: none;
    padding: 0 2rem;
    height: 50px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-primary:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 10px 30px rgba(157, 78, 221, 0.5);
}

.btn-icon {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.3);
}

.mode-switcher {
    position: relative;
    /* Context for absolute bg */
    display: flex;
    background: rgba(0, 0, 0, 0.4);
    padding: 0.4rem;
    border-radius: 16px;
    margin-bottom: 2rem;
    z-index: 10;
    width: fit-content;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.mode-bg {
    position: absolute;
    top: 0.4rem;
    left: 0.4rem;
    height: calc(100% - 0.8rem);
    background: white;
    border-radius: 12px;
    z-index: 1;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.mode-btn {
    position: relative;
    z-index: 2;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.6rem 1.2rem;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: color 0.3s;
}

.mode-btn.active {
    background: transparent;
    color: #000;
    font-weight: 700;
    box-shadow: none;
}

/* Entrance Animation */
.fade-in-up {
    animation: fadeInUp 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Height-based Safety: If screen is too short, allow the app to grow and scroll naturally */
@media (max-height: 800px) {
    .app-container {
        height: auto !important;
        min-height: 600px;
        margin: 2rem auto;
    }

    html,
    body {
        height: auto !important;
        overflow-y: auto !important;
    }
}

/* Responsive Design - Broadened to catch iPad Landscape (1400px) */
@media (max-width: 1400px) {
    .app-container {
        width: 100%;
        height: auto;
        border-radius: 0;
        border: none;
        padding: 1.5rem;
        overflow-y: visible;
        display: flex;
        flex-direction: column;
    }

    /* FIX: Disable nested scrolling on mobile/tablet */
    .sticky-hero {
        position: relative;
        height: auto;
        overflow-y: visible;
        padding-top: 1rem;
    }

    html,
    body {
        height: auto !important;
        overflow-y: auto !important;
        display: block !important;
    }

    body {
        padding: 0;
        background: black;
    }

    .background-gradient {
        position: fixed;
    }

    .app-header {
        flex-direction: row;
        align-items: center;
        margin-bottom: 1.5rem;
    }

    .app-header h1 {
        font-size: 1.8rem;
    }

    .main-content {
        flex-direction: column;
        gap: 2rem;
        height: auto;
        overflow: visible;
    }

    .task-section {
        flex: none;
        height: auto;
        order: 2;
        overflow: visible;
    }

    .task-list-container {
        flex: none;
        height: auto;
        max-height: 400px;
        overflow-y: auto;
    }

    .pomodoro-section {
        flex: none;
        order: 1;
        margin-bottom: 1rem;
        padding: 1.5rem;
    }

    .timer-circle {
        transform: scale(0.85);
        margin: -10px 0;
    }

    .timer-text {
        font-size: 3.5rem;
    }

    .timer-controls {
        width: 100%;
        justify-content: center;
    }

    .btn-primary {
        width: 100%;
        max-width: 200px;
    }
}

@media (max-width: 480px) {
    .app-header h1 {
        font-size: 1.5rem;
    }

    #current-date {
        font-size: 0.9rem;
    }

    .mode-switcher {
        width: 100%;
        display: flex;
        justify-content: space-between;
    }

    .mode-btn {
        flex: 1;
        text-align: center;
        padding: 0.6rem 0.5rem;
        font-size: 0.85rem;
    }

    /* Ensure modal fits */
    .modal-content {
        width: 95%;
        padding: 1.5rem;
    }

    /* Adjust timer size further for really small screens */
    .timer-circle {
        transform: scale(0.75);
        margin: -20px 0;
        /* Offset scale margin */
    }

    /* Touch targets */
    .task-item {
        padding: 0.8rem;
        /* Slightly compact but large enough */
    }

    .delete-btn {
        opacity: 1;
        /* Always visible on touch since hover doesn't exist */
        padding: 8px;
    }
}

/* Custom Timer Input */
.custom-input-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
    z-index: 20;
    width: 100%;
}

.custom-input-container.hidden {
    display: none !important;
}

#custom-minutes {
    width: 140px;
    background: transparent;
    border: none;
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 3.5rem;
    /* Match timer text size */
    font-weight: 700;
    text-align: center;
    outline: none;
    font-family: var(--font-main);
    padding: 0;
    line-height: 1;
}

#custom-minutes::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

#custom-minutes:focus {
    border-color: var(--accent-color);
}

/* Remove spin buttons */

/* Scroll Animation Structure */
.scroll-wrapper {
    position: relative;
    width: 100%;
}

.sticky-hero {
    position: sticky;
    top: 0;
    height: 100vh;
    /* Fallback */
    /* Removed 100dvh limit to allow natural flow if needed, but sticky needs height to stick */
    /* The issue was body hidden prevents reaching the next section. */
    width: 100%;
    z-index: 1;
    display: flex;
    justify-content: center;
    /* Better alignment for tall content */
    align-items: flex-start;
    padding-top: clamp(1rem, 5vh, 4rem);
    /* Allow overflow if content is too tall, but hide scrollbar if possible */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Smooth momentum scrolling */
    overscroll-behavior-y: none;
    /* Prevent bounce effects passing to body */
    scrollbar-width: none;
    /* Firefox */
}

.sticky-hero::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

#main-app {
    will-change: transform, filter;
    /* Transformation handled by JS */
}

/* PDF Section */
.pdf-section {
    position: relative;
    z-index: 2;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: clamp(1rem, 5vw, 2rem);
    /* Curtain Effect Background */
}

.pdf-section::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent, #050505 10%, #000000);
    backdrop-filter: blur(10px);
    z-index: -1;
    /* Start transparent to blend, then solid black */
}

.pdf-container {
    width: 100%;
    max-width: 1100px;
    height: 90vh;
    display: flex;
    flex-direction: column;
    padding: clamp(1.5rem, 4vw, 3rem);
    background: rgba(10, 10, 10, 0.85);
    /* Slightly more opaque */
    gap: 1.5rem;
}

.pdf-header {
    text-align: center;
}

.pdf-header h2 {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 700;
    background: linear-gradient(to right, #fff, var(--accent-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.pdf-header p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.pdf-upload-area {
    flex: 1;
    border: 2px dashed rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    transition: all 0.3s;
    background: rgba(255, 255, 255, 0.01);
}

.pdf-upload-area:hover,
.pdf-upload-area.dragover {
    border-color: var(--accent-color);
    background: rgba(255, 255, 255, 0.03);
    cursor: pointer;
}

.upload-hint {
    color: var(--text-muted);
}

.pdf-viewer {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    height: 100%;
    overflow: hidden;
}

.pdf-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1.2rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
}

#pdf-filename {
    font-weight: 500;
    color: var(--text-secondary);
}

#pdf-embed {
    flex: 1;
    border: none;
    border-radius: 12px;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>') no-repeat center center #f0f0f0;
}

#custom-minutes::-webkit-outer-spin-button,
#custom-minutes::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

#custom-minutes[type=number] {
    -moz-appearance: textfield;
    appearance: textfield;
}

#set-custom-time-btn {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: none;
    padding: 0.5rem 1.5rem;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s;
    backdrop-filter: blur(5px);
}

#set-custom-time-btn:hover {
    background: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(157, 78, 221, 0.4);
}

/* Settings Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 1;
    transition: opacity 0.3s;
}

.modal-overlay.hidden {
    display: none !important;
}

.modal-content {
    width: 90%;
    max-width: 400px;
    padding: 2rem;
    color: white;
    transform: translateY(0);
    transition: transform 0.3s;
}

.modal-overlay.hidden .modal-content {
    transform: translateY(20px);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    transition: color 0.2s;
}

.close-btn:hover {
    color: white;
}

.setting-group {
    margin-bottom: 1.5rem;
}

.setting-group label {
    display: block;
    margin-bottom: 3rem;
    /* Increased margin to prevent overlap */
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.timer-circle {
    position: relative;
    width: 220px;
    height: 220px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.setting-group input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.8rem;
    border-radius: 8px;
    color: white;
    font-family: var(--font-main);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.setting-group input:focus {
    border-color: var(--accent-color);
    background: rgba(255, 255, 255, 0.1);
}

/* Remove spin buttons from settings inputs */
.setting-group input::-webkit-outer-spin-button,
.setting-group input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}

.setting-group input[type=number] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* Header Button */
/* Header Button */
.btn-icon-small {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 5px;
    transition: color 0.2s;
    display: flex;
    align-items: center;
}

.btn-icon-small:hover {
    color: white;
    /* Removed rotation which was breaking text buttons */
    /* transform: rotate(45deg); */
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

/* Specific rotation for settings/reset icons only */
#settings-btn:hover svg,
#reset-timer-btn:hover svg {
    transform: rotate(45deg);
    transition: transform 0.5s ease;
}

.btn-text-small {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 12px;
    font-size: 0.85rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Floating Vault Button (Refined) */
.fab-btn {
    position: fixed;
    bottom: 2.5rem;
    right: 2.5rem;
    background: var(--accent-color);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.9rem 1.8rem;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    box-shadow: 0 12px 30px rgba(231, 60, 126, 0.5);
    cursor: pointer;
    z-index: 2000;
    /* Ensure it's above everything */
    font-weight: 700;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.fab-btn:hover {
    transform: translateY(-8px) scale(1.05);
    background: var(--accent-light);
    box-shadow: 0 18px 40px rgba(231, 60, 126, 0.6);
}

.fab-btn svg {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

@media (max-width: 1200px) {
    .fab-btn {
        bottom: 2rem;
        right: 2rem;
        padding: 0.8rem 1.4rem;
        font-size: 0.9rem;
    }
}

.btn-text-small:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* --- Advanced Animations (Refined) --- */

/* Jelly Effect - Subtle Press */
@keyframes jelly {
    0% {
        transform: scale(1);
    }

    30% {
        transform: scale(0.97);
    }

    50% {
        transform: scale(1.03);
    }

    70% {
        transform: scale(0.99);
    }

    100% {
        transform: scale(1);
    }
}

/* Pop In - Smooth Fade */
@keyframes popIn {
    0% {
        opacity: 0;
        transform: scale(0.9);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Checkmark Pop */
@keyframes checkPop {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    60% {
        transform: scale(1.1);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Heartbeat/Pulse - Gentle */
@keyframes heartBeat {
    0% {
        transform: scale(1);
        text-shadow: 0 0 10px rgba(157, 78, 221, 0.2);
    }

    50% {
        transform: scale(1.03);
        text-shadow: 0 0 15px rgba(157, 78, 221, 0.4);
    }

    100% {
        transform: scale(1);
        text-shadow: 0 0 10px rgba(157, 78, 221, 0.2);
    }
}

/* Slide In Right - Short Distance */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(-15px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* --- Components Overhaul --- */

/* Buttons: Glow & Subtle Press */
.btn-primary:active,
.mode-btn:active,
.btn-icon:active,
#set-custom-time-btn:active,
#add-task-btn:active {
    animation: jelly 0.2s ease-out;
    /* Faster, smoother */
}

.modal-content {
    animation: popIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.timer-text.running {
    animation: heartBeat 2s ease-in-out infinite;
}

.task-item.checked .checkbox-custom {
    animation: checkPop 0.3s ease-out forwards;
    box-shadow: 0 0 10px var(--success-color);
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Calendar Planner Styles */
.calendar-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    height: 100%;
    overflow-y: auto;
    /* Allow scrolling */
    padding-right: 5px;
    /* Prevent scrollbar overlap */
}

/* Scrollbar for calendar section */
/* Calendar Section Scrolling */
.calendar-section {
    overflow-y: auto;
    overflow-x: auto;
    /* Enable horizontal scroll */
    padding-right: 0.5rem;
}

/* Custom Scrollbar for Calendar Section */
.calendar-section::-webkit-scrollbar {
    width: 6px;
    height: 6px;
    /* Horizontal scrollbar height */
}

.calendar-section::-webkit-scrollbar-track {
    background: transparent;
}

.calendar-section::-webkit-scrollbar-corner {
    background: transparent;
}

.calendar-section::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.calendar-section::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Calendar Section Scrolling */
.calendar-section {
    overflow-y: auto;
    overflow-x: auto;
    /* Enable horizontal scroll */
    padding-right: 0.5rem;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    position: sticky;
    left: 0;
    /* Keep header visible */
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.5rem;
    margin-bottom: 2rem;
    min-width: 1000px;
    /* Force wide layout to prevent squishing */
}

.calendar-day {
    height: 200px;
    /* Fixed height for compactness */
    /* aspect-ratio: 1; Removed */
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    padding: 0.5rem;
    overflow: hidden;
}

.calendar-day:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.02);
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.calendar-day.selected {
    background: rgba(157, 78, 221, 0.1);
    border-color: var(--accent-color);
    box-shadow: 0 0 15px rgba(157, 78, 221, 0.2);
}

.calendar-day.today {
    border: 2px solid var(--accent-color);
}

.calendar-day.other-month {
    opacity: 0.3;
    pointer-events: none;
}

.calendar-day-number {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    align-self: flex-end;
    color: var(--text-muted);
}

.calendar-day.today .calendar-day-number {
    color: var(--accent-color);
    font-weight: 700;
}

.calendar-day-content {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Inline Task List */
.day-task-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    /* Space for scrollbar */
    margin-bottom: 0.5rem;
    min-height: 0;
    /* Important for flex overflow */
    max-width: 100%;
}

/* Custom Scrollbar for task list */
.day-task-list::-webkit-scrollbar {
    width: 4px;
}

.day-task-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.day-task-list::-webkit-scrollbar-track {
    background: transparent;
}

/* Inline Task Item */
.mini-task-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.4rem;
    border-radius: 6px;
    font-size: 0.8rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
    /* Prevent squishing */
    transition: all 0.2s;
    max-width: 100%;
    box-sizing: border-box;
}

.mini-task-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.mini-task-item.completed {
    opacity: 0.5;
    text-decoration: line-through;
}

.mini-checkbox {
    width: 14px;
    height: 14px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.mini-checkbox:hover {
    border-color: var(--accent-color);
}

.mini-task-item.completed .mini-checkbox {
    background: var(--accent-color);
    border-color: var(--accent-color);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");
    background-size: cover;
}

.mini-delete-btn {
    opacity: 0.6;
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    line-height: 1;
    transition: all 0.2s;
}

.mini-task-item:hover .mini-delete-btn {
    opacity: 1;
}

.mini-delete-btn:hover {
    color: var(--danger-color);
    transform: scale(1.1);
}


/* Priority Dot */
.priority-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
    flex-shrink: 0;
}

/* Scrollbar for task text */
/* Daily Task Item - Fix for Overflow */
.task-item {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.8rem;
    border-radius: 12px;
    margin-bottom: 0.5rem;
    gap: 0.8rem;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.task-item:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.1);
}

.task-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    min-width: 0;
    /* Critical */
    cursor: pointer;
}

.task-text {
    display: block;
    flex: 1;
    font-size: 1rem;
    color: var(--text-color);
    white-space: nowrap;
    overflow-x: auto;
    /* Scroll instead of hidden */
    min-width: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
    padding-bottom: 2px;
}

.task-text::-webkit-scrollbar {
    height: 4px;
    background: transparent;
}

.task-text::-webkit-scrollbar-track {
    background: transparent;
}

.task-text::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.task-text::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.4);
}

.task-text::-webkit-scrollbar-corner {
    background: transparent;
}

/* Scrollbar for calendar task text */
.mini-task-text {
    display: block;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    white-space: nowrap;
    cursor: default;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
    /* Standard for Firefox */
    padding-bottom: 2px;
}

.mini-task-text::-webkit-scrollbar {
    height: 4px;
    /* Thin scrollbar */
    background: transparent;
    /* Explicitly transparent track */
}

.mini-task-text::-webkit-scrollbar-track {
    background: transparent;
}

.mini-task-text::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
    /* Dark theme friendly thumb */
    border-radius: 4px;
}

.mini-task-text::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.4);
    /* Brighter on hover */
}

.mini-task-text::-webkit-scrollbar-corner {
    background: transparent;
}

.calendar-more {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 2px;
}

/* Inline wrapper for input + priority */
.day-input-wrapper {
    width: 100%;
    display: flex;
    gap: 4px;
    margin-bottom: 0.5rem;
}

.day-task-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 0.4rem;
    color: white;
    font-size: 0.8rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    /* margin-bottom removed as wrapper handles spacing */
    min-width: 0;
}

.day-priority-select {
    width: auto;
    max-width: 70px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 0 4px;
    cursor: pointer;
    outline: none;
}

.day-priority-select:focus,
.day-task-input:focus {
    border-color: var(--accent-color);
    background: rgba(0, 0, 0, 0.5);
}


.day-task-input:focus {
    border-color: var(--accent-color);
    background: rgba(0, 0, 0, 0.5);
}

.day-task-input::placeholder {
    color: rgba(255, 255, 255, 0.2);
}

/* Aesthetic Priority Dropdowns */
#main-priority-select,
.day-priority-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 0 2rem 0 1rem;
    /* Space for arrow */
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    height: 100%;

    /* Custom Arrow */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 1rem;

    /* Force dark theme for native popup */
    color-scheme: dark;
}

/* Compact override for Calendar Dropdown */
.day-priority-select {
    padding: 0 1.2rem 0 0.5rem;
    /* Tighter padding */
    font-size: 0.75rem;
    /* Smaller text */
    background-size: 0.8rem;
    /* Smaller arrow */
    background-position: right 0.2rem center;
    border-radius: 6px;
    height: auto;
    /* Let it shrink if needed */
    align-self: stretch;
}

#main-priority-select:hover,
.day-priority-select:hover {
    background-color: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
}

#main-priority-select:focus,
.day-priority-select:focus {
    outline: none;
    border-color: var(--accent-light);
    box-shadow: 0 0 0 2px rgba(231, 60, 126, 0.2);
}

/* Style the options if supported */
#main-priority-select option,
.day-priority-select option {
    background-color: #1e1e1e;
    color: white;
    padding: 10px;
}


.selected-date-tasks h3 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.priority-select {
    appearance: none;
    -webkit-appearance: none;
    background-color: rgba(255, 255, 255, 0.1);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    background-size: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0 2.5rem 0 1rem;
    /* Right padding for arrow */
    border-radius: 12px;
    color: white;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    cursor: pointer;
    min-width: 130px;
    /* Slightly wider */
    height: auto;
    /* Let flex determine or match others */
    display: flex;
    align-items: center;
}

.priority-select option {
    background-color: #1a0b2e;
    /* Dark background for options */
    color: white;
    padding: 10px;
}


.priority-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
    /* slightly squarer or smaller radius */
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    height: 1.4em;
    line-height: 1;
}

.priority-badge.high {
    background: rgba(255, 77, 109, 0.15);
    color: var(--danger-color);
    border: 1px solid rgba(255, 77, 109, 0.3);
}

.priority-badge.medium {
    background: rgba(255, 183, 3, 0.15);
    color: #ffb703;
    border: 1px solid rgba(255, 183, 3, 0.3);
}

.priority-badge.low {
    background: rgba(6, 214, 160, 0.15);
    color: var(--success-color);
    border: 1px solid rgba(6, 214, 160, 0.3);
}

#add-calendar-task-btn {
    background: white;
    color: #e73c7e;
    border: none;
    width: 3.5rem;
    min-width: 3.5rem;
    flex-shrink: 0;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#add-calendar-task-btn:hover {
    transform: scale(1.05);
}

#add-calendar-task-btn:active {
    transform: scale(0.95);
}

/* Custom Aesthetic Dropdown System */
.custom-select-wrapper {
    position: relative;
    user-select: none;
    height: 100%;
    min-width: 110px;
    z-index: 101;
    /* Above other inputs */
}

.custom-select-trigger {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    /* High horizontal padding */
    gap: 12px;
    /* Increased gap */
    font-size: 0.9rem;
    font-weight: 500;
    color: white;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.custom-select-trigger:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
}

.custom-select-trigger .arrow {
    position: relative;
    height: 10px;
    width: 10px;
}

.custom-select-trigger .arrow::before,
.custom-select-trigger .arrow::after {
    content: "";
    position: absolute;
    bottom: 0px;
    width: 0.15rem;
    height: 100%;
    transition: all 0.3s;
}

.custom-select-trigger .arrow::before {
    left: -3px;
    transform: rotate(45deg);
    background-color: white;
}

.custom-select-trigger .arrow::after {
    left: 3px;
    transform: rotate(-45deg);
    background-color: white;
}

.custom-select-wrapper.open .custom-select-trigger .arrow::before {
    transform: rotate(-45deg);
}

.custom-select-wrapper.open .custom-select-trigger .arrow::after {
    transform: rotate(45deg);
}

.custom-options {
    position: absolute;
    display: block;
    top: 100%;
    left: 0;
    right: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    background: #1e1e1e;
    transition: all 0.3s ease;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-10px);
    z-index: 200;
    /* Ensure high stacking context */
    min-width: 120px;
    overflow: hidden;
    max-height: 200px;
    /* Mobile overflow fix */
    overflow-y: auto;
}

.custom-select-wrapper.open .custom-options {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
    transform: translateY(10px);
}

.custom-option {
    position: relative;
    display: block;
    padding: 8px 12px;
    font-size: 0.9rem;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.custom-option:last-child {
    border-bottom: none;
}

.custom-option:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--accent-color);
}

.custom-option.selected {
    background: rgba(231, 60, 126, 0.2);
    color: var(--accent-light);
}

/* Specific styling for Calendar to be compact */
.day-task-input-wrapper {
    box-sizing: border-box;
    width: 100%;
}

.day-task-input-wrapper .day-task-input {
    padding: 6px 8px;
    font-size: 0.8rem;
    height: 28px;
    box-sizing: border-box;
}

.day-task-input-wrapper .custom-select-wrapper {
    min-width: 0;
    width: 68px;
    /* Increased from 60px to accommodate "Med" */
    margin-left: 4px;
    margin-right: 0;
}

.day-task-input-wrapper .custom-select-trigger {
    padding: 0 6px;
    border-radius: 6px;
    font-size: 0.75rem;
    height: 28px;
    justify-content: space-between;
    gap: 2px;
}

.day-task-input-wrapper .custom-option {
    padding: 4px 8px;
    /* Very thin for calendar */
    font-size: 0.75rem;
}

.day-task-input-wrapper .custom-select-trigger .arrow {
    transform: scale(0.5);
    width: 4px;
}

.day-task-input-wrapper .custom-options {
    min-width: 80px;
}