:root {
  color-scheme: light;
  --ink: #1b2029;
  --ink-soft: #5f6774;
  --ink-faint: #8b929e;
  --paper: #f4f1ea;
  --paper-raised: #fbfaf7;
  --paper-deep: #e9e4da;
  --line: rgba(28, 34, 44, 0.11);
  --line-strong: rgba(28, 34, 44, 0.18);
  --accent: #416fd1;
  --accent-soft: #e7edfc;
  --accent-bright: #8cb7ff;
  --navy: #171b23;
  --navy-soft: #242b37;
  --success: #2d8b65;
  --warning: #b56c26;
  --danger: #b54747;
  --shadow: 0 22px 60px rgba(27, 32, 41, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --sidebar-width: 330px;
  --font-sans: "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "SFMono-Regular", "SF Mono", "Cascadia Code", "Cascadia Mono", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 10%, rgba(255, 255, 255, 0.86), transparent 32%),
    radial-gradient(circle at 76% 92%, rgba(208, 218, 239, 0.34), transparent 38%),
    var(--paper);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(65, 111, 209, 0.28);
  outline-offset: 2px;
}

svg {
  display: block;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  width: 100vw;
  height: 100dvh;
}

.sidebar {
  position: relative;
  z-index: 20;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding:
    max(22px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(22px, env(safe-area-inset-left));
  color: #f8f7f4;
  background:
    radial-gradient(circle at 8% 0%, rgba(140, 183, 255, 0.17), transparent 35%),
    linear-gradient(150deg, #1c222c, #12161d 68%);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 52px;
}

.brand h1 {
  margin: 1px 0 0;
  font-size: 23px;
  font-weight: 670;
  letter-spacing: 0.04em;
}

.eyebrow {
  margin: 0;
  color: rgba(255, 255, 255, 0.45);
  font-size: 9px;
  font-weight: 760;
  letter-spacing: 0.22em;
}

.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.07);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.brand-mark span {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-bright);
  box-shadow: 0 0 16px rgba(140, 183, 255, 0.65);
}

.brand-mark span:nth-child(1) {
  transform: translateX(-11px);
}

.brand-mark span:nth-child(3) {
  transform: translateX(11px);
}

.brand-mark.large {
  width: 62px;
  height: 62px;
  margin-bottom: 22px;
  border-radius: 20px;
}

.brand-mark.large span {
  width: 9px;
  height: 9px;
}

.brand-mark.large span:nth-child(1) {
  transform: translateX(-16px);
}

.brand-mark.large span:nth-child(3) {
  transform: translateX(16px);
}

.connection-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  margin: 22px 0 18px;
  padding: 7px 11px;
  color: rgba(255, 255, 255, 0.67);
  font-size: 12px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
}

.connection-dot,
.live-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #7cd9ae;
  box-shadow: 0 0 0 4px rgba(124, 217, 174, 0.1);
}

.connection-pill.offline .connection-dot {
  background: #d38a79;
  box-shadow: 0 0 0 4px rgba(211, 138, 121, 0.1);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 43px;
  padding: 0 13px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.06);
  transition: border-color 160ms ease, background 160ms ease;
}

.search-box:focus-within {
  border-color: rgba(140, 183, 255, 0.45);
  background: rgba(255, 255, 255, 0.085);
}

.search-box svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: rgba(255, 255, 255, 0.42);
  stroke-width: 1.8;
  stroke-linecap: round;
}

.search-box input {
  width: 100%;
  min-width: 0;
  color: #fff;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 14px;
}

.search-box input::placeholder {
  color: rgba(255, 255, 255, 0.34);
}

.search-box input::-webkit-search-cancel-button {
  filter: invert(1);
  opacity: 0.45;
}

.list-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 16px 3px 8px;
  color: rgba(255, 255, 255, 0.42);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.04em;
}

.archive-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

.archive-toggle input {
  width: 13px;
  height: 13px;
  margin: 0;
  accent-color: var(--accent-bright);
}

