/* ============================================================
 * 跨境工具舱 · styles.css
 * 极简科技风 (Linear / shadcn) · 双主题
 * ============================================================ */

/* ── Design Tokens ── */
:root, [data-theme="dark"] {
  --bg:        #09090b;
  --bg-subtle: #101012;
  --bg-hover:  #18181b;
  --border:    #27272a;
  --border-strong: #3f3f46;
  --text:      #fafafa;
  --text-2:    #a1a1aa;
  --text-3:    #52525b;
  --accent:    #6366f1;
  --accent-soft: rgba(99,102,241,.12);
  --ring:      rgba(99,102,241,.35);
  --radius:    10px;
  --radius-sm: 6px;
  --shadow-md: 0 4px 24px rgba(0,0,0,.35);
  --tag-cn:    rgba(251,191,36,.15);
  --tag-cn-text: #fbbf24;
  --tag-intl:  rgba(56,189,248,.15);
  --tag-intl-text: #38bdf8;
}
[data-theme="light"] {
  --bg: #ffffff;  --bg-subtle: #fafafa;  --bg-hover: #f4f4f5;
  --border: #e4e4e7;  --border-strong: #d4d4d8;
  --text: #18181b;  --text-2: #52525b;  --text-3: #a1a1aa;
  --accent: #6366f1; --accent-soft: rgba(99,102,241,.08);
  --ring: rgba(99,102,241,.25);
  --shadow-md: 0 4px 24px rgba(0,0,0,.08);
  --tag-cn: rgba(251,191,36,.12);
  --tag-cn-text: #d97706;
  --tag-intl: rgba(56,189,248,.12);
  --tag-intl-text: #0284c7;
}

/* ── Reset & Base ── */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', 'Noto Sans SC', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: "";
  position: fixed; inset: 0;
  background: radial-gradient(600px at 50% -100px, var(--accent-soft), transparent);
  pointer-events: none; z-index: 0;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font: inherit; color: inherit; background: none; border: none; outline: none; }
::selection { background: var(--accent-soft); }

/* ── Topbar ── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  height: 56px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.topbar-inner {
  max-width: 1200px; margin: 0 auto;
  height: 100%; display: flex; align-items: center;
  gap: 16px; padding: 0 20px;
}
.topbar-logo {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 600; flex-shrink: 0;
}
.logo-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-soft);
}
.search-trigger {
  flex: 1; max-width: 420px;
  display: flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-3); font-size: 13px;
  transition: all .15s ease;
}
.search-trigger:hover { border-color: var(--border-strong); color: var(--text-2); }
.search-trigger svg { flex-shrink: 0; opacity: .6; }
.search-trigger span { flex: 1; }
.search-trigger kbd {
  font-family: ui-monospace, 'SF Mono', monospace;
  font-size: 11px; padding: 2px 6px;
  border: 1px solid var(--border); border-radius: 4px;
  color: var(--text-3); line-height: 1.2;
}
.topbar-actions { display: flex; gap: 8px; margin-left: auto; flex-shrink: 0; }
.theme-toggle {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  transition: all .15s ease;
}
.theme-toggle:hover { background: var(--bg-hover); color: var(--text); }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* ── Layout ── */
.layout {
  max-width: 1200px; margin: 0 auto;
  display: flex; gap: 0;
  padding: 0 20px 100px;
  position: relative; z-index: 1;
}

/* ── Sidebar ── */
.sidebar {
  width: 200px; flex-shrink: 0;
  position: sticky; top: 72px;
  height: calc(100vh - 72px);
  overflow-y: auto; padding: 20px 0;
  border-right: 1px solid var(--border);
  margin-right: 28px;
  scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }
