:root {
  --glass: rgba(255, 255, 255, 0.52);
  --glass-soft: rgba(255, 255, 255, 0.34);
  --glass-strong: rgba(255, 255, 255, 0.72);
  --glass-edge: rgba(255, 255, 255, 0.9);
  --hairline: rgba(28, 42, 80, 0.08);
  --hairline-soft: rgba(28, 42, 80, 0.055);

  --text: #1c2437;
  --text-soft: #3c4761;
  --muted: #5d687e;
  --muted-dim: #78829a;

  --accent: #6d9bff;
  --accent-ink: #2f5ae0;
  --accent-soft: rgba(109, 155, 255, 0.16);
  --accent-line: rgba(47, 90, 224, 0.28);
  --danger: #c93a4a;

  --shadow-sm: 0 2px 8px rgba(48, 66, 120, 0.06);
  --shadow-md: 0 12px 30px rgba(48, 66, 120, 0.1);
  --shadow-lg: 0 22px 55px rgba(48, 66, 120, 0.14);
  --inner-top: inset 0 1px 0 rgba(255, 255, 255, 0.95);
  --blur: blur(26px) saturate(175%);

  --radius: 16px;
  --sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", ui-monospace, "Consolas", monospace;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  background: #f7f9fe;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(760px 620px at 10% -8%, #d9e5ff 0%, rgba(217, 229, 255, 0) 62%),
    radial-gradient(680px 560px at 96% 4%, #ffe2ef 0%, rgba(255, 226, 239, 0) 60%),
    radial-gradient(720px 620px at 78% 104%, #d6f4ee 0%, rgba(214, 244, 238, 0) 62%),
    radial-gradient(640px 560px at 2% 92%, #e9dcff 0%, rgba(233, 220, 255, 0) 60%),
    linear-gradient(180deg, #f8faff 0%, #f4f7fd 100%);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image: radial-gradient(rgba(255, 255, 255, 0.9) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(180deg, black, transparent 70%);
  -webkit-mask-image: linear-gradient(180deg, black, transparent 70%);
}

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

svg {
  display: block;
}

::selection {
  background: rgba(109, 155, 255, 0.3);
  color: #16203a;
}

/* ---------------------------------------------------------------- layout */

.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 278px minmax(0, 1fr);
  height: 100dvh;
  overflow: hidden;
}

/* --------------------------------------------------------------- sidebar */

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 14px;
  min-height: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.66), rgba(255, 255, 255, 0.36));
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-right: 1px solid var(--glass-edge);
  box-shadow: 1px 0 0 var(--hairline-soft), 14px 0 44px rgba(48, 66, 120, 0.06);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 2px 4px 4px;
}

.mark,
.empty-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: linear-gradient(155deg, #ffffff, rgba(255, 255, 255, 0.55));
  border: 1px solid var(--glass-edge);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 20px;
  line-height: 1;
  padding-bottom: 2px;
  box-shadow: var(--shadow-sm), var(--inner-top);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.brand-name {
  font-size: 17px;
  font-weight: 680;
  letter-spacing: -0.02em;
  color: #141c2e;
}

.brand-by {
  font-size: 10.5px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted-dim);
}

.nav {
  display: flex;
  gap: 8px;
}

.nav-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 8px;
  border-radius: 11px;
  border: 1px solid var(--glass-edge);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0.44));
  color: var(--text-soft);
  font-size: 12.5px;
  font-weight: 560;
  cursor: pointer;
  box-shadow: var(--shadow-sm), var(--inner-top);
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.nav-btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-btn:hover {
  background: #ffffff;
  color: var(--text);
}

.nav-btn:active {
  transform: translateY(1px);
}

.nav-btn.active {
  background: linear-gradient(180deg, #ffffff, rgba(238, 244, 255, 0.92));
  border-color: rgba(109, 155, 255, 0.5);
  color: var(--accent-ink);
  box-shadow: 0 0 0 3px rgba(109, 155, 255, 0.12), var(--shadow-sm), var(--inner-top);
}

.search {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--muted-dim);
  stroke-width: 1.8;
  stroke-linecap: round;
}

