:root {
  --bg: #050a12;
  --panel: rgba(11, 17, 29, 0.9);
  --panel-soft: rgba(14, 22, 36, 0.86);
  --line: rgba(212, 191, 147, 0.14);
  --line-strong: rgba(212, 191, 147, 0.26);
  --text: #f4f5f7;
  --muted: #98a2b3;
  --gold: #d4bf93;
  --gold-soft: rgba(212, 191, 147, 0.14);
  --blue: #6f9dfb;
  --blue-soft: rgba(111, 157, 251, 0.16);
  --success: #8dd6b5;
  --danger: #ff9b9b;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(circle at 18% 16%, rgba(111, 157, 251, 0.12), transparent 24%),
    radial-gradient(circle at 82% 12%, rgba(212, 191, 147, 0.14), transparent 22%),
    linear-gradient(180deg, #08101b 0%, #04070d 100%);
  color: var(--text);
  font-family: "Manrope", sans-serif;
}

body {
  overflow-x: hidden;
  overflow-y: hidden;
}

button,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

code {
  font-family: "IBM Plex Mono", monospace;
}

.noise {
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.06;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 84px 84px;
  mask-image: radial-gradient(circle at center, black, transparent 82%);
}

.glow {
  position: fixed;
  z-index: 0;
  width: 32rem;
  height: 32rem;
  border-radius: 999px;
  filter: blur(110px);
  opacity: 0.22;
  pointer-events: none;
}

.glow-left {
  left: -12rem;
  top: -8rem;
  background: rgba(111, 157, 251, 0.34);
}

.glow-right {
  right: -10rem;
  top: 6rem;
  background: rgba(212, 191, 147, 0.24);
}

.layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  gap: 14px;
  height: calc(100vh - 40px);
  padding: 16px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(11, 17, 29, 0.92), rgba(8, 13, 21, 0.88));
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
  min-height: 0;
}

.sidebar-top {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.brand-logo {
  width: 100%;
  max-width: 144px;
}

.brand-row,
.topbar-left,
.topbar-right,
.chat-header,
.chat-header-actions,
.message-meta,
.message-attachments,
.message-outputs,
.composer-bottom,
.composer-tools,
.section-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-row {
  gap: 12px;
  flex-wrap: wrap;
}

.brand-copy h1 {
  font-size: 1.5rem;
}

.brand-copy h1,
.topbar h2,
.chat-header h3 {
  margin: 0;
  line-height: 1.02;
}

.brand-copy p,
.conversation-item small,
.empty-state p {
  color: var(--muted);
  line-height: 1.7;
}

.brand-copy p {
  margin: 8px 0 0;
  font-size: 0.86rem;
}

.brand-badge,
.section-pill,
.status-chip,
.file-pill,
.attachment-chip,
.output-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  text-decoration: none;
}

.brand-badge {
  color: var(--gold);
  background: var(--gold-soft);
  font-size: 0.75rem;
  text-transform: lowercase;
  white-space: nowrap;
}

.wide-button,
.primary-button,
.prompt-chip,
.tool-menu-item,
.conversation-item,
.icon-button {
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.primary-button {
  min-height: 44px;
  border: 1px solid rgba(212, 191, 147, 0.24);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(212, 191, 147, 0.2), rgba(111, 157, 251, 0.2));
  color: var(--text);
  font-weight: 700;
}

.wide-button {
  width: 100%;
}

.primary-button:hover,
.prompt-chip:hover,
.tool-menu-item:hover,
.conversation-item:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.history-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 0;
}

.section-head {
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.9rem;
}

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

.conversation-item {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.025);
  color: var(--text);
  text-align: left;
}

.conversation-item strong {
  font-size: 0.92rem;
}

.conversation-item small {
  font-size: 0.77rem;
}

.conversation-item.active {
  border-color: rgba(111, 157, 251, 0.22);
  background: linear-gradient(180deg, rgba(111, 157, 251, 0.12), rgba(9, 14, 23, 0.96));
}

.conversation-item strong {
  display: block;
  margin-bottom: 6px;
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
}

.topbar-left h2 {
  font-size: 1rem;
}

.overline {
  margin: 0 0 4px;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.7rem;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

#sidebarToggle span {
  display: block;
  width: 16px;
  height: 1.5px;
  margin: 1.5px 0;
  background: currentColor;
}

.status-chip.healthy {
  background: rgba(141, 214, 181, 0.12);
  border-color: rgba(141, 214, 181, 0.3);
}

.chat-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 16px 20px 18px;
}

.chat-header {
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.chat-header h3 {
  font-size: 1.06rem;
}

.message-list {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 14px 0 18px;
  overflow: auto;
}

.conversation-list,
.message-list {
  scrollbar-width: thin;
  scrollbar-color: rgba(111, 157, 251, 0.35) transparent;
}

.conversation-list::-webkit-scrollbar,
.message-list::-webkit-scrollbar {
  width: 10px;
}

.conversation-list::-webkit-scrollbar-track,
.message-list::-webkit-scrollbar-track {
  background: transparent;
}

.conversation-list::-webkit-scrollbar-thumb,
.message-list::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(212, 191, 147, 0.28), rgba(111, 157, 251, 0.34));
  background-clip: padding-box;
}