.sb-label {
  font-size: 11px; font-weight: 600;
  color: var(--text-3); text-transform: uppercase;
  letter-spacing: .06em;
  padding: 0 12px; margin-bottom: 6px;
}
.sb-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 12px; border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-2);
  transition: all .12s ease;
  cursor: pointer; border-left: 2px solid transparent;
  margin-bottom: 1px;
}
.sb-item:hover { color: var(--text); background: var(--bg-hover); }
.sb-item.active {
  color: var(--text); background: var(--accent-soft);
  border-left-color: var(--accent);
}
.sb-item .sb-count {
  font-size: 11px; font-family: ui-monospace, monospace;
  color: var(--text-3); min-width: 18px; text-align: right;
}
.sb-divider {
  height: 1px; background: var(--border);
  margin: 10px 12px;
}
.sb-fav { display: flex; align-items: center; gap: 6px; }
.sb-fav svg { width: 14px; height: 14px; fill: var(--tag-cn-text); }

/* ── Content ── */
.content { flex: 1; min-width: 0; padding-top: 20px; }

/* ── Filter Bar ── */
.filter-bar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 24px; flex-wrap: wrap;
}
.filter-bar input {
  height: 36px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-subtle); font-size: 13px;
  width: 200px; transition: border-color .15s;
}
.filter-bar input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--ring); }
.segmented {
  display: inline-flex;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden;
}
.seg {
  padding: 6px 14px; font-size: 13px;
  color: var(--text-2); transition: all .12s ease;
  border-right: 1px solid var(--border);
}
.seg:last-child { border-right: none; }
.seg:hover { color: var(--text); }
.seg.active {
  background: var(--accent); color: #fff;
  border-color: transparent;
}
.seg.active + .seg { border-left-color: transparent; }
.filter-count {
  font-size: 12px; font-family: ui-monospace, monospace;
  color: var(--text-3); margin-left: auto;
}
.filter-count b { color: var(--accent); font-weight: 600; }

/* ── Section ── */
.tool-section { margin-bottom: 32px; }
.tool-section { scroll-margin-top: 72px; }
.tool-section.hidden { display: none; }
.section-head {
  display: flex; align-items: baseline; gap: 10px;
  margin-bottom: 14px;
}
.section-title {
  font-size: 15px; font-weight: 600;
}
.section-en {
  font-size: 11px; font-family: ui-monospace, monospace;
  color: var(--text-3); letter-spacing: .04em;
}
.section-count {
  font-size: 11px; font-family: ui-monospace, monospace;
  color: var(--text-3); margin-left: auto;
}

/* ── Tool Card Grid ── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}
.tool-card {
  position: relative;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px;
  background: var(--bg-subtle);
  transition: all .15s ease;
  cursor: pointer;
  display: flex; flex-direction: column; gap: 6px;
}
.tool-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-hover);
  transform: translateY(-1px);
}
.tool-card.hidden { display: none; }
.card-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
}
.card-name {
  font-size: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-actions { display: flex; gap: 4px; flex-shrink: 0; }
.card-fav {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px; color: var(--text-3);
  transition: all .12s; opacity: 0;
}
.tool-card:hover .card-fav { opacity: 1; }
.card-fav.active { opacity: 1 !important; color: var(--tag-cn-text); }
.card-fav svg { width: 14px; height: 14px; }
.card-ext {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px; color: var(--text-3);
  opacity: 0; transition: all .12s;
}
.tool-card:hover .card-ext { opacity: .7; }
.tool-card:hover .card-ext:hover { opacity: 1; color: var(--accent); }
.card-ext svg { width: 14px; height: 14px; }
.card-desc {
  font-size: 13px; color: var(--text-2);
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
  line-height: 1.45;
}
.card-tag {
  display: inline-block;
  font-size: 11px; padding: 2px 7px;
  border-radius: 4px; font-weight: 500;
  align-self: flex-start;
}
.card-tag.cn { background: var(--tag-cn); color: var(--tag-cn-text); }
.card-tag.intl { background: var(--tag-intl); color: var(--tag-intl-text); }

/* ── Card Flash (Agent 定位高亮) ── */
.tool-card.flash {
  animation: cardFlash 1.6s ease forwards;
}
@keyframes cardFlash {
  0%   { box-shadow: 0 0 0 0 var(--ring); }
  25%  { box-shadow: 0 0 0 3px var(--ring); border-color: var(--accent); }
  100% { box-shadow: 0 0 0 0 transparent; border-color: var(--border); }
}

