/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Hanken Grotesk', sans-serif;
}

:root {
    --hour-height: 60px;
    --bg-main: #f8fafc; /* Google slate-50 background */
    --bg-surface: #ffffff;
    --bg-navbar: #ffffff;
    --border-color: #e0e2e6; /* Soft border */
    --color-primary: #0b57d0; /* Google blue */
    --color-primary-rgb: 11, 87, 208;
    --color-secondary: #1a73e8; /* Soft Google blue */
    --color-secondary-rgb: 26, 115, 232;
    --color-accent: #b3261e; /* Google red / MD3 error color */
    --color-accent-rgb: 179, 38, 30;
    --color-success: #146c2e; /* Google green */
    --text-main: #1f2937; /* Google dark grey (text-gray-800) */
    --text-muted: #5f6368; /* Google secondary text */
    --text-on-primary: #ffffff;
    
    --shadow-sm: 0 1px 2px 0 rgba(60,64,67,0.3), 0 1px 3px 1px rgba(60,64,67,0.15);
    --shadow-md: 0 1px 3px 0 rgba(60,64,67,0.3), 0 4px 8px 3px rgba(60,64,67,0.15);
    --shadow-lg: 0 2px 6px 2px rgba(60,64,67,0.15), 0 6px 10px 4px rgba(60,64,67,0.3);
    --shadow-glow: 0 0 20px rgba(11, 87, 208, 0.12);
    --radius-sm: 8px;
    --radius-md: 16px; /* rounded-2xl */
    --radius-lg: 28px; /* rounded-3xl for cards/modals */
    --radius-pill: 9999px; /* rounded-full */
    
    --transition: all 0.2s cubic-bezier(0.2, 0, 0, 1); /* MD3 standard easing */

    /* Active Highlight States (Google blue pills) */
    --bg-active: #e8f0fe;
    --text-active: #0b57d0;

    /* Glassmorphism Variables */
    --bg-glass-navbar: rgba(255, 255, 255, 0.8);
    --bg-glass-surface: rgba(255, 255, 255, 0.85);
    --backdrop-blur: blur(16px);
    --border-glass: 1px solid rgba(11, 87, 208, 0.08);

    /* Logo colors */
    --logo-left: #0b57d0;
    --logo-right: #146c2e;
    --logo-center: #ea4335;
    --logo-text: #1f2937;
}

/* Dark Mode Theme overrides for any mode */
body.dark-theme {
    --bg-main: #0f0f10; /* Google dark background */
    --bg-surface: #1e1f20; /* Google dark card surface */
    --bg-navbar: #1e1f20;
    --border-color: #444746; /* Google dark border */
    --color-primary: #a8c7fa; /* Google blue dark mode */
    --color-primary-rgb: 168, 199, 250;
    --color-secondary: #7cacf8;
    --color-secondary-rgb: 124, 172, 248;
    --color-accent: #f2b8b5;
    --color-accent-rgb: 242, 184, 181;
    --color-success: #6dd58c;
    --text-main: #e3e3e3;
    --text-muted: #c4c7c5;
    --text-on-primary: #042b5c;
    --shadow-glow: 0 0 25px rgba(168, 199, 250, 0.15);

    /* Active Highlight States in Dark Theme */
    --bg-active: #004b73;
    --text-active: #a8c7fa;

    /* Glassmorphism Variables */
    --bg-glass-navbar: rgba(30, 31, 32, 0.8);
    --bg-glass-surface: rgba(30, 31, 32, 0.85);
    --backdrop-blur: blur(16px);
    --border-glass: 1px solid rgba(255, 255, 255, 0.08);

    /* Logo colors in Dark Theme */
    --logo-left: #a8c7fa;
    --logo-right: #6dd58c;
    --logo-center: #f2b8b5;
    --logo-text: #e3e3e3;
}

body.app-mode {
    --bg-main: #f8f9fa;
    --bg-surface: #ffffff;
    --border-color: #e3e8ee;
    --border-color-hover: #cdd5df;
    --color-primary: #635bff;
    --color-primary-hover: #5433ff;
    --color-success: #00875a;
    --color-success-bg: #e6f4ea;
    --color-danger: #df1b41;
    --color-danger-bg: #fce8e6;
    
    --text-main: #1a1f36;
    --text-muted: #69778c;
    
    --shadow-sm: 0 1px 1px rgba(0, 0, 0, 0.06), 0 2px 5px rgba(50, 50, 93, 0.03);
    --shadow-md: 0 4px 6px rgba(50, 50, 93, 0.05), 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-focus: 0 0 0 1px var(--color-primary), 0 0 0 4px rgba(99, 91, 255, 0.16);
    
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 8px;
    --radius-pill: 4px; /* flat buttons instead of pills */
    
    background-color: var(--bg-main);
    color: var(--text-main);
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Ubuntu, sans-serif;
}

body.app-mode.dark-theme {
    --bg-main: #0a0a0c;
    --bg-surface: #121214;
    --border-color: #2a2c35;
    --border-color-hover: #3d404d;
    --color-primary: #8075ff;
    --color-primary-hover: #9c95ff;
    --color-success: #00b87a;
    --color-success-bg: rgba(0, 184, 122, 0.15);
    --color-danger: #ff4d6a;
    --color-danger-bg: rgba(255, 77, 106, 0.15);
    
    --text-main: #f4f6f8;
    --text-muted: #a3acb9;
}

body.app-mode :not(i):not([class*="fa-"]) {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Ubuntu, sans-serif;
}

