/* ============ DREAM — MISTY NIGHT THEME ============ */

.dream-page {
  background: linear-gradient(170deg, #0a0818 0%, #120e28 35%, #0e0a20 65%, #0a0818 100%);
  color: #cec4e0;
  overflow: hidden;
  position: relative;
}
.dream-page::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 600px 400px at 25% 25%, rgba(120,90,180,0.07) 0%, transparent 70%),
    radial-gradient(ellipse 500px 350px at 75% 65%, rgba(90,70,160,0.05) 0%, transparent 70%);
  pointer-events: none; z-index: 0;
}

/* ── Back button ── */
.dream-back {
  position: fixed; top: 16px; left: 16px; z-index: 90;
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,0.05);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  text-decoration: none;
  border: 1px solid rgba(160,140,200,0.12);
}
.dream-back svg {
  width: 16px; height: 16px; fill: none;
  stroke: rgba(160,140,200,0.6); stroke-width: 1.5;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ── Scenes ── */
.d-scene {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  opacity: 0; pointer-events: none;
  transition: opacity 0.5s ease, transform 0.5s ease;
  transform: translateY(12px);
  z-index: 1;
  overflow: hidden;
}
.d-scene.active {
  opacity: 1; pointer-events: auto;
  transform: translateY(0);
  z-index: 2;
}

/* ── Common ── */
.d-header {
  text-align: center;
  padding: 60px 24px 20px;
  flex-shrink: 0;
}
.d-step {
  font-family: 'EB Garamond', serif;
  font-size: 10px; letter-spacing: 4px;
  color: rgba(160,140,200,0.45);
  margin-bottom: 12px;
}
.d-scene-title {
  font-family: 'Noto Serif SC', serif;
  font-size: 22px; font-weight: 300;
  color: #e0d8ee; letter-spacing: 2px;
  margin-bottom: 8px;
}
.d-scene-sub {
  font-size: 12px; font-weight: 300;
  color: rgba(160,140,200,0.45);
  letter-spacing: 1px;
}

.d-back-link {
  display: flex; align-items: center; gap: 4px;
  justify-content: center;
  padding: 16px; margin-top: auto;
  font-family: 'EB Garamond', serif;
  font-size: 13px; letter-spacing: 1px;
  color: rgba(160,140,200,0.4);
  background: none; border: none; cursor: pointer;
  flex-shrink: 0;
  padding-bottom: calc(16px + var(--safe-bottom));
}

/* Buttons */
.d-btn {
  display: block; width: 200px; margin: 0 auto;
  padding: 12px 0; border-radius: 24px;
  font-family: 'Noto Serif SC', serif;
  font-size: 14px; letter-spacing: 2px;
  cursor: pointer; border: none;
  transition: all 0.3s;
}
.d-btn-primary {
  background: linear-gradient(135deg, #9a85c0, #7a68a8);
  color: #f0ecf8;
  box-shadow: 0 4px 20px rgba(140,120,180,0.25);
}
.d-btn-primary:active { transform: scale(0.97); }
.d-btn-ghost {
  background: none;
  color: rgba(160,140,200,0.5);
  border: 1px solid rgba(160,140,200,0.15);
  margin-top: 12px;
}
.d-btn-ghost:active { background: rgba(160,140,200,0.05); }

/* ============ WELCOME ============ */
.dw-stars {
  position: absolute; inset: 0;
  z-index: 0; pointer-events: none;
}

/* Mist layers */
.dw-mist {
  position: absolute; z-index: 1;
  width: 200%; height: 120px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(120,100,180,0.03) 20%,
    rgba(140,120,200,0.05) 50%,
    rgba(120,100,180,0.03) 80%,
    transparent 100%);
  filter: blur(30px);
  pointer-events: none;
}
.dw-mist-1 {
  bottom: 25%; left: -50%;
  animation: mistDrift 18s ease-in-out infinite;
}
.dw-mist-2 {
  top: 30%; left: -30%;
  animation: mistDrift 22s ease-in-out infinite reverse;
  opacity: 0.6;
}
@keyframes mistDrift {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(15%); }
}

.dw-content {
  position: relative; z-index: 2;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  flex: 1; padding: 80px 24px 40px;
  text-align: center;
}

.dw-eye {
  width: 90px; height: 55px;
  margin-bottom: 28px;
  animation: eyeFloat 7s ease-in-out infinite;
}
@keyframes eyeFloat {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-6px) scale(1.03); }
}

