:root {
    --bg-primary: #313338;
    --bg-secondary: #2B2D31;
    --bg-tertiary: #1E1F22;
    --channel-textarea-bg: #383A40;
    --text-normal: #DBDEE1;
    --text-muted: #949BA4;
    --header-primary: #F2F3F5;
    --interactive-normal: #B5BAC1;
    --interactive-hover: #DBDEE1;
    --brand: #5865F2;
    --brand-hover: #4752C4;
    --danger: #DA373C;
    --scrollbar-track: #2B2D31;
    --scrollbar-thumb: #1A1B1E;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-normal);
    height: 100vh;
    overflow: hidden;
}

#app {
    display: flex;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: 400px;
    background-color: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--bg-tertiary);
    min-width: 280px;
    /* Increased from 260px */
    flex-shrink: 0;
    /* Prevent flex shrinking */
}

.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

.sidebar-header {
    padding: 12px 16px;
    box-shadow: 0 1px 0 rgba(4, 4, 5, 0.2), 0 1.5px 0 rgba(6, 6, 7, 0.05), 0 2px 0 rgba(4, 4, 5, 0.05);
    color: var(--header-primary);
}

.user-info {
    margin-top: 12px;
}

.user-label {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 4px;
    display: block;
    white-space: nowrap;
}

.user-details-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    overflow: hidden;
    background: var(--bg-tertiary);
    padding: 8px;
    border-radius: 4px;
}

.user-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-normal);
}

.logout-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    flex-shrink: 0;
    transition: all 0.2s;
}

.logout-btn:hover {
    color: var(--danger);
    background: rgba(218, 55, 60, 0.1);
}

.user-actions {
    display: flex;
    gap: 24px;
    /* Increased from 12px for better separation */
    align-items: center;
}

.user-actions .icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.user-actions .icon-btn:hover {
    color: var(--text-normal);
    background-color: rgba(255, 255, 255, 0.1);
}


/* Date Navigation */
.date-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 8px;
    background: linear-gradient(135deg, rgba(88, 101, 242, 0.1) 0%, rgba(88, 101, 242, 0.05) 100%);
    border-bottom: 1px solid var(--bg-tertiary);
}

.nav-btn {
    background: var(--bg-tertiary);
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.nav-btn:hover {
    background: var(--brand);
    color: white;
    transform: scale(1.05);
}

.nav-btn svg {
    width: 18px;
    height: 18px;
}

.date-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
    cursor: default;
    padding: 6px 12px;
    border-radius: 8px;
    transition: all 0.2s ease;
    position: relative;
    pointer-events: none;
}

.date-display:hover {
    background: var(--bg-tertiary);
}

/* Hide date picker completely */
#date-picker {
    display: none !important;
}

.year {
    font-size: 11px;
    color: var(--text-muted);
}

#current-date {
    font-size: 16px;
    font-weight: 600;
    color: var(--header-primary);
}

.weekday {
    font-size: 12px;
    color: var(--text-muted);
}

.hidden-date-picker {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    cursor: pointer;
}

