/* ================================================
   tszwai.com — Enhanced Mindful Session UI
   Theme: Dreamy / Spiritual / Playful
   ================================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-deep:      #0d0818;
  --bg-mid:       #120f2a;
  --purple-glow:  #7c3aed;
  --pink-glow:    #db2777;
  --rose:         #f472b6;
  --lavender:     #c4b5fd;
  --mint:         #6ee7b7;
  --cream:        #fdf4ff;
  --glass-bg:     rgba(255,255,255,0.06);
  --glass-border: rgba(255,255,255,0.12);
  --text-main:    #f3e8ff;
  --text-muted:   rgba(243,232,255,0.55);
  --radius-lg:    20px;
  --radius-xl:    28px;
  --shadow-glow:  0 0 40px rgba(124,58,237,0.3);
}

/* ── Body & Canvas ─────────────────────────────── */
html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Noto Serif TC', serif;
  background: var(--bg-deep);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
}

#bg-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* ── Floating orbs ─────────────────────────────── */
.orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
  pointer-events: none;
  animation: drift 14s ease-in-out infinite alternate;
}
.orb-1 {
  width: 480px; height: 480px;
  background: radial-gradient(circle, #7c3aed, transparent 70%);
  top: -120px; left: -100px;
  animation-duration: 18s;
}
.orb-2 {
  width: 360px; height: 360px;
  background: radial-gradient(circle, #db2777, transparent 70%);
  bottom: -80px; right: -80px;
  animation-duration: 14s;
  animation-direction: alternate-reverse;
}
.orb-3 {
  width: 260px; height: 260px;
  background: radial-gradient(circle, #2dd4bf, transparent 70%);
  top: 40%; left: 60%;
  animation-duration: 22s;
}

@keyframes drift {
  from { transform: translate(0,0) scale(1); }
  to   { transform: translate(40px, 30px) scale(1.08); }
}

/* ── App wrapper ───────────────────────────────── */
.app-wrapper {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(480px, 100vw);
  height: 100dvh;
  background: rgba(13, 8, 24, 0.6);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-left:  1px solid var(--glass-border);
  border-right: 1px solid var(--glass-border);
  overflow: hidden;
}

/* ── Header ────────────────────────────────────── */
.site-header {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 28px 24px 20px;
  background: linear-gradient(180deg, rgba(124,58,237,0.18) 0%, transparent 100%);
  border-bottom: 1px solid var(--glass-border);
}

.header-badge {
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.25em;
  color: var(--lavender);
  background: rgba(124,58,237,0.25);
  border: 1px solid rgba(196,181,253,0.3);
  border-radius: 100px;
  padding: 3px 12px;
  text-transform: uppercase;
}

.lotus-wrap {
  position: relative;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px 0;
}

.lotus-icon {
  font-size: 34px;
  animation: breathe 4s ease-in-out infinite;
  position: relative;
  z-index: 2;
  cursor: default;
  user-select: none;
}

@keyframes breathe {
  0%, 100% { transform: scale(1);    filter: brightness(1); }
  50%       { transform: scale(1.15); filter: brightness(1.3) drop-shadow(0 0 12px #c4b5fd); }
}

.lotus-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid rgba(196,181,253,0.4);
  animation: ring-pulse 4s ease-in-out infinite;
}
.ring-2 {
  inset: -10px;
  border-color: rgba(244,114,182,0.2);
  animation-delay: 1s;
}

@keyframes ring-pulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50%       { opacity: 0.15; transform: scale(1.18); }
}

.site-title {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0.08em;
  background: linear-gradient(135deg, var(--cream) 0%, var(--lavender) 50%, var(--rose) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.site-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

/* ── Chat window ───────────────────────────────── */
.chat-window {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 16px;
  scroll-behavior: smooth;
}

.chat-window::-webkit-scrollbar { width: 4px; }
.chat-window::-webkit-scrollbar-track { background: transparent; }
.chat-window::-webkit-scrollbar-thumb {
  background: rgba(196,181,253,0.25);
  border-radius: 4px;
}

.message-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── Messages ──────────────────────────────────── */
.msg {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.msg.user {
  flex-direction: row-reverse;
}

.msg-avatar {
  font-size: 20px;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 50%;
}

.msg-bubble {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: 18px 18px 18px 4px;
  font-size: 14.5px;
  line-height: 1.7;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(8px);
  color: var(--text-main);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  white-space: pre-wrap;
}

.msg.user .msg-bubble {
  border-radius: 18px 18px 4px 18px;
  background: linear-gradient(135deg, rgba(124,58,237,0.45), rgba(219,39,119,0.35));
  border-color: rgba(196,181,253,0.25);
}

.msg-bubble p + p { margin-top: 6px; }

/* typing indicator */
.typing .msg-bubble {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 14px 18px;
}
.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--lavender);
  animation: blink 1.2s ease-in-out infinite;
}
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0.2; transform: scale(0.85); }
  40%            { opacity: 1;   transform: scale(1); }
}

/* Fade-in animation */
.fade-in {
  animation: fadeUp 0.5s ease both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Input area ────────────────────────────────── */
.input-area {
  flex-shrink: 0;
  padding: 12px 16px 20px;
  background: linear-gradient(0deg, rgba(13,8,24,0.95) 0%, transparent 100%);
  border-top: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Emotion tags */
.emotion-bar {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.emotion-tag {
  font-family: 'Noto Serif TC', serif;
  font-size: 12.5px;
  padding: 5px 13px;
  border-radius: 100px;
  border: 1px solid rgba(196,181,253,0.3);
  background: rgba(124,58,237,0.12);
  color: var(--lavender);
  cursor: pointer;
  transition: all 0.22s ease;
  letter-spacing: 0.04em;
}

.emotion-tag:hover,
.emotion-tag.active {
  background: linear-gradient(135deg, rgba(124,58,237,0.5), rgba(219,39,119,0.4));
  border-color: rgba(196,181,253,0.6);
  color: var(--cream);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(124,58,237,0.35);
}

/* Input row */
.input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  resize: none;
  font-family: 'Noto Serif TC', serif;
  font-size: 14px;
  line-height: 1.6;
  padding: 11px 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,0.07);
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  max-height: 120px;
  overflow-y: auto;
}

.chat-input::placeholder { color: var(--text-muted); }

.chat-input:focus {
  border-color: rgba(196,181,253,0.5);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.18);
}

.send-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--purple-glow), var(--pink-glow));
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s, box-shadow 0.18s;
  box-shadow: 0 4px 16px rgba(124,58,237,0.45);
}

