/* ==========================================================================
   Dream AI — 1.1
   Calm, editorial, quietly technical. Soft light, fine hairlines, one accent.
   ========================================================================== */

:root {
  --bg: #08090d;
  --bg-2: #0b0d13;
  --sidebar: rgba(10, 11, 16, 0.72);
  --surface: #111420;
  --surface-2: #171b27;
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.13);
  --text: #f4f5f9;
  --text-2: #adb4c4;
  --text-3: #767e90;
  --accent: #7c9cff;
  --accent-soft: rgba(124, 156, 255, 0.12);
  --teal: #5eead4;
  --violet: #b79cff;
  --rose: #f0a6c8;
  --gold: #f3c77b;
  --danger: #ff7b86;
  --grad: linear-gradient(100deg, #5eead4 0%, #7c9cff 46%, #b79cff 100%);
  --font: "Inter var", "Segoe UI Variable Display", "Segoe UI", -apple-system, BlinkMacSystemFont,
    "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", "Cascadia Code", Consolas, "Liberation Mono", monospace;
  --msg-size: 15.5px;
  --sidebar-w: 272px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --shadow-lg: 0 40px 100px -48px rgba(0, 0, 0, 0.9), 0 2px 12px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 20px 44px -30px rgba(0, 0, 0, 0.85);
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #f7f6f2;
  --bg-2: #fffefb;
  --sidebar: rgba(245, 243, 238, 0.82);
  --surface: #ffffff;
  --surface-2: #ffffff;
  --line: rgba(18, 22, 32, 0.08);
  --line-2: rgba(18, 22, 32, 0.15);
  --text: #14161c;
  --text-2: #4c5362;
  --text-3: #7b8292;
  --accent: #4a6ef5;
  --accent-soft: rgba(74, 110, 245, 0.1);
  --teal: #0f9e8a;
  --violet: #7c5cf0;
  --rose: #d4568c;
  --gold: #c08a2e;
  --danger: #d1434f;
  --grad: linear-gradient(100deg, #0f9e8a 0%, #4a6ef5 46%, #7c5cf0 100%);
  --shadow-lg: 0 40px 90px -50px rgba(30, 34, 60, 0.35), 0 2px 10px rgba(30, 34, 60, 0.05);
  --shadow-md: 0 18px 40px -30px rgba(30, 34, 60, 0.3);
  color-scheme: light;
}

html[data-size="sm"] {
  --msg-size: 14.5px;
}

html[data-size="lg"] {
  --msg-size: 17px;
}

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

html,
body {
  height: 100%;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

img,
svg {
  display: block;
}

h1,
h2,
h3,
p,
ul {
  margin: 0;
}

::selection {
  background: rgba(124, 156, 255, 0.3);
  color: #fff;
}

html[data-theme="light"] ::selection {
  background: rgba(74, 110, 245, 0.2);
  color: #101320;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translate(-50%, -160%);
  z-index: 300;
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  font-size: 13px;
  transition: transform 0.25s var(--ease);
}

.skip-link:focus {
  transform: translate(-50%, 0);
}

/* ---------- Ambient background ---------- */
.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(1100px 620px at 50% -18%, rgba(88, 110, 180, 0.16), transparent 62%),
    var(--bg);
}

html[data-theme="light"] .ambient {
  background:
    radial-gradient(1000px 560px at 50% -16%, rgba(120, 150, 255, 0.16), transparent 64%),
    var(--bg);
}

.ambient__glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(110px);
  opacity: 0.5;
  will-change: transform;
}

html[data-theme="light"] .ambient__glow {
  opacity: 0.34;
}

.ambient__glow--a {
  width: 54vw;
  height: 44vw;
  left: -16vw;
  top: -20vw;
  background: radial-gradient(circle at 45% 45%, rgba(94, 234, 212, 0.42), transparent 66%);
  animation: drift-a 30s ease-in-out infinite alternate;
}

.ambient__glow--b {
  width: 50vw;
  height: 42vw;
  right: -14vw;
  top: -14vw;
  background: radial-gradient(circle at 50% 50%, rgba(124, 156, 255, 0.44), transparent 66%);
  animation: drift-b 36s ease-in-out infinite alternate;
}

.ambient__glow--c {
  width: 64vw;
  height: 46vw;
  left: 22vw;
  bottom: -40vw;
  background: radial-gradient(circle at 50% 50%, rgba(183, 156, 255, 0.24), transparent 70%);
  animation: drift-c 42s ease-in-out infinite alternate;
}

@keyframes drift-a {
  to {
    transform: translate3d(5vw, 4vw, 0) scale(1.1);
  }
}

@keyframes drift-b {
  to {
    transform: translate3d(-4vw, 5vw, 0) scale(1.06);
  }
}

@keyframes drift-c {
  to {
    transform: translate3d(-3vw, -3vw, 0) scale(1.08);
  }
}

.ambient__noise {
  position: absolute;
  inset: 0;
  opacity: 0.035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
}

/* ---------- Shell ---------- */
.app {
  position: relative;
  z-index: 1;
  display: flex;
  height: 100dvh;
  height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: relative;
  z-index: 30;
  display: flex;
  flex: 0 0 var(--sidebar-w);
  flex-direction: column;
  width: var(--sidebar-w);
  padding: 14px 12px 12px;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
  backdrop-filter: blur(26px) saturate(130%);
  -webkit-backdrop-filter: blur(26px) saturate(130%);
  transition: margin-left 0.38s var(--ease), transform 0.38s var(--ease);
}

