:root {
  --bg: #0b0b10;
  --bg-2: #121219;
  --panel: rgba(18, 18, 28, 0.72);
  --panel-2: rgba(24, 24, 36, 0.74);
  --line: rgba(255,255,255,0.08);
  --line-strong: rgba(255,255,255,0.12);
  --text: #f7f7fb;
  --muted: #a8a8bd;
  --orange: #ff8a3d;
  --orange-2: #ff6b1a;
  --orange-3: #ffb36a;
  --shadow: 0 25px 80px rgba(0,0,0,0.45);
  --sidebar-w: 290px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255,138,61,0.12), transparent 28%),
    radial-gradient(circle at bottom right, rgba(255,107,26,0.10), transparent 26%),
    linear-gradient(180deg, #0a0b10, #11121a 55%, #0a0b10);
  overflow: hidden;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }

.bg-orb {
  position: fixed;
  border-radius: 999px;
  filter: blur(80px);
  pointer-events: none;
}
.orb-a { width: 360px; height: 360px; background: rgba(255, 122, 27, 0.18); top: -120px; left: -100px; }
.orb-b { width: 300px; height: 300px; background: rgba(255, 170, 95, 0.08); bottom: -90px; right: -50px; }
.noise {
  position: fixed; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,0.06) 0.55px, transparent 0.55px);
  background-size: 22px 22px;
  opacity: .08;
  pointer-events: none;
}

.glass {
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
  backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.interactive { transition: transform .22s ease, border-color .22s ease, background .22s ease; }
.interactive:hover { transform: translateY(-1px); border-color: rgba(255,138,61,0.35); }

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  gap: 18px;
  padding: 18px;
}