.send-btn svg {
  width: 18px;
  height: 18px;
}

.send-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 22px rgba(124,58,237,0.6);
}

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

/* Hint bar */
.input-hint {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: var(--text-muted);
  padding: 0 2px;
}

.quota-label strong {
  color: var(--mint);
}

.hint-key {
  letter-spacing: 0.02em;
}

/* ── Modal ─────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(13,8,24,0.82);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.modal-overlay[hidden] { display: none !important; }

.modal-card {
  background: rgba(28,18,52,0.95);
  border: 1px solid rgba(196,181,253,0.2);
  border-radius: var(--radius-xl);
  padding: 36px 32px;
  width: min(360px, 90vw);
  text-align: center;
  box-shadow: var(--shadow-glow), 0 24px 60px rgba(0,0,0,0.5);
  animation: slideUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-icon {
  font-size: 40px;
  margin-bottom: 14px;
  animation: breathe 4s ease-in-out infinite;
}

.modal-card h2 {
  font-size: 20px;
  font-weight: 500;
  margin-bottom: 10px;
  background: linear-gradient(135deg, var(--cream), var(--lavender));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.modal-card p {
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-primary {
  padding: 13px 20px;
  border-radius: 100px;
  border: none;
  background: linear-gradient(135deg, var(--purple-glow), var(--pink-glow));
  color: white;
  font-family: 'Noto Serif TC', serif;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.18s, box-shadow 0.18s;
  box-shadow: 0 4px 18px rgba(124,58,237,0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 26px rgba(124,58,237,0.55);
}

.btn-ghost {
  padding: 11px 20px;
  border-radius: 100px;
  border: 1px solid var(--glass-border);
  background: transparent;
  color: var(--text-muted);
  font-family: 'Noto Serif TC', serif;
  font-size: 14px;
  cursor: pointer;
  transition: color 0.18s, border-color 0.18s;
}

.btn-ghost:hover {
  color: var(--text-main);
  border-color: rgba(196,181,253,0.4);
}

/* ── Responsive ────────────────────────────────── */
@media (max-width: 520px) {
  .app-wrapper {
    width: 100vw;
    border-left: none;
    border-right: none;
  }
}
