:root {
  --bg: #f2eee8;
  --surface: #fefcf8;
  --surface-2: #f7f2ea;
  --text: #1f1b16;
  --muted: #6b6258;
  --accent: #cf4a2c;
  --accent-2: #0d675f;
  --ring: rgba(207, 74, 44, 0.28);
  --border: #e4d8c9;
  --shadow: 0 12px 30px rgba(40, 25, 10, 0.08);
  --workspace-height: clamp(560px, 78vh, 780px);
  --bg-hue-a: 28;
  --bg-hue-b: 168;
  --bg-hue-c: 206;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: radial-gradient(circle at top left, #fff9f0 0%, var(--bg) 55%);
  font-family: "Noto Sans SC", "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-weight: 500;
  text-rendering: geometricPrecision;
  overflow: auto;
}

.bg-dynamic {
  position: fixed;
  inset: -16%;
  z-index: -3;
  background:
    radial-gradient(circle at 12% 20%, hsl(var(--bg-hue-a) 96% 68% / 0.5) 0%, transparent 46%),
    radial-gradient(circle at 88% 12%, hsl(var(--bg-hue-b) 92% 66% / 0.45) 0%, transparent 52%),
    radial-gradient(circle at 52% 86%, hsl(var(--bg-hue-c) 94% 68% / 0.45) 0%, transparent 56%);
  filter: saturate(1.26) contrast(1.04);
  animation: bgDrift 13s ease-in-out infinite alternate;
}

.bg-dynamic::after {
  content: "";
  position: absolute;
  inset: -8%;
  background: conic-gradient(
    from 30deg,
    hsl(var(--bg-hue-a) 94% 67% / 0.24),
    hsl(var(--bg-hue-b) 90% 66% / 0.2),
    hsl(var(--bg-hue-c) 92% 69% / 0.24),
    hsl(var(--bg-hue-a) 94% 67% / 0.24)
  );
  filter: blur(52px);
  animation: bgSpin 19s linear infinite;
  pointer-events: none;
}

body.chat-scrolling .bg-dynamic,
body.chat-scrolling .bg-dynamic::after,
body.chat-scrolling .bg-glow {
  animation-play-state: paused;
}

.bg-glow {
  position: fixed;
  z-index: -2;
  width: 40rem;
  height: 40rem;
  border-radius: 999px;
  filter: blur(52px);
  opacity: 0.52;
  animation: glowFloat 16s ease-in-out infinite alternate;
}

.bg-glow-left {
  left: -12rem;
  top: -8rem;
  background: #ffc87f;
}

.bg-glow-right {
  right: -14rem;
  bottom: -12rem;
  background: #a7d7c5;
  animation-delay: -6s;
}

.app {
  width: min(1760px, calc(100vw - 1rem));
  margin: 0.75rem auto 2.25rem;
  display: grid;
  grid-template-columns: 200px 300px minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  gap: 0.8rem;
  min-height: calc(100vh - 2rem);
}

.topbar {
  grid-column: 1 / -1;
  padding: 0.62rem 0.7rem 0.78rem;
  border-radius: 18px;
  border: 1px solid color-mix(in srgb, var(--accent) 24%, transparent);
  background: color-mix(in srgb, #fff8ef 78%, transparent);
  backdrop-filter: blur(8px) saturate(130%);
  transition: transform 0.28s ease, box-shadow 0.28s ease, background 0.28s ease, border-color 0.28s ease;
}

.topbar:hover {
  transform: translateY(-3px) scale(1.01);
  border-color: color-mix(in srgb, var(--accent) 56%, transparent);
  background: color-mix(in srgb, #fff7ea 85%, transparent);
  box-shadow: 0 18px 28px rgba(207, 74, 44, 0.22), 0 3px 0 rgba(207, 74, 44, 0.08);
}

.topbar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: transform 0.26s ease;
}

.topbar:hover .brand {
  transform: translateX(6px);
}

.brand h1 {
  margin: 0;
  font-family: "Nunito", "Noto Sans SC", sans-serif;
  font-size: clamp(1.45rem, 2.35vw, 2.25rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  background: linear-gradient(
    100deg,
    #1f1b16 0%,
    #cf4a2c 24%,
    #0d675f 50%,
    #2d66c3 72%,
    #1f1b16 100%
  );
  background-size: 240% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: titleColorFlow 5.8s linear infinite;
  transition: filter 0.28s ease, transform 0.28s ease;
}

.topbar:hover .brand h1 {
  transform: translateX(2px) scale(1.02);
  filter: drop-shadow(0 5px 10px rgba(13, 103, 95, 0.25));
}

.brand-kicker {
  background: linear-gradient(110deg, var(--accent), #ea7c3e);
  color: #fff;
  font-family: "Nunito", "Noto Sans SC", sans-serif;
  font-weight: 800;
  font-size: 1.08rem;
  letter-spacing: 0.03em;
  border-radius: 999px;
  padding: 0.5rem 0.92rem;
  box-shadow: 0 10px 18px rgba(207, 74, 44, 0.32);
  animation: badgePulse 2.2s ease-in-out infinite;
  transition: transform 0.24s ease, filter 0.24s ease;
}

.topbar:hover .brand-kicker {
  transform: translateY(-2px) scale(1.08) rotate(-3deg);
  filter: saturate(1.2) brightness(1.03);
  animation-duration: 0.9s;
}

.subtitle {
  margin: 0.52rem 0 0;
  font-size: 1.14rem;
  font-weight: 600;
  background: linear-gradient(
    100deg,
    #6b6258 0%,
    #ca5a2d 28%,
    #126d65 52%,
    #6b6258 84%
  );
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: subtitleColorFlow 6.4s linear infinite;
  transition: transform 0.26s ease, letter-spacing 0.26s ease, filter 0.26s ease;
}

.topbar:hover .subtitle {
  transform: translateX(6px);
  letter-spacing: 0.02em;
  filter: drop-shadow(0 4px 8px rgba(207, 74, 44, 0.22));
}

.logout-btn {
  min-width: 102px;
  white-space: nowrap;
}

.sidebar {
  grid-column: 1 / 3;
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 0.8rem;
  height: var(--workspace-height);
  min-height: 0;
}

.window-manager {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.6rem;
  padding: 0.75rem;
  height: 100%;
  min-height: 0;
}

.window-tabs {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: none;
  min-height: 0;
}

.window-tab {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 999px;
  width: 100%;
  min-width: 0;
  gap: 0.35rem;
  transition: transform 0.18s ease, border-color 0.2s ease, box-shadow 0.22s ease, background 0.22s ease;
}

.window-tab:hover {
  transform: translateX(2px);
  border-color: color-mix(in srgb, var(--accent) 46%, var(--border));
  box-shadow: 0 7px 15px rgba(40, 25, 10, 0.08);
}

.window-tab.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--ring);
}

.window-tab-main {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
  font-weight: 600;
}

.window-tab-rename-input {
  flex: 1;
  min-width: 0;
  border: 1.5px solid #101010;
  background: #fffef9;
  color: #111;
  border-radius: 999px;
  padding: 0.33rem 0.72rem;
  font-size: 0.9rem;
  font-weight: 700;
}

.window-tab-rename-input:focus {
  box-shadow: 0 0 0 4px rgba(23, 23, 23, 0.16);
  border-color: #111;
}

.window-tab-save {
  border: 1px solid #141414;
  background: #111;
  color: #fff;
  width: 1.45rem;
  height: 1.45rem;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1;
  transition: transform 0.16s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.window-tab-save:hover {
  transform: scale(1.1);
  background: #000;
  box-shadow: 0 6px 10px rgba(0, 0, 0, 0.3);
}

.window-tab-close {
  border: 0;
  background: linear-gradient(135deg, #df5a3b, #c93f23);
  color: #fff;
  width: 1.45rem;
  height: 1.45rem;
  padding: 0;
  margin-right: 0.4rem;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
  transition: transform 0.16s ease, filter 0.2s ease, box-shadow 0.22s ease;
}

.window-tab.is-renaming .window-tab-close {
  margin-right: 0.3rem;
}

.window-tab-close:hover {
  transform: scale(1.12);
  filter: saturate(1.15);
  box-shadow: 0 6px 10px rgba(201, 63, 35, 0.3);
}

.window-tab-close:disabled {
  opacity: 0.45;
  background: #d7cec2;
  color: #8f867b;
  cursor: not-allowed;
}

.panel {
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px) saturate(130%);
}

.controls {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  height: 100%;
  min-height: 0;
  overflow-y: auto;
}

.controls label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  position: relative;
  transition: transform 0.16s ease;
}

.controls label:hover {
  transform: translateY(-1px);
}

.controls span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.toggle-row {
  flex-direction: row !important;
  align-items: center;
  justify-content: space-between;
}

.toggle-switch {
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease, transform 0.18s ease;
}

.toggle-switch:hover {
  transform: translateY(-1px);
}

.toggle-switch:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.ios-toggle {
  position: relative;
  width: 54px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid #d8cbbb;
  background: #d7d1c7;
  padding: 0;
  appearance: none;
}

.ios-toggle .toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  transition: transform 0.24s ease, box-shadow 0.2s ease;
}

.ios-toggle[aria-checked="true"] {
  border-color: #e16a42;
  background: linear-gradient(130deg, #e66d41, #cf4a2c);
}

.ios-toggle[aria-checked="true"] .toggle-thumb {
  transform: translateX(22px);
}

.ios-toggle:focus-visible {
  box-shadow: 0 0 0 4px var(--ring);
}

input,
select,
textarea {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  outline: none;
  transition: border-color 0.22s ease, box-shadow 0.22s ease, transform 0.18s ease, background 0.2s ease;
}

input {
  padding: 0.64rem 0.72rem;
  font-size: 0.96rem;
  line-height: 1.4;
  font-weight: 600;
}

.filter-search {
  padding: 0.58rem 0.72rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.hidden-select {
  display: none;
}

.is-hidden {
  display: none !important;
}

.suggest-panel {
  display: none;
  margin-top: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 10px 20px rgba(40, 25, 10, 0.1);
}

.suggest-panel.open {
  display: block;
}

.suggest-item {
  width: 100%;
  border: 0;
  border-bottom: 1px solid #efe4d5;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 0.52rem 0.72rem;
  cursor: pointer;
  transition: background 0.16s ease;
}

.suggest-item:last-child {
  border-bottom: 0;
}

.suggest-item:hover,
.suggest-item.active {
  background: var(--surface-2);
}

.suggest-empty {
  color: var(--muted);
  font-size: 0.82rem;
  padding: 0.5rem 0.65rem;
}

select {
  padding: 0.64rem 0.72rem;
  font-size: 0.96rem;
  font-weight: 600;
}

textarea {
  resize: vertical;
  min-height: 6rem;
  max-height: 13rem;
  padding: 0.95rem 1rem;
  font-size: 1.06rem;
  line-height: 1.58;
  font-weight: 600;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--ring);
  transform: translateY(-1px);
  background: #fffcf7;
}

.ghost-btn {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  padding: 0.52rem 0.68rem;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, transform 0.16s ease, background 0.2s ease;
}

.ghost-btn:hover {
  color: var(--text);
  border-color: var(--accent);
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.55);
}

.ghost-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#newWindowBtn,
#clearChatBtn {
  border: 1px solid #c93f23;
  background: linear-gradient(135deg, #e86a45, #cf4a2c);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 8px 14px rgba(201, 63, 35, 0.22);
}

#newWindowBtn:hover:not(:disabled),
#clearChatBtn:hover:not(:disabled) {
  border-color: #b8381f;
  color: #fff;
  transform: translateY(-1px);
  filter: saturate(1.12);
  box-shadow: 0 10px 16px rgba(201, 63, 35, 0.32);
}

