/*
 * Our Secret Diary v4.0 — CSS
 * Written from scratch to avoid all theme conflicts
 */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,600;1,400&family=Lato:wght@400;700&display=swap');

/* ── Scope everything tightly ── */
#osd-wrap {
  all: initial;
  display: block;
  font-family: 'Lato', sans-serif;
  font-size: 14px;
  color: #4a1a2e;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;

  /* CSS vars */
  --pk:      #c2185b;
  --pk-hot:  #e91e8c;
  --pk-soft: #f48fb1;
  --pk-pale: #fce4ec;
  --pk-blush:#fff0f5;
  --pk-page: #fffbfd;
  --pk-line: #fde8f0;
  --bdr:     #f0c4d8;
  --tm:      #8d4a6a;
  --tl:      #c0849e;
}

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

/* ══════════════════════════
   PAGE TITLE (Kids Art Info)
══════════════════════════ */
#osd-page-title {
  font-family: 'Playfair Display', serif;
  font-size: 28px;
  font-weight: 600;
  color: #c2185b;
  text-align: center;
  padding: 1rem 1rem 0.5rem;
  letter-spacing: 1px;
}

/* ══════════════════════════
   LOGIN SCREEN
══════════════════════════ */
#osd-login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 520px;
  padding: 1rem 1rem 1.5rem;
  background-image: url('');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border-radius: 16px;
  position: relative;
}
#osd-login-screen::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 182, 193, 0.18);
  border-radius: 16px;
  pointer-events: none;
}

#osd-login {
  display: flex;
  align-items: stretch;
  width: 100%;
  max-width: 340px;
  border-radius: 6px 20px 20px 6px;
  overflow: hidden;
  box-shadow: -6px 6px 0 #e48aaa, 0 14px 40px rgba(194,24,91,.35);
  background: linear-gradient(160deg, rgba(255,248,251,0.97) 0%, rgba(252,228,236,0.97) 100%);
  position: relative;
  z-index: 1;
}

.osd-spine {
  width: 22px;
  flex-shrink: 0;
  background: linear-gradient(180deg, #c2185b 0%, #880e4f 100%);
  position: relative;
}
.osd-spine::after {
  content: '';
}

.osd-cover-body {
  flex: 1;
  padding: 1.6rem 1.6rem 1.8rem;
  text-align: center;
  border-left: 3px solid #f48fb1;
}

/* Big heart replaces lock+title */
#osd-heart {
  font-size: 56px;
  line-height: 1;
  margin-bottom: 8px;
  animation: osd-pulse 1.6s ease-in-out infinite;
}
@keyframes osd-pulse {
  0%,100% { transform: scale(1); }
  50%      { transform: scale(1.1); }
}

.osd-subtitle {
  font-size: 12px;
  color: #c0849e;
  margin-bottom: 12px;
}

.osd-petals {
  font-size: 17px;
  letter-spacing: 5px;
  margin-bottom: 1.6rem;
}

.osd-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

.osd-form input {
  display: block;
  width: 100%;
  padding: 10px 16px;
  border: 1.5px solid #f0c4d8;
  border-radius: 30px;
  font-size: 14px;
  font-family: 'Lato', sans-serif;
  background: rgba(255,255,255,.85);
  color: #4a1a2e;
  outline: none;
  -webkit-appearance: none;
  transition: border-color .2s, box-shadow .2s;
}
.osd-form input:focus {
  border-color: #f48fb1;
  box-shadow: 0 0 0 3px rgba(244,143,177,.2);
  background: #fff;
}
.osd-form input::placeholder {
  color: #c0849e;
  font-style: italic;
}

#osd-login-btn {
  display: block;
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #e91e8c 0%, #c2185b 100%);
  color: #fff;
  border: none;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 700;
  font-family: 'Lato', sans-serif;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(194,24,91,.35);
  transition: opacity .2s, transform .1s;
}
#osd-login-btn:hover  { opacity: .88; }
#osd-login-btn:active { transform: scale(.97); }

#osd-login-err {
  display: block;
  min-height: 16px;
  font-size: 12px;
  color: #c0392b;
  text-align: center;
}

/* ══════════════════════════
   DIARY SHELL
══════════════════════════ */

/* ★ PHOTO FRAME — sits completely OUTSIDE the diary box ★ */
#osd-photo-frame {
  display: none; /* shown by JS after login */
  width: 100%;
  margin-bottom: 14px;
  border-radius: 18px;
  overflow: hidden;
  border: 3px solid #f48fb1;
  box-shadow: 0 6px 24px rgba(194,24,91,.18);
  position: relative;
  background: #fce4ec;
}

#osd-photo-img {
  display: block;
  width: 100%;
  height: auto;        /* full image, no crop */
  max-height: none;
  object-fit: unset;
}

