:root {
  color-scheme: light;
  --page: oklch(0.974 0.001 260);
  --surface: oklch(0.996 0.001 260);
  --surface-muted: oklch(0.944 0.002 260);
  --surface-hover: oklch(0.922 0.002 260);
  --ink: oklch(0.10 0.003 260);
  --ink-muted: oklch(0.42 0.004 260);
  --danger: oklch(0.46 0.14 28);
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-smooth: cubic-bezier(0.22, 1, 0.36, 1);
  font-family: "SF Pro Text", "SF Pro Display", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", ui-sans-serif, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  min-height: 100%;
  margin: 0;
  background: var(--page);
  color: var(--ink);
  overflow: hidden;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

button,
textarea,
input {
  font: inherit;
}

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

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.ui-icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.app-shell {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
  padding: 0 clamp(var(--space-md), 4vw, var(--space-2xl));
  background: color-mix(in oklch, var(--page) 92%, transparent);
  backdrop-filter: blur(18px);
}

h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
  font-weight: 650;
  letter-spacing: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.icon-button,
.send-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-muted);
}

.icon-button,
.send-button {
  cursor: pointer;
  transition: background 160ms var(--ease-smooth), color 160ms var(--ease-smooth), transform 160ms var(--ease-smooth), opacity 160ms var(--ease-smooth);
}

.icon-button:hover,
.icon-button:focus-visible,
.send-button:hover:not(:disabled) {
  background: var(--surface-muted);
  color: var(--ink);
}

.icon-button:focus-visible,
.send-button:focus-visible,
.message-action:focus-visible,
.jump-bottom:focus-visible {
  outline: none;
  background: var(--surface-muted);
  color: var(--ink);
}

.icon-button:active,
.send-button:active:not(:disabled) {
  transform: scale(0.96);
}

.icon-button:disabled {
  opacity: 0.28;
  cursor: default;
}

.icon-button.is-active {
  background: var(--ink);
  color: var(--surface);
}

.icon-button.is-active:hover,
.icon-button.is-active:focus-visible {
  background: oklch(0.22 0.003 260);
  color: var(--surface);
}

.send-button {
  background: var(--ink);
  color: var(--surface);
}

.send-button:hover:not(:disabled) {
  background: oklch(0.22 0.003 260);
  color: var(--surface);
}

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

.status-streaming .status-icon {
  animation: spin 1s linear infinite;
}

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

.lock-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--space-lg);
}

.login-form {
  width: min(420px, 100%);
  display: grid;
  gap: var(--space-lg);
  animation: empty-enter 420ms var(--ease-out) both;
}

.login-form h1 {
  font-size: clamp(40px, 9vw, 68px);
  line-height: 1.02;
  font-weight: 680;
}

.login-composer {
  min-height: 58px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 2px;
  padding: 8px;
  border-radius: 26px;
  background: var(--surface);
}

input {
  width: 100%;
  border: 0;
  border-radius: 18px;
  outline: none;
  background: transparent;
  color: var(--ink);
  padding: 10px 12px;
  line-height: 1.55;
}

input::placeholder {
  color: var(--ink-muted);
}

.login-error {
  margin: calc(-1 * var(--space-sm)) 0 0;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.4;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  z-index: 14;
  max-width: min(360px, calc(100vw - 32px));
  transform: translate(-50%, 8px);
  padding: 9px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--surface);
  font-size: 14px;
  line-height: 1.45;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms var(--ease-smooth), transform 180ms var(--ease-smooth);
}

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

.chat-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
}

