:root {
  --bg-primary: #0f0b2e;
  --bg-secondary: #1c1045;
  --bg-gradient: linear-gradient(
    180deg,
    #0f0b2e 0%,
    #3a1e6e 45%,
    #6a3fcf 78%,
    #9b6cff 100%
  );
  --card-bg: rgba(58, 30, 110, 0.72);
  --glass-border: rgba(255, 255, 255, 0.08);
  --accent-primary: #6a3fcf;
  --accent-neon: #9b6cff;
  --accent-magenta: #c86bff;
  --energy-cyan: #6fe7ff;
  --text-gold: #f2d27a;
  --text-soft-gold: #ffdfa3;
  --text-muted: #c9b8e8;
  --divider: rgba(255, 255, 255, 0.08);
  --glow-shadow: rgba(155, 108, 255, 0.45);
  --app-height: 100dvh;
  --app-offset-top: 0px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100%;
  background: var(--bg-gradient);
  font-family: "Times New Roman", Times, Georgia, serif;
  color: var(--text-muted);
}

.app-shell {
  max-width: 460px;
  width: min(100%, 460px);
  height: var(--app-height);
  min-height: var(--app-height);
  max-height: var(--app-height);
  display: flex;
  flex-direction: column;
  background: rgba(28, 16, 69, 0.86);
  position: fixed;
  left: 50%;
  top: 0;
  transform: translateX(-50%) translateY(var(--app-offset-top));
  overflow: hidden;
  border-left: 1px solid var(--glass-border);
  border-right: 1px solid var(--glass-border);
  background-image: url("./Home.png");
  background-repeat: no-repeat;
}

.app-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(
      circle at 16% 18%,
      rgba(111, 231, 255, 0.15),
      transparent 35%
    ),
    radial-gradient(
      circle at 84% 8%,
      rgba(200, 107, 255, 0.19),
      transparent 38%
    ),
    radial-gradient(
      circle at 52% 82%,
      rgba(155, 108, 255, 0.22),
      transparent 42%
    );
  z-index: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 3;
  background: rgba(15, 11, 46, 0.92);
  color: var(--text-soft-gold);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(
    135deg,
    var(--accent-primary),
    var(--accent-neon)
  );
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 0 14px var(--glow-shadow);
}

.topbar-title {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar-title strong {
  font-size: 16px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-gold);
  text-shadow: 0 0 8px rgba(242, 210, 122, 0.35);
}

.topbar-title span {
  font-size: 12px;
  color: var(--text-muted);
}

.chat-history {
  position: relative;
  z-index: 1;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 14px 10px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
  background: linear-gradient(
    180deg,
    rgba(15, 11, 46, 0.65) 0%,
    rgba(28, 16, 69, 0.7) 100%
  );
}

.chat-history::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(
      circle at 20% 12%,
      rgba(111, 231, 255, 0.1),
      transparent 38%
    ),
    radial-gradient(
      circle at 80% 90%,
      rgba(200, 107, 255, 0.14),
      transparent 42%
    );
  opacity: 0.56;
  z-index: 0;
}

.chat-stars {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.chat-star {
  position: absolute;
  color: #eedda7;
  opacity: 0.72;
  filter: drop-shadow(0 0 5px rgba(238, 221, 167, 0.35));
  animation: twinkleStar ease-in-out infinite;
}

.chat-star.dot {
  border-radius: 50%;
  background: currentColor;
}

.chat-star.cross {
  background: transparent;
}

.chat-star.cross::before,
.chat-star.cross::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 100%;
  height: 22%;
  border-radius: 999px;
  background: currentColor;
  transform: translate(-50%, -50%);
}

.chat-star.cross::after {
  transform: translate(-50%, -50%) rotate(90deg);
}

@keyframes twinkleStar {
  0%,
  100% {
    opacity: 0.26;
    transform: scale(0.86);
  }

  50% {
    opacity: 0.95;
    transform: scale(1.12);
  }
}

.chat-history > * {
  position: relative;
  z-index: 1;
}

.day-chip {
  align-self: center;
  background: rgba(58, 30, 110, 0.78);
  border: 1px solid var(--glass-border);
  color: var(--text-soft-gold);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 6px;
  box-shadow: 0 0 14px rgba(155, 108, 255, 0.2);
}

.bubble {
  max-width: 82%;
  padding: 8px 10px 6px;
  border-radius: 10px;
  box-shadow: 0 1px 0 rgba(11, 20, 26, 0.06);
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
  word-break: break-word;
  line-height: 1.35;
  font-size: 15px;
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(7px);
}

.bubble-row {
  display: flex;
}

.bubble-row.incoming {
  justify-content: flex-start;
}

.bubble-row.outgoing {
  justify-content: flex-end;
}

.bubble.incoming {
  background: rgba(58, 30, 110, 0.86);
  color: var(--text-muted);
  border-top-left-radius: 3px;
}

