:root {
  --bg: #020711;
  --panel: rgba(4, 17, 35, 0.76);
  --panel-strong: rgba(5, 23, 45, 0.9);
  --line: rgba(50, 113, 160, 0.42);
  --line-bright: rgba(77, 198, 232, 0.78);
  --cyan: #27d8f7;
  --cyan-soft: #8cecff;
  --ink: #f5f8fb;
  --muted: #8ea1b5;
  --muted-soft: #62758a;
  --shadow: 0 18px 52px rgba(0, 0, 0, 0.34);
  --cyan-glow: 0 0 18px rgba(39, 216, 247, 0.25);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  height: 100%;
}

body {
  margin: 0;
  height: 100%;
  min-height: 100vh;
  overflow: hidden;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(circle at 34% 34%, rgba(0, 145, 255, 0.1), transparent 38%),
    radial-gradient(circle at 77% 22%, rgba(0, 236, 255, 0.07), transparent 34%),
    linear-gradient(145deg, #01040d 0%, #030a17 44%, #00030a 100%);
  letter-spacing: 0;
}

body::after {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(119, 243, 255, 0.08), transparent 18%),
    radial-gradient(circle at 54% 70%, rgba(0, 216, 255, 0.08), transparent 28%);
}

body.modal-open {
  overflow: hidden;
}

.client-login-shell {
  display: grid;
  place-items: center;
  width: 100vw;
  min-height: 100vh;
  padding: 24px;
}

.client-login-panel {
  display: grid;
  gap: 16px;
  width: min(420px, calc(100vw - 48px));
  padding: 28px;
  background:
    linear-gradient(180deg, rgba(6, 24, 48, 0.94), rgba(2, 9, 22, 0.98)),
    var(--panel-strong);
  border: 1px solid rgba(77, 198, 232, 0.58);
  border-radius: 12px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.46), var(--cyan-glow);
}

.client-login-logo {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border: 1px solid rgba(0, 216, 255, 0.56);
  border-radius: 50%;
  box-shadow: var(--cyan-glow);
}

.client-login-copy {
  display: grid;
  gap: 4px;
}

.client-login-copy span,
.client-login-field span {
  color: var(--cyan-soft);
  font-size: 12px;
  font-weight: 820;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.client-login-copy h1 {
  margin: 0;
  color: var(--ink);
  font-size: 34px;
  line-height: 1;
  font-weight: 780;
}

.client-login-field {
  display: grid;
  gap: 8px;
}

.client-login-field input {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  color: var(--ink);
  background: rgba(0, 7, 18, 0.78);
  border: 1px solid rgba(77, 198, 232, 0.38);
  border-radius: 9px;
  font-size: 15px;
  font-weight: 620;
}

.client-login-status {
  margin: 0;
  color: var(--cyan-soft);
  font-size: 13px;
  font-weight: 650;
}

.client-login-status.is-error {
  color: #ffb3b3;
}

.client-login-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 46px;
  color: #001026;
  background: linear-gradient(135deg, var(--cyan), #13a7ff);
  border: 1px solid rgba(140, 236, 255, 0.82);
  border-radius: 10px;
  font-size: 15px;
  font-weight: 780;
}

.client-login-button:disabled {
  cursor: wait;
  opacity: 0.78;
}

.client-login-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(0, 16, 38, 0.28);
  border-top-color: #001026;
  border-radius: 50%;
  animation: login-spin 0.72s linear infinite;
}

.client-login-button.is-loading .client-login-spinner {
  display: inline-block;
}

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

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button,
input,
textarea {
  border: 0;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--cyan-soft);
  outline-offset: 3px;
}

svg {
  display: block;
}

.chat-app {
  display: grid;
  grid-template-columns: clamp(232px, 13.6vw, 268px) minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
  min-height: 0;
  margin: 0 auto;
  overflow: hidden;
  background: rgba(0, 5, 15, 0.45);
  border: 1px solid rgba(29, 98, 151, 0.46);
  border-radius: 0;
  box-shadow: inset 0 0 52px rgba(5, 94, 175, 0.18);
}

.chat-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 14px 16px 16px;
  background:
    linear-gradient(180deg, rgba(4, 19, 40, 0.9), rgba(0, 7, 19, 0.96)),
    rgba(3, 9, 22, 0.9);
  border-right: 1px solid rgba(54, 137, 197, 0.46);
  box-shadow: 16px 0 44px rgba(0, 0, 0, 0.32);
}

.brand-strip {
  display: flex;
  align-items: center;
  min-height: 58px;
  gap: 10px;
  margin: -14px -16px 10px;
  padding: 12px 20px;
  color: var(--ink);
  border-bottom: 1px solid rgba(54, 137, 197, 0.55);
  font-size: 18px;
  font-weight: 650;
}

.brand-logo,
.cove-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-logo {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(0, 216, 255, 0.52);
  border-radius: 50%;
  box-shadow: var(--cyan-glow);
}

.history-section {
  margin-top: 0;
}

.new-chat-button,
.manage-docs-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
  min-height: 48px;
  /* Success: Footer action labels and icons now share the same white foreground treatment. */
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(5, 32, 61, 0.86), rgba(2, 15, 32, 0.88)),
    rgba(5, 23, 45, 0.82);
  border: 1px solid rgba(8, 220, 255, 0.58);
  border-radius: 12px;
  box-shadow: inset 0 0 18px rgba(8, 220, 255, 0.08);
  font-size: 15px;
  font-weight: 600;
}

