/* =========================================================
   知遇 · DeepSeek Harness AI 顾问
   ========================================================= */

.ai-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(247, 240, 227, 0.14);
  border-radius: 999px;
  color: #f5eddd;
  background: var(--forest);
  box-shadow: 0 5px 14px rgba(23, 54, 46, 0.12);
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s var(--ease);
}

.ai-trigger:hover {
  background: var(--forest-mid);
  border-color: rgba(247, 240, 227, 0.28);
  transform: translateY(-1px);
}

.ai-trigger svg {
  flex: none;
  color: #d8b57a;
}

.ai-trigger-dot {
  width: 5px;
  height: 5px;
  flex: none;
  border-radius: 50%;
  background: var(--muted-2);
  box-shadow: 0 0 0 2px rgba(247, 240, 227, 0.08);
}

.ai-trigger.is-ready .ai-trigger-dot {
  background: #8db79b;
  box-shadow: 0 0 0 2px rgba(141, 183, 155, 0.12);
}

.ai-trigger.is-offline .ai-trigger-dot {
  background: #d58c76;
  box-shadow: 0 0 0 2px rgba(213, 140, 118, 0.13);
}

.ai-trigger.is-loading .ai-trigger-dot {
  background: var(--gold);
  animation: ai-pulse 1.2s ease-in-out infinite;
}

.ai-context-launch svg {
  color: var(--gold);
}

body.ai-open {
  overflow: hidden;
}

.ai-scrim {
  position: fixed;
  inset: 0;
  z-index: 180;
  background: rgba(20, 26, 22, 0.34);
  backdrop-filter: blur(2px);
  animation: ai-fade-in 0.22s ease both;
}

.ai-panel {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 185;
  width: min(468px, 100vw);
  display: flex;
  flex-direction: column;
  color: var(--ink);
  background:
    radial-gradient(circle at 100% 0%, rgba(169, 133, 76, 0.09), transparent 19rem),
    linear-gradient(180deg, var(--card-raised), var(--paper) 47%);
  border-left: 1px solid var(--line-strong);
  box-shadow: -30px 0 80px rgba(21, 29, 23, 0.18);
  animation: ai-panel-in 0.42s var(--ease) both;
}

.ai-head {
  flex: none;
  padding: 23px 22px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 254, 251, 0.9), rgba(251, 250, 246, 0.72));
}

.ai-head-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.ai-head-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.ai-seal,
.ai-msg-seal {
  display: grid;
  place-items: center;
  flex: none;
  color: #e8d4ad;
  background:
    radial-gradient(circle at 28% 20%, rgba(255, 255, 255, 0.14), transparent 40%),
    var(--forest);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 50%;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.035), 0 5px 16px rgba(23, 54, 46, 0.16);
}

.ai-seal {
  width: 36px;
  height: 36px;
}

.ai-eyebrow {
  display: block;
  margin-bottom: 2px;
  color: var(--gold);
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: 0.17em;
  line-height: 1.2;
}

.ai-head h2 {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.ai-head-actions {
  display: flex;
  gap: 4px;
  flex: none;
}

.ai-icon-btn {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.ai-icon-btn:hover:not(:disabled) {
  color: var(--ink);
  background: var(--paper-deep);
  border-color: var(--line);
}

.ai-icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.ai-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.02em;
}

.ai-status i {
  width: 5px;
  height: 5px;
  flex: none;
  border-radius: 50%;
  background: var(--muted-2);
}

.ai-status.is-ready i {
  background: var(--jade);
  box-shadow: 0 0 0 3px rgba(47, 102, 83, 0.09);
}

.ai-status.is-offline i {
  background: var(--cinnabar);
  box-shadow: 0 0 0 3px rgba(178, 74, 52, 0.09);
}

.ai-status.is-loading i {
  background: var(--gold);
  animation: ai-pulse 1.2s ease-in-out infinite;
}

.ai-status-refresh {
  margin-left: auto;
  padding: 0;
  border: 0;
  color: var(--gold);
  background: transparent;
  font-family: var(--sans);
  font-size: 8px;
  line-height: 1;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ai-status-refresh:hover {
  color: var(--cinnabar);
}

.ai-context-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  margin-top: 9px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 254, 251, 0.6);
  font-size: 9px;
  line-height: 1.5;
}