body.sidebar-collapsed .sidebar {
  margin-left: calc(var(--sidebar-w) * -1);
}

.sidebar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
  border-radius: 10px;
}

.brand__mark {
  width: 26px;
  height: 26px;
  filter: drop-shadow(0 4px 12px rgba(124, 156, 255, 0.4));
  transition: transform 0.5s var(--ease);
}

.brand:hover .brand__mark {
  transform: rotate(-10deg) scale(1.06);
}

.brand__name {
  font-size: 14.5px;
  font-weight: 620;
  letter-spacing: 0.01em;
}

.icon-btn.only-mobile {
  display: none;
}

html[data-theme="dark"] .i-moon {
  display: none;
}

html[data-theme="light"] .i-sun {
  display: none;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  color: var(--text-3);
  transition: background 0.18s, color 0.18s, transform 0.18s;
}

.icon-btn:hover {
  background: var(--line);
  color: var(--text);
}

.icon-btn:active {
  transform: scale(0.94);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.new-chat {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  margin: 16px 0 12px;
  padding: 9px 11px;
  border-radius: 11px;
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
  transition: border-color 0.18s, background 0.18s, transform 0.18s;
}

html[data-theme="light"] .new-chat {
  box-shadow: 0 1px 2px rgba(20, 24, 40, 0.04);
}

.new-chat svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  flex: none;
}

.new-chat kbd {
  margin-left: auto;
  padding: 1px 5px;
  border-radius: 5px;
  border: 1px solid var(--line-2);
  color: var(--text-3);
  font-family: var(--font);
  font-size: 10px;
  letter-spacing: 0.03em;
}

.new-chat:hover {
  border-color: rgba(124, 156, 255, 0.4);
  background: var(--surface);
}

.new-chat:active {
  transform: scale(0.995);
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 8px;
}

.search svg {
  position: absolute;
  left: 10px;
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--text-3);
  stroke-width: 1.8;
  stroke-linecap: round;
  pointer-events: none;
}

.search input {
  width: 100%;
  height: 32px;
  padding: 0 10px 0 31px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-size: 12.5px;
  outline: none;
  transition: background 0.18s, border-color 0.18s;
}

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

.search input:hover {
  background: var(--line);
}

.search input:focus {
  background: var(--line);
  border-color: var(--line-2);
}

.search input::-webkit-search-cancel-button {
  appearance: none;
}

.sessions-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 8px 6px;
  color: var(--text-3);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.link-btn {
  padding: 2px 4px;
  border-radius: 5px;
  color: var(--text-3);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  transition: color 0.18s, background 0.18s;
}

.link-btn:hover {
  color: var(--text);
  background: var(--line);
}

.sessions {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  margin: 0 -4px;
  padding: 0 4px 10px;
  scrollbar-width: thin;
}

.sessions__group {
  padding: 12px 8px 5px;
  color: var(--text-3);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.sessions__group:first-child {
  padding-top: 2px;
}

.session {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 8px 8px 9px;
  border-radius: 9px;
  color: var(--text-2);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.16s, color 0.16s;
}

.session svg.session__icon {
  flex: none;
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  opacity: 0.55;
}

.session__title {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.session:hover {
  background: var(--line);
  color: var(--text);
}

.session.is-active {
  background: var(--surface-2);
  color: var(--text);
}

html[data-theme="light"] .session.is-active {
  box-shadow: 0 1px 2px rgba(20, 24, 40, 0.05);
}

.session.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 2px;
  height: 14px;
  border-radius: 2px;
  background: var(--accent);
  transform: translateY(-50%);
}

.session__more {
  display: grid;
  place-items: center;
  flex: none;
  width: 22px;
  height: 22px;
  margin-left: auto;
  border-radius: 6px;
  color: var(--text-3);
  opacity: 0;
  transition: opacity 0.16s, background 0.16s, color 0.16s;
}

.session__more svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
  stroke: none;
}

.session:hover .session__more,
.session.is-active .session__more,
.session__more:focus-visible {
  opacity: 1;
}

.session__more:hover {
  background: var(--line-2);
  color: var(--text);
}

.sessions__empty {
  padding: 22px 10px;
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.8;
  text-align: center;
  white-space: pre-line;
}

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

.account {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 4px 4px 6px;
}

.account__avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(140deg, rgba(94, 234, 212, 0.22), rgba(124, 156, 255, 0.24));
  border: 1px solid var(--line-2);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}

.account__meta {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
  min-width: 0;
}

.account__meta strong {
  font-size: 12.5px;
  font-weight: 550;
}

.account__meta em {
  color: var(--text-3);
  font-size: 10.5px;
  font-style: normal;
}

.account .icon-btn {
  margin-left: auto;
  width: 30px;
  height: 30px;
}

.sidebar__links {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 0;
  color: var(--text-3);
  font-size: 11px;
}

.sidebar__links a,
.sidebar__links button {
  padding: 3px 5px;
  border-radius: 5px;
  color: inherit;
  font-size: inherit;
  transition: color 0.16s, background 0.16s;
}

.sidebar__links a:hover,
.sidebar__links button:hover {
  color: var(--text);
  background: var(--line);
}

.dot-sep {
  opacity: 0.5;
}

/* ---------- Expand button (when collapsed) ---------- */
.expand-btn {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 45;
  display: none;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--text-2);
  box-shadow: var(--shadow-md);
  transition: color 0.16s, border-color 0.16s, transform 0.16s;
}