.new-chat-button:hover,
.manage-docs-button:hover {
  color: #001026;
  background: linear-gradient(135deg, var(--cyan), #13a7ff);
}

.new-chat-button:focus-visible,
.manage-docs-button:focus-visible {
  color: #001026;
  background: linear-gradient(135deg, var(--cyan), #13a7ff);
  outline: 2px solid rgba(140, 236, 255, 0.72);
  outline-offset: 3px;
}

.new-chat-button svg,
.manage-docs-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.history-list {
  display: grid;
  gap: 0;
  max-height: min(42vh, 380px);
  overflow-y: auto;
  scrollbar-color: rgba(8, 220, 255, 0.62) rgba(2, 12, 28, 0.86);
}

.history-list.is-busy {
  opacity: 0.72;
  pointer-events: none;
}

.history-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 58px;
  padding: 4px 6px 4px 10px;
  color: var(--ink);
  text-align: left;
  background: transparent;
  border-bottom: 1px solid rgba(31, 83, 124, 0.47);
}

.history-row:hover,
.history-row.is-active {
  color: var(--cyan-soft);
  background: rgba(0, 216, 255, 0.04);
}

.history-select {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  min-width: 0;
  min-height: 50px;
  padding: 6px 0;
  color: inherit;
  text-align: left;
  background: transparent;
}

.history-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0.76;
  transition: opacity 160ms ease;
}

.history-row:hover .history-actions,
.history-row:focus-within .history-actions,
.history-row.is-active .history-actions {
  opacity: 1;
}

.history-action-button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  color: rgba(245, 248, 251, 0.86);
  background: rgba(4, 21, 43, 0.62);
  border: 1px solid rgba(77, 198, 232, 0.28);
  border-radius: 8px;
}

.history-action-button:hover {
  color: var(--cyan-soft);
  border-color: rgba(140, 236, 255, 0.72);
  background: rgba(6, 36, 70, 0.84);
}

.history-action-button.danger:hover {
  color: #ffd4d4;
  border-color: rgba(255, 126, 126, 0.6);
}

.history-action-button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.history-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.history-select strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 560;
}

.history-select small {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  line-height: 1.2;
}

.history-empty {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.sidebar-footer {
  display: grid;
  gap: 12px;
  margin-top: auto;
}

.sidebar-footer .manage-docs-button {
  min-height: 48px;
}

.usage-card {
  padding: 14px;
  background: linear-gradient(180deg, rgba(7, 29, 58, 0.84), rgba(3, 13, 28, 0.86));
  border: 1px solid rgba(49, 141, 208, 0.62);
  border-radius: 12px;
  box-shadow: inset 0 0 28px rgba(8, 220, 255, 0.06);
}

.usage-copy {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  margin-bottom: 11px;
  font-size: 14px;
}

.usage-copy strong {
  font-size: 15px;
}

.usage-track {
  height: 15px;
  padding: 2px;
  overflow: hidden;
  background: rgba(0, 8, 22, 0.88);
  border: 1px solid rgba(52, 137, 198, 0.68);
  border-radius: 999px;
}

.usage-track span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), #10a7ff);
  border-radius: inherit;
  box-shadow: 0 0 22px rgba(8, 220, 255, 0.64);
  transition: width 180ms ease;
}

.sidebar-actions {
  display: grid;
  grid-template-columns: 0.78fr 1.22fr;
  gap: 10px;
}

.icon-button {
  display: grid;
  place-items: center;
  min-height: 46px;
  color: var(--ink);
  background: linear-gradient(180deg, rgba(5, 24, 48, 0.86), rgba(3, 12, 28, 0.9));
  border: 1px solid rgba(47, 137, 201, 0.68);
  border-radius: 10px;
  box-shadow: inset 0 0 24px rgba(8, 220, 255, 0.06);
}

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

.logout-button {
  display: inline-flex;
  gap: 8px;
  padding: 0 12px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.logout-button svg {
  width: 20px;
  height: 20px;
  color: var(--ink);
  filter: drop-shadow(0 0 12px rgba(8, 220, 255, 0.36));
}

.logout-button:hover,
.logout-button:focus-visible {
  color: #001026;
  background: linear-gradient(135deg, var(--cyan), #13a7ff);
}

.settings-modal-shell {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 18px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.settings-modal-shell.is-open {
  opacity: 1;
  pointer-events: auto;
}

.settings-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 6, 16, 0.72);
  backdrop-filter: blur(12px);
}

.settings-modal {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(440px, calc(100vw - 36px));
  overflow: hidden;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(7, 35, 66, 0.96), rgba(2, 12, 28, 0.98)),
    var(--panel-strong);
  border: 1px solid rgba(77, 198, 232, 0.58);
  border-radius: 12px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42), var(--cyan-glow);
}

.settings-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 72px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(68, 136, 188, 0.58);
}

.settings-modal-header h2 {
  margin: 0;
  color: var(--ink);
  font-size: 22px;
  font-weight: 650;
}

.settings-modal-body {
  padding: 18px 20px 20px;
}

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

.settings-row strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 740;
}

.settings-row span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.theme-toggle {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(74px, 1fr));
  gap: 4px;
  padding: 4px;
  background: rgba(0, 8, 22, 0.72);
  border: 1px solid rgba(77, 198, 232, 0.34);
  border-radius: 999px;
}

.theme-option {
  min-height: 34px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 760;
}

