:root {
  --paper: #ece5d8;
  --paper-2: #e0d6c3;
  --ink: #211a15;
  --ink-soft: #6b5f55;
  --study: #56622b;
  --mood: #c2452d;
  --hi: #f2c230;
  --peek: 38dvh;
}

* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
[hidden] { display: none !important; }

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.4 'IBM Plex Sans KR', system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* 상단 */
.top {
  position: relative;
  z-index: 500;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 13px) 14px 10px 17px;
  border-bottom: 2px solid var(--ink);
  background: var(--paper);
}
.logo {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  font: 400 31px/.85 'Black Han Sans', sans-serif;
  letter-spacing: -1.5px;
}
.logo span {
  padding: 2px 5px 3px;
  background: var(--ink);
  color: var(--paper);
  font-size: 15px;
  letter-spacing: -.5px;
  transform: rotate(-4deg) translate(-3px, -3px);
}
.top-r { display: flex; align-items: flex-end; gap: 11px; }
.me {
  display: grid;
  place-items: center;
  min-width: 36px;
  height: 33px;
  padding: 0 7px;
  border: 1.5px dashed var(--ink);
  font-size: 12.5px;
  font-weight: 700;
}
.me.in { border-style: solid; background: var(--paper-2); }
.me .mk { width: 17px; height: 17px; }
.mode {
  display: flex;
  border: 2px solid var(--ink);
  background: var(--paper);
  box-shadow: 3px 3px 0 var(--ink);
  transform: rotate(-1.5deg);
}
.mode button { padding: 6px 14px 7px; font-weight: 700; font-size: 14px; }
.mode button.on { background: var(--ink); color: var(--paper); }

/* 필터 칩 */
.chips {
  position: relative;
  z-index: 500;
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 10px 14px 11px 17px;
  border-bottom: 1px dashed var(--ink-soft);
  background: var(--paper);
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px 7px;
  border: 1.5px solid var(--ink);
  border-radius: 2px;
  background: var(--paper);
  font-weight: 500;
  white-space: nowrap;
}
.chip small { font-size: 11px; color: var(--ink-soft); }
.chip em { font-style: normal; font-size: 11px; font-weight: 700; color: var(--ink-soft); }
.chip.on { background: var(--ink); color: var(--paper); }
.chip.on small, .chip.on em { color: var(--paper-2); }
.chip-study.on { background: var(--study); border-color: var(--study); }
.chip-mood.on { background: var(--mood); border-color: var(--mood); }

.lines { display: flex; gap: 2px; }
.lines i {
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  color: #fff;
  font: 700 10px/1 'IBM Plex Sans KR', sans-serif;
}

/* 지도 */
#map { flex: 1; background: var(--paper-2); }
.leaflet-container { font-family: inherit; }
.leaflet-tile-pane { filter: sepia(.35) saturate(.7) contrast(.96); }
.leaflet-control-attribution {
  font-size: 10px;
  background: rgba(236, 229, 216, .85) !important;
}

.pin, .stn { width: 0; height: 0; }
.pin b {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  padding: 3px 7px 4px;
  border: 2px solid var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
  color: var(--paper);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  transform: translate(-50%, calc(-100% - 9px));
  transition: transform .15s;
}
.pin b::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -11px;
  margin-left: -5px;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 9px solid var(--ink);
}
.pin-study b { background: var(--study); }
.pin-mood b { background: var(--mood); }
.pin-both b { background: linear-gradient(90deg, var(--study) 50%, var(--mood) 50%); }
.pin.is-on b {
  background: var(--hi);
  color: var(--ink);
  transform: translate(-50%, calc(-100% - 9px)) scale(1.2) rotate(-3deg);
}

.stn span {
  position: absolute;
  padding: 1px 5px 2px;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: -.02em;
  white-space: nowrap;
  transform: translate(-50%, 5px);
}
.stn span::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 4px;
  background: var(--ink);
  vertical-align: 1px;
}

.locate {
  position: fixed;
  right: 13px;
  bottom: calc(var(--peek) + 15px);
  z-index: 550;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 2px solid var(--ink);
  background: var(--paper);
  box-shadow: 3px 3px 0 var(--ink);
}

/* 하단 목록 */
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 600;
  display: flex;
  flex-direction: column;
  height: var(--peek);
  border-top: 2px solid var(--ink);
  background: var(--paper);
  transition: height .28s cubic-bezier(.3, .7, .2, 1);
}
.sheet.full { height: 82dvh; }
.handle {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 10px 17px 11px;
  border-bottom: 1px solid var(--ink);
  touch-action: none;
}
.handle span { width: 34px; height: 5px; background: var(--ink); transform: rotate(-3deg); }
.handle em { font-style: normal; font-weight: 700; font-size: 13px; }

