* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* 모바일 탭 하이라이트 제거 */
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    background: #ffffff;
    color: #1f2937;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.mg-container {
    max-width: 1100px;
    margin: 40px auto;
    padding: 0 16px 40px;
}

/* 카드 공통 */
.mg-card {
    background: #ffffff;
    border-radius: 20px;
    padding: 24px 22px;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid #e5e7eb;
}

/* 후기 남기기 - 파스텔 오렌지 */
#user-guestbook {
    background: #ffedd5;
    border: 1px solid #fb923c;
}

/* 사용자 방명록 - 파스텔 보라 */
#user-guestbook-list {
    background: #f3e8ff;
    border: 1px solid #a855f7;
}

/* 섹션 헤더 */
.mg-section-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-end;
    margin-bottom: 14px;
}

/* 후기 남기기: 제목(h2) + 안내박스(마퀴) 왼쪽에서 나란히 */
.mg-section-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* 후기 남기기: 우측 150px 흐르는 안내문 */
.mg-header-marquee {
    /* 기본(데스크톱): 넓으니 2배로 */
    --marquee-w: 300px;
    --marquee-dur: 26s;
    --marquee-delay: 1s;

    width: var(--marquee-w);
    max-width: var(--marquee-w);
    height: 20px;
    align-self: center;
    overflow: hidden;
    border-radius: 10px;
    padding: 0;
    background: transparent;
    border: none;
}

.mg-marquee-track {
    display: flex;
    width: max-content;
    white-space: nowrap;
    will-change: transform;
    transform: translateX(0);
    animation: mg-marquee var(--marquee-dur) linear infinite;
    animation-delay: var(--marquee-delay);
    animation-fill-mode: both; /* 딜레이 동안 첫 위치(translateX(0)) 유지 */
}

.mg-marquee-text {
    display: inline-block;
    font-size: 13px;
    line-height: 20px;
    color: #b91c1c;
    padding-right: 40px; /* 반복 사이 간격 */
    flex: 0 0 auto;
}

@keyframes mg-marquee {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

.mg-section-header h2 {
    margin: 0 0 4px;
    font-size: 24px;
    color: #000000;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}

.mg-guestbook-count {
    font-size: 11px;
    font-weight: 500;
    color: #6b7280;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(15,23,42,0.03);
    border: 1px solid rgba(148,163,184,0.6);
}

.mg-admin-header-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.mg-admin-header-controls button {
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid #9ca3af;
    background: #f9fafb;
    color: #111827;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
}

.mg-admin-header-controls button#devBlockBtn {
    border-color: #b91c1c;
    color: #b91c1c;
}

.mg-admin-header-controls button#devDeleteBtn {
    border-color: #dc2626;
    color: #dc2626;
}

.mg-admin-header-controls button#devClearBtn {
    font-size: 11px;
    padding: 4px 10px;
}

.mg-user-review-item.selected {
    outline: 2px solid #f97316;
    outline-offset: 2px;
    background: rgba(251, 146, 60, 0.04);
}

/* 폼 */
.mg-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mg-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    align-items: center;
}

.mg-form-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mg-form-field input,
.mg-form-field select,
.mg-form-field textarea {
    border-radius: 10px;
    border: 2px solid #9ca3af;
    padding: 7px 9px;
    background: #ffffff;
    color: #000000;
    font-size: 14px;
    font-weight: 500;
    width: 100%;
}

.mg-form-field input:focus,
.mg-form-field select:focus,
.mg-form-field textarea:focus {
    outline: none;
    border-color: #6366f1;
}

#userRoleCustomWrapper {
    display: flex;
    align-items: center;
    width: 100%;
}

#userRoleCustomWrapper input {
    flex: 1;
}

.mg-form-field textarea {
    resize: none; /* 크기 조절 불가 */
    height: 60px; /* 고정 높이 */
    overflow-y: hidden; /* 스크롤 숨김 */
    line-height: 1.5; /* 줄 간격 */
}

.mg-form-field input::placeholder,
.mg-form-field textarea::placeholder {
    color: #6b7280;
}