#osd-photo-caption {
  width: 100%;
  text-align: center;
  padding: 8px 10px 10px;
  background: linear-gradient(to bottom, rgba(252,228,236,.9), #fce4ec);
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 14px;
  color: #c2185b;
  letter-spacing: .5px;
}
#osd-diary {
  display: none;
  flex-direction: column;
  width: 100%;
  border-radius: 6px 18px 18px 6px;
  overflow: hidden;
  box-shadow: -6px 6px 0 #e48aaa, 0 14px 40px rgba(194,24,91,.18);
  background: #fffbfd;
  min-height: 580px;
  position: relative;
}

/* Photo background overlay behind the diary card */
#osd-diary-bg {
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  min-height: 660px;
  background-image: url(''); /* set by JS */
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  border-radius: 16px;
  position: relative;
}
#osd-diary-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 220, 235, 0.45);
  border-radius: 16px;
  pointer-events: none;
}
#osd-diary-bg > #osd-diary {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 900px;
  min-height: 580px;
  background: rgba(255, 251, 253, 0.94);
  backdrop-filter: blur(2px);
}

/* ── Top bar ── */
#osd-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  padding: 0 16px;
  gap: 12px;
  background: linear-gradient(135deg, #c2185b 0%, #880e4f 100%);
  border-bottom: 3px solid #880e4f;
  flex-shrink: 0;
}

#osd-bar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

#osd-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  background: rgba(255,255,255,.2);
  border-radius: 20px;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

#osd-status-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  color: rgba(255,255,255,.88);
  font-size: 11px;
  min-width: 0;
  overflow: hidden;
}
#osd-status-txt {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.osd-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: rgba(255,255,255,.3);
}
.osd-dot.online  { background: #a5d6a7; box-shadow: 0 0 0 2px rgba(165,214,167,.3); }
.osd-dot.offline { background: rgba(255,255,255,.3); }

#osd-unread-badge {
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  background: #fff;
  color: #c2185b;
  font-size: 10px;
  font-weight: 700;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}
#osd-unread-badge.show {
  display: inline-flex;
}

#osd-bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

#osd-bar-title {
  font-family: 'Playfair Display', serif;
  color: #fff;
  font-size: 15px;
  font-style: italic;
  white-space: nowrap;
}

#osd-logout-btn {
  display: inline-flex;
  align-items: center;
  padding: 5px 13px;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.4);
  border-radius: 20px;
  color: rgba(255,255,255,.95);
  font-size: 12px;
  font-family: 'Lato', sans-serif;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}
#osd-logout-btn:hover { background: rgba(255,255,255,.26); }

/* ── Pages layout ── */
#osd-pages {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Left decorative page */
#osd-left-page {
  width: 155px;
  flex-shrink: 0;
  background: linear-gradient(160deg, #fce4ec 0%, #fff0f5 100%);
  border-right: 2px solid #f0c4d8;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
}

#osd-deco { text-align: center; width: 100%; }

#osd-deco-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f48fb1, #f06292);
  border: 3px solid #fff;
  box-shadow: 0 4px 14px rgba(194,24,91,.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin: 0 auto 10px;
}

#osd-deco-name {
  font-family: 'Playfair Display', serif;
  font-size: 16px;
  font-weight: 600;
  color: #c2185b;
  margin-bottom: 2px;
}

.osd-deco-sub  { font-size: 11px; color: #c0849e; margin-bottom: 10px; }

.osd-deco-line {
  width: 36px;
  height: 1px;
  background: linear-gradient(to right, transparent, #f48fb1, transparent);
  margin: 0 auto 12px;
}

.osd-deco-flowers {
  font-size: 18px;
  line-height: 2.4;
  margin-bottom: 12px;
}

.osd-deco-quote {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 11px;
  color: #8d4a6a;
  line-height: 1.7;
}

/* Right writing page */
#osd-right-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background: #fffbfd;
}

/* ── Chat / lined area ── */
#osd-lined {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 20px 12px;
  background-color: #fffbfd;
  background-image: repeating-linear-gradient(
    to bottom, transparent, transparent 31px,
    #fde8f0 31px, #fde8f0 32px
  );
  background-position: 0 42px;
  -webkit-overflow-scrolling: touch;
}
#osd-lined::-webkit-scrollbar { width: 4px; }
#osd-lined::-webkit-scrollbar-thumb { background: #f48fb1; border-radius: 10px; }

#osd-messages {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 100%;
}

/* Empty state */
.osd-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 1rem;
  color: #c0849e;
}
.osd-empty-icon { font-size: 36px; margin-bottom: 10px; }
.osd-empty-text { font-family: 'Playfair Display', serif; font-style: italic; font-size: 14px; }

