:root {
  --bg-primary: #0b0e14;
  --bg-secondary: #121824;
  --bg-card: #182030;
  --bg-input: #1e293b;
  --border-color: #27354a;
  
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --dipper-accent: #38bdf8;
  --dipper-bubble: #075985;
  --dipper-bubble-text: #e0f2fe;
  
  --hisaru-accent: #f472b6;
  --hisaru-bubble: #9d174d;
  --hisaru-bubble-text: #fce7f3;

  --partner-bubble: #1e293b;
  --partner-bubble-text: #f1f5f9;

  --danger: #ef4444;
  --success: #10b981;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* --- Login Screen --- */
.login-screen {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at top center, #1e293b 0%, #0b0e14 70%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  padding: 1rem;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 1.5rem;
  padding: 2.25rem 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  text-align: center;
  animation: fadeInScale 0.3s ease-out;
}

.login-brand {
  margin-bottom: 1.75rem;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.login-brand h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #38bdf8, #f472b6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-brand p {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.input-group {
  position: relative;
  margin-bottom: 1.25rem;
  text-align: left;
}

.input-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-group input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 0.85rem 2.75rem 0.85rem 1rem;
  color: var(--text-primary);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.input-group input:focus {
  border-color: #38bdf8;
}

.toggle-password {
  position: absolute;
  right: 0.85rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem;
}

.toggle-password:hover {
  color: var(--text-primary);
}

.btn-primary {
  width: 100%;
  padding: 0.85rem;
  background: linear-gradient(135deg, #0284c7, #db2777);
  border: none;
  border-radius: 0.75rem;
  color: white;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary:hover {
  opacity: 0.95;
}

.btn-primary:active {
  transform: scale(0.98);
}

.login-error {
  margin-top: 1rem;
  padding: 0.6rem;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 0.5rem;
  color: #fca5a5;
  font-size: 0.825rem;
  display: none;
}

/* --- Chat Container --- */
.chat-app {
  width: 100%;
  max-width: 900px;
  height: 100dvh;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

@media (min-width: 901px) {
  .chat-app {
    height: 94dvh;
    border-radius: 1.25rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    border: 1px solid var(--border-color);
  }
}

/* Header */
.chat-header {
  height: 68px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  z-index: 10;
  flex-shrink: 0;
}

.partner-info {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.avatar-wrapper {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #253348;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  user-select: none;
}

.status-dot {
  position: absolute;
  bottom: 0px;
  right: 0px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #64748b;
  border: 2px solid var(--bg-card);
  transition: background-color 0.3s;
}

.status-dot.online {
  background: #10b981;
}

.partner-text h2 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.partner-status {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.partner-status.online {
  color: #34d399;
}

.partner-status.typing {
  color: #38bdf8;
  font-style: italic;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: var(--bg-input);
  color: var(--text-primary);
}

/* Messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background-color: #0b0e14;
  background-image: radial-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 24px 24px;
  scroll-behavior: smooth;
}

.date-divider {
  align-self: center;
  background: rgba(30, 41, 59, 0.8);
  backdrop-filter: blur(4px);
  border: 1px solid var(--border-color);
  padding: 0.25rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin: 0.5rem 0;
}

/* Bubbles */
.message-bubble {
  max-width: 78%;
  display: flex;
  flex-direction: column;
  padding: 0.65rem 0.9rem;
  border-radius: 1.15rem;
  position: relative;
  word-wrap: break-word;
  animation: messageSlideIn 0.2s ease-out;
}

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

.message-bubble.incoming {
  align-self: flex-start;
  background: var(--partner-bubble);
  color: var(--partner-bubble-text);
  border-bottom-left-radius: 0.25rem;
}

.message-bubble.outgoing {
  align-self: flex-end;
  border-bottom-right-radius: 0.25rem;
}

.message-bubble.outgoing.theme-dipper {
  background: var(--dipper-bubble);
  color: var(--dipper-bubble-text);
}

.message-bubble.outgoing.theme-hisaru {
  background: var(--hisaru-bubble);
  color: var(--hisaru-bubble-text);
}

.message-sender-name {
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
  display: block;
}

.message-bubble.incoming .message-sender-name {
  color: var(--text-secondary);
}

.message-text {
  font-size: 0.95rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.message-text a {
  color: #38bdf8;
  text-decoration: underline;
}

.message-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.3rem;
  margin-top: 0.3rem;
  font-size: 0.7rem;
  opacity: 0.7;
}

.message-check {
  display: inline-flex;
}

/* Image in bubble */
.message-image-container {
  border-radius: 0.75rem;
  overflow: hidden;
  margin-top: 0.2rem;
  cursor: pointer;
  max-width: 320px;
}

.message-image-container img {
  width: 100%;
  height: auto;
  max-height: 380px;
  object-fit: cover;
  display: block;
  border-radius: 0.75rem;
  transition: transform 0.2s ease;
}

.message-image-container:hover img {
  transform: scale(1.02);
}

/* Audio Player in bubble */
.audio-player {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 230px;
  padding: 0.25rem 0;
}

.audio-play-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.1s;
}

.audio-play-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.audio-play-btn:active {
  transform: scale(0.92);
}

.audio-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.audio-progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 9999px;
  position: relative;
  cursor: pointer;
}

.audio-progress-fill {
  height: 100%;
  background: white;
  border-radius: 9999px;
  width: 0%;
  pointer-events: none;
}

.audio-timing {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  opacity: 0.8;
}

.audio-speed-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: inherit;
  font-size: 0.7rem;
  padding: 0.15rem 0.35rem;
  border-radius: 0.25rem;
  cursor: pointer;
}

/* Chat Input Bar */
.chat-input-bar {
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: flex-end;
  gap: 0.65rem;
  position: relative;
  flex-shrink: 0;
}

.chat-input-wrapper {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 1.5rem;
  display: flex;
  align-items: center;
  padding: 0.35rem 0.85rem;
  min-height: 44px;
}

.chat-input {
  width: 100%;
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  resize: none;
  max-height: 120px;
  outline: none;
  line-height: 1.4;
  padding: 0.35rem 0;
}

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

.btn-circle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.1s, background 0.2s;
}

.btn-circle:active {
  transform: scale(0.92);
}

.btn-attach {
  background: none;
  color: var(--text-secondary);
}

.btn-attach:hover {
  background: var(--bg-input);
  color: var(--text-primary);
}

.btn-mic {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-mic:hover {
  background: #28374d;
}

.btn-mic.recording {
  background: #ef4444;
  color: white;
  border-color: #ef4444;
  animation: pulseMic 1.2s infinite;
}

@keyframes pulseMic {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.btn-send {
  background: #0284c7;
  color: white;
}

.btn-send:hover {
  background: #0369a1;
}

/* Audio Recording Panel */
.recording-bar {
  position: absolute;
  inset: 0;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  z-index: 20;
  animation: fadeIn 0.2s ease-out;
}

.recording-status {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.rec-blinking-dot {
  width: 12px;
  height: 12px;
  background: #ef4444;
  border-radius: 50%;
  animation: blink 1s infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.rec-timer {
  font-family: monospace;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.rec-wave-text {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.recording-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-cancel-rec {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-cancel-rec:hover {
  background: rgba(239, 68, 68, 0.25);
}

/* Lightbox Modal */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1.5rem;
  cursor: zoom-out;
}

.lightbox img {
  max-width: 95vw;
  max-height: 90vh;
  border-radius: 0.75rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
  cursor: default;
}

.lightbox-close {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: white;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Animations & Utilities */
@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

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

.hidden {
  display: none !important;
}

/* ==========================================================================
   Tema Hello Kitty & Fresitas 🎀🍓 (Exclusivo para Hisaru)
   ========================================================================== */
.chat-app.theme-hisaru-kitty {
  --bg-secondary: #190d18;
  --bg-card: #281225;
  --bg-input: #341830;
  --border-color: #55244e;
  --text-primary: #fff5f8;
  --text-secondary: #fecdd3;
  --text-muted: #f43f5e;
  border-color: #632658;
  box-shadow: 0 25px 60px -12px rgba(255, 77, 109, 0.28);
}

.chat-app.theme-hisaru-kitty .chat-header {
  background: linear-gradient(90deg, #2a1127 0%, #3a1636 100%);
  border-bottom: 1.5px solid #5a2651;
}

.chat-app.theme-hisaru-kitty .partner-info::after {
  content: '🎀🍓';
  font-size: 1.15rem;
  margin-left: 0.35rem;
  filter: drop-shadow(0 2px 4px rgba(255, 77, 109, 0.4));
}

.chat-app.theme-hisaru-kitty .avatar-wrapper {
  background: #3d1b38;
  border: 2px solid #ff758f;
  box-shadow: 0 0 12px rgba(255, 117, 143, 0.45);
}

.chat-app.theme-hisaru-kitty .chat-messages {
  background-color: #140a13;
  background-image: 
    radial-gradient(#ff758f 0.9px, transparent 0.9px),
    radial-gradient(#ff4d6d 0.9px, #140a13 0.9px);
  background-size: 30px 30px;
  background-position: 0 0, 15px 15px;
}

.chat-app.theme-hisaru-kitty .date-divider {
  background: rgba(56, 24, 51, 0.85);
  border: 1px solid #732a67;
  color: #ffccd5;
}

/* Burbujas de Hisaru (propias) */
.chat-app.theme-hisaru-kitty .message-bubble.outgoing {
  background: linear-gradient(135deg, #ff4d6d 0%, #ff758f 100%);
  color: #ffffff;
  box-shadow: 0 5px 15px rgba(255, 77, 109, 0.35);
  border-bottom-right-radius: 0.3rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.chat-app.theme-hisaru-kitty .message-bubble.outgoing .message-sender-name {
  color: #fff0f3;
}

.chat-app.theme-hisaru-kitty .message-bubble.outgoing .message-meta {
  color: #ffe4e9;
  opacity: 0.9;
}

/* Burbujas entrantes de Dipper vistas por Hisaru */
.chat-app.theme-hisaru-kitty .message-bubble.incoming {
  background: #281326;
  border: 1.5px solid #4d2047;
  color: #fff0f3;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.chat-app.theme-hisaru-kitty .message-bubble.incoming .message-sender-name {
  color: #ff8fa3;
}

/* Barra de entrada */
.chat-app.theme-hisaru-kitty .chat-input-bar {
  background: #251222;
  border-top: 1.5px solid #52234b;
}

.chat-app.theme-hisaru-kitty .chat-input-wrapper {
  background: #33172e;
  border: 1.5px solid #5d2754;
}

.chat-app.theme-hisaru-kitty .chat-input-wrapper:focus-within {
  border-color: #ff758f;
  box-shadow: 0 0 10px rgba(255, 117, 143, 0.3);
}

.chat-app.theme-hisaru-kitty .btn-send {
  background: linear-gradient(135deg, #ff4d6d, #ff758f);
  box-shadow: 0 4px 12px rgba(255, 77, 109, 0.45);
}

.chat-app.theme-hisaru-kitty .btn-send:hover {
  filter: brightness(1.1);
}

.chat-app.theme-hisaru-kitty .btn-mic {
  color: #ff758f;
  border-color: #5d2754;
}

.chat-app.theme-hisaru-kitty .btn-mic:hover {
  background: #3e1b38;
  color: #ffccd5;
}

.chat-app.theme-hisaru-kitty .btn-attach {
  color: #ff8fa3;
}

.chat-app.theme-hisaru-kitty .btn-attach:hover {
  background: #3a1934;
  color: #fff0f3;
}

/* Reproductor de audio Hello Kitty */
.chat-app.theme-hisaru-kitty .audio-play-btn {
  background: rgba(255, 255, 255, 0.25);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.chat-app.theme-hisaru-kitty .audio-progress-fill {
  background: #fff0f3;
  box-shadow: 0 0 8px #ffffff;
}

/* Barra de grabación de voz en tema Hello Kitty */
.chat-app.theme-hisaru-kitty .recording-bar {
  background: #2a1327;
  border-top: 1.5px solid #ff4d6d;
}

.chat-app.theme-hisaru-kitty .rec-blinking-dot {
  background: #ff4d6d;
  box-shadow: 0 0 8px #ff4d6d;
}