.sidebar {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.brand-panel,
.nav-panel,
.sidebar-block,
.new-chat {
  border-radius: 24px;
}
.brand-panel {
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 18px;
  padding: 1px;
  background: linear-gradient(135deg, rgba(255,179,106,0.8), rgba(255,107,26,0.55));
}
.brand-mark-inner {
  width: 100%; height: 100%; border-radius: 17px;
  display: grid; place-items: center;
  background: linear-gradient(180deg, #1b1b27, #111119);
  color: var(--orange-3); font-size: 24px; font-weight: 900;
}
.brand-title { font-weight: 800; font-size: 20px; }
.brand-subtitle { color: var(--muted); font-size: 12px; margin-top: 2px; }

.new-chat {
  height: 56px;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.new-chat-plus {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(180deg, var(--orange-3), var(--orange-2));
  color: #291003; font-weight: 800;
}

.nav-panel {
  padding: 10px;
  display: grid;
  gap: 8px;
}
.nav-item {
  height: 46px;
  border: 1px solid transparent;
  border-radius: 16px;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  transition: background .22s ease, border-color .22s ease, transform .22s ease;
}
.nav-item span { color: var(--orange-3); width: 18px; text-align: center; }
.nav-item.active,
.nav-item:hover { background: rgba(255,138,61,0.10); border-color: rgba(255,138,61,0.18); transform: translateX(1px); }
.nav-item b { font-weight: 600; }

.sidebar-block { padding: 14px; }
.compact-block { padding-bottom: 12px; }
.block-label {
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 11px;
  color: var(--muted);
}
.provider-pill {
  margin-top: 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255,138,61,0.10);
  color: #ffd5b4;
  border: 1px solid rgba(255,138,61,0.14);
}
.model-id {
  margin-top: 12px;
  font-weight: 700;
  line-height: 1.45;
  word-break: break-word;
}
.supports {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.supports span {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.08);
  color: #d7d7e6;
  background: rgba(255,255,255,0.03);
  font-size: 12px;
}

.history-block {
  min-height: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
}
.block-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.text-btn {
  border: none;
  background: transparent;
  color: var(--orange-3);
}
.history-list {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
}
.history-item {
  width: 100%;
  border: 1px solid transparent;
  background: rgba(255,255,255,0.03);
  border-radius: 16px;
  color: var(--text);
  padding: 12px;
  text-align: left;
  transition: transform .2s ease, background .2s ease, border-color .2s ease;
}
.history-item:hover,
.history-item.active {
  transform: translateX(2px);
  background: rgba(255,138,61,0.10);
  border-color: rgba(255,138,61,0.16);
}
.history-item-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-item-date { margin-top: 4px; font-size: 11px; color: var(--muted); }
.history-empty { color: var(--muted); font-size: 14px; padding: 8px 4px; }

.main-panel {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 6px;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.signal {
  width: 12px; height: 12px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff7ec, var(--orange));
  box-shadow: 0 0 26px rgba(255,138,61,0.65);
}
.topbar-title { font-weight: 700; }
.topbar-subtitle { color: var(--muted); font-size: 12px; margin-top: 2px; }
.topbar-actions { display: flex; gap: 10px; }
.top-chip {
  height: 40px;
  padding: 0 14px;
  color: var(--text);
  border-radius: 999px;
}

.hero-view,
.chat-stage,
.composer-wrap {
  width: min(1040px, 100%);
  margin: 0 auto;
}
.hero-view {
  display: grid;
  place-items: center;
  padding: 16px 0 120px;
}
.hero-card {
  position: relative;
  max-width: 720px;
  text-align: center;
  animation: heroIn .7s ease;
}
.hero-logo-wrap {
  position: relative;
  width: 140px;
  height: 140px;
  margin: 0 auto 20px;
}
.hero-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 180deg, rgba(255,138,61,0.05), rgba(255,138,61,0.7), rgba(255,180,120,0.18), rgba(255,138,61,0.05));
  filter: blur(10px);
  animation: spin 8s linear infinite;
}
.hero-logo {
  position: absolute;
  inset: 12px;
  border-radius: 40px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, rgba(20,20,30,.96), rgba(10,10,16,.98));
  border: 1px solid rgba(255,255,255,.08);
  font-size: 62px;
  font-weight: 900;
  color: var(--orange-3);
}
.hero-badge {
  display: inline-flex;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255,138,61,.16);
  background: rgba(255,138,61,.08);
  color: #ffd4b0;
  font-size: 12px;
  margin-bottom: 16px;
}
.hero-card h1 {
  margin: 0;
  font-size: clamp(48px, 7vw, 88px);
  letter-spacing: -.06em;
}
.hero-lead { margin: 12px 0 0; font-size: 22px; color: #ffe2ca; }
.hero-caption { margin: 16px auto 0; max-width: 630px; color: var(--muted); line-height: 1.7; }

.chat-stage {
  min-height: 0;
  overflow: auto;
  scroll-behavior: smooth;
  padding: 0 0 10px;
}
.messages-flow {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 12px 0 20px;
}
.message {
  display: grid;
  gap: 10px;
  opacity: 0;
  transform: translateY(18px) scale(.99);
  animation: messageIn .35s ease forwards;
}
.message.user { justify-items: end; }
.message.assistant { justify-items: start; }
.message-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}
.message-bubble {
  max-width: min(820px, 92%);
  border-radius: 26px;
  border: 1px solid var(--line-strong);
  padding: 16px 18px;
  line-height: 1.7;
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.03));
  position: relative;
  overflow: hidden;
}
.message.assistant .message-bubble::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, rgba(255,138,61,0.24), transparent 30%, transparent 70%, rgba(255,179,106,0.18));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}
.message.user .message-bubble {
  background: linear-gradient(180deg, rgba(255,138,61,0.22), rgba(255,107,26,0.12));
}
.message-file-preview {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.file-chip,
.image-thumb {
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
}
.file-chip {
  padding: 9px 12px;
  font-size: 12px;
  color: #dad9e8;
}
.image-thumb {
  padding: 6px;
}
.image-thumb img {
  display: block;
  width: 150px;
  max-height: 140px;
  object-fit: cover;
  border-radius: 12px;
}
.typing-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.typing-dots { display: inline-flex; gap: 6px; }
.typing-dots span {
  width: 8px; height: 8px; border-radius: 50%; background: var(--orange-3);
  animation: bounce 1s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: .16s; }
.typing-dots span:nth-child(3) { animation-delay: .32s; }
.cursor {
  display: inline-block;
  width: 9px;
  height: 1.1em;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--orange-3), var(--orange-2));
  vertical-align: middle;
  animation: blink 1s step-end infinite;
  margin-left: 4px;
}

