/* ─── Sakura Door → Room transition ─── */
.sakura-door--opening .sakura-door__frame {
  animation: doorCreak 0.3s ease forwards;
}
@keyframes doorCreak {
  0%   { transform: perspective(200px) rotateY(0deg); }
  100% { transform: perspective(200px) rotateY(-25deg); }
}

.sakura-door-transition {
  position: fixed;
  z-index: 9000;
  width: 0;
  height: 0;
  border-radius: 50%;
  pointer-events: none;
  /* The gradient: soft sakura pink, slightly transparent at the edge */
  background: radial-gradient(circle, #fef0f3 0%, #fbe4e9 60%, rgba(251,228,233,0.85) 100%);
  transform: translate(-50%, -50%);
}
.sakura-door-transition--expand {
  animation: sakuraDoorExpand 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
@keyframes sakuraDoorExpand {
  0%   { width: 0; height: 0; opacity: 0.6; }
  30%  { opacity: 1; }
  100% { width: calc(var(--max-r) * 2); height: calc(var(--max-r) * 2); opacity: 1; }
}
/* Start fully covering the screen (placed before shrink animation) */
.sakura-door-transition--cover {
  width: calc(var(--max-r) * 2);
  height: calc(var(--max-r) * 2);
  opacity: 1;
}
.sakura-door-transition--shrink {
  animation: sakuraDoorShrink 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
@keyframes sakuraDoorShrink {
  0%   { width: calc(var(--max-r) * 2); height: calc(var(--max-r) * 2); opacity: 1; }
  70%  { opacity: 1; }
  100% { width: 0; height: 0; opacity: 0; }
}

/* Dark mode: deeper sakura tones */
[data-theme="dark"] .sakura-door-transition {
  background: radial-gradient(circle, #2e2028 0%, #281c22 60%, rgba(40,28,34,0.9) 100%);
}

/* ─── Sakura Room — LINE-style Chat UI ─── */

/* Override body & #app background when sakura-room is active */
body.sakura-room-active {
  background: #fef0f3;
}
body.sakura-room-active #app {
  max-width: 100%;
  padding: 0;
  padding-bottom: 0;
}
body.sakura-room-active .feedback-fab,
body.sakura-room-active .jp-toggle {
  display: none;
}
[data-theme="dark"] body.sakura-room-active,
body.sakura-room-active[data-theme="dark"] {
  background: #2e2028;
}

.sakura-room {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  background: #fef0f3;
  overflow: hidden;
  position: relative;
}
[data-theme="dark"] .sakura-room {
  background: #2e2028;
}

/* Header (legacy, kept for compat) */
.sr-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--c-surface, #16213e);
  border-bottom: 1px solid var(--c-border, #333);
  flex-shrink: 0;
}
.sr-header__back {
  background: none;
  border: none;
  color: var(--c-text, #eee);
  font-size: 24px;
  cursor: pointer;
  padding: 0 4px;
}
.sr-header__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff9a9e, #fecfef);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.sr-header__info {
  flex: 1;
}
.sr-header__name {
  font-weight: 600;
  color: var(--c-text, #eee);
  font-size: 15px;
}
.sr-header__status {
  font-size: 11px;
  color: var(--c-text-muted, #888);
}

/* Chat area */
.sr-chat {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  padding-bottom: 33vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #f0c4cc #fef0f3;
}
.sr-chat::-webkit-scrollbar {
  width: 5px;
}
.sr-chat::-webkit-scrollbar-track {
  background: transparent;
}
.sr-chat::-webkit-scrollbar-thumb {
  background: #f0c4cc;
  border-radius: 4px;
}
.sr-chat::-webkit-scrollbar-thumb:hover {
  background: #e8a8b4;
}
[data-theme="dark"] .sr-chat {
  scrollbar-color: #6a505a #2e2028;
}
[data-theme="dark"] .sr-chat::-webkit-scrollbar-thumb {
  background: #6a505a;
}
[data-theme="dark"] .sr-chat::-webkit-scrollbar-thumb:hover {
  background: #7a606a;
}
/* PC: narrow chat column so bubbles stay close to center */
@media (min-width: 600px) {
  .sr-chat {
    max-width: 480px;
    margin: 0 auto;
    width: 100%;
  }
}

/* Message bubbles */
.sr-msg {
  display: flex;
  gap: 8px;
  max-width: 85%;
  animation: sr-fade-in 0.6s ease-out;
}
.sr-msg--sakura {
  align-self: flex-start;
}
.sr-msg--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.sr-msg--narration {
  align-self: center;
  max-width: 90%;
}

.sr-msg__avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff9a9e, #fecfef);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 2px;
}

.sr-msg__bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}
.sr-msg--sakura .sr-msg__bubble {
  background: var(--c-surface, #16213e);
  color: var(--c-text, #eee);
  border-bottom-left-radius: 4px;
}
.sr-msg--user .sr-msg__bubble {
  background: var(--c-primary, #4cc9f0);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.sr-msg--narration .sr-msg__bubble {
  background: transparent;
  color: var(--c-text-muted, #888);
  font-size: 12px;
  text-align: center;
  font-style: italic;
  padding: 8px 16px;
}

/* Image messages */
.sr-msg__image {
  max-width: 200px;
  border-radius: 12px;
  margin-bottom: 4px;
  cursor: pointer;
}
.sr-msg__caption {
  font-size: 12px;
  color: var(--c-text-muted, #888);
  margin-top: 4px;
}

/* Typing indicator */
.sr-typing {
  display: flex;
  gap: 8px;
  align-self: flex-start;
  max-width: 85%;
}
.sr-typing__dots {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: var(--c-surface, #16213e);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}
.sr-typing__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c-text-muted, #888);
  animation: sr-typing-bounce 1.2s infinite;
}
.sr-typing__dot:nth-child(2) { animation-delay: 0.2s; }
.sr-typing__dot:nth-child(3) { animation-delay: 0.4s; }

/* Choice buttons */
.sr-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  align-self: flex-end;
  width: 100%;
  max-width: 85%;
  animation: sr-fade-in 0.6s ease-out;
}
.sr-choice-btn {
  background: transparent;
  border: 1.5px solid var(--c-primary, #4cc9f0);
  color: var(--c-primary, #4cc9f0);
  padding: 10px 16px;
  border-radius: 20px;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}
.sr-choice-btn:hover, .sr-choice-btn:active {
  background: var(--c-primary, #4cc9f0);
  color: #fff;
}
.sr-choice-btn--selected {
  background: var(--c-primary, #4cc9f0);
  color: #fff;
  border-color: var(--c-primary, #4cc9f0);
}

/* Sleeping state */
.sr-sleeping {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--c-text-muted, #888);
}
.sr-sleeping__icon {
  font-size: 48px;
}
.sr-sleeping__text {
  font-size: 14px;
  text-align: center;
  line-height: 1.6;
}

/* No conversations available */
.sr-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--c-text-muted, #888);
  padding: 24px;
}
.sr-empty__text {
  font-size: 14px;
  text-align: center;
  line-height: 1.6;
}

/* Closing line */
.sr-closing {
  text-align: center;
  padding: 16px;
  color: var(--c-text-muted, #888);
  font-size: 12px;
  font-style: italic;
}

/* Animations */
@keyframes sr-fade-in {
  from { opacity: 0; }
  60%  { opacity: 0.7; }
  to   { opacity: 1; }
}
@keyframes sr-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

/* Header album button */
.sr-header__album {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.sr-header__album:hover { opacity: 1; }

/* Album overlay */
.sr-album-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: var(--c-bg, #0f0f23);
  overflow-y: auto;
  animation: sr-fade-in 0.2s ease;
}
.sr-album-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--c-border, #333);
  color: var(--c-text, #eee);
  font-weight: 600;
}
.sr-album-close {
  background: none;
  border: none;
  color: var(--c-text, #eee);
  font-size: 24px;
  cursor: pointer;
  padding: 0 4px;
  margin-left: auto;
}
.sr-album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 200px);
  justify-content: center;
  gap: 2px;
  padding: 2px;
}
.sr-album-thumb {
  width: 200px;
  height: 200px;
  overflow: hidden;
  cursor: pointer;
  background: var(--c-surface, #16213e);
}
.sr-album-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s;
}
.sr-album-thumb:hover img { transform: scale(1.05); }
.sr-album-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  opacity: 0.4;
}

/* Album detail */
.sr-album-detail {
  position: fixed;
  inset: 0;
  z-index: 600;
  background: rgba(0,0,0,0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  cursor: pointer;
  animation: sr-fade-in 0.2s ease;
}
.sr-album-detail img {
  max-width: 90%;
  max-height: 70vh;
  border-radius: 8px;
}
.sr-album-detail__caption {
  color: #eee;
  font-size: 14px;
  text-align: center;
  padding: 0 24px;
}
.sr-album-detail__date {
  color: #888;
  font-size: 12px;
}
.sr-album-dl {
  margin-top: 12px;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
}
.sr-album-dl:hover {
  background: rgba(255,255,255,0.25);
}

/* Home screen sakura door — floating fixed at bottom-right */
.sakura-door {
  position: fixed;
  bottom: 20px;
  right: 16px;
  z-index: 510;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  transition: transform 0.3s ease, filter 0.3s ease;
  filter: drop-shadow(0 3px 8px rgba(180,140,150,0.3));
}
.sakura-door:hover {
  transform: translateY(-3px) scale(1.05);
  filter: drop-shadow(0 6px 16px rgba(180,140,150,0.4));
}
.sakura-door:active {
  transform: scale(0.95);
}
/* Door shape — soft sakura palette */
.sakura-door__frame {
  width: 52px;
  height: 68px;
  border-radius: 26px 26px 4px 4px;
  background: linear-gradient(180deg, #fff5f7 0%, #fde8ed 40%, #f5d5dc 100%);
  border: 2px solid #e8c4cc;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.sakura-door__frame::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  right: 4px;
  bottom: 4px;
  border-radius: 22px 22px 2px 2px;
  background: linear-gradient(180deg, #fff9fa 0%, #fef0f3 60%, #fbe4e9 100%);
  opacity: 0.7;
}
/* Door knob */
.sakura-door__frame::after {
  content: '';
  position: absolute;
  right: 8px;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #d4a0aa;
  box-shadow: 0 0 4px rgba(212,160,170,0.4);
}
/* Sakura icon on door */
.sakura-door__icon {
  position: relative;
  z-index: 1;
  font-size: 1.5rem;
  animation: sakuraDoorPulse 3s ease-in-out infinite;
}
@keyframes sakuraDoorPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}
/* Label below door */
.sakura-door__label {
  font-size: 0.6rem;
  font-weight: 700;
  color: #c9919b;
  margin-top: 4px;
  white-space: nowrap;
  letter-spacing: 0.5px;
}

/* Dark mode */
[data-theme="dark"] .sakura-door {
  filter: drop-shadow(0 4px 12px rgba(220,180,190,0.25));
}
[data-theme="dark"] .sakura-door:hover {
  filter: drop-shadow(0 8px 20px rgba(220,180,190,0.35));
}
[data-theme="dark"] .sakura-door__frame {
  background: linear-gradient(180deg, #2e2028 0%, #352530 40%, #3a2835 100%);
  border-color: #6a505a;
}
[data-theme="dark"] .sakura-door__frame::before {
  background: linear-gradient(180deg, #322430 0%, #382830 60%, #3d2a35 100%);
}
[data-theme="dark"] .sakura-door__frame::after {
  background: #c9a0aa;
  box-shadow: 0 0 4px rgba(200,160,170,0.4);
}
[data-theme="dark"] .sakura-door__label {
  color: #d4b0b8;
}

/* Exit door variant — warm brown/wooden */
.sakura-door--exit {
  filter: drop-shadow(0 3px 8px rgba(120,90,60,0.3));
}
.sakura-door--exit:hover {
  filter: drop-shadow(0 6px 16px rgba(120,90,60,0.4));
}
.sakura-door--exit .sakura-door__frame {
  background: linear-gradient(180deg, #e8d5c0 0%, #c9a882 40%, #b08e68 100%);
  border-color: #8b6f4e;
}
.sakura-door--exit .sakura-door__frame::before {
  background: linear-gradient(180deg, #f0e4d4 0%, #dcc8aa 60%, #c9b090 100%);
}
.sakura-door--exit .sakura-door__frame::after {
  background: #8b6f4e;
  box-shadow: 0 0 4px rgba(139,111,78,0.4);
}
.sakura-door--exit .sakura-door__icon {
  animation: none;
}
.sakura-door--exit .sakura-door__label {
  color: #8b6f4e;
}
/* Dark mode exit door */
[data-theme="dark"] .sakura-door--exit {
  filter: drop-shadow(0 3px 8px rgba(80,60,40,0.4));
}
[data-theme="dark"] .sakura-door--exit:hover {
  filter: drop-shadow(0 6px 16px rgba(80,60,40,0.5));
}
[data-theme="dark"] .sakura-door--exit .sakura-door__frame {
  background: linear-gradient(180deg, #3a3028 0%, #4a3828 40%, #3e3020 100%);
  border-color: #6a5838;
}
[data-theme="dark"] .sakura-door--exit .sakura-door__frame::before {
  background: linear-gradient(180deg, #403530 0%, #4e4030 60%, #443828 100%);
}
[data-theme="dark"] .sakura-door--exit .sakura-door__frame::after {
  background: #a08860;
  box-shadow: 0 0 4px rgba(160,136,96,0.4);
}
[data-theme="dark"] .sakura-door--exit .sakura-door__label {
  color: #a08860;
}

/* ─── First Launch Tutorial Overlay ─── */

.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 24px 16px 48px;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.tutorial-chat {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  overflow-y: auto;
  padding-bottom: 16px;
}

.tutorial-msg {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: tutorial-msg-in 0.4s ease both;
}

.tutorial-msg__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff9a9e, #fecfef);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  line-height: 36px;
  text-align: center;
}

.tutorial-msg__text {
  background: linear-gradient(135deg, #fff0f5, #ffe8f0);
  color: #333;
  padding: 10px 14px;
  border-radius: 4px 16px 16px 16px;
  font-size: 15px;
  line-height: 1.6;
  max-width: 300px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.tutorial-hint {
  text-align: center;
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  margin-top: 20px;
  animation: tutorial-hint-pulse 1.5s ease-in-out infinite;
}

@keyframes tutorial-msg-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes tutorial-hint-pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* ─── Debug: Skip to next conversation button ─── */
.sr-debug-skip {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 2px solid #e91e63;
  border-radius: 20px;
  background: rgba(233, 30, 99, 0.9);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.sr-debug-skip:active {
  transform: scale(0.95);
}
.sr-debug-skip__id {
  font-size: 11px;
  font-weight: 400;
  opacity: 0.8;
  padding-right: 4px;
  border-right: 1px solid rgba(255,255,255,0.4);
}