/* ==================== STRIPE SYSTEM COMPONENT OVERRIDES ==================== */
body.app-mode .btn {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 13px;
    font-weight: 500;
    line-height: 16px;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 150ms cubic-bezier(0.215, 0.610, 0.355, 1);
    user-select: none;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    box-shadow: none;
}
body.app-mode .btn-primary {
    background-color: var(--color-primary);
    color: #ffffff;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
body.app-mode .btn-primary:hover {
    background-color: var(--color-primary-hover);
    transform: none;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
body.app-mode .btn-outline {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04), 0 2px 4px rgba(0, 0, 0, 0.02);
}
body.app-mode .btn-outline:hover {
    border-color: var(--border-color-hover);
    color: var(--text-main);
    background-color: var(--bg-main);
}
body.app-mode .btn-sm {
    padding: 5px 10px;
    font-size: 12px;
    height: 28px;
}
body.app-mode .btn-xs {
    padding: 3px 6px;
    font-size: 11px;
    height: 22px;
}

/* Inputs and Forms */
body.app-mode input[type="text"],
body.app-mode input[type="number"],
body.app-mode input[type="email"],
body.app-mode input[type="password"],
body.app-mode input[type="time"],
body.app-mode select,
body.app-mode textarea {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 20px;
    padding: 6px 12px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
    transition: border-color 120ms ease, box-shadow 120ms ease;
    outline: none;
}
body.app-mode input[type="text"]:focus,
body.app-mode input[type="number"]:focus,
body.app-mode input[type="email"]:focus,
body.app-mode input[type="password"]:focus,
body.app-mode input[type="time"]:focus,
body.app-mode select:focus,
body.app-mode textarea:focus {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-focus);
}

body.home-mode {
    overflow-x: hidden;
}

body.app-mode h1, body.app-mode h2, body.app-mode h3, body.app-mode h4, body.app-mode h5, body.app-mode h6 {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Ubuntu, sans-serif;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.01em;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Hanken Grotesk', sans-serif;
    font-weight: 800;
    letter-spacing: -0.03em;
}

/* Scrollbar styles */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    font-weight: 600;
    font-size: 0.875rem;
    border-radius: var(--radius-pill);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    gap: 8px;
    letter-spacing: 0.01em;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
    border-radius: var(--radius-pill);
}

.btn-xs {
    padding: 6px 12px;
    font-size: 0.75rem;
    border-radius: var(--radius-pill);
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-primary {
    background: var(--color-primary);
    color: var(--text-on-primary);
    box-shadow: none;
}
.btn-primary:hover {
    background: var(--color-secondary);
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}
.btn-outline:hover {
    background: rgba(var(--color-primary-rgb), 0.08);
    border-color: var(--color-primary);
}

.btn-danger {
    background: var(--color-accent);
    color: #fff;
}
.btn-danger:hover {
    background: #b3261e;
}

/* Navigation Bar */
.navbar {
    height: 72px;
    background-color: var(--bg-glass-navbar);
    backdrop-filter: var(--backdrop-blur);
    -webkit-backdrop-filter: var(--backdrop-blur);
    border-bottom: var(--border-glass);
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    position: relative;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.6rem;
    font-weight: 800;
    font-family: 'Hanken Grotesk', sans-serif;
    letter-spacing: -0.04em;
    color: var(--logo-text);
}
.logo-svg {
    width: 44px;
    height: 28px;
    display: inline-block;
}
.logo-circle-left {
    fill: var(--logo-left);
    transition: var(--transition);
}
.logo-circle-right {
    fill: var(--logo-right);
    transition: var(--transition);
}
.logo-lens {
    fill: var(--logo-center);
    transition: var(--transition);
}
.logo-text {
    font-weight: 800;
    text-transform: lowercase;
    color: var(--logo-text);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.lang-select-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 0.9rem;
    background: rgba(var(--color-primary-rgb), 0.05);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
}
.lang-select-wrapper select {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-weight: 700;
    outline: none;
    cursor: pointer;
}

/* ==================== HOME MODE ==================== */
.home-wrapper {
    flex-grow: 1;
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    align-items: center;
    padding: 40px;
    gap: 40px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    position: relative;
}

/* Onboarding Form */
.onboarding-card {
    background-color: var(--bg-glass-surface);
    backdrop-filter: var(--backdrop-blur);
    -webkit-backdrop-filter: var(--backdrop-blur);
    border: var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 48px;
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 10;
}
.onboarding-card h1 {
    font-size: 3rem;
    line-height: 1;
    margin-bottom: 8px;
}
.text-gradient {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.tagline {
    font-size: 1.15rem;
    color: var(--text-muted);
    margin-bottom: 36px;
}

.create-form-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}
.create-form-container label {
    font-weight: 700;
    color: var(--text-main);
}
.input-group {
    display: flex;
    gap: 12px;
}
.input-group input {
    flex-grow: 1;
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-main);
    color: var(--text-main);
    font-size: 1rem;
    outline: none;
    transition: var(--transition);
}
.input-group input:focus {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-glow);
}