#newWindowBtn:active:not(:disabled),
#clearChatBtn:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
}

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

.chat-log {
  padding: 1rem;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-height: 0;
  overscroll-behavior: contain;
  scrollbar-gutter: stable both-edges;
  -webkit-overflow-scrolling: touch;
  will-change: scroll-position;
  contain: layout paint style;
  transform: translateZ(0);
  scrollbar-width: thin;
  scrollbar-color: #7fa6cb #eaf3fb;
}

.chat-log::-webkit-scrollbar {
  width: 11px;
}

.chat-log::-webkit-scrollbar-track {
  background: linear-gradient(180deg, #edf5fd, #e6effa);
  border-radius: 999px;
}

.chat-log::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #8eb3d7, #6f98c0);
  border-radius: 999px;
  border: 2px solid #eaf3fb;
}

.chat-log::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #7ea8cf, #5f8fbf);
}

.message {
  max-width: min(90%, 72rem);
  border-radius: 14px;
  padding: 0.76rem 0.92rem;
  border: 2px solid #111111;
  transform-origin: center bottom;
  position: relative;
}

.message.is-new.user {
  animation: bubbleUserIn 0.3s cubic-bezier(0.2, 0.72, 0.24, 1) both;
}

.message.is-new.assistant {
  animation: bubbleAssistantIn 0.34s cubic-bezier(0.2, 0.72, 0.24, 1) both;
}

