:root {
    --bg-color: #ffffff;
    --text-color: #222222;
    --sub-text: #888888;
    --border-color: #e0e0e0;
    --accent-bg: #f7f7f7;
    --drawer-radius: 12px; /* 둥근 정도도 살짝 줄임 */
}

* { box-sizing: border-box; margin: 0; padding: 0; outline: none; }

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    overflow-x: hidden;
    padding-bottom: 80px;
}

/* 상단 헤더 (사이즈 축소) */
header {
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 800px; /* 전체 폭을 줄임 */
    margin: 0 auto;
}
header h1 { font-weight: 800; letter-spacing: -0.5px; font-size: 1.2rem; }
.repo-link {
    font-size: 0.6em;        /* ARCHIVE. 옆에 작게 */
    color: #888;
    text-decoration: none;
}
.repo-link:hover {
    color: #000;
}

.admin-btn {
    background: #fff; border: 1px solid #ccc;
    padding: 6px 12px; font-size: 0.75rem; cursor: pointer;
    border-radius: 10px; transition: 0.2s; font-weight: 600; color: #555;
}
.admin-btn:hover, .admin-btn.active { background: #222; color: #fff; border-color: #222; }

/* 사이트 추가 버튼 (플로팅) */
.add-site-btn {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
  
    background-color: #000;
    color: #fff;
  
    font-size: 32px;
    line-height: 56px;
    text-align: center;
    cursor: pointer;
  
    border: none;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
    display: none; 
    z-index: 1000;
  }

/* --- 메인 컨테이너 --- */
.main-container {
    max-width: 800px; /* 전체 폭 줄임 */
    margin: 20px auto;
    padding: 0 15px;
    display: flex;
    flex-direction: column;
    gap: 25px; /* 행 간격 줄임 */
}

.color-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 600;
    color: #555;
    user-select: none;
  }  

/* 각 행 (Row) */
.category-row {
    display: flex;
    align-items: stretch; /* 높이 동기화의 핵심 */
    gap: 15px; /* 사진-서랍 사이 간격 줄임 */
    /* 기본 높이를 아주 작게 줄임 -> 서랍 열면 늘어남 */
    min-height: 120px; 
    transition: all 0.4s ease; /* 부드러운 움직임 */
}

.category-row:nth-child(even) { flex-direction: row-reverse; }

/* 1. 사진 박스 영역 */
.row-image-box {
    flex: 3; /* 비율 조정 */
    position: relative;
    border-radius: var(--drawer-radius);
    overflow: hidden;
    background-color: #f4f4f4;
    /* 높이가 변할 때 이미지도 부드럽게 변하도록 설정 */
    transition: all 0.4s ease;
}
.row-image-box img {
    width: 100%; height: 100%; 
    object-fit: cover; /* 박스 크기에 맞춰 꽉 차게 */
    filter: none; 
    transform: none;
} 

.no-image-placeholder {
    width: 100%; height: 100%; display: flex; 
    justify-content: center; align-items: center;
    color: #ddd; font-weight: 800; font-size: 1rem;
}

/* 2. 서랍 박스 영역 */
.row-drawer-box {
    flex: 7; /* 서랍 영역을 좀 더 넓게 */
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--drawer-radius);
    overflow: hidden;
    display: flex; flex-direction: column;
    transition: all 0.4s ease; /* 박스 자체 애니메이션 */
}

/* 서랍 헤더 (작게) */
.drawer-header {
    padding: 0 25px; /* 상하 패딩 제거하고 flex로 중앙 정렬 */
    height: 100%; /* 닫혀있을 땐 박스 전체 높이 */
    min-height: 120px; /* row의 min-height와 맞춤 */
    cursor: pointer;
    display: flex; justify-content: space-between; align-items: center;
    font-weight: 700; font-size: 1.1rem;
    transition: background 0.2s;
}
/* 서랍이 열리면 헤더 높이를 줄여서 일반 헤더처럼 보이게 함 */
.row-drawer-box.open .drawer-header {
    height: auto;
    min-height: 60px;
    padding: 15px 25px;
    border-bottom: 1px solid var(--border-color);
    background: #fff;
}

