@charset "utf-8";

/* ============ Diary Calendar Styles ============ */

/* 전체 레이아웃 */
.diary-container {
    display: flex;
    min-height: 600px;
    font-family: 'Pretendard';
    margin: min(10vw, 100px) 0 20px; /* 위쪽은 화면 너비의 10%, 최대 100px */
    padding-bottom: 80px;
}

/* 사이드바 */
.diary-sidebar {
    width: 300px;
    background: var(--card-bg-color);
    border: 1px solid var(--card-border-color);
    border-radius: 8px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

#mobile-diary-sidebar, .mobile-bottom-toggle, .btn-view.btn-drag-mode {
    display: none;
}

/* 사이드바 상단 - 목록 영역 */
.sidebar-list {
    flex: 1;
    overflow-y: auto;
    max-height: 670px;
}

.sidebar-nav {
    display: flex;
    gap: 10px;
    margin-bottom: 0.6em;
    flex-direction: row;
    justify-content: space-between;
}

.sidebar-tabs {
    display: flex;
    gap: 5px;
    width: 100%;
}

.sidebar-tabs button {
    flex: 1;
    padding: 8px 12px;
    background: var(--container-bg-color);
    border: 1px solid var(--container-border-color);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    color: var(--content-font-color);
}

.sidebar-tabs button.active {
    background: var(--btn-accent-bg);
    color: var(--btn-accent-text);
    border-color: var(--btn-accent-bg);
}

.sidebar-tabs button:hover:not(.active) {
    background: rgb(from var(--white) r g b / 5%);
}

/* 카테고리 필터 */
.sidebar-category-filter {
    margin-bottom: 0.6em;
}

.sidebar-category-filter select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--container-border-color);
    border-radius: 5px;
    background: var(--container-bg-color);
    color: var(--content-font-color);
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s;
}

.sidebar-category-filter select:hover {
    border-color: var(--accent-color);
}

/* 사이드바 검색 */
.sidebar-search {
    margin-bottom: 0.6em;
}

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

.search-input-wrapper {
    position: relative;
    flex: 1;
}

.search-input-wrapper input {
    width: 100%;
    padding: 8px 32px 8px 12px;
    border: 1px solid var(--container-border-color);
    border-radius: 5px;
    background: var(--container-bg-color);
    color: var(--content-font-color);
    font-size: 1em;
    transition: all 0.3s;
}

.search-input-wrapper input:focus {
    border-color: var(--accent-color);
    outline: none;
}

.btn-clear-search {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 1em;
    transition: color 0.2s;
}

.btn-clear-search:hover {
    color: var(--content-font-color);
}

.search-option {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px;
    border: 1px solid var(--container-border-color);
    border-radius: 5px;
    background: var(--container-bg-color);
    color: var(--content-font-color);
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

.search-option:hover {
    border-color: var(--accent-color);
    background: var(--color-f-hover, #fafafa);
}

.search-option input[type="checkbox"] {
    cursor: pointer;
    margin: 0;
}

.search-option i {
    font-size: 1.1em;
}

.sidebar-category-filter select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(from var(--accent-color) r g b / 10%);
}

/* 목록 아이템 - 컴팩트 디자인 */
.list-item {
    padding: 8px 10px;
    border: 1px solid var(--container-border-color);
    border-radius: 5px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--container-bg-color);
}

.list-item:hover {
    background: rgb(from var(--white) r g b / 5%);
    border-color: var(--accent-color);
}

.list-item:hover .list-item-actions {
    opacity: 1;
}