.today-btn {
    background: transparent;
    border: 1px solid var(--brand);
    color: var(--brand);
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.today-btn:hover {
    background: var(--brand);
    color: white;
}

/* View Tabs */
.view-tabs {
    display: flex;
    padding: 8px;
    gap: 4px;
    border-bottom: 1px solid var(--bg-tertiary);
}

.view-tab {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.view-tab:hover {
    background: var(--bg-tertiary);
    color: var(--text-normal);
}

.view-tab.active {
    background: var(--brand);
    color: white;
}

.schedule-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.no-schedules {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    text-align: center;
    color: var(--text-muted);
}

.no-schedules-icon {
    width: 48px;
    height: 48px;
    background: var(--bg-tertiary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.no-schedules-icon svg {
    width: 24px;
    height: 24px;
    color: var(--text-muted);
}

.no-schedules p {
    font-size: 13px;
    line-height: 1.4;
}

/* Schedule item date badge for week/all view */
.schedule-item .date-badge {
    font-size: 10px;
    background: var(--brand);
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    margin-bottom: 4px;
    display: inline-block;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
    background-color: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
    background-color: var(--scrollbar-thumb);
    border-radius: 4px;
}

.schedule-item {
    margin-bottom: 4px;
    border-radius: 6px;
    padding: 10px 12px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 14px;
    display: flex;
    flex-direction: column;
    background-color: rgba(88, 101, 242, 0.15);
    border-left: 4px solid var(--brand);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.schedule-item:hover {
    background-color: rgba(88, 101, 242, 0.25);
    color: var(--interactive-hover);
    border-left-color: var(--brand-hover);
}

.schedule-item .title {
    font-weight: 500;
    color: var(--text-normal);
}

.schedule-item .time {
    font-size: 12px;
}

/* Main Area */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-primary);
    position: relative;
    min-width: 0;
}

.chat-header {
    padding: 12px 16px;
    box-shadow: 0 1px 0 rgba(4, 4, 5, 0.2);
    display: flex;
    align-items: center;
    color: var(--header-primary);
    font-size: 16px;
    font-weight: 600;
}

.chat-log {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    display: flex;
    gap: 16px;
    margin-top: 8px;
}

.message:hover {
    background-color: rgba(4, 4, 5, 0.02);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    flex-shrink: 0;
}

.message.user .avatar {
    background-color: #3ba55c;
    /* Green for user */
}

.content {
    display: flex;
    flex-direction: column;
}

.username {
    font-weight: 500;
    color: var(--header-primary);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.bot-tag {
    background-color: var(--brand);
    color: white;
    font-size: 10px;
    padding: 1px 4px;
    border-radius: 4px;
    line-height: 1.3;
}

.text {
    line-height: 1.375rem;
    white-space: pre-wrap;
    color: var(--text-normal);
}

/* Input Area */
.input-area {
    padding: 0 16px 24px;
    margin-top: auto;
    display: flex;
    gap: 10px;
    align-items: center;
}

.input-wrapper {
    flex: 1;
    background-color: var(--channel-textarea-bg);
    border-radius: 8px;
    padding: 11px;
}

#chat-input {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-normal);
    font-size: 16px;
    outline: none;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--interactive-normal);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
}

.icon-btn:hover {
    color: var(--interactive-hover);
}

.icon-btn.recording {
    color: var(--danger);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.hidden {
    display: none;
}

.modal-content {
    background-color: var(--bg-primary);
    width: 500px;
    /* Slightly wider for better layout */
    max-height: 90vh;
    /* Prevent exceeding viewport height */
    display: flex;
    flex-direction: column;
    border-radius: 4px;
    padding: 0;
    /* Remove padding here, move to children for better scroll */
    box-shadow: 0 2px 10px 0 rgba(0, 0, 0, 0.2);
}

.modal-header {
    padding: 16px;
    border-bottom: 1px solid var(--bg-tertiary);
    /* Visual separation */
    flex-shrink: 0;
}

.modal-body {
    padding: 16px;
    overflow-y: auto;
    /* Enable vertical scrolling */
    flex: 1;
    /* Take remaining space */
}

/* Ensure footer (if separate) stays at bottom */
.modal-footer {
    padding: 16px;
    border-top: 1px solid var(--bg-tertiary);
    flex-shrink: 0;
    margin: 0 !important;
    /* Override previous margin hacks */
    background-color: var(--bg-secondary);
    /* Consistent footer bg */
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    color: var(--header-primary);
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
}

.form-group {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

/* Allday toggle switch styling */
.allday-toggle {
    margin-bottom: 16px;
}

.toggle-switch {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

.toggle-switch input[type="checkbox"] {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 44px;
    height: 24px;
    background-color: var(--bg-tertiary);
    border-radius: 12px;
    transition: background-color 0.3s ease;
    cursor: pointer;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    top: 3px;
    background-color: var(--text-muted);
    border-radius: 50%;
    transition: all 0.3s ease;
}

.toggle-switch input:checked+.toggle-slider {
    background-color: var(--brand);
}

.toggle-switch input:checked+.toggle-slider::before {
    transform: translateX(20px);
    background-color: white;
}

.toggle-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-normal);
}

label {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

input,
select {
    padding: 10px;
    background-color: var(--bg-tertiary);
    border: none;
    border-radius: 3px;
    color: var(--text-normal);
    font-family: inherit;
    outline: none;
}

input:focus,
select:focus {
    background-color: black;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 16px;
    background-color: var(--bg-secondary);
    margin: 16px -16px -16px -16px;
    padding: 16px;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
}

/* Standard Button Styles for Neon/Glassmorphism */
.btn-primary,
.primary-btn {
    background: linear-gradient(135deg, var(--brand), var(--brand-hover));
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(88, 101, 242, 0.4);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
}

.btn-primary:hover,
.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(88, 101, 242, 0.6);
    filter: brightness(1.1);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-normal);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 10px 24px;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(4px);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.delete-btn {
    background: rgba(218, 55, 60, 0.1);
    color: var(--danger);
    border: 1px solid rgba(218, 55, 60, 0.3);
    padding: 10px 24px;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.delete-btn:hover {
    background: var(--danger);
    color: white;
    box-shadow: 0 0 15px rgba(218, 55, 60, 0.5);
    border-color: var(--danger);
}

/* Modal Close Button Override */
.close-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    text-shadow: 0 0 8px white;
}

/* Modal Buttons Container */
.modal-buttons {
    display: flex;
    justify-content: space-between;
    /* Cancel left, Save right */
    gap: 16px;
    margin-top: 24px;
}

textarea {
    padding: 10px;
    background-color: var(--bg-tertiary);
    border: none;
    border-radius: 3px;
    color: var(--text-normal);
    font-family: inherit;
    outline: none;
    resize: vertical;
    min-height: 60px;
}

.recording {
    animation: pulse-red 1.5s infinite;
    color: var(--danger) !important;
}

@keyframes pulse-red {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }

    100% {
        opacity: 1;
    }
}

textarea:focus {
    background-color: black;
}

/* Detail Modal */
.detail-modal-content {
    width: 480px;
}

.detail-item {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--bg-tertiary);
}

.detail-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.detail-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.detail-label svg {
    width: 14px;
    height: 14px;
}

.detail-value {
    color: var(--text-normal);
    font-size: 15px;
    line-height: 1.5;
}

.detail-content {
    white-space: pre-wrap;
    background: var(--bg-tertiary);
    padding: 12px;
    border-radius: 6px;
    min-height: 40px;
}

.modal-btn {
    padding: 10px 24px;
    border-radius: 3px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background-color 0.2s;
    color: white;
}

.delete-btn {
    padding: 10px 24px;
    border-radius: 3px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background-color 0.2s;
    color: white;
    background-color: var(--danger);
}

.delete-btn:hover {
    background-color: #c62828;
}

.secondary-btn {
    background-color: #747f8d;
    color: white;
}

.secondary-btn:hover {
    background-color: #686d73;
}

.modal-footer {
    gap: 12px;
}

/* Tabs */
.tab-container {
    display: flex;
    gap: 8px;
    padding: 0 16px;
    border-bottom: 1px solid var(--bg-modified);
    height: 48px;
    align-items: center;
}

.tab-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--header-primary);
}

.add-schedule-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background-color: var(--brand);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.add-schedule-btn:hover {
    background-color: var(--brand-hover);
}

.add-schedule-btn i {
    width: 16px;
    height: 16px;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}