.list {
  flex: 1;
  overflow-y: auto;
  padding: 0 0 calc(env(safe-area-inset-bottom) + 22px);
  list-style: none;
}
.list li { border-bottom: 1px dashed #b9ad9c; }
.item { display: block; width: 100%; padding: 13px 17px 15px 19px; text-align: left; }
.item:active { background: var(--paper-2); }
.item strong { display: block; margin: 5px 0 1px; font-size: 17px; letter-spacing: -.02em; }
.item small { font-size: 12.5px; color: var(--ink-soft); }
.item p { margin-top: 6px; font-size: 13.5px; line-height: 1.5; color: #3d342d; }
.empty { padding: 27px 19px; color: var(--ink-soft); }

.tag {
  display: inline-block;
  margin-right: 4px;
  padding: 1px 6px 2px;
  color: var(--paper);
  font: 700 11px/1.4 'IBM Plex Sans KR', sans-serif;
}
.tag-study { background: var(--study); }
.tag-mood { background: var(--mood); }

/* 상세 */
.detail {
  position: fixed;
  left: 9px;
  right: 11px;
  bottom: calc(env(safe-area-inset-bottom) + 11px);
  z-index: 700;
  max-height: 72dvh;
  overflow-y: auto;
  padding: 17px 18px 16px;
  border: 2px solid var(--ink);
  background: var(--paper);
  box-shadow: 5px 5px 0 var(--ink);
  animation: up .22s ease-out;
}
@keyframes up { from { transform: translateY(26px); opacity: 0; } }
.detail .x {
  position: absolute;
  top: 6px;
  right: 7px;
  width: 38px;
  height: 38px;
  font-size: 26px;
  line-height: 1;
}
.detail h2 {
  margin: 7px 34px 10px 0;
  font: 400 27px/1.1 'Black Han Sans', sans-serif;
  letter-spacing: -.5px;
}
.detail dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 13px;
  font-size: 13.5px;
}
.detail dt { color: var(--ink-soft); }
.detail .note {
  margin: 13px 0 4px;
  padding-left: 10px;
  border-left: 3px solid var(--hi);
  line-height: 1.55;
}
.detail .sample { margin-top: 9px; font-size: 11px; color: var(--mood); }
.go { display: flex; gap: 7px; margin-top: 15px; }
.go a {
  flex: 1;
  padding: 10px 0 11px;
  border: 2px solid var(--ink);
  color: var(--ink);
  font-weight: 700;
  font-size: 14px;
  text-align: center;
  text-decoration: none;
}
.go a:first-child { background: var(--ink); color: var(--paper); }


/* 후기 요약 (상세 카드 안) */
.item .n { color: var(--mood); font-weight: 700; }
.rv {
  margin: 15px -18px 0;
  padding: 14px 18px 3px;
  border-top: 2px solid var(--ink);
  background: var(--paper-2);
}
.rv-none { padding: 2px 0 11px; font-size: 13px; color: var(--ink-soft); }
.rv-top { display: flex; align-items: center; gap: 15px; margin-bottom: 13px; }
.rv-avg { font: 400 37px/1 'Black Han Sans', sans-serif; letter-spacing: -1px; }
.rv-avg span { margin-right: 3px; color: var(--mood); font-size: 27px; vertical-align: 4px; }
.rv-dist { flex: 1; display: grid; gap: 2px; max-width: 150px; }
.rv-dist span { display: flex; align-items: center; gap: 5px; height: 7px; }
.rv-dist small { width: 7px; font-size: 9px; line-height: 1; color: var(--ink-soft); }
.rv-dist i { display: block; height: 5px; min-width: 2px; background: var(--ink); }
.rv-n { align-self: flex-end; margin-left: auto; font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.rv-split { display: flex; height: 25px; margin-bottom: 11px; border: 2px solid var(--ink); }
.rv-split span {
  display: flex;
  align-items: center;
  min-width: 56px;
  padding: 0 8px;
  color: var(--paper);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.rv-split .s-study { background: var(--study); }
.rv-split .s-mood { background: var(--mood); justify-content: flex-end; }
.rv-split .s-study + .s-mood { border-left: 2px solid var(--ink); }
.rv-facts {
  display: grid;
  grid-template-columns: 5.6em 1fr;
  gap: 6px 11px;
  margin-bottom: 12px;
  font-size: 13.5px;
}
.rv-facts dt { color: var(--ink-soft); font-size: 12.5px; padding-top: 1px; }
.rv-facts dd { font-weight: 500; }
.rv-facts em { font-style: normal; font-size: 11px; color: var(--ink-soft); }
.meter { display: inline-flex; gap: 2px; margin-right: 7px; vertical-align: -1px; }
.meter i { width: 9px; height: 12px; border: 1.5px solid var(--ink); }
.meter i.on { background: var(--ink); }
.rv-words { list-style: none; padding: 0; margin: 0 -18px; }
.rv-words li { padding: 10px 18px 11px 21px; border-top: 1px dashed #b3a690; }
.rv-who { display: flex; align-items: center; gap: 6px; font-size: 12.5px; }
.rv-who b { font-weight: 700; }
.rv-who small { margin-left: auto; font-size: 11px; color: var(--ink-soft); }
.rv-stars { color: var(--mood); font-size: 11.5px; letter-spacing: .5px; }
.rv-words p { margin-top: 4px; font-size: 13.5px; line-height: 1.55; }

.write-btn {
  display: block;
  width: 100%;
  margin-top: 13px;
  padding: 12px 0 13px;
  border: 2px solid var(--ink);
  background: var(--hi);
  box-shadow: 3px 3px 0 var(--ink);
  font-weight: 700;
  font-size: 15px;
}
.write-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }

/* 프로필 표시 (카카오 사진 대신 쓰는 모양 8개) */
.mk { display: inline-block; flex: none; width: 13px; height: 13px; background: var(--c); }
.mk-1 { --c: #56622b; border-radius: 50%; }
.mk-2 { --c: #c2452d; }
.mk-3 { --c: #211a15; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.mk-4 { --c: #d9a21b; clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.mk-5 { --c: #2f5d5a; border-radius: 50% 50% 0 0; }
.mk-6 { background: none; border: 3px solid #7a4a2a; border-radius: 50%; }
.mk-7 { --c: #5b3f6b; clip-path: polygon(35% 0, 65% 0, 65% 35%, 100% 35%, 100% 65%, 65% 65%, 65% 100%, 35% 100%, 35% 65%, 0 65%, 0 35%, 35% 35%); }
.mk-8 { --c: #d06a24; clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }

/* 패널: 로그인 / 프로필 / 후기 쓰기 */
.panel {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  animation: up .2s ease-out;
}
.w-head {
  position: relative;
  padding: calc(env(safe-area-inset-top) + 15px) 54px 12px 18px;
  border-bottom: 2px solid var(--ink);
}
.w-head small { display: flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; color: var(--ink-soft); }
.w-head h2 { margin-top: 3px; font: 400 25px/1.1 'Black Han Sans', sans-serif; letter-spacing: -.5px; }
.w-x {
  position: absolute;
  right: 8px;
  top: calc(env(safe-area-inset-top) + 9px);
  width: 42px;
  height: 42px;
  font-size: 28px;
  line-height: 1;
}
.w-body { flex: 1; overflow-y: auto; padding: 14px 18px 27px 18px; -webkit-overflow-scrolling: touch; }
.w-hint { margin: 17px 0 9px; font-size: 13px; color: var(--ink-soft); line-height: 1.5; }
.w-demo { margin-top: 15px; font-size: 12px; color: var(--mood); }

.w-group {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 21px 0 9px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .2em;
  color: var(--ink-soft);
}
.w-group::after { content: ''; flex: 1; border-top: 1px dashed var(--ink-soft); }

.w-q { margin-bottom: 13px; }
.w-label { display: block; margin-bottom: 6px; font-size: 13.5px; font-weight: 700; }
.w-label small { margin-left: 6px; font-weight: 400; font-size: 11px; color: var(--ink-soft); }
.w-label .req { padding: 1px 5px 2px; background: var(--mood); color: var(--paper); font-weight: 700; font-size: 10.5px; }
.w-opts { display: flex; flex-wrap: wrap; gap: 6px 5px; }
.opt {
  padding: 7px 11px 8px;
  border: 1.5px solid var(--ink);
  border-radius: 2px;
  background: var(--paper);
  font-size: 13.5px;
  font-weight: 500;
}
.opt.on { background: var(--ink); color: var(--paper); }

.w-must { margin: 0 -18px; padding: 3px 18px 15px; border-bottom: 2px solid var(--ink); }
.w-stars { display: flex; align-items: center; gap: 1px; margin-left: -4px; }
.w-stars button {
  padding: 0 3px;
  color: var(--paper-2);
  font-size: 41px;
  line-height: 1.05;
  -webkit-text-stroke: 1.5px var(--ink);
  transition: transform .1s;
}
.w-stars button.on { color: var(--hi); }
.w-stars button:active { transform: scale(.88) rotate(-8deg); }
.w-star-word { margin-left: 9px; font-size: 13.5px; font-weight: 700; color: var(--ink-soft); }

.w-q.big { padding: 13px 13px 14px 14px; border: 2px solid var(--ink); background: var(--paper-2); transform: rotate(-.6deg); }
.w-q.big .w-label { font-size: 15px; }
.w-q.big .opt { flex: 1; padding: 11px 0 12px; font-size: 17px; font-weight: 700; text-align: center; }
.opt.o-study.on { background: var(--study); border-color: var(--study); }
.opt.o-mood.on { background: var(--mood); border-color: var(--mood); }

.w-text { position: relative; display: block; }
.w-text textarea {
  display: block;
  width: 100%;
  padding: 10px 11px 24px;
  border: 1.5px solid var(--ink);
  border-radius: 0;
  background: #f6f1e7;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  resize: vertical;
}
.w-text textarea:focus, .nick input:focus { outline: 2px solid var(--hi); outline-offset: 1px; }
.w-text small { position: absolute; right: 9px; bottom: 6px; font-size: 11px; color: var(--ink-soft); }
.w-del { margin-top: 19px; font-size: 12.5px; color: var(--mood); text-decoration: underline; }

/* 로그인 안내 */
.promise { list-style: none; padding: 0; margin: 7px 0 0; counter-reset: p; }
.promise li {
  position: relative;
  padding: 11px 0 12px 31px;
  border-bottom: 1px dashed #b3a690;
  font-size: 14px;
  line-height: 1.55;
  counter-increment: p;
}
.promise li::before {
  content: counter(p);
  position: absolute;
  left: 1px;
  top: 12px;
  width: 19px;
  height: 19px;
  background: var(--ink);
  color: var(--paper);
  font: 700 11px/19px 'IBM Plex Sans KR', sans-serif;
  text-align: center;
}
.promise b { background: linear-gradient(transparent 58%, var(--hi) 58%); }
.kakao {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 0 14px;
  border-radius: 6px;
  background: #fee500;
  color: rgba(0, 0, 0, .85);
  font-weight: 700;
  font-size: 15.5px;
}
.kakao:disabled { opacity: .6; }

/* 프로필 */
.nick { display: flex; gap: 6px; }
.nick input {
  flex: 1;
  min-width: 0;
  padding: 10px 11px 11px;
  border: 1.5px solid var(--ink);
  border-radius: 0;
  background: #f6f1e7;
  color: var(--ink);
  font: inherit;
  font-size: 17px;
  font-weight: 700;
}
.nick button { padding: 0 12px; border: 1.5px dashed var(--ink); font-size: 13px; font-weight: 700; }
.marks { display: flex; flex-wrap: wrap; gap: 6px 7px; }
.marks button {
  display: grid;
  place-items: center;
  width: 47px;
  height: 47px;
  border: 1.5px solid var(--ink);
  background: var(--paper);
}
.marks button .mk { width: 21px; height: 21px; }
.marks button.on { background: var(--hi); box-shadow: 3px 3px 0 var(--ink); transform: translate(-1px, -2px) rotate(-3deg); }
.acct { display: flex; flex-direction: column; align-items: flex-start; gap: 13px; margin-top: 39px; padding-top: 15px; border-top: 1px solid var(--ink); }
.acct button { font-size: 13.5px; font-weight: 700; text-decoration: underline; }
.acct .danger { color: var(--mood); font-weight: 500; font-size: 12.5px; }

.w-foot {
  padding: 10px 14px calc(env(safe-area-inset-bottom) + 11px) 16px;
  border-top: 2px solid var(--ink);
  background: var(--paper);
}
.w-err { margin-bottom: 8px; font-size: 12.5px; color: var(--mood); }
.w-send {
  display: block;
  width: 100%;
  padding: 13px 0 14px;
  border: 2px solid var(--ink);
  background: var(--hi);
  box-shadow: 3px 3px 0 var(--ink);
  font-weight: 700;
  font-size: 16px;
}
.w-send:disabled { background: var(--paper-2); color: var(--ink-soft); box-shadow: none; border-style: dashed; cursor: default; }

.toast {
  position: fixed;
  left: 50%;
  top: calc(env(safe-area-inset-top) + 70px);
  z-index: 1150;
  padding: 9px 15px 10px;
  border: 2px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  transform: translateX(-50%) rotate(-1deg);
}

/* 넓은 화면 */
@media (min-width: 860px) {
  .sheet, .sheet.full {
    left: auto;
    right: 19px;
    bottom: 18px;
    width: 370px;
    height: calc(100dvh - 165px);
    border: 2px solid var(--ink);
    box-shadow: 6px 6px 0 var(--ink);
  }
  .handle { pointer-events: none; }
  .handle span { display: none; }
  .detail { left: auto; right: 405px; bottom: 18px; width: 340px; }
  .locate { right: auto; left: 15px; bottom: 26px; }
  .panel { inset: 18px 19px 18px auto; width: 430px; border: 2px solid var(--ink); box-shadow: 6px 6px 0 var(--ink); }
}