/* ── Empty State ── */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--text-3); font-size: 14px;
  font-family: ui-monospace, monospace;
}

/* ── ⌘K Command Palette ── */
.palette {
  position: fixed; z-index: 200;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: 0; border: none;
  max-width: none; max-height: none;
  width: 100%; height: 100%;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 18vh;
}
.palette:not([open]) { display: none; }
.palette::backdrop { background: rgba(0,0,0,.55); }
.palette-inner {
  width: 560px; max-width: calc(100vw - 32px);
  background: var(--bg-subtle);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transform: translateY(0);
}
.palette[open] .palette-inner {
  animation: paletteIn .15s ease;
}
@keyframes paletteIn {
  from { opacity: 0; transform: translateY(-4px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.palette-search {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.palette-search svg { color: var(--text-3); flex-shrink: 0; }
.palette-search input {
  flex: 1; font-size: 15px; color: var(--text);
}
.palette-search input::placeholder { color: var(--text-3); }
.palette-search kbd {
  font-size: 10px; font-family: ui-monospace, monospace;
  padding: 2px 5px; border: 1px solid var(--border);
  border-radius: 3px; color: var(--text-3);
}
.palette-results {
  max-height: 360px; overflow-y: auto;
  padding: 6px;
}
.palette-results::-webkit-scrollbar { width: 6px; }
.palette-results::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.palette-group-label {
  font-size: 11px; font-weight: 600;
  color: var(--text-3); padding: 8px 10px 4px;
  text-transform: uppercase; letter-spacing: .04em;
}
.palette-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background .1s;
}
.palette-item:hover, .palette-item.selected {
  background: var(--bg-hover);
}
.palette-item.selected {
  box-shadow: inset 0 0 0 1px var(--border-strong);
}
.pi-name { font-size: 13px; font-weight: 500; flex-shrink: 0; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pi-desc { font-size: 12px; color: var(--text-2); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pi-cat { font-size: 11px; color: var(--text-3); font-family: ui-monospace, monospace; flex-shrink: 0; }
.palette-empty {
  padding: 40px 20px; text-align: center;
  color: var(--text-3); font-size: 13px;
}
.palette-hint {
  display: flex; gap: 16px; justify-content: center;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  font-size: 11px; color: var(--text-3);
  font-family: ui-monospace, monospace;
}

/* ── Agent FAB ── */

/* Agent Messages */
.msg { display: flex; flex-direction: column; gap: 8px; max-width: 92%; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.bot  { align-self: flex-start; }
.bubble {
  padding: 10px 14px; border-radius: 12px;
  font-size: 13px; line-height: 1.6;
}
.msg.user .bubble {
  background: var(--accent); color: #fff;
  border-bottom-right-radius: 4px;
}
.msg.bot .bubble {
  background: var(--bg-hover); color: var(--text);
  border-bottom-left-radius: 4px;
}

/* Step Cards (timeline) */
.steps-wrap { display: flex; flex-direction: column; gap: 0; padding-left: 2px; }
.step-card {
  position: relative;
  padding: 0 0 16px 32px;
}
.step-card:last-child { padding-bottom: 0; }
.step-card::before {
  content: "";
  position: absolute; left: 8px; top: 20px; bottom: 0;
  width: 1px; background: var(--border);
}
.step-card:last-child::before { display: none; }
.step-dot {
  position: absolute; left: 3px; top: 4px;
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: var(--bg-subtle);
}
.step-content {
  background: var(--bg-subtle);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12.5px; line-height: 1.55;
}
.step-no {
  font-family: ui-monospace, monospace;
  font-size: 10px; color: var(--accent);
  font-weight: 600; letter-spacing: .04em;
}
.step-ttl {
  color: var(--text); font-weight: 600;
  margin: 2px 0 4px;
}
.step-tip { color: var(--text-2); font-size: 12px; }
.tool-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tool-chip {
  font-size: 11.5px;
  padding: 3px 8px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; transition: all .12s;
  display: inline-flex; align-items: center; gap: 3px;
}
.tool-chip:hover { border-color: var(--accent); color: var(--accent); }
.tool-chip.locate:hover { background: var(--accent-soft); }

/* Quick Questions */
.quick-row { display: flex; flex-wrap: wrap; gap: 6px; align-self: flex-start; }
.quick-q {
  font-size: 12px; color: var(--text-2);
  border: 1px solid var(--border); border-radius: 16px;
  padding: 6px 12px; transition: all .12s;
}
.quick-q:hover { border-color: var(--accent); color: var(--accent); }

/* Typing indicator */
.typing { display: flex; gap: 4px; padding: 8px 0; }
.typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-3);
  animation: bounce 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce {
  0%, 80%, 100% { transform: scale(.6); opacity: .4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Error box */
.ap-error {
  background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.3);
  color: #fca5a5; font-size: 12px; border-radius: var(--radius-sm);
  padding: 8px 11px; line-height: 1.5;
}

/* ── Hero: AI 顾问入口 ── */
.hero { margin: 8px 0 28px; scroll-margin-top: 72px; }
.hero-input-wrap { position: relative; display: flex; align-items: center; }
.hero-input-wrap input {
  flex: 1; height: 52px; padding: 0 52px 0 18px;
  font-size: 15px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--bg-subtle);
  transition: border-color .15s, box-shadow .15s;
}
.hero-input-wrap input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.hero-send {
  position: absolute; right: 8px;
  width: 38px; height: 38px; border-radius: 9px;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  border: none; cursor: pointer;
}
.hero .quick-row { margin-top: 10px; }

/* ── Chat Area（对话区内嵌文档流）── */
.chat-area {
  margin-top: 14px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-subtle); overflow: hidden;
  animation: chatIn .2s ease;
}
.chat-area.hidden { display: none; }
@keyframes chatIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-head {
  display: flex; align-items: center; justify-content: space-between;
  height: 40px; padding: 0 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12px; color: var(--text-2);
}
.chat-status { display: flex; align-items: center; gap: 6px; }
.chat-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex-shrink: 0; }
.chat-status .dot.online { background: #22c55e; }
.chat-status .dot.offline { background: #ef4444; }
.chat-clear { font-size: 12px; color: var(--text-3); transition: color .15s; cursor: pointer; border: none; background: none; }
.chat-clear:hover { color: var(--text); }
.chat-body {
  max-height: 55vh; overflow-y: auto;
  padding: 16px; display: flex; flex-direction: column; gap: 12px;
}
.chat-body::-webkit-scrollbar { width: 5px; }
.chat-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Agent FAB（回到对话）── */
.agent-fab {
  position: fixed; right: 24px; bottom: 24px; z-index: 150;
  width: 48px; height: 48px;
  border-radius: var(--radius);
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-md);
  transition: all .15s ease;
}
.agent-fab:hover { transform: scale(1.06); box-shadow: 0 8px 30px rgba(99,102,241,.35); }
.agent-fab.hidden { display: none; }

/* ── Mobile ── */
@media (max-width: 1023px) {
  .sidebar { display: none; }
}
@media (max-width: 640px) {
  .topbar-inner { padding: 0 14px; }
  .layout { padding: 0 14px 100px; }
  .filter-bar input { width: 100%; }
  .card-grid { grid-template-columns: 1fr; }
  .agent-fab { right: 16px; bottom: 16px; }
  .chat-body { max-height: 50vh; }
  .hero-input-wrap input { font-size: 14px; }
  .palette-inner { width: calc(100vw - 24px); }
  .palette { padding-top: 12vh; }
  .palette-hint { gap: 8px; font-size: 10px; flex-wrap: wrap; }
}