.dw-en-top {
  font-family: 'EB Garamond', serif;
  font-size: 9px; letter-spacing: 6px;
  text-transform: uppercase;
  color: rgba(160,140,200,0.35);
  margin-bottom: 12px;
  animation: glDreamIn 0.8s ease 0.2s both;
}

.dw-title {
  font-family: 'Noto Serif SC', serif;
  font-size: 28px; font-weight: 300;
  color: #e8e0f4; letter-spacing: 4px;
  line-height: 1.6; margin-bottom: 6px;
  animation: glDreamIn 0.8s ease 0.4s both;
}
.dw-title span {
  font-family: 'Cormorant Garamond', serif;
  font-size: 20px; font-weight: 300;
  letter-spacing: 6px;
  color: rgba(160,140,200,0.7);
}

.dw-en-bottom {
  font-family: 'Pinyon Script', cursive;
  font-size: 18px;
  color: rgba(160,140,200,0.4);
  margin-bottom: 16px;
  animation: glDreamIn 0.8s ease 0.6s both;
}

@keyframes glDreamIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.dw-sub {
  font-size: 12px; font-weight: 300;
  color: rgba(160,140,200,0.42);
  line-height: 2; letter-spacing: 1.5px;
  margin-bottom: 24px;
  animation: glDreamIn 0.8s ease 0.8s both;
}

.dw-ornament {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 32px;
}
.dw-line {
  width: 40px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(160,140,200,0.3), transparent);
}

/* ============ RECORD ============ */
.dr-body {
  flex: 1; overflow-y: auto;
  padding: 0 24px 24px;
  -webkit-overflow-scrolling: touch;
}
.dr-date {
  font-family: 'EB Garamond', serif;
  font-size: 12px; letter-spacing: 2px;
  color: rgba(160,140,200,0.4);
  text-align: center; margin-bottom: 20px;
}
.dr-textarea-wrap {
  position: relative;
  margin-bottom: 20px;
}
.dr-textarea {
  width: 100%; box-sizing: border-box;
  padding: 20px;
  background: rgba(160,140,200,0.04);
  border: 1px solid rgba(160,140,200,0.1);
  border-radius: 16px;
  color: #d8d0e8;
  font-family: 'Noto Serif SC', serif;
  font-size: 14px; font-weight: 300;
  line-height: 1.8;
  letter-spacing: 0.5px;
  resize: none;
  outline: none;
  transition: border-color 0.3s;
  min-height: 180px;
}
.dr-textarea::placeholder {
  color: rgba(160,140,200,0.25);
}
.dr-textarea:focus {
  border-color: rgba(160,140,200,0.25);
}

.dr-mood {
  margin-bottom: 24px;
}
.dr-mood-label {
  display: block;
  font-family: 'EB Garamond', serif;
  font-size: 11px; letter-spacing: 2px;
  color: rgba(160,140,200,0.4);
  margin-bottom: 12px;
  text-align: center;
}
.dr-mood-options {
  display: flex; flex-wrap: wrap;
  gap: 8px; justify-content: center;
}
.dr-mood-btn {
  padding: 7px 14px;
  border-radius: 20px;
  border: 1px solid rgba(160,140,200,0.12);
  background: rgba(160,140,200,0.04);
  color: rgba(160,140,200,0.55);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.25s;
  font-family: 'Noto Serif SC', serif;
}
.dr-mood-btn.active {
  background: rgba(140,120,180,0.15);
  border-color: rgba(160,140,200,0.35);
  color: #d0c4e8;
  box-shadow: 0 0 12px rgba(140,120,180,0.15);
}

/* ============ RESULT ============ */
.dres-scroll {
  flex: 1; overflow-y: auto;
  padding: 60px 24px 40px;
  -webkit-overflow-scrolling: touch;
}
.dres-head {
  text-align: center; margin-bottom: 16px;
}
.dres-badge {
  display: inline-block;
  font-size: 12px; letter-spacing: 2px;
  padding: 4px 16px; border-radius: 20px;
  background: rgba(140,120,180,0.1);
  border: 1px solid rgba(160,140,200,0.15);
  color: rgba(160,140,200,0.6);
  margin-bottom: 12px;
}
.dres-title {
  font-family: 'Noto Serif SC', serif;
  font-size: 20px; font-weight: 300;
  color: #e0d8ee; letter-spacing: 2px;
  margin-bottom: 12px;
}
.dres-dream-summary {
  font-size: 12px; font-weight: 300;
  color: rgba(160,140,200,0.4);
  line-height: 1.8;
  max-height: 60px; overflow: hidden;
  text-overflow: ellipsis;
}

