/* 하나반 반려나무 관리 — 숲·나무 테마 (임팩트 디자인 시스템 기반) */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --forest-deep: #1e4d2b;   /* 짙은 숲 */
  --forest:      #2e6b3e;   /* 숲 초록 */
  --leaf:        #57a05e;   /* 잎 초록 */
  --leaf-light:  #a8cf9a;
  --wood:        #8a5a33;   /* 나무 줄기 */
  --wood-dark:   #5f3d1f;
  --wood-light:  #c9a876;
  --soil:        #cbbfa3;   /* 흙 */
  --grass-1:     #dcecc9;
  --grass-2:     #c8e2b4;
  --adopted:     #e0115f;   /* 입양 완료 — 선명한 로즈핑크 하트 */
  --adopted-2:   #ff5c8d;
}

body {
  font-family: var(--im-font);
  font-size: var(--im-font-size);
  background: linear-gradient(180deg, #eef6e4, #dcead2);
  color: var(--im-text);
}

/* ── 상단 바 : 숲 그라데이션 ── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: linear-gradient(135deg, var(--forest-deep), var(--forest) 60%, #3d7a4d);
  border-bottom: 4px solid var(--wood);
  box-shadow: 0 2px 10px rgba(30, 60, 35, .25);
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--im-gap); flex-wrap: wrap;
  padding: 12px 18px 8px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { font-size: 32px; filter: drop-shadow(0 2px 2px rgba(0,0,0,.3)); }
.brand-text h1 { font-size: 19px; color: #fff; letter-spacing: -0.3px; text-shadow: 0 1px 2px rgba(0,0,0,.25); }
.brand-text p { font-size: 12px; color: #cfe6c8; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#search {
  border: 2px solid rgba(255,255,255,.4); border-radius: var(--im-radius-pill);
  padding: 8px 16px; width: 230px; font-size: 14px;
  background: rgba(255,255,255,.92); color: var(--im-text); outline: none;
}
#search:focus { border-color: #ffd24d; }

.btn {
  border: none; cursor: pointer; font-size: 14px; font-weight: 700;
  border-radius: var(--im-radius-pill); padding: 8px 18px;
  transition: filter .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn.primary { background: var(--leaf); color: #fff; box-shadow: inset 0 -2px 0 rgba(0,0,0,.15); }
.btn.primary.on { background: #d98d0f; }
.btn.ghost { background: rgba(255,255,255,.18); color: #fff; border: 1px solid rgba(255,255,255,.4); }
.btn.danger { background: var(--im-danger); color: #fff; }

/* ── 통계 바 : 잎사귀 칩 ── */
.statsbar {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  padding: 4px 18px 12px;
}
.stat-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700;
  border-radius: 14px 14px 14px 4px;   /* 잎사귀 모양 */
  padding: 4px 12px;
  background: rgba(255,255,255,.92); color: var(--forest-deep);
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.stat-chip .dot { width: 10px; height: 10px; border-radius: 50% 50% 45% 45%; display: inline-block; border: 1px solid rgba(0,0,0,.15); }
.stat-chip.total { background: #ffd24d; color: #5f3d1f; }

/* ── 숲 지도 ── */
.map-wrap { overflow: auto; padding: 18px; }
.map {
  min-width: 1650px;
  background:
    radial-gradient(ellipse 600px 200px at 15% 0%, rgba(255,255,255,.25), transparent 70%),
    radial-gradient(ellipse 700px 260px at 85% 100%, rgba(46,107,62,.12), transparent 70%),
    linear-gradient(180deg, var(--grass-1), var(--grass-2));
  border: 3px solid var(--wood-light);
  outline: 2px solid var(--wood);
  border-radius: var(--im-radius-lg);
  padding: 18px 18px 10px;
  position: relative;
}

.map-top { display: flex; justify-content: center; gap: 24px; align-items: center; padding-bottom: 12px; }
.pavilion {
  background: linear-gradient(180deg, #fffdf6, #f3ead4);
  border: 2px solid var(--wood-light); border-bottom-width: 4px;
  border-radius: 10px;
  padding: 8px 20px; font-weight: 800; color: var(--wood-dark);
  box-shadow: 0 2px 6px rgba(95,61,31,.2);
}
.entrance {
  background: linear-gradient(180deg, #f5a623, #e0930f);
  color: #4d2f00; border: 2px solid #b47408; border-bottom-width: 5px;
  padding: 8px 26px; font-weight: 800; border-radius: 10px;
  box-shadow: 0 3px 8px rgba(95,61,31,.3);
  position: relative;
}
.entrance::before, .entrance::after {  /* 팻말 기둥 못 */
  content: ''; position: absolute; top: 6px; width: 6px; height: 6px;
  border-radius: 50%; background: #8a5a10;
}
.entrance::before { left: 8px; }
.entrance::after { right: 8px; }

/* 흙길 (통로) */
.path-band {
  height: 26px; margin: 6px 0 14px;
  background: linear-gradient(180deg, #dcc79b, #cdb583);
  border-top: 2px solid #bfa571; border-bottom: 2px solid #bfa571;
  border-radius: 8px;
  position: relative;
}
.path-band::before {
  content: ''; position: absolute; left: 10px; right: 10px; top: 50%;
  border-top: 2px dashed rgba(138, 90, 51, .5);
}

.map-row { display: flex; gap: 22px; align-items: flex-start; margin-bottom: 14px; }
.zone-slot { flex: 0 0 auto; }

/* ── 구역 : 나무 팻말 ── */
.zone { background: transparent; }
.zone-title {
  display: inline-block; font-weight: 800; font-size: 14px;
  padding: 6px 16px 7px; margin-bottom: 8px;
  border-radius: 10px;
  background: linear-gradient(180deg, #9a6a3e, var(--wood));
  color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.35);
  border: 1px solid var(--wood-dark); border-bottom-width: 4px;
  box-shadow: 0 2px 5px rgba(95,61,31,.25);
  position: relative;
}
.zone-title::before {  /* 팻말에 걸린 잎 표시 = 구역 색 */
  content: ''; display: inline-block; width: 11px; height: 11px;
  border-radius: 50% 50% 45% 45%; margin-right: 7px;
  vertical-align: -1px; border: 1px solid rgba(0,0,0,.25);
  background: var(--zc, #fff);
}
.zone-adopted { font-size: 12px; font-weight: 800; margin-left: 8px; color: var(--forest-deep); }

/* 구역별 색 (수관 틴트) */
.z-pink   { --zc: #eeaec4; --zc-line: #d68aa5; }
.z-white  { --zc: #f3f7ee; --zc-line: #c2cdb8; }
.z-red    { --zc: #e07a63; --zc-line: #c05744; }
.z-yellow { --zc: #f0d264; --zc-line: #cfae3d; }
.z-green  { --zc: #8fc57e; --zc-line: #6da55c; }
.z-blue   { --zc: #93b7dd; --zc-line: #6f95c0; }

.zone-grid { display: grid; gap: 2px; }

/* 열 이름표 : 작은 나무 명패 */
.hdr {
  font-size: 11px; font-weight: 800; text-align: center;
  padding: 4px 2px; border-radius: 6px 6px 3px 3px;
  background: linear-gradient(180deg, var(--zc), var(--zc));
  border: 1px solid var(--zc-line); border-bottom-width: 3px;
  color: rgba(40, 30, 15, .85);
}
.z-red .hdr, .z-blue .hdr { color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.25); }

/* ── 나무 셀 ── */
.cell {
  min-width: 58px; height: 56px;
  position: relative;
  display: flex; align-items: flex-end; justify-content: center;
  background: transparent;
}
/* 빈 자리 = 흙 두둑 */
.cell.empty::before {
  content: ''; position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  width: 22px; height: 9px; border-radius: 50%;
  background: var(--soil); opacity: .55;
  box-shadow: inset 0 -2px 0 rgba(138,90,51,.25);
}
/* 구조물(원본 남색 칸) = 바위 */
.cell.navy::before {
  content: ''; position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  width: 30px; height: 20px;
  border-radius: 45% 55% 40% 50%;
  background: linear-gradient(145deg, #93a0aa, #6d7a85);
  box-shadow: inset -3px -3px 0 rgba(0,0,0,.15);
}

/* 나무 = 수관(::before) + 줄기(::after) + 번호(.tn) */
.cell.tree { cursor: pointer; transition: transform .08s; }
.cell.tree::after {  /* 줄기 */
  content: ''; position: absolute; top: 25px; left: 50%; transform: translateX(-50%);
  width: 7px; height: 14px; background: linear-gradient(90deg, #9a6a3e, var(--wood));
  border-radius: 2px 2px 3px 3px;
  z-index: 1;
}
.cell.tree::before {  /* 수관: 세 덩어리 */
  content: ''; position: absolute; top: 3px; left: 50%; transform: translateX(-50%);
  width: 26px; height: 22px;
  background: var(--zc);
  border-radius: 50% 50% 46% 46%;
  box-shadow:
    -11px 7px 0 -5px var(--zc),
     11px 7px 0 -5px var(--zc),
     inset 0 -3px 0 rgba(0,0,0,.08);
  z-index: 2;
}
.cell.tree:hover { transform: scale(1.18); z-index: 10; }
.cell.tree .tn {
  position: relative; z-index: 3;
  font-size: 8.5px; font-weight: 800; color: #3c3428;
  background: rgba(255, 253, 246, .8);
  border-radius: 6px; padding: 0 3px; margin-bottom: 2px;
  line-height: 1.4;
}
/* 반려나무 이름표 : 수관 위 */
.cell.tree .nm {
  position: absolute; top: 6px; left: 50%; transform: translateX(-50%);
  z-index: 4;
  font-size: 8px; font-weight: 800; color: #fff;
  background: rgba(173, 20, 87, .92);
  padding: 1px 5px; border-radius: 7px;
  max-width: 56px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* 입양 완료 = 하트 모양 수관 (색+모양 모두 구분) */
.cell.tree.adopted::before {
  width: 32px; height: 27px; top: 1px;
  background: linear-gradient(135deg, var(--adopted-2), var(--adopted) 70%);
  border-radius: 0;
  box-shadow: none;
  clip-path: path('M16 27 C4.8 17 0 11.3 0 7 C0 2.6 3.7 0 7.5 0 C11.2 0 14.4 2 16 5.6 C17.6 2 20.8 0 24.5 0 C28.3 0 32 2.6 32 7 C32 11.3 27.2 17 16 27 Z');
  filter: drop-shadow(0 2px 2px rgba(120, 10, 60, .35));
}
.cell.tree.adopted::after { top: 26px; }
.cell.tree.adopted .tn { background: rgba(224, 17, 95, .13); color: #ad1457; }

/* BN 팻말 필요 = 같은 구역색 수관 + 빨간 점선 박스 */
.cell.tree.hl {
  border: 2px dashed #d05a5a;
  border-radius: 8px;
  background: rgba(255, 255, 255, .45);
}
.cell.tree.hl .tn { color: #a33; }

.cell.tree.hit { outline: 3px solid var(--im-coral); outline-offset: 0; border-radius: 10px; z-index: 5; background: rgba(255,255,255,.5); }
.cell.tree.dim { opacity: .18; }

/* 그린존 행 라벨 : 이끼 낀 나무토막 */
.rowlbl {
  min-width: 40px; height: 56px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800;
  background: linear-gradient(180deg, #8fc57e, #74ad63);
  color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.3);
  border: 1px solid #5f9450; border-bottom-width: 3px;
}
.rowpath {
  grid-column: 1 / -1; height: 22px;
  background: linear-gradient(180deg, #dcc79b, #cdb583);
  border-top: 2px solid #bfa571; border-bottom: 2px solid #bfa571;
  border-radius: 6px; position: relative;
}
.rowpath::before {
  content: ''; position: absolute; left: 8px; right: 8px; top: 50%;
  border-top: 2px dashed rgba(138, 90, 51, .5);
}

/* 배치도 원본 메모 : BN열 넘버링 팻말 안내 */
.map-note {
  flex: 0 0 auto;
  margin-top: 360px;   /* BN 2026-004 부근 높이에 맞춤 */
  background: #fff;
  border: 2px solid #e0b4b4;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12.5px; font-weight: 800; line-height: 1.6;
  color: #c00;
  box-shadow: 0 2px 6px rgba(95, 61, 31, .18);
  max-width: 190px;
}

/* 예정 구역 : 묘목장 울타리 */
.plan-box {
  border: 3px dashed var(--forest);
  border-radius: var(--im-radius-sm);
  background: rgba(255,255,255,.55);
  min-width: 150px; min-height: 180px;
  display: flex; align-items: center; justify-content: center;
  text-align: center; margin-left: auto;
}
.plan-box.tall { min-height: 260px; }
.plan-label { font-weight: 800; color: #b03030; font-size: 14px; line-height: 1.7; }
.plan-label em { font-style: normal; color: var(--forest-deep); }
.plan-label small { font-weight: 700; color: #555; font-size: 11px; }
.under-blue { text-align: right; padding: 2px 180px 8px 0; }
.plan-inline {
  display: inline-block; font-weight: 800; color: #b03030;
  background: rgba(255,255,255,.85); border: 2px dashed #d69a9a;
  border-radius: 10px; padding: 6px 16px; font-size: 13px;
}

/* 범례 */
.legend {
  display: flex; gap: 18px; flex-wrap: wrap; align-items: center;
  background: rgba(255,255,255,.85); border: 1px solid var(--wood-light);
  border-radius: var(--im-radius-sm);
  padding: 8px 14px; margin-top: 6px; font-size: 12px; font-weight: 700; color: #4a3d2c;
}
.legend .lg {
  display: inline-block; width: 15px; height: 14px;
  border-radius: 50% 50% 45% 45%;
  vertical-align: -2px; margin-right: 5px; border: 1px solid rgba(0,0,0,.2);
}
.lg-free { background: linear-gradient(135deg, #eeaec4 25%, #f0d264 25% 50%, #8fc57e 50% 75%, #93b7dd 75%); }
.lg-adopted {
  background: linear-gradient(135deg, var(--adopted-2), var(--adopted) 70%);
  border: none; border-radius: 0;
  clip-path: path('M7.5 13 C2.2 8.2 0 5.4 0 3.3 C0 1.2 1.7 0 3.5 0 C5.2 0 6.7 1 7.5 2.6 C8.3 1 9.8 0 11.5 0 C13.3 0 15 1.2 15 3.3 C15 5.4 12.8 8.2 7.5 13 Z');
}
.lg-hl { background: #93b7dd; border: 2px dashed #d05a5a; border-radius: 6px; }
.lg-navy { background: linear-gradient(145deg, #93a0aa, #6d7a85); border-radius: 45% 55% 40% 50%; }

/* ── 모달 : 나무 팻말 ── */
.modal-back {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(20, 35, 22, .5);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-back[hidden] { display: none; }
.modal {
  background: #fffdf6; border-radius: var(--im-radius-xl);
  box-shadow: 0 10px 30px rgba(20, 35, 22, .35);
  width: 100%; max-width: 430px;
  overflow: hidden;
  border: 3px solid var(--wood-light);
}
.modal.small { max-width: 330px; }
.modal-head {
  background: linear-gradient(135deg, var(--wood-dark), var(--wood) 70%, #9a6a3e);
  color: #fff;
  padding: 16px 20px; position: relative;
  border-bottom: 4px solid var(--wood-dark);
}
.modal-head::before {
  content: '🌳'; position: absolute; right: 46px; top: 14px; font-size: 28px; opacity: .9;
}
.m-zone { font-size: 12px; font-weight: 800; opacity: .85; margin-bottom: 2px; }
.m-id { font-size: 20px; font-weight: 800; }
.m-id strong { color: #ffd24d; }
.m-close {
  position: absolute; top: 10px; right: 14px;
  background: none; border: none; color: #fff; font-size: 26px; cursor: pointer; line-height: 1;
}
.modal-body { padding: 18px 20px 20px; }
.m-status { font-size: 13px; font-weight: 800; margin-bottom: 10px; }
.m-status.free { color: var(--leaf); }
.m-status.taken { color: var(--adopted); }
.m-view {
  background: #f2f5e8; border: 1px solid #dce3c8;
  border-radius: var(--im-radius-md);
  padding: 12px 16px; margin-bottom: 12px; font-size: 14px; line-height: 1.9;
}
.m-view:empty { display: none; }
.m-view b { color: var(--forest-deep); }
.m-form label {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; font-weight: 700; color: var(--im-text);
  margin-bottom: 8px;
}
.m-form label input {
  flex: 1; border: 1px solid #d8ceb6; border-radius: var(--im-radius-md);
  padding: 8px 12px; font-size: 14px; background: #fffef9; outline: none;
}
.m-form label input:focus { border-color: var(--leaf); }
.m-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.m-note { margin-top: 10px; font-size: 12px; font-weight: 800; color: #b00; }
.pin-err { color: var(--im-danger); font-size: 13px; font-weight: 700; margin-top: 6px; }
#pin-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 700; }
#pin-form input {
  border: 1px solid #d8ceb6; border-radius: var(--im-radius-md);
  padding: 10px 12px; font-size: 16px; letter-spacing: 4px; text-align: center;
  background: #fffef9; outline: none;
}

/* 읽기 전용(비관리자) */
body:not(.admin) .m-form { display: none; }
.viewer-hint { font-size: 12px; color: var(--im-text-sub); }

/* ── 모바일 최적화 ── */
@media (max-width: 860px) {
  /* 상단바: 컴팩트하게 */
  .topbar-inner { padding: 8px 12px 6px; gap: 8px; }
  .brand-mark { font-size: 24px; }
  .brand-text h1 { font-size: 16px; }
  .brand-text p { display: none; }
  .topbar-actions { width: 100%; }
  #search { flex: 1; width: auto; min-width: 0; padding: 7px 14px; }
  .btn { padding: 7px 12px; font-size: 13px; white-space: nowrap; }

  /* 통계 칩: 한 줄 가로 스크롤 */
  .statsbar {
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding: 2px 12px 10px; scrollbar-width: none;
  }
  .statsbar::-webkit-scrollbar { display: none; }
  .stat-chip { flex: 0 0 auto; }

  /* 지도: 구역을 세로로 쌓고, 각 구역만 좌우 스크롤 */
  .map-wrap { padding: 10px; }
  .map { min-width: 0; padding: 12px 10px 8px; }
  .map-top { gap: 10px; flex-wrap: wrap; }
  .pavilion, .entrance { padding: 6px 14px; font-size: 13px; }
  .path-band { height: 16px; margin: 4px 0 10px; }

  .map-row { display: block; margin-bottom: 0; }
  .zone-slot {
    width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
    margin-bottom: 16px; padding-bottom: 4px;
  }
  .zone-slot .zone-grid { width: max-content; }

  /* 예정 구역·메모: 일반 블록으로 */
  .plan-box, .plan-box.tall {
    min-height: 0; min-width: 0; width: 100%;
    margin: 0 0 16px; padding: 10px;
  }
  .plan-label { font-size: 13px; line-height: 1.5; }
  .plan-label br { display: none; }
  .map-note { margin: 0 0 16px; max-width: none; width: 100%; font-size: 12px; }
  .under-blue { padding: 0 0 8px; text-align: center; }

  .legend { gap: 10px; font-size: 11px; padding: 8px 10px; }

  /* 모달: 바텀시트 */
  .modal-back { align-items: flex-end; padding: 0; }
  .modal, .modal.small {
    max-width: 100%;
    border-radius: 22px 22px 0 0;
    border-left: none; border-right: none; border-bottom: none;
  }
  .modal-body { padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); }
  .m-form label { flex-direction: column; align-items: stretch; gap: 4px; }
  .m-form label input { padding: 10px 12px; font-size: 16px; } /* iOS 자동확대 방지 */
  #pin-form input { font-size: 16px; }
  .m-actions .btn { padding: 10px 20px; }
}