.tab-btn:hover {
    background-color: var(--bg-modified);
    color: var(--text-normal);
}

.tab-btn.active {
    color: var(--text-normal);
    background-color: var(--bg-tertiary);
    font-weight: 600;
}

/* Tab Contents */
/* Tab Contents */
.tab-content {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    /* height: calc(100% - 48px); removed */
}

.tab-content.active {
    display: flex;
    overflow: hidden;
    height: 100%;
    /* Restore height to fix collapse */
}

/* Calendar View */
/* Calendar View */
#tab-calendar {
    padding: 10px;
    background-color: var(--bg-primary);
}

.calendar-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    color: var(--text-normal);
}

.calendar-controls h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.calendar-wrapper {
    flex: 1;
    display: grid;
    /* Changed from flex to grid for robust height */
    grid-template-rows: auto 1fr;
    overflow: hidden;
    height: 100%;
    /* Ensure full height */
}

.calendar-header-days {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    /* Force strict equality */
    gap: 1px;
    /* Match grid gap */
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    margin-bottom: 4px;
    border: 1px solid transparent;
    /* Match grid border width identically */
    background-color: var(--bg-secondary);
    /* Match grid gap color */
    border-radius: 4px;
    /* Match grid border radius for consistent shape */
}

.calendar-header-days>div {
    background-color: var(--bg-primary);
    /* Match cal-day background */
    padding: 4px 0;
    /* Add visual padding */
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    /* Force strict equality */
    grid-template-rows: repeat(6, 1fr);
    gap: 1px;
    background-color: var(--bg-secondary);
    /* Restore grid lines */
    border: 1px solid var(--bg-secondary);
    border-radius: 4px;
    min-height: 0;
    overflow-y: hidden;
    height: 100%;
    /* Take full remaining height */
    width: 100%;
}

.cal-day {
    background-color: var(--bg-primary);
    padding: 0;
    /* Removed padding for full-width events */
    color: var(--text-normal);
    cursor: pointer;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: visible;
    /* Allow events to overlap */
}

.cal-day-header {
    flex: 0 0 auto;
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--bg-tertiary);
    z-index: 10;
    padding: 2px;
}

.cal-events-container {
    flex: 1;
    overflow-y: hidden;
    /* Hide scrollbar by default */
    overflow-x: hidden;
    /* Hide horizontal scrollbar */
    /* Scroll only events */
    min-height: 0;
    padding: 2px 0;
    /* Add vertical padding only */
    margin-right: -4px;
    /* Matched to custom scrollbar width (4px) */
    padding-right: 0;
    /* REMOVED padding to close gap for single-day events */
    scrollbar-gutter: stable;
    /* Reserve scrollbar space to prevent layout shift */
    scrollbar-width: thin;
    /* Firefox */
    scrollbar-color: var(--scrollbar-thumb) transparent;
    /* Firefox */
}

/* ... skipped intermediate blocks ... */
.cal-event-title.range-middle {
    border-radius: 0;
    border-left: none;
    /* No border */
    border-right: none;
    /* No border */
    margin-left: -5px;
    /* Offset start */
    /* Increased overlap */
    margin-right: -5px;
    /* Offset end */
    /* Increased overlap */
    width: calc(100% + 11px);
    /* Exact overlap calculation for 4px gutter */
    /* Ensure robust overlap on both sides */
    /* Overlap both sides */
    z-index: 9;
    padding-left: 12px;
    /* Increased to 12px for alignment */
}

.cal-event-title.range-end {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-left: none;
    /* No border on connected side */
    margin-left: -5px;
    /* Offset start */
    /* Increased overlap */
    width: calc(100% + 5px);
    /* Exact flush calculation for 4px gutter */
    /* Adjusted to exactly match left overlap + full width */
    /* Overlap left side */
    z-index: 10;
    padding-left: 12px;
    /* Increased to 12px for alignment */
}

/* Show scrollbar on hover */
.cal-day:hover .cal-events-container {
    overflow-y: auto;
}

/* Scrollbar for events container */
.cal-events-container::-webkit-scrollbar {
    width: 4px;
}

.cal-events-container::-webkit-scrollbar-thumb {
    background-color: var(--scrollbar-thumb);
    border-radius: 2px;
}

/* Scrollbar for cal-day - REMOVED */
.cal-day::-webkit-scrollbar {
    display: none;
}

.cal-day:hover {
    background-color: var(--bg-modified);
}

.cal-day:hover .cal-day-header {
    background-color: var(--bg-modified);
}

.cal-event-title {
    font-size: 10px;
    background-color: var(--brand);
    color: white;
    padding: 2px 4px;
    border-radius: 3px;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
    margin-left: 0;
    /* Explicitly reset */
    margin-right: 0;
    /* Explicitly reset */
    border: none;
    /* Explicitly reset */
    cursor: pointer;
    line-height: 1.2;
    display: block;
    flex-shrink: 0;
}

/* ... existing hover rules ... */

.cal-event-title.range-middle {
    border-radius: 0;
    border-left: none;
    /* No border */
    border-right: none;
    /* No border */
    margin-left: -5px;
    /* Offset start */
    /* Increased overlap */
    margin-right: -5px;
    /* Offset end */
    /* Increased overlap */
    width: calc(100% + 15px);
    /* Ensure robust overlap on both sides */
    /* Overlap both sides */
    z-index: 9;
    padding-left: 10px;
    /* Increased to 10px to fix alignment */
}

.cal-event-title.range-end {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-left: none;
    /* No border on connected side */
    margin-left: -5px;
    /* Offset start */
    /* Increased overlap */
    width: calc(100% + 5px);
    /* Adjusted to exactly match left overlap + full width */
    /* Overlap left side */
    z-index: 10;
    padding-left: 10px;
    /* Increased to 10px to fix alignment */
}

