:root {
  --bg-start: #eef7f8;
  --bg-mid: #f9f3ec;
  --bg-end: #eef1fb;
  --panel: rgba(255, 255, 255, 0.76);
  --panel-strong: rgba(255, 255, 255, 0.9);
  --line: rgba(28, 45, 68, 0.12);
  --text: #1f2937;
  --muted: #667085;
  --accent: #0b5e72;
  --accent-2: #2f9f8f;
  --accent-3: #e06b4f;
  --gold: #d8a740;
  --user-bubble: #0f5f73;
  --assistant-bubble: rgba(255, 255, 255, 0.78);
  --shadow: 0 24px 70px rgba(29, 43, 63, 0.16);
  --soft-shadow: 0 16px 34px rgba(29, 43, 63, 0.1);
  --cursor-x: 50%;
  --cursor-y: 42%;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Sans SC", "PingFang SC", sans-serif;
  color: var(--text);
  background: linear-gradient(135deg, var(--bg-start), var(--bg-mid) 48%, var(--bg-end));
  overflow: hidden;
}

.ambient-bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.ambient-bg::before {
  content: "";
  position: absolute;
  inset: -24%;
  background:
    radial-gradient(circle at var(--cursor-x) var(--cursor-y), rgba(47, 159, 143, 0.18), transparent 28%),
    conic-gradient(from 120deg at 42% 46%, rgba(47, 159, 143, 0.2), rgba(224, 107, 79, 0.2), rgba(216, 167, 64, 0.16), rgba(47, 159, 143, 0.2));
  filter: blur(42px);
  opacity: 0.78;
  animation: ambient-drift 18s ease-in-out infinite alternate;
}

.ambient-gradient {
  position: absolute;
  width: 62vw;
  height: 62vw;
  min-width: 520px;
  min-height: 520px;
  border-radius: 44% 56% 49% 51%;
  filter: blur(52px);
  opacity: 0.34;
  mix-blend-mode: multiply;
}

.ambient-gradient-1 {
  top: -28%;
  left: -20%;
  background: linear-gradient(135deg, rgba(50, 159, 143, 0.52), rgba(72, 106, 190, 0.24));
  animation: float-field-a 16s ease-in-out infinite alternate;
}

.ambient-gradient-2 {
  right: -22%;
  bottom: -32%;
  background: linear-gradient(135deg, rgba(224, 107, 79, 0.46), rgba(216, 167, 64, 0.28));
  animation: float-field-b 19s ease-in-out infinite alternate;
}

.ambient-grid,
.ambient-scan {
  position: absolute;
  inset: 0;
}

.ambient-grid {
  background-image:
    linear-gradient(rgba(15, 95, 115, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 95, 115, 0.07) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at 50% 45%, #000 0, transparent 74%);
  animation: grid-glide 22s linear infinite;
}

.ambient-scan {
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.34) 47%, transparent 59%);
  transform: translateX(-120%);
  animation: scan-pass 7s ease-in-out infinite;
}

.agent-workspace,
.app-shell {
  position: relative;
  z-index: 1;
  height: 100vh;
  padding: 52px 20px 20px;
  perspective: 1200px;
  animation: shell-enter 0.7s cubic-bezier(0.2, 0.85, 0.2, 1) both;
}

.hidden {
  display: none !important;
}

.agent-workspace {
  display: grid;
  grid-template-columns: minmax(320px, 430px) 1fr;
  gap: 16px;
}

.app-shell {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
}

.agent-hero,
.agent-library,
.agent-sidebar,
.chat-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(1.15);
  position: relative;
  overflow: hidden;
}

.agent-hero::before,
.agent-library::before,
.agent-sidebar::before,
.chat-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.64), transparent 36%, rgba(47, 159, 143, 0.08));
  pointer-events: none;
}

.agent-hero::after,
.agent-library::after,
.agent-sidebar::after,
.chat-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(47, 159, 143, 0.22), rgba(224, 107, 79, 0.16));
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  pointer-events: none;
}

.agent-hero,
.agent-library,
.agent-sidebar {
  display: flex;
  flex-direction: column;
  padding: 18px;
  gap: 14px;
  animation: panel-rise 0.72s 0.05s cubic-bezier(0.2, 0.85, 0.2, 1) both;
}

.brand,
.agent-form,
.agent-list,
.library-header,
.active-agent-card,
.btn-primary,
.btn-secondary,
.chat-header,
.message-list,
.chat-form {
  position: relative;
  z-index: 1;
}

