* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family:
    -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR",
    sans-serif;
  background: linear-gradient(180deg, #ffd6e7 0%, #c7e9ff 100%);
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-font-smoothing: antialiased;
}

.screen {
  height: 100vh;
  /* iOS Safari 주소창 변화 대응 */
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

#login-screen {
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: white;
  border-radius: 32px;
  padding: 32px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
  text-align: center;
  max-width: 360px;
  width: 100%;
}

.mascot {
  font-size: 80px;
  line-height: 1;
  animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.login-card h1 {
  font-size: 32px;
  margin: 12px 0 4px;
  color: #ff6b9d;
}

.subtitle {
  color: #888;
  font-size: 18px;
  margin: 0 0 24px;
}

.pin-display {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-bottom: 20px;
}

.pin-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 3px solid #ffd6e7;
  background: white;
  transition: background 0.2s;
}

.pin-dot.filled {
  background: #ff6b9d;
  border-color: #ff6b9d;
}

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.pin-key {
  font-size: 28px;
  font-weight: 600;
  background: #fff0f5;
  border: none;
  border-radius: 20px;
  padding: 20px 0;
  cursor: pointer;
  color: #555;
  transition: transform 0.1s, background 0.2s;
}

.pin-key:active {
  transform: scale(0.92);
  background: #ffd6e7;
}

.pin-back {
  background: #e8e8e8;
}

.pin-go {
  background: #ff6b9d;
  color: white;
}

.pin-error {
  color: #ff6b9d;
  font-size: 16px;
  margin: 16px 0 0;
  min-height: 20px;
}

#chat-screen {
  background: linear-gradient(180deg, #fff5f9 0%, #f0f8ff 100%);
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(16px + env(safe-area-inset-top)) 20px 16px;
  background: white;
  border-bottom: 3px solid #ffd6e7;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.chat-header .avatar {
  font-size: 36px;
}

.chat-header .title {
  font-size: 24px;
  font-weight: 700;
  color: #ff6b9d;
  flex: 1;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  padding: 8px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 12px;
  transition: background 0.15s;
}

.icon-btn:active {
  background: #ffeef4;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.bubble {
  max-width: 80%;
  padding: 14px 18px;
  border-radius: 22px;
  font-size: 20px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
  animation: pop-in 0.3s ease-out;
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.bubble.jjondegi {
  background: white;
  color: #333;
  align-self: flex-start;
  border-bottom-left-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.bubble.user {
  background: #ff6b9d;
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 6px;
}

.bubble.thinking {
  font-style: italic;
  color: #888;
  background: #f0f0f0;
}

.day-divider {
  align-self: center;
  font-size: 12px;
  color: #a08a95;
  background: rgba(255, 255, 255, 0.7);
  padding: 4px 14px;
  border-radius: 14px;
  margin: 6px 0 2px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.chat-input {
  display: flex;
  gap: 10px;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  background: white;
  border-top: 3px solid #ffd6e7;
}

.chat-input input {
  flex: 1;
  /* 16px 이상이어야 iOS Safari 가 focus 시 자동 줌 안 함 */
  font-size: 18px;
  padding: 14px 18px;
  border: 3px solid #ffd6e7;
  border-radius: 28px;
  outline: none;
  background: #fff5f9;
}

.chat-input input:focus {
  border-color: #ff6b9d;
}

#send-btn {
  font-size: 28px;
  background: #ff6b9d;
  color: white;
  border: none;
  border-radius: 50%;
  width: 56px;
  height: 56px;
  cursor: pointer;
  transition: transform 0.1s;
}

#send-btn:active {
  transform: scale(0.92);
}

#send-btn:disabled {
  opacity: 0.4;
}

/* 목소리 설정 패널 */
.voice-panel {
  background: linear-gradient(180deg, #fff8fb 0%, #fff 100%);
  border-bottom: 2px solid #ffd6e7;
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 15px;
  box-shadow: 0 4px 12px rgba(255, 107, 157, 0.08);
  animation: voice-slide-in 0.2s ease-out;
}

@keyframes voice-slide-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.voice-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 15px;
  font-weight: 700;
  color: #ff6b9d;
  margin-bottom: 2px;
}

.voice-close-x {
  background: transparent;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 22px;
  font-weight: 700;
  color: #999;
  cursor: pointer;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.voice-close-x:active {
  background: #ffeef4;
  color: #ff6b9d;
}

.voice-panel-current {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: white;
  border: 1px solid #ffe1ed;
  border-radius: 12px;
}

.voice-panel-current strong {
  color: #ff6b9d;
  word-break: break-word;
  font-size: 15px;
  flex: 1;
}

.voice-panel-label {
  color: #999;
  font-size: 13px;
  font-weight: 500;
}

#voice-select {
  width: 100%;
  /* 16px 이상이어야 iOS Safari 자동 줌 방지 */
  font-size: 16px;
  padding: 12px 14px;
  border: 2px solid #ffd6e7;
  border-radius: 12px;
  background: white;
  color: #333;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23ff6b9d' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

#voice-select:focus {
  border-color: #ff6b9d;
  outline: none;
}

.voice-test-btn {
  background: #ff6b9d;
  color: white;
  border: none;
  border-radius: 14px;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s;
}

.voice-test-btn:active {
  transform: scale(0.96);
}

.voice-panel-tip {
  font-size: 13px;
  color: #888;
  line-height: 1.55;
  margin: 4px 0 0;
  padding: 10px 12px;
  background: #f8f8fa;
  border-radius: 10px;
  border-left: 3px solid #ddd;
}

.voice-panel-tip.ok {
  background: #f0fbf4;
  border-left-color: #52c878;
  color: #2d6b3d;
}

.voice-panel-tip.warn {
  background: #fff8ec;
  border-left-color: #f4a742;
  color: #7a5418;
}

.voice-panel-tip b {
  color: inherit;
  font-weight: 700;
}

.voice-panel-tip:empty {
  display: none;
}
