:root{
  --maxw: 500px;
  --gap: 1px;
  --radius: 12px;
  --header-h: 126px;    /* JS가 갱신 */
  --header-pad: var(--header-h);  /* 헤더가 보일 땐 헤더 높이, 숨길 땐 0으로 */
  --footer-h: 0px;            /* 광고 높이 - JS가 갱신 */
  color-scheme: light;         /* CSS 쪽은 'light only' 대신 'light' */
}

html { -webkit-text-size-adjust: 100%; }

/* 기본 세팅 */
html, body{
  height: 100dvh;
  margin: 0;
  padding: 0;
  background: var(--gray-0) !important;
  color: var(--gray-90);
  overflow: hidden;
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
  display: flex;
  flex-direction: column;
}

html::-webkit-scrollbar,
html *::-webkit-scrollbar,
body::-webkit-scrollbar,
body *::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  background: transparent !important;
  -webkit-appearance: none !important;
}

html::-webkit-scrollbar-track,
html *::-webkit-scrollbar-track,
body::-webkit-scrollbar-track,
body *::-webkit-scrollbar-track {
  display: none !important;
  background: transparent !important;
}

html::-webkit-scrollbar-thumb,
html *::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb,
body *::-webkit-scrollbar-thumb {
  display: none !important;
  background: transparent !important;
}

/* index.css의 .app 스타일 오버라이드 */
.app {
  background-color: unset !important;
  padding: unset !important;
  padding-bottom: 0 !important;
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
  display: flex !important;
  flex-direction: column !important;
  flex: 1;
  min-height: 0;
  overflow: hidden !important;
  width: 100%;
  max-width: var(--maxw);
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}

.app::-webkit-scrollbar,
.app *::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  background: transparent !important;
  -webkit-appearance: none !important;
}


.header-topbar, .actions{
  width: 100%;
}

