:root {
  color-scheme: dark;

  --bg: #000000;

  --border-subtle: rgba(148, 163, 184, 0.22);
  --border-soft: rgba(148, 163, 184, 0.14);

  --accent: #27f3ff;
  --accent-soft: rgba(39, 243, 255, 0.18);
  --accent-strong: #5ff7ff;

  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  --text-soft: #6b7280;

  --error: #ff4b4b;

  --radius-xl: 20px;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-pill: 999px;

  --transition-fast: 0.14s ease-out;
}

/* Font loading (improvement) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600&family=Rajdhani:wght@400;600&display=swap');

/* RESET -------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

html {
  background: var(--bg) !important;
}

body {
  font-family: "Inter", system-ui, sans-serif;
  background: var(--bg) !important;
  color: var(--text-main);

  color-scheme: dark;

  display: flex;
  justify-content: center;
  align-items: stretch;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* APP ROOT -------------------------------------------------- */

.app-root {
  width: 100%;
  max-width: 1120px;

  padding: 18px;
  margin: 16px auto;

  background: transparent !important;
  border: 1px solid transparent !important;
  border-radius: 28px;

  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 32px);

  overflow: hidden;
  position: relative;
}

/* HEADER -------------------------------------------------- */

.app-header {
  background: transparent !important;
  padding: 6px 2px 16px;

  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 12px;

  display: flex;
  flex-direction: column;
}

.header-icon-row {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}

.logo-a {
  height: 52px;
  opacity: 0.9;
}

/* STATUS -------------------------------------------------- */

.header-status-row {
  display: flex;
  justify-content: flex-end;
}

.status-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}

.status-brand {
  font-family: "Rajdhani";
  text-transform: uppercase;
  color: var(--text-muted);
}

.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: "Rajdhani";
  font-weight: 600;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: var(--radius-pill);
}

.status-dot.online {
  background: #22c55e;
}
.status-dot.offline {
  background: #f97373;
}

.status-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  color: var(--text-soft);
  font-size: 0.85rem;
}

.status-model-control {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  text-align: right;
}

.status-model-label {
  color: var(--text-main);
  font-weight: 600;
}

.model-select {
  min-width: 180px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(10, 12, 16, 0.9);
  color: var(--text-main);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.9rem;
  appearance: none;
  background-image:
    linear-gradient(135deg, rgba(39, 243, 255, 0.22), rgba(39, 243, 255, 0.05)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='10' viewBox='0 0 14 10' fill='none'%3E%3Cpath d='M2 2.5L7 7.5L12 2.5' stroke='%23c3f3ff' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat, no-repeat;
  background-position: center, right 12px center;
  background-size: 100% 100%, 14px 10px;
  padding-right: 42px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.model-select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* MAIN PANEL -------------------------------------------------- */

.main-panel {
  background: transparent !important;

  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
}

/* CHAT PANEL -------------------------------------------------- */

.chat-panel {
  background: transparent !important;
  border: none;
  border-radius: 0;

  flex: 1;
  overflow: hidden;
  position: relative;
  min-height: 0;

  box-shadow: none;
}

/* ORB -------------------------------------------------- */

.chat-orb-layer {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;

  opacity: 0;
  pointer-events: none;

  transition: opacity .45s ease-out;
  z-index: 0;
}

.chat-orb-layer.active {
  opacity: 1 !important;
}

.chat-orb-image {
  width: clamp(200px, 50%, 360px); /* responsive improvement */
  opacity: 0.75;
  mix-blend-mode: normal; /* avoid additive glow on dark background */
  filter: none !important; /* ensure no glow so orb blends into black background */
  -webkit-mask-image: radial-gradient(circle at center, rgba(255, 255, 255, 1) 62%, rgba(255, 255, 255, 0) 82%);
          mask-image: radial-gradient(circle at center, rgba(255, 255, 255, 1) 62%, rgba(255, 255, 255, 0) 82%);
  -webkit-mask-repeat: no-repeat;
          mask-repeat: no-repeat;
  -webkit-mask-size: 110% 110%;
          mask-size: 110% 110%;
  -webkit-mask-position: center;
          mask-position: center;
}

/* CHAT INNER -------------------------------------------------- */

.chat-inner {
  background: transparent !important;
  position: relative;
  z-index: 1;

  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

/* CHAT BOX -------------------------------------------------- */

.chat-box {
  flex: 1;
  overflow-y: auto;

  padding: 18px 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;

  scroll-behavior: smooth; /* improvement */
  scrollbar-gutter: stable; /* improvement */
  overscroll-behavior: contain; /* avoid viewport bounce while autoscrolling */
  position: relative;
  z-index: 1;
}

/* SCROLLBAR -------------------------------------------------- */

.chat-box::-webkit-scrollbar {
  width: 6px;
}
.chat-box::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.28);
  border-radius: var(--radius-pill);
}

/* MESSAGES -------------------------------------------------- */

.message-row {
  width: 100%;
  display: flex;
}

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

.message-row.ai {
  justify-content: flex-start;
}

.message-meta {
  font-family: "Rajdhani";
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.message-row > div {
  max-width: 75%;
  display: flex;
  flex-direction: column;
}

.message-bubble {
  padding: 12px 15px;
  border-radius: var(--radius-lg); /* improvement */
  border: 1px solid transparent;
  background: rgba(6, 8, 12, 0.9) !important;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.35);
}

.message-bubble p {
  margin: 0 0 8px;
  line-height: 1.55;
}

.message-bubble h1,
.message-bubble h2,
.message-bubble h3,
.message-bubble h4,
.message-bubble h5,
.message-bubble h6 {
  font-family: "Rajdhani", "Inter", system-ui;
  margin: 0 0 8px;
  line-height: 1.2;
}

.message-bubble ul,
.message-bubble ol {
  margin: 0 0 10px 18px;
  padding: 0;
  line-height: 1.5;
}

.message-bubble code {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.92em;
}

.message-bubble pre {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 12px;
  overflow-x: auto;
  margin: 0 0 10px;
}

/* AI bubble */
.message-row.ai .message-bubble {
  border-color: rgba(56, 189, 248, 0.25);
}

/* User bubble */
.message-row.user .message-bubble {
  color: var(--accent-strong);
  border-color: rgba(130, 180, 220, 0.25);
}

/* INPUT PANEL -------------------------------------------------- */

.input-panel {
  background: transparent !important;
  border: none;
  border-radius: 0;

  padding: 12px 0 0;
  margin-top: 0;

  box-shadow: none;

  flex-shrink: 0;
}

.composer {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;
  background: radial-gradient(circle at 12% 12%, rgba(39, 243, 255, 0.08), transparent 42%),
    radial-gradient(circle at 80% 30%, rgba(39, 243, 255, 0.06), transparent 48%),
    linear-gradient(145deg, rgba(16, 16, 20, 0.9), rgba(9, 9, 11, 0.96));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 15px 40px rgba(0, 0, 0, 0.55);

  padding: 10px 12px 12px;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.composer.dragover {
  border-color: var(--accent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 20px 55px rgba(39, 243, 255, 0.22);
  background: radial-gradient(circle at 12% 12%, rgba(39, 243, 255, 0.14), transparent 55%),
    rgba(12, 16, 20, 0.95);
}

.composer-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
}

.composer-icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text-main);
  font-size: 1.05rem;
  cursor: pointer;
  transition: transform var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}

