* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", Arial, sans-serif;
    background: #f3f4f6;
    color: #111827;
}

.page-wrap {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    margin: 0;
    padding: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.card {
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 8px 18px rgba(15,23,42,0.06);
    padding: 16px 18px 18px;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.gridHeader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.gridHeader .title {
    font-size: 18px;
    font-weight: 600;
}

.gridHeader .subLabel {
    font-size: 12px;
    color: #6b7280;
    margin-top: 4px;
}

.gridTools {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn {
    border: 1px solid #d1d5db;
    background: #ffffff;
    color: #374151;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
}

.btn-ghost:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.healthLayout {
    display: grid;
    grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr);
    gap: 20px;
    margin-top: 6px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

@media (max-width: 1024px) {
    .healthLayout {
        grid-template-columns: minmax(0, 1fr);
    }
}

.calendarContainer {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.calendarHeader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px;
    flex-shrink: 0;
}

.calMeta {
    flex: 1;
    text-align: center;
}

.calMonth {
    font-size: 14px;
    font-weight: 600;
}

.calSummary {
    font-size: 10px;
    color: #6b7280;
    margin-top: 2px;
}

.cal-nav-btn {
    padding: 2px 6px;
    font-size: 12px;
}

.calendarTableWrap {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: auto;
    background: #ffffff;
    flex: 1;
    min-height: 0;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

.calendarTable {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    height: 100%;
    display: table;
}

.calendarTable thead {
    display: table-header-group;
}

.calendarTable thead th {
    height: 28px;
    text-align: center;
    font-weight: 500;
    color: #6b7280;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
    font-size: 11px;
}

.calendarTable tbody {
    display: table-row-group;
    height: calc(100% - 28px);
}

.calendarTable tbody tr {
    display: table-row;
    height: calc(100% / 6);
}

.calendarTable tbody td {
    border-right: 1px solid #e5e7eb;
    border-bottom: 1px solid #e5e7eb;
    background: #ffffff;
    vertical-align: top;
    height: calc(100% / 6);
    padding: 4px 6px 4px 8px;
    cursor: pointer;
    transition: background 0.12s ease;
}

.calendarTable tbody td:last-child {
    border-right: none;
}

.calendarTable tbody tr:last-child td {
    border-bottom: none;
}

.calendarTable tbody td.is-other-month {
    background: #f9fafb;
    color: #d1d5db;
    cursor: default;
}

.calendarTable tbody td:hover:not(.is-other-month) {
    background: #eff6ff;
}

.calendarTable tbody td.is-selected {
    background: #dbeafe;
}

.calendarTable tbody td.is-today {
    box-shadow: inset 0 0 0 2px #3b82f6;
}

.day-header-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.day-number {
    font-size: 13px;
    font-weight: 600;
    color: #111827;
}

/* 일요일: 빨간색 */
.calendarTable tbody td.is-sunday .day-number {
    color: #ef4444;
}

/* 토요일: 파란색 */
.calendarTable tbody td.is-saturday .day-number {
    color: #3b82f6;
}

/* 공휴일: 빨간색 (일요일과 동일) */
.calendarTable tbody td.is-holiday .day-number {
    color: #ef4444;
}

.day-holiday {
    font-size: 9px;
    color: #ef4444;
    font-weight: 500;
}

.day-icons {
    display: flex;
    flex-wrap: wrap;
    gap: clamp(4px, 0.4vw, 8px);
    margin-top: clamp(6px, 0.6vw, 10px);
    margin-left: 2px;
    align-items: center;
    justify-content: flex-start;
}

.day-icon {
    width: clamp(14px, 1.1vw, 18px);
    height: clamp(14px, 1.1vw, 18px);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(7px, 0.55vw, 10px);
    font-weight: 600;
    border: clamp(1.2px, 0.09vw, 1.8px) solid #d1d5db;
    background: #f3f4f6;
    color: #9ca3af;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    position: relative;
}

.day-icon:hover {
    transform: scale(1.25) translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
    z-index: 1;
}

/* OFF 상태: 모두 회색 */
.day-icon.day-ex {
    border-color: #d1d5db;
    background: #f3f4f6;
    color: #9ca3af;
}

.day-icon.day-med {
    border-color: #d1d5db;
    background: #f3f4f6;
    color: #9ca3af;
}

.day-icon.day-snack {
    border-color: #d1d5db;
    background: #f3f4f6;
    color: #9ca3af;
}

.day-icon.day-alc {
    border-color: #d1d5db;
    background: #f3f4f6;
    color: #9ca3af;
}

/* ON 상태: 각각의 색상 */
.day-icon.day-ex.is-active {
    background: #22c55e;
    border-color: #16a34a;
    color: #ffffff;
}

.day-icon.day-med.is-active {
    background: #3b82f6;
    border-color: #2563eb;
    color: #ffffff;
}

.day-icon.day-snack.is-active {
    background: #f97316;
    border-color: #ea580c;
    color: #ffffff;
}

.day-icon.day-alc.is-active {
    background: #a855f7;
    border-color: #7c3aed;
    color: #ffffff;
}

/* 운동 계획 페이지 전용 스타일은 plan.html의 인라인 스타일로 처리 */

.day-plan {
    margin-top: 4px;
    font-size: 11px;
    color: #6b7280;
}

.btn-primary {
    background: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
}

.btn-primary:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}


.healthLegend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    margin: 4px 2px 6px;
    font-size: 10px;
    color: #6b7280;
    flex-shrink: 0;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.legend-icon {
    width: 20px;
    height: 20px;
    border-radius: 999px;
    border: 1px solid #e5e7eb;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    background: #f3f4f6;
}

.legend-icon.legend-ex {
    background: #dcfce7;
    border-color: #22c55e;
    color: #166534;
}

.legend-icon.legend-med {
    background: #e0f2fe;
    border-color: #3b82f6;
    color: #1d4ed8;
}

.legend-icon.legend-snack {
    background: #fef3c7;
    border-color: #f59e0b;
    color: #92400e;
}

.legend-icon.legend-alc {
    background: #f3e8ff;
    border-color: #a855f7;
    color: #5b21b6;
}

.healthCalendar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.healthDetail {
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    padding: 16px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    min-height: 0;
}

.healthDetailHeader {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    padding: 0 0 12px 0;
    border-bottom: 2px solid #f3f4f6;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.healthDetailDate {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
}

.healthDetailTag {
    font-size: 11px;
    color: #9ca3af;
    font-weight: 500;
}

.healthDetailScroll {
    flex: 1;
    overflow: auto;
    padding-right: 2px;
}

.healthSection {
    margin-bottom: 12px;
    padding: 12px;
    border-radius: 10px;
    background: #f9fafb;
    border: 1px solid #f3f4f6;
    transition: all 0.2s ease;
}

.healthSection:hover {
    background: #f3f4f6;
    border-color: #e5e7eb;
}

.healthSectionTitle {
    font-size: 11px;
    font-weight: 600;
    color: #9ca3af;
    margin-bottom: 6px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.healthSectionBody {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 11px;
}

.healthFieldRow {
    display: flex;
    justify-content: space-between;
    gap: 4px;
}

.healthFieldRow .fieldKey {
    color: #9ca3af;
}

.healthFieldRow .fieldValue {
    text-align: right;
    font-weight: 500;
}

.fieldInput {
    width: 100%;
    padding: 2px 6px;
    font-size: 11px;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    background: #ffffff;
    color: #111827;
}

.fieldInput::placeholder {
    color: #9ca3af;
}

.healthNoteInput {
    width: 100%;
    min-height: 70px;
    padding: 4px 6px;
    font-size: 11px;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    background: #ffffff;
    color: #111827;
    resize: vertical;
    white-space: pre-wrap;
}

.healthNoteInput::placeholder {
    color: #9ca3af;
}

.workoutSummary {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 4px;
}

.workoutSummaryLine {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.workoutSummaryLabel {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: #9ca3af;
}

.workoutSummaryValue {
    font-size: 11px;
    text-align: right;
}

.sessionGraphEmpty {
    border-radius: 8px;
    border: 1px dashed #d1d5db;
    padding: 8px;
    font-size: 11px;
    color: #6b7280;
    background: #f9fafb;
    white-space: pre-wrap;
}

.healthDetailScroll::-webkit-scrollbar {
    width: 6px;
}

.healthDetailScroll::-webkit-scrollbar-track {
    background: transparent;
}

.healthDetailScroll::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 999px;
}

.healthDetailScroll::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}