/* 헤더를 고정 배치 */
.header {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  width: 100%;
  max-width: var(--maxw);
  z-index: 50;
  /* 이 줄 남겨두세요: 배경/보더 등 기존 스타일 그대로 */
  margin: 0 !important;
  padding: 0 !important;
  background: var(--gray-0);
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: flex-start !important;
  border-left: 1px solid var(--gray-20);
  border-right: 1px solid var(--gray-20);
  border-top: none;
  border-bottom: none;
  overflow: hidden;
  transition: transform 0.25s ease-out;
  box-sizing: border-box;
  /* 떨림 방지 */
  will-change: transform;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* 숨김 상태: 위로 밀어 올림(레이아웃은 고정이라 겹침 X) */
.header.is-hidden {
  transform: translateX(-50%) translateY(calc(-1 * var(--header-h)));
  pointer-events: none;
  transition: transform 0.25s ease-out;
}

/* 헤더가 숨겨졌을 때 패딩 0으로 (공백 제거) */
body.header-hidden {
  --header-pad: 0px;
}

.header.is-hidden .header-topbar,
.header.is-hidden .actions {
  padding: 0 !important;
  margin: 0 !important;
  opacity: 0;
  transition: padding 0.25s cubic-bezier(0.4, 0, 0.2, 1), 
              margin 0.25s cubic-bezier(0.4, 0, 0.2, 1), 
              opacity 0.2s ease-out;
}

.header .actions{
  padding: 0px 16px 18px 16px !important;
  margin-top: 0;
  padding-top: 0px !important;
  transition: padding 0.25s cubic-bezier(0.4, 0, 0.2, 1), 
              margin 0.25s cubic-bezier(0.4, 0, 0.2, 1), 
              opacity 0.2s ease-in;
}

.header-topbar {
  position: relative;
  margin: 0 !important;
  padding: 18px 16px !important;
  width: 100% !important;
  transition: padding 0.25s cubic-bezier(0.4, 0, 0.2, 1), 
              margin 0.25s cubic-bezier(0.4, 0, 0.2, 1), 
              opacity 0.2s ease-in;
}

.actions {
  margin: 0 !important;
  width: 100% !important;
}


.actions .btn{
  flex: 1;
  justify-content: center;
  display: flex;
  align-items: center;
  border: none;
}

/* disabled 버튼의 opacity 제거 - 모든 버튼에 적용 */
.actions .btn:disabled,
.btn:disabled,
button:disabled {
  opacity: 1 !important;
}

.btn .icon{
  /* SVG 이미지의 흰색을 어두운 회색으로 변경 */
  filter: brightness(0) saturate(100%) invert(14%) sepia(7%) saturate(200%) hue-rotate(175deg) brightness(95%) contrast(88%);
}
.btn--fill--teriGray .icon,
.btn--fill--teryGray .icon {
  /* gray-80 (#383E4A)에 맞춘 필터 */
  filter: brightness(0) saturate(100%) invert(18%) sepia(4%) saturate(800%) hue-rotate(175deg) brightness(97%) contrast(91%);
}
.btn--fill--teriGray:disabled,
.btn--fill--teryGray:disabled {
  /* disabled 버튼의 opacity 제거 */
  opacity: 1 !important;
}
.btn--fill--teriGray:disabled .icon,
.btn--fill--teryGray:disabled .icon {
  /* gray-40 (#C6C8CD)에 맞춘 필터 */
  filter: brightness(0) saturate(100%) invert(72%) sepia(2%) saturate(500%) hue-rotate(175deg) brightness(98%) contrast(85%);
}
.btn--fill--priBlack .icon {
  /* 흰색 아이콘 (변경 없음) */
  filter: none;
}

/* 앱(스크롤 컨테이너) */
.contentsArea{
  border-left: 1px solid var(--gray-20);
  border-right: 1px solid var(--gray-20);
  box-sizing: border-box;
  width: 100%;
  max-width: var(--maxw);
  margin-left: auto;
  margin-right: auto;
  flex: 1;
  min-height: 0;
  min-width: 0;
  padding: 0 !important;
  padding-top: var(--header-pad);  /* ⬅️ 추가 */
  padding-bottom: var(--footer-h);

  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  scrollbar-gutter: auto !important;
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
  touch-action: pan-y;
  -webkit-touch-callout: none;
}

/* section 요소 기본 margin/padding 제거 */
.contentsArea > section {
  margin: 0 !important;
  padding: 128px 0 0 0 !important;
}

/* 모든 브라우저에서 스크롤바 숨김 */
.contentsArea::-webkit-scrollbar,
.contentsArea *::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  background: transparent !important;
  -webkit-appearance: none !important;
}

.contentsArea::-webkit-scrollbar-track,
.contentsArea *::-webkit-scrollbar-track {
  display: none !important;
  background: transparent !important;
  -webkit-appearance: none !important;
}

.contentsArea::-webkit-scrollbar-thumb,
.contentsArea *::-webkit-scrollbar-thumb {
  display: none !important;
  background: transparent !important;
  -webkit-appearance: none !important;
}

.contentsArea::-webkit-scrollbar-corner {
  display: none !important;
  background: transparent !important;
}

@supports not (height: 100dvh){
  html, body {
    height: 100vh;
  }
}

.empty-mode .contentsArea{
  min-height: 0 !important;
  overflow: auto !important;
  padding-bottom: var(--footer-h) !important;
}

.title{
  flex: 1;
  font-weight: 700;
  font-size: 22px;
  line-height: 24px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--gray-90);
}

body.lang-kr .title.h2--B {
  font-weight: 900;
}
.actions{
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 이미지 그리드 */
.grid{
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap);
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
}
#grid .cell,
.grid .cell{ 
  position:relative !important; 
  width:100% !important; 
  background:var(--gray-0) !important; 
  overflow: hidden !important;
  aspect-ratio: 3 / 4 !important;
}
.cell::before{ 
  content:""; 
  display:block; 
  padding-top: 133.333%;
  width: 100%;
}
@supports not (aspect-ratio: 3 / 4) {
  .cell::before {
    padding-top: 133.333%;
  }
}
.cell img{
  position:absolute; 
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width:100%; 
  height:100%;
  object-fit:cover; 
  border-radius:2px;
}
.cell.dragging{
  opacity:.6;
  outline: 2px dashed var(--gray-60);
}

.grid, .cell { touch-action: pan-y; } 