.theme-option.is-active {
  color: #001026;
  background: linear-gradient(135deg, var(--cyan), #13a7ff);
  box-shadow: 0 0 18px rgba(39, 216, 247, 0.24);
}

.chat-main {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
}

.chat-canvas {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 18px;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

.chat-canvas::before {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  background:
    radial-gradient(circle at 30% 44%, rgba(7, 137, 222, 0.14), transparent 22%),
    radial-gradient(circle at 72% 53%, rgba(8, 220, 255, 0.12), transparent 28%);
}

.message-pill {
  position: absolute;
  z-index: 1;
  display: flex;
  align-items: center;
  min-height: 64px;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(6, 31, 63, 0.88), rgba(3, 14, 35, 0.92)),
    rgba(3, 13, 30, 0.8);
  border: 1px solid var(--line-bright);
  border-radius: 999px;
  box-shadow:
    0 0 28px rgba(8, 220, 255, 0.18),
    inset 0 0 30px rgba(0, 120, 255, 0.12);
  font-size: clamp(17px, 1.14vw, 22px);
  font-weight: 430;
}

.user-pill {
  top: clamp(42px, 7%, 68px);
  right: clamp(52px, 6vw, 120px);
  width: clamp(310px, 28vw, 450px);
  padding: 9px 30px 9px 18px;
  gap: 20px;
}

.user-avatar {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 47px;
  height: 47px;
  color: var(--cyan);
  border: 2px solid rgba(8, 220, 255, 0.82);
  border-radius: 50%;
  box-shadow: inset 0 0 18px rgba(8, 220, 255, 0.2), 0 0 16px rgba(8, 220, 255, 0.2);
}

.user-avatar svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.cove-pill {
  top: clamp(170px, 24%, 234px);
  left: clamp(58px, 8vw, 138px);
  width: clamp(360px, 30vw, 540px);
  padding: 9px 30px 9px 14px;
  gap: 24px;
}

.cove-avatar {
  display: block;
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  overflow: hidden;
  background: #020816;
  border: 1px solid rgba(8, 220, 255, 0.68);
  border-radius: 50%;
  box-shadow: var(--cyan-glow), inset 0 0 24px rgba(8, 220, 255, 0.12);
}

.cove-avatar.large {
  position: absolute;
  top: 30px;
  left: 24px;
  width: 60px;
  height: 60px;
}

.response-panel {
  position: absolute;
  z-index: 1;
  top: clamp(284px, 40%, 370px);
  right: clamp(64px, 7vw, 142px);
  width: clamp(520px, 38vw, 690px);
  min-height: clamp(228px, 29vh, 286px);
  padding: 58px 48px 42px 104px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(6, 36, 70, 0.82), rgba(2, 16, 38, 0.9)),
    rgba(3, 13, 30, 0.8);
  border: 1px solid rgba(8, 220, 255, 0.88);
  border-radius: 28px;
  box-shadow:
    0 0 34px rgba(8, 220, 255, 0.16),
    inset 0 0 40px rgba(0, 116, 255, 0.12),
    var(--shadow);
}

.response-panel::after {
  position: absolute;
  inset: -40% -20% auto auto;
  width: 340px;
  height: 340px;
  content: "";
  pointer-events: none;
  background: radial-gradient(circle, rgba(8, 220, 255, 0.16), transparent 62%);
}

.wave-lines svg {
  width: 100%;
  height: clamp(118px, 16vh, 148px);
  overflow: visible;
}

.wave-lines path {
  fill: none;
  stroke: rgba(8, 220, 255, 0.84);
  stroke-linecap: round;
  stroke-width: 2;
}

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

.message-list {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  min-height: 0;
  margin: 0;
  padding: clamp(24px, 3.4vw, 40px) 0 10px;
  overflow-y: auto;
  scrollbar-color: rgba(8, 220, 255, 0.62) rgba(2, 12, 28, 0.86);
}

.chat-message {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  width: min(980px, calc(100% - clamp(72px, 10.8vw, 192px)));
  max-width: none;
}

.chat-message .cove-avatar,
.chat-message .user-avatar {
  width: 38px;
  height: 38px;
  border-width: 1px;
}

.chat-message .user-avatar svg {
  width: 21px;
  height: 21px;
}

.chat-message.is-user {
  align-self: center;
  flex-direction: row-reverse;
  justify-content: flex-start;
}

.chat-message.is-assistant {
  align-self: center;
  justify-content: flex-start;
}

.message-bubble {
  min-width: 0;
  max-width: min(780px, 86%);
  padding: 13px 15px;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(6, 36, 70, 0.88), rgba(2, 16, 38, 0.94)),
    rgba(3, 13, 30, 0.84);
  border: 1px solid rgba(8, 220, 255, 0.72);
  border-radius: 16px;
  box-shadow:
    0 0 20px rgba(39, 216, 247, 0.08),
    inset 0 0 22px rgba(0, 120, 255, 0.08);
}

.chat-message.is-assistant .message-bubble {
  max-width: min(960px, calc(100% - 52px));
}

.chat-message.is-user .message-bubble {
  background:
    linear-gradient(180deg, rgba(8, 55, 88, 0.9), rgba(3, 19, 40, 0.94)),
    rgba(5, 23, 45, 0.86);
}

.message-bubble.is-pending {
  position: relative;
  overflow: hidden;
  min-width: min(220px, 100%);
  padding: 10px 13px;
  color: rgba(214, 246, 255, 0.94);
  background:
    radial-gradient(circle at 18% 18%, rgba(140, 236, 255, 0.16), transparent 30%),
    linear-gradient(180deg, rgba(8, 47, 82, 0.9), rgba(2, 16, 38, 0.96)),
    rgba(3, 13, 30, 0.84);
  border-color: rgba(140, 236, 255, 0.86);
  box-shadow:
    0 0 28px rgba(39, 216, 247, 0.14),
    inset 0 0 26px rgba(0, 120, 255, 0.12);
}

.message-bubble.is-pending::after {
  position: absolute;
  inset: -40% auto -40% -22%;
  width: 46%;
  content: "";
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(140, 236, 255, 0.18), transparent);
  transform: skewX(-18deg);
  animation: thinkingSweep 2.4s ease-in-out infinite;
}

.message-content.is-thinking {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  white-space: nowrap;
}

.thinking-brain {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 50px;
  height: 36px;
}

.thinking-brain svg {
  width: 50px;
  height: 36px;
  overflow: visible;
  filter: drop-shadow(0 0 10px rgba(39, 216, 247, 0.28));
}

.brain-outline {
  fill: rgba(5, 40, 75, 0.64);
  stroke: rgba(140, 236, 255, 0.96);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  animation: brainPulse 1.8s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}

