:root {
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --text-primary: #1a1b1e;
    --text-secondary: #868e96;
    --accent-color: #4c6ef5;
    /* Indigo */
    --accent-glow: rgba(76, 110, 245, 0.3);
    --danger-color: #fa5252;
    --sunday-color: #fa5252;
    --saturday-color: #228be6;
    --border-radius: 16px;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
    --font-family: 'Nanum Gothic', 'Inter', 'Noto Sans KR', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    /* Prevent double-tap zoom */
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow: hidden;
    /* Prevent body scroll, handle in main */
    height: 100vh;
    height: 100dvh;
    display: flex;
    justify-content: center;
}

.app-container {
    width: 100%;
    max-width: 600px;
    /* Mobile constraint on desktop */
    height: 100%;
    display: flex;
    flex-direction: column;
    background-color: var(--card-bg);
    position: relative;
    box-shadow: var(--shadow-sm);
}

/* Header */
.calendar-header {
    padding: 10px 8px;
    /* Reduced vertical padding */
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
    /* No blur */
    z-index: 10;
    border-bottom: 1px solid #e9ecef;
}

#current-month-year {
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 8px;
}

#current-month-year::after {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid var(--text-primary);
    margin-top: 4px;
    /* visually center */
}

#current-month-year:hover {
    background-color: #f1f3f5;
}

#current-month-year:active {
    background-color: #e9ecef;
    transform: scale(0.98);
}

/* Today Button Style */
#btn-today {
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 6px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
    box-shadow: 0 2px 8px var(--accent-glow);
}

/* ... (omitted) ... */

.memo-item {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.memo-text {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
}

.memo-delete {
    color: var(--text-secondary);
    background: none;
    border: none;
    padding: 8px;
    /* Larger hit area */
    cursor: pointer;
    font-size: 1.5rem;
    /* Larger Icon */
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.memo-list-dot {
    width: 12px;
    /* Larger dot */
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

#btn-today:active {
    transform: scale(0.95);
}

/* Main Calendar Area */
.calendar-main {
    flex: 1;
    overflow: hidden;
    position: relative;
    /* display: flex; Removed to allow slider block */
}

/* Slider Track */
.slider-track {
    display: flex;
    width: 300%;
    /* 3 months wide */
    height: 100%;
    transform: translateX(-33.333333%);
    /* Start at center */
    will-change: transform;
    /* Hint for performance */
}

.month-view {
    width: 33.333333%;
    /* 1/3 of track */
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 0;
    flex-shrink: 0;
    /* Don't shrink */
    /* Borders moved to .days-grid as per request */
}

.weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    padding: 10px 0;
    font-weight: 500;
    color: #495057;
    /* Darker weekday text */
    font-size: 0.9rem;
    border-bottom: 1px solid #dee2e6;
    /* Darker border */
    background: rgba(76, 110, 245, 0.05);
    /* Very light accent color */
}

.days-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: repeat(6, 1fr);
    gap: 0;
    flex: 1;
    background: #dee2e6;
    /* Darker grid base */
    border-bottom: 1px solid #dee2e6;
    border-right: 1px solid #dee2e6;
    /* Moved here */
    border-left: 1px solid #dee2e6;
    /* Moved here */
}

.day-cell {
    background: var(--card-bg);
    border-right: 1px solid #dee2e6;
    border-bottom: 1px solid #dee2e6;
    padding: 0;
    /* Removed padding to maximize space */
    padding-top: 4px;
    /* Only top padding */
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    position: relative;
    cursor: pointer;
    transition: background-color 0.2s;
    overflow: hidden;
}

.day-cell:nth-child(7n) {
    border-right: none;
}

.day-cell.today {
    background-color: rgba(76, 110, 245, 0.05);
    box-shadow: inset 0 0 0 1px var(--accent-color);
}

.day-number {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 2px;
    width: 100%;
    padding-left: 4px;
    /* Added internal padding */
}

.lunar-date {
    display: none;
}

.day-cell .lunar-date-mini {
    font-size: 0.6rem;
    color: #adb5bd;
    position: absolute;
    top: 6px;
    right: 6px;
}