.mg-char-counter {
    font-size: 11px;
    color: #6b7280;
    text-align: right;
    margin-top: 4px;
    font-weight: 500;
}

/* 데스크톱에서만 글자수 카운터 표시 */
@media (min-width: 481px) {
    .mg-char-counter {
        display: block !important;
    }
}

.mg-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #111827;
    font-weight: 500;
}

.mg-checkbox input {
    width: 16px;
    height: 16px;
}

.mg-btn-primary {
    border: none;
    border-radius: 999px;
    padding: 12px 24px;
    align-self: flex-start;
    background: linear-gradient(135deg, #a855f7, #6366f1);
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(168, 85, 247, 0.3);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    min-height: 44px; /* 터치 영역 최소 높이 */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: -6px; /* 위로 이동 */
}

.mg-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(168, 85, 247, 0.4);
}

.mg-btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(168, 85, 247, 0.3);
}

.mg-form-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.mg-form-footer .mg-checkbox {
    flex: 1;
}

.mg-form-footer .mg-btn-primary {
    margin-top: 0;
    flex-shrink: 0;
}

/* 사용자 방명록 리스트 */
.mg-user-review-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    max-height: 330px; /* 약 3줄 정도 높이 */
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
}

/* 스크롤바 스타일링 */
.mg-user-review-list::-webkit-scrollbar {
    width: 8px;
}

.mg-user-review-list::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 4px;
}

.mg-user-review-list::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

.mg-user-review-list::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

.mg-user-review-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px;
    border-radius: 12px;
    background: #ffffff;
    border: 1px solid #1e3a8a; /* 네이비 색상 1px 테두리 */
}

.mg-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: radial-gradient(circle at 30% 0, #a855f7, #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: #ffffff;
    flex-shrink: 0;
}

.mg-user-review-body {
    flex: 1;
}

.mg-user-review-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 0;
}

.mg-user-review-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.mg-user-nickname {
    font-size: 13px;
    font-weight: 700;
    color: #000000;
}

.mg-user-role {
    font-size: 12px;
    color: #4b5563;
    font-weight: 500;
}

.mg-user-time {
    font-size: 11px;
    color: #9ca3af;
    font-weight: 400;
    white-space: nowrap;
    margin-left: auto;
}

.mg-user-comment {
    margin-top: 0;
    font-size: 13px;
    color: #111827;
    line-height: 1.5;
}

/* 반응형 */
@media (max-width: 680px) {
    .mg-user-review-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        max-height: 350px;
    }
    .mg-form-row {
        grid-template-columns: 3fr 7fr; /* 30% : 70% 비율 */
    }
    .mg-page-title {
        font-size: 26px;
    }
    .mg-page-description {
        font-size: 18px;
    }
    .mg-section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    /* 모바일/태블릿: 제목 아래로 마퀴를 내려서 가로로 길게 */
    .mg-section-left {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        width: 100%;
    }

    .mg-header-marquee {
        --marquee-w: 100%;
        --marquee-dur: 34s;
        --marquee-delay: 1s;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        /* 모바일도 테두리/배경 제거 */
        border: none;
        background: transparent;
        padding: 0;
    }
}

@media (max-width: 480px) {
    .mg-user-review-list {
        grid-template-columns: repeat(1, minmax(0, 1fr));
        max-height: 400px; /* 모바일에서는 조금 더 높게 */
    }
    .mg-container {
        margin-top: 20px;
        padding-bottom: 20px;
        padding-left: 12px;
        padding-right: 12px;
    }
    .mg-card {
        padding: 18px 16px;
        border-radius: 16px;
    }
    .mg-section-header h2 {
        font-size: 20px;
    }
    .mg-form-field input,
    .mg-form-field select,
    .mg-form-field textarea {
        font-size: 14px;
        padding: 8px 10px;
    }
    .mg-btn-primary {
        width: 100%;
        padding: 12px 20px;
        font-size: 14px;
    }
    .mg-form-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    .mg-form-footer .mg-checkbox {
        order: 1;
    }
    .mg-form-footer .mg-btn-primary {
        order: 2;
    }
}