.search input {
  width: 100%;
  padding: 8px 12px 8px 31px;
  border-radius: 10px;
  border: 1px solid var(--glass-edge);
  background: rgba(255, 255, 255, 0.5);
  font-size: 12.5px;
  color: var(--text);
  outline: 0;
  transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.search input::placeholder {
  color: #8d97ab;
}

.search input:focus {
  background: #ffffff;
  border-color: rgba(109, 155, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(109, 155, 255, 0.14);
}

.search-inline {
  width: 200px;
}

.search-inline input {
  padding-top: 6px;
  padding-bottom: 6px;
}

.threads {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(28, 42, 80, 0.18) transparent;
}

.threads-note {
  margin: 8px 8px 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted-dim);
}

.threads-label {
  padding: 8px 8px 4px;
  font-size: 10.5px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted-dim);
}

.thread {
  position: relative;
  display: flex;
  align-items: center;
  border-radius: 11px;
}

.thread button.open {
  flex: 1;
  min-width: 0;
  text-align: left;
  padding: 8px 58px 8px 11px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--text-soft);
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.thread:hover button.open {
  background: rgba(255, 255, 255, 0.62);
  border-color: rgba(255, 255, 255, 0.85);
  color: var(--text);
}

.thread.active button.open {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.7));
  border-color: var(--glass-edge);
  color: #16203a;
  font-weight: 550;
  box-shadow: var(--shadow-sm), inset 2px 0 0 var(--accent);
}

.thread-actions {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 1px;
  opacity: 0;
  transition: opacity 0.14s ease;
}

.thread:hover .thread-actions,
.thread:focus-within .thread-actions {
  opacity: 1;
}

.thread .act {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted-dim);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

.thread .act:hover {
  background: rgba(255, 255, 255, 0.92);
  color: var(--accent-ink);
}

.thread .act.del:hover {
  color: var(--danger);
  background: rgba(201, 58, 74, 0.1);
}

.sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 6px 2px;
  border-top: 1px solid var(--hairline);
}

.status {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 4px;
  font-size: 11.5px;
  color: var(--muted-dim);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #a7b0c2;
  flex: none;
}

.dot.ok {
  background: #27a86e;
  box-shadow: 0 0 0 3px rgba(39, 168, 110, 0.16);
}

.dot.bad {
  background: #e39a1f;
  box-shadow: 0 0 0 3px rgba(227, 154, 31, 0.18);
}

.foot-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 6px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.foot-btn svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.foot-btn:hover {
  background: rgba(255, 255, 255, 0.7);
  border-color: var(--glass-edge);
  color: var(--text);
}

.scrim {
  display: none;
}

/* ------------------------------------------------------------------ chat */

.chat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 22px;
  border-bottom: 1px solid var(--glass-edge);
  background: rgba(255, 255, 255, 0.42);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: 0 1px 0 var(--hairline-soft), 0 10px 30px rgba(48, 66, 120, 0.04);
}

.topbar-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.topbar h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 620;
  letter-spacing: -0.015em;
  color: #16203a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.view-sub {
  margin: 0;
  font-size: 11.5px;
  color: var(--muted-dim);
  letter-spacing: 0.02em;
}

.title-input {
  width: min(320px, 58vw);
  padding: 3px 8px;
  border-radius: 8px;
  border: 1px solid rgba(109, 155, 255, 0.6);
  background: #ffffff;
  font-size: 15px;
  font-weight: 620;
  color: var(--text);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(109, 155, 255, 0.16);
}

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

.icon-btn {
  display: none;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--glass-edge);
  background: var(--glass-strong);
  cursor: pointer;
  color: var(--text-soft);
  box-shadow: var(--shadow-sm), var(--inner-top);
}

.icon-btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
}

.tool-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: 1px solid var(--glass-edge);
  background: rgba(255, 255, 255, 0.6);
  color: var(--muted);
  cursor: pointer;
  box-shadow: var(--shadow-sm), var(--inner-top);
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

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