.ai-context-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-context-chip.is-clickable {
  border: 1px solid var(--line);
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.ai-context-chip.is-clickable:hover {
  border-color: var(--line-strong);
  background: var(--paper);
}

.ai-context-chip svg {
  flex: none;
  color: var(--gold);
}

.ai-thread {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 22px 22px 12px;
  scroll-behavior: smooth;
}

.ai-thread::-webkit-scrollbar {
  width: 5px;
}

.ai-thread::-webkit-scrollbar-thumb {
  border-radius: 99px;
  background: var(--line-strong);
}

.ai-thread-date {
  margin-bottom: 17px;
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.14em;
  text-align: center;
  text-transform: uppercase;
}

.ai-empty {
  padding: 11px 2px 18px;
}

.ai-empty-kicker {
  color: var(--gold);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.16em;
}

.ai-empty h3 {
  margin: 10px 0 12px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 31px;
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 1.26;
}

.ai-empty-copy {
  max-width: 340px;
  margin: 0;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.9;
}

.ai-empty-loading {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 9px;
  padding-top: 28px;
}

.ai-empty-loading h3 {
  margin: 0;
  font-size: 21px;
}

.ai-empty-loading p {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
}

.ai-seal-large {
  width: 42px;
  height: 42px;
  margin-bottom: 3px;
}

.ai-suggestions {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 23px;
}

.ai-suggestion {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink-soft);
  background: rgba(255, 254, 251, 0.7);
  font-family: var(--sans);
  font-size: 10.5px;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s var(--ease);
}

.ai-suggestion svg {
  flex: none;
  color: var(--muted-2);
  transition: color 0.18s ease, transform 0.18s var(--ease);
}

.ai-suggestion:hover {
  border-color: var(--line-strong);
  background: var(--card-raised);
  transform: translateX(2px);
}

.ai-suggestion:hover svg {
  color: var(--cinnabar);
  transform: translateX(2px);
}

.ai-disclaimer {
  margin: 22px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted-2);
  font-size: 8px;
  line-height: 1.7;
}

.ai-setup {
  margin: 8px 0 18px;
  padding: 20px;
  border: 1px dashed var(--line-strong);
  border-radius: 13px;
  background: rgba(255, 254, 251, 0.68);
}

.ai-setup-icon {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  border-radius: 9px;
  color: var(--gold);
  background: var(--gold-soft);
}

.ai-setup h3 {
  margin: 12px 0 7px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.ai-setup p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 10px;
  line-height: 1.8;
}

.ai-setup .ai-setup-note {
  margin-top: 7px;
  color: var(--muted);
  font-size: 9px;
}

.ai-setup .btn {
  margin-top: 13px;
}

.ai-msg {
  animation: ai-message-in 0.3s var(--ease) both;
}

.ai-msg + .ai-msg {
  margin-top: 18px;
}

.ai-msg-user {
  display: flex;
  justify-content: flex-end;
}

.ai-user-bubble {
  max-width: 88%;
  padding: 9px 12px;
  border-radius: 13px 13px 4px 13px;
  color: #f8f1e4;
  background: var(--forest);
  box-shadow: 0 6px 18px rgba(23, 54, 46, 0.1);
  font-size: 11px;
  line-height: 1.75;
  word-break: break-word;
}

.ai-msg-assistant {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.ai-msg-seal {
  width: 26px;
  height: 26px;
  margin-top: 1px;
}

.ai-msg-body {
  flex: 1;
  min-width: 0;
}

.ai-msg-head {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin-bottom: 5px;
}

.ai-msg-head strong {
  color: var(--forest);
  font-family: var(--sans);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.ai-msg-head span {
  color: var(--muted-2);
  font-size: 8px;
}

.ai-answer {
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.88;
  word-break: break-word;
}

.ai-answer p {
  margin: 0 0 6px;
}

.ai-answer p:last-child {
  margin-bottom: 0;
}

.ai-answer ul,
.ai-answer ol {
  margin: 4px 0 8px;
  padding-left: 17px;
}

.ai-answer li {
  margin-bottom: 3px;
}

.ai-answer li::marker {
  color: var(--gold);
}

.ai-answer strong {
  color: var(--ink);
  font-weight: 600;
}

.ai-answer code {
  padding: 1px 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink-soft);
  background: var(--paper-deep);
  font-family: var(--mono);
  font-size: 9px;
}

.ai-answer-h {
  margin: 10px 0 5px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 600;
}

.ai-tool-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.ai-tool-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  background: rgba(255, 254, 251, 0.7);
  font-size: 7.5px;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-tool-chip svg {
  flex: none;
  color: var(--gold);
}

.ai-tool-chip.is-write {
  border-color: rgba(169, 133, 76, 0.32);
  color: #806434;
  background: var(--gold-soft);
}

.ai-tool-chip.is-error {
  border-color: var(--cinnabar-soft);
  color: var(--cinnabar);
}

.ai-msg-meta {
  margin-top: 5px;
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: 0.02em;
}

.ai-thinking {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 10px;
}

.ai-thinking i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--gold);
  animation: ai-dot 1.15s ease-in-out infinite;
}

