:root {
  --text-on-photo: #fff;
  --chip-bg: rgba(255, 255, 255, 0.85);
  --chip-text: #1b1b1b;
  --badge-bg: rgba(0, 0, 0, 0.45);
  --panel-radius: 20px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f1f2f4;
  color: #1b1b1b;
  font-family: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #fff;
}

.day-tabs {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  padding: 16px 20px 0;
}

#mainView {
  display: flex;
  flex-direction: column;
  flex: 1;
}

#mainView[hidden],
.settings[hidden] {
  display: none;
}

.icon-btn {
  appearance: none;
  border: none;
  background: none;
  color: #1b1b1b;
  width: 40px;
  height: 40px;
  margin: -8px -10px 0 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-btn:focus-visible {
  outline: 2px solid #1b1b1b;
  outline-offset: 0;
}

.settings-open {
  margin-left: auto;
}

/* 에러 화면 (예보 없음·12시간 초과·인터넷 끊김) */
.error-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex: 1;
  min-height: 50vh;
  margin: 0 20px 24px;
  padding: 32px 20px;
  background: #f1f2f4;
  border-radius: var(--panel-radius);
  text-align: center;
}

.error-view[hidden],
.panel-track[hidden] {
  display: none;
}

.error-view.fatal {
  margin: 24px 20px;
}

.error-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.55;
  color: #1b1b1b;
}

/* 로딩: 패널 자리의 스켈레톤. 3초가 넘으면 문구를 보여준다. */
.loading-view {
  position: relative;
  /* 첫 패널(.panel)과 같은 자리·크기라 로딩이 끝나도 화면이 튀지 않는다 */
  flex: 1;
  width: calc((100% - 40px) * 0.82);
  min-height: 50vh;
  margin: 0 0 24px;
  border-radius: var(--panel-radius);
  background: linear-gradient(100deg, #eceef1 40%, #f7f8f9 50%, #eceef1 60%) 100% 0 / 300% 100%;
  animation: skeleton 1.4s linear infinite;
}

.loading-view[hidden],
.loading-text[hidden] {
  display: none;
}

.loading-text {
  position: absolute;
  inset: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: #6b6c72;
}

@keyframes skeleton {
  to {
    background-position: 0 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .loading-view {
    animation: none;
  }
}

/* 메인 화면 아래 출처 */
.source-credit {
  margin: 0 20px 16px;
  font-size: 11px;
  color: #8a8b90;
  text-align: right;
}

/* ---------- 설정 화면 ---------- */
.settings {
  padding: 8px 20px 32px;
}

.settings-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 8px -10px;
}

.settings-header .icon-btn {
  margin: 0;
}

.settings-header h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  outline: none;
}

.settings-group {
  padding: 18px 0;
  border-bottom: 1px solid #ececef;
}

.settings-group:last-child {
  border-bottom: none;
}

.settings-group h2 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: #6b6c72;
}

.settings-text {
  margin: 0 0 12px;
  font-size: 15px;
  line-height: 1.5;
  color: #1b1b1b;
}

.settings-text:last-child {
  margin-bottom: 0;
}

.settings-warning {
  padding: 10px 12px;
  background: #fff4e5;
  border-radius: 10px;
  font-size: 13px;
  color: #7a4b00;
}

.settings-btn {
  appearance: none;
  border: 1px solid #d5d7db;
  background: #fff;
  color: #1b1b1b;
  font: inherit;
  font-size: 14px;
  padding: 9px 14px;
  border-radius: 10px;
  cursor: pointer;
}

.settings-btn:disabled {
  color: #b0b2b8;
  border-color: #ececef;
  cursor: default;
}

.settings-btn.danger {
  color: #c62828;
  border-color: #f1c5c5;
}

.settings-btn.danger-solid {
  background: #c62828;
  border-color: #c62828;
  color: #fff;
}

.settings-btn:focus-visible {
  outline: 2px solid #1b1b1b;
  outline-offset: 2px;
}

