/* ==== 기본 리셋 ==== */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    scrollbar-gutter: stable;  /* 스크롤바 유무에 따라 .app 중앙정렬이 흔들리지 않게 */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
                 "Hiragino Sans", "Yu Gothic", "Meiryo",
                 "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
    background: #F4F5FB;
    color: #1F2333;
    -webkit-tap-highlight-color: transparent;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    max-width: 600px;
    margin: 0 auto;
    background: #FFFFFF;
}

/* ==== 헤더 ==== */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    background: linear-gradient(135deg, #5B6FED 0%, #8C6FED 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(91, 111, 237, 0.2);
    position: relative;
}
.tutor-info { display: flex; align-items: center; gap: 12px; }
.avatar {
    width: 42px; height: 42px;
    background: rgba(255,255,255,0.25);
    border-radius: 50%;
    display: grid; place-items: center;
    font-size: 22px;
}
.tutor-name { font-weight: 700; font-size: 16px; }
.tutor-status { font-size: 12px; opacity: 0.85; margin-top: 2px; }

.icon-btn {
    width: 36px; height: 36px;
    border: none; border-radius: 50%;
    background: rgba(255,255,255,0.2);
    color: white;
    font-size: 20px;
    cursor: pointer;
    transition: background 0.15s;
}
.icon-btn:hover { background: rgba(255,255,255,0.3); }

/* ==== 주제 선택 화면 ==== */
.topic-screen {
    flex: 1;
    padding: 24px 20px;
    overflow-y: auto;
}
.topic-screen h2 {
    font-size: 20px;
    margin-bottom: 6px;
}
.hint {
    color: #6B7280;
    font-size: 14px;
    margin-bottom: 24px;
}
.topic-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 28px;
}
.topic-card {
    background: #F8F9FE;
    border: 2px solid transparent;
    border-radius: 14px;
    padding: 18px 14px;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.topic-card:hover, .topic-card:active {
    border-color: #5B6FED;
    background: #EEF1FE;
}
.topic-emoji { font-size: 28px; margin-bottom: 8px; }
.topic-title-ko { font-weight: 700; font-size: 15px; margin-bottom: 2px; }
.topic-title-ja { font-size: 12px; color: #6B7280; }

.level-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: #F8F9FE;
    border-radius: 12px;
}
.level-row label { font-size: 14px; font-weight: 600; }
.level-row select {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #D5D8E5;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    background: white;
}

/* ==== 채팅 화면 ==== */
.chat-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.hidden { display: none !important; }

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #F4F5FB;
}

.message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 15px;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
    animation: pop 0.18s ease-out;
}
@keyframes pop {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.message.tutor {
    align-self: flex-start;
    background: white;
    border: 1px solid #E5E7F0;
    border-bottom-left-radius: 4px;
}
.message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #5B6FED 0%, #8C6FED 100%);
    color: white;
    border-bottom-right-radius: 4px;
}
.message.typing {
    color: #6B7280;
    font-style: italic;
}

/* ==== 입력창 ==== */
.input-form {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    background: white;
    border-top: 1px solid #E5E7F0;
}
#user-input {
    flex: 1;
    padding: 12px 14px;
    border: 1px solid #D5D8E5;
    border-radius: 22px;
    font-family: inherit;
    font-size: 15px;
    outline: none;
    transition: border-color 0.15s;
}
#user-input:focus { border-color: #5B6FED; }
#send-btn {
    padding: 0 20px;
    border: none;
    border-radius: 22px;
    background: #5B6FED;
    color: white;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
#send-btn:disabled { background: #B5BCDF; cursor: not-allowed; }
#send-btn:hover:not(:disabled) { background: #4A5DD8; }

/* ==== 모드 선택 토글 ==== */
.settings-row {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.setting-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: #F8F9FE;
    border-radius: 12px;
}
.setting-item label {
    font-size: 14px;
    font-weight: 600;
    min-width: 70px;
}
.setting-item select {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #D5D8E5;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    background: white;
}
.mode-toggle {
    flex: 1;
    display: flex;
    gap: 6px;
    background: white;
    border-radius: 8px;
    padding: 4px;
    border: 1px solid #D5D8E5;
}
.mode-btn {
    flex: 1;
    padding: 8px 10px;
    border: none;
    border-radius: 6px;
    background: transparent;
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s;
}
.mode-btn.active {
    background: linear-gradient(135deg, #5B6FED 0%, #8C6FED 100%);
    color: white;
    font-weight: 600;
}

/* ==== 통화 화면 ==== */
.call-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
    background: linear-gradient(180deg, #EEF1FE 0%, #F4F5FB 100%);
    text-align: center;
}
.call-avatar {
    width: 110px;
    height: 110px;
    background: linear-gradient(135deg, #5B6FED 0%, #8C6FED 100%);
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 56px;
    margin-bottom: 18px;
    box-shadow: 0 8px 24px rgba(91, 111, 237, 0.35);
    animation: breathe 3s ease-in-out infinite;
}
@keyframes breathe {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.05); }
}
.call-avatar.listening {
    animation: listening 1s ease-in-out infinite;
    background: linear-gradient(135deg, #ED5B8C 0%, #ED8C5B 100%);
    box-shadow: 0 8px 24px rgba(237, 91, 140, 0.45);
}
@keyframes listening {
    0%, 100% { transform: scale(1);    box-shadow: 0 8px 24px rgba(237, 91, 140, 0.45); }
    50%      { transform: scale(1.08); box-shadow: 0 12px 32px rgba(237, 91, 140, 0.65); }
}
.call-avatar.speaking {
    animation: speaking 0.6s ease-in-out infinite;
}
@keyframes speaking {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.04); }
}

.call-name {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 6px;
}
.call-status {
    font-size: 15px;
    color: #5B6FED;
    font-weight: 600;
    margin-bottom: 24px;
    min-height: 22px;
}

.caption {
    width: 100%;
    max-width: 480px;
    min-height: 80px;
    padding: 16px 18px;
    background: white;
    border-radius: 14px;
    font-size: 16px;
    line-height: 1.6;
    color: #1F2333;
    margin-bottom: 32px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    text-align: left;
    white-space: pre-wrap;
}
.caption:empty::before {
    content: "여기에 대화 내용이 표시돼요";
    color: #9CA3AF;
    font-style: italic;
}