.agent-hero {
  justify-content: space-between;
}

.agent-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field-label {
  font-size: 14px;
  font-weight: 700;
}

.agent-textarea {
  min-height: 240px;
  resize: vertical;
  border: 1px solid #d6deeb;
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
  background: rgba(255, 255, 255, 0.88);
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease;
}

.agent-textarea:focus {
  border-color: rgba(47, 159, 143, 0.52);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(47, 159, 143, 0.12);
}

.novel-character-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  max-height: 260px;
  overflow-y: auto;
}

.novel-character-card {
  min-height: 132px;
  border: 1px solid rgba(28, 45, 68, 0.12);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.68);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease,
    background 0.2s ease;
}

.novel-character-card:hover {
  transform: translateY(-2px);
  border-color: rgba(47, 159, 143, 0.36);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--soft-shadow);
}

.novel-character-meta {
  margin-top: auto;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
}

.file-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

.file-button {
  min-width: 0;
  min-height: 42px;
  border: 1px solid rgba(47, 159, 143, 0.24);
  border-radius: 12px;
  padding: 0 12px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0.44)),
    linear-gradient(135deg, rgba(47, 159, 143, 0.12), rgba(216, 167, 64, 0.1));
  color: var(--accent);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  box-shadow: 0 12px 24px rgba(29, 43, 63, 0.08);
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease,
    background 0.2s ease;
}

.file-button:hover {
  border-color: rgba(47, 159, 143, 0.42);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.58)),
    linear-gradient(135deg, rgba(47, 159, 143, 0.16), rgba(216, 167, 64, 0.12));
  box-shadow: 0 16px 30px rgba(15, 95, 115, 0.14);
  transform: translateY(-1px);
}

.file-input:focus-visible + .file-button {
  border-color: rgba(47, 159, 143, 0.58);
  box-shadow:
    0 0 0 4px rgba(47, 159, 143, 0.12),
    0 16px 30px rgba(15, 95, 115, 0.12);
}

.file-button-icon {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 8px 18px rgba(15, 95, 115, 0.18);
}

.file-button-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 700;
}

.form-status {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.form-status.error {
  color: #b42318;
}

.library-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.library-header h2 {
  margin: 0;
  font-family: "Manrope", "Noto Sans SC", sans-serif;
  font-size: 22px;
}

.agent-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  overflow-y: auto;
  min-height: 0;
  padding-right: 4px;
}

.agent-card {
  min-height: 154px;
  border: 1px solid rgba(28, 45, 68, 0.12);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.68);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  box-shadow: 0 8px 20px rgba(29, 43, 63, 0);
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease,
    background 0.2s ease;
}

.agent-card:hover {
  transform: translateY(-2px);
  border-color: rgba(47, 159, 143, 0.36);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--soft-shadow);
}

.agent-badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border: 1px solid rgba(47, 159, 143, 0.22);
  border-radius: 999px;
  padding: 0 9px;
  color: var(--accent);
  background: rgba(47, 159, 143, 0.1);
  font-size: 12px;
  font-weight: 700;
}

.agent-name {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
}

.agent-desc {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.agent-sidebar {
  justify-content: flex-start;
}

.active-agent-card {
  border: 1px solid rgba(28, 45, 68, 0.12);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.62);
}

.active-agent-card h2 {
  margin: 12px 0 8px;
  font-size: 20px;
  line-height: 1.25;
}

.active-agent-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(17, 24, 39, 0.38);
  backdrop-filter: blur(10px);
}

.modal-backdrop.open {
  display: grid;
}

.confirm-modal {
  width: min(100%, 380px);
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 16px;
  padding: 22px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 26px 80px rgba(17, 24, 39, 0.24);
  animation: confirm-pop 0.22s cubic-bezier(0.2, 0.85, 0.2, 1) both;
}

.confirm-modal h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.confirm-modal p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.confirm-input-label {
  display: block;
  margin: 16px 0 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.confirm-input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid rgba(28, 45, 68, 0.18);
  border-radius: 10px;
  background: #fff;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.confirm-input:focus {
  border-color: var(--accent);
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.btn-secondary,
.btn-danger {
  min-width: 82px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}

.btn-secondary {
  border: 1px solid rgba(28, 45, 68, 0.14);
  background: rgba(255, 255, 255, 0.78);
  color: var(--text);
}

.btn-secondary:hover {
  border-color: rgba(28, 45, 68, 0.24);
  background: #fff;
}

.btn-danger {
  border: 1px solid rgba(180, 35, 24, 0.2);
  background: #c5221f;
  color: #fff;
  box-shadow: 0 12px 24px rgba(197, 34, 31, 0.18);
}

.btn-danger:hover {
  background: #a91f1b;
}

.brand {
  display: grid;
  grid-template-columns: 34px 1fr;
  column-gap: 10px;
  align-items: center;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.84), rgba(255, 255, 255, 0.18)),
    linear-gradient(135deg, var(--accent), var(--accent-2) 58%, var(--gold));
  box-shadow: 0 10px 26px rgba(15, 95, 115, 0.24);
  position: relative;
  overflow: hidden;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-left-color: transparent;
  border-radius: 50%;
  animation: spin-soft 4.5s linear infinite;
}