.google-pitch {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.google-pitch i {
    color: var(--color-primary);
}

/* Arrow indicator pointing to input */
.arrow-indicator {
    position: absolute;
    left: 45%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 4rem;
    color: var(--color-primary);
    z-index: 15;
    pointer-events: none;
    filter: drop-shadow(0 4px 10px rgba(var(--color-primary-rgb), 0.4));
    animation: arrowBounce 1.5s ease-in-out infinite alternate;
}

@keyframes arrowBounce {
    0% { transform: translate(-50%, -60%) rotate(-15deg); }
    100% { transform: translate(-55%, -40%) rotate(-5deg); }
}

/* Mock Calendar Graphic (Home Background) */
.mock-calendar-bg {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-md);
    opacity: 0.75;
    pointer-events: none;
    transform: perspective(800px) rotateY(-10deg) rotateX(5deg);
    transition: var(--transition);
    max-height: 550px;
    overflow: hidden;
}
.mock-calendar-bg:hover {
    opacity: 0.9;
    transform: perspective(800px) rotateY(0deg) rotateX(0deg);
}
.mock-calendar-header {
    display: flex;
    flex-direction: column;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
}
.mock-month {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 12px;
}
.mock-days-header {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    text-align: center;
    font-weight: 700;
    color: var(--text-muted);
    font-size: 0.85rem;
}
.mock-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    grid-auto-rows: 72px;
    gap: 4px;
}
.mock-day {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 6px;
    display: flex;
    flex-direction: column;
    background: var(--bg-main);
    position: relative;
}
.mock-day .day-num {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 700;
}
.mock-event {
    font-size: 0.65rem;
    color: #fff;
    padding: 2px 4px;
    border-radius: 4px;
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
}
.active-day {
    background: rgba(var(--color-primary-rgb), 0.05);
    border-color: var(--color-primary);
}

/* ==================== APP CONTAINER (WORKSPACE) ==================== */
.app-container {
    flex-grow: 1;
    display: grid;
    grid-template-columns: 280px 1fr;
    height: calc(100vh - 72px);
    overflow: hidden;
    background-color: var(--bg-main);
    padding: 8px 16px 16px 0; /* Add margins for floating card layout */
}

/* Sidebar */
.sidebar {
    background-color: var(--bg-main);
    display: flex;
    flex-direction: column;
    padding: 16px 16px 16px 24px;
    overflow-y: auto;
}
.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}
.calendar-avatar-container {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface);
}
.calendar-avatar-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.avatar-placeholder {
    font-size: 1.1rem;
    color: var(--text-muted);
}
.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    flex-grow: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    letter-spacing: -0.01em;
}
.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.sidebar-menu .btn {
    border-radius: var(--radius-pill);
    padding: 12px 24px;
    font-size: 0.9rem;
    font-weight: 700;
    justify-content: flex-start;
}
.sidebar-menu .btn-primary {
    background-color: var(--bg-active);
    color: var(--text-active);
    box-shadow: var(--shadow-sm);
}
.sidebar-menu .btn-primary:hover {
    background-color: var(--bg-active);
    filter: brightness(0.95);
    box-shadow: var(--shadow-md);
}
body.dark-theme .sidebar-menu .btn-primary:hover {
    filter: brightness(1.1);
}
.sidebar-footer {
    margin-top: auto;
    padding-top: 24px;
}

.privacy-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    font-family: 'IBM Plex Mono', monospace;
    letter-spacing: 0.02em;
}
.privacy-badge.public {
    background: rgba(16, 185, 129, 0.1);
    color: var(--color-success);
}
.privacy-badge.private {
    background: rgba(244, 63, 94, 0.1);
    color: var(--color-accent);
}

/* Calendar Workspace */
.calendar-workspace {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
    background-color: var(--bg-surface);
    border-radius: var(--radius-lg); /* Rounded-3xl card workspace! */
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}
.calendar-toolbar {
    height: 72px; /* Extra height for breathing room */
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-surface);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 28px; /* Comfortable padding */
}
.month-navigation {
    display: flex;
    align-items: center;
    gap: 16px;
}
.nav-arrow-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-main);
    transition: var(--transition);
}
.nav-arrow-btn:hover {
    border-color: var(--color-primary);
    background: rgba(var(--color-primary-rgb), 0.08);
}
.current-period-label {
    font-size: 1.25rem;
    font-weight: 700;
    min-width: 150px;
    text-align: center;
    letter-spacing: -0.01em;
}