/* Removed .cal-day:hover .cal-event-title rule to prevent layout shifts */

.cal-event-title:hover {
    background-color: var(--brand-hover);
}

/* Multi-day range schedule styles */
/* Multi-day range schedule styles */
.cal-event-title.range-start {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: none;
    /* No border on connected side */
    margin-right: -5px;
    /* Offset to push into overlap */
    /* Increased overlap */
    width: calc(100% + 12px);
    /* Much wider to overcome scrollbar width */
    /* Extend further */
    z-index: 8;
    /* Lower than Middle (9) */
    padding-right: 4px;
    /* Maintain text padding visual */
}

.cal-event-title.range-middle {
    border-radius: 0;
    border-left: none;
    /* No border */
    border-right: none;
    /* No border */
    margin-left: -5px;
    /* Offset start */
    /* Increased overlap */
    margin-right: -5px;
    /* Offset end */
    /* Increased overlap */
    width: calc(100% + 15px);
    /* Ensure robust overlap on both sides */
    /* Overlap both sides */
    z-index: 9;
    padding-left: 12px;
    /* Increased to 12px for alignment */
}

.cal-event-title.range-end {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-left: none;
    /* No border on connected side */
    margin-left: -5px;
    /* Offset start */
    /* Increased overlap */
    width: calc(100% + 5px);
    /* Adjusted to exactly match left overlap + full width */
    /* Overlap left side */
    z-index: 10;
    padding-left: 12px;
    /* Increased to 12px for alignment */
}

/* Add connecting line effect */
.cal-event-title.range-start::after,
.cal-event-title.range-middle::after {
    content: '';
    position: absolute;
    right: -2px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 2px;
    background-color: var(--brand-hover);
}


.cal-day.empty {
    background-color: var(--bg-secondary);
    cursor: default;
}



/* Use pseudo-element to overlay border ON TOP of header and events */
.cal-day.selected::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 2px solid var(--brand-hover);
    z-index: 20;
    /* Ensure it sits above header (z-10) and events (z-10) */
    pointer-events: none;
    /* specific click events fall through to underlying elements */
    border-radius: 4px;
    /* Match container */
}

.cal-day-num {
    font-size: 12px;
    color: var(--text-muted);
    padding: 2px 4px;
    width: 100%;
    text-align: left;
}

/* Ensure hover state also updates sticky header bg */
.cal-day:hover .cal-day-num {
    background-color: var(--bg-modified);
}

.cal-day.today .cal-day-num {
    color: var(--brand);
    font-weight: bold;
}


.cal-event-text {
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background-color: var(--bg-tertiary);
    border-radius: 2px;
    padding: 2px 4px;
    line-height: 1.2;
}

/* Bottom Navigation (Mobile) */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background-color: var(--bg-primary);
    border-top: 1px solid var(--bg-modified);
    justify-content: space-around;
    align-items: center;
    z-index: 1000;
}

.nav-item {
    background: none;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 10px;
    cursor: pointer;
    padding: 8px;
    width: 100%;
}

.nav-item i {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
}

.nav-item.active {
    color: var(--brand);
}

/* PC Defaults - Ensure bottom nav is hidden */
@media (min-width: 769px) {
    .bottom-nav {
        display: none !important;
    }
}

/* Mobile Responsive Styles - List+Calendar / Registration swipe */
@media (max-width: 768px) {

    /* Full screen container */
    #app {
        display: block;
        position: relative;
        height: 100vh;
        overflow: hidden;
    }

    /* Home view: Sidebar (list) at top 45% */
    .sidebar {
        width: 100%;
        height: 45%;
        position: absolute;
        top: 0;
        left: 0;
        z-index: 10;
        display: flex;
        flex-direction: column;
        background-color: var(--bg-secondary);
        transition: transform 0.3s ease;
        overflow: hidden;
    }

    /* Calendar section at bottom 55% */
    .calendar-section {
        width: 100%;
        height: 55%;
        position: absolute;
        top: 45%;
        left: 0;
        z-index: 10;
        display: flex;
        flex-direction: column;
        background-color: var(--bg-primary);
        transition: transform 0.3s ease;
        overflow: hidden;
        padding: 8px;
    }

    /* When hidden (swiped to registration) */
    .sidebar.mobile-hidden,
    .calendar-section.mobile-hidden {
        transform: translateX(-100%);
    }

    /* Registration screen (full screen, behind by default) */
    .main-area {
        width: 100%;
        height: 100%;
        position: absolute;
        top: 0;
        left: 0;
        z-index: 5;
        display: flex;
        flex-direction: column;
        background-color: var(--bg-primary);
    }

    /* Hide Bottom Nav */
    .bottom-nav {
        display: none;
    }

    /* Chat header style */
    .chat-header {
        height: 44px;
        display: flex;
        align-items: center;
        padding: 0 16px;
        border-bottom: 1px solid var(--bg-tertiary);
        flex-shrink: 0;
    }

    .chat-title {
        font-weight: 600;
        color: var(--text-normal);
    }

    .chat-log {
        flex: 1;
        overflow-y: auto;
    }

    /* Calendar adjustments for mobile */
    .calendar-controls {
        flex-shrink: 0;
    }

    .calendar-wrapper {
        flex: 1;
        min-height: 0;
        overflow: auto;
    }

    .calendar-grid {
        grid-template-rows: repeat(6, minmax(40px, 1fr));
    }

    /* Compact Schedule List for Mobile */
    .schedule-item {
        flex-direction: row;
        align-items: center;
        padding: 4px 8px;
        margin-bottom: 1px;
        gap: 8px;
        background-color: var(--bg-tertiary);
        border-radius: 4px;
    }

    .schedule-item .time {
        font-size: 11px;
        font-weight: 600;
        color: var(--brand);
        min-width: 40px;
        flex-shrink: 0;
    }

    .schedule-item .title {
        font-size: 12px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        flex: 1;
    }

    .schedule-item .location {
        display: none;
        /* Hide location on mobile to save space */
    }

    /* Sidebar header compact */
    .sidebar-header {
        padding: 8px 12px;
    }

    .sidebar-header h2 {
        font-size: 16px;
    }

    .date-nav {
        padding: 4px 8px;
    }

    /* Disable date picker click on mobile */
    .date-display {
        pointer-events: none;
        cursor: default;
    }

    #date-picker {
        display: none !important;
    }

    .view-tabs {
        padding: 4px 8px;
    }

    .schedule-list {
        padding: 4px 8px;
        flex: 1;
        overflow-y: auto;
    }

    .no-schedules {
        padding: 12px 8px;
        font-size: 12px;
    }

    /* Hide Voice Button on Mobile */
    #voice-btn {
        display: none !important;
    }

    /* Modal adjustments */
    .modal-content {
        width: 95%;
        margin: 10px auto;
    }

    /* Swipe hint indicator on calendar section */
    .calendar-section::after {
        content: '';
        position: absolute;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
        width: 4px;
        height: 40px;
        background: var(--text-muted);
        border-radius: 4px;
        opacity: 0.3;
    }
}