.brand h1 {
  margin: 0;
  font-family: "Manrope", "Noto Sans SC", sans-serif;
  font-size: 22px;
  letter-spacing: 0;
  line-height: 1.08;
}

.brand p {
  grid-column: 2;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.btn-primary,
.btn-new {
  border: none;
  border-radius: 12px;
  padding: 12px;
  background:
    linear-gradient(135deg, var(--accent), var(--accent-2)),
    linear-gradient(100deg, transparent 25%, rgba(255, 255, 255, 0.46) 50%, transparent 75%);
  background-size: 100% 100%, 240% 100%;
  background-position: 0 0, 140% 0;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 14px 28px rgba(15, 95, 115, 0.22);
  transition:
    transform 0.22s ease,
    box-shadow 0.22s ease,
    background-position 0.45s ease;
}

.btn-primary {
  min-height: 42px;
  padding: 0 16px;
}

.btn-primary:disabled {
  opacity: 0.56;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-primary:hover,
.btn-new:hover,
.btn-send:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 36px rgba(15, 95, 115, 0.28);
  background-position: 0 0, -40% 0;
}

.btn-new:disabled {
  opacity: 0.56;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.session-list {
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  padding-right: 4px;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.session-list::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.session-item {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.58);
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(29, 43, 63, 0);
  transition:
    border-color 0.2s ease,
    background 0.2s ease,
    box-shadow 0.2s ease;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
}

.session-item:hover {
  border-color: rgba(47, 159, 143, 0.35);
  background:
    linear-gradient(135deg, rgba(47, 159, 143, 0.12), rgba(255, 255, 255, 0.74)),
    rgba(255, 255, 255, 0.72);
  box-shadow: var(--soft-shadow);
}

.session-item.active {
  border-color: rgba(47, 159, 143, 0.42);
  background:
    linear-gradient(135deg, rgba(47, 159, 143, 0.16), rgba(255, 255, 255, 0.76)),
    rgba(255, 255, 255, 0.8);
  box-shadow: 0 12px 28px rgba(47, 159, 143, 0.14);
}

.session-name {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-copy {
  min-width: 0;
}

.session-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.session-delete {
  min-width: 44px;
  height: 28px;
  border: 1px solid rgba(180, 35, 24, 0.18);
  border-radius: 8px;
  background: rgba(220, 38, 38, 0.07);
  color: #b42318;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  line-height: 28px;
  padding: 0 8px;
}

.session-delete:hover {
  background: rgba(220, 38, 38, 0.14);
  border-color: rgba(180, 35, 24, 0.28);
}

.session-delete:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  animation: panel-rise 0.72s 0.14s cubic-bezier(0.2, 0.85, 0.2, 1) both;
}

.chat-header {
  border-bottom: 1px solid var(--line);
  padding: 18px 22px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.42), rgba(47, 159, 143, 0.08), rgba(224, 107, 79, 0.06));
}

.chat-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chat-header h2 {
  margin: 0;
  font-size: 20px;
  font-family: "Manrope", "Noto Sans SC", sans-serif;
}

.btn-clear-history {
  border: 1px solid rgba(180, 35, 24, 0.2);
  border-radius: 10px;
  padding: 0 12px;
  min-height: 34px;
  background: rgba(180, 35, 24, 0.08);
  color: #b42318;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    background 0.18s ease,
    border-color 0.18s ease;
}

.btn-clear-history:hover:not(:disabled) {
  transform: translateY(-1px);
  background: rgba(180, 35, 24, 0.14);
  border-color: rgba(180, 35, 24, 0.3);
}

.btn-clear-history:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.chat-loading-bar {
  position: relative;
  height: 3px;
  margin-top: 12px;
  border-radius: 999px;
  background: rgba(18, 78, 120, 0.08);
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.chat-loading-track {
  position: absolute;
  inset: 0;
  width: 35%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-2), var(--gold), var(--accent-3));
  box-shadow: 0 0 16px rgba(47, 159, 143, 0.34);
  transform: translateX(-120%);
}

