/* ===== Dating App ===== */
.dating-page {
  position: fixed;
  inset: 0;
  z-index: 839;
  display: none;
  flex-direction: column;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

.dating-bedtime-page {
  position: fixed;
  inset: 0;
  z-index: 839;
  display: none;
  flex-direction: column;
  color: #f7e8f3;
  background:
    radial-gradient(circle at 50% 18%, rgba(233, 79, 151, 0.18), transparent 32%),
    linear-gradient(180deg, #100814 0%, #09070f 48%, #030205 100%);
  overflow: hidden;
}

.dating-page.active,
.dating-bedtime-page.active {
  display: flex;
}

.dating-nav {
  background: var(--glass);
  border-bottom: 1px solid var(--glass-border);
  color: var(--text);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.bedtime-nav {
  background: rgba(8, 5, 13, 0.92);
  border-bottom: 1px solid rgba(242, 113, 181, 0.26);
  color: #ffd6eb;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.dating-nav .chat-nav-back,
.dating-nav .chat-nav-btn {
  color: var(--text) !important;
  background: var(--glass-strong) !important;
  border: 1px solid var(--glass-border) !important;
  box-shadow: 0 8px 18px var(--glass-shadow);
}

.bedtime-nav .chat-nav-back,
.bedtime-nav .chat-nav-btn {
  color: #ffd0e7 !important;
  background: linear-gradient(180deg, rgba(42, 17, 34, 0.98), rgba(12, 7, 17, 0.98)) !important;
  border: 1px solid rgba(242, 116, 181, 0.42) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 227, 242, 0.12),
    0 8px 18px rgba(0, 0, 0, 0.34);
}

.dating-nav .chat-nav-title {
  color: var(--text);
}

.bedtime-nav .chat-conv-nav-title {
  color: #ffd6eb;
}

.bedtime-nav .chat-conv-nav-subtitle {
  color: rgba(255, 199, 229, 0.68);
}

.dating-content {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 18px 14px calc(20px + env(safe-area-inset-bottom));
}

.dating-feature-card {
  width: min(680px, 100%);
  min-height: 86px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  background: var(--glass);
  color: var(--text);
  box-shadow: 0 16px 34px var(--glass-shadow);
  cursor: pointer;
  text-align: left;
}

.dating-feature-card:active {
  transform: scale(0.992);
  border-color: var(--text);
}

.dating-feature-icon {
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--text);
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
}

.dating-feature-main {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.dating-feature-title {
  font-size: 18px;
  line-height: 1.2;
  font-weight: 700;
  color: var(--text);
}

.dating-feature-meta {
  font-size: 12px;
  color: var(--text3);
}

.dating-feature-arrow {
  color: var(--text2);
}

.dating-modal.chat-modal-overlay {
  z-index: 910;
  background: rgba(0, 0, 0, 0.62);
}

.dating-modal-panel {
  width: min(380px, calc(100vw - 28px));
  max-height: min(78vh, 620px);
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
  background: var(--glass-strong);
  color: var(--text);
  box-shadow: 0 26px 62px rgba(0, 0, 0, 0.36);
  overflow: hidden;
}

.bedtime-word-panel,
.bedtime-continue-panel,
.bedtime-history-panel,
.bedtime-export-panel {
  border: 1px solid rgba(250, 140, 203, 0.28);
  background: linear-gradient(180deg, rgba(22, 12, 28, 0.98), rgba(10, 7, 15, 0.98));
  color: #f8e8f2;
  box-shadow: 0 26px 62px rgba(0, 0, 0, 0.52);
}

.dating-modal-head {
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--glass-border);
}

.bedtime-word-panel .dating-modal-head,
.bedtime-continue-panel .dating-modal-head,
.bedtime-history-panel .dating-modal-head,
.bedtime-export-panel .dating-modal-head {
  border-bottom-color: rgba(250, 140, 203, 0.18);
}

.dating-modal-title {
  min-width: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dating-modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.dating-icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  background: var(--glass);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.dating-icon-btn:active {
  transform: scale(0.96);
  background: var(--glass-strong);
}

.bedtime-word-panel .dating-modal-title,
.bedtime-continue-panel .dating-modal-title,
.bedtime-history-panel .dating-modal-title,
.bedtime-export-panel .dating-modal-title {
  color: #ffe1f0;
}

.bedtime-word-panel .dating-icon-btn,
.bedtime-continue-panel .dating-icon-btn,
.bedtime-history-panel .dating-icon-btn,
.bedtime-export-panel .dating-icon-btn {
  border-color: rgba(250, 140, 203, 0.34);
  background: rgba(255, 127, 190, 0.1);
  color: #ffd9ec;
}

.bedtime-role-list,
.bedtime-wb-list,
.bedtime-history-list {
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px;
}

.bedtime-role-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.bedtime-role-card {
  width: 100%;
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  background: var(--glass);
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.bedtime-role-card:active {
  transform: scale(0.992);
  border-color: var(--text);
}

.bedtime-role-avatar,
.bedtime-history-avatar {
  width: 54px;
  height: 54px;
  flex: 0 0 54px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  border: 1px solid var(--glass-border);
  background: var(--glass-strong);
  color: var(--text);
}

.bedtime-role-avatar img,
.bedtime-history-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.bedtime-role-main {
  min-width: 0;
  flex: 1;
}

.bedtime-role-name {
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bedtime-role-meta {
  margin-top: 6px;
  color: var(--text3);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dating-empty {
  padding: 28px 14px;
  text-align: center;
  color: var(--text3);
  font-size: 13px;
  line-height: 1.6;
}

.bedtime-wb-item {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-bottom: 1px solid var(--glass-border);
  cursor: pointer;
}

.bedtime-wb-item input {
  width: 18px;
  height: 18px;
  accent-color: var(--text);
}

.bedtime-wb-main {
  min-width: 0;
  flex: 1;
}

.bedtime-wb-name {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.bedtime-wb-meta {
  margin-top: 4px;
  color: var(--text3);
  font-size: 12px;
}

.dating-modal-footer {
  display: flex;
  gap: 10px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--glass-border);
}

.dating-primary-btn,
.dating-secondary-btn {
  flex: 1;
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.dating-primary-btn {
  background: var(--text);
  color: var(--bg);
  box-shadow: 0 10px 22px var(--glass-shadow);
}

.dating-secondary-btn {
  background: var(--glass);
  color: var(--text2);
  border: 1px solid var(--glass-border);
}

.bedtime-word-panel .dating-modal-footer,
.bedtime-continue-panel .dating-modal-footer,
.bedtime-history-panel .dating-modal-footer,
.bedtime-export-panel .dating-modal-footer {
  border-top-color: rgba(250, 140, 203, 0.16);
}

.bedtime-word-panel .dating-primary-btn,
.bedtime-continue-panel .dating-primary-btn,
.bedtime-history-panel .dating-primary-btn,
.bedtime-export-panel .dating-primary-btn {
  background: linear-gradient(135deg, #ff76b7, #f25da3);
  color: #fff;
  box-shadow: 0 10px 22px rgba(238, 67, 151, 0.28);
}

.bedtime-word-panel .dating-secondary-btn,
.bedtime-continue-panel .dating-secondary-btn,
.bedtime-history-panel .dating-secondary-btn,
.bedtime-export-panel .dating-secondary-btn {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 222, 240, 0.86);
  border-color: rgba(255, 157, 211, 0.22);
}

.dating-primary-btn:disabled,
.dating-secondary-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.bedtime-word-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px;
}

.bedtime-word-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: rgba(255, 220, 239, 0.78);
  font-size: 13px;
}

.bedtime-word-field input {
  width: 100%;
  height: 42px;
  padding: 0 10px;
  border: 1px solid rgba(255, 157, 211, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffe7f4;
  outline: none;
}

.bedtime-continue-text {
  padding: 20px 14px 8px;
  color: rgba(255, 225, 241, 0.88);
  text-align: center;
  font-size: 15px;
}

.bedtime-story-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 26px 14px calc(24px + env(safe-area-inset-bottom));
}

.bedtime-avatar-stage {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin: auto 0;
}

.bedtime-story-body.has-story .bedtime-avatar-stage {
  margin: 12px 0 14px;
  gap: 8px;
}

.bedtime-avatar-ring {
  position: relative;
  width: 148px;
  height: 148px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.bedtime-note {
  position: absolute;
  z-index: 2;
  color: #ff9ccc;
  font-size: 19px;
  line-height: 1;
  text-shadow: 0 0 12px rgba(255, 112, 188, 0.76);
  pointer-events: none;
  animation: bedtimeNoteFloat 2.7s ease-in-out infinite;
}

.note-a {
  left: 4px;
  top: 28px;
  animation-delay: 0s;
}

.note-b {
  right: -2px;
  top: 54px;
  font-size: 22px;
  animation-delay: 0.55s;
}

.note-c {
  left: 20px;
  bottom: 14px;
  font-size: 16px;
  animation-delay: 1.05s;
}

.bedtime-story-body.has-story .bedtime-avatar-ring {
  width: 86px;
  height: 86px;
}

.bedtime-story-body.has-story .bedtime-note {
  font-size: 13px;
}

.bedtime-story-body.has-story .note-a {
  left: -2px;
  top: 14px;
}

.bedtime-story-body.has-story .note-b {
  right: -6px;
  top: 30px;
  font-size: 15px;
}

.bedtime-story-body.has-story .note-c {
  left: 12px;
  bottom: 2px;
}

.bedtime-avatar-ring::before,
.bedtime-avatar-ring::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid rgba(255, 134, 199, 0.48);
  box-shadow:
    0 0 26px rgba(255, 106, 187, 0.36),
    inset 0 0 22px rgba(255, 129, 199, 0.18);
  animation: bedtimeGlow 2.8s ease-in-out infinite;
}

.bedtime-avatar-ring::after {
  inset: -10px;
  border-color: rgba(255, 182, 222, 0.22);
  animation-delay: -1.4s;
}

.bedtime-avatar {
  position: relative;
  z-index: 1;
  width: 124px;
  height: 124px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(255, 123, 189, 0.24), rgba(30, 16, 39, 0.96));
  border: 1px solid rgba(255, 196, 227, 0.4);
  color: #ffc1df;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.46);
}

.bedtime-story-body.has-story .bedtime-avatar {
  width: 72px;
  height: 72px;
}

.bedtime-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.bedtime-avatar-name {
  max-width: min(76vw, 420px);
  color: #ffe2f0;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bedtime-story-body.has-story .bedtime-avatar-name {
  font-size: 13px;
  color: rgba(255, 224, 241, 0.72);
}

.bedtime-story-content {
  width: min(720px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 0 2px 24px;
}

.bedtime-story-title {
  color: #ffe2f0;
  font-size: 22px;
  line-height: 1.35;
  font-weight: 800;
  text-align: center;
  margin: 0 0 2px;
}

.bedtime-story-meta {
  text-align: center;
  color: rgba(255, 214, 236, 0.58);
  font-size: 12px;
  margin-bottom: 6px;
}

.bedtime-segment {
  margin: 0;
  padding: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.86;
  font-size: 16px;
}

.bedtime-segment.story {
  color: rgba(244, 235, 255, 0.92);
}

.bedtime-segment.comment {
  color: #ff97cb;
  font-weight: 600;
}

.bedtime-history-panel {
  width: min(420px, calc(100vw - 24px));
}

.bedtime-history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: min(68vh, 560px);
}

.bedtime-history-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 48px 10px 10px;
  border: 1px solid rgba(255, 157, 211, 0.2);
  border-radius: 8px;
  background: rgba(255, 127, 190, 0.08);
  color: inherit;
  cursor: pointer;
}

.bedtime-history-export-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 157, 211, 0.28);
  border-radius: 8px;
  background: rgba(255, 127, 190, 0.1);
  color: #ffd9ec;
  cursor: pointer;
}

.bedtime-history-export-btn:active {
  transform: scale(0.94);
  background: rgba(255, 127, 190, 0.18);
}

.bedtime-history-avatar {
  border-color: rgba(255, 159, 212, 0.35);
  background: rgba(255, 128, 190, 0.12);
  color: #ffadd6;
}

.bedtime-history-main {
  min-width: 0;
  flex: 1;
}

.bedtime-history-title {
  color: #ffe3f2;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bedtime-history-meta,
.bedtime-history-preview {
  margin-top: 5px;
  color: rgba(255, 216, 238, 0.58);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bedtime-history-loading {
  padding: 12px;
  color: rgba(255, 216, 238, 0.6);
  text-align: center;
  font-size: 12px;
}

.bedtime-export-panel {
  width: min(360px, calc(100vw - 24px));
}

.bedtime-export-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  color: rgba(255, 220, 239, 0.78);
  font-size: 13px;
}

.bedtime-export-field input {
  width: 100%;
  height: 42px;
  padding: 0 10px;
  border: 1px solid rgba(255, 157, 211, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffe7f4;
  outline: none;
}

.bedtime-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 935;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 86, 170, 0.12), transparent 34%),
    rgba(0, 0, 0, 0.82);
  color: #ffc6e2;
}