.bubble.outgoing {
  background: linear-gradient(
    135deg,
    rgba(106, 63, 207, 0.92),
    rgba(155, 108, 255, 0.86)
  );
  color: #fff;
  border-top-right-radius: 3px;
}

.bubble-meta {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  color: var(--text-soft-gold);
  font-size: 11px;
  line-height: 1;
  opacity: 0.88;
}

.composer {
  position: relative;
  z-index: 3;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: rgba(15, 11, 46, 0.92);
  border-top: 1px solid var(--glass-border);
  display: flex;
  align-items: flex-end;
  gap: 8px;
  backdrop-filter: blur(10px);
}

.input-wrap {
  flex: 1;
  display: flex;
  align-items: flex-end;
  background: rgba(28, 16, 69, 0.96);
  border-radius: 22px;
  border: 1px solid var(--glass-border);
  padding: 6px 10px;
}

textarea {
  width: 100%;
  border: none;
  resize: none;
  outline: none;
  min-height: 24px;
  max-height: 120px;
  font: inherit;
  font-size: 15px;
  line-height: 1.4;
  color: var(--text-soft-gold);
  background: transparent;
}

textarea::placeholder {
  color: rgba(201, 184, 232, 0.82);
}

.send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(
    135deg,
    var(--accent-primary),
    var(--accent-neon)
  );
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition:
    filter 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease;
  box-shadow: 0 0 16px rgba(155, 108, 255, 0.42);
}

.send-icon {
  width: 20px;
  height: 20px;
  display: block;
  transform: translateX(0.5px);
}

.send-btn:hover {
  filter: brightness(1.07);
  box-shadow: 0 0 22px rgba(155, 108, 255, 0.6);
  transform: translateY(-1px);
}

.send-btn:active {
  transform: translateY(0);
}

.send-btn:disabled {
  cursor: not-allowed;
  filter: grayscale(0.45) opacity(0.7);
  transform: none;
}

.status-line {
  position: absolute;
  left: 50%;
  bottom: calc(68px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: rgba(58, 30, 110, 0.92);
  border: 1px solid var(--glass-border);
  color: var(--text-soft-gold);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 999px;
  z-index: 3;
  display: none;
  box-shadow: 0 0 16px rgba(155, 108, 255, 0.28);
}

.status-line.show {
  display: inline-flex;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 6, 24, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 30;
  padding: 20px;
}

.modal-content {
  width: 100%;
  max-width: 380px;
  background: rgba(58, 30, 110, 0.9);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 14px 36px rgba(16, 10, 44, 0.45);
  color: var(--text-muted);
  backdrop-filter: blur(10px);
}

.modal-content h2 {
  font-size: 20px;
  margin-bottom: 8px;
  color: var(--text-gold);
  text-shadow: 0 0 10px rgba(242, 210, 122, 0.3);
}

.modal-content p {
  color: var(--text-muted);
  margin-bottom: 14px;
  font-size: 14px;
  line-height: 1.45;
}

.modal-content input {
  width: 100%;
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 12px;
  font-size: 15px;
  margin-bottom: 10px;
  outline: none;
  background: rgba(15, 11, 46, 0.95);
  color: var(--text-soft-gold);
}

.modal-content input:focus {
  border-color: var(--accent-neon);
  box-shadow: 0 0 0 2px rgba(155, 108, 255, 0.2);
}

.modal-content button {
  width: 100%;
  border: none;
  border-radius: 12px;
  background: linear-gradient(
    135deg,
    var(--accent-primary),
    var(--accent-neon)
  );
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  padding: 12px;
  cursor: pointer;
}

.error {
  color: #ffd4d4;
  min-height: 18px;
  font-size: 13px;
  margin-bottom: 8px;
}

.sendBtn {
  color: #ffc74e !important;
  height: 48px;
  font-size: 20px;
  border: none;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-image: url("./Buttons_grey.png");
}

/* Active / typing */
.sendBtn.active {
  background-image: url("./Buttons.png");
  border: none;
}

.btn.disabled,
.btn:disabled,
fieldset:disabled .btn {
  border: none !important;
}

label {
  font-size: 12px;
  color: #ffc74e !important;
}

.custom-textarea {
  height: 128px;
  border-radius: 10px;
}

.mb-44 {
  margin-bottom: 10.5rem !important;
}

.form-control:disabled {
  background-color: #9b9d9f !important;
  opacity: 1 !important;
}

@media (min-width: 700px) {
  body {
    padding: 20px;
  }

  .app-shell {
    height: calc(var(--app-height) - 40px);
    min-height: calc(var(--app-height) - 40px);
    max-height: calc(var(--app-height) - 40px);
    top: 20px;
    border-radius: 18px;
    box-shadow: 0 12px 40px rgba(12, 8, 35, 0.4);
  }
}

@media (max-width: 699px) {
  .app-shell {
    width: 100%;
    left: 0;
    transform: translateY(var(--app-offset-top));
    border-left: none;
    border-right: none;
  }
}

@supports (-webkit-touch-callout: none) {
  textarea,
  .modal-content input {
    font-size: 16px;
  }
}