/* 모든 설정 지우기 확인 창 */
.confirm {
  width: min(340px, calc(100% - 32px));
  border: none;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.confirm::backdrop {
  background: rgba(0, 0, 0, 0.4);
}

.confirm p {
  margin: 0 0 18px;
  font-size: 15px;
  line-height: 1.55;
  color: #1b1b1b;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* 토스트 (설정: 되돌리기, 전체 삭제 후) */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 10px 12px 10px 16px;
  background: rgba(27, 27, 27, 0.94);
  color: #fff;
  font-size: 14px;
  border-radius: 12px;
  z-index: 10;
}

.toast[hidden] {
  display: none;
}

.toast-action {
  appearance: none;
  border: none;
  background: none;
  color: #8fb4ff;
  font: inherit;
  font-weight: 700;
  padding: 4px 6px;
  cursor: pointer;
}

.day-tab {
  appearance: none;
  background: none;
  border: none;
  padding: 0 0 10px;
  font-size: 17px;
  font-weight: 500;
  color: #9a9ba0;
  border-bottom: 3px solid transparent;
}

.day-tab.active {
  color: #1b1b1b;
  font-weight: 700;
  border-bottom-color: #1b1b1b;
}

.date-label {
  margin: 10px 20px 14px;
  min-height: 20px; /* 로딩 중 비어 있어도 자리를 지킨다 */
  font-size: 14px;
  color: #6b6c72;
}

/* 알림 띠 (있을 때만) */
.notice-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 20px 10px;
  padding: 9px 12px;
  background: #1b1b1b;
  color: #fff;
  border-radius: 12px;
  font-size: 13px;
}

.notice-band[hidden],
.card[hidden] {
  display: none;
}

.notice-action {
  appearance: none;
  border: none;
  background: #fff;
  color: #1b1b1b;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  white-space: nowrap;
  cursor: pointer;
}

/* 카드 (한 번에 하나, 한 줄 크기) */
.card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin: 0 20px 12px;
  padding: 8px 10px 8px 14px;
  background: #f1f2f4;
  border-radius: 12px;
  max-height: 160px;
  overflow: hidden;
  /* 0.4s: app.js CARD_FADE_MS와 맞춘다 */
  transition:
    opacity 0.4s ease,
    max-height 0.4s ease,
    min-height 0.4s ease,
    padding 0.4s ease,
    margin 0.4s ease,
    background-color 0.25s ease;
}

/* 응답 안내: 카드 자리에서 눈에 띄는 색으로 바뀐다 */
.card.card-message {
  background: #2f6fed;
  /* 누른 카드의 높이를 유지해 아래 패널이 튀지 않게 한다 (app.js showCardMessage) */
  min-height: var(--card-hold, 0);
}

.card.card-message .card-text {
  color: #fff;
  font-weight: 600;
  padding: 5px 0;
}

/* 응답 안내가 부드럽게 사라지며 자리도 접힌다 */
.card.is-leaving {
  opacity: 0;
  max-height: 0;
  min-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin-bottom: 0;
}

.card-text {
  flex: 1 1 180px;
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
  color: #1b1b1b;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.card-btn {
  appearance: none;
  border: 1px solid #d5d7db;
  background: #fff;
  color: #1b1b1b;
  font: inherit;
  font-size: 12px;
  padding: 5px 9px;
  border-radius: 999px;
  white-space: nowrap;
  cursor: pointer;
}

.card-btn.primary {
  background: #1b1b1b;
  border-color: #1b1b1b;
  color: #fff;
}

.card-close {
  appearance: none;
  border: none;
  background: none;
  color: #6b6c72;
  font-size: 14px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
}

.card-btn:focus-visible,
.card-close:focus-visible,
.notice-action:focus-visible {
  outline: 2px solid #1b1b1b;
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .card {
    transition: none;
  }
}