.composer-icon:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  background: rgba(39, 243, 255, 0.15);
}

.composer-icon:active {
  transform: scale(0.97);
}

.composer-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.composer-field {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(18, 18, 22, 0.88), rgba(10, 10, 12, 0.94));
  padding: 10px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 72px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

/* UPLOAD LIST -------------------------------------------------- */

.upload-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.upload-list.inline {
  min-height: 0;
}

.composer-body .upload-list {
  padding: 0 2px;
}

.upload-pill {
  background: rgba(39, 243, 255, 0.06);
  border: 1px solid rgba(56, 189, 248, 0.45);
  border-radius: var(--radius-pill);

  padding: 6px 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;

  font-size: 0.78rem;
  color: var(--text-muted);
}

.upload-pill button {
  background: transparent;
  border: none;
  color: var(--text-main);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  padding: 0 2px;
}

/* INPUT TEXT ----------------------------------------------- */

.input-text {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-main);

  border-radius: 12px;
  padding: 6px 4px 0;

  font-size: 0.95rem;
  resize: none;

  min-height: 52px;
  max-height: 160px;

  line-height: 1.45;
  outline: none;

  caret-color: var(--accent);
  transition: color .22s ease;
}

.input-text::placeholder {
  color: var(--text-soft);
}

.input-text:focus {
  outline: none;
}

/* SEND BUTTON ---------------------------------------------- */

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;

  min-width: 64px;
  height: 46px;

  border-radius: 16px;
  padding: 0 18px;

  background: linear-gradient(135deg, var(--accent), #9ef8ff);
  color: #020617;
  border: none;

  cursor: pointer;

  box-shadow: 0 0 10px rgba(39,243,255,0.35), 0 18px 40px rgba(0, 0, 0, 0.45);
  transition: transform .15s ease-out, opacity .2s ease;
}

.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

/* FOOTER -------------------------------------------------- */

.app-footer {
  text-align: center;
  color: var(--text-soft);

  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(31, 41, 55, 0.85);

  font-size: 0.75rem;
}

/* MOBILE -------------------------------------------------- */

@media (max-width: 768px) {
  .message-row > div {
    max-width: 100% !important;
  }
}