.thread-list {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  margin: 0 -7px;
  padding: 2px 7px 18px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.thread-list::-webkit-scrollbar,
.message-viewport::-webkit-scrollbar {
  display: none;
}

.thread-card {
  position: relative;
  display: block;
  width: 100%;
  padding: 12px 12px 11px;
  text-align: left;
  color: inherit;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.thread-card:hover {
  background: rgba(255, 255, 255, 0.045);
}

.thread-card:active {
  transform: scale(0.994);
}

.thread-card.active {
  border-color: rgba(140, 183, 255, 0.16);
  background: linear-gradient(135deg, rgba(140, 183, 255, 0.14), rgba(255, 255, 255, 0.055));
}

.thread-card.active::before {
  position: absolute;
  top: 17px;
  bottom: 17px;
  left: -8px;
  width: 3px;
  border-radius: 3px;
  background: var(--accent-bright);
  content: "";
}

.thread-title {
  display: -webkit-box;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.9);
  font-size: 13.5px;
  font-weight: 620;
  line-height: 1.42;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.thread-preview {
  display: -webkit-box;
  margin-top: 5px;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.38);
  font-size: 11.5px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
}

.thread-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 7px;
  color: rgba(255, 255, 255, 0.3);
  font-size: 10.5px;
}

.thread-row time {
  white-space: nowrap;
}

.thread-row .path {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.archived-tag {
  margin-left: auto;
  padding: 2px 5px;
  color: rgba(255, 255, 255, 0.47);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 5px;
}

.thread-list-empty {
  padding: 44px 18px;
  color: rgba(255, 255, 255, 0.38);
  text-align: center;
  font-size: 13px;
  line-height: 1.6;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 7px;
  padding: 14px 3px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.075);
}

.sidebar-footer div {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sidebar-footer strong {
  color: rgba(255, 255, 255, 0.58);
  font-size: 10.5px;
  font-weight: 620;
}

.sidebar-footer span {
  color: rgba(255, 255, 255, 0.28);
  font-size: 9.5px;
}

.logout-link {
  color: rgba(255, 255, 255, 0.4);
  font-size: 10.5px;
  text-decoration: none;
}

.logout-link:hover {
  color: rgba(255, 255, 255, 0.72);
}

.main {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding:
    max(16px, env(safe-area-inset-top))
    max(28px, env(safe-area-inset-right))
    0
    max(30px, env(safe-area-inset-left));
}

.topbar {
  display: flex;
  align-items: center;
  gap: 15px;
  width: 100%;
  max-width: 1020px;
  min-height: 56px;
  margin: 0 auto;
}

.title-block {
  min-width: 0;
  flex: 1;
}

.title-block h2 {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: clamp(19px, 2.2vw, 25px);
  font-weight: 670;
  letter-spacing: -0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.title-block p {
  margin: 4px 0 0;
  overflow: hidden;
  color: var(--ink-faint);
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.icon-button,
.export-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(251, 250, 247, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}

.icon-button {
  width: 40px;
  padding: 0;
}

.icon-button:hover,
.export-button:hover {
  color: var(--ink);
  border-color: var(--line-strong);
  background: var(--paper-raised);
}

.icon-button svg,
.export-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.export-button {
  gap: 7px;
  padding: 0 13px;
  font-size: 12.5px;
  font-weight: 620;
  text-decoration: none;
}

.menu-button,
.close-sidebar {
  display: none;
}

.reading-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1020px;
  min-height: 56px;
  margin: 5px auto 0;
  border-bottom: 1px solid var(--line);
}

.segmented-control {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border-radius: 11px;
  background: rgba(28, 34, 44, 0.055);
}

.segment {
  padding: 7px 14px;
  color: var(--ink-faint);
  font-size: 12px;
  font-weight: 620;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}

.segment.active {
  color: var(--ink);
  background: var(--paper-raised);
  box-shadow: 0 2px 8px rgba(28, 34, 44, 0.08);
}

.live-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-faint);
  font-size: 11px;
}

.live-status.stale .live-dot {
  background: #d18a5a;
  box-shadow: 0 0 0 4px rgba(209, 138, 90, 0.1);
  animation: breathe 1.4s ease-in-out infinite;
}

.live-status.offline .live-dot {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(181, 71, 71, 0.1);
}

@keyframes breathe {
  50% {
    opacity: 0.35;
  }
}

.message-viewport {
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  scroll-behavior: smooth;
}

.message-column {
  width: 100%;
  max-width: 920px;
  min-height: 100%;
  margin: 0 auto;
  padding: 26px 20px 38px;
}

.composer {
  width: 100%;
  max-width: 920px;
  flex: 0 0 auto;
  margin: 0 auto;
  padding: 8px 20px max(12px, calc(env(safe-area-inset-bottom) + 8px));
}

.composer-inner {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.composer-status {
  min-height: 15px;
  padding: 0 5px;
  color: var(--ink-faint);
  font-size: 10px;
  line-height: 1.4;
}

.composer-status.busy {
  color: var(--accent);
}

.composer-status.error {
  color: var(--danger);
}

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 7px 7px 7px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 19px;
  background: rgba(251, 250, 247, 0.94);
  box-shadow: 0 10px 34px rgba(27, 32, 41, 0.1);
  backdrop-filter: blur(18px);
}