.message.user {
  margin-left: auto;
  background: linear-gradient(120deg, #fff2e0, #ffe2d0);
  border-color: #111111;
}

.message.user::before {
  content: "";
  position: absolute;
  right: -12px;
  top: 18px;
  width: 0;
  height: 0;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-left: 12px solid #111111;
}

.message.user::after {
  content: "";
  position: absolute;
  right: -8px;
  top: 20px;
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 9px solid #ffe8d3;
}

.message.assistant {
  margin-right: auto;
  background: linear-gradient(125deg, #e6f3ff, #d7ebff);
  border-color: #111111;
}

.message.assistant::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 18px;
  width: 0;
  height: 0;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-right: 12px solid #111111;
}

.message.assistant::after {
  content: "";
  position: absolute;
  left: -8px;
  top: 20px;
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-right: 9px solid #e0efff;
}

.message .role {
  font-size: 0.73rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.message .text {
  white-space: pre-wrap;
  line-height: 1.6;
  font-size: 1rem;
  font-weight: 600;
}

.message.thinking {
  border-color: color-mix(in srgb, var(--accent) 34%, var(--border));
  background: linear-gradient(130deg, #edf6ff, #deeeff);
}

.thinking-text {
  display: inline-flex;
  align-items: center;
  gap: 0.56rem;
  color: #5c5146;
  font-weight: 500;
}

.thinking-pulse {
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 999px;
  background: var(--accent);
  animation: thinkingPulse 1.15s ease-in-out infinite;
}

.thinking-dots {
  display: inline-flex;
  gap: 0.2rem;
}

.thinking-dots span {
  width: 0.28rem;
  height: 0.28rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 72%, #ffffff);
  animation: dotBlink 1s infinite ease-in-out;
}

.thinking-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.thinking-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

.sources {
  margin-top: 0.6rem;
  border-top: 1px dashed var(--border);
  padding-top: 0.5rem;
}

.sources summary {
  cursor: pointer;
  color: var(--accent-2);
  font-size: 0.82rem;
}

.source-item {
  margin-top: 0.5rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.source-item b {
  color: var(--text);
}

.composer {
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, #fffaf2 86%, transparent);
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.composer.is-sending #sendBtn {
  animation: sendPulse 0.62s cubic-bezier(0.38, 0.08, 0.35, 1) infinite;
}

#prompt {
  border-radius: 14px;
  min-height: 6.8rem;
  font-size: 1.08rem;
  line-height: 1.6;
}

#prompt::placeholder {
  color: #8d8378;
}

#prompt.is-typing {
  animation: promptPulse 0.78s ease-in-out infinite;
  border-color: #cf4a2c;
}

.composer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.admin-users-panel {
  grid-column: 1 / -1;
  padding: 0.78rem 0.84rem 0.9rem;
  display: grid;
  gap: 0.55rem;
  max-height: 34vh;
  overflow: auto;
}

.admin-users-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
}