.view-toggles {
    display: flex;
    align-items: center;
}
.view-toggles-desktop {
    display: flex;
    background: var(--bg-main, #f1f5f9);
    padding: 3px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    gap: 2px;
}
.view-btn {
    border: none;
    background: transparent;
    padding: 6px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 16px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease-in-out;
}
.view-btn:hover {
    color: var(--text-main);
    background: rgba(0, 0, 0, 0.04);
}
.view-btn.active {
    background: var(--bg-surface, #ffffff);
    color: var(--color-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.calendar-canvas {
    flex-grow: 1;
    overflow-y: auto;
    padding: 24px; /* Comfortable padding */
}

/* ==================== CALENDAR VIEWS ==================== */
/* Month View Grid */
.calendar-month-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    grid-template-rows: 35px repeat(6, minmax(100px, 1fr));
    gap: 1px;
    background: var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    height: 100%;
}
.month-days-header-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    font-weight: 700;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
    padding: 0;
    height: 35px;
    align-items: center;
}
.calendar-month-cell {
    background: var(--bg-surface);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
    transition: var(--transition);
    min-height: 100px;
}
.calendar-month-cell:hover {
    background: rgba(var(--color-primary-rgb), 0.04);
}
.calendar-month-cell.today-cell {
    background: rgba(var(--color-primary-rgb), 0.02);
}
.calendar-month-cell.other-month {
    opacity: 0.35;
}
.cell-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}
.cell-day-num {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
}
.today-cell .cell-day-num {
    background: var(--color-primary);
    color: var(--text-on-primary);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.cell-events {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
    max-height: 72px;
}
.calendar-event-item {
    font-size: 0.72rem;
    color: #fff;
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    transition: var(--transition);
}
.calendar-event-item:hover {
    filter: brightness(0.95);
    transform: scale(0.98);
}

/* Week View Grid */
.calendar-week-grid {
    display: grid;
    grid-template-columns: 60px repeat(7, minmax(0, 1fr));
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.week-header-cell {
    grid-column: 2 / -1;
    grid-row: 1;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    border-bottom: 1px solid var(--border-color);
    text-align: center;
    padding: 10px 0;
    font-size: 0.85rem;
    font-weight: 700;
    background: var(--bg-surface);
}
.week-day-label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: var(--text-muted);
}
.week-day-label.today-label {
    color: var(--color-primary);
}
.week-day-label span.day-num {
    font-size: 1.1rem;
    font-weight: 800;
}
.hour-column {
    grid-column: 1;
    grid-row: 2;
    border-right: 1px solid var(--border-color);
    display: grid;
    grid-template-rows: repeat(24, var(--hour-height));
    text-align: right;
    padding-right: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 700;
    font-family: 'IBM Plex Mono', monospace;
}
.hour-cell {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    height: var(--hour-height);
}
.week-days-canvas {
    grid-column: 2 / -1;
    grid-row: 2;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    position: relative;
    background: var(--border-color);
    gap: 1px;
}
.week-day-column {
    background: var(--bg-surface);
    height: calc(24 * var(--hour-height));
    position: relative;
}
.week-hour-grid-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 1px;
    border-top: 1px dashed rgba(0, 0, 0, 0.05);
}
.current-time-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background-color: #ef4444;
    z-index: 15;
    pointer-events: none;
}
.current-time-line::before {
    content: '';
    position: absolute;
    left: -4px;
    top: -3px;
    width: 8px;
    height: 8px;
    background-color: #ef4444;
    border-radius: 50%;
}
/* Absolute positioned events in week/day view */
.absolute-event {
    position: absolute;
    left: 4px;
    right: 4px;
    border-radius: var(--radius-sm);
    color: #fff;
    padding: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    overflow: hidden;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}
.absolute-event:hover {
    box-shadow: var(--shadow-md);
    filter: brightness(1.1);
}

/* Day View */
.calendar-day-grid {
    display: grid;
    grid-template-columns: 80px minmax(0, 1fr);
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.day-header-title {
    grid-column: 1 / -1;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 1.2rem;
    font-weight: 800;
}
.day-canvas-column {
    position: relative;
    height: calc(24 * var(--hour-height));
    background: var(--bg-surface);
}

/* Roll view (Continuous scrolling months) */
.calendar-roll-container {
    display: flex;
    flex-direction: column;
    gap: 32px;
}
.roll-month-section {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 24px;
}
.roll-month-title {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 16px;
}

/* ==================== MODALS ==================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35); /* Slate background overlay */
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.modal-overlay.active {
    display: flex !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    z-index: 99000 !important;
}
.modal-card {
    background: var(--bg-surface, #ffffff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 12px; /* var(--radius-md) equivalent, matching settings-panel roundedness */
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    transform: scale(0.95);
    transition: transform 0.2s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}
.modal-card form {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow: hidden;
}
body.app-mode .modal-card {
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border: 1px solid var(--border-color);
}
.modal-overlay.active .modal-card {
    transform: scale(1);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px 12px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}
.close-btn {
    background: transparent;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition);
}
.close-btn:hover {
    background: var(--bg-main);
    color: var(--text-main);
}
.modal-body {
    padding: 20px 24px;
    flex-grow: 1;
    overflow-y: auto;
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px 20px;
    border-top: 1px solid var(--border-color, #e2e8f0);
    background: var(--bg-surface);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}
.form-group label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
}
.form-group input, .form-group textarea, .form-group select {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-main);
    outline: none;
    font-size: 0.9rem;
    transition: var(--transition);
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 1px var(--color-primary);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.color-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}
.color-palette input {
    display: none;
}
.color-palette label {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: var(--transition);
}
.color-palette input:checked + label {
    border-color: var(--text-main);
    transform: scale(1.15);
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--text-main);
    color: var(--bg-main);
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 999999;
}
.toast.active {
    opacity: 1;
    transform: translateY(0);
}

/* Helper Utilities */
.text-center { text-align: center; }
.google-giant-icon {
    font-size: 4rem;
    color: var(--color-primary);
    margin-bottom: 16px;
}
.google-card {
    max-width: 400px;
}

/* Responsive */
@media (max-width: 768px) {
    .home-wrapper {
        grid-template-columns: 1fr;
        padding: 20px;
    }
    .mock-calendar-bg {
        display: none;
    }
    .arrow-indicator {
        display: none;
    }
    .app-container {
        grid-template-columns: 1fr;
    }
    .sidebar {
        display: none; /* simple hidden sidebar on mobile */
    }
    .login-text {
        display: none;
    }
}

body.dark-theme .week-hour-grid-line {
    border-top: 1px dashed rgba(255, 255, 255, 0.05);
}

/* Preferences Dropdown */
.pref-dropdown {
    position: relative;
    display: inline-block;
}
.pref-menu {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 8px;
    background: var(--bg-glass-surface);
    backdrop-filter: var(--backdrop-blur);
    -webkit-backdrop-filter: var(--backdrop-blur);
    border: var(--border-glass);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 12px;
    display: none;
    flex-direction: column;
    gap: 12px;
    z-index: 500;
    min-width: 200px;
}
.pref-menu.active {
    display: flex;
}
.pref-menu-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
}