.tool-btn:hover {
  background: #ffffff;
  color: var(--accent-ink);
  border-color: rgba(109, 155, 255, 0.45);
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.track {
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: rgba(28, 42, 80, 0.12);
  border: 1px solid rgba(28, 42, 80, 0.08);
  padding: 2px;
  display: flex;
  box-shadow: inset 0 1px 2px rgba(28, 42, 80, 0.1);
  transition: background 0.18s ease, border-color 0.18s ease;
}

.knob {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(28, 42, 80, 0.28);
  transition: transform 0.18s ease;
}

.switch input:checked + .track {
  background: linear-gradient(180deg, #7fa8ff, #5b8bfa);
  border-color: rgba(47, 90, 224, 0.35);
}

.switch input:checked + .track .knob {
  transform: translateX(16px);
}

.switch input:focus-visible + .track {
  outline: 2px solid var(--accent-ink);
  outline-offset: 2px;
}

.switch-label {
  font-size: 12.5px;
  color: var(--muted);
}

/* ------------------------------------------------------------- transcript */

.scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: rgba(28, 42, 80, 0.18) transparent;
}

.scroll::-webkit-scrollbar,
.threads::-webkit-scrollbar,
.code pre::-webkit-scrollbar,
.thinking .think-body::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

.scroll::-webkit-scrollbar-thumb,
.threads::-webkit-scrollbar-thumb,
.code pre::-webkit-scrollbar-thumb,
.thinking .think-body::-webkit-scrollbar-thumb {
  background: rgba(28, 42, 80, 0.16);
  border-radius: 999px;
}

.messages {
  width: min(780px, 100%);
  margin: 0 auto;
  padding: 26px 22px 8px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.msg {
  display: flex;
  gap: 12px;
  animation: rise 0.28s ease both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.msg .who {
  flex: none;
  width: 27px;
  height: 27px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent-ink);
  background: linear-gradient(160deg, #ffffff, rgba(240, 245, 255, 0.8));
  border: 1px solid var(--glass-edge);
  box-shadow: var(--shadow-sm), var(--inner-top);
  margin-top: 2px;
}

.msg.user .who {
  color: var(--muted);
  background: linear-gradient(160deg, #ffffff, rgba(246, 248, 253, 0.85));
}

.msg .stack {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg.user .stack {
  align-items: flex-start;
}

.msg .body {
  min-width: 0;
  overflow-wrap: anywhere;
}

.msg.user .body {
  max-width: 100%;
  padding: 10px 15px;
  border-radius: 6px 16px 16px 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.66));
  border: 1px solid var(--glass-edge);
  box-shadow: var(--shadow-sm), var(--inner-top);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: #1b2438;
  white-space: pre-wrap;
}

.msg.assistant .body {
  padding: 2px 2px 0;
  color: var(--text);
}

.msg-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.16s ease;
}

.msg:hover .msg-actions,
.msg-actions:focus-within {
  opacity: 1;
}

.msg-actions button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted-dim);
  font-size: 11.5px;
  padding: 3px 7px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.msg-actions button:hover {
  background: rgba(255, 255, 255, 0.85);
  border-color: var(--glass-edge);
  color: var(--accent-ink);
}

.msg-actions .words {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted-dim);
}

.body > *:first-child {
  margin-top: 0;
}

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

.body p {
  margin: 0 0 12px;
}

.body h2,
.body h3,
.body h4,
.body h5,
.body h6 {
  margin: 20px 0 8px;
  line-height: 1.3;
  letter-spacing: -0.015em;
  color: #141c2e;
}

.body h2 {
  font-size: 19px;
}
.body h3 {
  font-size: 17px;
}
.body h4 {
  font-size: 15.5px;
}
.body h5,
.body h6 {
  font-size: 14px;
  color: var(--muted);
}

.body ul,
.body ol {
  margin: 0 0 12px;
  padding-left: 22px;
}

.body li {
  margin: 4px 0;
}

.body li::marker {
  color: #9aa4b8;
}

.body a {
  color: var(--accent-ink);
  text-decoration: none;
  border-bottom: 1px solid rgba(47, 90, 224, 0.28);
}

.body a:hover {
  border-bottom-color: var(--accent-ink);
}

.body strong {
  color: #101827;
  font-weight: 650;
}

.body blockquote {
  margin: 0 0 12px;
  padding: 2px 0 2px 14px;
  border-left: 2px solid rgba(47, 90, 224, 0.35);
  color: var(--muted);
}

.body hr {
  border: 0;
  border-top: 1px solid var(--hairline);
  margin: 18px 0;
}

.body code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: rgba(47, 90, 224, 0.07);
  border: 1px solid rgba(47, 90, 224, 0.12);
  padding: 1px 5px;
  border-radius: 6px;
  color: #24418f;
}