.composer-row:focus-within {
  border-color: rgba(65, 111, 209, 0.42);
  box-shadow: 0 10px 34px rgba(27, 32, 41, 0.12), 0 0 0 3px rgba(65, 111, 209, 0.09);
}

.composer textarea {
  width: 100%;
  min-height: 38px;
  max-height: 132px;
  field-sizing: content;
  padding: 9px 0 7px;
  overflow-y: auto;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  line-height: 1.5;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
}

.composer textarea::placeholder {
  color: var(--ink-faint);
}

.composer textarea:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.send-button {
  display: grid;
  place-items: center;
  width: 39px;
  height: 39px;
  flex: 0 0 auto;
  padding: 0;
  color: #fff;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(145deg, #547fda, #345fbd);
  box-shadow: 0 5px 16px rgba(65, 111, 209, 0.26);
  cursor: pointer;
  transition: transform 150ms ease, opacity 150ms ease;
}

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

.send-button:disabled {
  color: var(--ink-faint);
  background: rgba(28, 34, 44, 0.08);
  box-shadow: none;
  cursor: not-allowed;
}

.send-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.message.pending {
  opacity: 0.78;
}

.message.pending .message-phase {
  color: var(--accent);
  border-color: rgba(65, 111, 209, 0.18);
  background: rgba(65, 111, 209, 0.06);
}

.message.pending.failed .message-phase {
  color: var(--danger);
  border-color: rgba(181, 71, 71, 0.18);
  background: rgba(181, 71, 71, 0.06);
}

.load-older {
  display: flex;
  justify-content: center;
  margin: 0 0 26px;
}

.load-older button {
  padding: 8px 14px;
  color: var(--ink-soft);
  font-size: 11.5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(251, 250, 247, 0.72);
  cursor: pointer;
}

.load-older button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.message {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  margin: 0 0 30px;
  animation: enter 240ms ease both;
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
}

.avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 750;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper-raised);
}

.message.user .avatar {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(145deg, #527cda, #345ebd);
}

.message.assistant .avatar {
  color: #dce9ff;
  border-color: rgba(255, 255, 255, 0.08);
  background: var(--navy);
}

.message-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 25px;
  margin-bottom: 5px;
}

.message-author {
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 680;
}

.message-time,
.message-phase {
  color: var(--ink-faint);
  font-size: 10px;
}

.message-phase {
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
}

.copy-message {
  margin-left: auto;
  padding: 4px 7px;
  color: var(--ink-faint);
  font-size: 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  opacity: 0;
  transition: opacity 140ms ease, background 140ms ease;
}

.message:hover .copy-message,
.copy-message:focus-visible {
  opacity: 1;
}

.copy-message:hover {
  color: var(--ink);
  background: rgba(28, 34, 44, 0.055);
}

.message-body {
  min-width: 0;
}

