/* 켜켜 공통 레이아웃 - 모바일 우선 */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--color-bg-app);
  color: var(--color-ink);
  font-family: var(--font-base);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

input, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

input:focus, textarea:focus {
  outline: none;
}

/* 앱 셸 - 모바일 폭 고정 (데스크탑에서도 모바일 폭으로) */
#app {
  position: relative;
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  margin: 0 auto;
  background: var(--color-bg-app);
  overflow-x: hidden;
}

/* 화면 컨테이너 - 탭바 영역만큼 하단 패딩 */
.screen {
  min-height: 100vh;
  padding-bottom: var(--tabbar-height);
  display: flex;
  flex-direction: column;
}

.screen.no-tab {
  padding-bottom: 0;
}

/* 화면 상단 헤더 */
.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  min-height: var(--header-height);
}

.screen-header .title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

/* 월 네비게이션 (좌/우 chevron + YYYY-MM) */
.month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  font-size: 16px;
  color: var(--color-ink);
}

.month-nav .month-label {
  font-size: 16px;
  font-weight: 600;
  min-width: 90px;
  text-align: center;
  color: var(--color-ink);
  letter-spacing: 0.3px;
}

/* 일 네비게이션 (v1.2.3 - 메모/장면 탭 일별 보기) */
.day-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  font-size: 16px;
  color: var(--color-ink);
}

.day-nav .day-label {
  font-size: 16px;
  font-weight: 700;
  min-width: 140px;
  text-align: center;
  color: var(--color-accent-deep);
  letter-spacing: 0.2px;
  cursor: pointer;
}

.day-nav .day-label:hover {
  color: var(--color-accent);
}

/* 공통 chevron 버튼 (월 네비, 디테일 헤더 등) */
.chev-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--color-ink-muted);
  background: transparent;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.chev-btn:hover {
  background: var(--color-tint);
  color: var(--color-accent-deep);
}

.chev-btn:active {
  background: var(--color-tint);
  color: var(--color-accent);
  transform: scale(0.92);
}

.chev-btn svg {
  display: block;
  pointer-events: none;
}

/* 하단 탭바 (v1.2.1: 아이콘 + 라벨 세로 정렬) */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--tabbar-height);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--color-bg-app);
  border-top: 1px solid var(--color-line);
  z-index: 100;
}

.tabbar a.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: var(--color-ink-muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: -0.2px;
  padding: 6px 0 4px;
}

.tabbar a.tab .tab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  color: inherit;
}

.tabbar a.tab .tab-label {
  line-height: 1;
}

.tabbar a.tab.active {
  color: var(--color-accent);
  font-weight: 700;
}

/* 빈 상태 */
.empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-ink-muted);
  font-size: 16px;
  padding: var(--space-8);
  text-align: center;
}

/* 플로팅 + 버튼 */
.fab {
  position: fixed;
  right: 50%;
  transform: translateX(220px);
  bottom: calc(var(--tabbar-height) + var(--space-5));
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-accent);
  font-size: 36px;
  font-weight: 300;
  line-height: 1;
  z-index: 50;
}

@media (max-width: 519px) {
  .fab {
    right: var(--space-5);
    transform: none;
  }
}

.fab:active { color: var(--color-accent-deep); }

/* 토스트 알럿 (저장/삭제 알림) */
.toast-overlay {
  position: fixed;
  inset: 0;
  background: var(--color-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.toast-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.toast {
  background: var(--color-bg-app);
  padding: var(--space-8) var(--space-6);
  width: 80%;
  max-width: 360px;
  border-radius: var(--radius-sm);
  text-align: center;
  position: relative;
}

.toast .message {
  font-size: 17px;
  color: var(--color-ink);
}

.toast .close {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  width: 28px;
  height: 28px;
  color: var(--color-ink-muted);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 텍스트 버튼 (헤더 우측 액션 등) */
.text-btn {
  font-size: 16px;
  color: var(--color-ink-muted);
  padding: var(--space-2) var(--space-3);
}

.text-btn.primary {
  color: var(--color-accent);
  font-weight: 600;
}

.text-btn.danger {
  color: var(--color-danger);
  font-weight: 600;
}

/* 보조 버튼 (메모 상세의 수정/삭제) */
.btn-outline {
  flex: 1;
  height: 48px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 500;
  color: var(--color-ink);
  background: var(--color-bg-app);
}

.btn-outline.danger { color: var(--color-danger); }
.btn-outline:active { background: var(--color-tint); }

/* 백 버튼 (헤더 좌측) */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 17px;
  font-weight: 600;
  color: var(--color-ink);
  padding: var(--space-2) 0;
}

/* 안전 영역 (iOS 노치 대응) */
@supports (padding: max(0px)) {
  .screen-header { padding-top: max(var(--space-4), env(safe-area-inset-top)); }
  .tabbar { padding-bottom: env(safe-area-inset-bottom); height: calc(var(--tabbar-height) + env(safe-area-inset-bottom)); }
}
