* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  color: #e8e8f0; height: 100vh; overflow: hidden;
}
.muted { color: #9a9ab0; font-size: .9rem; margin-bottom: 1.2rem; }
.error { color: #ff6b81; margin-bottom: .8rem; font-size: .9rem;
  background: rgba(255,107,129,.1); padding: .6rem; border-radius: 8px; }
.info { color: #6bcf9f; margin-bottom: .8rem; font-size: .9rem;
  background: rgba(107,207,159,.1); padding: .6rem; border-radius: 8px; }
.field-error { color: #ff6b81; font-size: .8rem; margin: -.4rem 0 .8rem; text-align: left; }

/* ---- Auth ---- */
.auth-screen {
  height: 100vh; display: flex; align-items: center; justify-content: center;
}
.card {
  background: #20203a; padding: 2.5rem; border-radius: 16px;
  width: 90%; max-width: 380px; text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,.4);
}
.card h1 { margin-bottom: .3rem; }
.card input {
  width: 100%; padding: .8rem 1rem; margin-bottom: .8rem;
  border: 1px solid #3a3a5a; border-radius: 10px;
  background: #16162a; color: #fff; font-size: 1rem;
}
.card button {
  width: 100%; padding: .8rem; border: none; border-radius: 10px;
  background: #6c5ce7; color: #fff; font-size: 1rem; cursor: pointer;
  transition: opacity .2s;
}
.card button:hover { opacity: .88; }
.switch { margin-top: 1.2rem; font-size: .9rem; color: #9a9ab0; }
.switch a { color: #8c7cff; text-decoration: none; }
.switch a:hover { text-decoration: underline; }
.switch .secondary-button {
  display: block; width: 100%; margin-top: .8rem; padding: .75rem;
  border: 1px solid #6c5ce7; border-radius: 10px;
  color: #fff; text-align: center;
}
.switch .secondary-button:hover {
  background: rgba(108, 92, 231, .18); text-decoration: none;
}

/* ---- Chat ---- */
.chat-screen { height: 100vh; display: flex; flex-direction: column; }
.profile-screen { height: 100vh; display: flex; flex-direction: column; }
header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.2rem; background: #20203a; border-bottom: 1px solid #2e2e4a;
}
.header-left { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.header-right { display: flex; gap: .5rem; align-items: center; }
.inline-form { display: flex; gap: .4rem; align-items: center; margin: 0; }
header button {
  padding: .5rem .9rem; border: none; border-radius: 8px;
  font-size: .85rem; cursor: pointer; background: #6c5ce7; color: #fff;
}
header button.secondary { background: #3a3a5a; }
header button:hover { opacity: .88; }
.header-button {
  padding: .5rem .9rem; border-radius: 8px; color: #fff;
  font-size: .85rem; text-decoration: none; background: #6c5ce7;
}
.header-button.secondary { background: #3a3a5a; }
.header-button:hover { opacity: .88; }
.history-toggle, .history-close { display: none; }

.chat-layout { flex: 1; min-height: 0; display: flex; }
.conversation-sidebar {
  width: 260px; flex: 0 0 260px; overflow-y: auto;
  background: #1b1b31; border-right: 1px solid #2e2e4a;
}
.sidebar-heading {
  position: sticky; top: 0; z-index: 1; display: flex;
  justify-content: space-between; align-items: center;
  padding: 1rem; background: #1b1b31; border-bottom: 1px solid #2e2e4a;
}
.conversation-list { display: flex; flex-direction: column; padding: .5rem; gap: .25rem; }
.conversation-item {
  min-width: 0; display: flex; align-items: center; gap: .75rem;
  padding: .75rem; border-radius: 6px; color: #e8e8f0;
  text-decoration: none; border: 1px solid transparent;
}
.conversation-item:hover { background: #262642; }
.conversation-item.active { background: #303052; border-color: #555584; }
.conversation-avatar {
  width: 36px; height: 36px; flex: 0 0 36px; display: grid;
  place-items: center; border-radius: 50%; font-weight: 700; color: #fff;
}
.conversation-avatar.novia { background: #8d3f72; }
.conversation-avatar.novio { background: #286b78; }
.conversation-info { min-width: 0; display: flex; flex-direction: column; gap: .15rem; }
.conversation-info strong {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem;
}
.conversation-info small { color: #9292aa; font-size: .75rem; }
.chat-panel { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.history-overlay { display: none; }

.profile-picker {
  flex: 1; overflow-y: auto; display: flex; align-items: center;
  justify-content: center; flex-direction: column; padding: 2rem 1.25rem;
}
.profile-picker-heading { text-align: center; margin-bottom: 2rem; }
.profile-picker-heading h1 { font-size: 2rem; margin-bottom: .5rem; }
.profile-picker-heading p { color: #aaaac0; }
.profile-options {
  width: 100%; max-width: 720px; display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem;
}
.profile-form { min-width: 0; }
.profile-card {
  width: 100%; min-height: 290px; padding: 1.5rem; display: flex;
  flex-direction: column; align-items: center; justify-content: center;
  gap: .7rem; border: 1px solid #3a3a5a; border-radius: 8px;
  background: #20203a; color: #fff; cursor: pointer; font: inherit;
  transition: border-color .2s, transform .2s, background .2s;
}
.profile-card:hover {
  border-color: #8c7cff; background: #292947; transform: translateY(-2px);
}
.profile-card:focus-visible { outline: 3px solid #8c7cff; outline-offset: 3px; }
.profile-avatar {
  width: 112px; height: 112px; display: block; object-fit: cover;
  border-radius: 50%; border: 3px solid rgba(255, 255, 255, .18);
}
.profile-name { font-size: 1.35rem; font-weight: 700; }
.profile-description { color: #aaaac0; line-height: 1.4; }
.profile-action {
  margin-top: .55rem; padding: .65rem 1rem; border-radius: 6px;
  background: #6c5ce7; color: #fff; font-weight: 600;
}

main {
  flex: 1; overflow-y: auto; padding: 1.5rem;
  display: flex; flex-direction: column; gap: .8rem;
}
.bubble {
  max-width: 75%; padding: .8rem 1.1rem; border-radius: 18px;
  line-height: 1.45; white-space: pre-wrap; word-wrap: break-word;
}
.bubble.user { align-self: flex-end; background: #6c5ce7; border-bottom-right-radius: 4px; }
.bubble.assistant { align-self: flex-start; background: #2e2e4a; border-bottom-left-radius: 4px; }
.bubble.typing { font-style: italic; color: #9a9ab0; }

footer {
  display: flex; gap: .6rem; padding: 1rem 1.2rem;
  background: #20203a; border-top: 1px solid #2e2e4a;
}
footer input {
  flex: 1; padding: .8rem 1rem; border: 1px solid #3a3a5a;
  border-radius: 24px; background: #16162a; color: #fff; font-size: 1rem;
}
footer button {
  padding: .8rem 1.5rem; border: none; border-radius: 24px;
  background: #6c5ce7; color: #fff; font-size: 1rem; cursor: pointer;
}
footer button:hover { opacity: .88; }
footer button:disabled { opacity: .5; cursor: not-allowed; }
.disclaimer {
  text-align: center; font-size: .72rem; color: #6a6a85;
  padding: .4rem; background: #20203a;
}

@media (max-width: 600px) {
  .profile-options { grid-template-columns: 1fr; }
  .profile-card { min-height: 220px; }
  .header-button { padding: .5rem .65rem; }
  .persona-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .history-toggle {
    display: inline-flex; padding: .5rem .65rem; background: #3a3a5a;
  }
  .conversation-sidebar {
    position: fixed; z-index: 20; top: 0; bottom: 0; left: 0;
    width: min(84vw, 300px); transform: translateX(-100%);
    transition: transform .2s ease;
  }
  .history-close {
    display: grid; place-items: center; width: 32px; height: 32px;
    padding: 0; background: #3a3a5a; font-size: 1.25rem;
  }
  .history-overlay {
    position: fixed; z-index: 15; inset: 0; border: 0;
    background: rgba(0, 0, 0, .55);
  }
  .history-open .conversation-sidebar { transform: translateX(0); }
  .history-open .history-overlay { display: block; }
}