.bedtime-loading-overlay.active {
  display: flex;
}

.bedtime-paw-loader {
  position: relative;
  width: 92px;
  height: 84px;
  filter: drop-shadow(0 0 24px rgba(255, 91, 172, 0.45));
  animation: bedtimePawFloat 1.9s ease-in-out infinite;
}

.bedtime-paw-toe,
.bedtime-paw-pad {
  position: absolute;
  display: block;
  background: linear-gradient(145deg, #050306, #ff76b7 72%);
  border: 1px solid rgba(255, 181, 222, 0.48);
  box-shadow:
    inset 0 0 12px rgba(0, 0, 0, 0.42),
    0 0 18px rgba(255, 91, 172, 0.36);
}

.bedtime-paw-toe {
  width: 23px;
  height: 28px;
  border-radius: 50%;
  animation: bedtimeToePulse 1.2s ease-in-out infinite;
}

.bedtime-paw-pad {
  left: 25px;
  bottom: 4px;
  width: 44px;
  height: 42px;
  border-radius: 48% 48% 52% 52%;
  animation: bedtimePadPulse 1.2s ease-in-out infinite;
}

.toe-a { left: 8px; top: 28px; transform: rotate(-24deg); animation-delay: 0s; }
.toe-b { left: 24px; top: 8px; transform: rotate(-8deg); animation-delay: 0.12s; }
.toe-c { left: 48px; top: 8px; transform: rotate(8deg); animation-delay: 0.24s; }
.toe-d { right: 8px; top: 28px; transform: rotate(24deg); animation-delay: 0.36s; }

.bedtime-loading-text {
  font-size: 13px;
  letter-spacing: 0;
  color: rgba(255, 213, 237, 0.8);
}

@keyframes bedtimeGlow {
  0%, 100% { transform: scale(0.96); opacity: 0.58; }
  50% { transform: scale(1.08); opacity: 1; }
}

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

@keyframes bedtimeNoteFloat {
  0%, 100% { transform: translateY(0) rotate(-8deg); opacity: 0.54; }
  50% { transform: translateY(-8px) rotate(9deg); opacity: 1; }
}

@keyframes bedtimeToePulse {
  0%, 100% { opacity: 0.68; }
  50% { opacity: 1; }
}

@keyframes bedtimePadPulse {
  0%, 100% { transform: scale(0.98); }
  50% { transform: scale(1.04); }
}

@media (max-width: 420px) {
  .dating-content {
    padding-left: 10px;
    padding-right: 10px;
  }

  .bedtime-avatar-ring {
    width: 136px;
    height: 136px;
  }

  .bedtime-avatar {
    width: 114px;
    height: 114px;
  }

  .bedtime-segment {
    font-size: 15px;
    line-height: 1.82;
  }
}
