/* ─── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; overflow: hidden; }
body {
  background: #0d1117;
  color: #e6edf3;
  font-family: 'Pretendard', sans-serif;
  height: 100%;
  overflow: hidden;
  font-size: 14px;
}
a { text-decoration: none; color: inherit; }


/* ─── App Layout ─────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 0;
  margin-top: 46px;
  height: calc(100vh - 46px);
  height: calc(100dvh - 46px);
  overflow: hidden;
}

.preview-area {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: hidden;
  gap: 12px;
  background: #0d1117;
}

.controls {
  grid-column: 1;
  grid-row: 1;
  background: #161b22;
  border-right: 1px solid #30363d;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.controls::-webkit-scrollbar { width: 4px; }
.controls::-webkit-scrollbar-track { background: transparent; }
.controls::-webkit-scrollbar-thumb { background: #30363d; border-radius: 2px; }

/* mobile-controls hidden on desktop */
.mobile-controls { display: none; }

/* ─── Canvas ─────────────────────────────────────────────── */
.canvas-wrap {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
#preview-canvas {
  display: block;
  border-radius: 6px;
  box-shadow: 0 0 0 1px #30363d, 0 8px 32px rgba(0,0,0,0.5);
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.attribution { font-size: 11px; color: #444d56; }
.attribution a { color: #444d56; transition: color 0.2s; }
.attribution a:hover { color: #8b949e; }

/* ─── Controls common ────────────────────────────────────── */
.section-label {
  font-size: 11px;
  font-weight: 500;
  color: #8b949e;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.basic-section { display: flex; flex-direction: column; gap: 16px; }
.ctrl-block { }
.ctrl-divider { height: 1px; background: #30363d; flex-shrink: 0; }

/* ─── Accordion ──────────────────────────────────────────── */
.accordion-header {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 0;
  color: inherit;
}
.accordion-label {
  font-size: 11px;
  font-weight: 500;
  color: #8b949e;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.accordion-current {
  margin-left: auto;
  color: #e05555;
  font-size: 13px;
  font-weight: 600;
}
.accordion-arrow {
  color: #8b949e;
  font-size: 16px;
  display: inline-block;
  transition: transform 0.2s;
  line-height: 1;
  flex-shrink: 0;
}
.accordion-block.open .accordion-arrow { transform: rotate(90deg); }
.accordion-body { display: none; padding-top: 10px; }
.accordion-block.open .accordion-body { display: block; }

/* ─── Team Grid ──────────────────────────────────────────── */
.team-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.team-btn {
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #8b949e;
  font-family: 'Pretendard', sans-serif;
  font-size: 11px;
  padding: 8px 4px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
  line-height: 1.3;
}
.team-btn:hover { border-color: #8b949e; color: #e6edf3; }
.team-btn.active { background: rgba(224,85,85,0.15); border-color: #e05555; color: #e05555; }

/* ─── Month Tabs ─────────────────────────────────────────── */
.month-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.month-btn {
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #8b949e;
  font-family: 'Pretendard', sans-serif;
  font-size: 12px;
  padding: 7px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}
.month-btn:hover { border-color: #8b949e; color: #e6edf3; }
.month-btn.active { background: rgba(224,85,85,0.15); border-color: #e05555; color: #e05555; }

/* ─── Toggle Row ─────────────────────────────────────────── */
.toggle-row { display: flex; gap: 6px; }
.toggle-btn {
  flex: 1;
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #8b949e;
  font-family: 'Pretendard', sans-serif;
  font-size: 12px;
  padding: 8px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}
.toggle-btn:hover { border-color: #8b949e; color: #e6edf3; }
.toggle-btn.active { background: rgba(224,85,85,0.15); border-color: #e05555; color: #e05555; }

/* ─── Background Filter Tabs ─────────────────────────────── */
.bg-filter-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 8px;
  scrollbar-width: none;
}
.bg-filter-tabs::-webkit-scrollbar { display: none; }
.bg-filter-btn {
  flex: 0 0 auto;
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 4px;
  color: #8b949e;
  font-family: 'Pretendard', sans-serif;
  font-size: 11px;
  padding: 4px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.bg-filter-btn:hover { border-color: #8b949e; color: #e6edf3; }
.bg-filter-btn.active { background: rgba(224,85,85,0.15); border-color: #e05555; color: #e05555; }

/* ─── Background Slider ──────────────────────────────────── */
.bg-slider {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 4px;
  margin-bottom: 8px;
  min-height: 56px;
}
.bg-slider::-webkit-scrollbar { display: none; }
.bg-slider.dragging, .bg-slider.dragging * { user-select: none; pointer-events: none; }
.bg-slider-wrap { position: relative; }
.bg-scroll-hint {
  text-align: center;
  font-size: 10px;
  color: #4a5568;
  margin-top: 2px;
  margin-bottom: 8px;
  letter-spacing: 0.05em;
  user-select: none;
}
.bg-thumb {
  flex: 0 0 68px;
  display: flex;
  flex-direction: column;
  border: 2px solid #30363d;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  background: #21262d;
  transition: border-color 0.15s;
  scroll-snap-align: start;
}
.bg-thumb img { width: 100%; aspect-ratio: 9/16; object-fit: cover; display: block; }
.bg-thumb__solid-preview {
  width: 100%;
  aspect-ratio: 9/16;
  background: linear-gradient(135deg, #fff 0%, #e8e8e8 50%, #ccc 100%);
  display: block;
}
.bg-slider--landscape .bg-thumb__solid-preview { aspect-ratio: 16/9; }
/* PC 비율일 때 썸네일 가로형으로 전환 */
.bg-slider--landscape .bg-thumb { flex: 0 0 96px; }
.bg-slider--landscape .bg-thumb img { aspect-ratio: 16/9; }
.bg-thumb__name {
  display: block;
  padding: 3px 4px;
  font-family: 'Pretendard', sans-serif;
  font-size: 9px;
  color: #8b949e;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-top: 1px solid #30363d;
  background: #161b22;
  transition: color 0.15s;
}
.bg-thumb:hover { border-color: #8b949e; }
.bg-thumb:hover .bg-thumb__name { color: #e6edf3; }
.bg-thumb.active { border-color: #e05555; }
.bg-thumb.active .bg-thumb__name { color: #e05555; }
.bg-empty { font-size: 11px; color: #8b949e; padding: 6px 0; line-height: 1.7; }
.upload-btn {
  display: block;
  width: 100%;
  background: #21262d;
  border: 1px dashed #30363d;
  border-radius: 6px;
  color: #8b949e;
  font-family: 'Pretendard', sans-serif;
  font-size: 12px;
  padding: 10px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}
.upload-btn:hover { border-color: #8b949e; color: #e6edf3; }
#bg-upload, #m-bg-upload { display: none; }

/* ─── Advanced Toggle Button ─────────────────────────────── */
.advanced-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #8b949e;
  font-family: 'Pretendard', sans-serif;
  font-size: 12px;
  font-weight: 500;
  padding: 10px 14px;
  cursor: pointer;
  transition: all 0.15s;
}
.advanced-toggle-btn:hover { border-color: #8b949e; color: #e6edf3; }
.adv-arrow { display: inline-block; transition: transform 0.22s; }
.advanced-toggle-btn.open .adv-arrow { transform: rotate(90deg); }

/* ─── Mode Tabs (Desktop) ────────────────────────────────── */
.mode-tabs {
  display: flex;
  border-bottom: 1px solid #30363d;
  margin-bottom: 16px;
  flex-shrink: 0;
}
.mode-tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: #8b949e;
  font-family: 'Pretendard', sans-serif;
  font-size: 13px;
  font-weight: 600;
  padding: 12px 0;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: -1px;
}
.mode-tab:hover { color: #e6edf3; }
.mode-tab.active { color: #e05555; border-bottom-color: #e05555; }

/* ─── Mode Show/Hide ─────────────────────────────────────── */
.app.mode-pc .ratio-group--mo { display: none; }
.app.mode-mo .ratio-group--pc { display: none; }
/* .app.mode-pc .calpos-ctrl — 슬라이더 자유배치로 변경, PC에서도 표시 */
.app.mode-mo .pc-only { display: none; }

/* ─── PC 배경색 피커 ─────────────────────────────────────── */
.pc-color-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.pc-bg-color-input {
  width: 36px;
  height: 36px;
  border: 1px solid #30363d;
  border-radius: 8px;
  cursor: pointer;
  background: none;
  padding: 2px;
}
.pc-color-label {
  font-size: 12px;
  color: #8b949e;
  font-family: 'Pretendard', monospace;
  letter-spacing: 0.05em;
}

/* ─── Advanced Panel ─────────────────────────────────────── */
.advanced-panel { display: none; flex-direction: column; gap: 0; }
.advanced-panel.open { display: flex; }

.adv-tabs { display: flex; border-bottom: 1px solid #30363d; }
.adv-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: #8b949e;
  font-family: 'Pretendard', sans-serif;
  font-size: 12px;
  font-weight: 500;
  padding: 10px 14px;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: -1px;
}
.adv-tab:hover { color: #e6edf3; }
.adv-tab.active { color: #e05555; border-bottom-color: #e05555; }
.adv-pane { display: none; flex-direction: column; gap: 16px; padding: 16px 0 4px; }
.adv-pane.active { display: flex; }

/* ─── Download Button ────────────────────────────────────── */
.download-btn {
  width: 100%;
  background: #e05555;
  border: none;
  border-radius: 8px;
  color: #fff;
  font-family: 'Pretendard', sans-serif;
  font-size: 13px;
  font-weight: 700;
  padding: 14px;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: background 0.2s, transform 0.1s;
}
.download-btn:hover { background: #c94444; }
.download-btn:active { transform: scale(0.98); }
.download-btn--secondary {
  background: #21262d;
  border: 1px solid #30363d;
  margin-top: 6px;
}
.download-btn--secondary:hover { background: #30363d; }

/* ─── Mobile ─────────────────────────────────────────────── */
@media (max-width: 900px) {

  /* app: flex column */
  .app {
    display: flex;
    flex-direction: column;
    margin-top: 46px;
    height: calc(100vh - 46px);
    height: calc(100dvh - 46px);
    overflow: hidden;
  }

  /* preview: fills remaining space */
  .preview-area {
    flex: 1;
    min-height: 0;
    padding: 10px;
    gap: 6px;
  }

  /* desktop sidebar: hidden */
  .controls { display: none; }

  /* ── 모바일/PC 모드 선택 바 ── */
  .m-mode-bar {
    display: flex;
    border-bottom: 1px solid #30363d;
    flex-shrink: 0;
  }
  .m-mode-btn {
    flex: 1;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: #8b949e;
    font-family: 'Pretendard', sans-serif;
    font-size: 13px;
    font-weight: 600;
    padding: 10px 0;
    cursor: pointer;
    transition: all 0.15s;
    margin-bottom: -1px;
  }
  .m-mode-btn.active { color: #e05555; border-bottom-color: #e05555; }

  /* ── 모바일 컨트롤 (피크루 스타일) ── */
  .mobile-controls {
    display: flex;
    flex-direction: column;
    background: #161b22;
    border-top: 1px solid #30363d;
    flex-shrink: 0;
  }

  /* 탭 네비게이션 */
  .m-tab-nav {
    display: flex;
    border-bottom: 1px solid #30363d;
    flex-shrink: 0;
  }
  .m-tab {
    flex: 1;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: #8b949e;
    font-family: 'Pretendard', sans-serif;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 4px 6px;
    transition: color 0.15s;
    margin-bottom: -1px;
  }
  .m-tab.active { color: #e05555; border-bottom-color: #e05555; }
  .m-tab-label { font-size: 12px; font-weight: 500; line-height: 1; }
  .m-tab-badge {
    font-size: 10px;
    font-weight: 700;
    color: #e05555;
    background: rgba(224,85,85,0.12);
    border-radius: 3px;
    padding: 1px 5px;
    line-height: 1.4;
  }

  /* 탭 패널 영역 */
  .m-panels {
    height: 210px;
    overflow-y: auto;
    flex-shrink: 0;
  }
  .m-panels::-webkit-scrollbar { width: 3px; }
  .m-panels::-webkit-scrollbar-thumb { background: #30363d; border-radius: 2px; }

  .m-panel { display: none; padding: 10px 16px 8px; }
  .m-panel.active { display: block; }
  .m-panel .ctrl-block { margin-bottom: 10px; }
  .m-panel .ctrl-block:last-child { margin-bottom: 0; }

  /* 다운로드 바 (항상 노출) */
  .m-download-bar {
    padding: 10px 16px 12px;
    border-top: 1px solid #30363d;
    flex-shrink: 0;
    display: flex;
    gap: 8px;
  }
  .m-download-bar .download-btn { margin-top: 0; padding: 11px; flex: 1; }
  .m-download-bar .download-btn--secondary { margin-top: 0; }
}