.code {
  margin: 0 0 14px;
  border: 1px solid var(--glass-edge);
  border-radius: 13px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.6);
  box-shadow: var(--shadow-sm), var(--inner-top);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 6px 12px;
  background: rgba(255, 255, 255, 0.5);
  border-bottom: 1px solid var(--hairline);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted-dim);
  text-transform: lowercase;
}

.code .copy {
  border: 0;
  background: transparent;
  color: var(--muted-dim);
  font-size: 11px;
  font-family: var(--sans);
  padding: 3px 8px;
  border-radius: 7px;
  cursor: pointer;
  transition: color 0.14s ease, background 0.14s ease;
}

.code .copy:hover {
  color: var(--accent-ink);
  background: rgba(255, 255, 255, 0.85);
}

.code pre {
  margin: 0;
  padding: 13px 14px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.code code {
  background: none;
  border: 0;
  padding: 0;
  font-size: 12.5px;
  line-height: 1.62;
  color: #24314f;
}

.body table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 14px;
  font-size: 13.5px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm), var(--inner-top);
}

.body th,
.body td {
  border: 1px solid var(--hairline);
  padding: 7px 10px;
  text-align: left;
  vertical-align: top;
}

.body th {
  background: rgba(255, 255, 255, 0.72);
  font-weight: 600;
  color: #141c2e;
}

.thinking {
  margin: 0;
  border: 1px solid var(--glass-edge);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.45);
  box-shadow: var(--shadow-sm), var(--inner-top);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.thinking summary {
  cursor: pointer;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--muted);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 7px;
}

.thinking summary::-webkit-details-marker {
  display: none;
}

.thinking summary::before {
  content: "▸";
  color: var(--accent);
  font-size: 10px;
  transition: transform 0.16s ease;
}

.thinking[open] summary::before {
  transform: rotate(90deg);
}

.thinking .think-body {
  padding: 0 12px 10px;
  font-size: 12.5px;
  line-height: 1.62;
  color: var(--muted);
  max-height: 320px;
  overflow-y: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  scrollbar-width: thin;
}

.error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1px solid rgba(201, 58, 74, 0.24);
  background: rgba(255, 233, 235, 0.7);
  color: #8d2432;
  font-size: 13.5px;
}

.typing {
  display: inline-block;
  width: 7px;
  height: 15px;
  background: var(--accent);
  border-radius: 2px;
  vertical-align: -2px;
  animation: blink 1s steps(2, start) infinite;
}

@keyframes blink {
  to {
    opacity: 0;
  }
}

/* ---------------------------------------------------------- empty state */

.empty {
  width: min(780px, 100%);
  margin: 0 auto;
  padding: 34px 22px 40px;
  text-align: center;
}

.empty-mark {
  width: 54px;
  height: 54px;
  border-radius: 17px;
  font-size: 30px;
  margin: 0 auto 14px;
}

.empty h2 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.035em;
  font-weight: 680;
  color: #121a2b;
}

.empty-by {
  margin: 2px 0 14px;
  font-size: 10.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted-dim);
}

.empty-copy {
  margin: 0 auto 26px;
  max-width: 410px;
  color: var(--muted);
  font-size: 14px;
}

.suggestions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  text-align: left;
}

.suggestions button {
  border: 1px solid var(--glass-edge);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.42));
  border-radius: 14px;
  padding: 12px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  box-shadow: var(--shadow-sm), var(--inner-top);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease, background 0.16s ease;
}

.suggestions button:hover {
  border-color: rgba(109, 155, 255, 0.6);
  background: linear-gradient(180deg, #ffffff, rgba(242, 246, 255, 0.9));
  box-shadow: var(--shadow-md), var(--inner-top);
  transform: translateY(-1px);
}

.suggestions strong {
  font-size: 13px;
  font-weight: 620;
  color: #16203a;
}

.suggestions span {
  font-size: 12.5px;
  color: var(--muted-dim);
}

/* ------------------------------------------------------------------ home */

.home {
  width: min(880px, 100%);
  margin: 0 auto;
  padding: 26px 22px 46px;
}

.home-hero {
  text-align: center;
  padding: 14px 0 6px;
}

.eyebrow {
  font-size: 10.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted-dim);
}