.panel-track {
  display: flex;
  gap: 12px;
  padding: 0 20px 24px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

.panel-track::-webkit-scrollbar {
  display: none;
}

.panel {
  flex: 0 0 82%;
  container-type: size;
  aspect-ratio: 3 / 4;
  position: relative;
  border-radius: var(--panel-radius);
  overflow: hidden;
  scroll-snap-align: start;
  background: #222;
}

.layer {
  position: absolute;
  inset: 0;
}

.bg.sky-sunny {
  background: linear-gradient(180deg, #7ec8f2 0%, #d9ecfa 100%);
}
.bg.sky-cloudy,
.bg.sky-overcast {
  background: linear-gradient(180deg, #9aa3ad 0%, #c8ccd1 100%);
}
.bg.sky-rain {
  background: linear-gradient(180deg, #5c6b78 0%, #8d9aa5 100%);
}
.bg.sky-snow {
  background: linear-gradient(180deg, #b9c6d6 0%, #eef2f7 100%);
}

.character {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 그림(3:4)의 높이를 패널에 맞추고 좌우 빈 곳만 잘라, 긴 패널에서도 캐릭터가 작아지지 않게 한다. */
.outfit {
  flex: none;
  height: 100%;
  width: auto;
  max-width: none;
  aspect-ratio: 3 / 4;
  user-select: none;
  pointer-events: none;
  /* 머리 위치(위에서 290/1440)를 지키며 줄인다. 비율은 app.js fitOutfits가 정한다. */
  transform: scale(var(--outfit-scale, 1));
  transform-origin: 50% 20.14%;
}

.character.no-image .outfit,
.character:not(.no-image) .placeholder-figure {
  display: none;
}

.placeholder-figure {
  width: 42%;
  height: auto;
  fill: #9397a0;
  opacity: 0.9;
}


.overlay {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px;
  color: var(--text-on-photo);
}

.overlay-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.overlay-top-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.overlay-top-left .time {
  font-size: 20px;
  font-weight: 700;
}

.past-label {
  display: none;
  margin-left: 4px;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 500;
  vertical-align: middle;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 6px;
}

.panel.is-past .past-label {
  display: inline-block;
}

.panel.is-past .bg {
  filter: grayscale(0.6);
}

.overlay-top-left .temp {
  font-size: 15px;
}

.overlay-top-left .feels {
  font-size: 13px;
  opacity: 0.9;
}

.overlay-top-left .issued {
  font-size: 11px;
  opacity: 0.75;
}

.overlay-top-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.badge {
  appearance: none;
  border: 1px solid transparent;
  font: inherit;
  cursor: pointer;
  background: var(--badge-bg);
  color: #fff;
  font-size: 12px;
  padding: 4px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.badge[aria-expanded='true'] {
  border-color: rgba(255, 255, 255, 0.9);
}

.badge:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.badge-detail {
  position: absolute;
  top: 100px;
  left: 16px;
  right: 16px;
  z-index: 2;
  margin: 0;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 13px;
  line-height: 1.45;
  border-radius: 12px;
}

.badge-detail[hidden] {
  display: none;
}

.badge-temp_range_dark {
  background: rgba(255, 110, 60, 0.75);
}

.badge-temp_range_light {
  background: rgba(255, 110, 60, 0.4);
}

.overlay-bottom {
  position: relative;
  margin: -16px;
  padding: 60px 16px 16px;
}

.overlay-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.65) 55%, rgba(0, 0, 0, 0.75) 100%);
  z-index: 0;
}

.core-sentence,
.item-names,
.group-suggestions {
  position: relative;
  z-index: 1;
}

.core-sentence {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 700;
}

/* 다시 계산해서 착장이 바뀐 경우에만 잠깐 강조한다 */
.core-sentence.is-changed {
  border-radius: 6px;
  animation: core-changed 1.6s ease-out;
}

@keyframes core-changed {
  0%,
  35% {
    background-color: rgba(47, 111, 237, 0.85);
    box-shadow: 0 0 0 4px rgba(47, 111, 237, 0.85);
  }
  100% {
    background-color: rgba(47, 111, 237, 0);
    box-shadow: 0 0 0 4px rgba(47, 111, 237, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .core-sentence.is-changed {
    animation: none;
  }
}

.item-names {
  margin: 0 0 10px;
  font-size: 13px;
  opacity: 0.85;
}

.group-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  appearance: none;
  border: none;
  background: var(--chip-bg);
  color: var(--chip-text);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
}

/* 낮은 패널(작은 화면, 카드·알림이 떠 있을 때)에서는 글자 영역을 줄여 캐릭터 자리를 남긴다. */
@container (max-height: 540px) {
  .overlay-bottom {
    padding: 40px 14px 10px;
  }

  .core-sentence {
    margin-bottom: 2px;
    font-size: 15px;
    line-height: 1.3;
  }

  .item-names {
    margin-bottom: 6px;
    font-size: 12px;
    line-height: 1.3;
  }

  .group-suggestions {
    gap: 4px;
  }

  .chip {
    padding: 4px 8px;
    font-size: 11px;
  }
}
