:root {
  --oled-black: #000000;
  --oled-white: #ffffff;
  --oled-grey: #131313;
  --accent: #191919;
  --oled-purple: #a987ff;
  --oled-pink: #ff73b4;
  --chat-ai-bubble: transparent;
  --chat-user-bubble: transparent;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--oled-black);
  min-height: 100vh;
  font-family: 'Nunito', Arial, sans-serif;
  color: var(--oled-white);
}

header {
  background: var(--oled-black);
  border: none;
  text-align: center;
  padding: 1.6em 0 1em 0;
}

.logo {
  font-weight: bold;
  color: var(--oled-purple);
  letter-spacing: 1px;
  font-size: 2.1em;
}

.subtitle {
  color: var(--oled-white);
  opacity: 0.6;
  font-size: 1.1em;
  letter-spacing: .2em;
  margin-top: .3em;
}

main {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 1.8em 0.8em 1.5em 0.8em;
  min-height: 60vh;
  width: 100%;
  flex-direction: column;
  align-items: center;
}

.character-form {
  background: var(--oled-grey);
  border-radius: 18px;
  box-shadow: 0 3px 24px #0c002f44;
  padding: 1.5em 1.3em;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  z-index: 2;
}

.form-group {
  margin-bottom: 1.2em;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: .35em;
  color: var(--oled-white);
  font-size: 1.05em;
  opacity: 0.88;
}

input[type="text"], textarea {
  width: 100%;
  border: none;
  border-radius: 0;
  padding: .8em .85em;
  font-size: 1em;
  margin-top: .15em;
  background: transparent;
  color: var(--oled-white);
  font-family: inherit;
  outline: none;
  box-shadow: none;
  transition: box-shadow 0.19s;
  border-bottom: 2px solid #43277900;
}

input[type="text"]:focus, textarea:focus {
  box-shadow: 0 2px 0 0 var(--oled-purple);
  border-bottom: 2px solid var(--oled-purple);
}

textarea {
  resize: vertical;
  min-height: 2.5em;
}

.required {
  color: var(--oled-pink);
  font-size: .95em;
}

.optional {
  color: #666;
  font-size: .93em;
  font-style: italic;
  opacity: 0.6;
}

.create-btn {
  background: var(--oled-black);
  color: var(--oled-purple);
  font-weight: bold;
  border: 2px solid var(--oled-purple);
  border-radius: 28px;
  font-size: 1.09em;
  padding: .85em 1.42em;
  margin: .8em 0 .4em 0;
  width: 100%;
  box-shadow: 0 1px 7px #1a002a66;
  cursor: pointer;
  transition: background .18s, filter 0.16s;
  filter: brightness(1.12) contrast(1.12);
}

.create-btn:active,
.create-btn:focus {
  background: var(--oled-purple);
  color: var(--oled-black);
  filter: brightness(1.32);
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  z-index: 1000;
  inset: 0;
  background: rgb(0 0 0 / 0.93);
  display: none;
  justify-content: center;
  align-items: center;
  text-align: center;
}

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

.loading-center {
  text-align: center;
  margin: auto;
}

.loading-text {
  color: var(--oled-white);
  font-size: 1.16em;
  font-weight: 600;
  margin-top: 2em;
  letter-spacing: 0.04em;
}

.spinner {
  border: 4px solid rgba(169,135,255,0.15);
  border-top: 4px solid var(--oled-purple);
  border-radius: 50%;
  width: 2.5rem;
  height: 2.5rem;
  animation: spin 1s linear infinite;
  margin: 0 auto;
  margin-top: 4em;
}
@keyframes spin {
  0% { transform: rotate(0deg);}
  100% { transform: rotate(360deg);}
}

/* --- Chat Interface NEW --- */
.myriva-chat-root {
  height: 100vh;
  min-height: 100vh;
  background: var(--oled-black);
  display: flex;
  flex-direction: column;
}

.myriva-chat-header {
  background: var(--accent);
  display: flex;
  align-items: center;
  padding: 1.2em 1.1em 1em 1.1em;
  border-radius: 0 0 22px 22px;
  box-shadow: 0 2px 24px #21112432;
  gap: .9em;
}

.myriva-chat-avatar {
  border-radius: 50%;
  background: #232323;
  width: 54px;
  height: 54px;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid var(--oled-purple);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 11px #1e023b99;
}

.myriva-chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.myriva-chat-meta {
  display: flex;
  flex-direction: column;
  gap: 0.28em;
  overflow: hidden;
}
.myriva-chat-name {
  font-weight: bold;
  color: var(--oled-purple);
  font-size: 1.17em;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}