.home-hero h2 {
  margin: 10px 0 6px;
  font-size: clamp(25px, 3.6vw, 33px);
  line-height: 1.15;
  letter-spacing: -0.035em;
  font-weight: 680;
  color: #111a2c;
}

.home-hero > p {
  margin: 0 auto 20px;
  max-width: 470px;
  color: var(--muted);
  font-size: 14px;
}

.home-search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(620px, 100%);
  margin: 0 auto;
  padding: 8px 8px 8px 16px;
  border-radius: 16px;
  border: 1px solid var(--glass-edge);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.62));
  box-shadow: var(--shadow-lg), var(--inner-top);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.home-search:focus-within {
  border-color: rgba(109, 155, 255, 0.65);
  box-shadow: 0 0 0 4px rgba(109, 155, 255, 0.16), var(--shadow-lg), var(--inner-top);
}

.home-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 14.5px;
  padding: 7px 0;
}

.home-search input::placeholder {
  color: #8d97ab;
}

.home-search button {
  flex: none;
  padding: 9px 18px;
  border-radius: 11px;
  border: 1px solid rgba(38, 76, 190, 0.32);
  background: linear-gradient(180deg, #7aa5ff, #4f7ff2);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(79, 127, 242, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transition: filter 0.16s ease, transform 0.16s ease;
}

.home-search button:hover {
  filter: brightness(1.05);
}

.home-search button:active {
  transform: scale(0.98);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}

.chip {
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--glass-edge);
  background: rgba(255, 255, 255, 0.5);
  color: var(--text-soft);
  font-size: 12.5px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.chip:hover {
  background: #ffffff;
  border-color: rgba(109, 155, 255, 0.55);
  color: var(--accent-ink);
}

.section {
  margin-top: 34px;
}

.section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.section-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 640;
  letter-spacing: -0.02em;
  color: #16203a;
}

.count {
  font-size: 11.5px;
  color: var(--muted-dim);
}

.grow {
  flex: 1;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.filter {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--glass-edge);
  background: rgba(255, 255, 255, 0.45);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.filter:hover {
  background: #ffffff;
  color: var(--text);
}

.filter.active {
  background: var(--accent-soft);
  border-color: rgba(109, 155, 255, 0.5);
  color: var(--accent-ink);
  font-weight: 560;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(212px, 1fr));
  gap: 10px;
}

.template {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--glass-edge);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.42));
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow-sm), var(--inner-top);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease, background 0.16s ease;
}

.template:hover {
  border-color: rgba(109, 155, 255, 0.6);
  background: linear-gradient(180deg, #ffffff, rgba(242, 246, 255, 0.9));
  box-shadow: var(--shadow-md), var(--inner-top);
  transform: translateY(-1px);
}

.ticon {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: rgba(109, 155, 255, 0.14);
  border: 1px solid rgba(109, 155, 255, 0.22);
  color: var(--accent-ink);
  font-size: 13px;
}

.ttext {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.ttext strong {
  font-size: 13px;
  font-weight: 620;
  color: #16203a;
}

.ttext > span {
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted-dim);
}

.template-empty {
  margin: 0;
  padding: 14px 2px;
  font-size: 13px;
  color: var(--muted-dim);
}

.recent {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}

.recent-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--glass-edge);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.42));
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow-sm), var(--inner-top);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.recent-card:hover {
  border-color: rgba(109, 155, 255, 0.55);
  box-shadow: var(--shadow-md), var(--inner-top);
  transform: translateY(-1px);
}

.recent-card strong {
  font-size: 13px;
  font-weight: 600;
  color: #16203a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-card span {
  font-size: 11.5px;
  color: var(--muted-dim);
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
}

.feature {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--glass-edge);
  background: rgba(255, 255, 255, 0.4);
  box-shadow: var(--shadow-sm), var(--inner-top);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.feature h4 {
  margin: 0 0 3px;
  font-size: 13px;
  font-weight: 620;
  color: #16203a;
}

.feature p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted-dim);
}

.home-foot {
  margin: 34px 0 0;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--muted-dim);
}

.chat-view {
  padding-bottom: 6px;
}

/* ------------------------------------------------------------- composer */

.composer-wrap {
  display: flex;
  flex-direction: column;
}