/* ── Date separator ── */
.osd-datesep {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
}
.osd-datesep::before,
.osd-datesep::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #f0c4d8;
}
.osd-datesep span {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 11px;
  color: #c0849e;
  white-space: nowrap;
}

/* ══════════════════════════
   MESSAGE ENTRIES — FIXED
══════════════════════════ */
.osd-entry {
  display: flex;
  flex-direction: column;
  /* mine = align right, theirs = align left */
}
.osd-entry.mine   { align-items: flex-end; }
.osd-entry.theirs { align-items: flex-start; }

.osd-entry-inner {
  max-width: 78%;
  min-width: 90px;
  position: relative;
}

/* Name + avatar row */
.osd-entry-head {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 4px;
}
.osd-entry.mine   .osd-entry-head { flex-direction: row-reverse; }
.osd-entry.theirs .osd-entry-head { flex-direction: row; }

.osd-ava {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}
.osd-entry.mine   .osd-ava { background: linear-gradient(135deg, #f06292, #e91e8c); }
.osd-entry.theirs .osd-ava { background: linear-gradient(135deg, #f8bbd0, #f48fb1); }

.osd-ename {
  font-family: 'Playfair Display', serif;
  font-size: 11px;
  font-weight: 600;
  color: #c2185b;
}

/* Bubble */
.osd-bubble {
  display: block;
  width: 100%;
  position: relative;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.6;
  color: #4a1a2e;
  word-break: break-word;
  border: 1px solid #f0c4d8;
  box-shadow: 1px 2px 8px rgba(194,24,91,.07);
  transition: box-shadow .2s;
}
.osd-entry.theirs .osd-bubble {
  background: rgba(255, 248, 251, 0.95);
  border-radius: 4px 16px 16px 16px;
}
.osd-entry.mine .osd-bubble {
  background: rgba(252, 228, 236, 0.96);
  border-color: #f48fb1;
  border-radius: 16px 4px 16px 16px;
}
.osd-bubble:hover { box-shadow: 1px 4px 14px rgba(194,24,91,.14); }

/* Action buttons (hover) */
.osd-bactions {
  position: absolute;
  top: -14px;
  display: none;
  gap: 4px;
  z-index: 5;
}
.osd-entry.mine   .osd-bactions { left: 8px; right: auto; }
.osd-entry.theirs .osd-bactions { right: 8px; left: auto; }
.osd-bubble:hover .osd-bactions { display: flex; }

.osd-abtn {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  background: #fff;
  border: 1px solid #f0c4d8;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  font-family: 'Lato', sans-serif;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
  line-height: 1.5;
  transition: background .15s;
}
.osd-abtn:hover { background: #fce4ec; }

/* Meta (time + seen) */
.osd-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 3px;
  padding: 0 4px;
  font-size: 11px;
  color: #c0849e;
}
.osd-entry.mine   .osd-meta { flex-direction: row-reverse; }
.osd-entry.theirs .osd-meta { flex-direction: row; }

.osd-seen { font-style: italic; }
.osd-seen.read   { color: #e91e8c; }
.osd-seen.unread { color: #c0849e; }

/* Reactions */
.osd-reacts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}
.osd-entry.mine   .osd-reacts { justify-content: flex-end; }
.osd-entry.theirs .osd-reacts { justify-content: flex-start; }

.osd-rchip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  background: #fff;
  border: 1px solid #f0c4d8;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  transition: background .15s;
}
.osd-rchip:hover     { background: #fce4ec; }
.osd-rchip.myreact   { background: #fce4ec; border-color: #f48fb1; }
.osd-rchip-count { font-size: 11px; font-weight: 700; color: #8d4a6a; }

/* Reaction picker */
#osd-rpicker {
  position: fixed;
  z-index: 99999;
  display: none;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: #fff;
  border: 1.5px solid #f0c4d8;
  border-radius: 30px;
  box-shadow: 0 6px 24px rgba(194,24,91,.18);
  flex-wrap: wrap;
  max-width: 220px;
}
#osd-rpicker.show { display: flex; }
#osd-rpicker span {
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  line-height: 1;
  transition: background .15s, transform .1s;
}
#osd-rpicker span:hover { background: #fce4ec; transform: scale(1.2); }

/* ══════════════════════════
   COMPOSE AREA — FULLY FIXED
══════════════════════════ */
#osd-compose-wrap {
  flex-shrink: 0;
  padding: 8px 14px 14px;
  border-top: 2px dashed #f0c4d8;
  background: linear-gradient(to bottom, #fff0f5, #fffbfd);
}

#osd-compose-label {
  display: block;
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 12px;
  color: #c0849e;
  margin-bottom: 7px;
}

#osd-emoji-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-bottom: 8px;
  font-size: 20px;
}
#osd-emoji-tray span {
  cursor: pointer;
  padding: 3px;
  border-radius: 6px;
  line-height: 1;
  transition: background .15s, transform .1s;
}
#osd-emoji-tray span:hover { background: #fce4ec; transform: scale(1.15); }

/* THE KEY FIX — compose row as proper flex */
#osd-compose-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  width: 100%;
}

#osd-emoji-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  font-size: 18px;
  line-height: 1;
  background: #fff;
  border: 1.5px solid #f0c4d8;
  border-radius: 50%;
  cursor: pointer;
  transition: background .15s;
}
/* Camera / image button */
#osd-img-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  font-size: 18px;
  line-height: 1;
  background: #fff;
  border: 1.5px solid #f0c4d8;
  border-radius: 50%;
  cursor: pointer;
  transition: background .15s;
}
#osd-img-btn:hover { background: #fce4ec; }