.dres-interp {
  position: relative; min-height: 120px;
}
.dres-loading {
  display: flex; flex-direction: column;
  align-items: center; gap: 16px;
  padding: 40px 0;
  color: rgba(160,140,200,0.45);
  font-size: 13px;
}
.dres-orb {
  width: 32px; height: 32px; border-radius: 50%;
  background: radial-gradient(circle, rgba(160,140,200,0.2), transparent 70%);
  animation: orbPulse 2s ease-in-out infinite;
}
@keyframes orbPulse {
  0%, 100% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.3); opacity: 1; }
}
.dres-text {
  font-family: 'Noto Serif SC', serif;
  font-size: 14px; font-weight: 300;
  line-height: 2;
  color: #d0c8e0;
  letter-spacing: 0.5px;
}
.dres-text p { margin-bottom: 16px; }

.dres-actions {
  padding-top: 24px;
}

/* ============ CHAT ============ */
.dc-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid rgba(160,140,200,0.08);
  flex-shrink: 0;
  padding-top: calc(16px + var(--safe-top, 0px));
}
.dc-bar-back {
  background: none; border: none; cursor: pointer;
  padding: 4px; color: rgba(160,140,200,0.5);
}
.dc-bar-title {
  font-family: 'Noto Serif SC', serif;
  font-size: 15px; font-weight: 300;
  color: #d8d0e8; letter-spacing: 1px;
}

.dc-msgs {
  flex: 1; overflow-y: auto;
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  -webkit-overflow-scrolling: touch;
}
.dc-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px; line-height: 1.7;
  font-weight: 300;
  animation: msgIn 0.3s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.dc-msg.user {
  align-self: flex-end;
  background: rgba(140,120,180,0.15);
  color: #dcd4ee;
  border-bottom-right-radius: 4px;
}
.dc-msg.ai {
  align-self: flex-start;
  background: rgba(160,140,200,0.06);
  border: 1px solid rgba(160,140,200,0.1);
  color: #cec4e0;
  border-bottom-left-radius: 4px;
}
.dc-msg.system {
  align-self: center;
  max-width: 90%;
  background: none;
  color: rgba(160,140,200,0.35);
  font-size: 11px;
  text-align: center;
  padding: 6px 0;
}

.dc-input-row {
  display: flex; gap: 8px;
  padding: 12px 16px;
  padding-bottom: calc(12px + var(--safe-bottom));
  border-top: 1px solid rgba(160,140,200,0.08);
  flex-shrink: 0;
}
.dc-input {
  flex: 1;
  padding: 10px 16px; border-radius: 22px;
  background: rgba(160,140,200,0.06);
  border: 1px solid rgba(160,140,200,0.1);
  color: #d8d0e8;
  font-size: 14px;
  outline: none;
  font-family: 'Noto Serif SC', serif;
  font-weight: 300;
}
.dc-input::placeholder { color: rgba(160,140,200,0.25); }
.dc-send {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #9a85c0, #7a68a8);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s;
}
.dc-send:active { transform: scale(0.92); }
.dc-send svg { stroke: #f0ecf8; }

/* ============ HISTORY ============ */
.dh-list {
  flex: 1; overflow-y: auto;
  padding: 0 24px 24px;
  -webkit-overflow-scrolling: touch;
}
.dh-empty {
  text-align: center;
  color: rgba(160,140,200,0.3);
  font-size: 13px;
  padding-top: 60px;
}
.dh-card {
  padding: 16px;
  margin-bottom: 12px;
  border-radius: 14px;
  background: rgba(160,140,200,0.04);
  border: 1px solid rgba(160,140,200,0.08);
  cursor: pointer;
  transition: background 0.25s;
}
.dh-card:active {
  background: rgba(160,140,200,0.08);
}
.dh-card-top {
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 8px;
}
.dh-card-date {
  font-family: 'EB Garamond', serif;
  font-size: 11px; letter-spacing: 1.5px;
  color: rgba(160,140,200,0.4);
}
.dh-card-mood {
  font-size: 11px;
  padding: 2px 10px;
  border-radius: 12px;
  background: rgba(140,120,180,0.08);
  color: rgba(160,140,200,0.5);
}
.dh-card-text {
  font-size: 13px; font-weight: 300;
  color: rgba(200,190,220,0.7);
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