/* PC: Calendar section hidden (use tab instead) */
@media (min-width: 769px) {
    .calendar-section {
        display: none;
    }
}

/* Event count badge */
.cal-event-count {
    background-color: var(--brand);
    color: white;
    font-size: 10px;
    font-weight: bold;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 2px auto 0;
}

/* Resizer */
#resizer {
    width: 5px;
    background-color: var(--bg-tertiary);
    cursor: col-resize;
    user-select: none;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

#resizer:hover,
#resizer.resizing {
    background-color: var(--brand);
}

/* Timeline View */
.timeline-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    position: relative;
    background-color: var(--bg-secondary);
}

.timeline-header {
    padding: 12px;
    border-bottom: 1px solid var(--bg-tertiary);
    text-align: center;
}

.allday-section {
    padding: 8px;
    border-bottom: 1px solid var(--bg-tertiary);
    background-color: var(--bg-secondary);
    max-height: 100px;
    overflow-y: auto;
}

.cal-event-title {
    background-color: var(--brand);
    color: white;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 6px;
    /* Increased from small value or 0 */
    margin-bottom: 2px;
    margin-left: 2px;
    /* Add margin */
    margin-right: 2px;
    /* Add margin */
    width: calc(100% - 4px);
    /* Adjust width */
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    /* Add depth */
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    /* Enable z-index */
}

.allday-item {
    background-color: var(--brand);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    margin-bottom: 4px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.timeline-scroll-area {
    flex: 1;
    overflow-y: auto;
    position: relative;
    display: flex;
}

.time-axis {
    width: 50px;
    flex-shrink: 0;
    border-right: 1px solid var(--bg-tertiary);
    background-color: var(--bg-secondary);
    position: relative;
    height: 1440px;
    /* 24 hours * 60px */
}

.time-label {
    position: absolute;
    width: 100%;
    text-align: right;
    padding-right: 8px;
    font-size: 11px;
    color: var(--text-muted);
    transform: translateY(-50%);
    height: 12px;
}

.timeline-grid {
    flex: 1;
    position: relative;
    background-color: var(--bg-secondary);
    height: 1440px;
    /* 24 hours * 60px */
}

.grid-line {
    position: absolute;
    left: 0;
    right: 0;
    border-top: 1px dashed var(--bg-tertiary);
    pointer-events: none;
}

.grid-line.hour {
    border-top: 1px dashed rgba(255, 255, 255, 0.6) !important;
    /* Thick dashed line */
}

.grid-line.thirty {
    border-top: 1px dashed rgba(255, 255, 255, 0.2);
    /* Clear dashed */
}

.grid-line.quarter {
    border-top: 1px dotted rgba(255, 255, 255, 0.1);
    /* Subtle dot */
}

.timeline-event {
    position: absolute;
    left: 4px;
    right: 4px;
    background-color: var(--bg-modified);
    border-left: 3px solid var(--brand);
    border-radius: 3px;
    padding: 2px 4px;
    font-size: 11px;
    overflow: hidden;
    cursor: pointer;
    z-index: 10;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    transition: transform 0.1s;
}

.timeline-event:hover {
    transform: scale(1.02);
    z-index: 20;
    background-color: var(--bg-tertiary);
}

/* Interruptible Event Style - Striped for visibility */
.timeline-event.interruptible {
    border-left-color: #3ba55c;
    /* Green */
    background: repeating-linear-gradient(45deg,
            rgba(59, 165, 92, 0.2),
            rgba(59, 165, 92, 0.2) 10px,
            rgba(59, 165, 92, 0.3) 10px,
            rgba(59, 165, 92, 0.3) 20px);
}

.timeline-event.interruptible:hover {
    background: repeating-linear-gradient(45deg,
            rgba(59, 165, 92, 0.3),
            rgba(59, 165, 92, 0.3) 10px,
            rgba(59, 165, 92, 0.4) 10px,
            rgba(59, 165, 92, 0.4) 20px);
}

.timeline-event.interruptible::after {
    content: '🔓 割り込み可';
    position: absolute;
    bottom: 2px;
    right: 4px;
    font-size: 10px;
    color: #4ade80;
    font-weight: bold;
    opacity: 0.9;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.timeline-event .event-title {
    font-weight: 600;
    color: var(--text-normal);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.timeline-event .event-time {
    font-size: 10px;
    color: var(--text-muted);
}

.current-time-line {
    position: absolute;
    left: 0;
    right: 0;
    border-top: 2px solid #3b82f6;
    /* Blue line */
    z-index: 30;
    pointer-events: none;
}

.current-time-circle {
    position: absolute;
    left: -5px;
    top: -6px;
    /* Optimized */
    width: 10px;
    height: 10px;
    background-color: #3b82f6;
    border-radius: 50%;
}

/* User Info Tweaks */
.sidebar-header {
    display: flex;
    flex-direction: column;
}

.user-info {
    margin-top: 16px;
}

.user-label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.user-details-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Header Action Buttons */
.action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background-color: var(--bg-tertiary);
    border: none;
    border-radius: 4px;
    color: var(--text-normal);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    margin-left: 8px;
    height: 32px;
}

.action-btn:hover {
    background-color: var(--brand);
    color: white;
}

.action-btn svg {
    width: 16px;
    height: 16px;
}

#settings-btn {
    transition: all 0.2s;
    border-radius: 4px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
}

#settings-btn:hover {
    color: var(--brand);
    background-color: var(--bg-tertiary);
}