/* Calendar Title in Navbar */
.navbar-calendar-title {
    font-size: 1.1rem;
    font-weight: 600;
    border-left: 2px solid var(--border-color);
    padding-left: 12px;
    margin-left: 12px;
    color: var(--text-muted);
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Responsive view select dropdown */
.view-select-mobile {
    display: none;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-main);
    font-weight: 700;
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
}

/* Account Section in Preferences Menu - Hidden by default on Desktop */
.pref-account-item {
    display: none !important;
}

@media (max-width: 768px) {
    .view-toggles-desktop {
        display: none;
    }
    .view-select-mobile {
        display: block;
    }
    .navbar-calendar-title {
        font-size: 0.95rem;
        max-width: 60vw !important; /* Limit title to 60% of viewport width */
        margin-left: 8px;
        padding-left: 8px;
    }
    
    /* Hide Logo SVG on Mobile and shrink text */
    .logo-svg {
        display: none !important;
    }
    .logo-text {
        font-size: 1.2rem !important;
    }

    /* Show primary navbar login/dashboard buttons on Mobile */
    .navbar > .nav-actions > .login-btn,
    .navbar > .nav-actions > .nav-dashboard-btn {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
    }

    /* Show account section inside settings dropdown on Mobile */
    .pref-menu .pref-account-item {
        display: flex !important;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        border-top: 1px dashed var(--border-color);
        padding-top: 12px;
        margin-top: 8px;
        width: 100%;
    }
    .pref-menu .pref-account-item > span {
        align-self: flex-start;
        color: var(--text-muted);
        font-size: 0.8rem;
    }
    .pref-menu .pref-account-item .login-btn,
    .pref-menu .pref-account-item .nav-dashboard-btn {
        width: 100%;
        justify-content: center;
        margin: 2px 0;
    }

    /* Navbar & Workspace Spacing Reductions on Mobile */
    :root {
        --hour-height: 35px;
    }
    .navbar {
        height: 56px !important;
        padding: 0 12px !important;
    }
    .app-container, .app-container.sidebar-collapsed {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: 1fr !important;
        padding: 0 !important;
        height: calc(100vh - 56px) !important;
        width: 100vw !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }
    .sidebar {
        display: none !important;
    }
    .calendar-workspace {
        width: 100% !important;
        max-width: 100vw !important;
        padding: 0 0 8px 0 !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        box-sizing: border-box !important;
        flex-grow: 1 !important;
    }
    .calendar-toolbar {
        height: 52px !important;
        padding: 0 8px !important;
        width: 100% !important;
        box-sizing: border-box !important;
        margin-bottom: 8px !important;
    }
    .zoom-controls, #fullscreen-toggle-btn {
        display: none !important;
    }
    .current-period-label {
        font-size: 0.95rem !important;
        min-width: 80px !important;
        margin: 0 4px !important;
    }
    .nav-arrow-btn {
        width: 28px !important;
        height: 28px !important;
        flex-shrink: 0 !important;
    }
    .month-navigation {
        gap: 4px !important;
    }
    .view-select-mobile {
        padding: 4px 6px !important;
        font-size: 0.8rem !important;
    }
    .calendar-canvas {
        padding: 2px !important;
        width: 100% !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
    }

    /* Mobile Modals Optimization */
    .modal-content, .settings-modal-content, .account-modal-content {
        width: 92% !important;
        max-width: 440px !important;
        max-height: 88vh !important;
        padding: 18px 16px !important;
        border-radius: 16px !important;
        margin: auto !important;
    }

    /* Month View and Roll Month Cell Spacing Reductions */
    .calendar-month-grid {
        grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
        width: 100% !important;
        box-sizing: border-box !important;
        grid-template-rows: 35px repeat(6, minmax(55px, 1fr)) !important;
        border-radius: 4px !important;
    }
    .month-days-header-row {
        grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
        width: 100% !important;
        box-sizing: border-box !important;
        padding: 0 !important;
        height: 35px !important;
        align-items: center !important;
        font-size: 0.72rem !important;
    }
    .month-days-header-row span {
        font-size: 0.7rem !important;
    }
    .calendar-month-cell {
        padding: 3px 2px !important;
        min-height: 62px !important;
        gap: 2px !important;
    }
    .cell-header {
        margin-bottom: 2px !important;
    }
    .cell-day-num {
        font-size: 0.75rem !important;
    }
    .today-cell .cell-day-num {
        width: 18px !important;
        height: 18px !important;
        font-size: 0.72rem !important;
    }
    .cell-events {
        gap: 2px !important;
        max-height: 48px !important;
        overflow-y: hidden !important;
    }
    .calendar-event-item {
        font-size: 0.65rem !important;
        padding: 2px 4px !important;
        border-radius: 4px !important;
        line-height: 1.2 !important;
    }
    .calendar-event-item .event-time {
        font-size: 0.6rem !important;
        margin-right: 2px !important;
    }

    /* Week View: Hide Hour Column and expand days to full width */
    .calendar-week-grid {
        grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
    }
    .calendar-week-grid .hour-column {
        display: none !important;
    }
    .calendar-week-grid .week-header-cell {
        grid-column: 1 / -1 !important;
        padding: 4px 0 !important;
        font-size: 0.7rem !important;
    }
    .calendar-week-grid .week-days-canvas {
        grid-column: 1 / -1 !important;
    }
    .absolute-event {
        left: 1px !important;
        right: 1px !important;
        padding: 1px 2px !important;
        font-size: 0.62rem !important;
        border-radius: 3px !important;
    }
    .absolute-event strong {
        font-size: 0.62rem !important;
        font-weight: 600 !important;
        display: block !important;
        line-height: 1.1 !important;
        white-space: nowrap !important;
        text-overflow: ellipsis !important;
        overflow: hidden !important;
    }
    .calendar-week-grid .absolute-event div {
        display: none !important;
    }

    /* Day View shrink hour label column width */
    .calendar-day-grid {
        grid-template-columns: 50px minmax(0, 1fr) !important;
    }

    /* Scroll/Roll View spacing reductions */
    .calendar-roll-container {
        gap: 8px !important;
    }
    .roll-month-section {
        padding-bottom: 4px !important;
    }
    .roll-month-title {
        font-size: 1rem !important;
        margin-bottom: 4px !important;
    }
}