.key-banner {
  width: min(780px, calc(100% - 44px));
  margin: 0 auto 10px;
  padding: 10px 13px;
  border-radius: 12px;
  border: 1px solid rgba(227, 154, 31, 0.32);
  background: rgba(255, 248, 233, 0.78);
  color: #7a5410;
  font-size: 12.5px;
  line-height: 1.55;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.key-banner strong {
  color: #6a4708;
}

.key-banner code {
  font-family: var(--mono);
  font-size: 11.5px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(227, 154, 31, 0.22);
  padding: 1px 5px;
  border-radius: 5px;
}

.composer {
  width: min(780px, calc(100% - 44px));
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 9px 9px 9px 15px;
  border-radius: var(--radius);
  border: 1px solid var(--glass-edge);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0.6));
  box-shadow: var(--shadow-lg), var(--inner-top);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.composer:focus-within {
  border-color: rgba(109, 155, 255, 0.65);
  box-shadow: 0 0 0 4px rgba(109, 155, 255, 0.16), var(--shadow-lg), var(--inner-top);
}

.composer textarea {
  flex: 1;
  min-height: 26px;
  max-height: 190px;
  padding: 5px 0;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text);
}

.composer textarea::placeholder {
  color: #8d97ab;
}

.send,
.stop {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: filter 0.16s ease, transform 0.16s ease, opacity 0.16s ease, box-shadow 0.16s ease;
}

.send {
  background: linear-gradient(180deg, #7aa5ff, #4f7ff2);
  border-color: rgba(38, 76, 190, 0.32);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(79, 127, 242, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

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

.stop {
  background: rgba(255, 255, 255, 0.9);
  border-color: var(--glass-edge);
  color: var(--text-soft);
  box-shadow: var(--shadow-sm), var(--inner-top);
}

.stop svg {
  width: 13px;
  height: 13px;
  fill: currentColor;
  stroke: none;
}

.send:hover {
  filter: brightness(1.04);
}

.stop:hover {
  background: #ffffff;
  box-shadow: var(--shadow-md), var(--inner-top);
}

.send:active,
.stop:active {
  transform: scale(0.96);
}

.send:disabled {
  opacity: 0.4;
  cursor: default;
  box-shadow: none;
}

.hint {
  width: min(780px, calc(100% - 44px));
  margin: 9px auto 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
  color: var(--muted-dim);
}

.hint-brand {
  letter-spacing: 0.02em;
}

/* ---------------------------------------------------------------- modal */

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(28, 42, 80, 0.16);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fade 0.16s ease;
}

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

.modal-card {
  width: min(520px, 100%);
  max-height: 88dvh;
  overflow-y: auto;
  padding: 18px 20px 20px;
  border-radius: 20px;
  border: 1px solid var(--glass-edge);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.86));
  box-shadow: 0 30px 80px rgba(48, 66, 120, 0.22), var(--inner-top);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  animation: pop 0.2s ease;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: #141c2e;
}

.field,
.field-row {
  margin-bottom: 16px;
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--hairline);
}

.field label,
.field-row label {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
}

.field-row label {
  margin-bottom: 2px;
}

.field textarea,
.field input[type="number"] {
  width: 100%;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--glass-edge);
  background: rgba(255, 255, 255, 0.8);
  font-size: 13px;
  color: var(--text);
  outline: 0;
  resize: vertical;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.field textarea:focus,
.field input[type="number"]:focus {
  border-color: rgba(109, 155, 255, 0.6);
  box-shadow: 0 0 0 3px rgba(109, 155, 255, 0.14);
}

.field input[type="range"] {
  width: 100%;
  accent-color: var(--accent-ink);
}

.desc {
  margin: 5px 0 0;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted-dim);
}

.val {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--accent-ink);
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--hairline);
}