.composer-wrap { padding-bottom: 8px; }
.composer {
  display: flex;
  align-items: end;
  gap: 12px;
  border-radius: 28px;
  padding: 12px;
}
.icon-btn,
.send-btn {
  flex: 0 0 auto;
  border: none;
}
.icon-btn {
  width: 48px; height: 48px; border-radius: 16px;
  background: rgba(255,255,255,0.05); color: var(--orange-3);
}
.composer-main {
  min-width: 0;
  flex: 1;
}
.attachment-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.attachment-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  font-size: 12px;
}
.attachment-pill button {
  border: none;
  background: transparent;
  color: var(--muted);
}
#promptInput {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  resize: none;
  outline: none;
  max-height: 180px;
  line-height: 1.6;
  font-size: 16px;
  padding: 8px 2px;
}
#promptInput::placeholder { color: #8d8da4; }
.send-btn {
  width: 52px; height: 52px; border-radius: 18px;
  background: linear-gradient(180deg, var(--orange-3), var(--orange-2));
  color: #311103;
  box-shadow: 0 12px 30px rgba(255,107,26,0.28);
}
.send-core { font-size: 20px; font-weight: 800; }

.admin-modal { position: fixed; inset: 0; z-index: 40; }
.admin-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.52); backdrop-filter: blur(8px); }
.admin-card {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: min(920px, calc(100vw - 30px));
  border-radius: 30px;
  padding: 20px;
}
.admin-head { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.admin-title { font-size: 28px; font-weight: 800; }
.admin-subtitle { color: var(--muted); margin-top: 4px; }
.close-btn {
  width: 42px; height: 42px; border-radius: 14px; border: 1px solid var(--line);
  background: rgba(255,255,255,0.03); color: var(--text); font-size: 24px;
}
.admin-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.admin-box {
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  padding: 16px;
}
.admin-box-title { font-weight: 700; margin-bottom: 12px; }
.admin-status { font-size: 15px; color: #ffe0c5; line-height: 1.6; }
.admin-meta { color: var(--muted); font-size: 13px; margin-top: 8px; line-height: 1.6; }
.admin-box label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 6px; }
.admin-box input {
  width: 100%;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  padding: 0 12px;
  outline: none;
}
.admin-foot { display: flex; justify-content: end; margin-top: 16px; }
.admin-save {
  border: none;
  height: 48px;
  padding: 0 18px;
  border-radius: 16px;
  background: linear-gradient(180deg, var(--orange-3), var(--orange-2));
  color: #2f1002; font-weight: 800;
}

.hidden { display: none !important; }

@keyframes heroIn {
  from { opacity: 0; transform: translateY(14px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes messageIn {
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .5; }
  40% { transform: translateY(-4px); opacity: 1; }
}
@keyframes blink { 50% { opacity: 0; } }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: start;
    max-height: 38vh;
    overflow: auto;
  }
  .history-block { min-height: 220px; }
}

@media (max-width: 780px) {
  body { overflow: auto; }
  .app-shell { height: auto; min-height: 100vh; }
  .sidebar { grid-template-columns: 1fr; max-height: none; }
  .topbar { flex-direction: column; align-items: start; gap: 12px; }
  .admin-grid { grid-template-columns: 1fr; }
  .hero-view { padding-bottom: 48px; }
  .message-bubble { max-width: 100%; }
}