.expand-btn:hover {
  color: var(--text);
  border-color: rgba(124, 156, 255, 0.45);
  transform: translateY(-1px);
}

.expand-btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

body.sidebar-collapsed .expand-btn {
  display: grid;
}

/* ---------- Main ---------- */
.main {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  height: 100%;
}

.topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 60px;
  padding: 0 20px;
  border-bottom: 1px solid transparent;
  transition: background 0.25s, border-color 0.25s, backdrop-filter 0.25s;
}

.topbar::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--bg) 90%, transparent) 0%,
    color-mix(in srgb, var(--bg) 58%, transparent) 62%,
    transparent 100%
  );
  pointer-events: none;
}

html[data-theme="light"] .topbar::before {
  background: linear-gradient(180deg, rgba(247, 246, 242, 0.92) 0%, rgba(247, 246, 242, 0.6) 62%, transparent 100%);
}

.topbar.is-scrolled {
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-bottom-color: var(--line);
}

.topbar.is-scrolled::before {
  opacity: 0;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}

.model-wrap {
  position: relative;
  margin-left: 2px;
}

body.sidebar-collapsed .model-wrap {
  margin-left: 40px;
}

.model-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--line);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 480;
  transition: border-color 0.18s, color 0.18s, background 0.18s;
}

.model-pill:hover {
  border-color: var(--line-2);
  color: var(--text);
  background: var(--line-2);
}

.model-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.12);
}

.model-pill svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  opacity: 0.55;
}

.model-badge {
  padding: 0 5px;
  border-radius: 4px;
  background: rgba(94, 234, 212, 0.12);
  color: #7fe9d6;
  font-size: 9px;
  font-style: normal;
  letter-spacing: 0.04em;
  line-height: 15px;
}

html[data-theme="light"] .model-badge {
  background: rgba(15, 158, 138, 0.1);
  color: #0f8a78;
}

.model-badge.is-key {
  background: rgba(124, 156, 255, 0.14);
  color: #a9c0ff;
}

html[data-theme="light"] .model-badge.is-key {
  background: rgba(74, 110, 245, 0.1);
  color: #3d5fe0;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid rgba(243, 199, 123, 0.28);
  background: rgba(243, 199, 123, 0.08);
  color: var(--gold);
  font-size: 11px;
}

.status i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

/* ---------- Menus ---------- */
.menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 60;
  min-width: 260px;
  padding: 5px;
  border-radius: 13px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: pop 0.16s var(--ease);
}

.menu--fixed {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 120;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.985);
  }
}

.menu__label {
  padding: 7px 9px 4px;
  color: var(--text-3);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 9px;
  border-radius: 8px;
  color: var(--text-2);
  text-align: left;
  transition: background 0.14s, color 0.14s;
}

.menu__item:hover {
  background: var(--line);
  color: var(--text);
}

.menu__item.is-active {
  background: var(--accent-soft);
  color: var(--text);
}

.menu__item svg {
  flex: none;
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.7;
}

.menu__item__main {
  display: flex;
  flex-direction: column;
  line-height: 1.35;
  min-width: 0;
}

.menu__item__main strong {
  font-size: 12.5px;
  font-weight: 520;
}

.menu__item__main span {
  color: var(--text-3);
  font-size: 10.5px;
}

.menu__check {
  width: 13px;
  height: 13px;
  margin-left: auto;
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.2;
}

.menu__item .menu__check {
  opacity: 0;
}

.menu__item.is-active .menu__check {
  opacity: 1;
}

.menu__divider {
  height: 1px;
  margin: 5px 8px;
  background: var(--line);
}

.menu__item--help {
  color: var(--text-3);
}

.menu__item--help strong {
  font-weight: 500;
}

.menu__item--help svg {
  width: 13px;
  height: 13px;
  margin-left: auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  opacity: 0.7;
}

.menu--danger .menu__item {
  color: var(--danger);
}

.menu--danger .menu__item:hover {
  background: rgba(255, 123, 134, 0.08);
}

/* ---------- Scroll & hero ---------- */
.scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 88px 24px 0;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}

.scroll::-webkit-scrollbar,
.sessions::-webkit-scrollbar {
  width: 8px;
}

.scroll::-webkit-scrollbar-thumb,
.sessions::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: content-box;
}

.scroll__spacer {
  height: 190px;
}

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100dvh - 300px);
  padding: 8px 0 12px;
  text-align: center;
}

.hero__mark {
  width: 54px;
  height: 54px;
  margin-bottom: 18px;
  filter: drop-shadow(0 18px 40px rgba(124, 156, 255, 0.35));
  animation: rise 0.9s var(--ease) both, float 7s ease-in-out 1s infinite;
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

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

.hero__title {
  font-size: clamp(30px, 4.2vw, 48px);
  font-weight: 560;
  line-height: 1.2;
  letter-spacing: -0.035em;
  animation: rise 0.9s var(--ease) 0.06s both;
}

.grad {
  background: var(--grad);
  background-size: 180% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: sheen 10s ease-in-out infinite;
}

@keyframes sheen {
  0%,
  100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

.hero__sub {
  max-width: 540px;
  margin: 16px auto 0;
  color: var(--text-2);
  font-size: 14.5px;
  line-height: 1.85;
  animation: rise 0.9s var(--ease) 0.12s both;
}

.cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
  max-width: 700px;
  margin: 36px auto 0;
  text-align: left;
  animation: rise 0.9s var(--ease) 0.18s both;
}

.card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 15px;
  text-align: left;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 55%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: transform 0.25s var(--ease), border-color 0.25s, background 0.25s, box-shadow 0.25s;
}

