:root {
  --bg: #040507;
  --bg-soft: #0d0f13;
  --card: #111319;
  --line: #2a2f38;
  --text: #f1f3f7;
  --muted: #a3aab5;
  --red: #d31124;
  --red-dark: #9d0718;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.55);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Segoe UI", "Arial", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 80% -10%, #1f0a0e 0%, transparent 28%),
    radial-gradient(circle at -10% 10%, #2a0c13 0%, transparent 34%), var(--bg);
  overflow: hidden;
}

.hidden {
  display: none !important;
}

.bg-noise {
  position: fixed;
  inset: 0;
  opacity: 0.05;
  pointer-events: none;
  z-index: 0;
  background-image: radial-gradient(circle at 30% 30%, #fff 0 0.4px, transparent 0.6px);
  background-size: 3px 3px;
}

.bg-spot {
  position: fixed;
  border-radius: 999px;
  filter: blur(58px);
  pointer-events: none;
}

.bg-spot-red {
  width: 360px;
  height: 360px;
  left: -120px;
  top: 80px;
  background: rgba(180, 10, 28, 0.36);
}

.bg-spot-gray {
  width: 300px;
  height: 300px;
  right: -100px;
  bottom: 140px;
  background: rgba(140, 145, 157, 0.18);
}

.card {
  background: linear-gradient(180deg, rgba(18, 21, 27, 0.95) 0%, rgba(9, 11, 15, 0.95) 100%);
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.root {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

.splash-screen {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #030406;
  transition: opacity 0.4s ease;
}

.splash-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

.brand-center {
  display: grid;
  place-items: center;
  transform: translateY(-19px);
}

.logo-stage {
  position: relative;
  width: min(288px, 62vw);
}

.brand-logo {
  width: 100%;
  height: auto;
  display: block;
}

.splash-logo-stage {
  animation: revealLogo 1.25s ease both;
}

@keyframes revealLogo {
  from {
    opacity: 0;
    transform: scale(0.92);
    filter: blur(8px);
  }
  to {
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
  }
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 26px 14px;
}

.auth-card {
  width: min(520px, 100%);
  padding: 26px;
}

.auth-logo-stage {
  width: min(330px, 100%);
  margin: 0 auto 6px;
  opacity: 0;
  transform: translateY(8px);
  animation: authLogoIn 0.7s ease forwards;
}

@keyframes authLogoIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.logo-glint {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.logo-glint::before {
  content: "";
  position: absolute;
  top: -20%;
  left: -30%;
  width: 34%;
  height: 140%;
  transform: rotate(20deg) translateX(-170%);
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.94) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  filter: blur(2px);
}

.auth-logo-stage.play .logo-glint {
  opacity: 1;
}

.auth-logo-stage.play .seg-1::before {
  animation: glintRun 0.72s ease-out 0.32s forwards;
}

.auth-logo-stage.play .seg-2::before {
  animation: glintRun 0.72s ease-out 0.9s forwards;
}

.auth-logo-stage.play .seg-3::before {
  animation: glintRun 0.72s ease-out 1.48s forwards;
}

.seg-1 {
  clip-path: polygon(15% 86%, 45% 14%, 57% 35%, 33% 90%);
}

.seg-2 {
  clip-path: polygon(30% 57%, 84% 36%, 84% 54%, 40% 74%);
}

.seg-3 {
  clip-path: polygon(61% 64%, 82% 58%, 91% 85%, 72% 86%);
}

@keyframes glintRun {
  0% {
    transform: translateX(-160%);
    opacity: 0;
  }
  16% {
    opacity: 1;
  }
  100% {
    transform: translateX(250%);
    opacity: 0;
  }
}

.auth-subtitle {
  margin: 6px 0 14px;
  text-align: center;
  color: var(--muted);
  font-size: 17px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.tab,
.btn-ghost,
.btn-red,
.icon-btn,
.mode-pill {
  border: 1px solid transparent;
  border-radius: 14px;
  color: var(--text);
  background: #23262d;
  padding: 12px 14px;
  cursor: pointer;
  transition: 0.2s ease;
}

.tab.active,
.btn-red {
  background: linear-gradient(180deg, var(--red) 0%, var(--red-dark) 100%);
}

.tab:hover,
.btn-red:hover,
.btn-ghost:hover,
.icon-btn:hover,
.mode-pill:hover {
  transform: translateY(-1px);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

input,
textarea {
  width: 100%;
  color: var(--text);
  background: #0b0d12;
  border: 1px solid #2c313b;
  border-radius: 14px;
  padding: 12px 14px;
  outline: none;
  font-size: 16px;
}

input:focus,
textarea:focus {
  border-color: #8e1a27;
  box-shadow: 0 0 0 2px rgba(210, 16, 36, 0.22);
}

.error {
  margin: 10px 0 0;
  min-height: 20px;
  font-size: 14px;
  color: #ff9aa5;
}

.workspace {
  height: 100vh;
  display: block;
  padding: 0;
  transform: translateY(-19px);
}

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: min(88vw, 380px);
  z-index: 20;
  transform: translateX(-112%);
  transition: transform 0.25s ease;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  border-right: 1px solid #2d323d;
  border-radius: 0;
}

.sidebar.open {
  transform: translateX(0);
}

.profile-box {
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid #2a2f39;
  border-radius: 16px;
}

.avatar-wrap {
  width: 66px;
  height: 66px;
  border-radius: 14px;
  background: #12151a;
  border: 1px solid #2a2f39;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.avatar-logo {
  width: 100%;
  height: 100%;
}

.profile-meta h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1;
}

.profile-meta p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.thread-item {
  width: 100%;
  text-align: left;
  border: 1px solid #3a3f48;
  background: rgba(34, 38, 45, 0.62);
  border-radius: 16px;
  padding: 14px;
  color: var(--text);
}

.thread-item.active {
  border-color: rgba(211, 17, 36, 0.8);
  background: rgba(44, 18, 24, 0.6);
}

.thread-item span {
  display: block;
  font-size: 16px;
}

.thread-item small {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.side-buttons {
  display: grid;
  gap: 8px;
}

.btn-ghost {
  background: #161a20;
  border-color: #323741;
}

.chat {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
  overflow: hidden;
  height: calc(100vh + 19px);
  border-radius: 0;
  border: 0;
}

.chat-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid #232833;
}

.icon-btn {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 12px;
  background: #161a20;
  border-color: #2d323a;
  font-size: 22px;
}

.chat-heading h3 {
  margin: 0;
  font-size: 20px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mode-toggle {
  margin-top: 8px;
  display: inline-flex;
  border: 1px solid #2e3340;
  border-radius: 999px;
  overflow: hidden;
  background: #161a22;
}

.mode-pill {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 6px 14px;
  font-size: 13px;
}

.mode-pill.active {
  background: #1f2e50;
  color: #8cb0ff;
}

.chat-log {
  overflow: auto;
  padding: 10px 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.msg-row {
  display: flex;
}

.msg-row.user {
  justify-content: flex-end;
}

.msg-row.assistant {
  justify-content: flex-start;
}

.bubble {
  max-width: min(84%, 760px);
  border-radius: 18px;
  padding: 10px 14px;
  white-space: pre-wrap;
  line-height: 1.45;
  border: 1px solid #313742;
  background: #181c22;
  font-size: 16px;
}

.bubble.user {
  border-color: rgba(211, 17, 36, 0.55);
  background: linear-gradient(180deg, #cf1729 0%, #9a0818 100%);
}

.composer {
  border-top: 1px solid #2b3038;
  padding: 10px 10px 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
}

.composer-box {
  background: #0d1015;
  border: 0;
  border-radius: 16px;
  padding: 12px;
  min-height: 86px;
}

.composer textarea {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
  resize: none;
  min-height: 36px;
  height: 60px;
}

.clip-btn {
  align-self: end;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  border: 1px solid #2f3440;
  background: #131821;
  cursor: pointer;
  user-select: none;
}

.composer-tools {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}

.chip {
  background: #1c2a47;
  color: #8db0ff;
  border: 1px solid #2f4779;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
}

.send-btn {
  align-self: end;
  min-width: 96px;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 15;
  background: rgba(0, 0, 0, 0.56);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, 0.65);
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-card {
  width: min(440px, 100%);
  padding: 18px;
}

.modal-card h3 {
  margin: 0 0 10px;
}

@media (max-width: 900px) {
  .workspace {
    padding: 0;
  }

  .sidebar {
    width: min(88vw, 380px);
    left: 0;
    top: 0;
    bottom: 0;
  }

  .chat {
    height: calc(100vh + 19px);
  }

  .chat-heading h3 {
    font-size: 18px;
  }

  .bubble {
    font-size: 15px;
  }

  .profile-meta h2 {
    font-size: 20px;
  }

  .profile-meta p,
  .thread-item small {
    font-size: 13px;
  }

  .thread-item span {
    font-size: 16px;
  }
}