.call-controls {
    display: flex;
    gap: 24px;
    margin-bottom: 18px;
}
.call-btn {
    width: 64px;
    height: 64px;
    border: none;
    border-radius: 50%;
    font-size: 26px;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.call-btn.mic {
    background: white;
    color: #5B6FED;
}
.call-btn.mic.active {
    background: #ED5B8C;
    color: white;
    animation: listening 1s ease-in-out infinite;
}
.call-btn.mic:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.call-btn.hangup {
    background: #EF4444;
    color: white;
    transform: rotate(135deg);
}
.call-btn.hangup:hover { background: #DC2626; }

.call-hint {
    font-size: 13px;
    color: #6B7280;
    min-height: 20px;
}
/* ==== 통화 받기 오버레이 ==== */
.call-accept {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, #5B6FED 0%, #8C6FED 100%);
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
    text-align: center;
    z-index: 10;
}
.call-accept-avatar {
    width: 130px;
    height: 130px;
    background: rgba(255,255,255,0.25);
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 64px;
    margin-bottom: 24px;
    animation: incoming 1.2s ease-in-out infinite;
}
@keyframes incoming {
    0%, 100% { transform: scale(1);    box-shadow: 0 0 0 0 rgba(255,255,255,0.5); }
    50%      { transform: scale(1.05); box-shadow: 0 0 0 24px rgba(255,255,255,0); }
}
.call-accept-name {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
}
.call-accept-sub {
    font-size: 16px;
    opacity: 0.9;
    margin-bottom: 48px;
}
.accept-btn {
    padding: 18px 36px;
    background: white;
    color: #5B6FED;
    border: none;
    border-radius: 40px;
    font-family: inherit;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    margin-bottom: 18px;
    transition: transform 0.1s;
}
.accept-btn:active { transform: scale(0.96); }
.call-accept-hint {
    font-size: 13px;
    opacity: 0.85;
    max-width: 280px;
    line-height: 1.5;
}

/* call-screen이 absolute 자식을 가지려면 relative 필요 */
.call-screen { position: relative; }

/* 단어 추출 모달 */
.vocab-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.vocab-modal-content {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  max-width: 480px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}
.vocab-modal-content h3 {
  margin: 0 0 16px;
  text-align: center;
  color: #7c5cff;
}
.vocab-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.vocab-card {
  background: #f7f5ff;
  border-left: 4px solid #7c5cff;
  padding: 12px 14px;
  border-radius: 8px;
}
.vocab-jp { font-size: 1.1rem; font-weight: 700; color: #333; }
.vocab-reading { font-size: 0.9rem; color: #888; margin-top: 2px; }
.vocab-ko { font-size: 0.95rem; color: #555; margin-top: 4px; }
.vocab-example { font-size: 0.85rem; color: #777; margin-top: 6px; font-style: italic; }
.vocab-close {
  margin-top: 16px;
  width: 100%;
  padding: 12px;
  background: #7c5cff;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  cursor: pointer;
}
.vocab-close:hover { background: #6a4dff; }

/* 학습 노트 화면 */
.notebook-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  overflow-y: auto;
  background: #fafaff;
}
.notebook-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.notebook-header h2 { margin: 0; color: #7c5cff; }
.notebook-back {
  background: #eee;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
}
.notebook-stats {
  background: #fff;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  text-align: center;
  font-size: 0.95rem;
  color: #555;
}
.notebook-stats strong { color: #7c5cff; font-size: 1.4rem; }
.notebook-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.notebook-empty {
  text-align: center;
  color: #999;
  padding: 40px 20px;
}


/* ============================================ */
/* 8-3 캐릭터 시스템 추가 스타일                 */
/* ============================================ */

/* ==== 헤더: 캐릭터 선택 시 사진 표시 ==== */
.header-avatar {
    width: 42px;
    height: 42px;
    background: rgba(255,255,255,0.25);
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 22px;
    overflow: hidden;
    flex-shrink: 0;
}
.header-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}
.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
}
.header-text {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
}
.header-name {
    font-weight: 700;
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}
.header-sub {
    font-size: 12px;
    opacity: 0.85;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}
.reset-btn {
    width: 36px; height: 36px;
    border: none; border-radius: 50%;
    background: rgba(255,255,255,0.2);
    color: white;
    font-size: 18px;
    cursor: pointer;
    margin-left: 6px;
    transition: background 0.15s;
}
.reset-btn:hover { background: rgba(255,255,255,0.3); }

/* ==== 연락처 화면 ==== */
.contacts-screen {
    flex: 1;
    padding: 24px 20px;
    overflow-y: auto;
}
.contacts-heading {
    font-size: 20px;
    margin-bottom: 6px;
}
.contacts-desc {
    color: #6B7280;
    font-size: 14px;
    margin-bottom: 24px;
}
.contacts-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.contact-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: #FFFFFF;
    border: 2px solid #E5E7F0;
    border-radius: 16px;
    padding: 14px;
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
    font-family: inherit;
    width: 100%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.03);
}
.contact-card:hover, .contact-card:active {
    border-color: var(--char-color, #5B6FED);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.08);
}

.contact-photo {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: #F4F5FB;
    position: relative;
    border: 3px solid var(--char-color, #5B6FED);
}
.contact-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.contact-emoji-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: white;
    display: grid;
    place-items: center;
    font-size: 14px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.contact-info { flex: 1; min-width: 0; }
.contact-name-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 2px;
}
.contact-name {
    font-weight: 700;
    font-size: 17px;
    color: #1F2333;
}
.contact-name-ko {
    font-size: 13px;
    color: #6B7280;
}
.contact-meta {
    font-size: 13px;
    color: #4B5563;
    margin-bottom: 4px;
}
.contact-interests {
    font-size: 12px;
    color: #6B7280;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.contact-call-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--char-color, #5B6FED);
    color: white;
    display: grid;
    place-items: center;
    font-size: 18px;
    flex-shrink: 0;
}

/* ==== 토픽 화면: 뒤로가기 + 캐릭터 정보 ==== */
.back-btn {
    background: none;
    border: none;
    color: #5B6FED;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 0;
    margin-bottom: 12px;
    font-family: inherit;
}
.back-btn:hover { text-decoration: underline; }

.topic-character-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: #F8F9FE;
    border-radius: 12px;
    margin-bottom: 18px;
    border-left: 4px solid var(--char-color, #5B6FED);
}
.topic-character-info img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.topic-character-info .info-text {
    font-size: 13px;
    color: #4B5563;
    line-height: 1.4;
}
.topic-character-info .info-text strong {
    color: #1F2333;
    font-size: 14px;
}

/* ==== 토픽 카드: 기존 selectors와 호환 (HTML이 .topics와 .topic-card 사용) ==== */
.topics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}
.topic-heading { font-size: 20px; margin-bottom: 6px; }
.topic-desc { color: #6B7280; font-size: 14px; margin-bottom: 20px; }

/* ==== 통화 화면: 캐릭터 사진 ==== */
.call-avatar {
    overflow: hidden;
    padding: 0;
    background: linear-gradient(135deg, #5B6FED 0%, #8C6FED 100%);
}
.call-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}
.call-avatar:not(:has(img[src])) img {
    display: none;
}
.call-sub {
    font-size: 13px;
    color: #6B7280;
    margin-bottom: 4px;
    min-height: 18px;
}

.call-accept-avatar {
    overflow: hidden;
    padding: 0;
}
.call-accept-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

/* 캐릭터별 통화 화면 배경 색상 (동적으로 var 변경) */
.call-screen {
    background: linear-gradient(180deg, var(--char-bg-light, #EEF1FE) 0%, #F4F5FB 100%);
}
.call-accept {
    background: linear-gradient(180deg, var(--char-color, #5B6FED) 0%, #8C6FED 100%);
}

/* ==== 통화 컨트롤 (mic-btn, hangup-btn) ==== */
.mic-btn, .hangup-btn {
    width: 64px;
    height: 64px;
    border: none;
    border-radius: 50%;
    font-size: 26px;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.mic-btn {
    background: white;
    color: #5B6FED;
}
.mic-btn.active {
    background: #ED5B8C;
    color: white;
    animation: listening 1s ease-in-out infinite;
}
.hangup-btn {
    background: #EF4444;
    color: white;
}
.hangup-btn:hover { background: #DC2626; }

.call-caption {
    width: 100%;
    max-width: 480px;
    min-height: 80px;
    padding: 16px 18px;
    background: white;
    border-radius: 14px;
    font-size: 16px;
    line-height: 1.6;
    color: #1F2333;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    text-align: left;
    white-space: pre-wrap;
}
.call-caption:empty::before {
    content: "여기에 대화 내용이 표시됩니다";
    color: #9CA3AF;
    font-style: italic;
}

/* ==== 채팅 화면 캐릭터 정보 ==== */
.chat-character-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #F8F9FE;
    border-bottom: 1px solid #E5E7F0;
}
.chat-character-info img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}
.chat-character-info .name {
    font-weight: 700;
    font-size: 14px;
}
.chat-character-info .sub {
    font-size: 12px;
    color: #6B7280;
}

/* ===== 9-2: 플래시카드 복습 모드 ===== */
.notebook-actions {
  display: flex;
  justify-content: center;
  margin: 12px 0;
}
.review-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 12px 32px;
  border-radius: 24px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
  transition: transform 0.15s, box-shadow 0.15s;
}
.review-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}
.review-btn:active {
  transform: translateY(0);
}

.flashcard-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: calc(60px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  padding: 20px;
}
.flashcard-screen.hidden {
  display: none;
}

.flashcard-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 4px 16px;
}
.flashcard-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #555;
  padding: 4px 12px;
}
.flashcard-progress {
  font-size: 16px;
  font-weight: 600;
  color: #555;
}

.flashcard {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1000px;
  margin: 16px 0;
  cursor: pointer;
}
.flashcard-face {
  width: 100%;
  max-width: 400px;
  min-height: 280px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.flashcard-face.hidden {
  display: none !important;
}
.flashcard-jp {
  font-size: 42px;
  font-weight: 700;
  color: #222;
  margin-bottom: 12px;
  word-break: keep-all;
}
.flashcard-reading {
  font-size: 22px;
  color: #888;
  margin-bottom: 24px;
}
.flashcard-ko {
  font-size: 32px;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 16px;
}
.flashcard-example {
  font-size: 18px;
  color: #555;
  line-height: 1.5;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: #f5f7fa;
  border-radius: 8px;
  width: 100%;
  box-sizing: border-box;
}
.flashcard-hint {
  font-size: 13px;
  color: #aaa;
  margin-top: auto;
}

.flashcard-actions {
  display: flex;
  gap: 12px;
  padding: 8px 4px 16px;
}
.flashcard-btn {
  flex: 1;
  padding: 16px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
}
.flashcard-no {
  background: #ffebee;
  color: #c62828;
}
.flashcard-yes {
  background: #e8f5e9;
  color: #2e7d32;
}
.flashcard-btn:active {
  transform: scale(0.97);
  opacity: 0.85;
}

.flashcard-result {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
  z-index: 10;
}
.flashcard-result.hidden {
  display: none;
}
.flashcard-result h2 {
  font-size: 32px;
  margin-bottom: 24px;
}
.result-summary {
  font-size: 22px;
  line-height: 1.6;
  margin-bottom: 16px;
  color: #333;
}
.result-summary strong {
  color: #667eea;
  font-size: 28px;
}
.result-rate {
  font-size: 18px;
  color: #555;
  margin-bottom: 32px;
}
.result-rate strong {
  color: #2e7d32;
  font-size: 24px;
}
.result-actions {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 400px;
}
.result-actions .flashcard-btn {
  background: white;
  color: #555;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.result-actions .flashcard-yes {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

/* === 9-3 복습 상태 표시 === */
.notebook-filters {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  flex-wrap: wrap;
  justify-content: center;
}
.filter-btn {
  padding: 6px 14px;
  border: 1px solid #4a90e2;
  background: white;
  color: #4a90e2;
  border-radius: 16px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.filter-btn.active {
  background: #4a90e2;
  color: white;
}
.filter-btn:hover {
  opacity: 0.85;
}

.vocab-card {
  position: relative;
}
.vocab-status {
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 18px;
}
.vocab-review-date {
  font-size: 11px;
  color: #888;
  margin-top: 6px;
  font-style: italic;
}
.vocab-card.status-known {
  border-left: 4px solid #4caf50;
}
.vocab-card.status-unknown {
  border-left: 4px solid #f44336;
}
.vocab-card.status-new {
  border-left: 4px solid #bbb;
}

/* === 9-3 복습 상태 표시 (보강) === */
.notebook-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 8px 0;
}
/* === B-2: 백업/복원 버튼 === */
.notebook-backup {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 8px 16px 12px;
}
.backup-btn, .restore-btn {
  flex: 1;
  max-width: 160px;
  padding: 8px 12px;
  border: 1px solid #7c5cff;
  background: #ffffff;
  color: #7c5cff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
}
.backup-btn:hover, .restore-btn:hover {
  background: #7c5cff;
  color: #ffffff;
}
.backup-btn:active, .restore-btn:active {
  transform: scale(0.97);
}
/* === B-3: JLPT 레벨 필터 + 뱃지 === */

/* JLPT 필터 줄 (작게) */
.notebook-filters-jlpt {
  margin-top: 4px;
}
.notebook-filters-jlpt .filter-btn {
  font-size: 12px;
  padding: 4px 10px;
  min-width: 44px;
}

/* JLPT 뱃지 (단어 카드 우상단) */
.vocab-jlpt {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  color: white;
  margin-left: 6px;
  letter-spacing: 0.5px;
  cursor: pointer;
  user-select: none;
  transition: transform 0.1s ease;
}
.vocab-jlpt:hover {
  transform: scale(1.1);
}
.vocab-jlpt.N5 { background: #4caf50; }   /* 초록 - 가장 쉬움 */
.vocab-jlpt.N4 { background: #2196f3; }   /* 파랑 */
.vocab-jlpt.N3 { background: #ff9800; }   /* 주황 */
.vocab-jlpt.N2 { background: #f44336; }   /* 빨강 */
.vocab-jlpt.N1 { background: #9c27b0; }   /* 보라 - 가장 어려움 */
.vocab-jlpt.unknown { background: #999; } /* 회색 - 미분류 */

/* JLPT 변경 메뉴 (롱탭/우클릭 시) */
.jlpt-menu {
  position: fixed;
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  padding: 6px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 120px;
}
.jlpt-menu-title {
  font-size: 12px;
  color: #666;
  text-align: center;
  padding: 4px 0;
  border-bottom: 1px solid #eee;
  margin-bottom: 4px;
}
.jlpt-menu button {
  padding: 6px 10px;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  border-radius: 4px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.jlpt-menu button:hover {
  background: #f0f0f0;
}
.jlpt-menu .jlpt-color {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
}
.jlpt-menu .jlpt-color.N5 { background: #4caf50; }
.jlpt-menu .jlpt-color.N4 { background: #2196f3; }
.jlpt-menu .jlpt-color.N3 { background: #ff9800; }
.jlpt-menu .jlpt-color.N2 { background: #f44336; }
.jlpt-menu .jlpt-color.N1 { background: #9c27b0; }
.jlpt-menu .jlpt-color.unknown { background: #999; }
/* === B-4: 통화 기록 화면 === */
.history-screen {
  position: fixed;
  inset: 0;
  background: #f5f5f7;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.history-screen.hidden { display: none !important; }

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: white;
  border-bottom: 1px solid #e5e5e7;
  position: sticky;
  top: 0;
  z-index: 10;
}
.history-header h2 { margin: 0; font-size: 18px; }
.history-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #666;
  padding: 4px 8px;
}

.history-toolbar {
  padding: 12px 16px;
  background: white;
  border-bottom: 1px solid #e5e5e7;
}
.history-clear-btn {
  padding: 8px 14px;
  background: white;
  border: 1px solid #f44336;
  color: #f44336;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.history-clear-btn:hover { background: #f44336; color: white; }

.history-empty {
  text-align: center;
  padding: 60px 20px;
  color: #999;
  font-size: 14px;
  line-height: 1.6;
}
.history-empty.hidden { display: none !important; }

.history-list {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.history-card {
  background: white;
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.history-card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}
.history-card-meta {
  font-size: 12px;
  color: #666;
}
.history-card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.history-card-actions button {
  flex: 1;
  min-width: 60px;
  padding: 6px 8px;
  font-size: 12px;
  background: white;
  border: 1px solid #ddd;
  border-radius: 6px;
  cursor: pointer;
}
.history-card-actions button:hover { background: #f0f0f0; }
.history-delete { color: #f44336; border-color: #f44336 !important; }
.history-delete:hover { background: #ffebee !important; }

/* 상세 보기 */
.history-detail {
  position: fixed;
  inset: 0;  /* 뷰포트 전체 — z-index 1100으로 탭바 위 */
  background: white;
  z-index: 1100;
  display: flex;
  flex-direction: column;
}
.history-detail.hidden { display: none !important; }

.history-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: #7c5cff;
  color: white;
  position: sticky;
  top: 0;
}
.history-detail-title {
  font-size: 15px;
  font-weight: 600;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-detail-close {
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
}

.history-detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-msg {
  max-width: 80%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
}
.history-msg-time {
  font-size: 10px;
  color: #999;
  margin-bottom: 2px;
}
.history-msg-user {
  align-self: flex-end;
  background: #7c5cff;
  color: white;
}
.history-msg-user .history-msg-time { color: rgba(255,255,255,0.7); }
.history-msg-tutor {
  align-self: flex-start;
  background: #e5e5ea;
  color: #000;
}
.history-msg-ai {
  align-self: flex-start;
  background: #e5e5ea;
  color: #000;
}
/* ============================================================
   A-1: 로그인 화면 스타일
   ============================================================ */

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: linear-gradient(135deg, #FFE5EC 0%, #FFC2D4 50%, #FFA5C0 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-screen.hidden {
  display: none !important;
}

.auth-container {
  background: #fff;
  border-radius: 24px;
  padding: 36px 28px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(255, 100, 150, 0.25);
  text-align: center;
}

.auth-logo {
  font-size: 56px;
  margin-bottom: 8px;
}

.auth-container h1 {
  margin: 0 0 8px 0;
  font-size: 24px;
  color: #333;
}

.auth-subtitle {
  color: #888;
  font-size: 13px;
  margin: 0 0 24px 0;
  line-height: 1.5;
}

.auth-error {
  background: #FFE5E5;
  color: #C62828;
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 13px;
  border-left: 4px solid #E74C3C;
  text-align: left;
}

.auth-container input[type="email"],
.auth-container input[type="password"] {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid #F0F0F0;
  border-radius: 12px;
  font-size: 15px;
  margin-bottom: 12px;
  box-sizing: border-box;
  transition: border-color 0.2s;
}

.auth-container input:focus {
  outline: none;
  border-color: #FF6B9D;
}

.auth-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
  transition: transform 0.1s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.auth-btn:active {
  transform: scale(0.98);
}

.auth-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.auth-btn-primary {
  background: linear-gradient(135deg, #FF6B9D 0%, #FF8FA3 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(255, 107, 157, 0.35);
}

.auth-btn-primary:hover:not(:disabled) {
  box-shadow: 0 6px 20px rgba(255, 107, 157, 0.45);
}

.auth-btn-google {
  background: #fff;
  color: #444;
  border: 2px solid #E0E0E0;
}

.auth-btn-google:hover:not(:disabled) {
  background: #F8F8F8;
  border-color: #BBB;
}

.google-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4285F4, #34A853, #FBBC05, #EA4335);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.auth-divider {
  display: flex;
  align-items: center;
  margin: 18px 0;
  color: #BBB;
  font-size: 12px;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #E5E5E5;
}

.auth-divider span {
  padding: 0 12px;
}

.auth-links {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth-link-btn {
  background: none;
  border: none;
  color: #FF6B9D;
  font-size: 13px;
  cursor: pointer;
  padding: 6px;
  text-decoration: underline;
}

.auth-link-btn:hover {
  color: #E91E63;
}

.auth-footer {
  margin-top: 20px;
  font-size: 11px;
  color: #999;
  line-height: 1.6;
}

.auth-footer a {
  color: #FF6B9D;
  text-decoration: none;
}

.auth-footer a:hover {
  text-decoration: underline;
}

/* ===== 헤더의 사용자 정보 영역 ===== */
.user-info-area {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 14px;
  font-size: 12px;
}

.user-info-area.hidden {
  display: none;
}

.user-email-label {
  color: #666;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.signout-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 4px 6px;
  border-radius: 8px;
  transition: background 0.2s;
}

.signout-btn:hover {
  background: rgba(255, 100, 150, 0.15);
}

/* ===== 로그인 전 + 게스트 모드 아닐 때만 메인 앱을 가림 ===== */
body:not(.authenticated):not(.guest-mode) .app-main {
  display: none;
}
/* ============================================================
   A-1: 로그인 화면 & 사용자 정보 영역
   ============================================================ */

/* 로그인 안 된 상태에서 메인 앱 숨김 */
body:not(.authenticated):not(.guest-mode) .app-main,
body:not(.authenticated):not(.guest-mode) .header {
  display: none !important;
}

/* 로그인 후에는 auth-screen 항상 숨김 */
body.authenticated #auth-screen {
  display: none !important;
}

/* 게스트 모드: hidden 클래스가 있을 때만 숨김 (모달 호출 시 표시 가능) */
body.guest-mode #auth-screen.hidden {
  display: none !important;
}

/* 로그인 화면 */
.auth-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ffeef2 0%, #fff5e6 100%);
  z-index: 9999;
  padding: 20px;
  overflow-y: auto;
}

.auth-container {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 20px;
  padding: 32px 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  text-align: center;
}

.auth-logo {
  font-size: 48px;
  margin-bottom: 8px;
}

#auth-title {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 8px 0;
  color: #333;
}

.auth-subtitle {
  font-size: 13px;
  color: #777;
  margin: 0 0 24px 0;
  line-height: 1.5;
}

.auth-error {
  background: #fee;
  color: #c33;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  text-align: left;
}

.auth-screen input[type="email"],
.auth-screen input[type="password"] {
  width: 100%;
  padding: 13px 14px;
  border: 1.5px solid #e5e5e5;
  border-radius: 10px;
  font-size: 15px;
  margin-bottom: 10px;
  box-sizing: border-box;
  transition: border-color 0.2s;
}

.auth-screen input:focus {
  outline: none;
  border-color: #ff7eb3;
}

.auth-btn {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
  transition: transform 0.1s, box-shadow 0.2s;
}

.auth-btn:active {
  transform: scale(0.98);
}

.auth-btn-primary {
  background: linear-gradient(135deg, #ff7eb3, #ff6b9d);
  color: #fff;
}

.auth-btn-primary:hover {
  box-shadow: 0 4px 12px rgba(255, 107, 157, 0.3);
}

.auth-btn-google {
  background: #fff;
  color: #444;
  border: 1.5px solid #e5e5e5;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.auth-btn-google:hover {
  border-color: #bbb;
  background: #fafafa;
}

.google-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4285f4, #34a853);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
}

.auth-divider {
  position: relative;
  margin: 18px 0;
  font-size: 12px;
  color: #aaa;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: #e5e5e5;
}

.auth-divider::before { left: 0; }
.auth-divider::after { right: 0; }

.auth-divider span {
  background: #fff;
  padding: 0 10px;
}

.auth-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 18px;
}

.auth-link-btn {
  background: none;
  border: none;
  color: #ff6b9d;
  font-size: 13px;
  cursor: pointer;
  padding: 4px;
}

.auth-link-btn:hover {
  text-decoration: underline;
}

.auth-footer {
  font-size: 11px;
  color: #999;
  margin-top: 20px;
  line-height: 1.5;
}

.auth-footer a {
  color: #ff6b9d;
  text-decoration: none;
}

/* 헤더 사용자 정보 영역 */
.user-info-area {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.user-info-area.hidden {
  display: none;
}

.user-email-label {
  font-size: 12px;
  color: #666;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.signout-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.15s;
}

.signout-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

/* 모바일 대응 */
@media (max-width: 480px) {
  .auth-container { padding: 24px 18px; }
  #auth-title { font-size: 20px; }
  .user-email-label { max-width: 90px; font-size: 11px; }
}
/* ============================================================
   동기화 상태 인디케이터 (A-1-5-4)
   ============================================================ */
.sync-indicator {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.2s;
  margin: 0 4px;
}

.sync-indicator:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(1.1);
}

.sync-indicator:active {
  transform: scale(0.95);
}

/* 동기화 중일 때 회전 애니메이션 */
.sync-indicator.syncing {
  animation: sync-spin 1.2s linear infinite;
}

@keyframes sync-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* 상태별 색상 */
.sync-indicator.idle    { opacity: 0.7; }
.sync-indicator.pending { opacity: 1.0; }
.sync-indicator.syncing { opacity: 1.0; }
.sync-indicator.error   { background: rgba(255, 80, 80, 0.3); }

/* ==== 헤더 액션 영역 (니혼고 센세 리뉴얼) ==== */
.header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    position: relative;
}

/* ↺ (대화 초기화) 버튼은 통화 중에만 표시 */
#reset-btn { display: none; }
body.in-call #reset-btn { display: inline-flex; align-items: center; justify-content: center; }
.header-actions .reset-btn {
    margin-left: 0;
    width: 34px;
    height: 34px;
    font-size: 16px;
}
.user-info-area {
    display: flex;
    align-items: center;
    gap: 4px;
    position: relative;
}
.user-info-area.hidden { display: none; }

.sync-indicator {
    width: 34px; height: 34px;
    border: none; border-radius: 50%;
    background: rgba(255,255,255,0.2);
    color: white;
    font-size: 14px;
    cursor: pointer;
}
.sync-indicator:hover { background: rgba(255,255,255,0.3); }

.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: white;
    color: #333;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    padding: 12px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.user-menu-dropdown.hidden { display: none; }
.user-menu-email {
    font-size: 13px;
    color: #666;
    word-break: break-all;
    padding: 4px 8px;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
}
.user-menu-signout {
    background: #f5f5f5;
    border: none;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    cursor: pointer;
    text-align: left;
    color: #333;
}
.user-menu-signout:hover { background: #e8e8e8; }

.user-menu-divider {
    border: none;
    border-top: 1px solid #eee;
    margin: 4px 0;
}
.user-menu-delete {
    background: #fff5f5;
    border: none;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    cursor: pointer;
    text-align: left;
    color: #d32f2f;
    font-weight: 600;
    transition: background 0.15s, color 0.15s;
    font-family: inherit;
}
.user-menu-delete:hover {
    background: #ffebee;
    color: #b71c1c;
}
.user-menu-delete:active {
    background: #ffcdd2;
}

/* Day 6: 동의 관리 메뉴 버튼 */
.user-menu-consent {
    background: #f0f7ff;
    border: none;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    cursor: pointer;
    text-align: left;
    color: #1976d2;
    font-weight: 600;
    transition: background .15s, color .15s;
    font-family: inherit;
    width: 100%;
}
.user-menu-consent:hover { background: #e3f2fd; color: #0d47a1; }
.user-menu-consent:active { background: #bbdefb; }

/* 좁은 모바일 화면 대응 */
@media (max-width: 480px) {
    .header { padding: 10px 12px; gap: 8px; }
    .header-actions .reset-btn,
    .sync-indicator { width: 32px; height: 32px; font-size: 15px; }
    .header-actions { gap: 2px; }
    .header-name { font-size: 15px; }
    .header-sub { font-size: 11px; }
    .header-avatar { width: 38px; height: 38px; font-size: 20px; }
}
@media (max-width: 380px) {
    .header-sub { display: none; }  /* 매우 좁은 화면에서는 부제목 숨김 */
    .header-actions .reset-btn,
    .sync-indicator { width: 30px; height: 30px; font-size: 14px; }
}


/* ===== 약관 동의 모달 (Day 4 추가) ===== */
.consent-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 20px;
  animation: consent-fade-in 0.25s ease-out;
}
.consent-modal.hidden {
  display: none;
}
@keyframes consent-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.consent-modal-content {
  background: #fff;
  border-radius: 18px;
  padding: 28px 24px;
  max-width: 480px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
  animation: consent-slide-up 0.3s ease-out;
}
@keyframes consent-slide-up {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.consent-title {
  margin: 0 0 8px;
  text-align: center;
  color: #7c5cff;
  font-size: 22px;
  font-weight: 700;
}
.consent-subtitle {
  margin: 0 0 20px;
  text-align: center;
  color: #666;
  font-size: 14px;
  line-height: 1.5;
}
.consent-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.consent-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: #f7f5ff;
  border: 1px solid #e8e3ff;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.consent-item:hover {
  background: #efebff;
  border-color: #d4ccff;
}
.consent-item input[type="checkbox"] {
  margin-top: 3px;
  width: 18px;
  height: 18px;
  accent-color: #7c5cff;
  cursor: pointer;
  flex-shrink: 0;
}
.consent-label {
  font-size: 14px;
  color: #333;
  line-height: 1.5;
  flex: 1;
}
.consent-label a {
  color: #7c5cff;
  text-decoration: underline;
  font-weight: 600;
}
.consent-label a:hover {
  color: #5b3fd9;
}
.consent-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  margin-right: 6px;
  vertical-align: middle;
}
.consent-badge.required {
  background: #ff5b6b;
  color: #fff;
}
.consent-badge.optional {
  background: #95a5b8;
  color: #fff;
}
.consent-all-item {
  margin-top: 4px;
  margin-bottom: 18px;
  padding: 14px;
  background: #fff8e7;
  border: 2px solid #ffd966;
  border-radius: 10px;
}
.consent-all-item:hover {
  background: #fff3d4;
  border-color: #ffc933;
}
.consent-all-item .consent-label {
  font-size: 15px;
  color: #5a4a1f;
}
.consent-buttons {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}
.consent-btn {
  flex: 1;
  padding: 13px 16px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
  font-family: inherit;
}
.consent-btn:active {
  transform: scale(0.98);
}
.consent-btn-cancel {
  background: #f0f0f3;
  color: #666;
}
.consent-btn-cancel:hover {
  background: #e3e3e8;
}
.consent-btn-agree {
  background: linear-gradient(135deg, #7c5cff 0%, #9b7eff 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(124, 92, 255, 0.3);
}
.consent-btn-agree:hover:not(:disabled) {
  background: linear-gradient(135deg, #6b4ae8 0%, #8a6bee 100%);
  box-shadow: 0 6px 16px rgba(124, 92, 255, 0.4);
}
.consent-btn-agree:disabled {
  background: #c8c0e8;
  color: #fff;
  cursor: not-allowed;
  opacity: 0.6;
  box-shadow: none;
}
.consent-notice {
  margin: 14px 0 0;
  text-align: center;
  font-size: 12px;
  color: #999;
  line-height: 1.5;
}

/* 모바일 반응형 */
@media (max-width: 480px) {
  .consent-modal {
    padding: 12px;
  }
  .consent-modal-content {
    padding: 22px 18px;
    max-height: 92vh;
  }
  .consent-title {
    font-size: 19px;
  }
  .consent-subtitle {
    font-size: 13px;
  }
  .consent-label {
    font-size: 13px;
  }
  .consent-btn {
    padding: 12px;
    font-size: 14px;
  }
}


/* ===== Day 6: 동의 관리 모달 (consent-settings-modal) ===== */
.consent-settings-content { max-width: 460px; }
.consent-settings-content .consent-modal-subtitle {
    color: #666;
    font-size: 14px;
    margin-bottom: 16px;
}
.cs-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}
.cs-item:last-of-type { border-bottom: none; }
.cs-item-label {
    flex: 1;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}
.cs-item-status {
    color: #555;
    font-size: 13px;
    min-width: 80px;
    text-align: right;
}
.cs-mini-btn {
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    color: #888;
    cursor: pointer;
    font-family: inherit;
}
.cs-mini-btn:hover { background: #eee; color: #555; }

/* 토글 스위치 */
.cs-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}
.cs-toggle input { opacity: 0; width: 0; height: 0; }
.cs-toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #ccc;
    border-radius: 24px;
    transition: .25s;
}
.cs-toggle-slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: .25s;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.cs-toggle input:checked + .cs-toggle-slider { background: #4caf50; }
.cs-toggle input:checked + .cs-toggle-slider::before { transform: translateX(20px); }

.cs-item-marketing { gap: 12px; }
.cs-item-feedback {
    font-size: 12px;
    color: #4caf50;
    min-width: 60px;
    text-align: right;
}

.cs-meta {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #eee;
    font-size: 12px;
    color: #888;
    text-align: center;
}

@media (max-width: 480px) {
    .cs-item-status { min-width: 60px; font-size: 12px; }
    .cs-item-label { font-size: 13px; }
    .cs-mini-btn { padding: 4px 8px; font-size: 11px; }
}

/* ====== 인앱 브라우저 안내 배너 (KakaoTalk, FB, IG, Line 등) ====== */
.auth-inapp-banner {
  background: linear-gradient(135deg, #fff7e0 0%, #ffe9b3 100%);
  color: #5a3e00;
  border: 1px solid #ffb84d;
  border-left: 4px solid #ff9500;
  border-radius: 10px;
  padding: 14px 16px;
  margin: 12px 0;
  font-size: 14px;
  line-height: 1.6;
  text-align: left;
  box-shadow: 0 2px 8px rgba(255, 149, 0, 0.15);
}

.auth-inapp-banner-title {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.auth-inapp-banner-body {
  color: #6a4a00;
  margin-bottom: 8px;
}

.auth-inapp-banner-steps {
  margin: 8px 0 0 0;
  padding-left: 20px;
  color: #5a3e00;
}

.auth-inapp-banner-steps li {
  margin-bottom: 4px;
}

.auth-inapp-banner-close {
  background: transparent;
  border: 1px solid #ff9500;
  color: #5a3e00;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  margin-top: 6px;
}

.auth-inapp-banner-close:hover {
  background: #ff9500;
  color: white;
}


/* ====== 인앱 브라우저 안내 배너 (KakaoTalk, FB, IG 등) ====== */
.auth-inapp-banner {
  background: linear-gradient(135deg, #fff7e0 0%, #ffe9b3 100%);
  color: #5a3e00;
  border: 1px solid #ffb84d;
  border-left: 4px solid #ff9500;
  border-radius: 10px;
  padding: 14px 16px;
  margin: 12px 0;
  font-size: 14px;
  line-height: 1.6;
  text-align: left;
  box-shadow: 0 2px 8px rgba(255, 149, 0, 0.15);
}

.auth-inapp-banner-title {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.auth-inapp-banner-body {
  color: #6a4a00;
  margin-bottom: 8px;
}

.auth-inapp-banner-steps {
  margin: 8px 0 0 0;
  padding-left: 20px;
  color: #5a3e00;
}

.auth-inapp-banner-steps li {
  margin-bottom: 4px;
}

.auth-inapp-banner-close {
  background: transparent;
  border: 1px solid #ff9500;
  color: #5a3e00;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  margin-top: 6px;
}

.auth-inapp-banner-close:hover {
  background: #ff9500;
  color: white;
}
/* ============================================================ */
/* Fix M: 초기 로딩 오버레이 (Firebase 인증 복원 중 깜빡임 방지) */
/* ============================================================ */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  transition: opacity 0.3s ease-out;
}
#loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #f0f0f0;
  border-top-color: #ff6b9d;
  border-radius: 50%;
  animation: loading-spin 0.9s linear infinite;
}
.loading-text {
  margin-top: 16px;
  color: #666;
  font-size: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
@keyframes loading-spin {
  to { transform: rotate(360deg); }
}


/* ===== 신규 사용자 환영 가이드 모달 (v1.1 - 켄타 강조형) ===== */
.welcome-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}

.welcome-modal.hidden {
  display: none;
}

.welcome-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(3px);
}

.welcome-modal-content {
  position: relative;
  background: linear-gradient(180deg, #fdfbff 0%, #ffffff 100%);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 420px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  padding: 28px 22px 20px;
  animation: welcomeFadeIn 0.4s ease-out;
  text-align: center;
}

@keyframes welcomeFadeIn {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.welcome-close-btn {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  font-size: 28px;
  line-height: 1;
  color: #aaa;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 50%;
  transition: background 0.2s, color 0.2s;
}

.welcome-close-btn:hover {
  background: #f0f0f0;
  color: #333;
}

/* --- 헤더 --- */
.welcome-header {
  margin-bottom: 20px;
}

.welcome-emoji {
  font-size: 36px;
  margin-bottom: 6px;
}

.welcome-header h2 {
  font-size: 19px;
  margin: 4px 0 8px;
  color: #1a1a1a;
  font-weight: 700;
}

.welcome-subtitle {
  font-size: 13px;
  color: #666;
  line-height: 1.6;
  margin: 0;
}

/* --- 메인 켄타 카드 --- */
.welcome-main-char {
  position: relative;
  background: linear-gradient(135deg, #e8f7ff 0%, #f0faff 100%);
  border: 3px solid #4FC3F7;
  border-radius: 18px;
  padding: 18px 16px 14px;
  margin: 0 auto 14px;
  max-width: 280px;
  box-shadow: 0 4px 16px rgba(79, 195, 247, 0.2);
}

.welcome-recommend-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: #4FC3F7;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 12px;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(79, 195, 247, 0.4);
}

.welcome-main-img {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  object-fit: cover;
  margin: 8px auto 10px;
  border: 4px solid #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: block;
}

.welcome-main-name {
  font-size: 18px;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 2px;
}

.welcome-main-age {
  font-size: 13px;
  font-weight: 400;
  color: #888;
  margin-left: 2px;
}

.welcome-main-level {
  font-size: 12px;
  color: #0288d1;
  font-weight: 700;
  margin-bottom: 4px;
}

.welcome-main-desc {
  font-size: 12px;
  color: #555;
  line-height: 1.4;
}

/* --- 버튼 --- */
.welcome-btn {
  width: 100%;
  padding: 13px 16px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: transform 0.1s, opacity 0.15s, box-shadow 0.2s;
  margin-bottom: 8px;
}

.welcome-btn:active {
  transform: scale(0.98);
}

.welcome-btn-primary {
  background: linear-gradient(135deg, #4FC3F7 0%, #29B6F6 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(79, 195, 247, 0.35);
}

.welcome-btn-primary:hover {
  box-shadow: 0 6px 16px rgba(79, 195, 247, 0.5);
}

.welcome-btn-secondary {
  background: #fff;
  color: #555;
  border: 1.5px solid #ddd;
  margin-top: 4px;
}

.welcome-btn-secondary:hover {
  background: #f8f8f8;
  border-color: #bbb;
}

/* --- 구분선 --- */
.welcome-divider {
  display: flex;
  align-items: center;
  margin: 18px 0 12px;
  color: #999;
  font-size: 12px;
}

.welcome-divider::before,
.welcome-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #e5e5e5;
}

.welcome-divider span {
  padding: 0 12px;
}

/* --- 작은 캐릭터 3명 --- */
.welcome-mini-chars {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.welcome-mini-char {
  background: #fafafa;
  border: 1.5px solid #eee;
  border-radius: 12px;
  padding: 10px 6px 8px;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
  font-family: inherit;
}

.welcome-mini-char:hover {
  border-color: #b39ddb;
  background: #f8f5ff;
  transform: translateY(-2px);
}

.welcome-mini-char:active {
  transform: translateY(0);
}

.welcome-mini-char img {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 6px;
  border: 2px solid #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.welcome-mini-name {
  font-size: 12px;
  font-weight: 600;
  color: #333;
  margin-bottom: 2px;
  line-height: 1.2;
}

.welcome-mini-level {
  font-size: 10px;
  color: #7c5cff;
  font-weight: 600;
}

/* --- 다시 듣기 버튼 --- */
.welcome-replay-btn {
  display: block;
  margin: 8px auto 0;
  background: none;
  border: none;
  color: #888;
  font-size: 12px;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}

.welcome-replay-btn:hover {
  background: #f5f5f5;
  color: #333;
}

/* --- 모바일 대응 --- */
@media (max-width: 420px) {
  .welcome-modal-content {
    padding: 24px 18px 16px;
    border-radius: 16px;
  }
  .welcome-header h2 {
    font-size: 17px;
  }
  .welcome-main-img {
    width: 96px;
    height: 96px;
  }
  .welcome-main-name {
    font-size: 16px;
  }
  .welcome-mini-char img {
    width: 44px;
    height: 44px;
  }
  .welcome-mini-name {
    font-size: 11px;
  }
}

/* ============================================================
   Guest Mode UI (2026-06-15 추가)
   ============================================================ */

/* 게스트 전용 로그인 버튼 (헤더) - 기본은 숨김 */
.guest-login-btn {
  display: none;
  padding: 8px 14px;
  background: linear-gradient(135deg, #ff6b9d 0%, #c44569 100%);
  color: white;
  border: none;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(255, 107, 157, 0.3);
  transition: transform 0.15s, box-shadow 0.15s;
}

.guest-login-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255, 107, 157, 0.4);
}

.guest-login-btn:active {
  transform: translateY(0);
}

/* 게스트 모드에서만 로그인 버튼 표시 */
body.guest-mode .guest-login-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* auth-screen을 모달처럼 띄울 때 닫기 버튼 */
.auth-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  background: rgba(0, 0, 0, 0.05);
  border: none;
  border-radius: 50%;
  font-size: 18px;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.auth-close-btn:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #333;
}

.auth-close-btn.hidden {
  display: none;
}

/* auth-container를 모달처럼 보이게 (게스트 모드에서 띄울 때) */
body.guest-mode #auth-screen .auth-container {
  position: relative;
  max-width: 420px;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

/* 가입 유도 안내 메시지 (선택적) */
.signup-prompt-message {
  background: linear-gradient(135deg, #fff5e6 0%, #ffeef2 100%);
  border-radius: 12px;
  padding: 12px 16px;
  margin: 0 0 16px 0;
  font-size: 14px;
  color: #c44569;
  text-align: center;
  font-weight: 500;
  border: 1px solid rgba(255, 107, 157, 0.2);
}

.signup-prompt-message.hidden {
  display: none;
}
/* ===== 게스트 모드 동의 모달 ===== */
.guest-consent-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.guest-consent-modal.hidden { display: none !important; }

.guest-consent-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
}

.guest-consent-container {
  position: relative;
  background: #fff;
  border-radius: 20px;
  max-width: 420px;
  width: 100%;
  padding: 28px 24px 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-height: 90vh;
  overflow-y: auto;
}

.guest-consent-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  background: #f0f0f0;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  color: #666;
}
.guest-consent-close:hover { background: #e0e0e0; }

.guest-consent-header { text-align: center; margin-bottom: 20px; }
.guest-consent-icon { font-size: 48px; margin-bottom: 8px; }
.guest-consent-header h2 { margin: 0 0 6px; font-size: 22px; color: #333; }
.guest-consent-subtitle { margin: 0; color: #888; font-size: 14px; }

.guest-consent-info {
  background: #f8f9fb;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.info-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 14px;
  color: #555;
}
.info-row span { font-size: 18px; }

.guest-consent-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  background: #fff8fa;
  border: 1px solid #ffd0e0;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.5;
}
.guest-consent-checkbox input { margin-top: 2px; flex-shrink: 0; }
.guest-consent-checkbox a { color: #e91e63; text-decoration: underline; }

.guest-consent-footer {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}
.guest-consent-footer button {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}
.btn-secondary {
  background: #f0f0f0;
  color: #666;
}
.btn-secondary:hover { background: #e0e0e0; }
.btn-primary {
  background: linear-gradient(135deg, #e91e63, #ff5e8a);
  color: #fff;
}
.btn-primary:disabled {
  background: #ccc;
  cursor: not-allowed;
}
.btn-primary:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(233, 30, 99, 0.4);
}

.guest-consent-signup-hint {
  margin-top: 14px;
  text-align: center;
  font-size: 12px;
  color: #888;
  padding: 8px;
}
/* ===== 게스트 타이머 30초 경고 ===== */
@keyframes guestTimerPulse {
  0%, 100% { 
    transform: scale(1); 
    box-shadow: 0 4px 12px rgba(233, 30, 99, 0.4); 
  }
  50% { 
    transform: scale(1.1); 
    box-shadow: 0 6px 24px rgba(220, 20, 60, 0.8); 
  }
}
#guest-timer.warning {
  background: linear-gradient(135deg, #d50000, #ff1744) !important;
  animation: guestTimerPulse 0.8s infinite;
}
/* ===== Welcome Modal: Compact Premium Info Boxes (2026-06-17) ===== */
.welcome-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;  /* 모든 화면에서 좌우 2단 강제 */
  gap: 8px;
  margin: 10px 0 12px;
}

.welcome-info-box {
  position: relative;
  padding: 10px 8px;
  border-radius: 12px;
  text-align: center;
  border: 1.5px solid transparent;
  background-clip: padding-box;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.welcome-info-trial {
  background: linear-gradient(135deg, #fff5f8, #ffe8ee);
  border-color: #ffb8d0;
  box-shadow: 0 2px 8px rgba(233, 30, 99, 0.1);
}

.welcome-info-premium {
  background: linear-gradient(135deg, #f5ecff, #ead7ff);
  border-color: #c89af0;
  box-shadow: 0 2px 10px rgba(147, 51, 234, 0.15);
}

.welcome-info-badge {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 11px;
  animation: sparkle 2s ease-in-out infinite;
}

@keyframes sparkle {
  0%, 100% { opacity: 0.6; transform: scale(1) rotate(0deg); }
  50% { opacity: 1; transform: scale(1.2) rotate(15deg); }
}

.welcome-info-icon {
  font-size: 18px;
  line-height: 1;
  margin-bottom: 2px;
}

.welcome-info-title {
  font-weight: 700;
  font-size: 12px;
  margin-bottom: 5px;
  letter-spacing: -0.3px;
  background-image: linear-gradient(135deg, #d63384, #ff7eb6);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.welcome-info-premium .welcome-info-title {
  background-image: linear-gradient(135deg, #7c2dc7, #b066f0);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.welcome-info-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 11px;
  color: #4a4a4a;
  line-height: 1.5;
  font-weight: 500;
}

.welcome-info-list li {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  white-space: nowrap;  /* 줄바꿈 방지 */
}

.welcome-info-list li::before {
  content: "◆";
  font-size: 6px;
  color: #d63384;
  flex-shrink: 0;
}

.welcome-info-premium .welcome-info-list li::before {
  color: #7c2dc7;
}

/* 환영 인사 버튼 (켄타 카드 아래) */
.welcome-replay-btn {
  display: block;
  margin: 8px auto 10px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  color: #7c2dc7;
  background: rgba(243, 232, 255, 0.7);
  border: 1.5px solid rgba(147, 51, 234, 0.25);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.welcome-replay-btn:hover {
  background: rgba(243, 232, 255, 1);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(147, 51, 234, 0.2);
}

/* 모달 자체 패딩 축소로 공간 확보 */
.welcome-modal-content {
  padding-top: 20px !important;
  padding-bottom: 16px !important;
}

/* 켄타 카드 영역 콤팩트 */
.welcome-main-char {
  padding: 12px 10px !important;
}
.welcome-main-img {
  width: 80px !important;
  height: 80px !important;
}
.welcome-main-desc {
  font-size: 11px !important;
  margin-top: 4px;
}

/* 부제목 콤팩트 */
.welcome-subtitle {
  font-size: 12px !important;
  margin: 4px 0 8px !important;
  line-height: 1.5 !important;
}

/* 모바일에서 더 축소 (~380px) */
@media (max-width: 380px) {
  .welcome-info-list {
    font-size: 10px;
  }
  .welcome-info-title {
    font-size: 11px;
  }
  .welcome-info-list li {
    white-space: normal;  /* 좁은 화면에서는 줄바꿈 허용 */
  }
}
/* ===== 켄타 이름 + 통화 버튼 한 줄 배치 (2026-06-17) ===== */
.welcome-main-name-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.welcome-main-name-row .welcome-main-name {
  margin: 0;
  white-space: nowrap;  /* "켄타 15세"가 한 묶음으로 유지 */
}

/* 📞 통화하기 버튼 - 그린 그라데이션 */
.welcome-call-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #34c759, #4cd964);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(52, 199, 89, 0.35);
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
  white-space: nowrap;
  letter-spacing: -0.3px;
}

.welcome-call-btn:hover {
  background: linear-gradient(135deg, #28a745, #34c759);
  transform: translateY(-1px) scale(1.03);
  box-shadow: 0 4px 14px rgba(52, 199, 89, 0.5);
}

.welcome-call-btn:active {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 2px 6px rgba(52, 199, 89, 0.3);
}

/* 통화 버튼 호버 시 살짝 떨림 효과로 클릭 유도 */
@keyframes callPulse {
  0%, 100% { box-shadow: 0 2px 8px rgba(52, 199, 89, 0.35); }
  50% { box-shadow: 0 2px 12px rgba(52, 199, 89, 0.55); }
}

.welcome-call-btn {
  animation: callPulse 2s ease-in-out infinite;
}

/* 모바일 콤팩트 */
@media (max-width: 480px) {
  .welcome-call-btn {
    font-size: 12px;
    padding: 5px 12px;
  }
}
/* ===== 켄타 이름 정렬 미세 조정 (2026-06-17) ===== */
.welcome-main-name-row {
  gap: 14px !important;
}

.welcome-main-name {
  white-space: nowrap;
  display: inline-block;
}

.welcome-main-name .welcome-main-age {
  margin-left: 4px;
}
/* ===== 켄타 이름 + 통화 버튼 시각적 그룹화 (2026-06-17 최종) ===== */
.welcome-main-name-row {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 10px !important;
  margin: 8px auto 0 !important;
  flex-wrap: nowrap !important;
  width: auto !important;
  max-width: 100% !important;
}

/* welcome-main-char(부모) 안에서 가운데 정렬 */
.welcome-main-char {
  text-align: center;
}

.welcome-main-name {
  margin: 0 !important;
  padding: 0 !important;
  white-space: nowrap !important;
  font-size: 18px !important;
  font-weight: 700 !important;
}

.welcome-main-age {
  font-size: 14px !important;
  color: #999 !important;
  font-weight: 500 !important;
  margin-left: 4px !important;
}

/* 통화 버튼 약간 더 강조 */
.welcome-call-btn {
  flex-shrink: 0 !important;
}

/* ===== 마스코트 로고 이미지 (2026-06-22 추가) ===== */
.welcome-emoji {
  /* 폰트 사이즈는 이모지 fallback용으로 남겨두되, 컨테이너 크기를 명시 */
  width: 56px;
  height: 56px;
  margin: 0 auto 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.welcome-emoji img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.auth-logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
/* .header-avatar img는 이미 line 552에 정의되어 있음 */
/* ===== Stage 5: <form> 래퍼는 레이아웃에 영향 없게 (display: contents) ===== */
.auth-form {
  display: contents;
}


/* === Patch 21: 단어장 발음 재생 버튼 === */
.vocab-jp, .vocab-japanese {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.vocab-example {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.vocab-speak-btn {
  background: transparent;
  border: 1px solid #d8d0ee;
  border-radius: 50%;
  width: 28px; height: 28px;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  color: #7c5fd3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.15s;
  flex-shrink: 0;
}
.vocab-speak-btn:hover {
  background: #f0eaff;
  transform: scale(1.08);
}
.vocab-speak-btn:active {
  transform: scale(0.95);
}
.vocab-speak-btn-sm {
  width: 22px; height: 22px;
  font-size: 11px;
  border-color: #e3dcf5;
}
.vocab-speak-btn.speaking {
  background: #7c5fd3;
  color: #fff;
  border-color: #7c5fd3;
  animation: vocabSpeakPulse 0.9s ease-in-out infinite;
}
@keyframes vocabSpeakPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(124, 95, 211, 0.5); }
  50% { box-shadow: 0 0 0 6px rgba(124, 95, 211, 0); }
}
/* === /Patch 21 === */


/* ============================================ */
/* [QuizP1] review-mode-modal */
/* ============================================ */
.review-mode-modal {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.review-mode-modal.hidden { display: none; }

.review-mode-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
}

.review-mode-content {
  position: relative;
  background: #ffffff;
  border-radius: 20px;
  padding: 28px 24px 24px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  z-index: 1;
}

.review-mode-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: transparent;
  border: none;
  font-size: 22px;
  color: #888;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
}
.review-mode-close:hover { background: #f3f4f6; color: #333; }

.review-mode-content h2 {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 700;
  color: #1f2937;
  text-align: center;
}

.review-mode-subtitle {
  margin: 0 0 20px;
  font-size: 13px;
  color: #6b7280;
  text-align: center;
}

.review-mode-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.review-mode-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: #f9fafb;
  border: 2px solid #e5e7eb;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}
.review-mode-card:hover:not(:disabled) {
  background: #eff6ff;
  border-color: #3b82f6;
  transform: translateY(-1px);
}
.review-mode-card:active:not(:disabled) { transform: translateY(0); }

.review-mode-card.review-mode-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.review-mode-icon {
  font-size: 32px;
  width: 48px;
  text-align: center;
  flex-shrink: 0;
}

.review-mode-name {
  font-size: 16px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 2px;
}

.review-mode-desc {
  font-size: 13px;
  color: #6b7280;
}

/* ============================================ */
/* [QuizP1] quiz-screen */
/* ============================================ */
.quiz-screen {
  position: fixed;
  inset: 0;
  z-index: 8500;
  background: linear-gradient(180deg, #f0f4ff 0%, #ffffff 100%);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.quiz-screen.hidden { display: none; }

.quiz-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 10;
}

.quiz-exit-btn {
  background: transparent;
  border: none;
  font-size: 20px;
  color: #6b7280;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
}
.quiz-exit-btn:hover { background: #f3f4f6; color: #111; }

.quiz-progress-wrap {
  flex: 1;
}
.quiz-progress-text {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 4px;
  font-weight: 600;
}
.quiz-progress-bar {
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  overflow: hidden;
}
.quiz-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #6366f1);
  border-radius: 3px;
  transition: width 0.3s ease;
  width: 0%;
}

.quiz-score {
  font-size: 14px;
  font-weight: 600;
  color: #059669;
  flex-shrink: 0;
}

.quiz-body {
  flex: 1;
  padding: 24px 18px 32px;
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

.quiz-question-card {
  background: #ffffff;
  border-radius: 18px;
  padding: 32px 20px 24px;
  text-align: center;
  position: relative;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
  margin-bottom: 24px;
}

.quiz-jlpt-badge {
  position: absolute;
  top: 14px;
  left: 14px;
  background: #6366f1;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
}

.quiz-question-jp {
  font-size: 36px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 6px;
  word-break: keep-all;
}

.quiz-question-reading {
  font-size: 16px;
  color: #6b7280;
  margin-bottom: 12px;
}

.quiz-tts-btn {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  font-size: 18px;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  color: #2563eb;
}
.quiz-tts-btn:hover { background: #dbeafe; }

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quiz-option {
  background: #ffffff;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 15px;
  color: #1f2937;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}
.quiz-option:hover:not(:disabled) {
  border-color: #3b82f6;
  background: #eff6ff;
}
.quiz-option:disabled { cursor: default; }

.quiz-option .quiz-option-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #e5e7eb;
  color: #6b7280;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.quiz-option.correct {
  background: #d1fae5;
  border-color: #10b981;
  color: #065f46;
}
.quiz-option.correct .quiz-option-num {
  background: #10b981;
  color: #fff;
}

.quiz-option.wrong {
  background: #fee2e2;
  border-color: #ef4444;
  color: #991b1b;
}
.quiz-option.wrong .quiz-option-num {
  background: #ef4444;
  color: #fff;
}

.quiz-feedback {
  margin-top: 20px;
  padding: 18px;
  background: #ffffff;
  border-radius: 14px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.quiz-feedback.hidden { display: none; }

.quiz-feedback-icon {
  font-size: 32px;
  margin-bottom: 6px;
}

.quiz-feedback-text {
  font-size: 16px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 8px;
}

.quiz-feedback-example {
  font-size: 13px;
  color: #6b7280;
  line-height: 1.5;
  margin-bottom: 14px;
  padding: 10px;
  background: #f9fafb;
  border-radius: 8px;
  white-space: pre-line;
}
.quiz-feedback-example:empty { display: none; }

.quiz-next-btn {
  background: #3b82f6;
  color: #fff;
  border: none;
  padding: 12px 28px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
}
.quiz-next-btn:hover { background: #2563eb; }

/* ============================================ */
/* [QuizP1] quiz-result-screen */
/* ============================================ */
.quiz-result-screen {
  position: fixed;
  inset: 0;
  z-index: 8500;
  background: linear-gradient(180deg, #fefce8 0%, #ffffff 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}
.quiz-result-screen.hidden { display: none; }

.quiz-result-content {
  background: #ffffff;
  border-radius: 20px;
  padding: 32px 24px;
  max-width: 460px;
  width: 100%;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.quiz-result-emoji {
  font-size: 56px;
  margin-bottom: 8px;
}

.quiz-result-title {
  font-size: 22px;
  font-weight: 700;
  color: #111827;
  margin: 0 0 18px;
}

.quiz-result-score {
  font-size: 36px;
  font-weight: 800;
  color: #3b82f6;
  margin-bottom: 4px;
}

.quiz-result-accuracy {
  font-size: 14px;
  color: #6b7280;
  margin-bottom: 22px;
}

.quiz-result-wrong-wrap {
  text-align: left;
  background: #fef2f2;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 20px;
}
.quiz-result-wrong-wrap.hidden { display: none; }

.quiz-result-wrong-wrap h3 {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 700;
  color: #991b1b;
}

.quiz-result-wrong-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 220px;
  overflow-y: auto;
}

.quiz-result-wrong-list li {
  padding: 8px 0;
  border-bottom: 1px solid #fecaca;
  font-size: 13px;
  color: #1f2937;
}
.quiz-result-wrong-list li:last-child { border-bottom: none; }

.quiz-result-wrong-list .wrong-jp {
  font-weight: 700;
  color: #111827;
  margin-right: 8px;
}
.quiz-result-wrong-list .wrong-ko { color: #6b7280; }

.quiz-result-actions {
  display: flex;
  gap: 10px;
}

.quiz-result-btn {
  flex: 1;
  padding: 13px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 10px;
  border: none;
  cursor: pointer;
}
.quiz-result-btn.primary {
  background: #3b82f6;
  color: #fff;
}
.quiz-result-btn.primary:hover { background: #2563eb; }
.quiz-result-btn.secondary {
  background: #f3f4f6;
  color: #374151;
}
.quiz-result-btn.secondary:hover { background: #e5e7eb; }