.card::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: var(--grad);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}

.card:hover {
  transform: translateY(-2px);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.card:hover::after {
  opacity: 0.55;
}

.card__icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--line);
}

.card__icon svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.55;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.card__icon--a {
  background: linear-gradient(145deg, rgba(94, 234, 212, 0.14), transparent 80%);
  color: var(--teal);
}

.card__icon--b {
  background: linear-gradient(145deg, rgba(124, 156, 255, 0.16), transparent 80%);
  color: var(--accent);
}

.card__icon--c {
  background: linear-gradient(145deg, rgba(183, 156, 255, 0.16), transparent 80%);
  color: var(--violet);
}

.card__icon--d {
  background: linear-gradient(145deg, rgba(243, 199, 123, 0.16), transparent 80%);
  color: var(--gold);
}

.card__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding-top: 1px;
}

.card__body strong {
  font-size: 13.5px;
  font-weight: 550;
}

.card__body span {
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.55;
}

.card__arrow {
  width: 14px;
  height: 14px;
  margin: 4px 0 0 auto;
  flex: none;
  fill: none;
  stroke: var(--text-3);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transform: translate(-2px, 2px);
  transition: opacity 0.2s, transform 0.2s;
}

.card:hover .card__arrow {
  opacity: 1;
  transform: translate(0, 0);
}

.hero__meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  margin-top: 30px;
  animation: rise 0.9s var(--ease) 0.24s both;
}

.hero__meta span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--text-3);
  font-size: 11px;
}

.hero__meta i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--teal);
}

/* ---------- Chat ---------- */
.chat {
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
}

.msg {
  display: flex;
  gap: 13px;
  padding: 18px 0;
  animation: msg-in 0.4s var(--ease) both;
}

@keyframes msg-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.msg--user {
  justify-content: flex-end;
}

.msg__avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  margin-top: 2px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
}

.msg__avatar img {
  width: 18px;
  height: 18px;
}

.msg--user .msg__avatar {
  order: 2;
  border-color: transparent;
  background: linear-gradient(140deg, rgba(124, 156, 255, 0.2), rgba(183, 156, 255, 0.16));
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
}

.msg__main {
  min-width: 0;
  max-width: 100%;
  flex: 1;
}

.msg--user .msg__main {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex: 0 1 auto;
}

.msg__head {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 6px;
  color: var(--text-3);
  font-size: 11.5px;
}

.msg__head strong {
  color: var(--text);
  font-size: 12px;
  font-weight: 550;
}

.msg__head .tag {
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: var(--line);
  color: var(--text-3);
  font-size: 9.5px;
  letter-spacing: 0.02em;
}

.msg__bubble {
  max-width: min(82vw, 600px);
  padding: 10px 15px;
  border-radius: 16px 16px 5px 16px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: var(--msg-size);
  line-height: 1.72;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

html[data-theme="light"] .msg__bubble {
  box-shadow: 0 1px 2px rgba(20, 24, 40, 0.04);
}

.msg__body {
  min-width: 0;
  color: var(--text);
  font-size: var(--msg-size);
  line-height: 1.78;
  overflow-wrap: anywhere;
}

.msg__actions {
  display: flex;
  align-items: center;
  gap: 1px;
  margin-top: 6px;
  opacity: 0;
  transition: opacity 0.18s;
}

.msg--user .msg__actions {
  justify-content: flex-end;
}

.msg:hover .msg__actions,
.msg:focus-within .msg__actions,
.msg__actions.is-visible {
  opacity: 1;
}

.act {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 7px;
  border-radius: 6px;
  color: var(--text-3);
  font-size: 11px;
  transition: color 0.16s, background 0.16s;
}

.act svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.act:hover {
  color: var(--text);
  background: var(--line);
}

.act.is-on {
  color: var(--accent);
}

/* Thinking */
.think {
  margin: 0 0 10px;
  padding-left: 12px;
  border-left: 2px solid var(--line-2);
}

.think[open] {
  border-left-color: color-mix(in srgb, var(--violet) 70%, transparent);
}

.think__summary {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  list-style: none;
  color: var(--text-3);
  font-size: 11.5px;
  user-select: none;
  transition: color 0.16s;
}

.think__summary:hover {
  color: var(--text-2);
}

.think__summary::-webkit-details-marker {
  display: none;
}

.think__summary svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  transition: transform 0.2s;
}

.think[open] .think__summary svg {
  transform: rotate(90deg);
}

.think__text {
  margin-top: 8px;
  color: var(--text-3);
  font-size: 12.5px;
  line-height: 1.8;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Typing / caret */
.caret::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: -0.16em;
  border-radius: 2px;
  background: var(--accent);
  animation: blink 1.05s steps(2, start) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

.typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 0;
}

.typing i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-3);
  animation: pulse 1.3s ease-in-out infinite;
}

.typing i:nth-child(2) {
  animation-delay: 0.16s;
}

.typing i:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

.msg__error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid rgba(255, 123, 134, 0.22);
  background: rgba(255, 123, 134, 0.06);
  color: #ffb3ba;
  font-size: 12.5px;
  line-height: 1.65;
}

html[data-theme="light"] .msg__error {
  color: #b3273a;
}

/* ---------- Markdown ---------- */
.md > :first-child {
  margin-top: 0;
}

.md > :last-child {
  margin-bottom: 0;
}

.md p {
  margin: 0.7em 0;
}