/* Settings Modal */
.settings-section {
    padding: 16px 0;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 0px solid var(--bg-tertiary);
}

.setting-label {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.setting-label span:first-child {
    font-weight: 500;
    color: var(--text-normal);
}

.setting-desc {
    font-size: 12px;
    color: var(--text-muted);
}

/* Toggle Switch (iOS Style) */
.ios-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.ios-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.ios-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-tertiary);
    transition: .4s;
    border-radius: 24px;
}

.ios-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.ios-slider {
    background-color: var(--brand);
}

input:checked+.ios-slider:before {
    transform: translateX(20px);
}

/* Chat Log Area */
.chat-container {
    height: 150px;
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--bg-tertiary);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.chat-log {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 13px;
}

.message {
    padding: 8px 12px;
    border-radius: 8px;
    max-width: 90%;
    line-height: 1.4;
    word-wrap: break-word;
}

.user-message {
    background-color: var(--brand);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

.bot-message {
    background-color: var(--bg-tertiary);
    color: var(--text-normal);
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}

/* Custom Month Picker */
.month-picker {
    position: absolute;
    top: 120%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #2f3136;
    /* Discord popout color */
    border: 1px solid #202225;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    padding: 12px;
    z-index: 1000;
    width: 220px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    color: var(--text-normal);
}

.month-picker.hidden {
    display: none;
}

.month-picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-secondary);
    border-radius: 4px;
    padding: 4px;
    margin-bottom: 4px;
}

.month-picker .icon-btn-small {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    width: 28px;
    height: 28px;
}

.month-picker .icon-btn-small:hover {
    background-color: var(--bg-modified);
    color: var(--text-normal);
}

#mp-current-year {
    font-weight: bold;
    font-size: 15px;
}

.month-picker-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.month-item {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background-color 0.2s;
}

.month-item:hover {
    background-color: var(--bg-modified);
}

.month-item.selected {
    background-color: var(--brand);
    color: white;
    font-weight: bold;
}

.month-picker-footer {
    display: flex;
    justify-content: flex-end;
    border-top: 1px solid var(--bg-tertiary);
    padding-top: 8px;
}

.text-btn {
    background: none;
    border: none;
    color: var(--brand);
    cursor: pointer;
    font-size: 13px;
    padding: 4px 8px;
    border-radius: 4px;
}

.text-btn:hover {
    text-decoration: underline;
}

/* Timeline View (Day View) Styles */
.timeline-scroll-area {
    display: flex;
    overflow-y: auto;
    flex: 1;
    position: relative;
    padding-top: 10px;
    height: 100%;
}

.time-axis {
    width: 50px;
    flex-shrink: 0;
    position: relative;
    border-right: 1px solid var(--bg-tertiary);
    height: 1440px;
    /* 24h * 60px */
}

.time-label {
    position: absolute;
    width: 100%;
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    transform: translateY(-6px);
}

.timeline-grid {
    flex: 1;
    position: relative;
    height: 1440px;
}

.grid-line {
    position: absolute;
    width: 100%;
    border-top: 1px solid var(--bg-tertiary);
    height: 1px;
}

.grid-line.hour {
    border-top: 1px solid var(--bg-modified);
}

.timeline-event {
    position: absolute;
    left: 4px;
    right: 12px;
    background-color: rgba(88, 101, 242, 0.25);
    border-left: 4px solid var(--brand);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    transition: background-color 0.2s;
    z-index: 10;
}

.timeline-event:hover {
    background-color: rgba(88, 101, 242, 0.4);
    z-index: 11;
}