.holiday-name {
    font-size: 0.6rem;
    color: var(--danger-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    padding-left: 4px;
    /* Added padding to restore alignment */
}

.day-cell:nth-child(7n+1) .day-number {
    color: var(--sunday-color);
}

.day-cell:nth-child(7n) .day-number {
    color: var(--saturday-color);
}

.day-cell.other-month {
    background-color: #f1f3f5;
    color: #868e96;
    /* Darker other month text */
}

.day-cell.other-month .day-number {
    color: #868e96;
    opacity: 0.6;
}

/* Memo Preview Text in Cell */
.memo-preview {
    font-size: 0.6rem;
    padding: 2px 1px;
    /* Reduced inner padding */
    border-radius: 4px;
    margin: 2px 1px 0 1px;
    /* 1px outer margin */
    width: calc(100% - 2px);
    /* Full width minus margins */

    /* Multiline Support */
    white-space: normal;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;

    color: white;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);
    text-align: center;
    /* Center alignment */
    line-height: 1.3;
    /* Fix line height for consistency */
}

/* Modals */
.modal-container {
    position: absolute;
    /* Changed from fixed to absolute to stick to app container */
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
}

.modal-container.active {
    pointer-events: auto;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.2s;
    /* Slower */
}

.modal-container.active .modal-backdrop {
    opacity: 1;
}

.modal-content {
    background: var(--card-bg);
    width: 90%;
    /* Increased side margins */
    max-width: 550px;
    /* Allow wider on tablet/desktop */
    border-radius: 20px;
    padding: 24px;
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.2s cubic-bezier(0.19, 1, 0.22, 1);
    /* Slower */
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    max-height: 85vh;
    max-height: 85dvh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    position: relative;
    pointer-events: auto;
    z-index: 1001;
    margin: auto;
}

.modal-container.active .modal-content.active {
    transform: translateY(0);
    opacity: 1;
}

.hidden {
    display: none !important;
}

/* Buttons and Controls */
.btn-add-memo {
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    box-shadow: 0 4px 12px var(--accent-glow);
    cursor: pointer;
    margin-top: 15px;
    width: 100%;
    transition: transform 0.2s;
}

.btn-add-memo:active {
    transform: scale(0.98);
}

.datepicker-controls {
    display: flex;
    gap: 10px;
    margin: 20px 0;
}

.datepicker-controls select {
    flex: 1;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid #dee2e6;
    font-size: 1rem;
    background: white;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: auto;
}

.btn-primary,
.btn-secondary {
    flex: 1;
    padding: 14px;
    border-radius: 12px;
    border: none;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
}

.btn-primary {
    background-color: var(--accent-color);
    color: white;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-secondary {
    background-color: #f1f3f5;
    color: var(--text-primary);
}

/* Memo Details */
.memo-header {
    margin-bottom: 20px;
    display: flex;
    align-items: baseline;
    /* Align text baselines */
    gap: 8px;
    /* Spacing between date and lunar date */
}

/* Override global display:none for lunar date inside memo header */
.memo-header .lunar-date {
    display: inline-block;
    /* Show it! */
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.memo-markers {
    display: flex;
    gap: 4px;
    margin-top: 2px;
    flex-wrap: wrap;
    justify-content: center;
}

.memo-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--accent-color);
}

.color-picker {
    display: flex;
    gap: 6px;
    /* Reduced gap */
    margin: 15px 0;
    flex-wrap: wrap;
    /* Allow wrapping if there are many colors */
}

.color-option {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    flex-shrink: 0;
    /* Prevent squashing into ovals */
}

.color-option.selected {
    border-color: #000;
    transform: scale(1.1);
}

#memo-input-text {
    width: 100%;
    padding: 12px;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    margin-bottom: 10px;
    margin-top: 15px;
    /* Added spacing from title */
    font-size: 1rem;
}

.checkbox-group {
    display: flex;
    flex-direction: row;
    /* Explicitly set to row */
    flex-wrap: wrap;
    /* Allow wrapping if needed */
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    margin-bottom: 0;
    /* Override */
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--accent-color);
    cursor: pointer;
}

.modal-content h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0;
    /* Remove bottom margin to rely on container or input margin */
    color: var(--text-primary);
}

.memo-item {
    background: #e9ecef;
    /* Darker gray */
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.memo-text {
    font-size: 0.95rem;
}

.memo-delete {
    color: var(--text-secondary);
    background: none;
    border: none;
    padding: 4px 8px;
    cursor: pointer;
}

/* Header Alignment */
.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* btn-logout updated to match btn-today style */
.btn-logout {
    background: white;
    border: 1px solid #dee2e6;
    color: #495057;
    /* Match geometry of btn-today */
    border-radius: 50px;
    padding: 6px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: all 0.2s;
}

.btn-logout:hover {
    background-color: #f8f9fa;
    border-color: #adb5bd;
    color: #212529;
}

.btn-logout:active {
    background-color: #e9ecef;
    transform: scale(0.98);
}