.brain-fold,
.thought-rail {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brain-fold {
  stroke: rgba(245, 252, 255, 0.74);
  stroke-dasharray: 19;
  stroke-dashoffset: 38;
  stroke-width: 1.6;
  animation: thoughtTrace 1.9s ease-in-out infinite;
}

.fold-two {
  animation-delay: 120ms;
}

.fold-three {
  animation-delay: 240ms;
}

.fold-four {
  animation-delay: 360ms;
}

.fold-five {
  animation-delay: 480ms;
}

.fold-six {
  animation-delay: 600ms;
}

.thought-rail {
  stroke: rgba(39, 216, 247, 0.3);
  stroke-width: 1.2;
}

.thought-pulse {
  fill: #f7fdff;
  filter: drop-shadow(0 0 7px rgba(140, 236, 255, 0.92));
}

.thinking-copy {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  color: rgba(248, 251, 255, 0.94);
  font-size: 14px;
  font-weight: 680;
}

.thinking-dots {
  display: inline-flex;
  gap: 2px;
  min-width: 18px;
}

.thinking-dots span {
  width: 4px;
  height: 4px;
  background: var(--cyan-soft);
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(140, 236, 255, 0.7);
  animation: thinkingDot 1.1s ease-in-out infinite;
}

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

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

@keyframes brainPulse {
  0%,
  100% {
    filter: drop-shadow(0 0 4px rgba(39, 216, 247, 0.22));
    transform: scale(0.98);
  }

  50% {
    filter: drop-shadow(0 0 12px rgba(140, 236, 255, 0.5));
    transform: scale(1.025);
  }
}

@keyframes thoughtTrace {
  0% {
    opacity: 0.32;
    stroke-dashoffset: 38;
  }

  48% {
    opacity: 1;
    stroke-dashoffset: 0;
  }

  100% {
    opacity: 0.38;
    stroke-dashoffset: -28;
  }
}

@keyframes thinkingDot {
  0%,
  100% {
    opacity: 0.34;
    transform: translateY(0) scale(0.78);
  }

  48% {
    opacity: 1;
    transform: translateY(-5px) scale(1.08);
  }
}

@keyframes thinkingSweep {
  0% {
    transform: translateX(-20%) skewX(-18deg);
    opacity: 0;
  }

  38%,
  62% {
    opacity: 1;
  }

  100% {
    transform: translateX(330%) skewX(-18deg);
    opacity: 0;
  }
}

body[data-theme="light"] {
  --bg: #f4f8fb;
  --panel: rgba(255, 255, 255, 0.86);
  --panel-strong: rgba(255, 255, 255, 0.96);
  --line: rgba(87, 128, 158, 0.36);
  --line-bright: rgba(22, 134, 174, 0.58);
  --cyan: #39bce8;
  --cyan-soft: #087ea4;
  --ink: #102235;
  --muted: #5d7286;
  --muted-soft: #8294a5;
  --shadow: 0 18px 52px rgba(23, 62, 92, 0.16);
  --cyan-glow: 0 0 18px rgba(33, 152, 200, 0.18);
  color: var(--ink);
  background:
    radial-gradient(circle at 34% 34%, rgba(49, 188, 232, 0.16), transparent 38%),
    radial-gradient(circle at 77% 22%, rgba(111, 210, 236, 0.18), transparent 34%),
    linear-gradient(145deg, #f6fbff 0%, #e8f3fa 48%, #f9fcff 100%);
}

body[data-theme="light"]::after {
  background:
    linear-gradient(180deg, rgba(12, 119, 163, 0.08), transparent 18%),
    radial-gradient(circle at 54% 70%, rgba(35, 174, 219, 0.12), transparent 28%);
}

body[data-theme="light"] .client-login-panel,
body[data-theme="light"] .chat-sidebar,
body[data-theme="light"] .settings-modal,
body[data-theme="light"] .chat-action-modal,
body[data-theme="light"] .docs-modal {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(239, 247, 252, 0.98)),
    var(--panel-strong);
  border-color: rgba(22, 134, 174, 0.34);
  box-shadow: 0 24px 80px rgba(23, 62, 92, 0.16), var(--cyan-glow);
}

body[data-theme="light"] .chat-app {
  background: rgba(245, 250, 254, 0.68);
  border-color: rgba(87, 128, 158, 0.28);
  box-shadow: inset 0 0 52px rgba(55, 141, 190, 0.12);
}

body[data-theme="light"] .brand-strip,
body[data-theme="light"] .settings-modal-header,
body[data-theme="light"] .chat-action-modal-header,
body[data-theme="light"] .docs-modal-header {
  border-color: rgba(87, 128, 158, 0.28);
}

body[data-theme="light"] .chat-canvas::before {
  background:
    radial-gradient(circle at 30% 44%, rgba(45, 164, 214, 0.13), transparent 22%),
    radial-gradient(circle at 72% 53%, rgba(65, 189, 225, 0.16), transparent 28%);
}

body[data-theme="light"] .new-chat-button,
body[data-theme="light"] .manage-docs-button,
body[data-theme="light"] .usage-card,
body[data-theme="light"] .icon-button,
body[data-theme="light"] .history-action-button,
body[data-theme="light"] .modal-icon-button,
body[data-theme="light"] .modal-action-button,
body[data-theme="light"] .theme-toggle,
body[data-theme="light"] .prompt-bar,
body[data-theme="light"] .message-bubble,
body[data-theme="light"] .doc-list-message,
body[data-theme="light"] .doc-row,
body[data-theme="light"] .doc-textarea,
body[data-theme="light"] .instructions-textarea,
body[data-theme="light"] .chat-action-input,
body[data-theme="light"] .client-login-field input {
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(235, 245, 251, 0.94)),
    rgba(255, 255, 255, 0.82);
  border-color: rgba(22, 134, 174, 0.32);
  box-shadow: inset 0 0 18px rgba(28, 145, 193, 0.05);
}