#share-edit-url, #share-view-url, #settings-slug-input {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 500;
    font-size: 0.85rem;
}

/* Drag & Drop Visual Feedback */
.calendar-event-item.dragging,
.absolute-event.dragging {
    opacity: 0.4;
    transform: scale(0.96);
    border: 1px dashed var(--color-primary);
}

.calendar-month-cell.drag-hover,
.week-day-column.drag-hover,
.day-canvas-column.drag-hover {
    background-color: rgba(45, 106, 227, 0.08) !important;
    border: 2px dashed var(--color-primary) !important;
    transition: background-color 0.15s ease, border 0.15s ease;
}

/* Calendar List View */
.calendar-list-view {
    display: flex;
    flex-direction: column;
    gap: 32px;
    padding: 12px 4px;
    max-width: 800px;
    margin: 0 auto;
}
.list-view-group {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.list-view-group-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
    margin-bottom: 4px;
}
.list-view-events-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.list-event-card {
    display: flex;
    background: var(--bg-glass-surface);
    backdrop-filter: var(--backdrop-blur);
    -webkit-backdrop-filter: var(--backdrop-blur);
    border: var(--border-glass);
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
}
.list-event-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md), 0 0 15px var(--event-color-glow);
    border-color: var(--event-color);
}
.list-event-color-bar {
    width: 6px;
    flex-shrink: 0;
}
.list-event-content {
    padding: 16px 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.list-event-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: 'IBM Plex Mono', monospace;
}
.list-event-meta span {
    display: flex;
    align-items: center;
    gap: 6px;
}
.list-event-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
}
.list-event-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Favorites Button and Icon Styles */
#nav-favorite-btn.favorited i {
    color: #eab308; /* gold star */
}
.fa-star.gold-star {
    color: #eab308;
    margin-right: 4px;
}

/* Fullscreen Mode Styles */
body.fullscreen-mode .navbar {
    display: none !important;
}
body.fullscreen-mode .sidebar {
    display: none !important;
}
body.fullscreen-mode .view-toggles {
    display: none !important;
}
body.fullscreen-mode .app-container {
    grid-template-columns: 1fr !important;
    height: 100vh !important;
    padding: 0 !important;
}
body.fullscreen-mode .calendar-workspace {
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
}

/* Category Manager and Legend Styles */
.category-edit-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.add-category-form {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 12px;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-main);
    cursor: pointer;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.legend-item:hover {
    background: rgba(var(--color-primary-rgb), 0.04);
}
.legend-color-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.event-cal-badge {
    display: inline-block;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.6rem;
    color: #fff;
    margin-right: 4px;
    font-weight: 600;
}
.list-event-meta .event-cal-badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    margin-right: 8px;
}

/* Fullscreen Zoom Controls */
.zoom-controls {
    display: none !important;
    gap: 8px;
    align-items: center;
}
body.fullscreen-mode .zoom-controls {
    display: flex !important;
}
.zoom-btn {
    opacity: 0.5;
    transition: var(--transition);
}
.zoom-btn:hover {
    opacity: 1;
}

/* Global Toggle Switch Styles */
.toggle-switch-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: rgba(99, 102, 241, 0.06);
    border-radius: 12px;
    border: 1px solid var(--border-color, rgba(226, 232, 240, 0.6));
    margin-bottom: 20px;
}
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 24px;
    flex-shrink: 0;
    cursor: pointer;
    margin: 0;
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-slider {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #cbd5e1;
    transition: .25s ease;
    border-radius: 24px;
}
.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: #ffffff;
    transition: .25s ease;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-slider {
    background-color: var(--color-primary, #6366f1);
}
.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

/* Navbar Active Toggle Badges (Green Border) */
.btn.nav-btn-active-green {
    border: 1px solid #22c55e !important;
    color: #15803d !important;
    background-color: rgba(34, 197, 94, 0.08) !important;
    font-weight: 700 !important;
}

/* ==================== Inline Settings Panels ==================== */
.settings-panel {
    display: none;
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 24px 28px 40px;
    box-sizing: border-box;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    animation: panelSlideIn 0.2s ease-out;
}
.settings-panel.active {
    display: block;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}
@keyframes panelSlideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.settings-panel .panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e2e8f0;
}
.settings-panel .panel-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: #1a202c;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}
.settings-panel .panel-header .panel-close-btn {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    display: flex;
    align-items: center;
    gap: 6px;
}
.settings-panel .panel-header .panel-close-btn:hover {
    background: #f8f9fa;
    color: #1a202c;
    border-color: #cbd5e1;
}
.settings-panel .panel-footer {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ==================== UX/UI ENHANCEMENTS ==================== */

/* Collapsible Sidebar Support */
.app-container {
    transition: grid-template-columns 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.app-container.sidebar-collapsed {
    grid-template-columns: 56px 1fr !important;
}
.sidebar.collapsed {
    padding: 16px 8px !important;
    overflow: hidden;
}
.sidebar.collapsed .sidebar-search,
.sidebar.collapsed .sidebar-calendars-section h3,
.sidebar.collapsed .sidebar-legend-section h3,
.sidebar.collapsed #sidebar-calendars-list span,
.sidebar.collapsed #sidebar-legend-list span,
.sidebar.collapsed .sidebar-toggle-text {
    display: none !important;
}
.sidebar.collapsed .sidebar-header {
    justify-content: center !important;
}
.sidebar-toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.sidebar-toggle-btn:hover {
    background: var(--bg-active);
    color: var(--color-primary);
}

/* Resources Dropdown Menu in Header */
.resources-dropdown {
    position: relative;
    display: inline-block;
}
.resources-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    min-width: 220px;
    z-index: 1000;
    padding: 6px;
    animation: fadeInDown 0.15s ease-out;
}
.resources-menu.active {
    display: block;
}
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.resources-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    color: var(--text-main);
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease;
}
.resources-menu-item:hover {
    background: var(--bg-active);
    color: var(--color-primary);
}
.resources-menu-item i {
    width: 18px;
    text-align: center;
}