.message.user .bubble {
  width: fit-content;
  max-width: 100%;
  padding: 12px 15px;
  color: #202731;
  border: 1px solid rgba(65, 111, 209, 0.1);
  border-radius: 6px 17px 17px;
  background: linear-gradient(145deg, #edf2ff, #e5ecfb);
}

.prose {
  color: var(--ink);
  font-size: clamp(14.5px, 1.38vw, 16px);
  line-height: 1.76;
  overflow-wrap: anywhere;
}

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

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

.prose p {
  margin: 0 0 0.85em;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4 {
  margin: 1.3em 0 0.55em;
  color: #141922;
  font-weight: 700;
  line-height: 1.35;
}

.prose h1 {
  font-size: 1.45em;
}

.prose h2 {
  font-size: 1.25em;
}

.prose h3,
.prose h4 {
  font-size: 1.08em;
}

.prose ul,
.prose ol {
  margin: 0.55em 0 0.9em;
  padding-left: 1.35em;
}

.prose li {
  margin: 0.22em 0;
  padding-left: 0.16em;
}

.prose blockquote {
  margin: 1em 0;
  padding: 2px 0 2px 14px;
  color: var(--ink-soft);
  border-left: 3px solid var(--accent-bright);
}

.prose code {
  padding: 0.15em 0.34em;
  font-family: var(--font-mono);
  font-size: 0.88em;
  border: 1px solid rgba(28, 34, 44, 0.08);
  border-radius: 5px;
  background: rgba(28, 34, 44, 0.055);
}

.prose pre {
  margin: 0.9em 0 1.05em;
  padding: 14px 16px;
  overflow: auto;
  color: #e9eef8;
  border-radius: 12px;
  background: #1a2029;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  -webkit-overflow-scrolling: touch;
}

.prose pre code {
  padding: 0;
  color: inherit;
  font-size: 12.5px;
  line-height: 1.55;
  border: 0;
  background: transparent;
  white-space: pre;
}

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

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

.markdown-table-wrap {
  margin: 1em 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.prose table {
  width: 100%;
  font-size: 0.88em;
  border-collapse: collapse;
}

.prose th,
.prose td {
  padding: 8px 10px;
  text-align: left;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.prose th {
  color: var(--ink);
  font-weight: 650;
  background: rgba(28, 34, 44, 0.045);
}

.prose th:last-child,
.prose td:last-child {
  border-right: 0;
}

.prose tr:last-child td {
  border-bottom: 0;
}

.tool-event {
  margin: 0 0 10px 46px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(251, 250, 247, 0.6);
  animation: enter 200ms ease both;
}

.tool-event summary {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 8px 12px;
  color: var(--ink-soft);
  font-size: 11.5px;
  list-style: none;
  cursor: pointer;
}

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

.tool-icon {
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  flex: 0 0 auto;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper-raised);
}

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

.status-badge {
  margin-left: auto;
  padding: 2px 6px;
  color: var(--success);
  font-size: 9px;
  border: 1px solid rgba(45, 139, 101, 0.18);
  border-radius: 999px;
  background: rgba(45, 139, 101, 0.06);
}

.status-badge.failed,
.status-badge.error {
  color: var(--danger);
  border-color: rgba(181, 71, 71, 0.18);
  background: rgba(181, 71, 71, 0.06);
}

.status-badge.running,
.status-badge.in_progress {
  color: var(--warning);
  border-color: rgba(181, 108, 38, 0.18);
  background: rgba(181, 108, 38, 0.06);
}

.tool-content {
  padding: 0 12px 12px;
  border-top: 1px solid var(--line);
}

.tool-content code,
.tool-content pre {
  display: block;
  margin: 11px 0 0;
  padding: 12px 13px;
  overflow: auto;
  color: #dfe6f1;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border-radius: 9px;
  background: #1a2029;
}

.raw-button {
  margin-top: 10px;
  padding: 6px 9px;
  color: var(--ink-soft);
  font-size: 10.5px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper-raised);
  cursor: pointer;
}

.raw-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.system-event {
  margin: 0 0 12px 46px;
  padding: 10px 12px;
  color: var(--ink-faint);
  font-size: 10.5px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
}

.empty-state {
  display: flex;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  min-height: 58vh;
  color: var(--ink-faint);
  text-align: center;
}

.empty-state h3 {
  margin: 21px 0 5px;
  color: var(--ink-soft);
  font-size: 16px;
}

.empty-state p {
  margin: 0;
  font-size: 12px;
}

.empty-orbit {
  position: relative;
  width: 62px;
  height: 62px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  animation: rotate 3s linear infinite;
}

.empty-orbit::before,
.empty-orbit::after {
  position: absolute;
  border-radius: 50%;
  content: "";
}

.empty-orbit::before {
  inset: 13px;
  border: 1px solid var(--line);
}

.empty-orbit::after {
  top: 7px;
  left: 27px;
  width: 9px;
  height: 9px;
  background: var(--accent-bright);
  box-shadow: 0 0 16px rgba(140, 183, 255, 0.8);
}

@keyframes rotate {
  to {
    transform: rotate(360deg);
  }
}

.jump-bottom {
  position: absolute;
  right: max(32px, calc(env(safe-area-inset-right) + 20px));
  bottom: max(102px, calc(env(safe-area-inset-bottom) + 92px));
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(251, 250, 247, 0.92);
  box-shadow: 0 10px 30px rgba(27, 32, 41, 0.14);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.jump-bottom.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.jump-bottom svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.toast {
  position: fixed;
  z-index: 80;
  bottom: max(24px, calc(env(safe-area-inset-bottom) + 18px));
  left: 50%;
  padding: 9px 14px;
  color: #f8f7f4;
  font-size: 11.5px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(23, 27, 35, 0.92);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.clipboard-helper {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.sidebar-scrim {
  display: none;
}

.login-body {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 28px;
  overflow: auto;
  background:
    radial-gradient(circle at 18% 14%, rgba(140, 183, 255, 0.14), transparent 34%),
    linear-gradient(150deg, #202734, #11151c 72%);
}

.login-card {
  width: min(100%, 420px);
  padding: 38px;
  color: #f8f7f4;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.055);
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(20px);
}

.login-card .eyebrow {
  color: rgba(255, 255, 255, 0.42);
}

.login-card h1 {
  margin: 8px 0 10px;
  font-size: 28px;
  letter-spacing: -0.02em;
}

.login-copy {
  margin: 0 0 28px;
  color: rgba(255, 255, 255, 0.48);
  font-size: 13px;
  line-height: 1.7;
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 11px;
  font-weight: 600;
}

.login-card input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  outline: 0;
  background: rgba(0, 0, 0, 0.18);
  font-size: 15px;
}

.login-card input:focus {
  border-color: rgba(140, 183, 255, 0.55);
}

.login-card button {
  width: 100%;
  height: 48px;
  margin-top: 14px;
  color: #111722;
  font-weight: 680;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #a9c9ff, #78a9ff);
  cursor: pointer;
}

.login-card button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.login-error {
  min-height: 18px;
  margin: 10px 0 0;
  color: #f0a49a;
  font-size: 11px;
}

@media (hover: none) {
  .copy-message {
    opacity: 1;
  }
}

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

  .main {
    padding-right: max(18px, env(safe-area-inset-right));
    padding-left: max(18px, env(safe-area-inset-left));
  }

  .message-column {
    padding-right: 6px;
    padding-left: 6px;
  }

  .tool-event,
  .system-event {
    margin-left: 0;
  }
}

@media (max-width: 720px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, 340px);
    transform: translateX(-102%);
    transition: transform 220ms cubic-bezier(0.2, 0.75, 0.2, 1);
  }

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

  .sidebar-scrim {
    position: fixed;
    z-index: 15;
    inset: 0;
    display: block;
    border: 0;
    background: rgba(16, 20, 27, 0.32);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
  }

  body.sidebar-open .sidebar-scrim {
    opacity: 1;
    pointer-events: auto;
  }

  .menu-button,
  .close-sidebar {
    display: inline-flex;
  }

  .close-sidebar {
    margin-left: auto;
    color: rgba(255, 255, 255, 0.55);
    border-color: rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.045);
  }

  .main {
    height: 100dvh;
    padding-top: max(10px, env(safe-area-inset-top));
  }

  .topbar {
    min-height: 48px;
    gap: 9px;
  }

  .title-block h2 {
    font-size: 17px;
  }

  .title-block p {
    max-width: 54vw;
    font-size: 10px;
  }

  .top-actions {
    gap: 5px;
  }

  .top-actions .icon-button {
    display: none;
  }

  .export-button {
    width: 40px;
    padding: 0;
  }

  .export-button span {
    display: none;
  }

  .reading-toolbar {
    min-height: 50px;
  }

  .segment {
    padding: 7px 11px;
  }

  .message-column {
    padding: 18px 5px 20px;
  }

  .composer {
    padding-right: 5px;
    padding-left: 5px;
  }

  .composer textarea {
    font-size: 16px;
  }

  .message {
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 9px;
    margin-bottom: 25px;
  }

  .avatar {
    width: 29px;
    height: 29px;
    border-radius: 9px;
  }

  .prose {
    font-size: 14.5px;
    line-height: 1.72;
  }

  .message.user .bubble {
    padding: 11px 13px;
  }

  .login-card {
    padding: 28px 23px;
    border-radius: 24px;
  }
}

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

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --ink: #eef2f8;
    --ink-soft: #b3bdcb;
    --ink-faint: #7f8a99;
    --paper: #11151b;
    --paper-raised: #1a2028;
    --paper-deep: #202730;
    --line: rgba(255, 255, 255, 0.09);
    --line-strong: rgba(255, 255, 255, 0.15);
    --accent: #8cb7ff;
    --accent-soft: rgba(140, 183, 255, 0.12);
  }

  body {
    background:
      radial-gradient(circle at 16% 8%, rgba(62, 87, 122, 0.18), transparent 34%),
      radial-gradient(circle at 80% 92%, rgba(43, 68, 112, 0.18), transparent 38%),
      var(--paper);
  }

  .message.user .bubble {
    color: #e7edfb;
    border-color: rgba(140, 183, 255, 0.13);
    background: linear-gradient(145deg, #202b3e, #1a2332);
  }

  .prose h1,
  .prose h2,
  .prose h3,
  .prose h4 {
    color: #f3f6fb;
  }

  .segment.active,
  .icon-button,
  .export-button,
  .load-older button,
  .jump-bottom,
  .tool-event,
  .raw-button {
    background-color: rgba(26, 32, 40, 0.9);
  }

  .segmented-control {
    background: rgba(255, 255, 255, 0.045);
  }

  .composer-row {
    background: rgba(26, 32, 40, 0.94);
  }
}