.empty-state {
  padding: 28px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(15, 23, 36, 0.92), rgba(10, 16, 25, 0.94));
}

.empty-state h3 {
  margin: 0 0 10px;
  font-size: 1.32rem;
}

.prompt-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 8px;
}

.prompt-chip {
  min-height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 0.86rem;
}

.message-card {
  display: flex;
  gap: 16px;
  padding: 20px 22px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(15, 23, 36, 0.94), rgba(10, 17, 27, 0.94));
}

.message-card.user {
  border-color: rgba(212, 191, 147, 0.2);
  background: linear-gradient(180deg, rgba(212, 191, 147, 0.08), rgba(12, 18, 29, 0.96));
}

.message-card.assistant {
  border-color: rgba(111, 157, 251, 0.24);
}

.message-card.system {
  border-color: rgba(255, 155, 155, 0.24);
}

.message-avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 14px;
  border: 1px solid rgba(212, 191, 147, 0.18);
  background: linear-gradient(135deg, rgba(212, 191, 147, 0.2), rgba(111, 157, 251, 0.22));
  color: var(--text);
  font-weight: 700;
  font-size: 0.82rem;
}

.message-shell {
  flex: 1;
  min-width: 0;
}

.message-meta {
  justify-content: space-between;
  margin-bottom: 8px;
}

.message-role {
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.7rem;
}

.message-time {
  color: var(--muted);
  font-size: 0.82rem;
}

.message-content {
  font-size: 1.04rem;
  line-height: 1.82;
}

.message-content p {
  margin: 0;
}

.message-attachments,
.message-outputs {
  flex-wrap: wrap;
  margin-top: 12px;
}

.composer {
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.composer-shell {
  padding: 12px 14px;
  border-radius: 24px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, rgba(8, 13, 21, 0.96), rgba(11, 18, 28, 0.96));
}

.composer textarea {
  width: 100%;
  min-height: 88px;
  max-height: 180px;
  resize: none;
  border: 0;
  outline: 0;
  padding: 0 2px 10px;
  background: transparent;
  color: var(--text);
  font-size: 0.98rem;
  line-height: 1.65;
}

.composer textarea::placeholder {
  color: rgba(152, 162, 179, 0.82);
}

.composer-bottom {
  justify-content: space-between;
  gap: 14px;
}

.composer-tools {
  position: relative;
  flex-wrap: wrap;
}

.tools-trigger-wrap {
  position: relative;
}

.plus-button {
  font-size: 1.45rem;
  line-height: 1;
}

.mic-button {
  width: auto;
  min-width: 52px;
  padding: 0 14px;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}

.mic-button.recording {
  border-color: rgba(255, 155, 155, 0.45);
  background: rgba(255, 155, 155, 0.14);
  color: #ffd5d5;
  box-shadow: 0 0 0 4px rgba(255, 155, 155, 0.08);
}

.tool-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 12px);
  display: grid;
  gap: 8px;
  width: min(280px, 72vw);
  padding: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: rgba(12, 19, 30, 0.98);
  box-shadow: var(--shadow);
}

.tool-menu-item {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  text-align: left;
}

.tool-menu-item:hover {
  border-color: rgba(111, 157, 251, 0.22);
  background: rgba(111, 157, 251, 0.08);
}

.send-button {
  min-width: 112px;
}

.file-pill button {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
}

.hidden {
  display: none !important;
}

.reveal {
  opacity: 0;
  transform: translateY(16px);
  animation: rise 620ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.delay-1 {
  animation-delay: 40ms;
}

.delay-2 {
  animation-delay: 120ms;
}

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

@media (max-width: 980px) {
  body {
    overflow-y: auto;
  }

  .layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
    padding: 14px;
  }

  .sidebar {
    position: fixed;
    top: 14px;
    left: 14px;
    bottom: 14px;
    width: min(320px, calc(100vw - 28px));
    max-width: calc(100vw - 28px);
    transform: translateX(-108%);
    transition: transform 180ms ease;
    z-index: 4;
  }

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

  .topbar,
  .chat-panel {
    padding: 18px;
  }

  .workspace,
  .chat-panel,
  .message-list {
    min-height: unset;
  }
}

@media (min-width: 981px) {
  #sidebarToggle {
    display: none;
  }
}

@media (max-width: 720px) {
  .topbar,
  .chat-header,
  .composer-bottom {
    flex-direction: column;
    align-items: stretch;
  }

  .send-button,
  .primary-button {
    width: 100%;
  }

  .tool-menu {
    width: min(320px, calc(100vw - 48px));
  }
}