body[data-theme="light"] .history-row {
  border-color: rgba(87, 128, 158, 0.22);
}

body[data-theme="light"] .history-row:hover,
body[data-theme="light"] .history-row.is-active,
body[data-theme="light"] .doc-row:hover,
body[data-theme="light"] .doc-row.is-active {
  color: #066f91;
  background: rgba(57, 188, 232, 0.12);
}

/* Previous: light mode targeted `.message-bubble.is-user`, but `is-user` lives on the row, so user bubbles stayed dark. */
/* Success: light mode now styles the actual user bubble and keeps user text readable on the light surface. */
body[data-theme="light"] .chat-message.is-user .message-bubble {
  color: #1d3145;
  background:
    linear-gradient(180deg, rgba(211, 242, 253, 0.95), rgba(189, 233, 249, 0.98)),
    rgba(226, 246, 253, 0.92);
  border-color: rgba(22, 134, 174, 0.42);
}

body[data-theme="light"] .chat-message.is-user .message-meta {
  color: #066f91;
}

body[data-theme="light"] .chat-message.is-user .message-content {
  color: #1d3145;
}

body[data-theme="light"] .settings-modal-backdrop,
body[data-theme="light"] .chat-action-modal-backdrop,
body[data-theme="light"] .docs-modal-backdrop {
  background: rgba(226, 238, 246, 0.68);
}

body[data-theme="light"] .usage-track {
  background: rgba(222, 238, 247, 0.9);
  border-color: rgba(22, 134, 174, 0.32);
}

body[data-theme="light"] .theme-option.is-active,
body[data-theme="light"] .new-chat-button:hover,
body[data-theme="light"] .manage-docs-button:hover,
body[data-theme="light"] .logout-button:hover,
body[data-theme="light"] .logout-button:focus-visible {
  color: #ffffff;
  background: linear-gradient(135deg, #0797c7, #39bce8);
}

@media (prefers-reduced-motion: reduce) {
  .message-bubble.is-pending::after,
  .brain-outline,
  .brain-fold,
  .thinking-dots span {
    animation: none;
  }

  .thought-pulse {
    display: none;
  }
}

.message-bubble.is-error {
  border-color: rgba(255, 126, 126, 0.55);
  box-shadow:
    0 0 20px rgba(255, 126, 126, 0.08),
    inset 0 0 20px rgba(255, 126, 126, 0.05);
}

.message-meta {
  margin-bottom: 5px;
  color: var(--cyan-soft);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.message-content {
  margin: 0;
  overflow-wrap: anywhere;
  color: rgba(248, 251, 255, 0.94);
  font-size: clamp(14px, 0.92vw, 16px);
  line-height: 1.48;
}

.message-content.is-plain {
  white-space: pre-wrap;
}

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

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

.markdown-paragraph {
  margin: 0 0 12px;
  white-space: normal;
}

.markdown-heading {
  margin: 18px 0 8px;
  color: rgba(248, 251, 255, 0.98);
  font-size: clamp(15px, 1vw, 18px);
  font-weight: 760;
  line-height: 1.28;
}

.markdown-list {
  display: grid;
  gap: 5px;
  margin: 8px 0 16px;
  padding-left: 22px;
}

.markdown-list li {
  padding-left: 2px;
}

.markdown-list li[data-indent="1"] {
  margin-left: 18px;
}

.markdown-list li[data-indent="2"] {
  margin-left: 34px;
}

.markdown-list li[data-indent="3"] {
  margin-left: 50px;
}

.message-content strong {
  color: rgba(255, 255, 255, 0.98);
  font-weight: 760;
}

.message-content em {
  color: rgba(230, 245, 255, 0.96);
}

.message-content a {
  color: var(--cyan-soft);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.message-content del {
  color: rgba(190, 208, 222, 0.84);
}

.message-content code {
  padding: 1px 5px;
  color: var(--cyan-soft);
  background: rgba(2, 12, 28, 0.72);
  border: 1px solid rgba(77, 198, 232, 0.26);
  border-radius: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.92em;
}

.markdown-code-block {
  max-width: 100%;
  margin: 10px 0 16px;
  padding: 12px;
  overflow-x: auto;
  color: rgba(238, 248, 255, 0.96);
  background: rgba(1, 9, 22, 0.82);
  border: 1px solid rgba(77, 198, 232, 0.28);
  border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9em;
  line-height: 1.5;
  white-space: pre;
}

.markdown-code-block code {
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 0;
  font-size: 1em;
}

.markdown-blockquote {
  margin: 10px 0 16px;
  padding: 8px 12px;
  color: rgba(226, 242, 252, 0.96);
  background: rgba(6, 31, 63, 0.52);
  border-left: 3px solid var(--cyan-soft);
  border-radius: 8px;
}

.markdown-rule {
  height: 1px;
  margin: 16px 0;
  background: rgba(77, 198, 232, 0.34);
  border: 0;
}

.markdown-table-wrap {
  max-width: 100%;
  margin: 10px 0 16px;
  overflow-x: auto;
  border: 1px solid rgba(77, 198, 232, 0.32);
  border-radius: 10px;
}

.markdown-table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  background: rgba(1, 9, 22, 0.52);
  font-size: 0.92em;
}

.markdown-table th,
.markdown-table td {
  padding: 9px 11px;
  vertical-align: top;
  border-bottom: 1px solid rgba(77, 198, 232, 0.22);
  border-right: 1px solid rgba(77, 198, 232, 0.18);
}

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

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

.markdown-table th {
  color: var(--cyan-soft);
  background: rgba(8, 55, 88, 0.72);
  font-weight: 780;
}

/* Previous: light mode reused dark markdown foregrounds, making Cove responses nearly invisible on white bubbles. */
/* Success: light mode now overrides markdown foregrounds after the shared dark-theme rules. */
body[data-theme="light"] .message-content {
  color: #1d3145;
}

body[data-theme="light"] .markdown-heading,
body[data-theme="light"] .message-content strong {
  color: #102235;
}

body[data-theme="light"] .message-content em {
  color: #304a61;
}

body[data-theme="light"] .message-content del {
  color: #7a8fa2;
}

body[data-theme="light"] .message-content a {
  color: #066f91;
}

body[data-theme="light"] .message-content code {
  color: #075f7e;
  background: rgba(220, 239, 248, 0.86);
  border-color: rgba(22, 134, 174, 0.26);
}

body[data-theme="light"] .markdown-code-block {
  color: #172b3e;
  background: rgba(231, 244, 250, 0.94);
  border-color: rgba(22, 134, 174, 0.28);
}

body[data-theme="light"] .markdown-blockquote {
  color: #2b4358;
  background: rgba(224, 241, 249, 0.84);
}

body[data-theme="light"] .markdown-rule {
  background: rgba(22, 134, 174, 0.28);
}

body[data-theme="light"] .markdown-table-wrap {
  border-color: rgba(22, 134, 174, 0.24);
}

body[data-theme="light"] .markdown-table {
  background: rgba(245, 250, 253, 0.92);
}

body[data-theme="light"] .markdown-table th,
body[data-theme="light"] .markdown-table td {
  border-color: rgba(22, 134, 174, 0.18);
}

body[data-theme="light"] .markdown-table th {
  color: #075f7e;
  background: rgba(218, 239, 248, 0.88);
}

body[data-theme="light"] .copy-response-button {
  color: #38566e;
}

body[data-theme="light"] .copy-response-button:hover {
  color: #066f91;
  background: rgba(57, 188, 232, 0.13);
}

body[data-theme="light"] .message-bubble.is-pending {
  color: #1d3145;
  background:
    radial-gradient(circle at 18% 18%, rgba(57, 188, 232, 0.14), transparent 30%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(232, 244, 250, 0.98)),
    rgba(255, 255, 255, 0.88);
}

body[data-theme="light"] .thinking-copy {
  color: #1d3145;
}

body[data-theme="light"] .brain-outline {
  fill: rgba(223, 241, 249, 0.9);
  stroke: rgba(22, 134, 174, 0.82);
}

body[data-theme="light"] .brain-fold {
  stroke: rgba(37, 69, 95, 0.72);
}

body[data-theme="light"] .thought-pulse {
  fill: #087ea4;
}

.message-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}

.copy-response-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  color: rgba(245, 248, 251, 0.82);
  background: transparent;
  border: 0;
  border-radius: 4px;
}

