/* ============================================================
   이태원회중 ITW Mobile Layout CSS v2.1.0
   기존 itw_mobile 레이아웃 교체용
   ============================================================ */

/* ── CSS 변수 ── */
:root {
  --bg:          #f5f4f0;
  --surface:     #ffffff;
  --border:      #e8e6e0;
  --text:        #1a1916;
  --text-muted:  #7a7872;
  --accent:      #1a3a5c;
  --accent-bg:   #eef3f9;
  --green:       #1e7e34;
  --green-bg:    #eafaf1;
  --orange:      #d35400;
  --orange-bg:   #fef5ec;
  --red:         #c0392b;
  --red-bg:      #fdf0ef;

  /* 구역 컬러 */
  --c-yongsan:   #c0392b;
  --c-itw2:      #d35400;
  --c-itw1:      #7d6608;
  --c-bogwang:   #27ae60;
  --c-dongbing:  #2471a3;
  --c-hannam-s:  #6c3483;
  --c-hannam-n:  #9b59b6;
  --c-etc:       #1a5276;
  --c-redev:     #616a6b;

  /* 타이포 */
  --font-main: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;

  /* 탭바 높이 */
  --tabbar-h: 64px;
  --header-h: 52px;
}

/* ── 리셋 ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── 전역 ── */
html { -webkit-text-size-adjust: 100%; }
body.itw-mobile {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-main);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100dvh;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
img { max-width: 100%; height: auto; }

/* ── 공지 배너 ── */
.itw-notice-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 9px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}
.itw-notice-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-bg);
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}
.itw-notice-scroll {
  overflow: hidden;
  flex: 1;
  mask-image: linear-gradient(to right, black 80%, transparent 100%);
  -webkit-mask-image: linear-gradient(to right, black 80%, transparent 100%);
}
.itw-notice-items {
  display: flex;
  gap: 24px;
  animation: itwMarquee 22s linear infinite;
  width: max-content;
}
.itw-notice-items a {
  font-size: 13px;
  white-space: nowrap;
  opacity: 0.8;
}
.itw-notice-items a:hover { opacity: 1; }
@keyframes itwMarquee {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}
.itw-notice-more {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
  white-space: nowrap;
}

/* ── 헤더 ── */
.itw-hd {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.itw-hd-inner { min-height: var(--header-h); }
.itw-hd-default {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: var(--header-h);
}
.itw-hd-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.itw-hd-title a { color: var(--text); }
.itw-hd-actions { display: flex; gap: 8px; }
.itw-hd-btn {
  font-size: 12px;
  color: var(--accent);
  padding: 5px 10px;
  border-radius: 7px;
  background: var(--accent-bg);
  border: none;
  cursor: pointer;
  font-weight: 500;
  white-space: nowrap;
}

/* ── 메인 콘텐츠 ── */
.itw-main {
  min-height: calc(100dvh - var(--header-h) - var(--tabbar-h));
}

/* ── 하단 탭바 ── */
.itw-tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--tabbar-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.itw-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 500;
  padding-top: 6px;
  transition: color .15s;
  position: relative;
  text-decoration: none;
}
.itw-tab:active { opacity: 0.7; }
.itw-tab.active { color: var(--accent); }
.itw-tab svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.8px;
}
.itw-tab-badge {
  position: absolute;
  top: 6px; right: calc(50% - 16px);
  background: var(--red);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ══════════════════════════════════════════
   공통 UI 컴포넌트
══════════════════════════════════════════ */

/* ── 섹션 헤더 ── */
.itw-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 8px;
}
.itw-section-dot {
  width: 10px; height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}
.itw-section-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.2px;
}
.itw-section-count {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.itw-section-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── 카드 그리드 (구역카드) ── */
.itw-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  padding: 0 12px 12px;
}
.itw-card-item {
  background: var(--surface);
  border-radius: 10px;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  border: 1.5px solid var(--border);
  text-decoration: none;
  transition: transform .12s, box-shadow .12s, border-color .12s;
  position: relative;
  overflow: hidden;
}
.itw-card-item::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--card-color, var(--border));
  border-radius: 10px 10px 0 0;
}
.itw-card-item:active {
  transform: scale(0.96);
}
.itw-card-item:hover {
  border-color: var(--card-color, var(--border));
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
}
.itw-card-num {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  line-height: 1;
}
/* 최근 수정 표시 */
.itw-card-item.recent::after {
  content: '';
  position: absolute;
  top: 7px; right: 7px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
}

/* ── 검색 ── */
.itw-search-wrap {
  padding: 10px 12px 4px;
  position: relative;
}
.itw-search-wrap::before {
  content: '';
  position: absolute;
  left: 24px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a7872' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat center;
  background-size: contain;
  pointer-events: none;
}
.itw-search-input {
  width: 100%;
  height: 38px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 0 12px 0 36px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  outline: none;
  color: var(--text);
  transition: border-color .15s;
  -webkit-appearance: none;
}
.itw-search-input:focus { border-color: var(--accent); }

