:root {
  color-scheme: dark;
  --bg: #030b15;
  --panel: #091a2b;
  --panel-light: #10283c;
  --cyan: #52eaff;
  --text: #e7faff;
  --muted: #8bb1c4;
  --border: rgba(82,234,255,.24);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 55% 40%,
      rgba(0,126,190,.15), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

button, input { font: inherit; }
button { cursor: pointer; }

.app {
  display: flex;
  height: 100dvh;
  min-height: 480px;
  overflow: hidden;
}

.sidebar {
  width: 270px;
  flex: 0 0 270px;
  display: flex;
  flex-direction: column;
  background: rgba(6,19,33,.97);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  transition: margin-left .25s ease;
}

.sidebar.closed { margin-left: -270px; }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.brand-symbol {
  font-size: 35px;
  color: var(--cyan);
  text-shadow: 0 0 20px var(--cyan);
}

.brand strong {
  font-size: 14px;
  letter-spacing: 2px;
}

.brand small {
  display: block;
  margin-top: 5px;
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--muted);
}

.new-chat {
  padding: 15px;
  border: 1px solid var(--cyan);
  border-radius: 10px;
  color: var(--cyan);
  background: rgba(35,179,220,.08);
  font-weight: bold;
  text-align: left;
}

.new-chat:hover {
  background: rgba(35,179,220,.22);
}

.section-heading {
  margin: 28px 8px 12px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 2px;
}

.history {
  flex: 1;
  overflow-y: auto;
}

.history-item {
  display: block;
  width: 100%;
  padding: 12px;
  margin-bottom: 7px;
  text-align: left;
  background: transparent;
  color: #c6e8f5;
  border: 1px solid transparent;
  border-radius: 8px;
}

.history-item:hover,
.history-item.active {
  background: rgba(82,234,255,.09);
  border-color: var(--border);
}

.sidebar-bottom {
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

.account {
  margin-bottom: 14px;
  font-size: 12px;
  color: #b7eaff;
}

.sidebar-bottom small {
  font-size: 9px;
  color: var(--muted);
}

.main {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 76px;
  flex: 0 0 76px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 26px;
  background: rgba(4,15,27,.65);
}

.menu-button {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--cyan);
  padding: 9px 13px;
}

.top-title {
  font-size: 15px;
  letter-spacing: 3px;
  font-weight: bold;
}

.top-title span {
  display: block;
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--muted);
  margin-top: 5px;
}

.status {
  margin-left: auto;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--cyan);
  white-space: nowrap;
}

.status-dot {
  display: inline-block;
  height: 7px;
  width: 7px;
  border-radius: 50%;
  background: #4effb7;
  box-shadow: 0 0 12px #4effb7;
  margin-right: 7px;
}

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(300px, 1.1fr) minmax(350px, 1fr);
  gap: 20px;
  padding: 20px;
}

.character-panel,
.chat-panel {
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(
    145deg, rgba(14,42,64,.92), rgba(4,15,28,.95)
  );
  box-shadow: inset 0 0 35px rgba(0,160,230,.05),
              0 0 28px rgba(0,140,210,.07);
}

.character-panel {
  display: flex;
  flex-direction: column;
  padding: 22px;
  overflow: hidden;
}

.character-heading {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--cyan);
}

.character-stage {
  flex: 1;
  min-height: 170px;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.character-stage img {
  position: relative;
  z-index: 2;
  max-width: 95%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0 30px rgba(30,200,255,.3));
}

.character-fallback {
  position: absolute;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  text-align: center;
  color: var(--cyan);
  letter-spacing: 3px;
}

.fallback-icon {
  font-size: 110px;
  text-shadow: 0 0 50px rgba(82,234,255,.7);
}

.character-fallback span {
  font-size: 10px;
  color: var(--muted);
}

.holo-ring {
  position: absolute;
  width: 75%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid rgba(82,234,255,.2);
  box-shadow: 0 0 45px rgba(82,234,255,.08);
  animation: pulse 4s infinite alternate;
}

.ring-two {
  width: 55%;
  animation-delay: 1.5s;
}

.scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 5px,
    rgba(82,234,255,.025) 6px
  );
  z-index: 3;
}

.character-details {
  text-align: center;
}

.character-details h1 {
  margin: 0;
  color: var(--cyan);
  font-size: 24px;
  letter-spacing: 5px;
  text-shadow: 0 0 20px rgba(82,234,255,.5);
}

.character-details p {
  color: var(--muted);
  font-size: 13px;
}

.character-status {
  font-size: 10px;
  letter-spacing: 2px;
  color: #a9eaff;
}

.chat-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-heading {
  padding: 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-heading small {
  font-size: 9px;
  color: var(--cyan);
  letter-spacing: 2px;
}

.chat-heading h2 {
  font-size: 18px;
  margin: 9px 0 0;
}

.demo-label {
  border: 1px solid var(--border);
  padding: 6px 9px;
  border-radius: 20px;
  font-size: 10px;
  color: var(--cyan);
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.message {
  max-width: 88%;
  padding: 14px 17px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.6;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message.user {
  align-self: flex-end;
  background: #16435c;
  border: 1px solid rgba(82,234,255,.3);
}

.message.ai {
  align-self: flex-start;
  background: #0c293d;
  border: 1px solid var(--border);
  color: #c8f4ff;
}

.composer {
  display: flex;
  gap: 10px;
  padding: 16px;
  border-top: 1px solid var(--border);
}

.composer input {
  flex: 1;
  min-width: 0;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #061725;
  color: white;
  outline: none;
}

.composer input:focus {
  border-color: var(--cyan);
}

.composer button {
  width: 50px;
  border-radius: 10px;
  border: 1px solid var(--cyan);
  background: rgba(82,234,255,.14);
  color: var(--cyan);
  font-size: 23px;
}

.chat-footer {
  text-align: center;
  padding-bottom: 12px;
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 1px;
}

@keyframes pulse {
  from { transform: scale(.92); opacity: .35; }
  to { transform: scale(1.08); opacity: .9; }
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }

  .character-panel {
    min-height: 350px;
  }

  .chat-panel {
    min-height: 450px;
  }
}

@media (max-width: 600px) {
  .sidebar {
    position: absolute;
    z-index: 20;
    height: 100%;
    box-shadow: 12px 0 35px #0008;
  }

  .sidebar.closed {
    margin-left: -270px;
  }

  .topbar {
    padding: 0 14px;
    gap: 12px;
  }

  .top-title {
    font-size: 12px;
    letter-spacing: 1px;
  }

  .status {
    font-size: 8px;
  }

  .workspace {
    padding: 10px;
    gap: 12px;
  }

  .character-details h1 {
    font-size: 19px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .holo-ring { animation: none; }
  .sidebar { transition: none; }
}