.messages {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  padding: clamp(var(--space-xl), 8vh, 96px) clamp(var(--space-md), 4vw, 72px) 132px;
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

.messages::-webkit-scrollbar {
  width: 8px;
}

.messages::-webkit-scrollbar-thumb {
  background: oklch(0.78 0.002 260);
  border-radius: 999px;
}

.message {
  width: min(760px, 100%);
  display: grid;
  gap: 8px;
  animation: message-enter 320ms var(--ease-out) both;
}

.message.user {
  align-self: center;
}

.message.assistant {
  align-self: center;
}

.bubble {
  line-height: 1.72;
  font-size: 15px;
  letter-spacing: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.user .bubble {
  justify-self: end;
  max-width: min(620px, 92%);
  padding: 10px 14px;
  border-radius: 18px;
  background: oklch(0.918 0.002 260);
  color: var(--ink);
}

.message.assistant .bubble {
  max-width: 75ch;
  color: var(--ink);
  font-weight: 430;
}

.message-actions {
  display: flex;
  gap: 2px;
  opacity: 0.34;
  transition: opacity 160ms var(--ease-smooth);
}

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

.message-action {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  transition: background 160ms var(--ease-smooth), color 160ms var(--ease-smooth), transform 160ms var(--ease-smooth);
}

.message-action .ui-icon {
  width: 17px;
  height: 17px;
}

.message-action:hover {
  background: var(--surface-muted);
  color: var(--ink);
}

.message-action:active {
  transform: scale(0.95);
}

.message.assistant[data-active="true"] .bubble::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 1.08em;
  margin-left: 3px;
  vertical-align: -0.16em;
  border-radius: 999px;
  background: var(--ink);
  animation: cursor-blink 1s steps(2, start) infinite;
}

.message.assistant[data-active="true"] .bubble:empty::before {
  content: "Fiona 正在输入";
  color: var(--ink-muted);
}

.empty-state {
  width: min(760px, 100%);
  margin: auto;
  display: grid;
  gap: var(--space-md);
  animation: empty-enter 420ms var(--ease-out) both;
}

.empty-state h2 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(36px, 5vw, 68px);
  line-height: 1.02;
  font-weight: 680;
  letter-spacing: 0;
}

.composer-wrap {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 12;
  display: grid;
  gap: var(--space-xs);
  pointer-events: none;
  padding: var(--space-xl) clamp(var(--space-md), 4vw, 72px) var(--space-md);
  background: linear-gradient(to top, var(--page) 70%, oklch(0.972 0.001 260 / 0));
}

.jump-bottom {
  width: 38px;
  height: 38px;
  justify-self: center;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--surface);
  cursor: pointer;
  pointer-events: auto;
  transition: background 160ms var(--ease-smooth), color 160ms var(--ease-smooth), transform 160ms var(--ease-smooth), opacity 160ms var(--ease-smooth);
}

.jump-bottom:hover {
  background: oklch(0.22 0.003 260);
}

.jump-bottom:active {
  transform: scale(0.96);
}

.composer {
  width: min(820px, 100%);
  min-height: 58px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 2px;
  padding: 8px;
  border-radius: 26px;
  background: var(--surface);
  pointer-events: auto;
}

.composer:focus-within {
  background: oklch(0.99 0.001 260);
}

textarea {
  width: 100%;
  max-height: 190px;
  resize: none;
  border: 0;
  border-radius: 18px;
  background: transparent;
  color: var(--ink);
  padding: 10px 12px;
  line-height: 1.55;
  outline: none;
}

textarea::placeholder {
  color: var(--ink-muted);
}

.hidden {
  display: none;
}

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

@keyframes message-enter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes empty-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes cursor-blink {
  0%, 45% {
    opacity: 1;
  }
  46%, 100% {
    opacity: 0;
  }
}

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

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

@media (max-width: 620px) {
  .topbar {
    min-height: 58px;
    padding-inline: var(--space-md);
  }

  .messages {
    padding-inline: var(--space-md);
    padding-bottom: 122px;
  }

  .empty-state h2 {
    font-size: 44px;
  }

  .composer-wrap {
    padding: var(--space-lg) var(--space-md) var(--space-sm);
  }

  .toast {
    bottom: 88px;
  }

  .composer {
    border-radius: 24px;
  }
}