.copy-response-button:hover {
  color: var(--cyan-soft);
  background: rgba(140, 236, 255, 0.08);
}

.copy-response-button:disabled {
  cursor: default;
  opacity: 0.82;
}

.copy-response-button svg {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.prompt-bar {
  position: relative;
  z-index: 2;
  right: auto;
  bottom: auto;
  left: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 54px;
  align-items: end;
  justify-self: center;
  width: min(980px, calc(100% - clamp(72px, 10.8vw, 192px)));
  margin-bottom: clamp(24px, 4vh, 38px);
  min-height: 60px;
  padding: 7px 8px 7px 24px;
  background:
    linear-gradient(180deg, rgba(4, 26, 55, 0.92), rgba(1, 11, 28, 0.96)),
    rgba(3, 13, 30, 0.88);
  border: 1px solid var(--line-bright);
  border-radius: 30px;
  box-shadow:
    0 0 24px rgba(39, 216, 247, 0.13),
    inset 0 0 28px rgba(0, 120, 255, 0.08);
}

.prompt-bar textarea {
  min-width: 0;
  height: 42px;
  min-height: 42px;
  max-height: 176px;
  padding: 9px 0;
  color: var(--ink);
  background: transparent;
  font-size: clamp(15px, 0.95vw, 17px);
  line-height: 1.45;
  resize: none;
  overflow-y: hidden;
  scrollbar-color: rgba(8, 220, 255, 0.62) rgba(2, 12, 28, 0.86);
}

.prompt-bar textarea:focus-visible {
  outline: none;
}

.prompt-bar textarea::placeholder {
  color: #7589a1;
  opacity: 1;
}

.send-button {
  display: grid;
  align-self: end;
  place-items: center;
  width: 48px;
  height: 48px;
  color: #001026;
  background: linear-gradient(135deg, var(--cyan), #13a7ff);
  border: 1px solid rgba(119, 243, 255, 0.9);
  border-radius: 15px;
  box-shadow: 0 0 18px rgba(39, 216, 247, 0.3);
}

.send-button svg {
  width: 27px;
  height: 27px;
  fill: currentColor;
}

.prompt-bar.is-busy,
.prompt-bar.is-busy .send-button {
  cursor: wait;
}

.prompt-bar.is-busy .send-button {
  opacity: 0.72;
}

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

.docs-modal-shell {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  padding: clamp(16px, 3vw, 34px);
}

.docs-modal-shell.is-open {
  display: grid;
  place-items: center;
}

.chat-action-modal-shell {
  position: fixed;
  inset: 0;
  z-index: 12;
  display: none;
  padding: 18px;
}

.chat-action-modal-shell.is-open {
  display: grid;
  place-items: center;
}

.docs-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 3, 10, 0.72);
  backdrop-filter: blur(8px);
}

.chat-action-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 3, 10, 0.74);
  backdrop-filter: blur(8px);
}

.docs-modal {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(1180px, 100%);
  height: min(760px, calc(100vh - 48px));
  overflow: hidden;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(5, 20, 43, 0.98), rgba(1, 8, 22, 0.98)),
    rgba(3, 13, 30, 0.96);
  border: 1px solid rgba(77, 198, 232, 0.72);
  border-radius: 8px;
  box-shadow:
    0 26px 80px rgba(0, 0, 0, 0.58),
    inset 0 0 38px rgba(39, 216, 247, 0.08);
}