.list-item.selected {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

.list-item.selected .list-item-title,
.list-item.selected .list-item-date {
    color: white;
}

.list-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.list-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.list-item-title {
    font-weight: 600;
    font-size: 0.95em;
    color: var(--content-font-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item-date {
    font-size: 0.8em;
    color: var(--text-muted);
}

.list-item-actions {
    display: flex;
    flex-direction: row;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

.list-item-actions button {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 4px 6px;
    font-size: 0.75em;
    border: 0;
    background: transparent;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: 3px;
    transition: all 0.2s;
}

.list-item-actions button:hover {
    background: rgb(from var(--black) r g b / 10%);
    color: var(--content-font-color);
}

.list-item-actions .btn-delete:hover {
    background: rgb(from var(--error-color) r g b / 20%);
    color: var(--error-color);
}

/* 날짜 없는 일정 표시 */
.list-item.no-date {
    border-left: 3px solid var(--warning-color);
}

.list-item.no-date .list-item-date {
    color: var(--warning-color);
    font-style: italic;
}

/* 날짜 없는 일정 섹션 */
.unscheduled-section {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px dashed var(--container-border-color);
}

.unscheduled-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.85em;
    color: var(--text-muted);
}

.unscheduled-header span {
    font-weight: 500;
}

/* 드래그 가능한 아이템 */
.list-item.draggable {
    cursor: grab;
}

.list-item.draggable:active {
    cursor: grabbing;
}

.list-item.dragging {
    opacity: 0.5;
    transform: scale(0.98);
}

/* 편집 모드 - 사이드바 */
.diary-sidebar.edit-mode .list-item.draggable {
    border: 2px dashed var(--primary-color, #3b82f6);
    cursor: grab;
}

.diary-sidebar.edit-mode .list-item.draggable:hover {
    border-color: var(--accent-color, #8b5cf6);
    background: rgb(from var(--primary-color) r g b / 5%);
}

.diary-sidebar.edit-mode .list-item.no-date {
    border-left: 3px solid var(--warning-color);
    border-style: dashed;
}

/* 미배정 일정은 편집 모드가 아니어도 항상 드래그 가능 */
.list-item.no-date.draggable {
    cursor: grab;
}

.list-item.no-date.draggable:hover {
    border-color: var(--primary-color);
}

/* 토스트 메시지 */
.toast-message {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--content-font-color, #333);
    color: var(--card-bg-color, #fff);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.95em;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.toast-message.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* 사이드바 하단 - 상세 내용 영역 */
.sidebar-detail {
    padding: 15px;
    background: var(--container-bg-color);
    border: 1px solid var(--container-border-color);
    border-radius: 5px;
    height: 200px;
    overflow-y: scroll;
}

.detail-title {
    font-size: 16px;
    font-weight: bold;
    color: var(--content-font-color);
}

.detail-meta {
    margin-bottom: 5px;
    color: var(--text-muted);
    opacity: 0.6;
    font-size: 0.8em;
}

.detail-content {
    font-size: 1em;
    line-height: 1.6;
    color: var(--text-muted);
    white-space: pre-line;
}

.detail-empty {
    color: var(--text-muted);
    text-align: center;
    padding: 40px 0;
}

/* 달력 영역 */
.diary-calendar {
    flex: 1;
    background: var(--card-bg-color);
    border: 1px solid var(--card-border-color);
    border-radius: 8px;
    padding: 1em;
}

/* 달력 헤더 */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* margin-bottom: 1em; */
    padding-bottom: 10px;
}

.calendar-nav {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.calendar-nav button {
    padding: 5px 15px;
    background: var(--btn-accent-bg);
    color: var(--btn-accent-text);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
}

.calendar-nav button:hover {
    opacity: 0.8;
}

.calendar-current {
    font-size: 2em;
    font-weight: 700;
    color: var(--content-font-color);
}

/* 달력 테이블 */
.calendar-table {
    width: 100%;
    border-collapse: collapse;
    border-radius: 10px;
    overflow: hidden;
    table-layout: fixed; /* 셀 너비 고정 - 이벤트 바가 셀을 넓히지 못하도록 */
}

.calendar-table th, .calendar-table td {
    text-align: left;
    height: 120px;
    vertical-align: top;
    border: 1px solid rgb(from var(--container-border-color) r g b / 60%);
    padding: 5px;
    position: relative;
    background: rgb(from var(--container-bg-color) r g b / 60%);
    width: 14.28%; /* 7일 = 100% / 7 */
}

.calendar-table th {
    background: var(--card-bg-color);
    height: auto;
    padding: 10px;
    text-align: center;
    font-weight: bold;
    color: var(--content-font-color);
}

.calendar-table th.sunday {
    color: var(--error-color);
}

.calendar-table th.saturday {
    color: var(--warning-color);
}

/* 날짜 숫자 */
.day-number {
    font-weight: normal;
    margin-bottom: 3px;
    font-size: 1em;
    color: var(--content-font-color);
    font-family: pretendard;
}

.day-cell.other-month .day-number {
    color: var(--text-muted);
}

.day-cell.today {
    background: var(--card-bg-color);
}

.day-cell.today .day-number {
    color: var(--accent-color);
    font-weight: bold;
}

/* 이벤트 바 */
.event-bar {
    display: flex;
    align-items: center;
    padding: 2px 5px;
    margin: 1px 0;
    border-radius: 3px;
    font-size: 0.8em;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
    color: white;
    min-height: 14px;
    line-height: 10px;
}

/* 이벤트 바 내부 span 요소도 너비 제한 */
.event-bar span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    display: inline-block;
}

/* 연속 이벤트는 기본 border-radius 제거 */
.event-bar.start,
.event-bar.middle,
.event-bar.end {
    border-radius: 0;
}

.event-bar:hover {
    opacity: 0.8;
    transform: translateY(-1px);
}

/* 연속 이벤트 처리 */
/* 실제 시작일 */
.event-bar.start:not(.week-end) {
    border-top-left-radius: 5px;
    border-bottom-left-radius: 5px;
    margin-right: -5px;
}

/* 실제 종료일 */
.event-bar.end:not(.week-start) {
    border-top-right-radius: 5px;
    border-bottom-right-radius: 5px;
    margin-left: -5px;
}

/* 중간 날짜들 */
.event-bar.middle {
    margin-left: -5px;
    margin-right: -2px;
}

/* 시작일이면서 토요일(주 끝) - 다음 주로 이어짐, 오른쪽 둥글지 않게 */
.event-bar.start.week-end {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    margin-right: -5px;
    padding-right: 10px;
    width: calc(100% + 14px);
}

/* 종료일이면서 일요일(주 시작) - 이전 주에서 이어짐, 왼쪽 둥글지 않게 */
.event-bar.end.week-start {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    margin-left: -5px;
    padding-left: 10px;
    width: calc(100% + 14px);
}

/* 중간 날짜인데 일요일(주 시작) - 왼쪽 padding 보정 */
.event-bar.middle.week-start {
    border-top-left-radius: 5px;
    border-bottom-left-radius: 5px;
    margin-left: -5px;
    /* padding-left: 10px; */
    width: calc(100% + 14px);
}

/* 중간 날짜인데 토요일(주 끝) - 오른쪽 padding 보정 */
.event-bar.middle.week-end {
    border-top-right-radius: 5px;
    border-bottom-right-radius: 5px;
    margin-right: -5px;
    padding-right: 10px;
    width: calc(100% + 7px);
}

/* 중간 날짜인데 주중 - 양쪽 연결 */
.event-bar.middle:not(.week-start):not(.week-end) {
    width: calc(100% + 14px);
}

/* 달력 셀 오버플로우 방지 */
.day-cell {
    overflow: hidden;
    border-radius: 6px;
}

.day-events {
    position: relative;
}

/* 이벤트 타입별 색상 - CSS 변수 사용 */
.event-schedule {
    background: var(--accent-color);
}

.event-anniversary {
    background: var(--warning-color);
    color: black;
}

.event-todo {
    background: var(--error-color);
}

/* 투두리스트 체크박스 */
.todo-checkbox {
    position: relative;
    margin-right: 2px;
    width: 12px;
    height: 12px;
    cursor: pointer;
    accent-color: var(--accent-color);
    flex-shrink: 0;
}

.todo-checkbox:disabled {
    opacity: 1;
    cursor: default;
}

.event-todo {
    display: flex;
    align-items: center;
}

.event-todo.completed {
    opacity: 0.75;
}

.event-todo.completed span,
.event-todo.completed .event-title {
    text-decoration: line-through;
}

/* Write Form Styles */
.diary-write-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 1em;
    background: var(--card-bg-color);
    border: 1px solid var(--card-border-color);
    border-radius: 8px;
}

.diary-type-selector {
    margin-bottom: 30px;
}

.type-label {
    display: block;
    font-weight: bold;
    margin-bottom: 10px;
    color: var(--content-font-color);
}

.type-buttons {
    display: flex;
    gap: 10px;
}

.type-btn {
    flex: 1;
    padding: 15px;
    border: 2px solid var(--container-border-color);
    background: var(--container-bg-color);
    color: var(--content-font-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 16px;
}

.type-btn:hover {
    background: rgb(from var(--white) r g b / 5%);
}

.type-btn.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.form-group {
    margin-bottom: 25px;
}

.form-label {
    display: block;
    font-weight: bold;
    margin-bottom: 8px;
    color: var(--content-font-color);
}

.form-label strong {
    color: var(--error-color);
}

.frm_input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--container-border-color);
    background: var(--container-bg-color);
    color: var(--content-font-color);
    border-radius: 5px;
    font-size: 1.1em;
}

.frm_input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.date-inputs {
    display: flex;
    gap: 1em;
}

.date-input-group {
    flex: 1;
}

.date-input-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 1.1em;
    color: var(--content-font-color);
}

.checkbox-label {
    font-weight: normal;
    margin-left: 5px;
}

.repeat-options {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.repeat-options label {
    display: flex;
    align-items: center;
    font-weight: normal;
    color: var(--content-font-color);
}

.repeat-options input[type="checkbox"] {
    margin-right: 5px;
    accent-color: var(--accent-color);
}

.repeat-years {
    margin-top: 10px;
}

.repeat-years select {
    background: var(--container-bg-color);
    color: var(--content-font-color);
    border: 1px solid var(--container-border-color);
    padding: 5px;
    border-radius: 3px;
}

.color-selector {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.color-selector input[type="radio"] {
    display: none;
}

.color-option {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.3s;
}

.color-selector input[type="radio"]:checked + .color-option {
    border-color: var(--content-font-color);
    transform: scale(1.1);
}

.color-add-btn {
    background: var(--card-bg-color);
    border: 2px dashed var(--card-border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--content-font-color);
    font-size: 18px;
    opacity: 0.6;
}

.color-add-btn:hover {
    opacity: 1;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.color-custom {
    padding: 0;
    overflow: hidden;
}

.color-custom input[type="color"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background: transparent;
    border: none !important;
    cursor: pointer;
}

.color-custom input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-custom input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 50%;
}

.color-custom input[type="color"]::-moz-color-swatch {
    border: none;
    border-radius: 50%;
}

.btn-wrap {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 30px;
}

.btn {
}

.btn-primary {
    background: var(--btn-accent-bg);
    color: var(--btn-accent-text);
}

.btn-primary:hover {
    opacity: 0.8;
}

.btn-secondary {
    background: var(--card-bg-color);
    color: var(--content-font-color);
    border: 1px solid var(--card-border-color);
}

.btn-secondary:hover {
    background: rgb(from var(--white) r g b / 5%);
}

.btn-small {
    padding: 4px 8px;
    font-size: 0.9em;
    border-radius: 3px;
    background: var(--card-bg-color);
    border: 1px solid var(--card-border-color);
	color: var(--content-font-color);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-small:hover {
    background: var(--hover-bg-color, #f0f0f0);
}

/* 카테고리 목록 */
.category-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.category-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: var(--card-bg-color);
    border: 1px solid var(--card-border-color);
    border-radius: 4px;
}

.category-item-name {
    flex: 1;
    font-size: 1.1em;
}

.category-item-buttons {
    display: flex;
    gap: 8px;
}

.category-item-edit {
    padding: 4px 8px;
    background: var(--primary-color, #54cd9a);
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 1em;
}

.category-item-edit:hover {
    background: var(--primary-color-dark, #3fae7d);
}

.category-item-delete {
    padding: 4px 8px;
    background: var(--error-color, #ff6b6b);
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 1em;
}

.category-item-delete:hover {
    background: var(--error-color-dark, #ff5252);
}

/* ================== 반응형 디자인 ================== */

/* 태블릿 (768px ~ 1024px) */
@media (max-width: 1024px) and (min-width: 769px) {
    .diary-sidebar {
        width: 280px;
    }

    .calendar-header {
        flex-wrap: wrap;
        gap: 15px;
    }

    .calendar-current {
    }
}

/* 모바일 (최대 768px) */
@media (max-width: 768px) {
    .diary-container {
        flex-direction: column;
        gap: 15px;
    }

    .diary-sidebar {
        width: 100%;
        max-height: none;
        min-height: 200px;
    }

    .sidebar-list {
        max-height: 250px;
    }

    .sidebar-detail {
        min-height: 150px;
    }

    /* 헤더 */
    .calendar-header {
        flex-direction: column;
        gap: 10px;
        padding: 15px;
    }

    .calendar-nav button {
        padding: 6px 12px;
        font-size: 1em;
    }

    .calendar-current {
        text-align: center;
    }

    .view-switcher {
        justify-content: center;
        flex-wrap: wrap;
    }

    .btn-view {
        padding: 6px 12px;
        font-size: 1em;
    }

    /* 달력 테이블 */
    .calendar-table {
        font-size: 1em;
    }

    .calendar-table th,
    .calendar-table td {
        height: 55px;
        font-size: 0.8em;
        padding: 2px;
    }

    .day-number {
        font-size: 1.1em;
    }

    .day-events {
        gap: 1px;
    }

    .event-bar {
        padding: 2px 4px;
        min-height: 18px;
    }

    .event-bar span {
        max-width: 80px;
    }

    /* 사이드바 탭 */
    .sidebar-tabs button {
        font-size: 16px;
        padding: 8px;
    }

    .list-item {
        padding: 10px;
    }

    .list-item-title {
        font-size: 1em;
    }

    .list-item-date {
        font-size: 0.9em;
    }

    .list-item-actions button {
        padding: 3px 8px;
        font-size: 0.9em;
    }

    .detail-title {
        font-size: 15px;
    }

    .detail-meta {
        font-size: 1em;
    }

    .detail-content {
        font-size: 1em;
    }
}

/* 로딩 스피너 */
.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
}

.spinner {
    border: 3px solid var(--border-light);
    border-radius: 50%;
    border-top: 3px solid var(--accent-color);
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 툴팁 */
.event-tooltip {
    position: absolute;
    background: var(--container-bg-color);
    color: var(--content-font-color);
    padding: 8px 12px;
    border-radius: 5px;
    border: 1px solid var(--container-border-color);
    font-size: 1em;
    z-index: 1000;
    pointer-events: none;
    white-space: nowrap;
    display: none;
    box-shadow: 0 2px 8px rgb(from var(--black) r g b / 30%);
}

.event-bar:hover + .event-tooltip {
    display: block;
}

.sidebar-detail .detail-btn {
    color: var(--content-font-color);
    background: none;
    border: none;
    padding-left: 5px;
    cursor: pointer;
    opacity: 0.7;
    font-size: 0.8em;
}

::-webkit-scrollbar {
  display: none;
}

/* 뷰 전환 버튼 */
.view-switcher {
    display: flex;
    gap: 6px;
}

.btn-view {
    padding: 8px 16px;
    border: 0;
    background: var(--btn-primary-bg);
    border-radius: var(--btn-primary-radius);
    cursor: pointer;
    text-decoration: none;
    color: var(--btn-primary-text);
    font-size: 1em;
    transition: all 0.2s;
}

.btn-view:hover, .btn-view.active:hover {
    background: var(--btn-primary-text);
    color: var(--btn-primary-bg);
}

.btn-view.active {
    background: var(--btn-accent-bg);
    color: var(--btn-accent-text);
    background: var(--btn-accent-bg);
    cursor: default;
}

/* 편집 모드 버튼 */
.btn-edit-mode {
    background: var(--btn-secondary-bg);
    border-color: var(--btn-secondary-bg);
    color: var(--btn-secondary-text);
}

.btn-edit-mode:hover {
    background: var(--warning-color);
    color: var(--white);
}

.btn-edit-mode.active {
    background: var(--warning-color, #ffb020);
    color: white;
    border-color: var(--warning-color, #ffb020);
}

/* 편집 모드 활성화 시 */
.edit-mode .day-cell,
.edit-mode .hour-slot {
    cursor: default !important;
}

/* 편집 가능한 일정 (일정, 투두) */
.edit-mode .event-bar:not(.event-anniversary),
.edit-mode .event-block:not(.event-anniversary) {
    cursor: move !important;
    user-select: none;
    border: 2px dashed var(--primary-color, #3b82f6) !important;
    box-sizing: border-box;
}

.edit-mode .event-bar:not(.event-anniversary):hover,
.edit-mode .event-block:not(.event-anniversary):hover {
    opacity: 0.8;
    border-color: var(--accent-color, #8b5cf6) !important;
}

/* 편집 불가능한 일정 (기념일) */
.edit-mode .event-bar.event-anniversary,
.edit-mode .event-block.event-anniversary {
    cursor: not-allowed !important;
    opacity: 0.6;
    filter: grayscale(30%);
}

/* ================== 드래그 가능 모달 (작성 폼) ================== */

/* 모달 오버레이 및 컨테이너 */
.write-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s, visibility 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.write-panel.active {
    visibility: visible;
    opacity: 1;
}

/* 모달 콘텐츠 (드래그 가능) */
.write-panel-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 500px;
    max-height: 85vh;
    background: var(--card-bg-color, #fff);
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    border-radius: 8px;
    overflow: hidden;
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
    transition: opacity 0.3s, transform 0.3s;
    z-index: 10;
    pointer-events: auto;
}

.write-panel.active .write-panel-content {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* 모달 헤더 (드래그 핸들) */
.write-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1em;
    border-bottom: 1px solid var(--card-border-color, #e0e0e0);
    background: var(--card-bg-color, #f8f9fa);
    cursor: move;
    user-select: none;
}

.write-panel-header h3 {
    margin: 0;
    font-size: 18px;
    color: var(--content-font-color, #333);
}

.btn-close-panel, .btn-close-category {
    background: none;
    border: none;
    font-size: 1em;
    color: var(--content-font-color, #666);
    cursor: pointer;
    padding: 5px 10px;
    transition: color 0.2s;
}

.btn-close-panel:hover, .btn-close-category:hover {
    color: var(--error-color, #ff6b6b);
}

/* 모달 바디 (폼) */
.write-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 1em;
    max-height: calc(85vh - 80px);
}

.write-panel-body .form-group {
    margin-bottom: 1em;
}

.write-panel-body .form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--content-font-color, #333);
    font-size: 1.1em;
}

.write-panel-body .form-group label strong {
    color: var(--error-color, #ff6b6b);
}

/* 선택된 날짜 표시 */
.selected-date-display {
    background: var(--hover-bg-color, #f0f0f0);
    padding: 12px;
    border-radius: 5px;
    font-size: 1.1em;
    color: var(--content-font-color, #333);
    border: 1px solid var(--card-border-color, #e0e0e0);
}

/* 타입 버튼 (패널용) */
.write-panel .type-buttons {
    display: flex;
    gap: 8px;
}

.write-panel .type-btn {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--card-border-color, #ddd);
    background: var(--card-bg-color, #fff);
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.2s;
    color: var(--content-font-color, #333);
}

.write-panel .type-btn:hover {
    background: var(--hover-bg-color, #f5f5f5);
}

.write-panel .type-btn.active {
    background: var(--primary-color, #3b82f6);
    color: white;
    border-color: var(--primary-color, #3b82f6);
}

.write-panel .type-btn i {
    margin-right: 5px;
}

/* 입력 필드 */
.write-panel .frm_input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--input-border-color, #ddd);
    border-radius: 5px;
    font-size: 1.1em;
    color: var(--content-font-color, #333);
    background: var(--card-bg-color, #fff);
    transition: border-color 0.2s;
}

.write-panel .frm_input:focus {
    outline: none;
    border-color: var(--primary-color, #3b82f6);
}

.write-panel textarea.frm_input {
    resize: vertical;
    min-height: 100px;
}

/* 색상 선택기 (패널용) */
.write-panel .color-selector {
    display: flex;
    gap: 10px;
}

.write-panel .color-selector input[type="radio"] {
    display: none;
}

.write-panel .color-option {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s;
}

.color-option.color-add-btn {
    border: 3px dashed var(--container-border-color);
}
.write-panel .color-selector input[type="radio"]:checked + .color-option {
    border-color: var(--content-font-color, #333);
    transform: scale(1.1);
}

.write-panel .color-option:hover {
    transform: scale(1.05);
}

/* 커스텀 컬러피커 */
.write-panel .color-picker-label {
    position: relative;
    overflow: visible;
    border: 2px dashed var(--border-light, #ddd);
    display: flex;
    align-items: center;
    justify-content: center;
}

.write-panel .color-picker-label input[type="color"] {
    width: 100%;
    height: 100%;
    border: none;
    cursor: pointer;
    border-radius: 50%;
}

.write-panel .color-picker-label input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
    border-radius: 50%;
}

.write-panel .color-picker-label input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 50%;
}

/* 폼 액션 버튼 */
.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 1em;
    padding-top: 1em;
    border-top: 1px solid var(--card-border-color, #e0e0e0);
}

.form-actions .btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 5px;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.2s;
}

.form-actions .btn-primary {
    background: var(--primary-color, #3b82f6);
    color: white;
}

.form-actions .btn-primary:hover {
    background: var(--primary-color-dark, #2563eb);
}

.form-actions .btn-secondary {
    background: var(--card-border-color, #e0e0e0);
    color: var(--content-font-color, #666);
}

.form-actions .btn-secondary:hover {
    background: var(--hover-bg-color, #d0d0d0);
}

/* 드래그 선택 시 하이라이트 */
.day-cell.selecting {
    background: rgba(59, 130, 246, 0.15) !important;
}

/* 편집 모드 - 드래그 오버 */
.day-cell.drag-over {
    background: rgba(139, 92, 246, 0.2) !important;
    border: 2px dashed var(--accent-color, #8b5cf6) !important;
    box-sizing: border-box;
}

/* ================== 반응형: 모달 ================== */

/* 태블릿 (최대 1024px) */
@media (max-width: 1024px) {
    .write-panel-content {
        max-width: 90%;
    }
}

/* 모바일 (최대 768px) */
@media (max-width: 768px) {
    .write-panel-content {
        width: 95%;
        max-width: none;
        max-height: 90vh;
    }

    .write-panel-header {
        padding: 15px;
    }

    .write-panel-header h3 {
        font-size: 16px;
    }

    .write-panel-body {
        padding: 15px;
        max-height: calc(90vh - 80px);
    }

    .write-panel .type-buttons {
        flex-direction: column;
    }

    .write-panel .type-btn {
        width: 100%;
    }
}

/* 작은 모바일 (최대 480px) */
@media (max-width: 480px) {
    .write-panel-content {
        width: 98%;
        max-height: 95vh;
    }

    .write-panel-header {
        padding: 12px;
    }

    .write-panel-header h3 {
        font-size: 15px;
    }

    .write-panel-body {
        padding: 12px;
        max-height: calc(95vh - 70px);
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
    }
}

/* ============ 모바일 레이아웃 (768px 이하) ============ */
@media (max-width: 768px) {
    /* 사이드바를 숨기고 달력을 전체 화면으로 */
    .diary-container {
        flex-direction: column;
        gap: 0;
        margin: 0;
    }

    /* 데스크톱 사이드바 숨김 */
    .diary-sidebar {
        display: none;
    }

    .btn-view.btn-drag-mode {
        display: block;
    }

    /* 모바일 사이드바 (화면 최하단에서 올라옴) */
    #mobile-diary-sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 70vh;
        z-index: 800;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 12px rgba(0,0,0,0.15);
        transition: transform 0.3s ease;
        transform: translateY(100%);
        display: flex;
        padding-bottom: 80px; /* 하단 버튼 공간 확보 */
    }

    #mobile-diary-sidebar.mobile-visible {
        transform: translateY(0);
    }

    /* 모바일 하단 고정 토글 버튼 */
    .mobile-bottom-toggle {
        display: block;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        background: var(--card-bg-color);
        border-top: 2px solid var(--card-border-color);
        padding: 12px 1em;
        z-index: 900;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    }

    .btn-toggle-sidebar {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: 100%;
        padding: 12px 1em;
        background: var(--primary-color, #3b82f6);
        color: white;
        border: none;
        border-radius: 8px;
        font-size: 15px;
        font-weight: 500;
        cursor: pointer;
        transition: background 0.2s;
    }

    .btn-toggle-sidebar:hover {
        background: var(--primary-color, #3b82f6);
        filter: brightness(0.85);
    }

    .btn-toggle-sidebar i {
        font-size: 1.1em;
        transition: transform 0.3s;
    }

    /* 사이드바 열렸을 때 아이콘 회전 */
    .btn-toggle-sidebar.active i {
        transform: rotate(180deg);
    }

    /* 데스크톱에서는 하단 버튼 숨김 */
    @media (min-width: 769px) {
        .mobile-bottom-toggle {
            display: none;
        }
    }

    /* 달력 헤더 조정 */
    .calendar-header {
        flex-direction: column;
        gap: 10px;
        padding: 10px;
    }

    .calendar-current {
        text-align: center;
        width: 100%;
    }

    .view-switcher {
        width: 100%;
        justify-content: center;
        gap: 5px;
    }

    .calendar-table .day-number {
        font-size: 1.1em;
    }

    .event-bar {
        font-size: 0.9em;
        padding: 2px 4px;
        margin: 1px 0;
    }

    /* 주간 뷰 조정 */
    .week-header {
        gap: 2px;
    }

    .day-col-header {
        padding: 5px 2px;
        font-size: 0.9em;
    }

    .time-col-header {
        width: 40px;
    }

    .event-block {
        font-size: 10px;
        padding: 2px;
        min-height: 30px;
    }

    .event-title {
        font-size: 10px;
    }

    /* 모바일용 플로팅 액션 버튼 (FAB) */
    .mobile-fab {
        display: block;
        position: fixed;
        bottom: 1em;
        right: 1em;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: var(--primary-color, #3b82f6);
        color: white;
        border: none;
        box-shadow: 0 4px 8px rgba(0,0,0,0.3);
        font-size: 24px;
        cursor: pointer;
        z-index: 900;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: transform 0.2s;
    }

    .mobile-fab:active {
        transform: scale(0.95);
    }

    /* 데스크톱에서는 FAB 숨김 */
    @media (min-width: 769px) {
        .mobile-fab {
            display: none !important;
        }
    }

    /* 모바일에서 기존 추가 버튼 숨김 */
    #btn-open-write-panel {
        display: none;
    }

    /* 편집 모드 버튼 크기 조정 */
    .btn-view {
        padding: 6px 10px;
        font-size: 1em;
    }

    /* 모바일에서 드래그 선택 비활성화 표시 */
    .calendar-table td {
        user-select: none;
        -webkit-user-select: none;
    }

    /* 모바일 패널 전체화면 스타일 */
    .write-panel.active {
        padding: 0;
    }

    .write-panel-content {
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        border-radius: 0;
        transform: none !important;
        left: 0 !important;
        top: 0 !important;
    }

    .write-panel-header {
        border-radius: 0;
    }

    /* 카테고리 관리 모달도 전체화면 */
    .category-modal.active .category-modal-content {
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        border-radius: 0;
    }
}

/* ============ 아주 작은 모바일 (480px 이하) ============ */
@media (max-width: 480px) {
    .calendar-table th,
    .calendar-table td {
        padding: 3px 1px;
        font-size: 0.9em;
    }

    .calendar-table .day-number {
        font-size: 1em;
    }

    .event-bar {
        padding: 1px 3px;
    }

    /* FAB 크기 조정 */
    .mobile-fab {
        width: 50px;
        height: 50px;
        font-size: 1em;
        bottom: 15px;
        right: 15px;
    }

    /* 달력 네비게이션 버튼 크기 조정 */
    .calendar-nav button {
        padding: 5px 10px;
        font-size: 1em;
    }

    /* 주간 뷰 시간 컬럼 더 좁게 */
    .time-col-header {
        width: 35px;
    }

    .time-slot {
        font-size: 10px;
    }
}


/* ============ 일정 삭제 확인 팝업 (확인 페이지 없이 바로 삭제) ============ */
.dy-confirm {
    position: fixed;
    inset: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.35);
    opacity: 0;
    transition: opacity 0.2s ease;
}
.dy-confirm.is-open { opacity: 1; }
.dy-confirm-box {
    width: 100%;
    max-width: 420px;
    padding: 28px 24px 24px;
    box-sizing: border-box;
    border-radius: 14px;
    border: 1px solid var(--card-border-color, #e5e5e5);
    background: var(--card-bg-color, #ffffff);
    color: var(--content-font-color, #333333);
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18);
    transform: translateY(8px) scale(0.98);
    transition: transform 0.2s ease;
}
.dy-confirm.is-open .dy-confirm-box { transform: none; }
.dy-confirm-title {
    margin: 0 0 12px;
    font-size: 1.2em;
    font-weight: 700;
    color: var(--accent-color, #5b86c5);
}
.dy-confirm-msg { margin: 0 0 4px; font-size: 1em; word-break: break-all; }
.dy-confirm-sub { margin: 0 0 20px; font-size: 0.92em; color: var(--text-muted, #888888); }
.dy-confirm-btns { display: flex; justify-content: center; gap: 8px; }
.dy-confirm-btns button {
    min-width: 88px;
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: 700;
    cursor: pointer;
    transition: filter 0.15s, opacity 0.15s;
}
.dy-confirm-cancel { background: var(--gray-500, #7a7a7a); color: #ffffff; }
.dy-confirm-ok {
    background: rgba(255, 107, 107, 0.12);
    color: var(--error-color, #e05555);
}
@supports (color: rgb(from red r g b)) {
    .dy-confirm-ok { background: rgb(from var(--error-color, #ff6b6b) r g b / 12%); }
}
.dy-confirm-btns button:hover { filter: brightness(0.95); }
.dy-confirm-ok:disabled { opacity: 0.6; cursor: default; }
@media (prefers-reduced-motion: reduce) {
    .dy-confirm, .dy-confirm-box { transition: none; }
}


/* ============ 기간 반복 (요일 + 몇 회 / 언제까지) ============ */
.dy-rr { margin-top: 10px; }
.dy-rr-toggle {
    display: inline-flex !important;
    align-items: center;
    gap: 5px;
    margin: 0 !important;
    font-size: 1em !important;
    cursor: pointer;
}
.dy-rr-box {
    margin-top: 8px;
    padding: 10px 12px;
    border: 1px solid var(--container-border-color, #e5e5e5);
    border-radius: 8px;
    background: rgba(128, 128, 128, 0.1);                                        /* color-mix 를 모르는 브라우저용 */
    background: color-mix(in srgb, var(--secondary-color, #888888) 10%, transparent); /* secondary-color 10% */
}
.dy-rr-days { display: flex; flex-wrap: wrap; gap: 6px; }
.dy-rr-days label { margin: 0 !important; cursor: pointer; }
.dy-rr-days input { position: absolute; opacity: 0; width: 0; height: 0; }
.dy-rr-days span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--container-border-color, #dddddd);
    background: var(--card-bg-color, #ffffff);
    color: var(--content-font-color, #333333);
    font-size: 0.95em;
    font-weight: 600;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.dy-rr-days .is-sun span { color: var(--error-color, #e05555); }
.dy-rr-days .is-sat span { color: var(--info-color, #3b82f6); }
.dy-rr-days input:checked + span {
    background: var(--accent-color, #3b82f6);
    border-color: var(--accent-color, #3b82f6);
    color: #ffffff;
}
.dy-rr-days input:focus-visible + span { outline: 2px solid var(--accent-color, #3b82f6); outline-offset: 2px; }
.dy-rr-end { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.dy-rr-end label {
    display: flex !important;
    align-items: center;
    gap: 6px;
    margin: 0 !important;
    font-size: 0.95em !important;
    font-weight: normal !important;
}
.dy-rr-end input[type="number"] { width: 80px !important; padding: 6px 8px !important; }
.dy-rr-end input[type="date"] { width: auto !important; padding: 6px 8px !important; }
.dy-rr-hint { display: block; margin-top: 8px; color: var(--text-muted, #888888); font-size: 0.85em; }
.dy-rr-hint:empty { display: none; }


/* ============ 일정 작성/수정 창 정리 ============ */
/* 투두 유형, 시간 입력, 종료일 옆 '기간 설정' 체크는 쓰지 않음 (기존 투두·시간 값은 그대로 유지) */
#write-panel .type-btn[data-type="todo"],
#write-panel #time-input-group,
#write-panel #panel_has_end_date,
#write-panel #panel_has_end_date + span { display: none !important; }

/* 반복: 체크 상자 없이 요일을 고르면 반복 */
.dy-rr-title { font-size: 1em; font-weight: 500; color: var(--content-font-color, #333333); }
.dy-rr-title small { margin-left: 6px; font-size: 0.82em; font-weight: normal; color: var(--text-muted, #888888); }
#panel_rr_box { display: block !important; }

/* 내용: GM / PL / 시간 / 기타 */
.dy-content-fields .dy-cf-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}
.dy-content-fields .dy-cf-row > label {
    flex: 0 0 44px;
    margin: 0 !important;
    font-size: 0.95em !important;
    font-weight: 600 !important;
    color: var(--text-muted, #888888) !important;
}
.dy-content-fields .dy-cf-row > .frm_input { flex: 1 1 auto; min-width: 0; }
.dy-content-fields .dy-cf-etc { align-items: flex-start; }
.dy-content-fields .dy-cf-etc > label { padding-top: 10px; }
.dy-content-fields textarea.frm_input { min-height: 72px; resize: vertical; }

/* 카테고리 색상 안내 (카테고리에 색이 있으면 색상 고르기 대신 보임) */
.dy-cat-color-note {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 0.9em;
    color: var(--text-muted, #888888);
}
.dy-cat-swatch {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.1);
    flex-shrink: 0;
}
/* 카테고리 관리: 색상 고르기 */
.category-item-color,
.dy-new-cat-color {
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid var(--card-border-color, #dddddd);
    border-radius: 50%;
    background: none;
    cursor: pointer;
    flex-shrink: 0;
}
.category-item-color::-webkit-color-swatch-wrapper,
.dy-new-cat-color::-webkit-color-swatch-wrapper { padding: 0; }
.category-item-color::-webkit-color-swatch,
.dy-new-cat-color::-webkit-color-swatch { border: none; border-radius: 50%; }
.category-item-color.is-empty { background: repeating-linear-gradient(45deg, #eee 0 4px, #fff 4px 8px); }
.category-item { gap: 8px; }


/* ============ 유형·색상 숨김 / 제목 앞 [카테고리] / 비밀 / 반복 삭제·수정 선택 ============ */
.write-panel .dy-hide { display: none !important; }
.dy-title-row { display: flex; align-items: center; gap: 6px; }
.dy-title-row .frm_input { flex: 1 1 auto; min-width: 0; }
.dy-title-prefix {
    flex-shrink: 0;
    padding: 9px 10px;
    border-radius: 5px;
    background: var(--container-bg-color, rgba(0,0,0,0.04));
    border: 1px solid var(--container-border-color, #dddddd);
    color: var(--content-font-color, #333333);
    font-weight: 600;
    white-space: nowrap;
}
.dy-title-prefix[hidden] { display: none; }
.dy-secret {
    display: flex !important;
    align-items: center;
    gap: 6px;
    margin: 8px 0 0 !important;
    font-size: 0.95em !important;
    font-weight: normal !important;
    cursor: pointer;
}
.dy-secret small { color: var(--text-muted, #888888); font-size: 0.85em; }
.dy-lock { opacity: 0.9; }
.event-bar .dy-lock, .event-chip .fa-lock, .event-block .fa-lock { font-size: 0.95em; }
.dy-confirm-btns { flex-wrap: wrap; }
.dy-confirm-alt {
    background: var(--container-bg-color, rgba(0,0,0,0.06));
    color: var(--content-font-color, #333333);
    border: 1px solid var(--container-border-color, #dddddd) !important;
}
.dy-confirm-ok.dy-confirm-primary {
    background: var(--accent-color, #3b82f6);
    color: #ffffff;
}
.dy-confirm-box { max-width: 480px; }
.dy-confirm-btns button { min-width: 0; padding: 10px 14px; }

/* 예전 '반복 설정'(매일/매주/매월/요일 지정)은 위 '반복' 칸과 겹쳐서 숨김 (기념일의 100일/매년 반복만 기념일 수정 때 보임) */
#write-panel #panel_todo_repeat,
#write-panel #panel_weekday_options { display: none !important; }
#write-panel #panel_repeat_group:not(.is-anniv) { display: none !important; }


/* ============ 반복: 작은 달력에서 날짜 더하기/빼기 ============ */
.dy-rr-cal {
    margin-top: 10px;
    padding: 8px;
    border-radius: 8px;
    background: var(--card-bg-color, #ffffff);
    border: 1px solid var(--container-border-color, #e5e5e5);
}
.dy-rr-cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-weight: 600; font-size: 0.95em; }
.dy-rr-cal-nav {
    width: 26px; height: 26px;
    border: none; border-radius: 6px;
    background: none;
    color: var(--content-font-color, #333333);
    cursor: pointer;
}
.dy-rr-cal-nav:hover { background: var(--container-bg-color, rgba(0,0,0,0.05)); }
.dy-rr-cal-week, .dy-rr-cal-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; text-align: center; }
.dy-rr-cal-week { font-size: 0.78em; color: var(--text-muted, #888888); margin-bottom: 3px; }
.dy-rr-cal-week .is-sun, .dy-rr-cal-day.is-sun { color: var(--error-color, #e05555); }
.dy-rr-cal-week .is-sat, .dy-rr-cal-day.is-sat { color: var(--info-color, #3b82f6); }
.dy-rr-cal-day {
    position: relative;
    height: 30px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 6px;
    background: none;
    font-size: 0.85em;
    color: var(--content-font-color, #333333);
    cursor: pointer;
}
.dy-rr-cal-day.is-blank { cursor: default; }
.dy-rr-cal-day:not(.is-blank):hover { border-color: var(--accent-color, #3b82f6); }
.dy-rr-cal-day.is-before { opacity: 0.35; }
.dy-rr-cal-day.is-today { font-weight: 700; text-decoration: underline; }
.dy-rr-cal-day.is-start { box-shadow: inset 0 0 0 1px var(--content-font-color, #333333); }
.dy-rr-cal-day.is-on { background: var(--accent-color, #3b82f6); color: #ffffff !important; }
.dy-rr-cal-day.is-add { border: 2px dashed var(--accent-color, #3b82f6); }
.dy-rr-cal-day.is-add.is-on { border-color: #ffffff; outline: 2px solid var(--accent-color, #3b82f6); outline-offset: -1px; }
.dy-rr-cal-day.is-ex { text-decoration: line-through; color: var(--text-muted, #999999) !important; background: rgba(128,128,128,0.15); }
.dy-rr-cal-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 6px; font-size: 0.78em; color: var(--text-muted, #888888); }
.dy-rr-cal-legend span { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: middle; margin-right: -6px; }
.dy-rr-cal-legend .lg-on { background: var(--accent-color, #3b82f6); }
.dy-rr-cal-legend .lg-add { background: var(--accent-color, #3b82f6); outline: 2px dashed var(--accent-color, #3b82f6); outline-offset: 1px; }
.dy-rr-cal-legend .lg-ex { background: rgba(128,128,128,0.3); }


/* ============ 비서 (왼쪽 목록 아래 오른쪽, 오늘 일정 말풍선) ============ */
.sidebar-list { display: flex; flex-direction: column; }
/* 말풍선이 목록 칸 위로 넘쳐도 잘리지 않게: 스크롤은 목록(.list-items)에서만 */
.sidebar-list { overflow: visible; }
.sidebar-list > .list-items { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.sidebar-list > .dy-helper { flex-shrink: 0; }
.dy-helper {
    margin-top: auto;              /* 목록 아래쪽으로 */
    display: flex;
    flex-direction: column;
    align-items: center;           /* 가운데 */
    gap: 6px;
}
.dy-helper-bubble {
    position: absolute;            /* 이미지 바로 위 가운데 */
    left: 50%;
    bottom: calc(100% + 12px);
    z-index: 5;
    width: max-content;
    max-width: 220px;
    padding: 9px 13px;
    border-radius: 5px;
    background: var(--card-bg-color, #ffffff);
    color: var(--content-font-color, #333333);
    border: 0 !important;          /* 테두리 없음 */
    font-family: 'DyDungGeunMo', 'DungGeunMo', sans-serif !important;   /* 둥근모꼴 */
    box-shadow: 0 4px 14px rgba(0,0,0,0.12);
    font-size: 0.9em;
    line-height: 1.5;
    word-break: keep-all;
    overflow-wrap: anywhere;
    white-space: pre-line;         /* 세 줄로 */
    text-align: center;
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, 6px) scale(0.96);
    transform-origin: 50% 100%;
    transition: opacity 0.5s ease, transform 0.5s ease, visibility 0s linear 0.5s, background-color 0.3s, color 0.3s;   /* 부드럽게 사라짐 */
}
.dy-helper-bubble.is-show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
    transition: opacity 0.25s ease, transform 0.3s cubic-bezier(.3, 1.5, .5, 1), visibility 0s, background-color 0.3s, color 0.3s;
}
.dy-helper-bubble::after {           /* 꼬리: 아래, 이미지 가운데를 가리킴 */
    content: '';
    position: absolute;
    left: 50%;
    margin-left: -7px;
    bottom: -7px;
    width: 12px;
    height: 12px;
    background: inherit;
    transform: rotate(45deg);
}
.dy-helper-figure { position: relative; max-width: 100%; }
.dy-helper-img {
    display: block;
    max-width: min(300px, 100%);   /* 가로·세로 최대 300px */
    max-height: 300px;
    width: auto;
    height: auto;
    object-fit: contain;
    cursor: pointer;
    user-select: none;
    -webkit-user-drag: none;
    transform-origin: 50% 100%;
}
.dy-helper-noimg {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-color, #3b82f6);
    color: var(--content-font-color, #333333);   /* 이미지 아이콘 */
    font-size: 30px;
}
/* 말랑하게 눌리는 효과 */
.dy-helper-img.is-squish { animation: dyHelperSquish 0.55s ease; }
@keyframes dyHelperSquish {
    0%   { transform: scale(1, 1); }
    20%  { transform: scale(1.12, 0.84); }
    45%  { transform: scale(0.93, 1.08); }
    65%  { transform: scale(1.04, 0.97); }
    82%  { transform: scale(0.99, 1.01); }
    100% { transform: scale(1, 1); }
}
.dy-helper-manage {
    position: absolute;            /* 이미지 오른쪽 위 */
    top: 4px;
    right: 4px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 7px;
    border: none;
    border-radius: 12px;
    background: rgba(128,128,128,0.18);
    color: var(--content-font-color, #333333);   /* 이미지 아이콘 */
    font-size: 0.72em;
    cursor: pointer;
    opacity: 0.75;
}
.dy-helper-manage:hover { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
    .dy-helper-bubble, .dy-helper-bubble.is-show { transition: none; }
    .dy-helper-img.is-squish { animation: none; }
}

/* 비서 이미지 관리 팝업 (관리자) */
html.dy-helper-mgr-open { overflow: hidden; }
.dy-helper-mgr {
    position: fixed; inset: 0; z-index: 10002;
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
    background: rgba(0,0,0,0.45);
}
.dy-helper-mgr[hidden] { display: none; }
.dy-helper-mgr-box {
    position: relative;
    width: 100%; max-width: 520px; max-height: calc(100vh - 32px);
    display: flex; flex-direction: column;
    padding: 16px; box-sizing: border-box;
    border-radius: 14px;
    background: var(--card-bg-color, #ffffff);
    color: var(--content-font-color, #333333);
    box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}
.dy-helper-mgr-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.dy-helper-mgr-num { font-weight: 400; color: var(--text-muted, #888888); font-size: 0.9em; }
.dy-helper-mgr-close { width: 30px; height: 30px; border: none; border-radius: 50%; background: none; color: var(--text-muted, #888888); font-size: 1.1em; cursor: pointer; }
.dy-helper-mgr-hint { margin: 0 0 10px; font-size: 0.8em; color: var(--text-muted, #888888); }
.dy-helper-mgr-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; overflow-y: auto; min-height: 90px; padding: 2px; }
.dy-helper-mgr-item {
    position: relative; aspect-ratio: 1 / 1; padding: 0;
    border: 2px solid transparent; border-radius: 10px;
    background: rgba(128,128,128,0.08);
    overflow: hidden; cursor: pointer;
}
.dy-helper-mgr-item img { width: 100%; height: 100%; object-fit: contain; display: block; }
.dy-helper-mgr-item.is-picked { border-color: var(--error-color, #dc3232); }
.dy-helper-mgr-item.is-picked img { opacity: 0.6; }
.dy-helper-mgr-check {
    position: absolute; top: 5px; right: 5px;
    width: 20px; height: 20px; box-sizing: border-box;
    border-radius: 50%; border: 2px solid #ffffff;
    background: rgba(0,0,0,0.25); color: transparent; font-size: 0.65em;
    display: flex; align-items: center; justify-content: center;
}
.dy-helper-mgr-item.is-picked .dy-helper-mgr-check { background: var(--error-color, #dc3232); color: #ffffff; }
.dy-helper-mgr-empty { grid-column: 1 / -1; padding: 24px 0; text-align: center; font-size: 0.85em; color: var(--text-muted, #888888); }
.dy-helper-mgr-foot { display: flex; align-items: center; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.dy-helper-mgr-btn {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 6px 14px; border: none; border-radius: 20px;
    background: rgba(128,128,128,0.12); color: var(--content-font-color, #333333);
    font-size: 0.85em; font-weight: 600; cursor: pointer;
}
.dy-helper-mgr-btn.is-add { background: var(--accent-color, #3b82f6); color: var(--content-font-color, #333333); }   /* '이미지 추가' 글자·아이콘 */
.dy-helper-mgr-btn.is-del { margin-left: auto; background: var(--error-color, #dc3232); color: #ffffff; }
.dy-helper-mgr-btn.is-del:disabled { opacity: 0.4; cursor: default; }
.dy-helper-mgr-loading {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    border-radius: 14px; background: rgba(255,255,255,0.55);
    font-size: 1.6em; color: var(--text-muted, #888888);
}
.dy-helper-mgr-loading[hidden] { display: none; }
@media (max-width: 480px) { .dy-helper-mgr-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* 비서 말풍선 글꼴: 둥근모꼴 (컴퓨터에 있으면 그것을, 없으면 웹 글꼴을 받아 씀) */
@font-face {
    font-family: 'DyDungGeunMo';
    src: local('DungGeunMo'), local('둥근모꼴'),
         url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_six@1.2/DungGeunMo.woff') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}
/* 둥근모꼴에서 밑줄(_)이 안 보이는 경우가 있어 그 글자만 보통 글꼴로 */
.dy-helper-bubble .dy-us { font-family: 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif !important; }


/* ============ 분류 + 일정 검색 (달력 오른쪽 아래, 검색창 모양) ============ */
.diary-calendar, .diary-week-calendar { position: relative; }
.dy-cal-search-wrap {
    display: flex;
    justify-content: flex-end;     /* 오른쪽 */
    padding: 12px 0 0;
}
.diary-week-calendar .dy-cal-search-wrap { padding: 10px 12px 12px; }
.dy-cal-search {
    display: flex;
    align-items: center;
    gap: 4px;
    width: min(560px, 100%);
    height: 46px;
    padding: 0 6px 0 16px;
    box-sizing: border-box;
    border-radius: 23px;
    border: 1px solid var(--container-border-color, #dfe1e5);
    background: var(--card-bg-color, #ffffff);
    color: var(--content-font-color, #333333);
    box-shadow: 0 1px 6px rgba(32,33,36,0.12);
    transition: box-shadow 0.2s, border-color 0.2s;
}
.dy-cal-search:hover,
.dy-cal-search:focus-within { box-shadow: 0 2px 10px rgba(32,33,36,0.2); border-color: transparent; }
.dy-cal-search-icon { color: var(--text-muted, #888888); font-size: 0.95em; flex-shrink: 0; }
.dy-cal-search-cat {
    flex: 0 0 auto;
    max-width: 130px;
    height: 34px;
    padding: 0 6px;
    border: none;
    background: transparent;
    color: var(--content-font-color, #333333);
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    outline: none;
}
.dy-cal-search-bar { width: 1px; height: 22px; background: var(--container-border-color, #dfe1e5); flex-shrink: 0; }
.dy-cal-search-input {
    flex: 1 1 auto;
    min-width: 0;
    height: 34px;
    padding: 0 8px;
    border: none !important;
    background: transparent !important;
    color: var(--content-font-color, #333333);
    font-size: 1em;
    outline: none;
    box-shadow: none !important;
}
.dy-cal-search-input::placeholder { color: var(--text-muted, #999999); }
.dy-cal-search-btn,
.dy-cal-search-add {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 50% !important;
    background: transparent !important;
    color: var(--text-muted, #888888) !important;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.dy-cal-search-btn:hover,
.dy-cal-search-add:hover { background: rgba(128,128,128,0.12) !important; color: var(--content-font-color, #333333) !important; }
.dy-cal-search .search-option:has(input:checked) { color: var(--accent-color, #3b82f6) !important; }   /* 지난 일정 포함 켜짐 */
.dy-cal-search-add {
    background: rgba(128,128,128,0.1) !important;
    color: var(--content-font-color, #333333) !important;
}
@media (max-width: 768px) {
    .dy-cal-search-wrap { padding: 10px; }
    .dy-cal-search { width: 100%; }
}


/* ============ 사이드바: 배경·테두리 없음 / 상세 칸은 비서 말풍선과 같은 모양 ============ */
.diary-sidebar:not(#mobile-diary-sidebar),
.week-view .diary-sidebar:not(#mobile-diary-sidebar) {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
}
/* 상세 칸: 말풍선과 같은 배경색·글자색·글씨체 (색은 비서 이미지에서 고른 색을 함께 씀) */
.sidebar-detail {
    background: var(--card-bg-color, #ffffff);
    color: var(--content-font-color, #333333);
    border: 0;
    border-radius: 5px;
    font-family: 'DyDungGeunMo', 'DungGeunMo', sans-serif !important;
    transition: background-color 0.3s, color 0.3s;
}
.sidebar-detail *:not(i):not(.fa):not([class*="fa-"]) { font-family: inherit !important; }
.sidebar-detail .detail-title,
.sidebar-detail .detail-meta,
.sidebar-detail .detail-content,
.sidebar-detail .detail-empty,
.sidebar-detail .detail-btn { color: inherit; }
.sidebar-detail .detail-meta { opacity: 0.75; }


/* ============ 달력: 분류 색 동그라미만 보기 (방문자는 항상, 관리자는 스위치로) ============ */
.diary-calendar.dy-dots .day-events {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding-top: 4px;
}
.diary-calendar.dy-dots .event-bar {
    flex: 0 0 10px;
    width: 10px !important;
    height: 10px !important;
    min-height: 10px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 50% !important;
    font-size: 0 !important;
    overflow: hidden;
    transform: none !important;
}
.diary-calendar.dy-dots .event-bar > *,
.diary-calendar.dy-dots .event-tooltip { display: none !important; }
/* 동그라미 커지기는 마우스가 있는 화면에서만 (모바일에서 누르면 커진 채로 남지 않게) */
@media (hover: hover) and (pointer: fine) {
    .diary-calendar.dy-dots .event-bar:hover { transform: scale(1.3) !important; opacity: 1; }
}

/* 관리자 스위치 */
.dy-mode-switch {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0 4px;
    cursor: pointer;
    user-select: none;
    color: var(--content-font-color, #333333);
    font-size: 0.9em;
}
.dy-mode-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.dy-switch-track {
    position: relative;
    width: 36px;
    height: 20px;
    border-radius: 10px;
    background: rgba(128,128,128,0.35);
    transition: background 0.2s;
    flex-shrink: 0;
}
.dy-switch-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
    transition: transform 0.2s;
}
.dy-mode-switch input:checked + .dy-switch-track { background: var(--accent-color, #3b82f6); }
.dy-mode-switch input:checked + .dy-switch-track .dy-switch-thumb { transform: translateX(16px); }
.dy-mode-switch input:focus-visible + .dy-switch-track { outline: 2px solid var(--accent-color, #3b82f6); outline-offset: 2px; }

/* 날짜를 눌렀을 때 상세 칸: 그 날 일정 목록 */
.dy-date-detail .detail-title { margin-bottom: 8px; }
.dy-date-item { padding: 6px 0; border-top: 1px dashed rgba(128,128,128,0.35); }
.dy-date-item:first-of-type { border-top: 0; }
.dy-date-item-title {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
}
.dy-date-item-title:hover { text-decoration: underline; }
.dy-date-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dy-date-item .detail-content { margin-top: 4px; }


/* ============ 달력 칸 스티커 ============ */
.calendar-table td.day-cell { position: relative; }
.dy-stickers {
    position: absolute;
    right: 4px;
    bottom: 4px;
    z-index: 2;
    display: flex;
    flex-wrap: wrap-reverse;
    justify-content: flex-end;
    gap: 2px;
    max-width: calc(100% - 8px);
    pointer-events: none;          /* 평소에는 칸 클릭을 막지 않음 */
}
.dy-stickers:empty { display: none; }
.dy-sticker {
    width: 85px;                   /* 2.5배 */
    height: 85px;
    max-width: 100%;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.15));
}
@media (max-width: 768px) { .dy-sticker { width: 22px; height: 22px; } }   /* 모바일: 44px 의 50% */
/* 스티커 모드 (관리자) */
.diary-calendar.dy-sticker-mode td.day-cell[data-date] { cursor: copy; }
.diary-calendar.dy-sticker-mode td.day-cell[data-date]:hover { outline: 2px dashed var(--accent-color, #3b82f6); outline-offset: -3px; }
.diary-calendar.dy-sticker-mode .dy-stickers { pointer-events: auto; }
.diary-calendar.dy-sticker-mode .dy-sticker { cursor: pointer; }
.diary-calendar.dy-sticker-mode .dy-sticker:hover { filter: drop-shadow(0 0 2px var(--error-color, #dc3232)); opacity: 0.7; }
.dy-sticker-btn.active { background: var(--btn-accent-bg, var(--accent-color, #3b82f6)); color: var(--btn-accent-text, #ffffff); }
.dy-sticker-pal {
    position: fixed;
    left: 50%;
    bottom: 16px;
    z-index: 9000;
    width: min(640px, calc(100% - 24px));
    transform: translateX(-50%);
    padding: 12px 14px;
    box-sizing: border-box;
    border-radius: 14px;
    background: var(--card-bg-color, #ffffff);
    color: var(--content-font-color, #333333);
    box-shadow: 0 10px 32px rgba(0,0,0,0.22);
}
.dy-sticker-pal[hidden] { display: none; }
.dy-sticker-pal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.dy-sticker-pal-hint { flex: 1; font-size: 0.8em; color: var(--text-muted, #888888); }
.dy-sticker-pal-close { width: 28px; height: 28px; border: none; border-radius: 50%; background: none; color: var(--text-muted, #888888); cursor: pointer; }
.dy-sticker-pal-grid { display: flex; flex-wrap: wrap; gap: 6px; max-height: 150px; overflow-y: auto; padding: 2px; }
.dy-sticker-pal-item {
    width: 52px; height: 52px; padding: 4px;
    border: 2px solid transparent; border-radius: 10px;
    background: rgba(128,128,128,0.08);
    cursor: pointer;
}
.dy-sticker-pal-item img { width: 100%; height: 100%; object-fit: contain; display: block; }
.dy-sticker-pal-item.is-sel { border-color: var(--accent-color, #3b82f6); background: rgba(59,130,246,0.1); }
.dy-sticker-pal-item.is-del { border-color: var(--error-color, #dc3232); opacity: 0.7; }
.dy-sticker-pal-empty { padding: 14px 0; font-size: 0.85em; color: var(--text-muted, #888888); }
.dy-sticker-pal-foot { display: flex; align-items: center; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.dy-sticker-pal-btn {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 6px 12px; border: none; border-radius: 20px;
    background: rgba(128,128,128,0.12); color: var(--content-font-color, #333333);
    font-size: 0.85em; font-weight: 600; cursor: pointer;
}
.dy-sticker-pal-btn.is-add { background: var(--accent-color, #3b82f6); color: var(--content-font-color, #333333); }
.dy-sticker-pal-btn.is-delbtn { background: var(--error-color, #dc3232); color: #ffffff; }
.dy-sticker-pal-btn.is-delbtn:disabled { opacity: 0.45; cursor: default; }
.dy-sticker-pal-btn[hidden], .dy-sticker-pal-loading[hidden] { display: none !important; }
.dy-sticker-pal-loading { color: var(--text-muted, #888888); }


/* ============ 스킨 전체 글꼴: 둥근모꼴 ============ */
.diary-container,
#mobile-diary-sidebar,
.mobile-bottom-toggle,
.write-panel,
.dy-confirm,
.dy-helper-mgr,
.dy-sticker-pal,
.toast-message,
.diary-write-container,
#bo_w {
    font-family: 'DyDungGeunMo', 'DungGeunMo', sans-serif !important;
}
/* 안쪽 글자·입력칸·버튼도 같은 글꼴 (아이콘 글꼴은 그대로) */
.diary-container *:not(i):not(.fa):not([class*="fa-"]),
#mobile-diary-sidebar *:not(i):not(.fa):not([class*="fa-"]),
.mobile-bottom-toggle *:not(i):not(.fa):not([class*="fa-"]),
.write-panel *:not(i):not(.fa):not([class*="fa-"]),
.dy-confirm *:not(i):not(.fa):not([class*="fa-"]),
.dy-helper-mgr *:not(i):not(.fa):not([class*="fa-"]),
.dy-sticker-pal *:not(i):not(.fa):not([class*="fa-"]),
.diary-write-container *:not(i):not(.fa):not([class*="fa-"]),
#bo_w *:not(i):not(.fa):not([class*="fa-"]) {
    font-family: inherit !important;
}


/* ============ 달력 표: 비서 이미지에서 고른 색(60% 불투명) + 그에 맞춘 글자색 ============ */
/* (색은 helper.skin.php 가 이미지에서 골라 --dy-pick-rgb / --dy-pick-fg 로 넘김, 못 고르면 원래 색) */
html .calendar-table th,
html .calendar-table td {
    background: rgba(var(--dy-pick-rgb), 0.6);
    color: var(--dy-pick-fg);
    transition: background-color 0.3s, color 0.3s;
}
html .calendar-table th,
html .calendar-table th.sunday,
html .calendar-table th.saturday,
html .calendar-table .day-number,
html .calendar-table .day-cell.other-month .day-number { color: var(--dy-pick-fg); }
html .calendar-table .day-cell.today { background: rgba(var(--dy-pick-rgb), 0.85); }   /* 오늘은 조금 더 진하게 */
html .calendar-table .day-cell.today .day-number { color: var(--dy-pick-fg); text-decoration: underline; }

/* 달력 날짜 숫자 1.5배 */
.calendar-table .day-number { font-size: 1.5em !important; line-height: 1.2; }
/* 상세 칸: 제목 아래 5px 띄움 */
.sidebar-detail .detail-title { margin-bottom: 5px !important; }
/* 달력 테두리 부분(날짜 칸 바깥 틀과 테두리)도 비서 이미지에서 고른 색으로 (날짜 칸은 위의 60% 색 그대로) */
html .diary-calendar {
    background: transparent !important;    /* 틀 배경·테두리 투명 */
    border-color: transparent !important;
}
/* 달력 숫자 · 년월 글자: 자동 글자색을 70% 불투명으로 */
html .calendar-table .day-number,
html .calendar-table .day-cell.today .day-number,
html .diary-calendar .calendar-current {
    color: var(--dy-pick-fg) !important;
    color: color-mix(in srgb, var(--dy-pick-fg) 70%, transparent) !important;
}

/* 달력 칸: 테두리 선 없이 둥근 칸(15px) + 칸 사이 2px 간격 */
.calendar-table {
    border-collapse: separate !important;
    border-spacing: 2px;
}
.calendar-table th,
.calendar-table td,
.calendar-table td.day-cell {
    border: 0 !important;
    border-radius: 15px !important;
}
/* 드래그로 고를 때·편집 모드 끌어다 놓을 때 표시는 그대로 보이게 */
.calendar-table td.day-cell.drag-over { box-shadow: inset 0 0 0 2px var(--accent-color, #8b5cf6); }
/* 상세 칸 글자 70% 불투명 (이미지 색을 고르기 전 기본값, 고른 뒤에는 helper.skin.php 가 같은 70% 로 넣음) */
.sidebar-detail { color: color-mix(in srgb, var(--content-font-color, #333333) 70%, transparent); }
/* 들어오자마자 상세 칸도 말풍선과 같은 색 (비서 이미지에서 고른 색, 글자 70%) */
html .sidebar-detail {
    background-color: rgb(var(--dy-pick-rgb)) !important;
    color: var(--dy-pick-fg70) !important;
}
/* 관리자 스위치 · 검색창 테두리도 말풍선처럼 비서 이미지에서 고른 색으로 */
html .dy-switch-track { background: rgba(var(--dy-pick-rgb), 0.4); }   /* 꺼짐: 옅게 */
html .dy-mode-switch input:checked + .dy-switch-track { background: rgb(var(--dy-pick-rgb)); }   /* 켜짐 */
html .dy-cal-search,
html .dy-cal-search:hover,
html .dy-cal-search:focus-within {
    border-color: transparent;   /* 테두리 색 없음 */
}
/* 검색창 배경도 비서 이미지에서 고른 색 60% */
html .dy-cal-search { background: rgba(var(--dy-pick-rgb), 0.6); }
html .dy-cal-search,
html .dy-cal-search-input,
html .dy-cal-search-cat { color: var(--dy-pick-fg); }   /* 배경 색에 묻히지 않는 글자색 */
html .dy-cal-search-input::placeholder { color: var(--dy-pick-fg); opacity: 0.6; }

/* ============ 웹(데스크톱): 달력 가로 800px, 안쪽 글자·칸·검색창·머리줄도 비율에 맞춰 축소 (모바일은 그대로) ============ */
@media (min-width: 769px) {
    .diary-calendar {
        flex: 0 1 800px;
        width: 800px;
        max-width: 800px;
        font-size: 0.8em;            /* em 으로 된 글자·여백이 함께 줄어듦 */
        padding: 0.8em;
    }
    .diary-container { justify-content: center; }
    /* 머리줄 (년월·이동 버튼·보기 버튼) */
    .diary-calendar .calendar-header { padding-bottom: 8px; gap: 8px; }
    .diary-calendar .calendar-nav button { padding: 4px 11px; }
    .diary-calendar .btn-view { padding: 6px 12px; }
    .dy-mode-switch { font-size: 1em; }
    .dy-switch-track { width: 30px; height: 17px; border-radius: 9px; }
    .dy-switch-thumb { width: 13px; height: 13px; }
    .dy-mode-switch input:checked + .dy-switch-track .dy-switch-thumb { transform: translateX(13px); }
    /* 날짜 칸 */
    .diary-calendar .calendar-table th { padding: 7px; }
    .diary-calendar .calendar-table td { height: 88px; padding: 4px; }
    .diary-calendar .event-bar { min-height: 12px; line-height: 9px; }
    .diary-calendar.dy-dots .event-bar { flex-basis: 8px; width: 8px !important; height: 8px !important; min-height: 8px !important; }
    .diary-calendar .dy-sticker { width: 62px; height: 62px; }
    /* 검색창 */
    .dy-cal-search { width: min(420px, 100%); height: 38px; border-radius: 19px; padding: 0 4px 0 12px; }
    .dy-cal-search-cat { max-width: 100px; height: 28px; font-size: 0.9em; }
    .dy-cal-search-input { height: 28px; font-size: 0.95em; }
    .dy-cal-search-btn, .dy-cal-search-add { width: 28px; height: 28px; }
    .dy-cal-search-wrap { padding-top: 10px; }
}

/* ============ 상세 칸 · 달력 색 고정 (지금 보이는 색) ============ */
/* 예전에는 비서 이미지에서 색을 골라 바꿨지만, 이제 이 색으로 고정 (말풍선만 이미지 색을 따라감)
   - 배경: rgb(247, 243, 243) — 상세 칸은 그대로, 달력 칸·검색창은 60% 불투명
   - 글자: #1f1f1f — 달력 숫자·년월·상세 글자는 70% 불투명 */
:root {
    --dy-pick-rgb: 247, 243, 243;
    --dy-pick-fg: #1f1f1f;
    --dy-pick-fg70: rgba(31, 31, 31, 0.7);
}

/* 달력 이동 버튼(.calendar-nav)을 오른쪽 보기 버튼(.view-switcher)과 같은 간격·높이·색으로 */
.calendar-nav { gap: 6px; }
.calendar-nav button {
    padding: 8px 16px;
    border: 0;
    border-radius: var(--btn-primary-radius);
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    font-size: 1em;
    line-height: normal;
    transition: all 0.2s;
}
.calendar-nav button:hover { background: var(--btn-primary-text); color: var(--btn-primary-bg); opacity: 1; }
@media (min-width: 769px) {
    .diary-calendar .calendar-nav button { padding: 6px 12px; }   /* 800px 달력에서 보기 버튼과 같은 크기 */
}
@media (max-width: 768px) {
    .calendar-nav button { padding: 6px 10px; font-size: 1em; }   /* 모바일 보기 버튼과 같은 크기 */
}


/* ============ 년/월: 관리자 외에는 오른쪽 정렬 ============ */
.diary-calendar .calendar-header .calendar-current.dy-cur-right {
    flex: 1 1 auto;
    text-align: right;
}


/* ============ 관리자 외에는 검색창 숨김 ============ */
.dy-cal-search-wrap[hidden] { display: none !important; }

/* ============ 모바일: 누른 날짜 칸 배경색 (말풍선과 같은 색) ============ */
@media (max-width: 768px) {
    html .calendar-table td.day-cell.dy-sel {
        background: var(--dy-bubble-bg, var(--card-bg-color, #ffffff)) !important;   /* 말풍선과 같은 배경색 */
    }
    html .calendar-table td.day-cell.dy-sel .day-number { color: var(--dy-bubble-fg, var(--content-font-color, #333333)) !important; }
}


/* ============ 모바일: 비서를 년/월과 달력 사이에 ============ */
/* 이미지는 왼쪽, 말풍선은 이미지 오른쪽 남는 자리에 (숨어 있을 때도 자리 차지 → 달력이 움직이지 않음) */
@media (max-width: 768px) {
    .diary-calendar .dy-helper {
        margin: 0;
        padding: 0;
        display: block;
    }
    .diary-calendar .dy-helper-figure {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: 14px;
        width: 100%;
    }
    .diary-calendar .dy-helper-img {
        flex: 0 0 auto;
        margin: 0;
        max-width: min(290px, calc(55% + 40px));   /* 모바일 이미지 (40px 키움) */
        max-height: 290px;
    }
    .diary-calendar .dy-helper-bubble {
        order: 2;                      /* 이미지 오른쪽 */
        position: relative;
        left: auto;
        bottom: auto;
        flex: 0 1 auto;
        min-width: 0;
        max-width: none;
        width: auto;
        transform: translateX(-6px) scale(0.96);
        transform-origin: 0 50%;
    }
    .diary-calendar .dy-helper-bubble.is-show { transform: none; }
    .diary-calendar .dy-helper-bubble::after {   /* 꼬리: 왼쪽, 이미지를 가리킴 */
        left: -5px;
        top: 50%;
        bottom: auto;
        margin: -6px 0 0;
    }
    .diary-calendar .dy-helper-manage { top: auto; bottom: 4px; right: 4px; }

    /* 말풍선·글자 1.5배 (모바일)
       - 이미지 오른쪽, 년/월 바로 위에 떠서 위로 자람 → 글이 길어도 달력이 움직이지 않고 년/월과 겹치지 않음 */
    .diary-calendar .dy-helper-figure { position: relative; }
    .diary-calendar .dy-helper-bubble {
        position: absolute;
        left: calc(var(--dy-fig-half, 100px) * 2 - 21px);   /* 이미지 쪽으로 35px 당김 */
        bottom: 72px;                  /* 년/월 위 */
        width: max-content;
        max-width: calc(100% - var(--dy-fig-half, 100px) * 2 + 21px);
        box-sizing: border-box;
        font-size: calc(1.35em - 2pt); /* 0.9em × 1.5 에서 2pt 작게 */
        padding: 13px 19px;            /* 9px 13px × 1.5 */
        border-radius: 7px;
        transform-origin: 0 100%;
    }
    .diary-calendar .dy-helper-bubble::after { width: 16px; height: 16px; left: -7px; top: auto; bottom: 16px; margin: 0; }

    /* 년/월: 이미지 옆 오른쪽 아래 (달력 바로 위에 보임), 오른쪽 정렬, 2em */
    html .diary-calendar .dy-helper-figure .calendar-current {
        position: absolute;
        left: auto;
        right: 5px;                    /* 오른쪽에서 5px */
        bottom: 5px;                   /* 달력에서 5px 위 */
        width: auto;
        margin: 0;
        padding: 0;
        text-align: right;
        line-height: 1.1;
        font-size: 2em;
        white-space: nowrap;
    }
    /* 이미지 위에 겹친 말풍선·년/월이 누르기를 가로채지 않게 (이미지 클릭이 잘 되도록) */
    .diary-calendar .dy-helper-bubble,
    html .diary-calendar .dy-helper-figure .calendar-current { pointer-events: none; }
    .diary-calendar .dy-helper-img {
        position: relative;
        z-index: 1;
        touch-action: manipulation;    /* 두 번 눌러 확대 대기 없이 바로 반응 */
        -webkit-tap-highlight-color: transparent;
    }
    .diary-calendar .dy-helper-bubble,
    html .diary-calendar .dy-helper-figure .calendar-current { z-index: 2; }   /* 글자는 이미지 위에 보이게 */
    .diary-calendar .dy-helper-manage { z-index: 3; }
    /* 년/월이 빠져 빈 머리줄(관리자 외)은 숨김 */
    .diary-calendar .calendar-header.dy-head-empty { display: none; }
}


/* ============ 요일 칸: 일요일·토요일 글자색 ============ */
html .diary-calendar .calendar-table th.sunday { color: #ffb1be; }
html .diary-calendar .calendar-table th.saturday { color: var(--btn-primary-text); }

/* ============ 모바일: 요일 칸 세로 길이 줄이기 (날짜 칸 높이 85px 가 요일 칸에도 걸려 있었음) ============ */
@media (max-width: 768px) {
    html .diary-calendar .calendar-table th {
        height: auto;
        padding: 4px 2px;
        line-height: 1.2;
    }
}


/* ============ 이전 달 / 오늘 / 다음 달: 달력 아래 ============ */
/* 웹: 왼쪽 아래, 검색창과 같은 줄 / 모바일: 가운데 (검색창은 그 아래) */
.dy-cal-foot { display: flex; flex-direction: column; }
.dy-cal-foot > .calendar-nav { justify-content: center; margin-top: 10px; }
@media (min-width: 769px) {
    .dy-cal-foot {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding-top: 12px;
    }
    .dy-cal-foot > .calendar-nav { justify-content: flex-start; margin-top: 0; flex-shrink: 0; }
    /* 버튼 높이를 검색창(38px)과 같게, 가로·글자도 같은 비율(약 1.3배)로 키움 */
    html .diary-calendar .dy-cal-foot > .calendar-nav button {
        height: 38px;
        padding: 0 16px;
        font-size: 1em;
        line-height: 1;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
    }
    .dy-cal-foot > .dy-cal-search-wrap { flex: 1 1 auto; min-width: 0; padding-top: 0 !important; }
}


/* ============ 년/월 글자색: content-font-color 70% ============ */
html .diary-calendar .calendar-header .calendar-current {
    color: var(--content-font-color) !important;
    color: color-mix(in srgb, var(--content-font-color) 70%, transparent) !important;
}


/* ============ 모바일: 년/월 왼쪽 정렬 · 일정 점 작게 ============ */
@media (max-width: 768px) {
    html .diary-calendar .calendar-header .calendar-current,
    html .diary-calendar .calendar-header .calendar-current.dy-cur-right { text-align: left; }
    .diary-calendar.dy-dots .day-events { gap: 3px; padding-top: 3px; }
    .diary-calendar.dy-dots .event-bar {
        flex-basis: 6px;
        width: 6px !important;
        height: 6px !important;
        min-height: 6px !important;
    }
}


/* ============ 이미지 출처: 달력 오른쪽 아래 작은 글씨 ============ */
.dy-credit {
    margin-top: 2px;                /* 달력 바로 아래 */
    text-align: right;
    font-size: 1em;
    line-height: 1.4;
    color: var(--content-font-color) !important;
    opacity: 0.4;
    word-break: break-all;
}
.dy-credit[hidden] { display: none !important; }
/* 출처 글만 둥근모꼴 대신 보통 글꼴 (스킨 전체 글꼴 규칙보다 우선) */
#dyCredit,
#dyCredit * { font-family: 'Malgun Gothic', 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif !important; }


/* ============ 모바일: 테마 바깥 틀(#container_wr) 여백 없애기 (이 게시판에서만) ============ */
@media (max-width: 768px) {
    html body #container_wr { padding: 0 !important; }
}


/* ============ 모바일: 이동 버튼(왼쪽)과 출처(오른쪽)를 달력 아래 한 줄로 ============ */
@media (max-width: 768px) {
    html .diary-calendar { display: flex; flex-wrap: wrap; align-items: center; align-content: flex-start; }
    html .diary-calendar > * { flex: 0 0 100%; min-width: 0; }
    html .diary-calendar > .dy-cal-foot { display: contents; }   /* 이동 버튼·검색창을 달력 줄에 바로 놓음 */
    html .diary-calendar .dy-cal-foot > .calendar-nav { order: 1; flex: 0 0 auto; justify-content: flex-start; margin-top: 10px; }
    html .diary-calendar > .dy-credit { order: 2; flex: 1 1 0; margin-top: 10px; padding-left: 10px; text-align: right; }
    html .diary-calendar .dy-cal-foot > .dy-cal-search-wrap { order: 3; flex: 0 0 100%; }
}