.admin-users-head h3 {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.admin-users-hint {
  font-size: 0.8rem;
  color: var(--muted);
}

.admin-users-create-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.5rem;
}

#adminUsersCreateBtn {
  border: 1px solid #c93f23;
  border-radius: 11px;
  background: linear-gradient(135deg, #e86a45, #cf4a2c);
  color: #fff;
  font-weight: 700;
  padding: 0.58rem 0.9rem;
  cursor: pointer;
  transition: transform 0.16s ease, filter 0.2s ease, box-shadow 0.2s ease;
}

#adminUsersCreateBtn:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: saturate(1.1);
  box-shadow: 0 8px 14px rgba(201, 63, 35, 0.24);
}

#adminUsersCreateBtn:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

.admin-users-status {
  margin: 0;
  min-height: 1.2rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.admin-users-status.error {
  color: #9e2f1d;
}

.admin-users-list {
  display: grid;
  gap: 0.52rem;
}

.admin-user-row {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 92%, #fff 8%);
  padding: 0.52rem 0.6rem;
  display: grid;
  gap: 0.48rem;
}

.admin-user-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.admin-user-name {
  font-size: 0.9rem;
  font-weight: 700;
}

.admin-user-badge {
  border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--border));
  color: var(--muted);
  border-radius: 999px;
  padding: 0.12rem 0.52rem;
  font-size: 0.73rem;
  font-weight: 700;
}