.btn {
  padding: 8px 13px;
  border-radius: 10px;
  border: 1px solid var(--glass-edge);
  background: rgba(255, 255, 255, 0.8);
  color: var(--text-soft);
  font-size: 12.5px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.btn:hover {
  background: #ffffff;
  border-color: rgba(109, 155, 255, 0.45);
  color: var(--accent-ink);
}

.btn.danger {
  color: var(--danger);
  border-color: rgba(201, 58, 74, 0.28);
  background: rgba(255, 240, 242, 0.75);
}

.btn.danger:hover {
  background: rgba(255, 228, 232, 0.95);
  border-color: rgba(201, 58, 74, 0.45);
  color: #a92b39;
}

.modal-foot {
  margin: 12px 0 0;
  text-align: center;
  font-size: 11px;
  color: var(--muted-dim);
}

/* ---------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 80;
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(24, 33, 55, 0.9);
  color: #ffffff;
  font-size: 12.5px;
  box-shadow: 0 12px 30px rgba(20, 30, 55, 0.25);
  opacity: 0;
  transform: translateX(-50%) translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.mode {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border-radius: 11px;
  border: 1px solid var(--glass-edge);
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 550;
  cursor: pointer;
  box-shadow: var(--shadow-sm), var(--inner-top);
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

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

.mode:hover {
  background: #ffffff;
  color: var(--accent-ink);
  border-color: rgba(109, 155, 255, 0.45);
}

.mode.on {
  background: linear-gradient(180deg, rgba(109, 155, 255, 0.22), rgba(109, 155, 255, 0.12));
  border-color: rgba(109, 155, 255, 0.6);
  color: var(--accent-ink);
  box-shadow: 0 0 0 3px rgba(109, 155, 255, 0.14), var(--shadow-sm), var(--inner-top);
}

.steps {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 0;
}

.steps .step {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid rgba(109, 155, 255, 0.28);
  background: rgba(255, 255, 255, 0.6);
  font-size: 11.5px;
  color: var(--muted);
  box-shadow: var(--shadow-sm);
}

.steps .step:last-child {
  color: var(--accent-ink);
  border-color: rgba(109, 155, 255, 0.55);
  background: rgba(255, 255, 255, 0.85);
}

.steps .step:last-child::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.sources {
  list-style: none;
  margin: 2px 0 0;
  padding: 10px 12px;
  display: grid;
  gap: 2px;
  border-radius: 12px;
  border: 1px solid var(--glass-edge);
  background: rgba(255, 255, 255, 0.45);
  box-shadow: var(--shadow-sm), var(--inner-top);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.sources li {
  margin: 0;
}

.sources a {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-soft);
  font-size: 12.5px;
  transition: background 0.14s ease, color 0.14s ease;
}

.sources a:hover {
  background: rgba(255, 255, 255, 0.9);
  color: var(--accent-ink);
}

.sources .n {
  flex: none;
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border-radius: 6px;
  background: rgba(109, 155, 255, 0.16);
  color: var(--accent-ink);
  font-size: 10.5px;
  font-weight: 650;
}

.sources .t {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sources .d {
  flex: none;
  font-size: 11px;
  color: var(--muted-dim);
}

.body a.cite {
  display: inline-grid;
  place-items: center;
  min-width: 15px;
  height: 15px;
  margin: 0 1px;
  padding: 0 3px;
  border-radius: 5px;
  border: 0;
  background: rgba(109, 155, 255, 0.18);
  color: var(--accent-ink);
  font-size: 10px;
  font-weight: 650;
  line-height: 1;
  vertical-align: 1px;
  text-decoration: none;
}

.body a.cite:hover {
  background: rgba(109, 155, 255, 0.34);
}

@media (max-width: 520px) {
  .mode span {
    display: none;
  }

  .mode {
    padding: 0 10px;
  }
}

/* ------------------------------------------------------------ responsive */

@media (max-width: 860px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 278px;
    z-index: 30;
    transform: translateX(-102%);
    transition: transform 0.24s ease;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.74));
    box-shadow: 24px 0 70px rgba(48, 66, 120, 0.18);
  }

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

  body.sidebar-open .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 20;
    background: rgba(28, 42, 80, 0.18);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
  }

  .chats-btn {
    display: grid;
  }

  .messages,
  .empty {
    padding-left: 16px;
    padding-right: 16px;
  }

  .home {
    padding-left: 16px;
    padding-right: 16px;
  }

  .composer,
  .hint,
  .key-banner {
    width: calc(100% - 28px);
  }

  .hint-brand {
    display: none;
  }

  .switch-label {
    display: none;
  }

  .search-inline {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .suggestions {
    grid-template-columns: minmax(0, 1fr);
  }

  .template-grid,
  .recent,
  .features {
    grid-template-columns: minmax(0, 1fr);
  }

  .nav-btn {
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }

  .scroll {
    scroll-behavior: auto;
  }
}