.timeline-event .event-title {
    font-weight: 600;
    color: var(--text-normal);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.timeline-event .event-time {
    font-size: 11px;
    color: var(--text-muted);
}

.current-time-line {
    position: absolute;
    width: 100%;
    height: 2px;
    background-color: #f23f42;
    z-index: 20;
    pointer-events: none;
}

.current-time-circle {
    display: none;
}

/* Timeline Selection (Voice Recording) */
.timeline-selection {
    position: absolute;
    left: 4px;
    right: 14px;
    /* Account for scrollbar */
    background-color: rgba(218, 55, 60, 0.3);
    /* Red transparent */
    border: 2px solid var(--danger);
    border-radius: 4px;
    pointer-events: none;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 12px;
}

.timeline-selection.recording-active {
    animation: selectionPulse 1.5s infinite;
}

.selection-label {
    background-color: var(--danger);
    padding: 2px 8px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.selection-label svg {
    width: 12px;
    height: 12px;
}

@keyframes selectionPulse {
    0% {
        background-color: rgba(218, 55, 60, 0.3);
        border-color: var(--danger);
    }

    50% {
        background-color: rgba(218, 55, 60, 0.5);
        border-color: #ff5e63;
    }

    100% {
        background-color: rgba(218, 55, 60, 0.3);
        border-color: var(--danger);
    }
}

/* Interruptible Schedule Styling */
/* Month View */
.cal-event-title.interruptible {
    background: #2e7d32 !important;
    /* Overrides gradient in range-middle */
    color: #e8f5e9 !important;
    /* Light Green Text */
    box-shadow: none;
    font-weight: normal;
}

.cal-event-title.interruptible:hover {
    background: #388e3c !important;
}

/* Day View Timeline */
.timeline-event.interruptible {
    background-color: rgba(46, 125, 50, 0.25) !important;
    border-left: 3px solid #2e7d32 !important;
    border: 1px solid rgba(46, 125, 50, 0.4);
    border-left-width: 3px;
    color: white !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.timeline-event.interruptible .event-time {
    color: #81c784 !important;
    /* Lighter green text */
}

/* Sidebar List */
.schedule-item.interruptible {
    border-left: 3px solid #2e7d32 !important;
    background: linear-gradient(90deg, rgba(46, 125, 50, 0.1) 0%, transparent 100%);
}

.schedule-item.interruptible .time {
    color: #4caf50 !important;
}

/* Day View All-Day Item */
.allday-item.interruptible {
    background-color: #2e7d32 !important;
    color: #e8f5e9 !important;
    border-radius: 4px;
    box-shadow: none;
    font-weight: normal;
}

/* Custom Date/Time Picker Styles */
.custom-picker {
    position: fixed;
    background-color: #2f3136;
    border: 1px solid #202225;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    padding: 12px;
    z-index: 2000;
    color: var(--text-normal);
    display: flex;
    flex-direction: column;
    gap: 12px;
    user-select: none;
}

.custom-picker.hidden {
    display: none;
}

.picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.picker-header span {
    font-weight: bold;
    font-size: 15px;
}

/* Date Picker Specifics */
.date-picker {
    width: 260px;
}

.weekdays-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.picker-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.picker-day {
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background-color 0.2s;
}

.picker-day:hover {
    background-color: var(--bg-modified);
}

.picker-day.current-month {
    color: var(--text-normal);
}

.picker-day.other-month {
    color: var(--text-muted);
    opacity: 0.5;
}

.picker-day.today {
    border: 1px solid var(--brand);
}

.picker-day.selected {
    background-color: var(--brand);
    color: white;
    font-weight: bold;
}

.picker-footer {
    display: flex;
    justify-content: flex-end;
    border-top: 1px solid var(--bg-tertiary);
    padding-top: 8px;
    margin-top: 4px;
}

/* Time Picker Specifics */
.time-picker {
    width: 180px;
}

.time-picker-columns {
    display: flex;
    height: 200px;
    gap: 8px;
    justify-content: center;
}

.time-column {
    flex: 1;
    overflow-y: auto;
    border-radius: 4px;
    background-color: var(--bg-secondary);
    padding: 4px;
}


.time-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: var(--text-muted);
}

.time-item {
    padding: 6px;
    text-align: center;
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
    margin-bottom: 2px;
}

.time-item:hover {
    background-color: var(--bg-modified);
}

.time-item.selected {
    background-color: var(--brand);
    color: white;
}

/* Make custom inputs look like clickable fields */
.custom-date-input,
.custom-time-input {
    cursor: pointer;
    background-color: var(--bg-tertiary);
}

/* Custom Scrollbar for Time Picker */
.time-column {
    scrollbar-width: thin;
    scrollbar-color: #40444b #202225;
}

.time-column::-webkit-scrollbar {
    width: 8px;
}

.time-column::-webkit-scrollbar-track {
    background: #202225;
    border-radius: 4px;
}

.time-column::-webkit-scrollbar-thumb {
    background: #40444b;
    border-radius: 4px;
    border: 2px solid #202225;
    /* internal padding effect */
}

.time-column::-webkit-scrollbar-thumb:hover {
    background: #72767d;
}

/* Validation Popup */
.validation-popup {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    background-color: #2f3136;
    border: 1px solid #DA373C;
    color: #DA373C;
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    font-weight: 600;
    font-size: 14px;
    opacity: 1;
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
    pointer-events: none;
}

.validation-popup.hidden {
    display: block !important;
    /* Override global hidden for transition */
    opacity: 0;
    transform: translate(-50%, -20px);
    pointer-events: none;
}

/* =========================================
   Friend UI Styles
   ========================================= */

/* Friend Panel (Fixed Side Overlay) */
.friend-panel {
    position: fixed;
    top: 0;
    right: -400px;
    /* Hidden initially */
    width: 350px;
    height: 100vh;
    background-color: var(--bg-secondary);
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.5);
    z-index: 1001;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--bg-tertiary);
}

.friend-panel.open {
    right: 0;
}

.panel-header {
    padding: 16px;
    background-color: var(--bg-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--bg-tertiary);
    color: var(--header-primary);
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.friend-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.friend-section h3 {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
}

/* My Card */
.my-code-display {
    background-color: var(--bg-tertiary);
    padding: 12px;
    border-radius: 8px;
}

.code-box {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    background: var(--bg-secondary);
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid var(--bg-primary);
}

.code-box span {
    font-family: monospace;
    font-size: 18px;
    flex: 1;
    text-align: center;
    letter-spacing: 2px;
    color: var(--brand);
    font-weight: 600;
}

.icon-btn-small {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn-small:hover {
    color: var(--text-normal);
}

.icon-btn-small svg {
    width: 16px;
    height: 16px;
}

/* Add Friend Input */
.add-friend-input-group {
    display: flex;
    gap: 8px;
}

.add-friend-input-group input {
    flex: 1;
    text-transform: uppercase;
}

.btn-primary-small {
    background-color: var(--brand);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.btn-primary-small:hover {
    background-color: var(--brand-hover);
}

/* Friend List Items */
.friend-request-item,
.friend-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: 4px;
    background: var(--bg-tertiary);
    transition: background 0.2s;
}

.friend-request-item:hover,
.friend-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.friend-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--brand);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    flex-shrink: 0;
}