.chat-loading-bar.active {
  opacity: 1;
}

.chat-loading-bar.active .chat-loading-track {
  animation: loading-slide 1s ease-in-out infinite;
}

.message-list {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.message-row {
  display: flex;
  animation: message-pop 0.36s cubic-bezier(0.2, 0.85, 0.2, 1) both;
}

.message-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: min(76%, 820px);
}

.message-row.user {
  justify-content: flex-end;
}

.message-row.assistant {
  justify-content: flex-start;
}

.bubble {
  padding: 12px 14px;
  border-radius: 14px;
  line-height: 1.55;
  font-size: 14px;
  white-space: pre-wrap;
  box-shadow: 0 10px 24px rgba(29, 43, 63, 0.08);
  transform-origin: bottom;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.message-row:hover .bubble {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(29, 43, 63, 0.11);
}

.message-row.user .bubble {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent 38%),
    linear-gradient(135deg, var(--user-bubble), var(--accent-2));
  color: #f8fcff;
  border-bottom-right-radius: 6px;
}

.message-row.user .message-stack {
  align-items: flex-end;
}

.message-row.assistant .message-stack {
  align-items: flex-start;
}

.message-row.assistant .bubble {
  background: var(--assistant-bubble);
  border: 1px solid #e6eaf2;
  border-bottom-left-radius: 6px;
  backdrop-filter: blur(10px);
}

.message-row.assistant.streaming .bubble::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 3px;
  background: #6b7280;
  vertical-align: text-bottom;
  animation: caret-blink 1s steps(1, end) infinite;
}

.speech-btn {
  height: 28px;
  min-width: 52px;
  border: 1px solid rgba(47, 159, 143, 0.22);
  border-radius: 8px;
  background: rgba(47, 159, 143, 0.1);
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  line-height: 26px;
  padding: 0 10px;
  transition:
    transform 0.18s ease,
    background 0.18s ease,
    border-color 0.18s ease;
}

.speech-btn:hover {
  background: rgba(47, 159, 143, 0.16);
  border-color: rgba(47, 159, 143, 0.34);
  transform: translateY(-1px);
}

.speech-btn.playing {
  background: rgba(47, 159, 143, 0.18);
  border-color: rgba(47, 159, 143, 0.4);
  animation: pulse-soft 1.2s ease-in-out infinite;
}

.speech-btn:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 16px;
  background: rgba(255, 255, 255, 0.38);
}

.chat-input {
  width: 100%;
  border: 1px solid #d6deeb;
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.88);
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease,
    background 0.2s ease;
}

.chat-input:focus {
  border-color: rgba(47, 159, 143, 0.52);
  background: #fff;
  box-shadow:
    0 0 0 4px rgba(47, 159, 143, 0.12),
    0 12px 28px rgba(47, 159, 143, 0.12);
  transform: translateY(-1px);
}

.btn-send,
.btn-stop {
  border: none;
  border-radius: 12px;
  padding: 0 18px;
  min-height: 44px;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 0.22s ease,
    box-shadow 0.22s ease,
    background-position 0.45s ease;
}

.btn-send {
  background:
    linear-gradient(135deg, #19324f, var(--accent)),
    linear-gradient(100deg, transparent 25%, rgba(255, 255, 255, 0.42) 50%, transparent 75%);
  background-size: 100% 100%, 240% 100%;
  background-position: 0 0, 140% 0;
  color: #fff;
  box-shadow: 0 12px 26px rgba(25, 50, 79, 0.22);
}

.btn-stop {
  border: 1px solid rgba(180, 35, 24, 0.18);
  background: rgba(180, 35, 24, 0.08);
  color: #b42318;
  box-shadow: 0 10px 22px rgba(180, 35, 24, 0.1);
}

.btn-stop:hover:not(:disabled) {
  transform: translateY(-2px);
  background: rgba(180, 35, 24, 0.14);
  box-shadow: 0 14px 28px rgba(180, 35, 24, 0.16);
}

.btn-send:disabled,
.btn-stop:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.empty-state {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  margin-top: 24px;
  animation: fade-up 0.45s ease both;
}

.auth-view {
  position: relative;
  z-index: 1;
  height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  animation: shell-enter 0.7s cubic-bezier(0.2, 0.85, 0.2, 1) both;
}

.auth-card {
  width: min(100%, 400px);
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 20px;
  padding: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(1.15);
  animation: panel-rise 0.72s 0.05s cubic-bezier(0.2, 0.85, 0.2, 1) both;
}

.auth-brand {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
}

.auth-brand h1 {
  margin: 0;
  font-family: "Manrope", "Noto Sans SC", sans-serif;
  font-size: 22px;
  line-height: 1.08;
}

.auth-brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.auth-tab {
  flex: 1;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  padding: 10px 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  transition:
    color 0.2s ease,
    border-color 0.2s ease;
}

.auth-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent-2);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-input {
  border: 1px solid #d6deeb;
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
  font-family: inherit;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.88);
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease;
}