.admin-user-badge.is-admin {
  color: #fff;
  background: linear-gradient(120deg, #cf4a2c, #f0753f);
  border-color: #c74226;
}

.admin-user-locked {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.admin-user-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.admin-user-reset-editor {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.45rem;
}

.admin-user-password {
  min-width: 0;
}

.admin-user-reset-btn,
.admin-user-delete-btn,
.admin-user-confirm-btn,
.admin-user-cancel-btn {
  white-space: nowrap;
  padding: 0.52rem 0.72rem;
}

.status {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

#sendBtn {
  border: 0;
  border-radius: 12px;
  background: linear-gradient(120deg, var(--accent), #f5743c);
  color: #fff;
  font-family: "Nunito", "Noto Sans SC", sans-serif;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  padding: 0.7rem 1.12rem;
  transition: transform 0.16s ease, filter 0.2s ease, box-shadow 0.2s ease;
}

#sendBtn:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: saturate(1.08);
  box-shadow: 0 8px 14px rgba(207, 74, 44, 0.22);
}

#sendBtn:active:not(:disabled) {
  transform: translateY(0) scale(0.97);
}

#sendBtn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.auth-page {
  min-height: 100vh;
  overflow: auto;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.login-card {
  width: min(100%, 440px);
  padding: 1.25rem 1.25rem 1.1rem;
  border-radius: 18px;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  background: color-mix(in srgb, var(--surface) 92%, #ffffff 8%);
  backdrop-filter: blur(10px) saturate(120%);
  box-shadow: 0 14px 30px rgba(40, 25, 10, 0.16);
}

.login-kicker {
  margin: 0;
  display: inline-block;
  border-radius: 999px;
  padding: 0.24rem 0.72rem;
  font-family: "Nunito", "Noto Sans SC", sans-serif;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(120deg, var(--accent), #f5743c);
}

.login-card h1 {
  margin: 0.82rem 0 0.36rem;
  font-family: "Nunito", "Noto Sans SC", sans-serif;
  font-size: clamp(1.35rem, 4.5vw, 1.9rem);
  font-weight: 800;
}

.login-subtitle {
  margin: 0;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 0.72rem;
  margin-top: 1rem;
}

.login-form label {
  display: grid;
  gap: 0.42rem;
  font-size: 0.93rem;
  color: color-mix(in srgb, var(--text) 82%, #000 18%);
}

.login-form input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.68rem 0.8rem;
  font-size: 0.98rem;
  font-family: inherit;
  background: #fffdf9;
}

.login-form input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 60%, #fff 40%);
  box-shadow: 0 0 0 3px var(--ring);
}

#loginBtn {
  margin-top: 0.2rem;
  border: 0;
  border-radius: 11px;
  padding: 0.72rem 0.96rem;
  font-family: "Nunito", "Noto Sans SC", sans-serif;
  font-size: 1rem;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(120deg, var(--accent), #f5743c);
  cursor: pointer;
  transition: transform 0.16s ease, filter 0.2s ease, box-shadow 0.2s ease;
}

#loginBtn:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: saturate(1.08);
  box-shadow: 0 8px 14px rgba(207, 74, 44, 0.22);
}

#loginBtn:disabled {
  opacity: 0.64;
  cursor: not-allowed;
}