/* ── 지역 필터 탭 ── */
.itw-region-tabs {
  background: var(--surface);
  padding: 0 12px;
  overflow-x: auto;
  display: flex;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.itw-region-tabs::-webkit-scrollbar { display: none; }
.itw-region-tab {
  flex-shrink: 0;
  padding: 11px 12px 9px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: all .15s;
  background: none;
  border-top: none; border-left: none; border-right: none;
  font-family: inherit;
}
.itw-region-tab.active {
  color: var(--text);
  font-weight: 700;
  border-bottom-color: currentColor;
}

/* ── 통계 칩 ── */
.itw-stats-row {
  display: flex;
  gap: 8px;
  padding: 10px 12px 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.itw-stats-row::-webkit-scrollbar { display: none; }
.itw-stat-chip {
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.itw-stat-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.itw-stat-label { color: var(--text-muted); }
.itw-stat-num {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13px;
}

/* ── 공지 목록 ── */
.itw-notice-list {
  margin: 10px 12px 0;
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
}
.itw-notice-item {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .1s;
}
.itw-notice-item:last-child { border-bottom: none; }
.itw-notice-item:active { background: var(--bg); }
.itw-notice-cat-bar {
  width: 4px; align-self: stretch; flex-shrink: 0;
}
.itw-notice-body { flex: 1; padding: 12px 14px; }
.itw-notice-badge {
  display: inline-block;
  font-size: 10.5px; font-weight: 600;
  padding: 2px 8px; border-radius: 10px;
  margin-bottom: 5px;
}
.itw-notice-title {
  font-size: 14px; font-weight: 500; line-height: 1.4;
  margin-bottom: 3px;
}
.itw-notice-title.unread { font-weight: 700; }
.itw-notice-meta { font-size: 11.5px; color: var(--text-muted); }

/* ── 공통 하단 모달 ── */
.itw-modal-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,0.42);
  align-items: flex-end;
}
.itw-modal-overlay.open { display: flex; }
.itw-modal {
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 20px;
  width: 100%;
  max-height: 90dvh;
  overflow-y: auto;
  animation: itwSlideUp .22s ease;
}
@keyframes itwSlideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.itw-modal-handle {
  width: 36px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 16px;
}
.itw-modal-title {
  font-size: 17px; font-weight: 700; margin-bottom: 14px;
}

/* ── 폼 공통 ── */
.itw-form-field { margin-bottom: 14px; }
.itw-form-label {
  font-size: 12px; color: var(--text-muted);
  font-weight: 500; margin-bottom: 5px; display: block;
}
.itw-form-input,
.itw-form-select,
.itw-form-textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s;
  -webkit-appearance: none;
}
.itw-form-input:focus,
.itw-form-select:focus,
.itw-form-textarea:focus { border-color: var(--accent); }
.itw-form-textarea { resize: none; min-height: 80px; }
.itw-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ── 버튼 ── */
.itw-btn-primary {
  width: 100%; padding: 14px;
  background: var(--accent); color: #fff;
  border: none; border-radius: 10px;
  font-size: 15px; font-weight: 700;
  font-family: inherit; cursor: pointer;
  transition: opacity .15s;
}
.itw-btn-primary:active { opacity: 0.85; }
.itw-btn-ghost {
  width: 100%; padding: 12px;
  background: none; color: var(--text-muted);
  border: none; font-size: 14px;
  font-family: inherit; cursor: pointer;
}
.itw-btn-danger {
  width: 100%; padding: 14px;
  background: var(--surface); color: var(--red);
  border: 1.5px solid var(--red-bg);
  border-radius: 12px; font-size: 14px; font-weight: 600;
  font-family: inherit; cursor: pointer;
  transition: background .15s;
}
.itw-btn-danger:active { background: var(--red-bg); }

/* ── 토글 스위치 ── */
.itw-toggle {
  width: 44px; height: 26px; border-radius: 13px;
  background: var(--border);
  position: relative; cursor: pointer;
  border: none; -webkit-appearance: none;
  transition: background .2s;
  flex-shrink: 0;
}
.itw-toggle::after {
  content: '';
  position: absolute;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; top: 3px; left: 3px;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.itw-toggle.on { background: var(--accent); }
.itw-toggle.on::after { transform: translateX(18px); }

/* ── 프로그레스 바 ── */
.itw-progress-bg {
  height: 6px; background: var(--border);
  border-radius: 3px; overflow: hidden;
}
.itw-progress-fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--green), #52be80);
  transition: width .5s ease;
}

/* ── 유틸리티 ── */
.itw-surface {
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
}
.itw-divider {
  height: 1px; background: var(--border);
  margin: 0;
}
.itw-text-mono {
  font-family: var(--font-mono);
}
.itw-badge {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 10px;
}

/* ── 로딩 스피너 ── */
.itw-spinner {
  width: 24px; height: 24px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: itwSpin .7s linear infinite;
  margin: 20px auto;
}
@keyframes itwSpin {
  to { transform: rotate(360deg); }
}

/* ── 빈 상태 ── */
.itw-empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.itw-empty-icon {
  font-size: 36px;
  margin-bottom: 12px;
  display: block;
}

/* ── 데스크톱 대응 ── */
@media (min-width: 640px) {
  body.itw-mobile {
    max-width: 480px;
    margin: 0 auto;
    box-shadow: 0 0 40px rgba(0,0,0,.1);
    min-height: 100dvh;
  }
  .itw-tabbar {
    max-width: 480px;
    left: 50%;
    transform: translateX(-50%);
  }
}

/* ── 기존 스킨 호환성 (sketchbook5_itw 잔재 숨김) ── */
.btm_mn { border-top: none !important; }
.ft { display: none !important; }
.itw-ft { display: none !important; }
.hd_notice_before + .hd_notice { display: none; }

/* ── 다크모드 준비 ── */
@media (prefers-color-scheme: dark) {
  /* 추후 적용 */
}