.md h1,
.md h2,
.md h3,
.md h4 {
  margin: 1.45em 0 0.55em;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -0.015em;
}

.md h1 {
  font-size: 1.4em;
}

.md h2 {
  font-size: 1.22em;
}

.md h3 {
  font-size: 1.08em;
}

.md h4 {
  font-size: 1em;
  color: var(--text-2);
}

.md ul,
.md ol {
  margin: 0.65em 0;
  padding-left: 1.3em;
}

.md li {
  margin: 0.3em 0;
}

.md li::marker {
  color: var(--text-3);
}

.md strong {
  font-weight: 620;
}

.md a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent);
  text-underline-offset: 3px;
}

.md a:hover {
  text-decoration-color: var(--accent);
}

.md blockquote {
  margin: 0.85em 0;
  padding: 2px 0 2px 14px;
  border-left: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  color: var(--text-2);
}

.md hr {
  margin: 1.5em 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.md code {
  padding: 0.15em 0.4em;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: var(--line);
  font-family: var(--mono);
  font-size: 0.86em;
}

.md table {
  width: 100%;
  margin: 1em 0;
  border-collapse: collapse;
  font-size: 0.92em;
  border-radius: 8px;
  overflow: hidden;
}

.md th,
.md td {
  padding: 7px 11px;
  border: 1px solid var(--line);
  text-align: left;
}

.md th {
  background: var(--line);
  font-weight: 550;
  font-size: 0.94em;
}

/* Code */
.code-block {
  margin: 13px 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #090b11;
}

html[data-theme="light"] .code-block {
  background: #fbfbfd;
  box-shadow: 0 1px 2px rgba(20, 24, 40, 0.05);
}

.code-block__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 11px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-3);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

html[data-theme="light"] .code-block__head {
  background: rgba(20, 24, 40, 0.025);
}

.code-block__copy {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 5px;
  color: var(--text-3);
  font-family: var(--font);
  font-size: 10.5px;
  text-transform: none;
  letter-spacing: 0;
  transition: color 0.16s, background 0.16s;
}

.code-block__copy:hover {
  color: var(--text);
  background: var(--line);
}

.code-block__copy svg {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.code-block pre {
  margin: 0;
  padding: 13px 15px;
  overflow-x: auto;
}

.code-block code {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  font-family: var(--mono);
  font-size: 12.8px;
  line-height: 1.72;
  color: #dbe2f2;
  tab-size: 2;
  -webkit-font-smoothing: auto;
}

html[data-theme="light"] .code-block code {
  color: #1f2430;
}

/* Prism tokens */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: #6f7b96;
}

.token.punctuation {
  color: #9aa6bf;
}

.token.property,
.token.tag,
.token.constant,
.token.symbol,
.token.deleted {
  color: #ff9dba;
}

.token.boolean,
.token.number {
  color: #ffc98a;
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
  color: #9be8c0;
}

.token.operator,
.token.entity,
.token.url {
  color: #93dff0;
}

.token.atrule,
.token.attr-value,
.token.keyword {
  color: #c4a5ff;
}

.token.function,
.token.class-name {
  color: #9cc0ff;
}

.token.regex,
.token.important,
.token.variable {
  color: #ffd08a;
}

html[data-theme="light"] .token.comment {
  color: #8b94a8;
}

html[data-theme="light"] .token.keyword {
  color: #7c3aed;
}

html[data-theme="light"] .token.string {
  color: #0f7a54;
}

html[data-theme="light"] .token.function {
  color: #2456d6;
}

html[data-theme="light"] .token.number {
  color: #b45309;
}

/* Inline edit */
.edit-box {
  width: min(560px, 78vw);
  margin-top: 2px;
}

.edit-input {
  width: 100%;
  min-height: 76px;
  max-height: 220px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line-2);
  background: var(--bg-2);
  color: var(--text);
  font-size: var(--msg-size);
  line-height: 1.65;
  resize: vertical;
  outline: none;
}

.edit-input:focus {
  border-color: var(--accent);
}

.edit-input:focus-visible {
  outline: none;
}

.edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  margin-top: 7px;
}

/* Work mode */
.chip--mode.is-work {
  color: var(--text);
  border-color: color-mix(in srgb, var(--violet) 45%, transparent);
  background: color-mix(in srgb, var(--violet) 12%, transparent);
}

.chip--mode.is-work svg:first-child {
  color: var(--violet);
}

.work {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--line);
}

.work__head {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
}

.work__head svg {
  width: 14px;
  height: 14px;
  flex: none;
  fill: none;
  stroke: var(--violet);
  stroke-width: 1.7;
  stroke-linejoin: round;
}

.work__head strong {
  font-weight: 550;
}

.work__state {
  margin-left: auto;
  color: var(--text-3);
  font-size: 10.5px;
}

.work__state.is-running,
.work__state.is-planning,
.work__state.is-finalizing {
  color: var(--accent);
}

.work__state.is-done {
  color: var(--teal);
}

.work__state.is-error {
  color: var(--danger);
}

.work__steps {
  display: flex;
  flex-direction: column;
  margin-top: 8px;
}

.work-step {
  border-top: 1px solid var(--line);
}

.work-step:first-child {
  border-top: 0;
}

.work-step__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 2px;
  list-style: none;
  color: var(--text-2);
  font-size: 12.5px;
  cursor: pointer;
}

.work-step__head::-webkit-details-marker {
  display: none;
}

.work-step__dot {
  display: grid;
  place-items: center;
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  color: var(--text-3);
  font-size: 9.5px;
}

