:root {
    --primary: #00b894;
    --primary-hover: #00cec9;
    --primary-light: #e8f8f5;
    --danger: #ff7675;
    --danger-hover: #d63031;
    --text-main: #2d3436;
    --text-muted: #636e72;
    --bg-main: #f5f6fa;
    --bg-card: #ffffff;
    --border-color: #dfe6e9;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.05);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.08);
    --shadow-lg: 0 16px 32px rgba(0,0,0,0.1);
    --border-radius: 16px;
    --transition: all 0.2s ease-in-out;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, 'Helvetica Neue', 'Segoe UI', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 2rem;
}

.app-container {
    width: 100%;
    max-width: 1200px;
    background: var(--bg-card);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

header {
    background: linear-gradient(135deg, #00b894 0%, #00cec9 100%);
    padding: 2rem;
    color: white;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.header-content h1 {
    font-size: 1.8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.month-selector {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(255,255,255,0.2);
    padding: 0.5rem 1rem;
    border-radius: 50px;
    backdrop-filter: blur(10px);
}

.month-selector h2 {
    font-size: 1.2rem;
    min-width: 120px;
    text-align: center;
}

.icon-btn {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    transition: var(--transition);
}

.icon-btn:hover {
    background: rgba(255,255,255,0.3);
}

.today-btn {
    background: white;
    color: var(--primary);
    border: none;
    padding: 0.4rem 1rem;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.today-btn:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-1px);
}

.stats-summary {
    display: flex;
    gap: 1rem;
}

.stat-card {
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(10px);
    padding: 1rem;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    min-width: 140px;
}

.stat-title {
    font-size: 0.85rem;
    opacity: 0.9;
    margin-bottom: 0.3rem;
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 700;
}

.calendar-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    background: var(--bg-card);
}

.calendar-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-weight: 600;
    padding: 1rem 0;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

.sun { color: #ff7675; }
.sat { color: #74b9ff; }

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-auto-rows: minmax(120px, auto);
    gap: 1px;
    background: var(--border-color);
    border: 1px solid var(--border-color);
}

.day-cell {
    background: white;
    padding: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.day-cell:hover {
    background: var(--primary-light);
}

.day-cell.other-month {
    background: #fdfdfd;
    color: #b2bec3;
}

.day-cell.today .day-number {
    background: var(--primary);
    color: white;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.day-number {
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: inline-block;
}

.day-content {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.8rem;
}

.tag {
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
}
.tag.glucose { background: #ffeaa7; color: #d35400; }
.tag.meal { background: #81ecec; color: #00b894; }

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    transform: translateY(0);
    transition: transform 0.3s;
    overflow: hidden;
}

.modal-overlay.hidden .modal-content {
    transform: translateY(20px);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.3rem;
    color: var(--text-main);
}

.modal-header .icon-btn {
    color: var(--text-muted);
}
.modal-header .icon-btn:hover {
    background: var(--bg-main);
    color: var(--text-main);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-section h4 {
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary);
}

.input-group-row {
    display: flex;
    gap: 1rem;
}

.input-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.input-wrapper label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
}

input[type="number"], textarea {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    outline: none;
    font-size: 0.95rem;
    transition: var(--transition);
}

input[type="number"]:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.meal-input {
    margin-bottom: 1rem;
}

.meal-label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    background: #fafafa;
}

button {
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    border: none;
    transition: var(--transition);
}

.primary-btn {
    background: var(--primary);
    color: white;
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 184, 148, 0.3);
}

.danger-btn {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
}

.danger-btn:hover {
    background: var(--danger);
    color: white;
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    .stats-summary {
        width: 100%;
    }
    .stat-card {
        flex: 1;
    }
    .calendar-grid {
        grid-auto-rows: minmax(80px, auto);
    }
    .input-group-row {
        flex-direction: column;
    }
}