.auth-input:focus {
  border-color: rgba(47, 159, 143, 0.52);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(47, 159, 143, 0.12);
}

.auth-code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.auth-code-row .btn-secondary {
  min-height: 44px;
  white-space: nowrap;
}

.auth-password-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-password-fields.disabled {
  opacity: 0.56;
}

.auth-submit {
  margin-top: 6px;
}

.auth-link-button {
  align-self: center;
  border: none;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 8px;
}

.auth-link-button:hover {
  color: var(--accent-2);
}

.auth-status {
  min-height: 20px;
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.auth-status.error {
  color: #b42318;
}

.user-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 8px 20px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  animation: fade-up 0.3s ease both;
}

.user-bar-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
}

.token-usage-panel {
  margin-right: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.token-usage-item {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid rgba(47, 159, 143, 0.16);
  border-radius: 8px;
  padding: 0 8px;
  background: rgba(255, 255, 255, 0.62);
  white-space: nowrap;
}

.token-usage-item strong {
  color: var(--accent);
  font-weight: 700;
}

.btn-logout {
  border: 1px solid rgba(180, 35, 24, 0.2);
  border-radius: 10px;
  padding: 0 12px;
  min-height: 32px;
  background: rgba(180, 35, 24, 0.08);
  color: #b42318;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    background 0.18s ease,
    border-color 0.18s ease;
}

.btn-logout:hover {
  transform: translateY(-1px);
  background: rgba(180, 35, 24, 0.14);
  border-color: rgba(180, 35, 24, 0.3);
}

@keyframes ambient-drift {
  from {
    transform: rotate(0deg) scale(1);
  }
  to {
    transform: rotate(9deg) scale(1.08);
  }
}

@keyframes float-field-a {
  from {
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
  to {
    transform: translate3d(8vw, 6vh, 0) rotate(18deg);
  }
}

@keyframes float-field-b {
  from {
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
  to {
    transform: translate3d(-7vw, -5vh, 0) rotate(-14deg);
  }
}

@keyframes grid-glide {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 44px 44px;
  }
}

@keyframes scan-pass {
  0%,
  18% {
    transform: translateX(-120%);
    opacity: 0;
  }
  32%,
  62% {
    opacity: 0.6;
  }
  78%,
  100% {
    transform: translateX(120%);
    opacity: 0;
  }
}

@keyframes shell-enter {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes panel-rise {
  from {
    opacity: 0;
    transform: rotateX(3deg) translateY(18px);
  }
  to {
    opacity: 1;
    transform: rotateX(0) translateY(0);
  }
}

@keyframes message-pop {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

@keyframes confirm-pop {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

@keyframes pulse-soft {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(47, 159, 143, 0.2);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(47, 159, 143, 0);
  }
}

@keyframes loading-slide {
  from {
    transform: translateX(-120%);
  }
  to {
    transform: translateX(320%);
  }
}

@keyframes caret-blink {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

@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: 900px) {
  .user-bar {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .token-usage-panel {
    order: 3;
    width: 100%;
    overflow-x: auto;
  }

  .agent-workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(360px, auto) 1fr;
    min-height: 100vh;
    height: auto;
    padding: 88px 12px 12px;
    gap: 12px;
    overflow-y: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: 100vh;
    padding: 88px 12px 12px;
    gap: 12px;
  }

  .agent-sidebar {
    overflow: hidden;
  }

  .file-row {
    grid-template-columns: 1fr;
  }

  .chat-form {
    grid-template-columns: 1fr auto;
  }

  .chat-input {
    grid-column: 1 / -1;
  }

  .chat-header-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .agent-list {
    grid-template-columns: 1fr;
  }

  .message-list {
    padding: 16px;
  }

  .bubble {
    max-width: none;
  }

  .message-stack {
    max-width: 88%;
  }
}