.work-step.is-running .work-step__dot {
  border-color: color-mix(in srgb, var(--accent) 65%, transparent);
  color: var(--accent);
  animation: dot-pulse 1.4s ease-in-out infinite;
}

@keyframes dot-pulse {
  50% {
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent);
  }
}

.work-step.is-done .work-step__dot {
  border-color: rgba(94, 234, 212, 0.45);
  color: var(--teal);
}

.work-step__head strong {
  overflow: hidden;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.work-step__state {
  margin-left: auto;
  flex: none;
  color: var(--text-3);
  font-size: 10px;
}

.work-step__chev {
  display: inline-flex;
  flex: none;
  color: var(--text-3);
  transition: transform 0.2s;
}

.work-step__chev svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.work-step[open] .work-step__chev {
  transform: rotate(90deg);
}

.work-step.is-running .work-step__state {
  color: var(--accent);
}

.work-step.is-done .work-step__state {
  color: var(--teal);
}

.work-step__body {
  padding: 0 0 10px 26px;
  color: var(--text-2);
  font-size: calc(var(--msg-size) - 1px);
  line-height: 1.75;
}

.work-step__body:empty {
  display: none;
}

.work__final {
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line-2);
  font-size: var(--msg-size);
}

/* Attachment chips inside a message */
.msg__files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 240px;
  padding: 4px 9px;
  border-radius: 7px;
  border: 1px solid var(--line-2);
  background: var(--line);
  color: var(--text-2);
  font-size: 11.5px;
}

.file-chip svg {
  flex: none;
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
}

.file-chip span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ---------- Composer ---------- */
.composer-dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 15;
  padding: 24px 24px 14px;
  background: linear-gradient(180deg, transparent 0%, var(--bg) 44%, var(--bg) 70%);
  pointer-events: none;
}

.attach-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
  max-width: 800px;
  margin: 0 auto 8px;
  pointer-events: auto;
}

.attach {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 260px;
  padding: 5px 6px 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--text-2);
  font-size: 11.5px;
  box-shadow: var(--shadow-md);
}

.attach svg {
  flex: none;
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
}

.attach span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.attach button {
  display: grid;
  place-items: center;
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  color: var(--text-3);
}

.attach button:hover {
  background: var(--line-2);
  color: var(--text);
}

.attach button svg {
  width: 11px;
  height: 11px;
}

.composer {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  pointer-events: auto;
}

.composer__field,
.composer form {
  position: relative;
}

.composer {
  position: relative;
  padding: 12px 12px 8px;
  border-radius: 20px;
  border: 1px solid var(--line-2);
  background: var(--bg-2);
  background: color-mix(in srgb, var(--bg-2) 88%, transparent);
  backdrop-filter: blur(26px) saturate(150%);
  -webkit-backdrop-filter: blur(26px) saturate(150%);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: border-color 0.22s, box-shadow 0.25s;
}

.composer::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(120deg, rgba(94, 234, 212, 0.5), rgba(124, 156, 255, 0.5) 45%, rgba(183, 156, 255, 0.5));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}

.composer:focus-within::before {
  opacity: 0.85;
}

.composer__input {
  display: block;
  width: 100%;
  max-height: 180px;
  padding: 2px 4px 8px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: var(--msg-size);
  line-height: 1.65;
  resize: none;
  outline: none;
  overflow-y: auto;
  scrollbar-width: thin;
}

.composer__input::placeholder {
  color: var(--text-3);
}

.composer__bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.composer__left {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.composer__right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.tool {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: var(--text-3);
  transition: color 0.16s, background 0.16s;
}

.tool:hover {
  color: var(--text);
  background: var(--line);
}

.tool svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tool.is-recording {
  color: var(--danger);
  background: rgba(255, 123, 134, 0.1);
  animation: rec 1.4s ease-in-out infinite;
}

@keyframes rec {
  50% {
    opacity: 0.55;
  }
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-3);
  font-size: 11.5px;
  white-space: nowrap;
  transition: color 0.16s, border-color 0.16s, background 0.16s;
}

.chip svg {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linejoin: round;
}

.chip:hover {
  color: var(--text);
  border-color: var(--line);
  background: var(--line);
}

.chip--think[aria-pressed="true"] {
  color: var(--text);
  border-color: color-mix(in srgb, var(--violet) 45%, transparent);
  background: color-mix(in srgb, var(--violet) 12%, transparent);
}

.chip--think[aria-pressed="true"] svg {
  fill: currentColor;
  stroke: none;
  color: var(--violet);
}

.counter {
  color: var(--text-3);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  opacity: 0;
  transition: opacity 0.16s;
}

.counter.is-visible {
  opacity: 0.8;
}

.send {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  transition: transform 0.18s var(--ease), opacity 0.18s, background 0.18s;
}

html[data-theme="dark"] .send {
  background: linear-gradient(140deg, #f7f8fb, #dfe5f5);
  color: #0a0c12;
}

.send svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.send .i-stop {
  display: none;
  fill: currentColor;
  stroke: none;
}

.send:hover:not(:disabled) {
  transform: translateY(-1px);
  opacity: 0.92;
}

.send:active:not(:disabled) {
  transform: scale(0.94);
}

.send:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.composer.is-streaming .send {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line-2);
}

.composer.is-streaming .send .i-send {
  display: none;
}

.composer.is-streaming .send .i-stop {
  display: block;
}

