:root {
            --clr-bg: #f9fafb; --clr-card: #ffffff; --clr-text: #1f2937; --clr-text-muted: #6b7280;
            --clr-primary: #7c3aed; --clr-primary-hover: #6d28d9; --clr-primary-light: #f5f3ff;
            --clr-secondary: #4b5563; --clr-accent: #10b981; --clr-success: #10b981;
            --clr-danger: #ef4444; --clr-warning: #f59e0b; --clr-info: #3b82f6;
            --clr-border: #e5e7eb; --clr-xp: var(--clr-warning);
            --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
            --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
            --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
            --border-radius: 0.75rem; --progress-bg: #f3f4f6; --transition-speed: 0.25s;
            --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
            /* Tooltip styles */
            --tooltip-bg: rgba(31, 41, 55, 0.9); /* Dark gray, slightly transparent */
            --tooltip-text-color: #ffffff;
            --tooltip-arrow-size: 6px;
            /* Toast Notification */
            --toast-success-bg: rgba(16, 185, 129, 0.9); /* Success color */
            --toast-info-bg: rgba(59, 130, 246, 0.9); /* Info color */
            --toast-warning-bg: rgba(245, 158, 11, 0.9); /* Warning color */
            --toast-danger-bg: rgba(239, 68, 68, 0.9); /* Danger color */
            --toast-text-color: #ffffff;
        }
        [data-theme="dark"] {
            --clr-bg: #111827; --clr-card: #1f2937; --clr-text: #f3f4f6; --clr-text-muted: #9ca3af;
            --clr-primary: #a78bfa; --clr-primary-hover: #8b5cf6; --clr-primary-light: rgba(167, 139, 250, 0.1);
            --clr-secondary: #9ca3af; --clr-accent: #34d399; --clr-success: #34d399;
            --clr-danger: #f87171; --clr-warning: #fcd34d; --clr-info: #60a5fa;
            --clr-border: #374151; --clr-xp: var(--clr-warning);
            --progress-bg: #374151;
            --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.15);
            --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.2), 0 2px 4px -2px rgb(0 0 0 / 0.15);
            --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.2), 0 4px 6px -4px rgb(0 0 0 / 0.15);
            /* Dark theme tooltip */
            --tooltip-bg: rgba(243, 244, 246, 0.9); /* Light gray, slightly transparent */
            --tooltip-text-color: #1f2937;
             /* Toast Notification Dark */
            --toast-success-bg: rgba(52, 211, 153, 0.9);
            --toast-info-bg: rgba(96, 165, 250, 0.9);
            --toast-warning-bg: rgba(252, 211, 77, 0.9);
            --toast-danger-bg: rgba(248, 113, 113, 0.9);
            --toast-text-color: #1f2937; /* Darker text on light background */
        }
        * { box-sizing: border-box; margin: 0; padding: 0; }
        html { scroll-behavior: smooth; font-size: 16px; }
        body {
            font-family: var(--font-sans); background-color: var(--clr-bg); color: var(--clr-text);
            display: flex; flex-direction: column; align-items: center; padding: 1.5rem 1rem;
            transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
            min-height: 100vh; line-height: 1.6;
        }
        .container { max-width: 800px; width: 100%; display: flex; flex-direction: column; gap: 2rem; }
        header { text-align: center; margin-bottom: 0.5rem; }
        h1 { font-size: 2rem; font-weight: 800; margin-bottom: 0.25rem; color: var(--clr-primary); letter-spacing: -0.02em; }
        header p { font-size: 1.05rem; color: var(--clr-text-muted); }
        .card {
            background-color: var(--clr-card); padding: 1.75rem; border-radius: var(--border-radius);
            box-shadow: var(--shadow-md); border: 1px solid var(--clr-border);
            position: relative; overflow: visible; /* Allow tooltips/modals to overflow if needed, or manage z-index */
            transition: background-color var(--transition-speed) ease;
        }
        .gamification-header {
            display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 1rem;
        }
        .gamification-item {
            background-color: var(--clr-card); padding: 0.875rem 1rem; border-radius: var(--border-radius);
            border: 1px solid var(--clr-border); box-shadow: var(--shadow-sm); text-align: center;
            transition: transform var(--transition-speed) ease; position: relative; /* Needed for tooltip positioning */
            cursor: help; /* Indicate interactivity */
        }
        .gamification-item:hover { transform: translateY(-2px); }
        .gamification-item i { margin-right: 0.5rem; font-size: 1.1em; vertical-align: -0.1em; }
        .gamification-item span { font-weight: 700; font-size: 1.25rem; vertical-align: middle; }
        .gamification-label { display: block; font-size: 0.8rem; color: var(--clr-text-muted); margin-top: 0.15rem; text-transform: uppercase; letter-spacing: 0.02em; }
        .xp-bar-container { width: 100%; height: 6px; background-color: var(--progress-bg); border-radius: 3px; overflow: hidden; margin-top: 0.4rem; }
        .xp-bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--clr-warning), var(--clr-xp)); border-radius: 3px; transition: width 0.5s ease-out; }
        .level { color: var(--clr-primary); } .goal-progress { color: var(--clr-success); }

        /* Gamification Tooltip Styling */
        .gamification-item .tooltiptext {
            visibility: hidden; width: 180px; background-color: var(--tooltip-bg); color: var(--tooltip-text-color);
            text-align: center; border-radius: 6px; padding: 8px 10px; position: absolute; z-index: 1070;
            bottom: 115%; left: 50%; transform: translateX(-50%); opacity: 0;
            transition: opacity 0.3s, visibility 0.3s; font-size: 0.75rem; font-weight: 500; line-height: 1.4;
            pointer-events: none; white-space: normal; box-shadow: var(--shadow-sm);
        }
        .gamification-item .tooltiptext::after {
            content: ""; position: absolute; top: 100%; left: 50%; margin-left: calc(-1 * var(--tooltip-arrow-size));
            border-width: var(--tooltip-arrow-size); border-style: solid; border-color: var(--tooltip-bg) transparent transparent transparent;
        }
        .gamification-item:hover .tooltiptext { visibility: visible; opacity: 1; }

        .timer-section { display: flex; flex-direction: column; align-items: center; gap: 1.5rem; padding-bottom: 1rem; }
        .progress-ring { position: relative; width: 260px; height: 260px; }
        .progress-ring__svg { transform: rotate(-90deg); display: block; }
        .progress-ring__circle { transition: stroke-dashoffset 0.5s linear, stroke var(--transition-speed) ease; stroke-width: 14px; fill: transparent; }
        .progress-ring__background { stroke: var(--progress-bg); }
        .progress-ring__progress { stroke: var(--clr-primary); stroke-linecap: round; }
        .timer-display { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; }
        #timeDisplay { font-size: 4.25rem; font-weight: 800; line-height: 1; margin-bottom: 0.2rem; letter-spacing: -0.04em; color: var(--clr-primary); }
        .session-info { font-size: 1rem; font-weight: 600; color: var(--clr-text-muted); margin-bottom: 0; min-height: 1.3em; transition: color var(--transition-speed) ease; }
        .controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem; align-items: center; width: 100%; max-width: 400px; margin: 1rem auto 0 auto; }
        button { padding: 0.8rem 1.5rem; border: none; border-radius: var(--border-radius); font-size: 0.95rem; font-weight: 700; cursor: pointer; transition: all var(--transition-speed) ease; display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; }
        button i { font-size: 0.95em; }
        button:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.05); box-shadow: var(--shadow-sm); }
        button:active:not(:disabled) { transform: translateY(0); filter: brightness(1); }
        button:disabled { opacity: 0.6; cursor: not-allowed; box-shadow: none; filter: grayscale(60%); }
        .btn-primary { background-color: var(--clr-primary); color: white; }
        .btn-secondary { background-color: var(--clr-secondary); color: white; }
        .btn-warning { background-color: var(--clr-warning); color: var(--clr-text); }
        .btn-success { background-color: var(--clr-success); color: white; }
        .btn-danger { background-color: var(--clr-danger); color: white; }
        .btn-info { background-color: var(--clr-info); color: white; }
        #settingsToggleBtn { padding: 0.8rem; line-height: 1; }
        #settingsToggleBtn i { margin: 0; }

        .quote-section {
            margin-top: 1.5rem; padding: 1rem 1.5rem; background-color: var(--clr-primary-light); color: var(--clr-primary);
            border-radius: var(--border-radius); text-align: center; font-style: italic; font-weight: 500; min-height: 3.5em;
            display: flex; align-items: center; justify-content: center; transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
        }
        .quote-section i { margin-right: 0.6rem; font-size: 1.1em; }

        /* Settings no longer uses details/summary */
        .settings-content { /* This class is now inside the settings modal */
            padding: 1rem 0 0.5rem 0; /* Adjusted padding for modal */
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
            gap: 1.25rem;
        }
        .settings-content label { display: block; margin-bottom: 0.4rem; font-size: 0.85rem; font-weight: 600; color: var(--clr-text-muted); }
        .settings-content input[type="number"]{ width: 100%; padding: 0.7rem 0.9rem; border: 1px solid var(--clr-border); border-radius: 0.5rem; font-size: 0.95rem; background-color: var(--clr-card); color: var(--clr-text); transition: border-color var(--transition-speed) ease, box-shadow var(--transition-speed) ease; }
        .settings-content input:focus { outline: none; border-color: var(--clr-primary); box-shadow: 0 0 0 3px var(--clr-primary-light); }
        .settings-content .daily-goal-group {
            grid-column: 1 / -1; display: flex; align-items: center; gap: 0.6rem;
            background-color: var(--clr-primary-light); padding: 0.6rem 0.9rem; border-radius: 0.5rem; margin-bottom: 1rem; /* Add some bottom margin */
        }
        .settings-content .daily-goal-group label { margin-bottom: 0; color: var(--clr-primary); font-weight: 600; font-size: 0.9rem; }
        .settings-content .daily-goal-group input[type="number"] { width: 70px; }

        .section-title { margin-bottom: 1.5rem; font-size: 1.25rem; font-weight: 700; text-align: center; color: var(--clr-secondary); text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--clr-border); padding-bottom: 0.75rem; }
        .section-title i { margin-right: 0.6rem; color: var(--clr-primary); }
        .stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
        .stat-item { background-color: var(--clr-card); padding: 1.25rem; border-radius: var(--border-radius); border: 1px solid var(--clr-border); box-shadow: var(--shadow-sm); text-align: center; }
        .stat-item h3 { font-size: 0.8rem; color: var(--clr-text-muted); margin-bottom: 0.25rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
        .stat-item span { font-size: 1.6rem; font-weight: 700; color: var(--clr-primary); line-height: 1.2; }
        .stats .actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.8rem; margin-top: 1rem; }
        .achievements-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(85px, 1fr)); gap: 1.1rem; }
        .achievement-item { text-align: center; transition: opacity 0.4s ease, transform 0.3s ease, filter 0.4s ease; position: relative; }
        .achievement-item.locked { opacity: 0.4; filter: grayscale(90%); cursor: help; }
        .achievement-item.unlocked { transform: scale(1.03); }
        .achievement-icon-wrapper { width: 65px; height: 65px; margin: 0 auto 0.5rem auto; border-radius: 50%; background-color: var(--progress-bg); display: flex; align-items: center; justify-content: center; border: 2px solid var(--clr-border); transition: all var(--transition-speed) ease; }
        .achievement-item:hover .achievement-icon-wrapper { transform: scale(1.05); }
        .achievement-item i { font-size: 2rem; color: var(--clr-secondary); transition: color var(--transition-speed) ease; }
        .achievement-item.unlocked .achievement-icon-wrapper { background-color: var(--clr-success); border-color: transparent; }
        .achievement-item.unlocked i { color: white; }
        .achievement-item span { font-size: 0.8rem; font-weight: 600; display: block; color: var(--clr-text); margin-bottom: 0.1rem; }
        /* Achievement Tooltip (for locked ones) */
        .achievement-item .tooltiptext {
            visibility: hidden; width: 150px; background-color: var(--tooltip-bg); color: var(--tooltip-text-color);
            text-align: center; border-radius: 6px; padding: 7px 9px; position: absolute; z-index: 1070;
            bottom: 105%; left: 50%; transform: translateX(-50%); opacity: 0;
            transition: opacity 0.3s, visibility 0.3s; font-size: 0.7rem; font-weight: 500;
            pointer-events: none; white-space: normal; box-shadow: var(--shadow-sm);
        }
        .achievement-item:hover .tooltiptext { visibility: visible; opacity: 1; }

        /* Modal Base Styles (Shared by History and Settings Modals) */
        .modal { display: none; position: fixed; z-index: 1050; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(17, 24, 39, 0.8); backdrop-filter: blur(8px); animation: fadeIn 0.3s ease-out; }
        .modal-content { background-color: var(--clr-card); margin: 8% auto; padding: 2rem; border: none; border-radius: var(--border-radius); max-width: 550px; position: relative; box-shadow: var(--shadow-lg); animation: slideIn 0.4s ease-out; }
        .modal-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--clr-border); padding-bottom: 0.8rem; margin-bottom: 1.25rem; }
        .modal-header h2 { margin: 0; font-size: 1.25rem; font-weight: 700; }
        .modal-header h2 i { margin-right: 0.6rem; color: var(--clr-primary); } /* Style icon in modal header */
        .modal-close { background: none; border: none; color: var(--clr-text-muted); font-size: 1.8rem; font-weight: bold; cursor: pointer; line-height: 1; padding: 0.4rem; transition: color var(--transition-speed) ease, transform var(--transition-speed) ease; }
        .modal-close:hover { color: var(--clr-danger); transform: rotate(90deg); }
        .modal-body { /* Generic class for modal content area */
             max-height: 60vh; /* Limit height and allow scrolling */
             overflow-y: auto;
             padding-right: 0.5rem; /* Space for scrollbar */
        }
        /* Specific modal content styles */
        .history-log { /* Already defined, but ensure it fits modal-body concept */
            max-height: 380px; overflow-y: auto; margin-top: 0; /* Removed default margin */ padding-right: 0.5rem;
        }
        .history-item { display: grid; grid-template-columns: auto 1fr auto; gap: 0.8rem; align-items: center; padding: 0.75rem 0.5rem; border-bottom: 1px solid var(--clr-border); font-size: 0.875rem; transition: background-color var(--transition-speed) ease; border-radius: 0.375rem; }
        .history-item:hover { background-color: var(--clr-primary-light); }
        .history-item:last-child { border-bottom: none; }
        .history-item .type-icon { font-size: 1rem; width: 22px; text-align: center; color: var(--clr-secondary); }
        .history-item .type-icon.work { color: var(--clr-primary); }
        .history-item .type-icon.break { color: var(--clr-accent); }
        .history-item .details { display: flex; flex-direction: column; }
        .history-item .details span:first-child { font-weight: 600; }
        .history-item .date { font-size: 0.75rem; color: var(--clr-text-muted); text-align: right; white-space: nowrap; }

        .theme-toggle { position: fixed; top: 1rem; right: 1rem; background: var(--clr-card); color: var(--clr-text); border: 1px solid var(--clr-border); width: 45px; height: 45px; border-radius: 50%; cursor: pointer; display: flex; justify-content: center; align-items: center; font-size: 1.3rem; box-shadow: var(--shadow-md); z-index: 1060; transition: all var(--transition-speed) ease; }
        .theme-toggle:hover { transform: scale(1.1) rotate(20deg); box-shadow: var(--shadow-lg); color: var(--clr-primary); }
        footer { text-align: center; margin-top: 2.5rem; padding: 1.5rem 1rem; font-size: 0.9rem; color: var(--clr-text-muted); border-top: 1px solid var(--clr-border); }
        .hidden { display: none !important; }

        /* Toast Notification Styles (Requirement b) */
        .toast-container {
            position: fixed;
            top: 20px;
            right: 20px;
            z-index: 1080; /* Above modals */
            display: flex;
            flex-direction: column;
            gap: 0.75rem;
            align-items: flex-end; /* Align toasts to the right */
        }
        .toast {
            background-color: var(--toast-info-bg); /* Default info */
            color: var(--toast-text-color);
            padding: 0.9rem 1.25rem;
            border-radius: var(--border-radius);
            box-shadow: var(--shadow-lg);
            display: flex;
            align-items: center;
            gap: 0.75rem;
            opacity: 0;
            transform: translateX(100%); /* Start off-screen */
            transition: opacity 0.4s ease, transform 0.4s ease;
            min-width: 250px;
            max-width: 350px;
            font-size: 0.9rem;
            font-weight: 500;
        }
        .toast.show {
            opacity: 1;
            transform: translateX(0); /* Slide in */
        }
        .toast i { font-size: 1.1rem; }
        /* Toast Types */
        .toast-success { background-color: var(--toast-success-bg); }
        .toast-warning { background-color: var(--toast-warning-bg); }
        .toast-danger { background-color: var(--toast-danger-bg); }
        .toast-info { background-color: var(--toast-info-bg); }


        @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
        @keyframes slideIn { from { transform: translateY(-15px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
        @media (max-width: 768px) {
            html { font-size: 15px; } .container { max-width: 95%; gap: 1.75rem; } .card { padding: 1.5rem; }
            h1 { font-size: 1.8rem; } header p { font-size: 1rem; } .progress-ring { width: 240px; height: 240px; }
            #timeDisplay { font-size: 4rem; } .gamification-header { grid-template-columns: 1fr 1fr; }
            .gamification-item span { font-size: 1.15rem; } .stats-grid { grid-template-columns: 1fr 1fr; }
            .achievements-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 1rem;}
            .modal-content { margin: 15% auto; max-width: 90%; padding: 1.75rem; }
            .history-item { grid-template-columns: auto 1fr; gap: 0.5rem 1rem; }
            .history-item .date { grid-column: 2 / 3; grid-row: 2 / 3; text-align: left; margin-top: 0.2rem; }
            .toast-container { top: 15px; right: 15px; gap: 0.5rem; }
            .toast { min-width: 200px; max-width: 300px; padding: 0.8rem 1rem; font-size: 0.85rem;}
        }
        @media (max-width: 480px) {
            html { font-size: 14px; } body { padding: 1rem 0.75rem; } .container { gap: 1.25rem; }
            .card { padding: 1.25rem; border-radius: 0.5rem; } h1 { font-size: 1.6rem; } header p { font-size: 0.95rem; }
            .gamification-header { grid-template-columns: 1fr 1fr; }
            .gamification-item { padding: 0.75rem 0.9rem; }
            .progress-ring { width: 200px; height: 200px; } #timeDisplay { font-size: 3.2rem; } .session-info { font-size: 0.95rem; }
            .controls { flex-direction: row; flex-wrap: nowrap; max-width: none; justify-content: center; }
            button { width: auto; flex-shrink: 1; padding: 0.7rem 1rem; }
             #settingsToggleBtn { padding: 0.7rem; }
            /* Settings content inside modal is handled by modal CSS */
            .stats .actions { flex-direction: row; } .modal-content { margin: 10% auto; padding: 1.25rem; }
            .theme-toggle { width: 40px; height: 40px; font-size: 1.2rem; top: 0.75rem; right: 0.75rem; }
            .history-item { padding: 0.7rem 0.4rem; }
            .toast-container { top: 10px; right: 10px; }
            .toast { width: calc(100% - 20px); max-width: calc(100% - 20px); } /* Full width on small screens */
        }
        
[data-theme="dark"] .footer-tagline {
  color: #111827 !important;
}
    .container > footer {
  margin-top: -3rem; 
}