:root {
  --font-sans: 'Inter', system-ui, sans-serif;
  --font-display: 'Playfair Display', serif;

  --accent: #d7b65f;
  --accent-soft: #f4e2ad;
  --accent-deep: #b88a2f;
  --accent-2: #7b72ff;

  --bg: #090a0f;
  --bg-2: #11131a;
  --surface: rgba(18, 20, 29, 0.7);
  --surface-2: rgba(255,255,255,0.05);
  --border: rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.15);

  --text: #f7f1e8;
  --text-soft: #bdb4a7;
  --text-dim: #847b6e;

  --shadow: 0 20px 50px rgba(0,0,0,0.45);
  --blur: 18px;
  --radius: 18px;
}

html[data-theme="light"] {
  --bg: #f8f3ea;
  --bg-2: #efe5d8;
  --surface: rgba(255,255,255,0.72);
  --surface-2: rgba(255,255,255,0.58);
  --border: rgba(0,0,0,0.08);
  --border-strong: rgba(0,0,0,0.14);
  --text: #1d1a16;
  --text-soft: #5f574d;
  --text-dim: #8b8378;
  --shadow: 0 15px 40px rgba(0,0,0,0.08);
}

html[data-preset="rose"] {
  --accent: #d9a7a0;
  --accent-soft: #f3d3ce;
  --accent-deep: #b67a72;
}

html[data-preset="platinum"] {
  --accent: #cfd5dc;
  --accent-soft: #eff3f7;
  --accent-deep: #99a4b1;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--font-sans);
  color: var(--text);
  overflow: hidden;
  background:
    radial-gradient(circle at 10% 10%, rgba(215,182,95,0.08), transparent 24%),
    radial-gradient(circle at 90% 10%, rgba(123,114,255,0.10), transparent 22%),
    linear-gradient(135deg, var(--bg), var(--bg-2));
}

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: .55;
}

.orb-1 {
  width: 420px;
  height: 420px;
  top: -100px;
  left: -80px;
  background: rgba(215,182,95,0.16);
}

.orb-2 {
  width: 460px;
  height: 460px;
  right: -120px;
  top: -50px;
  background: rgba(123,114,255,0.14);
}

.grid-glow {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(circle at center, black 35%, transparent 85%);
  opacity: .18;
}

.app {
  display: flex;
  height: 100vh;
  position: relative;
  z-index: 1;
}

.glass,
.glass-panel,
.glass-soft {
  backdrop-filter: blur(var(--blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(160%);
}

.glass-panel,
.glass {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.glass-soft {
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.sidebar {
  width: 300px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
}

.sidebar-head {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark,
.welcome-mark {
  display: grid;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(135deg, var(--accent-soft), var(--accent-deep));
  box-shadow: 0 10px 25px rgba(215,182,95,0.22);
  color: #1f1609;
  font-family: var(--font-display);
  font-weight: 700;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  font-size: 24px;
}

.brand-mark img,
.welcome-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
}

.brand-name span,
.welcome-title span {
  color: var(--accent);
}

.icon-btn {
  width: 38px;
  height: 38px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--text-soft);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: .25s ease;
}

.icon-btn:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text);
}

.new-chat-btn {
  margin: 8px 16px 12px;
  height: 46px;
  border-radius: 16px;
  border: 1px solid rgba(215,182,95,0.18);
  background: linear-gradient(135deg, rgba(215,182,95,0.08), rgba(255,255,255,0.02));
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  font-weight: 600;
  cursor: pointer;
  transition: .25s ease;
}

.new-chat-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(215,182,95,0.34);
  box-shadow: 0 10px 24px rgba(215,182,95,0.10);
}

.search-wrap {
  margin: 0 16px 12px;
  height: 40px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  color: var(--text-dim);
}

.search-wrap input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}

.history {
  flex: 1;
  overflow-y: auto;
  padding: 0 10px 10px;
}

.sidebar-foot {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 12px;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  min-height: 64px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.select-wrap {
  position: relative;
  height: 40px;
  min-width: 220px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  overflow: hidden;
}

.select-wrap select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  padding: 0 38px 0 34px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}

.select-wrap::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text-dim);
  border-bottom: 2px solid var(--text-dim);
  transform: translateY(-60%) rotate(45deg);
  pointer-events: none;
}

.select-ico {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent);
  pointer-events: none;
}

.preset-wrap {
  min-width: 140px;
}

.theme-toggle {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.toggle-track {
  width: 66px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 9px;
}

.toggle-track svg {
  color: var(--text-dim);
  z-index: 1;
}

.ic-sun {
  color: var(--accent);
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-soft), var(--accent-deep));
  transition: transform .3s ease;
}

html[data-theme="light"] .toggle-thumb {
  transform: translateX(30px);
}

.chat {
  flex: 1;
  overflow-y: auto;
}

.welcome {
  max-width: 760px;
  margin: 0 auto;
  padding: 80px 24px 40px;
  text-align: center;
}

.welcome-mark {
  width: 88px;
  height: 88px;
  border-radius: 28px;
  margin: 0 auto 18px;
  font-size: 42px;
}

.welcome-title {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  line-height: 1.1;
  margin: 0;
}

.welcome-sub {
  margin: 14px auto 0;
  max-width: 560px;
  color: var(--text-soft);
  font-size: 16px;
  line-height: 1.7;
}

.suggestions {
  margin: 34px auto 0;
  max-width: 640px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.chip {
  min-height: 54px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--text-soft);
  text-align: left;
  padding: 0 18px;
  font-size: 15px;
  cursor: pointer;
  transition: .25s ease;
}

.chip:hover {
  transform: translateY(-2px);
  color: var(--text);
  border-color: rgba(215,182,95,0.22);
  box-shadow: 0 10px 24px rgba(215,182,95,0.08);
}

.messages {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px;
}

.composer-wrap {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 10px 16px 14px;
}

.composer {
  border-radius: 28px;
  padding: 10px;
}

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.prompt-input {
  flex: 1;
  min-height: 44px;
  max-height: 180px;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.6;
  padding: 10px 4px;
}

.prompt-input::placeholder {
  color: var(--text-dim);
}

.send-btn {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent-soft), var(--accent-deep));
  color: #201709;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: .25s ease;
}

.send-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(215,182,95,0.22);
}

.send-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.footer-note {
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 10px;
}

.backdrop {
  display: none;
}

@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 20;
    transform: translateX(-100%);
    transition: transform .3s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    opacity: 0;
    visibility: hidden;
    transition: .25s ease;
    z-index: 10;
  }

  .backdrop.show {
    opacity: 1;
    visibility: visible;
  }

  .topbar {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .topbar-left,
  .topbar-right {
    width: 100%;
  }

  .select-wrap {
    min-width: 0;
    flex: 1 1 220px;
  }

  .suggestions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .welcome {
    padding-top: 56px;
  }

  .welcome-mark {
    width: 74px;
    height: 74px;
    font-size: 36px;
  }

  .welcome-sub {
    font-size: 14px;
  }

  .chip {
    font-size: 14px;
  }
}