.hint {
  max-width: 800px;
  margin: 8px auto 0;
  color: var(--text-3);
  font-size: 10px;
  letter-spacing: 0.02em;
  text-align: center;
  opacity: 0.7;
  pointer-events: auto;
}

/* ---------- To bottom ---------- */
.to-bottom {
  position: absolute;
  right: 28px;
  bottom: 178px;
  z-index: 16;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--text-2);
  box-shadow: var(--shadow-md);
  transition: color 0.16s, transform 0.16s;
  animation: fade 0.18s ease both;
}

.to-bottom:hover {
  color: var(--text);
  transform: translateY(-1px);
}

.to-bottom svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

/* ---------- Modals ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 22px;
}

.modal__scrim {
  position: absolute;
  inset: 0;
  background: rgba(3, 4, 8, 0.6);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  animation: fade 0.2s ease both;
}

html[data-theme="light"] .modal__scrim {
  background: rgba(240, 238, 232, 0.55);
}

.modal__panel {
  position: relative;
  width: 100%;
  max-height: min(84vh, 760px);
  overflow-y: auto;
  padding: 28px;
  border-radius: 20px;
  border: 1px solid var(--line-2);
  background: var(--bg-2);
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.3s var(--ease) both;
  scrollbar-width: thin;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.99);
  }
}

.modal__panel--about {
  max-width: 520px;
}

.modal__panel--settings {
  max-width: 480px;
}

.modal__panel--confirm {
  max-width: 380px;
}

.modal__panel--shortcuts {
  max-width: 430px;
}

.modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: var(--text-3);
  transition: background 0.16s, color 0.16s;
}

.modal__close:hover {
  background: var(--line);
  color: var(--text);
}

.modal__close svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.panel__title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.panel__note {
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--text-3);
  font-size: 10.5px;
  line-height: 1.75;
}

/* About */
.about__head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.about__head img {
  width: 52px;
  height: 52px;
  filter: drop-shadow(0 10px 24px rgba(124, 156, 255, 0.35));
}

.about__head h2 {
  font-size: 20px;
  font-weight: 620;
  letter-spacing: -0.02em;
}

.about__head p {
  margin-top: 2px;
  color: var(--text-3);
  font-size: 12px;
}

.about__lead {
  margin: 20px 0;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.85;
}

.about__label {
  margin-bottom: 8px;
  color: var(--text-3);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.person {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--line);
}

.person__avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(140deg, rgba(94, 234, 212, 0.22), rgba(124, 156, 255, 0.24));
  border: 1px solid var(--line-2);
  font-size: 12px;
  font-weight: 600;
}

.person strong {
  display: block;
  font-size: 13px;
  font-weight: 550;
}

.person em {
  display: block;
  margin-top: 1px;
  color: var(--text-3);
  font-size: 10.5px;
  font-style: normal;
}

.about__rows {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 16px 0 12px;
}

.about__row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 9px;
  border-radius: 9px;
  transition: background 0.16s;
}

.about__row:hover {
  background: var(--line);
}

.about__row svg {
  flex: none;
  width: 15px;
  height: 15px;
  fill: none;
  stroke: var(--text-3);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.about__row span {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.about__row em {
  flex: none;
  width: 58px;
  color: var(--text-3);
  font-size: 11px;
  font-style: normal;
}

.about__row strong {
  font-size: 12.5px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.about__stack {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 13px 0 4px;
  border-top: 1px solid var(--line);
}

.about__stack span {
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--text-3);
  font-size: 10px;
}

.about__foot {
  margin-top: 14px;
  color: var(--text-3);
  font-size: 10px;
}

.about__foot a {
  color: var(--text-2);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Settings */
.setting {
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.setting:last-of-type {
  border-bottom: 0;
}

.setting h3 {
  margin-bottom: 9px;
  color: var(--text-3);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--line);
}

.segmented button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  border-radius: 7px;
  color: var(--text-3);
  font-size: 11.5px;
  transition: background 0.16s, color 0.16s;
}

.segmented button[aria-checked="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

html[data-theme="light"] .segmented button[aria-checked="true"] {
  box-shadow: 0 1px 2px rgba(20, 24, 40, 0.08);
}

.swatch {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  border: 1px solid var(--line-2);
}

.swatch--dark {
  background: #0b0d13;
}

.swatch--light {
  background: #f7f6f2;
}

.swatch--system {
  background: linear-gradient(135deg, #0b0d13 50%, #f7f6f2 50%);
}

.field {
  margin-top: 10px;
}

.field label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  color: var(--text-2);
  font-size: 12px;
}

.field__value {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.field select {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--line);
  color: var(--text);
  font-size: 12.5px;
  outline: none;
}

.field input[type="range"] {
  width: 100%;
  height: 4px;
  margin: 7px 0 2px;
  appearance: none;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) var(--fill, 50%), var(--line-2) var(--fill, 50%));
  outline: none;
}

.field input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line-2);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

.field__hint {
  margin-top: 5px;
  color: var(--text-3);
  font-size: 10.5px;
}

.setting__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 0;
}

.setting__row strong {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
}

.setting__row em {
  display: block;
  margin-top: 1px;
  color: var(--text-3);
  font-size: 10.5px;
  font-style: normal;
}

.btn {
  flex: none;
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  font-size: 12px;
  transition: background 0.16s, color 0.16s, border-color 0.16s, transform 0.14s;
}

.btn:active {
  transform: scale(0.98);
}

.btn--ghost {
  background: var(--line);
  color: var(--text-2);
}

.btn--ghost:hover {
  background: var(--line-2);
  color: var(--text);
}