.myriva-chat-desc {
  color: var(--oled-white);
  opacity: 0.67;
  font-size: .98em;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}
/* CHAT SCROLL AREA */
.myriva-chat-scroll {
  flex: 1;
  overflow-y: auto;
  background: transparent;
  padding: 0 0.5em 0.5em 0.5em;
  display: flex;
  flex-direction: column;
  gap: 0.5em;
  scroll-behavior: smooth;
  margin-bottom: 1.2em;
  padding-bottom: 4.3em !important; /* enough for floating bar on mobile */
}

.myriva-chat-bubble {
  max-width: 82vw;
  width: fit-content;
  padding: 0.82em 1.15em;
  border-radius: 20px 20px 14px 8px;
  margin: .15em 0;
  font-size: 1.07em;
  box-shadow: 0 2px 11px #1e023b22;
  word-break: break-word;
  background: transparent !important;
  color: var(--oled-white);
  outline: none;
}

.myriva-chat-bubble.ai {
  background: transparent !important;
  color: var(--oled-white);
  align-self: flex-start;
  border-radius: 18px 18px 12px 22px;
}
.myriva-chat-bubble.user {
  background: transparent !important;
  color: var(--oled-purple);
  align-self: flex-end;
  border-radius: 20px 18px 10px 18px;
  margin-left: auto;
  margin-right: 0;
}

.myriva-chat-bubble .sender-label {
  font-size: .68em;
  font-weight: 700;
  opacity: 0.6;
  text-align: right;
  margin-bottom: 0.19em;
  display: block;
  letter-spacing: 0.3px;
}

/* floating chatbar */
.myriva-floating-bar-shell {
  position: fixed;
  bottom: 0;
  left: 50%;
  width: 100vw;
  max-width: 430px;
  transform: translateX(-50%);
  display: flex;
  justify-content: center;
  z-index: 999;
  background: none;
  pointer-events: none;
}
.myriva-floating-bar-inner {
  margin: 0 auto 1.33em auto;
  background: var(--oled-grey);
  border-radius: 26px;
  box-shadow: 0 3px 24px #1a002a55;
  display: flex;
  align-items: center;
  width: 97vw;
  max-width: 410px;
  padding: 0.25em 0.38em 0.25em 0.8em;
  pointer-events: all;
  gap: 0.44em;
}
.myriva-chat-input {
  background: transparent;
  border: none;
  color: var(--oled-white);
  padding: .91em .9em .91em 0;
  font-size: 1.06em;
  border-radius: 0;
  flex: 1;
  outline: none;
  box-shadow: none;
}
.myriva-chat-input:focus {
  outline: none;
  border-bottom: 2.5px solid var(--oled-purple);
}

.myriva-send-btn {
  background: transparent !important; /* Remove background */
  color: var(--oled-purple) !important;
  border: 2px solid var(--oled-purple);
  border-radius: 32px;
  font-weight: bold;
  width: 40px;
  height: 40px;
  font-size: 1.5em;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 1px 8px #7a42ab7d;
  transition: filter 0.12s;
}
.myriva-send-btn:active,
.myriva-send-btn:focus {
  filter: brightness(1.2);
  outline: 2px solid var(--oled-purple);
}
.myriva-send-btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

/* --- Chat icons etc --- */
.myriva-ai-icon {
  display: none !important; /* Hide previous AI bubble icon */
}

footer {
  text-align: center;
  color: var(--oled-white);
  font-size: .97em;
  margin-bottom: 1em;
  margin-top: 2.2em;
  opacity: 0.6;
  background: none;
  border: none;
}

/* Hide old style toggle */
.myriva-chat-style-toggle {
  display: none !important;
}

/* New single change button for style switch */
.myriva-chat-style-change-btn {
  margin-left: auto;
  background: var(--oled-grey);
  color: var(--oled-white);
  border: 2px solid var(--oled-purple);
  border-radius: 16px;
  font-size: 0.97em;
  padding: .58em 1.1em;
  font-weight: bold;
  cursor: pointer;
  transition: border 0.15s, color 0.16s;
  outline: none;
  box-shadow: 0 2px 11px #1e023b22;
  display: flex;
  align-items: center;
  gap: .5em;
}
.myriva-chat-style-change-btn:focus,
.myriva-chat-style-change-btn:active {
  color: var(--oled-pink);
  border: 2px solid var(--oled-pink);
}