.friend-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.friend-name {
    font-weight: 600;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.friend-status {
    font-size: 11px;
    color: var(--text-muted);
}

.friend-actions {
    display: flex;
    gap: 8px;
}

.btn-approve {
    background-color: #3ba55c;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
}

.btn-reject {
    background-color: var(--danger);
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
}

.success-text {
    color: #3ba55c;
    font-size: 12px;
    margin-top: 4px;
}

.error-text {
    color: var(--danger);
    font-size: 12px;
    margin-top: 4px;
}

.no-friends {
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.no-friends {
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    padding: 16px;
    border-radius: 4px;
}

/* Member Selection (Phase 4) */
.member-selection-list {
    max-height: 150px;
    overflow-y: auto;
    border: 1px solid var(--bg-tertiary);
    border-radius: 8px;
    padding: 10px;
    background: var(--bg-secondary);
    margin-top: 5px;
}

.member-selection-item {
    display: flex;
    align-items: center;
    padding: 6px;
    gap: 10px;
    border-radius: 6px;
    transition: background 0.2s;
}

.member-selection-item:hover {
    background: var(--bg-tertiary);
}

.member-selection-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.member-selection-item label {
    font-size: 14px;
    cursor: pointer;
}

.hint-text {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Group Chips (Header) */
.group-list-header {
    /* Layout already inline in HTML but can enforce here */
    scrollbar-width: none;
    /* Hide scrollbar Firefox */
}

.group-list-header::-webkit-scrollbar {
    display: none;
    /* Hide scrollbar Chrome/Safari */
}

.group-chip {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background-color: rgba(255, 255, 255, 0.05);
    /* Transparent-ish gray */
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    /* Pill shape */
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.group-chip:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-normal);
}

.group-chip.active {
    background-color: var(--brand);
    /* Active Primary Color */
    color: white;
    border-color: var(--brand);
    box-shadow: 0 2px 8px rgba(88, 101, 242, 0.3);
}

.group-chip.active:hover {
    background-color: var(--brand-hover);
}

/* Group Member List in Detail Modal */
.member-list-display {
    max-height: 120px;
    overflow-y: auto;
    background-color: var(--bg-tertiary);
    border-radius: 4px;
    padding: 8px;
    list-style: none;
    margin: 0;
}

.member-list-display li {
    padding: 4px 8px;
    font-size: 13px;
    color: var(--text-normal);
    border-bottom: 1px solid var(--bg-secondary);
}

.member-list-display li:last-child {
    border-bottom: none;
}

/* Side Panel */
.side-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 360px;
    height: 100vh;
    background-color: var(--bg-secondary);
    box-shadow: -4px 0 15px rgba(0, 0, 0, 0.3);
    z-index: 2000;
    transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--bg-tertiary);
}

.side-panel.open {
    right: 0;
}

.side-panel .panel-header {
    padding: 16px;
    border-bottom: 1px solid var(--bg-tertiary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-secondary);
}

.side-panel .panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.friend-section {
    margin-bottom: 24px;
}

.code-box-row {
    display: flex;
    gap: 8px;
    align-items: center;
    background: var(--bg-tertiary);
    padding: 8px;
    border-radius: 4px;
    margin-top: 4px;
}

.code-text {
    font-family: monospace;
    font-size: 14px;
    font-weight: bold;
    color: var(--text-normal);
    flex: 1;
    letter-spacing: 1px;
}

/* Friend Panel Tabs */
.friend-panel-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin: 16px -16px;
    /* Negate padding */
    padding: 0 16px;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.tab-btn:hover {
    color: var(--text-normal);
    background: var(--bg-tertiary);
}

.tab-btn.active {
    color: var(--brand);
    border-bottom-color: var(--brand);
    font-weight: 600;
}

.panel-tab-content {
    display: none;
    animation: fadeIn 0.2s ease;
}

.panel-tab-content.active {
    display: block;
}

/* Group List Vertical */
.group-actions-panel {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.group-actions-panel .action-btn {
    flex: 1;
    justify-content: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 8px;
    border-radius: 4px;
    color: var(--text-normal);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background-color 0.2s;
}

.group-actions-panel .action-btn:hover {
    background: var(--bg-tertiary);
}

.group-list-vertical {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.group-list-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s;
}

.group-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    cursor: pointer;
}

.group-item-header:hover {
    background: var(--bg-tertiary);
}

.group-item-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.group-item-name {
    font-weight: 500;
    color: var(--text-normal);
}

.group-item-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.group-members-list {
    display: none;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    padding: 8px;
    list-style: none;
    margin: 0;
}

.group-list-item.expanded .group-members-list {
    display: block;
}

.group-member-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    font-size: 13px;
    color: var(--text-muted);
}

/* Header Layout Fix */
.chat-header {
    width: 100%;
}

.tab-container {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab-container>div[style*="flex-grow: 1"] {
    flex-grow: 1 !important;
}

/* Tab Content Visibility */
.panel-tab-content {
    display: none;
    /* Hide by default */
}

.panel-tab-content.active {
    display: block;
    /* Show when active */
}

/* Group Tabs in Calendar Header */
.group-tabs-container {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--border-color);
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
}

.group-tabs-container::-webkit-scrollbar {
    display: none;
}

.group-tab {
    padding: 6px 12px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-muted);
    font-size: 0.85em;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.group-tab:hover {
    background: var(--bg-tertiary);
    color: var(--text-normal);
}

.group-tab.active {
    background: var(--brand);
    color: white;
    border-color: var(--brand);
    font-weight: 500;
}