.chat-action-modal {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto auto;
  width: min(460px, 100%);
  overflow: hidden;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(5, 20, 43, 0.98), rgba(1, 8, 22, 0.98)),
    rgba(3, 13, 30, 0.96);
  border: 1px solid rgba(77, 198, 232, 0.72);
  border-radius: 8px;
  box-shadow:
    0 26px 80px rgba(0, 0, 0, 0.58),
    0 0 34px rgba(39, 216, 247, 0.12),
    inset 0 0 34px rgba(39, 216, 247, 0.08);
}

.chat-action-modal.is-rename {
  width: min(360px, 100%);
}

.docs-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 78px;
  padding: 18px 22px;
  border-bottom: 1px solid rgba(68, 136, 188, 0.58);
}

.chat-action-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 72px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(68, 136, 188, 0.58);
}

.chat-action-modal.is-rename .chat-action-modal-header {
  min-height: auto;
  padding: 20px 20px 8px;
  border-bottom: 0;
}

.modal-header-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.save-status {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.save-status.is-error {
  color: #ffb4b4;
}

.modal-kicker {
  display: block;
  margin-bottom: 4px;
  color: var(--cyan-soft);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.docs-modal-header h2,
.docs-modal h3 {
  margin: 0;
  color: var(--ink);
}

.docs-modal-header h2 {
  font-size: clamp(22px, 2vw, 30px);
  font-weight: 650;
}

.chat-action-modal h2 {
  margin: 0;
  color: var(--ink);
  font-size: 22px;
  font-weight: 650;
}

.chat-action-modal.is-rename .modal-kicker,
.chat-action-modal.is-rename .modal-icon-button {
  display: none;
}

.chat-action-modal.is-rename h2 {
  font-size: 20px;
}

.docs-modal h3 {
  font-size: 16px;
  font-weight: 650;
}

.modal-icon-button,
.modal-action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(7, 35, 66, 0.92), rgba(2, 14, 32, 0.94)),
    rgba(3, 13, 30, 0.86);
  border: 1px solid rgba(77, 198, 232, 0.55);
  box-shadow: inset 0 0 18px rgba(39, 216, 247, 0.07);
}

.modal-icon-button {
  width: 40px;
  height: 40px;
  border-radius: 8px;
}

.modal-icon-button.small {
  width: 34px;
  height: 34px;
}

.modal-icon-button:hover,
.modal-action-button:hover {
  color: var(--cyan-soft);
  border-color: rgba(140, 236, 255, 0.86);
}

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

.docs-modal-body {
  display: grid;
  grid-template-columns: minmax(145px, 0.7fr) minmax(330px, 2fr) minmax(300px, 1.6fr);
  min-height: 0;
}

.doc-list-panel,
.doc-editor-panel,
.doc-instructions-panel {
  min-width: 0;
  min-height: 0;
  padding: 18px;
}

.doc-list-panel,
.doc-editor-panel {
  border-right: 1px solid rgba(68, 136, 188, 0.58);
}

.doc-list-toolbar,
.panel-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.doc-list-toolbar {
  margin-bottom: 12px;
}

.doc-list {
  display: grid;
  gap: 8px;
  overflow-y: auto;
  max-height: calc(100% - 48px);
}

.doc-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  min-height: 52px;
  padding: 8px 10px;
  color: var(--ink);
  text-align: left;
  background: rgba(5, 23, 45, 0.5);
  border: 1px solid rgba(47, 137, 201, 0.42);
  border-radius: 8px;
}

.doc-row.is-selected {
  background:
    linear-gradient(180deg, rgba(9, 51, 87, 0.96), rgba(2, 18, 42, 0.96)),
    rgba(5, 23, 45, 0.9);
  border-color: rgba(140, 236, 255, 0.82);
  box-shadow:
    0 0 18px rgba(39, 216, 247, 0.18),
    inset 0 0 22px rgba(39, 216, 247, 0.08);
}

.doc-row-icon {
  color: var(--cyan-soft);
}

.doc-row-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.doc-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 620;
}

.doc-actions {
  display: flex;
  gap: 8px;
}

.modal-action-button {
  gap: 8px;
  min-height: 36px;
  padding: 0 11px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 650;
}

.modal-action-button.danger {
  border-color: rgba(255, 126, 126, 0.42);
}

.modal-action-button.danger:not(:hover) {
  color: #ffd4d4;
}

.modal-action-button.danger:hover {
  color: #ffd4d4;
  border-color: rgba(255, 126, 126, 0.72);
}

.modal-action-button.primary {
  color: #03111d;
  background: linear-gradient(180deg, rgba(144, 239, 255, 0.96), rgba(68, 199, 233, 0.94));
  border-color: rgba(168, 245, 255, 0.92);
  box-shadow: 0 0 18px rgba(39, 216, 247, 0.18);
}

.modal-action-button.primary:hover {
  color: #00101d;
  border-color: rgba(213, 252, 255, 0.98);
}

.modal-action-button:disabled,
.modal-icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.modal-action-button[aria-busy="true"] {
  cursor: wait;
  opacity: 0.78;
}