/* --- Chat style select (for chat header, modal) --- */
.myriva-style-modal {
  background: rgb(0 0 0 / 94%);
  position: fixed;
  inset: 0;
  z-index: 1600;
  display: flex;
  justify-content: center;
  align-items: center;
  animation: fadein .17s;
}
.myriva-style-modal-content {
  background: var(--oled-grey);
  color: var(--oled-white);
  border-radius: 18px;
  width: 340px;
  max-width: 92vw;
  box-shadow: 0 5px 40px #0a001133;
  padding: 1.7em 1em 2.0em 1em;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.myriva-style-modal-content h2 {
  color: var(--oled-purple);
  text-align: center;
  margin-bottom: 1.1em;
  font-size: 1.17em;
}
.myriva-style-modal-option {
  width: 100%;
  margin-bottom: 1.15em;
  background: var(--oled-black);
  border-radius: 14px;
  border: 2px solid var(--oled-purple);
  color: var(--oled-white);
  box-shadow: 0 2px 11px #1e023b22;
  padding: 1.05em 1em;
  cursor: pointer;
  font-size: 1.05em;
  transition: background .20s, border .18s;
  text-align: left;
  outline: none;
  display: flex;
  align-items: flex-start;
  gap: .65em;
}
.myriva-style-modal-option.selected,
.myriva-style-modal-option:focus, .myriva-style-modal-option:active {
  border: 2px solid var(--oled-pink);
  background: var(--oled-grey);
  color: var(--oled-pink);
}
.myriva-style-modal-option:last-child {
  margin-bottom: 0;
}
.myriva-style-modal-desc {
  display: block;
  font-size: .97em;
  color: #ccc;
  margin-top: .36em;
  opacity: 0.68;
}

@media (max-width: 600px) {
  main {
    padding: 1.1em 0.1em 1.4em 0.1em;
    min-height: 60vh;
  }
  .character-form {
    padding: 1.1em 0.5em;
    max-width: 99vw;
  }
  .myriva-chat-header {
    padding-left: 0.5em;
    padding-right: 0.4em;
  }
  .myriva-chat-avatar {
    width: 37px;
    height: 37px;
  }
  .myriva-floating-bar-inner {
    padding-right: 0.18em;
    padding-left: 0.35em;
    max-width: 99vw;
    margin-bottom: .6em;
  }
  .myriva-chat-bubble {
    max-width: 97vw;
    font-size: 1em;
    padding: 0.7em 0.89em;
  }
  .myriva-chat-scroll {
    padding-bottom: 6.5em !important;
  }
}

@media (max-width: 500px) {
  .myriva-style-modal-content {
    width: 97vw;
    max-width: 97vw;
    padding: 1.09em 0.2em 1.09em 0.2em;
  }
}

.riva-style-select-overlay {
  background: rgb(0 0 0 / 95%);
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  justify-content: center;
  align-items: center;
  animation: fadein .22s;
}
@keyframes fadein {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.riva-style-content {
  background: var(--oled-grey);
  border-radius: 22px;
  max-width: 95vw;
  width: 380px;
  box-shadow: 0 5px 40px #0a001133;
  padding: 2em 1.1em 2.2em 1.1em;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.riva-style-content h2 {
  color: var(--oled-purple);
  text-align: center;
  margin-bottom: 1.1em;
  font-size: 1.25em;
}
.riva-style-option {
  width: 100%;
  margin-bottom: 1.2em;
  background: var(--oled-black);
  border-radius: 16px;
  border: 2px solid var(--oled-purple);
  color: var(--oled-white);
  box-shadow: 0 2px 11px #1e023b22;
  padding: 1.1em 1em 1.1em 1em;
  cursor: pointer;
  font-size: 1.09em;
  transition: background .20s, border .18s;
  text-align: left;
  outline: none;
}
.riva-style-option:focus, .riva-style-option:active {
  border: 2px solid var(--oled-pink);
  background: var(--oled-grey);
  color: var(--oled-pink);
}
.riva-style-option:last-child {
  margin-bottom: 0;
}
.riva-style-desc {
  display: block;
  font-size: .98em;
  color: #ccc;
  margin-top: .42em;
  opacity: 0.68;
}

@media (max-width: 500px) {
  .riva-style-content {
    width: 99vw;
    max-width: 99vw;
    padding: 1.4em 0.3em 1.1em 0.3em;
  }
}

/* --- More Options button --- */
.myriva-more-options-btn {
  background: none;
  border: none;
  color: var(--oled-purple);
  border-radius: 50%;
  width: 43px;
  height: 43px;
  margin-left: .5em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.13s, filter 0.13s, box-shadow .13s;
  box-shadow: 0 1px 7px #250c434d;
  outline: none;
}
.myriva-more-options-btn:active,
.myriva-more-options-btn:focus {
  background: #45316a44;
  outline: 2px solid var(--oled-purple);
  filter: brightness(1.18);
}
.myriva-more-options-btn svg {
  display: block;
}

@media (max-width: 600px) {
  .myriva-more-options-btn {
    width: 33px;
    height: 33px;
    margin-left: .16em;
  }
  .myriva-more-options-btn svg {
    width: 25px;
    height: 25px;
  }
}

/* --- More Options popover/sheet --- */
.myriva-options-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 0.93);
  z-index: 2100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadein .16s;
}
.myriva-options-sheet {
  background: var(--oled-grey);
  width: 97vw;
  max-width: 430px;
  margin-bottom: 0;
  border-radius: 18px 18px 0 0;
  padding: 1.25em 1.12em 1.18em 1.12em;
  box-shadow: 0 0 40px #0a001133;
  display: flex;
  flex-direction: column;
  gap: 1.25em;
}
@media (max-width: 600px) {
  .myriva-options-sheet {
    width: 100vw;
    max-width: 100vw;
    border-radius: 18px 18px 0 0;
    padding-bottom: 1.18em;
  }
}
.myriva-options-sheet button {
  width: 100%;
  background: var(--oled-black);
  color: var(--oled-white);
  border-radius: 13px;
  border: 2px solid var(--oled-purple);
  font-size: 1.08em;
  padding: 1.05em .8em;
  margin-bottom: 0.25em;
  box-shadow: 0 2px 9px #16013520;
  cursor: pointer;
  font-weight: bold;
  text-align: left;
  outline: none;
  transition: background 0.14s, border 0.11s, color 0.12s;
  display: flex;
  align-items: flex-start;
  gap: .6em;
}

.myriva-options-sheet button:focus,
.myriva-options-sheet button.selected,
.myriva-options-sheet button:active {
  border-color: var(--oled-pink);
  color: var(--oled-pink);
  background: var(--oled-grey);
}

.myriva-options-sheet button:last-child {
  margin-bottom: 0;
}

.myriva-options-sheet-desc {
  display: block;
  font-size: .97em;
  color: #bbb;
  margin-top: .2em;
  opacity: 0.66;
}

/* --- Character Edit Modal --- */
.myriva-editchar-overlay {
  background: rgb(0 0 0 / 0.96);
  position: fixed;
  inset: 0;
  z-index: 2500;
  display: flex;
  justify-content: center;
  align-items: center;
  animation: fadein .19s;
}

.myriva-editchar-modal {
  background: var(--oled-grey);
  border-radius: 20px;
  width: 99vw;
  max-width: 410px;
  box-shadow: 0 5px 40px #0a001133;
  padding: 1.5em 1.2em 1.33em 1.2em;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1.18em;
}

.myriva-editchar-modal h2 {
  color: var(--oled-purple);
  text-align: center;
  margin-bottom: 0.9em;
  margin-top: .18em;
  font-size: 1.17em;
}

.myriva-editchar-form .form-group {
  margin-bottom: 1.05em;
}

.myriva-editchar-form label {
  font-weight: 600;
  font-size: 1.05em;
  margin-bottom: .19em;
  color: var(--oled-white);
}

.myriva-editchar-form input[type="text"],
.myriva-editchar-form textarea {
  width: 100%;
  border: none;
  border-bottom: 2px solid #43277900;
  border-radius: 0;
  background: transparent;
  color: var(--oled-white);
  padding: .77em .82em;
  font-size: 1em;
  font-family: inherit;
  margin-top: 0.07em;
  outline: none;
  box-shadow: none;
  transition: box-shadow 0.19s;
}

.myriva-editchar-form input[type="text"]:focus,
.myriva-editchar-form textarea:focus {
  box-shadow: 0 2px 0 0 var(--oled-purple);
  border-bottom: 2px solid var(--oled-purple);
}

.myriva-editchar-form textarea {
  resize: vertical;
  min-height: 2.2em;
}

.myriva-editchar-modal .myriva-editchar-btns {
  display: flex;
  justify-content: space-between;
  gap: 0.87em;
}

.myriva-editchar-btn {
  background: var(--oled-black);
  color: var(--oled-purple);
  border: 2px solid var(--oled-purple);
  border-radius: 20px;
  font-size: 1em;
  font-weight: bold;
  padding: .75em 1.3em;
  margin: .3em 0 0 0;
  flex: 1 0 0%;
  box-shadow: 0 1px 7px #1a002a44;
  cursor: pointer;
  transition: background .16s, color .16s;
}

.myriva-editchar-btn:active,
.myriva-editchar-btn:focus {
  background: var(--oled-purple);
  color: var(--oled-black);
}

@media (max-width: 600px) {
  .myriva-editchar-modal {
    max-width: 98vw;
    width: 98vw;
    padding: 1em 0.3em 1.1em 0.3em;
  }
}