/* Accessibility & Touch Targets */
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
    outline: 2px solid var(--color-primary) !important;
    outline-offset: 2px !important;
}
.nav-arrow-btn, .view-btn, .btn {
    min-height: 36px;
}

/* Sidebar Item Action Hover Rules (Reduce Visual Noise) */
.sidebar-calendar-item .sidebar-item-actions,
.sidebar-label-item .sidebar-item-actions {
    display: none !important;
}
.sidebar-calendar-item:hover .sidebar-item-actions,
.sidebar-label-item:hover .sidebar-item-actions {
    display: flex !important;
}

/* Mobile Utilities */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Searchable Country Autocomplete Dropdown */
.country-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    background: var(--bg-glass-surface, #ffffff);
    backdrop-filter: var(--backdrop-blur, blur(12px));
    -webkit-backdrop-filter: var(--backdrop-blur, blur(12px));
    border: 1px solid var(--border-color, #cbd5e1);
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    z-index: 99999;
    display: none;
}
.country-item:hover {
    background: var(--bg-active, #f1f5f9) !important;
}

/* =========================================
   Print Styles & PDF Export Styles
   ========================================= */
@page {
    size: landscape;
    margin: 1cm;
}

@media print {
    header, .sidebar, .calendar-toolbar, .pref-dropdown, .btn, .modal, .view-toggles, .nav-actions {
        display: none !important;
    }
    body, .calendar-workspace, .calendar-main, .calendar-container, .calendar-grid, .calendar-week-grid, .calendar-day-grid {
        background: white !important;
        color: black !important;
        margin: 0 !important;
        padding: 0 !important;
        height: auto !important;
        overflow: visible !important;
        width: 100% !important;
        max-width: 100% !important;
        box-shadow: none !important;
        border: none !important;
    }
    .event {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        page-break-inside: avoid;
    }
}

body.exporting-pdf header, 
body.exporting-pdf .sidebar, 
body.exporting-pdf .calendar-toolbar, 
body.exporting-pdf .pref-dropdown, 
body.exporting-pdf .btn, 
body.exporting-pdf .modal, 
body.exporting-pdf .view-toggles, 
body.exporting-pdf .nav-actions {
    display: none !important;
}

body.exporting-pdf, 
body.exporting-pdf .calendar-workspace, 
body.exporting-pdf .calendar-main, 
body.exporting-pdf .calendar-container, 
body.exporting-pdf .calendar-grid, 
body.exporting-pdf .calendar-week-grid, 
body.exporting-pdf .calendar-day-grid {
    background: white !important;
    color: black !important;
    margin: 0 !important;
    padding: 0 !important;
    height: auto !important;
    overflow: visible !important;
    width: 100% !important;
    max-width: 100% !important;
    box-shadow: none !important;
    border: none !important;
}

body.exporting-pdf .event {
    page-break-inside: avoid;
}

body.app-mode .event {
    page-break-inside: avoid;
}

/* ==================== STRIPE SIDEBAR & LAYOUT SYSTEM ==================== */
body.app-mode .app-container {
    display: grid;
    grid-template-columns: 240px 1fr;
    height: 100vh;
    padding: 0;
    margin: 0;
    overflow: hidden;
    background-color: var(--bg-main);
}

body.app-mode .app-container.sidebar-collapsed {
    grid-template-columns: 64px 1fr;
}

body.app-mode .stripe-sidebar {
    width: 240px;
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 16px;
    flex-shrink: 0;
    box-shadow: none;
    height: 100vh;
    box-sizing: border-box;
    transition: width 0.2s cubic-bezier(0.2, 0, 0, 1);
}

body.app-mode .app-container.sidebar-collapsed .stripe-sidebar {
    width: 64px;
    padding: 14px 8px;
    align-items: center;
}

body.app-mode .app-container.sidebar-collapsed .stripe-sidebar .sidebar-header {
    width: 100%;
    justify-content: center;
    padding-bottom: 8px;
    margin-bottom: 12px;
}

body.app-mode .app-container.sidebar-collapsed .stripe-sidebar .sidebar-brand {
    display: none !important;
}

body.app-mode .app-container.sidebar-collapsed .stripe-sidebar .sidebar-menu {
    width: 100%;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
}

body.app-mode .app-container.sidebar-collapsed .stripe-sidebar .sidebar-item {
    width: 100%;
    display: flex;
    justify-content: center;
}

body.app-mode .app-container.sidebar-collapsed .stripe-sidebar .sidebar-item a {
    width: 42px;
    height: 42px;
    padding: 0;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border-radius: var(--radius-sm);
    box-sizing: border-box;
}

body.app-mode .app-container.sidebar-collapsed .stripe-sidebar .sidebar-item a > div {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    gap: 0 !important;
}

body.app-mode .app-container.sidebar-collapsed .stripe-sidebar .sidebar-item a span:not(.status-indicator) {
    display: none !important;
}

body.app-mode .app-container.sidebar-collapsed .stripe-sidebar .sidebar-item a svg,
body.app-mode .app-container.sidebar-collapsed .stripe-sidebar .sidebar-item a i {
    width: 18px;
    height: 18px;
    margin: 0 !important;
    flex-shrink: 0;
    display: block;
}

body.app-mode .app-container.sidebar-collapsed .stripe-sidebar .sidebar-item a .status-indicator {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 6px;
    height: 6px;
}

body.app-mode .app-container.sidebar-collapsed .stripe-sidebar .sidebar-search,
body.app-mode .app-container.sidebar-collapsed .stripe-sidebar .sidebar-calendars-section,
body.app-mode .app-container.sidebar-collapsed .stripe-sidebar .sidebar-legend-section {
    display: none !important;
}

body.app-mode .app-container.sidebar-collapsed .stripe-sidebar .sidebar-footer {
    width: 100%;
    padding-top: 12px;
    align-items: center;
}

body.app-mode .app-container.sidebar-collapsed .stripe-sidebar .sidebar-footer > div {
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
}

body.app-mode .app-container.sidebar-collapsed .stripe-sidebar .sidebar-footer .theme-toggle {
    width: 42px;
    height: 42px;
    flex: none;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.app-mode .app-container.sidebar-collapsed .stripe-sidebar .sidebar-footer .lang-select-wrapper {
    display: none !important;
}

body.app-mode .stripe-sidebar .sidebar-item a:hover {
    background-color: #f4f6f8;
    color: var(--text-main);
}

body.app-mode .stripe-sidebar .sidebar-item.active a {
    background-color: transparent;
    color: var(--color-primary);
    font-weight: 400;
}

body.app-mode .stripe-sidebar .sidebar-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

body.app-mode .calendar-workspace {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100vh;
    background-color: var(--bg-surface);
    border-radius: 0;
    border: none;
    box-shadow: none;
    padding: 0;
}

body.app-mode .calendar-toolbar {
    height: auto;
    border: none;
    border-radius: 0;
    background: var(--bg-surface);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}

body.app-mode .calendar-canvas {
    background: var(--bg-surface);
    border: none;
    border-radius: 0;
    box-shadow: var(--shadow-sm);
    padding: 24px;
}

body.app-mode .calendar-month-grid {
    border-radius: 0;
}

body.app-mode .view-toggles-desktop {
    display: flex;
    background: transparent;
    padding: 0;
    border-radius: 0;
    border: none;
    border-bottom: 1px solid var(--border-color);
    gap: 16px;
}

body.app-mode .view-btn {
    border: none;
    background: transparent;
    padding: 6px 0 10px 0;
    font-size: 13px;
    font-weight: 500;
    border-radius: 0;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 150ms ease;
    border-bottom: 2px solid transparent;
    box-shadow: none !important;
}

body.app-mode .view-btn:hover {
    color: var(--text-main);
    background: transparent;
}

body.app-mode .view-btn.active {
    background: transparent;
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

/* Badges */
body.app-mode .stripe-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    line-height: 12px;
    padding: 3px 8px;
    border-radius: 4px;
}
body.app-mode .stripe-badge::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
}
body.app-mode .stripe-badge-success {
    background-color: var(--color-success-bg);
    color: var(--color-success);
}
body.app-mode .stripe-badge-success::before {
    background-color: var(--color-success);
}
body.app-mode .stripe-badge-danger {
    background-color: var(--color-danger-bg);
    color: var(--color-danger);
}
body.app-mode .stripe-badge-danger::before {
    background-color: var(--color-danger);
}

/* Inline settings panels styled like Stripe Cards */
body.app-mode .settings-panel {
    background: var(--bg-surface);
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 32px 24px 100px;
    width: 100%;
    max-width: none;
    margin: 0;
    min-height: 100%;
    box-sizing: border-box;
}

body.app-mode .settings-panel.active {
    display: block;
    max-height: none;
    overflow-y: visible;
}

body.app-mode .settings-panel > * {
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

body.app-mode .settings-panel .panel-header {
    border-bottom: 1px solid var(--border-color);
}

body.app-mode .settings-panel .panel-footer {
    border-top: 1px solid var(--border-color);
}

/* Responsive Mobile Layout and Calendar Toolbar overrides */
@media (max-width: 768px) {
    body.app-mode .app-container {
        grid-template-columns: 1fr !important;
        display: flex !important;
        flex-direction: column !important;
        height: calc(100vh - 56px) !important;
    }
    body.app-mode .stripe-sidebar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        width: 240px !important;
        height: 100vh !important;
        z-index: 9999 !important;
        transform: translateX(-100%) !important;
        transition: transform 0.3s ease-in-out !important;
        display: flex !important;
        box-shadow: var(--shadow-lg) !important;
    }
    body.app-mode .stripe-sidebar.mobile-active {
        transform: translateX(0) !important;
    }
    body.app-mode .today-btn {
        display: none !important;
    }
    body.app-mode .view-toggles-desktop {
        display: none !important;
    }
    body.app-mode .view-select-mobile {
        display: block !important;
        margin-left: 8px !important;
    }
    body.app-mode .mobile-hamburger-btn {
        display: flex !important;
    }
}