.drawer-header:hover { background: var(--accent-bg); }
.drawer-header::after { content: '+'; font-weight: 300; font-size: 1.2rem; color: #aaa; }
.row-drawer-box.open .drawer-header::after { content: '-'; }

/* 서랍 내용 */
.drawer-content {
    flex: 1; 
    max-height: 0; overflow: hidden;
    /* 애니메이션 속도 */
    transition: max-height 0.4s ease-in-out; 
    background: #fff;
}
.row-drawer-box.open .drawer-content { 
    max-height: 1000px; /* 열렸을 때 최대 높이 제한 */
}

/* 리스트 아이템 (작게) */
.site-item {
    padding: 12px 25px; /* 패딩 축소 */
    border-bottom: 1px solid #f5f5f5;
    display: flex; justify-content: space-between; align-items: center;
}
.site-item:hover { background: #fafafa; padding-left: 30px; transition: 0.2s; }

.site-info { display: flex; flex-direction: column; flex: 1; text-decoration: none; color: inherit; }
.site-name { font-weight: 600; font-size: 0.95rem; margin-bottom: 2px; }
.site-desc { font-size: 0.75rem; color: var(--sub-text); }

/* 관리 버튼 그룹 */
.action-btns { display: none; gap: 6px; }
body.admin-mode .action-btns { display: flex; }
body.admin-mode .site-info { pointer-events: none; opacity: 0.6; } /* 관리모드 시 링크 비활성 느낌 */

.sm-btn { padding: 4px 8px; font-size: 0.7rem; cursor: pointer; border: 1px solid #333; border-radius: 5px; font-weight: 600;}
.btn-edit,
.btn-del {
  border-radius: 5px;
  padding: 6px 12px;
  font-size: 14px;
  cursor: pointer;
  border: 1px solid #ccc;
  transition: 
    background-color 0.15s ease,
    color 0.15s ease,
    transform 0.05s ease,
    box-shadow 0.05s ease;
}

/* 수정 버튼 */
.btn-edit {
    background: #fff;
    color: #333;
}

/* hover */
.btn-edit:hover {
    background: #f2f2f2;
}

/* active (클릭) */
.btn-edit:active {
    transform: scale(0.97);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.15);
}

/* 삭제 버튼 */
.btn-del {
    background: #333;
    color: #fff;
    border-color: #333;
}

/* hover */
.btn-del:hover {
    background: #555;
}

/* active (클릭) */
.btn-del:active {
    transform: scale(0.97);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.25);
}
  
/* 모달 및 플로팅 버튼 */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}
  
.modal {
    background: #ffffff;
    width: 360px;
    max-width: calc(100vw - 32px);
    padding: 24px 22px 20px;
    border-radius: 5px;
  
    box-shadow:
      0 10px 30px rgba(0, 0, 0, 0.15),
      0 1px 3px rgba(0, 0, 0, 0.1);
  
    animation: modalPop 0.2s ease-out;
}
/* 타이틀 */
.modal h2 {
    margin: 0 0 18px;
    font-size: 20px;
    font-weight: 700;
    color: #222;
}
/* 입력 필드 */
.modal input {
    width: 100%;
    box-sizing: border-box;
  
    padding: 12px 14px;
    margin-bottom: 10px;
  
    border-radius: 5px;
    border: 1px solid #ddd;
  
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
  
.modal input:focus {
    border-color: #333;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.08);
}
/* 버튼 영역 */
.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
}
/* 버튼 스타일 */
#modalSave,
#modalCancel {
  flex: 1;
  padding: 12px 0;
  border-radius: 5px;
  border: none;

  font-size: 14px;
  font-weight: 600;
  cursor: pointer;

  transition: transform 0.08s ease 0.15s ease;
}
/* 저장 버튼 */
#modalSave {
    background: #111;
    color: #fff;
}
  
#modalSave:hover {
    background: #000;
}
  
#modalSave:active {
    transform: scale(0.97);
}
/* 취소 버튼 */
#modalCancel {
    background: #f1f1f1;
    color: #333;
}
  
#modalCancel:hover {
    background: #e5e5e5;
}
  
#modalCancel:active {
    transform: scale(0.97);
}

/* 폼 */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
  
.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: #555;
}
  
/* 모달 팝업 애니메이션 */
@keyframes modalPop {
    from {
      opacity: 0.5;
      transform: scale(1) translateY(3px);
    }
    to {
      opacity: 1;
      transform: scale(1) translateY(0);
    }
}

.hidden {
    display: none;
}

#modalOverlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.3); z-index: 100; justify-content: center; align-items: center;
    backdrop-filter: blur(3px);
}

.modal-box { background: #fff; width: 90%; max-width: 400px; padding: 25px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,0.15); }
.input-group { margin-bottom: 15px; }
.input-group label { display: block; font-size: 0.75rem; font-weight: 700; margin-bottom: 5px; color: #555; }
.input-group input { width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 5px; font-size: 0.9rem; }

.img-helper-btns { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap;}
.img-helper-btns button { font-size: 0.7rem; padding: 5px 8px; border: 1px solid #eee; background: #f9f9f9; cursor: pointer; border-radius: 15px; }
.img-helper-btns button:hover { background: #eee; border-color: #ccc; }

.modal-footer { margin-top: 20px; display: flex; gap: 10px; }
.btn-primary { flex: 1; background: #222; color: #fff; padding: 10px; border: none; cursor: pointer; font-weight: 700; border-radius: 5px; font-size: 0.9rem;}
.btn-secondary { flex: 1; background: #fff; color: #222; padding: 10px; border: 1px solid #ddd; cursor: pointer; border-radius: 5px; font-size: 0.9rem;}

.fab {
    position: fixed; bottom: 25px; right: 25px; width: 45px; height: 45px; background: #222; color: #fff;
    border-radius: 50%; border: none; font-size: 1.5rem; cursor: pointer; box-shadow: 0 5px 15px rgba(0,0,0,0.15);
    display: none; z-index: 50; transition: transform 0.2s;
}
.fab:hover { transform: scale(1.1); }
body.admin-mode .fab { display: block; }

@media (max-width: 768px) {
    .category-row, .category-row:nth-child(even) { flex-direction: column; min-height: auto; }
    .row-image-box { height: 140px; flex: none; } 
    .drawer-header { min-height: 60px; height: auto; } /* 모바일은 헤더 높이 고정 */
}