.ai-thinking i:nth-child(2) {
  animation-delay: 0.14s;
}

.ai-thinking i:nth-child(3) {
  animation-delay: 0.28s;
}

.ai-thinking span {
  margin-left: 3px;
}

.ai-loading-note {
  margin: 5px 0 0;
  color: var(--muted-2);
  font-size: 8px;
}

.ai-compose-wrap {
  flex: none;
  padding: 10px 20px 15px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(244, 241, 234, 0), var(--paper) 24%);
}

.ai-error {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 8px;
  padding: 8px 9px;
  border: 1px solid rgba(178, 74, 52, 0.16);
  border-radius: 8px;
  color: var(--cinnabar-deep);
  background: var(--cinnabar-soft);
  font-size: 9px;
  line-height: 1.65;
}

.ai-error svg {
  flex: none;
  margin-top: 1px;
}

.ai-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 7px 7px 7px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--card-raised);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 7px 20px rgba(38, 34, 24, 0.035);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ai-composer:focus-within {
  border-color: var(--forest);
  box-shadow: 0 0 0 3px rgba(23, 54, 46, 0.07);
}

.ai-composer textarea {
  flex: 1;
  min-height: 34px;
  max-height: 112px;
  padding: 4px 0;
  border: 0;
  outline: 0;
  resize: none;
  color: var(--ink);
  background: transparent;
  font-family: var(--sans);
  font-size: 11px;
  line-height: 1.7;
}

.ai-composer textarea::placeholder {
  color: var(--muted-2);
}

.ai-composer textarea:disabled {
  opacity: 0.54;
}

.ai-send {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 9px;
  color: #f6eddb;
  background: var(--forest);
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s var(--ease), opacity 0.18s ease;
}

.ai-send:hover:not(:disabled) {
  background: var(--forest-mid);
  transform: translateY(-1px);
}

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

.ai-compose-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  margin-top: 6px;
  color: var(--muted-2);
  font-size: 7.5px;
  line-height: 1.4;
}

.ai-compose-hint span:last-child {
  text-align: right;
}

@keyframes ai-panel-in {
  from { opacity: 0; transform: translateX(22px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes ai-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes ai-message-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes ai-dot {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

@keyframes ai-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

@media (max-width: 1260px) {
  .ai-trigger span {
    display: none;
  }

  .ai-trigger {
    width: 30px;
    justify-content: center;
    gap: 4px;
    padding: 0;
  }

  .ai-trigger svg {
    width: 14px;
  }

  .ai-trigger-dot {
    display: none;
  }
}

@media (max-width: 680px) {
  .ai-panel {
    width: 100vw;
    border-left: 0;
  }

  .ai-head {
    padding: 18px 18px 13px;
  }

  .ai-head h2 {
    font-size: 20px;
  }

  .ai-thread {
    padding: 18px 18px 10px;
  }

  .ai-empty h3 {
    font-size: 27px;
  }

  .ai-suggestion {
    padding: 10px 11px;
  }

  .ai-compose-wrap {
    padding: 8px 14px 12px;
  }

  .ai-compose-hint span:first-child {
    display: none;
  }

  .ai-compose-hint {
    justify-content: flex-end;
  }

  .ai-msg-assistant {
    gap: 7px;
  }

  .ai-msg-seal {
    width: 23px;
    height: 23px;
  }

  .ai-user-bubble {
    max-width: 92%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ai-panel,
  .ai-scrim,
  .ai-msg,
  .ai-thinking i,
  .ai-trigger.is-loading .ai-trigger-dot {
    animation: none !important;
  }

  .ai-thread {
    scroll-behavior: auto;
  }
}
