/* ===== 토큰 ===== */
:root {
  --text: #f5f8fd;
  --dim: rgba(245, 248, 253, 0.62);
  --faint: rgba(245, 248, 253, 0.4);
  --glass: rgba(255, 255, 255, 0.1);
  --glass-line: rgba(255, 255, 255, 0.14);
  --blue: #8ecbff;
  --track: rgba(0, 0, 0, 0.22);
  --radius: 20px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  background: linear-gradient(175deg, #101832 0%, #1c2c52 55%, #2d456e 100%);
  background-attachment: fixed;
  transition: background 0.8s;
}
/* 시간대별 하늘 */
body[data-sky="dawn"]  { background: linear-gradient(175deg, #232a4d 0%, #4b4577 55%, #b06a67 100%); background-attachment: fixed; }
body[data-sky="day"]   { background: linear-gradient(175deg, #1d4f8f 0%, #2f6cb3 55%, #5c96cf 100%); background-attachment: fixed; }
body[data-sky="dusk"]  { background: linear-gradient(175deg, #1d2a52 0%, #4c4374 55%, #c07a4e 100%); background-attachment: fixed; }
body[data-sky="night"] { background: linear-gradient(175deg, #0b1026 0%, #16204a 55%, #253461 100%); background-attachment: fixed; }
/* 궂은 날(흐림/비)은 시간대와 무관하게 회색조 하늘 */
body[data-cond="overcast"], body[data-cond="rain"], body[data-cond="sleet"] {
  background: linear-gradient(175deg, #4d5a6e 0%, #617085 55%, #78889c 100%);
  background-attachment: fixed;
}
body[data-sky="night"][data-cond="overcast"],
body[data-sky="night"][data-cond="rain"],
body[data-sky="night"][data-cond="sleet"] {
  background: linear-gradient(175deg, #12182a 0%, #1c2438 55%, #28324a 100%);
  background-attachment: fixed;
}
/* 눈 오는 날은 밝은 잿빛 */
body[data-cond="snow"] {
  background: linear-gradient(175deg, #6b7688 0%, #8792a4 55%, #a5aebd 100%);
  background-attachment: fixed;
}
body[data-sky="night"][data-cond="snow"] {
  background: linear-gradient(175deg, #1a2133 0%, #262f44 55%, #364157 100%);
  background-attachment: fixed;
}

#fx {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh; height: 100dvh;
  z-index: 0; pointer-events: none;
}
.app, .sheet { position: relative; z-index: 1; }

.app {
  max-width: 620px;
  margin: 0 auto;
  padding-top: max(14px, env(safe-area-inset-top));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-bottom: max(34px, env(safe-area-inset-bottom));
  padding-left: max(16px, env(safe-area-inset-left));
}

/* ===== 상단 바 ===== */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.citypick {
  display: flex; align-items: center; gap: 8px;
  font-size: 22px; font-weight: 700;
  padding: 8px 4px;
  color: var(--text);
  min-width: 0;
  background: none; border: none; cursor: pointer;
  font-family: inherit;
}
.citypick svg { color: var(--dim); flex: 0 0 auto; }
.citypick #cityLabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { display: flex; gap: 8px; flex: 0 0 auto; }
.actions button {
  width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--glass-line);
  background: var(--glass); color: var(--text);
  cursor: pointer;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.actions button:active { transform: scale(0.92); }

/* ===== 공통 카드 ===== */
.card {
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: var(--radius);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}

/* ===== 키 설정 ===== */
.keycard { padding: 18px 20px; margin-top: 12px; }
.keycard h2 { font-size: 16px; margin: 0 0 6px; }
.keycard p { font-size: 13.5px; color: var(--dim); line-height: 1.65; margin: 0 0 12px; }
.keycard a { color: var(--blue); }
.keyrow { display: flex; gap: 8px; }
.keyrow input {
  flex: 1; min-width: 0;
  font-size: 16px; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--glass-line); background: rgba(0,0,0,0.18);
  color: var(--text); outline: none;
}
.keyrow input::placeholder { color: var(--faint); }
.keyrow button {
  font-size: 15px; font-weight: 700; padding: 12px 20px; border-radius: 12px;
  border: none; background: var(--text); color: #16223f; cursor: pointer;
}
.keyrow button:active { transform: translateY(1px); }

.status { font-size: 14px; color: var(--dim); padding: 14px 6px; white-space: pre-wrap; word-break: break-all; }
.status.err { color: #ffb3ad; }
.hidden { display: none !important; }

/* ===== 현재 날씨 ===== */
.hero { text-align: center; padding: 26px 0 8px; }
.hero-temp { font-size: 96px; font-weight: 100; line-height: 1; letter-spacing: -3px; }
.hero-temp .deg { font-weight: 200; color: var(--dim); }
.hero-cond { font-size: 18px; font-weight: 600; margin-top: 2px; }
.hero-cond .wx { width: 30px; height: 30px; vertical-align: -8px; margin-right: 2px; }
.hero-range { font-size: 15px; color: var(--dim); margin-top: 5px; }

/* ===== 상세 타일 ===== */
.tiles {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 10px; margin-top: 18px;
}
.tile { padding: 12px 8px; text-align: center; }
.tile-k { font-size: 11px; color: var(--dim); letter-spacing: 0.3px; }
.tile-v { font-size: 19px; font-weight: 600; margin-top: 5px; }
.tile-s { font-size: 10px; color: var(--faint); margin-top: 1px; }

.stamp { font-size: 12px; color: var(--faint); text-align: center; margin-top: 12px; }

/* ===== 예보 블록 ===== */
.block { margin-top: 14px; padding: 14px 16px 10px; overflow: hidden; }
.block-title {
  font-size: 12px; font-weight: 700; color: var(--dim);
  letter-spacing: 0.5px; padding-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.block-foot { font-size: 11px; color: var(--faint); text-align: right; padding: 8px 2px 6px; }

/* 시간별 */
.hours {
  display: flex; overflow-x: auto;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
  margin: 0 -16px; padding: 10px 10px 6px;
}
.hours::-webkit-scrollbar { display: none; }
.hour { flex: 0 0 62px; text-align: center; padding: 6px 0; }
.hour .h-t { font-size: 13px; font-weight: 500; color: var(--dim); white-space: nowrap; }
.hour .h-i { font-size: 25px; margin: 7px 0 5px; height: 36px; }
.hour .h-i .wx { width: 36px; height: 36px; }
.hour .h-d { font-size: 16px; font-weight: 600; }
.hour .h-p { font-size: 11px; font-weight: 600; color: var(--blue); margin-top: 4px; min-height: 14px; }
.hour.daybreak { border-left: 1px solid rgba(255,255,255,0.14); }

/* 10일 (날씨누리 주간날씨 스타일: 요일 | 오전 | 오후 | 최저/최고) */
.block-stamp { float: right; font-size: 12px; font-weight: 400; color: var(--faint); letter-spacing: 0; }
.days-head {
  display: grid; grid-template-columns: 74px 1fr 1fr 92px;
  padding: 10px 0 2px;
  font-size: 12px; font-weight: 600; color: var(--dim); text-align: center;
}
.day-row {
  display: grid;
  grid-template-columns: 74px 1fr 1fr 92px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.day-row:last-child { border-bottom: none; }
.day-row .d-n { font-size: 17px; font-weight: 700; }
.day-row .d-n small { margin-left: 5px; font-size: 12px; font-weight: 400; color: var(--faint); }
.day-row.sat .d-n { color: #8ecbff; }
.day-row.sun .d-n { color: #ff9d8a; }
.d-half { text-align: center; }
.d-half .ic { display: block; font-size: 25px; line-height: 1.2; height: 38px; }
.d-half .ic .wx { width: 38px; height: 38px; }
.d-half .p { display: block; font-size: 12px; font-weight: 700; color: var(--blue); min-height: 15px; margin-top: 1px; }
.day-row .d-t { text-align: right; font-size: 17px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.day-row .d-t .lo { color: var(--dim); }
.day-row .d-t .sep { color: var(--faint); margin: 0 3px; font-size: 14px; }
.day-row .d-t .hi { font-weight: 700; }

.foot { font-size: 12px; color: var(--faint); text-align: center; margin-top: 22px; line-height: 1.7; }

/* ===== 지역 검색 시트 ===== */
.sheet {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(8, 12, 28, 0.55);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-card {
  width: 100%; max-height: 86vh; max-height: 86dvh;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: #1a2440;
  border: 1px solid var(--glass-line);
  border-radius: 22px 22px 0 0;
  padding: 16px 16px max(20px, env(safe-area-inset-bottom));
}
.sheet-head { display: flex; gap: 8px; position: sticky; top: 0; background: #1a2440; padding-bottom: 4px; }
.sheet-head input {
  flex: 1; min-width: 0;
  font-size: 16px; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--glass-line); background: rgba(0,0,0,0.25);
  color: var(--text); outline: none; -webkit-appearance: none;
}
.sheet-head input::placeholder { color: var(--faint); }
.sheet-head button {
  font-size: 15px; font-weight: 600; padding: 0 16px; border-radius: 12px;
  border: none; background: var(--glass); color: var(--text); cursor: pointer;
}
.results { margin-top: 6px; }
.result {
  display: block; width: 100%; text-align: left;
  padding: 13px 10px; border: none; background: none; cursor: pointer;
  color: var(--text); font-family: inherit;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.result:last-child { border-bottom: none; }
.result .r-name { font-size: 16px; font-weight: 600; }
.result .r-addr { font-size: 12.5px; color: var(--dim); margin-top: 3px; }
.result:active { background: rgba(255,255,255,0.06); border-radius: 10px; }
.results .r-msg { font-size: 13.5px; color: var(--dim); padding: 14px 10px; }
.sheet-sec { font-size: 12px; font-weight: 700; color: var(--dim); margin: 16px 4px 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button {
  font-size: 14px; font-weight: 500; padding: 9px 14px; border-radius: 999px;
  border: 1px solid var(--glass-line); background: var(--glass);
  color: var(--text); cursor: pointer; font-family: inherit;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chips button:active { transform: scale(0.96); }
.sheet-note { font-size: 11.5px; color: var(--faint); margin-top: 18px; line-height: 1.6; }

@media (min-width: 700px) {
  .sheet { align-items: center; padding: 24px; }
  .sheet-card { max-width: 520px; border-radius: 22px; max-height: 78vh; }
}

/* ===== 아이패드 / 가로 화면: 2단 ===== */
@media (min-width: 700px) {
  .app { max-width: 1080px; }
  .content { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 22px; align-items: start; }
  .col-hero { position: sticky; top: 18px; }
  .col-fcst { min-width: 0; }
  .col-fcst .block:first-child { margin-top: 0; }
  .hero { padding-top: 46px; }
  .hero-temp { font-size: 110px; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .tile { padding: 16px 10px; }
  .tile-v { font-size: 22px; }
  .hour { flex: 0 0 70px; }
  .day-row { padding: 14px 0; }
}
@media (min-width: 1000px) {
  .app { max-width: 1160px; }
  .content { grid-template-columns: 430px minmax(0, 1fr); gap: 26px; }
  .days-head, .day-row { grid-template-columns: 90px 1fr 1fr 104px; }
}

/* 날씨 아이콘(SVG): 배경 위에서도 또렷하게 옅은 그림자 */
.wx { display: inline-block; filter: drop-shadow(0 2px 3px rgba(0,0,0,0.18)); -webkit-user-select: none; user-select: none; }