.chat-action-form {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.chat-action-modal.is-rename .chat-action-form {
  gap: 12px;
  padding: 8px 20px 20px;
}

.chat-action-input-row {
  display: grid;
  gap: 8px;
}

.chat-action-input-row[hidden],
.chat-action-message[hidden] {
  display: none;
}

.chat-action-input-row label {
  color: var(--cyan-soft);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.chat-action-modal.is-rename .chat-action-input-row label {
  display: none;
}

.chat-action-input {
  width: 100%;
  height: 44px;
  padding: 0 13px;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(3, 17, 37, 0.92), rgba(0, 8, 20, 0.96)),
    rgba(3, 13, 30, 0.84);
  border: 1px solid rgba(77, 198, 232, 0.62);
  border-radius: 8px;
  box-shadow: inset 0 0 20px rgba(39, 216, 247, 0.05);
  font-size: 15px;
  font-weight: 650;
}

.chat-action-modal.is-rename .chat-action-input {
  height: 42px;
  font-weight: 600;
}

.chat-action-input:disabled {
  opacity: 0.64;
}

.chat-action-message {
  margin: 0;
  color: rgba(248, 251, 255, 0.94);
  font-size: 15px;
  font-weight: 650;
  line-height: 1.42;
  overflow-wrap: anywhere;
}

.chat-action-status {
  min-height: 18px;
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.chat-action-status[hidden] {
  display: none;
}

.chat-action-status.is-error {
  color: #ffb4b4;
}

.chat-action-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.doc-name-input,
.doc-textarea,
.instructions-textarea {
  width: 100%;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(3, 17, 37, 0.92), rgba(0, 8, 20, 0.96)),
    rgba(3, 13, 30, 0.84);
  border: 1px solid rgba(77, 198, 232, 0.52);
  border-radius: 8px;
  box-shadow: inset 0 0 20px rgba(39, 216, 247, 0.05);
}

.doc-name-input {
  height: 44px;
  margin: 14px 0 12px;
  padding: 0 13px;
  font-size: 15px;
  font-weight: 650;
}

.doc-textarea,
.instructions-textarea {
  min-height: 0;
  padding: 14px;
  resize: none;
  font-size: 14px;
  line-height: 1.45;
}

.doc-textarea {
  height: calc(100% - 108px);
}

.delete-confirmation {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  margin: -2px 0 12px;
  padding: 8px;
  color: var(--ink);
  background: rgba(61, 16, 24, 0.52);
  border: 1px solid rgba(255, 126, 126, 0.48);
  border-radius: 8px;
}

.delete-confirmation[hidden] {
  display: none;
}

.delete-confirmation span {
  margin-right: auto;
  color: #ffd4d4;
  font-size: 13px;
  font-weight: 700;
}

.doc-list-message {
  margin: 6px 2px;
  color: var(--muted);
  font-size: 13px;
}

.instructions-textarea {
  height: calc(100% - 48px);
  margin-top: 14px;
}

@media (max-width: 1020px) {
  .docs-modal-body {
    grid-template-columns: 180px minmax(0, 1fr);
    grid-template-rows: minmax(330px, 1fr) minmax(220px, 0.78fr);
  }

  .doc-list-panel {
    grid-row: 1 / span 2;
  }

  .doc-editor-panel {
    border-right: 0;
    border-bottom: 1px solid rgba(68, 136, 188, 0.58);
  }

  .doc-instructions-panel {
    grid-column: 2;
  }
}

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

  .chat-sidebar {
    padding-inline: 16px;
  }

  .brand-strip {
    margin-inline: -16px;
    padding-inline: 20px;
  }

  .chat-canvas {
    grid-template-rows: minmax(0, 1fr) auto;
    align-content: stretch;
    padding: 28px 36px 36px;
  }

  .user-pill,
  .cove-pill,
  .response-panel,
  .prompt-bar {
    position: relative;
    inset: auto;
    width: min(100%, 720px);
  }

  .chat-canvas {
    display: grid;
    align-content: start;
    gap: 28px;
    padding-bottom: 36px;
  }

  .user-pill {
    justify-self: end;
    max-width: 520px;
  }

  .cove-pill,
  .response-panel {
    justify-self: start;
  }

  .prompt-bar {
    justify-self: stretch;
    width: 100%;
    margin-top: 0;
  }
}

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

  .chat-app {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .chat-sidebar {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid rgba(54, 137, 197, 0.55);
  }

  .history-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    max-height: none;
  }

  .history-row {
    min-height: 48px;
    border: 1px solid rgba(31, 83, 124, 0.55);
    border-radius: 10px;
  }

  .sidebar-footer {
    margin-top: 24px;
  }

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

  .theme-toggle {
    width: 100%;
  }

  .chat-main {
    grid-template-rows: minmax(0, 1fr);
    min-height: 100vh;
  }

  .chat-canvas {
    height: 100vh;
    min-height: 560px;
    padding: 32px 18px 28px;
  }

  .chat-message {
    max-width: 100%;
  }

  .message-pill {
    min-height: 64px;
    font-size: 17px;
  }

  .cove-pill,
  .user-pill {
    gap: 14px;
    padding-right: 22px;
  }

  .cove-avatar {
    width: 50px;
    height: 50px;
  }

  .response-panel {
    min-height: 250px;
    padding: 92px 24px 28px;
    border-radius: 24px;
  }

  .cove-avatar.large {
    top: 22px;
    left: 24px;
    width: 56px;
    height: 56px;
  }

  .prompt-bar {
    grid-template-columns: minmax(0, 1fr) 58px;
    min-height: 70px;
    padding-left: 18px;
  }

  .send-button {
    width: 52px;
    height: 52px;
    border-radius: 17px;
  }

  .docs-modal-shell {
    padding: 10px;
  }

  .docs-modal {
    height: calc(100vh - 20px);
  }

  .docs-modal-header {
    min-height: 68px;
    padding: 14px;
  }

  .docs-modal-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(300px, 1fr) minmax(260px, 0.8fr);
    overflow-y: auto;
  }

  .doc-list-panel,
  .doc-editor-panel,
  .doc-instructions-panel {
    padding: 14px;
    border-right: 0;
  }

  .doc-list-panel,
  .doc-editor-panel {
    border-bottom: 1px solid rgba(68, 136, 188, 0.58);
  }

  .doc-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: none;
  }

  .doc-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .doc-textarea {
    height: 250px;
  }

  .instructions-textarea {
    height: 220px;
  }
}