.login-status {
  min-height: 1.4rem;
  margin: 0.15rem 0 0;
  color: var(--muted);
}

.login-status.error {
  color: #9e2f1d;
}

@keyframes bgDrift {
  from {
    transform: translate3d(-1.5%, -1.2%, 0) scale(1.02);
  }
  to {
    transform: translate3d(1.4%, 1.1%, 0) scale(1.08);
  }
}

@keyframes bgSpin {
  from {
    transform: rotate(0deg) scale(1);
    opacity: 0.52;
  }
  50% {
    opacity: 0.75;
  }
  to {
    transform: rotate(360deg) scale(1.06);
    opacity: 0.52;
  }
}

@keyframes glowFloat {
  from {
    transform: translate3d(-6px, -8px, 0);
  }
  to {
    transform: translate3d(12px, 10px, 0);
  }
}

@keyframes bubbleUserIn {
  from {
    opacity: 0;
    transform: translate3d(18px, 10px, 0) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}

@keyframes bubbleAssistantIn {
  from {
    opacity: 0;
    transform: translate3d(-16px, 9px, 0) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}

@keyframes thinkingPulse {
  0%,
  100% {
    transform: scale(0.84);
    opacity: 0.48;
  }
  50% {
    transform: scale(1.16);
    opacity: 1;
  }
}

@keyframes dotBlink {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }
  40% {
    transform: translateY(-3px);
    opacity: 1;
  }
}

@keyframes promptPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(207, 74, 44, 0.24), 0 0 0 rgba(207, 74, 44, 0.18);
    transform: translateY(0);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(207, 74, 44, 0.18), 0 0 22px rgba(207, 74, 44, 0.25);
    transform: translateY(-1px);
  }
}

@keyframes sendPulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(207, 74, 44, 0.45), 0 8px 14px rgba(207, 74, 44, 0.22);
  }
  55% {
    transform: scale(1.06);
    box-shadow: 0 0 0 10px rgba(207, 74, 44, 0.04), 0 12px 18px rgba(207, 74, 44, 0.34);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(207, 74, 44, 0), 0 8px 14px rgba(207, 74, 44, 0.24);
  }
}

@keyframes titleColorFlow {
  from {
    background-position: 0% 50%;
  }
  to {
    background-position: 240% 50%;
  }
}

@keyframes subtitleColorFlow {
  from {
    background-position: 0% 50%;
  }
  to {
    background-position: 220% 50%;
  }
}

@keyframes badgePulse {
  0%,
  100% {
    transform: translateY(0) scale(1);
    box-shadow: 0 8px 16px rgba(207, 74, 44, 0.26);
  }
  50% {
    transform: translateY(-2px) scale(1.06);
    box-shadow: 0 14px 22px rgba(207, 74, 44, 0.42);
  }
}

@media (max-width: 760px) {
  body {
    overflow: auto;
  }

  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    min-height: auto;
    width: min(1120px, calc(100vw - 2rem));
  }

  .sidebar {
    grid-column: auto;
    display: flex;
    flex-direction: column;
    gap: 0.72rem;
    height: auto;
    order: 2;
  }

  .window-manager {
    flex-direction: row;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.7rem;
    height: auto;
    min-height: 0;
    padding: 0.72rem;
  }

  .window-tabs {
    flex: 1 1 auto;
    min-width: 0;
    max-height: none;
    min-height: 0;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 0.15rem;
  }

  .chat-panel {
    grid-column: auto;
    order: 1;
    height: 70vh;
    min-height: 440px;
  }

  .controls {
    height: auto;
    max-height: none;
    overflow: visible;
    padding-bottom: calc(0.95rem + env(safe-area-inset-bottom));
  }

  .controls label {
    gap: 0.32rem;
  }

  .message {
    max-width: 95%;
  }

  .topbar-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .logout-btn {
    width: 100%;
  }

  #clearChatBtn {
    margin-top: 0.16rem;
  }

  .admin-users-create-form {
    grid-template-columns: 1fr;
  }

  .admin-user-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .admin-user-reset-editor {
    grid-template-columns: 1fr;
  }

  .admin-users-panel {
    grid-column: auto;
    order: 3;
    max-height: none;
  }
}