.btn--primary {
  border-color: transparent;
  background: var(--text);
  color: var(--bg);
  font-weight: 550;
}

.btn--primary:hover {
  opacity: 0.9;
}

.btn--danger {
  border-color: rgba(255, 123, 134, 0.3);
  background: rgba(255, 123, 134, 0.07);
  color: #ff9aa3;
}

html[data-theme="light"] .btn--danger {
  color: #c02a3b;
}

.btn--danger:hover {
  background: rgba(255, 123, 134, 0.14);
}

.text-input {
  width: 100%;
  height: 40px;
  margin-top: 16px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--line-2);
  background: var(--line);
  color: var(--text);
  font-size: 13.5px;
  outline: none;
}

.text-input:focus {
  border-color: var(--accent);
}

/* Own key */
.modal__panel--key {
  max-width: 470px;
}

.key__lead {
  margin: 14px 0 12px;
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.75;
}

.key__lead strong {
  color: var(--text);
  font-weight: 600;
}

.key__steps {
  margin: 0 0 14px;
  padding-left: 18px;
  color: var(--text-2);
  font-size: 12px;
  line-height: 2;
}

.key__steps code {
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--line);
  font-family: var(--mono);
  font-size: 11px;
}

.key__steps a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.key__warn {
  margin-top: 8px;
  color: var(--text-3);
  font-size: 10.5px;
  line-height: 1.7;
}

.key__clear {
  display: block;
  margin: 14px auto 0;
  color: var(--text-3);
  font-size: 11px;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.16s;
}

.key__clear:hover {
  color: var(--danger);
}

.pill-tag {
  flex: none;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  color: var(--text-3);
  font-size: 10px;
}

/* Shortcuts */
.shortcuts {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
}

.shortcuts li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 2px;
  border-bottom: 1px solid var(--line);
  color: var(--text-2);
  font-size: 12.5px;
}

.shortcuts li:last-child {
  border-bottom: 0;
}

.keys {
  display: flex;
  gap: 4px;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 5px;
  border: 1px solid var(--line-2);
  background: var(--line);
  color: var(--text-2);
  font-family: var(--font);
  font-size: 10.5px;
  box-shadow: 0 1px 0 var(--line-2);
}

/* Confirm */
.modal__panel--confirm h2 {
  font-size: 16px;
  font-weight: 600;
}

.modal__panel--confirm p {
  margin-top: 7px;
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.75;
}

/* ---------- Toasts ---------- */
.toasts {
  position: fixed;
  left: 50%;
  bottom: 96px;
  z-index: 260;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  color: var(--text);
  font-size: 12px;
  animation: toast-in 0.25s var(--ease) both;
}

.toast.is-out {
  animation: toast-out 0.22s ease both;
}

.toast i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--teal);
}

.toast--err i {
  background: var(--danger);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(5px);
  }
}

/* ---------- Scrim / noscript ---------- */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 25;
  background: rgba(3, 4, 8, 0.5);
  backdrop-filter: blur(3px);
  animation: fade 0.18s ease both;
}

.noscript {
  position: fixed;
  inset: auto 20px 20px;
  z-index: 400;
  padding: 13px 17px;
  border-radius: 11px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  font-size: 12.5px;
  text-align: center;
}

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  :root {
    --sidebar-w: 256px;
  }
}

@media (max-width: 900px) {
  .only-desktop,
  .hide-sm {
    display: none !important;
  }

  .icon-btn.only-mobile {
    display: grid;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(84vw, 310px);
    transform: translateX(-102%);
    background: var(--bg-2);
    box-shadow: 40px 0 80px -40px rgba(0, 0, 0, 0.7);
  }

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

  body.sidebar-collapsed .sidebar {
    margin-left: 0;
  }

  .expand-btn {
    display: none !important;
  }

  .topbar {
    padding: 0 12px;
    height: 54px;
  }

  .scroll {
    padding: 72px 14px 0;
  }

  .hero {
    min-height: calc(100dvh - 290px);
  }

  .hero__mark {
    width: 46px;
    height: 46px;
    margin-bottom: 14px;
  }

  .hero__title {
    font-size: clamp(26px, 7.6vw, 34px);
  }

  .hero__sub {
    font-size: 13.5px;
    line-height: 1.8;
  }

  .hero__sub br {
    display: none;
  }

  .cards {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 26px;
  }

  .hero__meta {
    display: none;
  }

  .composer-dock {
    padding: 20px 10px calc(8px + env(safe-area-inset-bottom));
  }

  .composer {
    border-radius: 18px;
    padding: 10px 10px 7px;
  }

  .hint {
    font-size: 9px;
  }

  .toasts {
    bottom: 106px;
  }

  .to-bottom {
    right: 14px;
    bottom: 168px;
  }

  .modal {
    padding: 12px;
  }

  .modal__panel {
    padding: 22px 18px;
    max-height: 88vh;
  }

  .msg {
    gap: 9px;
    padding: 14px 0;
  }

  .msg__actions {
    opacity: 1;
  }

  .msg__bubble {
    max-width: 84vw;
  }

  .session__more {
    opacity: 1;
  }
}

@media (max-width: 420px) {
  .model-pill {
    font-size: 11.5px;
  }

  body.sidebar-collapsed .model-wrap {
    margin-left: 0;
  }

  .topbar__actions {
    gap: 0;
  }

  .composer__left {
    gap: 1px;
  }

  .chip {
    font-size: 11px;
    padding: 0 7px;
  }
}

/* ---------- Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