/* Image in chat bubble */
.osd-msg-img {
  display: block;
  max-width: 100%;
  max-height: 240px;
  width: auto;
  border-radius: 10px;
  cursor: pointer;
  transition: opacity .15s;
}
.osd-msg-img:hover { opacity: .92; }

/* Uploading spinner */
.osd-uploading {
  font-size: 12px;
  color: #c0849e;
  font-style: italic;
  padding: 4px 0;
}

#osd-compose {
  flex: 1 1 0%;
  min-width: 0;
  width: 0; /* forces flex to control width */
  display: block;
  padding: 9px 14px;
  border: 1.5px solid #f0c4d8;
  border-radius: 20px;
  font-size: 14px;
  font-family: 'Lato', sans-serif;
  color: #4a1a2e;
  background: #fff;
  resize: none;
  outline: none;
  line-height: 1.5;
  max-height: 90px;
  overflow-y: auto;
  transition: border-color .2s, box-shadow .2s;
}
#osd-compose:focus {
  border-color: #f48fb1;
  box-shadow: 0 0 0 3px rgba(244,143,177,.18);
}
#osd-compose::placeholder { color: #c0849e; font-style: italic; }

#osd-send-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  height: 38px;
  padding: 0 20px;
  background: linear-gradient(135deg, #e91e8c 0%, #c2185b 100%);
  color: #fff;
  border: none;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  font-family: 'Lato', sans-serif;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 3px 10px rgba(194,24,91,.3);
  transition: opacity .2s, transform .1s;
}
#osd-send-btn:hover    { opacity: .88; }
#osd-send-btn:active   { transform: scale(.97); }
#osd-send-btn:disabled { opacity: .6; cursor: not-allowed; }

/* ══════════════════════════
   MOBILE ≤ 640px
══════════════════════════ */
@media (max-width: 640px) {
  #osd-login-screen {
    min-height: auto;
    padding: 1.2rem .75rem;
    border-radius: 12px;
  }
  #osd-login {
    max-width: 100%;
    border-radius: 4px 12px 12px 4px;
    box-shadow: -4px 4px 0 #e48aaa, 0 8px 24px rgba(194,24,91,.18);
  }
  .osd-spine { width: 16px; }
  .osd-cover-body { padding: 1.5rem 1.2rem; }
  .osd-title { font-size: 20px !important; }

  #osd-diary-bg {
    padding: .5rem;
    border-radius: 12px;
    min-height: auto;
  }
  #osd-diary {
    border-radius: 4px 12px 12px 4px;
    box-shadow: -4px 4px 0 #e48aaa, 0 8px 24px rgba(194,24,91,.14);
    min-height: auto;
  }

  #osd-bar {
    height: auto;
    min-height: 48px;
    padding: 6px 10px;
    flex-wrap: wrap;
    gap: 4px;
  }
  #osd-bar-title { display: none; }
  #osd-chip      { font-size: 12px; padding: 3px 9px; }
  #osd-logout-btn { font-size: 11px; padding: 4px 9px; }

  #osd-photo-frame { border-radius: 12px; margin-bottom: 10px; }
  #osd-left-page { display: none; }

  #osd-lined { padding: 10px 12px 8px; }
  .osd-entry-inner { max-width: 92%; }

  #osd-compose-wrap { padding: 6px 10px 12px; }
  #osd-compose-row  { gap: 6px; }
  #osd-emoji-btn    { width: 32px; height: 32px; font-size: 16px; }
  #osd-compose      { padding: 8px 12px; font-size: 13px; }
  #osd-send-btn     { height: 36px; padding: 0 14px; font-size: 12px; }
}

@media (max-width: 380px) {
  #osd-status-wrap { display: none; }
  .osd-entry-inner { max-width: 95%; }
  #osd-send-btn    { padding: 0 10px; font-size: 11px; }
}

/* Message text span */
.osd-msg-text {
  display: block;
  white-space: pre-wrap;
  word-break: break-word;
}