.grid.empty{
  display:flex !important;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  min-height: 0 !important;
  gap:8px;
  background:transparent;
  overflow:hidden;
}
.grid.empty > *{ display:none !important; }

.empty-guide{
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  padding: 0 24px;
  text-align: center;
  color: #555;
}
.empty-guide.show { 
  display: block !important; 
}
.empty-guide .guide-inner {
  width: 100%;
  gap: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.empty-guide .guide-content {
  display: none;
  width: 100%;
}

.empty-guide .guide-content.kr {
  display: block;
}

body.lang-en .empty-guide .guide-content.kr {
  display: none;
}

body.lang-en .empty-guide .guide-content.en {
  display: block;
}

.empty-guide .guide-divider {
  display: none;
  width: 300px;
  height: 1px;
  background-color: var(--gray-20);
  margin: 14px 0;
}

/* 한국어: 첫 번째 guide-content 다음의 divider 표시 */
.empty-guide .guide-content.kr:first-of-type + .guide-divider {
  display: block;
}

/* 영어: 첫 번째 guide-content 다음의 divider 표시 */
body.lang-en .empty-guide .guide-content.en:first-of-type + .guide-divider {
  display: block;
}

/* 한국어일 때 영어 divider 숨김 */
.empty-guide .guide-content.en:first-of-type + .guide-divider {
  display: none;
}

/* 영어일 때 한국어 divider 숨김 */
body.lang-en .empty-guide .guide-content.kr:first-of-type + .guide-divider {
  display: none;
}

.empty-guide .guide-text {
  width: 100%;
  text-align: center;
}

.empty-guide .guide-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  min-width: 24px;
  border-radius: 50%;
  background-color: var(--gray-50);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  margin-bottom: 8px;
}

.empty-guide .title{
  font-size: 18px;
  line-height: 24px;
  color: #5D626D;
  font-weight: 500;
  margin-bottom: 8px;
}

.empty-guide .desc{
  font-size: 15px;
  color: #7F838C;
  font-weight: 400;
  line-height: 22px;
  margin: 0;
}

.handle{
  position:absolute; right:6px; bottom:6px;
  width:36px; height:36px; border:0; border-radius:10px;
  background: rgba(0,0,0,.45); color:#fff; font-size:18px; font-weight:700;
  line-height:36px; text-align:center; cursor:grab;
  -webkit-tap-highlight-color: transparent;
  display:none; touch-action:none;
}
.handle:active{ cursor:grabbing; background:rgba(0,0,0,.55); }
.editing .handle{ display:block; }

.ghost{
  position:fixed; pointer-events:none; z-index:1000;
  width:120px; height:160px; transform:translate(-50%, -50%);
  border-radius:4px; box-shadow:0 8px 24px rgba(0,0,0,.25);
  overflow:hidden; opacity:0; transition:opacity .15s ease;
}
.ghost.show{ opacity:1; }
.ghost img{ width:100%; height:100%; object-fit:cover; }

/* Footer 스타일 */
.footer {
  width: 100%;
  max-width: 500px;
  height: 0;
  min-height: 0;
  margin-left: auto;
  margin-right: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-10);
  border-left: 1px solid var(--gray-20);
  border-right: 1px solid var(--gray-20);
  padding: 0;
  margin-top: 0;
  margin-bottom: 0;
  flex-shrink: 0;
  overflow: hidden;
}

.footer .adsbygoogle {
  display: block;
  margin: 0 auto;
  width: 100%;
  max-width: 430px;
  height: 80px !important;
  max-height: 80px !important;
  overflow: hidden;
}

/* 모달 스타일은 design-system/components/modal.css 사용 */

/* 선택/드래그 차단 */
html, body, .contentsArea, .header, .title, .actions, .grid, .cell,
button, .btn, img, canvas, svg{
  -webkit-user-select:none; -moz-user-select:none; -ms-user-select:none; user-select:none;
  -webkit-touch-callout:none;
}
img, svg, canvas{ -webkit-user-drag:none; }

/* 다크모드 강제 무시 */
@media (prefers-color-scheme: dark){
  html, body{ background:#fff !important; color:#000 !important; }
}

