:root {
      --bg: #030914;
      --line: rgba(52, 113, 157, 0.35);
      --line-soft: rgba(52, 113, 157, 0.18);
      --text: #d8f0ff;
      --muted: #79a9c5;
      --cyan: #14f0ff;
      --violet: #8875ff;
      --max: 1360px;
    }
    * { box-sizing: border-box; }
    html, body { margin: 0; padding: 0; }
    body {
      font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif;
      color: var(--text);
      background:
        radial-gradient(1000px 420px at 50% -8%, rgba(20, 240, 255, 0.08), transparent 60%),
        radial-gradient(900px 380px at 20% 10%, rgba(136, 117, 255, 0.1), transparent 60%),
        linear-gradient(transparent 95%, rgba(34, 88, 128, 0.08) 96%),
        linear-gradient(90deg, transparent 95%, rgba(34, 88, 128, 0.08) 96%),
        var(--bg);
      background-size: auto, auto, 36px 36px, 36px 36px, auto;
      min-height: 100vh;
      display: flex;
      flex-direction: column;
    }
    a { color: inherit; text-decoration: none; }
    .container { width: min(var(--max), calc(100% - 40px)); margin: 0 auto; }

    .topbar {
      position: sticky;
      top: 0;
      z-index: 40;
      backdrop-filter: blur(8px);
      background: rgba(2, 8, 18, 0.75);
      border-bottom: 1px solid var(--line-soft);
    }
    .nav {
      min-height: 70px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 14px;
    }
    .brand {
      display: flex;
      align-items: center;
      gap: 10px;
      font-weight: 700;
      white-space: nowrap;
    }
    .brand-dot {
      width: 30px;
      height: 30px;
      border-radius: 9px;
      background: linear-gradient(130deg, var(--violet), var(--cyan));
      box-shadow: 0 0 28px rgba(20, 240, 255, 0.45);
    }
    .brand-logo {
      display: none;
      width: 30px;
      height: 30px;
      border-radius: 9px;
      object-fit: cover;
      box-shadow: 0 0 20px rgba(20, 240, 255, 0.25);
    }
    .menu { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 14px; }
    .menu-item { position: relative; }
    .menu-item::before {
      content: "";
      position: absolute;
      left: 0;
      right: 0;
      top: 100%;
      height: 12px;
    }
    .menu-toggle {
      border: 1px solid transparent;
      border-radius: 10px;
      background: transparent;
      color: inherit;
      padding: 8px 12px;
      cursor: pointer;
      font-size: 13px;
      font-family: "Orbitron", "Noto Sans SC", sans-serif;
      display: inline-flex;
      align-items: center;
      gap: 6px;
    }
    .menu-toggle:hover, .menu-item.open .menu-toggle {
      border-color: var(--line);
      color: #e9f9ff;
      background: rgba(10, 24, 46, 0.7);
    }
    .caret { font-size: 11px; transition: transform 0.2s ease; }
    .menu-item.open .caret { transform: rotate(180deg); }
    .submenu {
      display: none;
      list-style: none;
      margin: 8px 0 0;
      padding: 8px;
      min-width: 172px;
      position: absolute;
      left: 0;
      top: 100%;
      border: 1px solid var(--line);
      border-radius: 12px;
      background: rgba(4, 14, 30, 0.96);
      box-shadow: 0 18px 38px rgba(0, 0, 0, 0.42);
      z-index: 60;
    }
    .menu-item.open .submenu { display: block; }
    .submenu a {
      display: block;
      padding: 8px 10px;
      border-radius: 8px;
      color: #b9ddf0;
      white-space: nowrap;
      font-size: 13px;
    }
    .submenu a:hover { background: rgba(20, 240, 255, 0.15); color: #e8fcff; }
    .submenu-num {
      display: inline-block;
      min-width: 1.6em;
      margin-right: 6px;
      font-family: "Orbitron", ui-monospace, monospace;
      font-size: 11px;
      color: rgba(20, 240, 255, 0.8);
      letter-spacing: 0.04em;
      vertical-align: middle;
    }
    .btn {
      border: 1px solid transparent;
      border-radius: 12px;
      padding: 11px 18px;
      font-size: 14px;
      cursor: pointer;
      background: linear-gradient(120deg, var(--cyan), #52fff8);
      color: #02131a;
      font-weight: 700;
      font-family: "Orbitron", "Noto Sans SC", sans-serif;
    }
    .btn.ghost {
      background: rgba(10, 24, 46, 0.85);
      color: #d5ecfb;
      border: 1px solid var(--line);
      padding: 8px 14px;
      font-size: 13px;
      font-weight: 600;
    }
    .btn.ghost:hover {
      border-color: rgba(20, 240, 255, 0.45);
      color: #f0fbff;
    }
    .user-actions { display: flex; align-items: center; gap: 8px; }
    .user-link {
      border: 1px solid var(--line);
      border-radius: 10px;
      padding: 9px 12px;
      color: #d7f5ff;
      background: rgba(8, 20, 41, 0.65);
      font-size: 13px;
    }
    .logout-btn {
      border: 1px solid rgba(255, 150, 150, 0.35);
      border-radius: 10px;
      padding: 9px 12px;
      color: #ffd3d3;
      background: rgba(58, 20, 20, 0.55);
      cursor: pointer;
      font-size: 13px;
    }

    main { flex: 1; display: flex; flex-direction: column; }

    .tools-wrap {
      flex: 1 1 auto;
      min-height: 0;
      display: grid;
      grid-template-columns: 220px 1fr;
      grid-template-rows: 1fr;
      align-items: stretch;
      gap: 16px;
      padding: 24px 0 40px;
    }
    .coming-card {
      display: none;
      margin: 34px 0 40px;
      border: 1px solid var(--line);
      border-radius: 14px;
      background: rgba(8, 20, 41, 0.72);
      padding: 32px;
      text-align: center;
    }
    .coming-card h1 { margin: 0 0 12px; }
    .coming-card p { margin: 0; color: #9fc5dd; }
    .tools-side {
      border: 1px solid var(--line);
      border-radius: 14px;
      background: rgba(8, 20, 41, 0.7);
      padding: 10px;
      height: fit-content;
      position: sticky;
      top: 92px;
    }
    .tools-side button {
      width: 100%;
      text-align: left;
      border: 1px solid transparent;
      border-radius: 10px;
      background: transparent;
      color: var(--muted);
      padding: 10px 12px;
      cursor: pointer;
      margin: 4px 0;
      font-size: 13px;
    }
    .tools-side button:hover,
    .tools-side button.active {
      border-color: var(--line);
      color: #e9f9ff;
      background: rgba(20, 240, 255, 0.12);
    }
    .tools-main {
      border: 1px solid var(--line);
      border-radius: 14px;
      background: rgba(8, 20, 41, 0.72);
      padding: 18px 18px 22px;
      min-height: 460px;
      position: relative;
      overflow: hidden;
    }
    /* 对话内嵌在主卡片内：打开时隐藏标题与列表；主卡片随网格行拉高，对话区铺满卡片 */
    .tools-main.tool-chat-open {
      display: flex;
      flex-direction: column;
      min-height: 0;
      height: 100%;
    }
    .tools-main.tool-chat-open .tool-chat-mask.show {
      flex: 1 1 auto;
      min-height: 0;
    }
    .tools-main.tool-chat-open .tools-main-head,
    .tools-main.tool-chat-open .tool-panel {
      display: none !important;
    }
    .tools-main h1 {
      margin: 0 0 8px;
      font-size: 24px;
      letter-spacing: 0.04em;
    }
    .tools-main-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 14px;
      margin-bottom: 14px;
    }
    .tools-bar-search {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 8px;
      margin-bottom: 14px;
    }
    .tools-bar-search .store-search-input,
    .tools-bar-search .tools-search-input {
      flex: 1 1 200px;
      min-width: 0;
      margin-left: 0;
    }
    .tools-bar-search .btn {
      flex: 0 0 auto;
    }
    .store-search-input {
      width: min(360px, 100%);
      border: 1px solid var(--line);
      border-radius: 10px;
      background: rgba(6, 17, 34, 0.8);
      color: #dff5ff;
      padding: 10px 12px;
      outline: none;
      margin-left: auto;
    }
    .tools-main .desc {
      margin: 0 0 16px;
      color: #9fc5dd;
      font-size: 13px;
      line-height: 1.7;
    }
    .tool-panel { display: none; }
    .tool-panel.active { display: block; }
    .tool-grid { display: grid; gap: 12px; }
    .store-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .tool-card {
      border: 1px solid var(--line-soft);
      border-radius: 12px;
      padding: 12px;
      background: rgba(9, 23, 46, 0.72);
      color: #cce8f8;
      min-height: 122px;
      cursor: pointer;
      display: grid;
      grid-template-rows: auto 1fr auto;
      gap: 8px;
      transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
      position: relative;
    }
    .tool-card:hover {
      transform: translateY(-2px);
      border-color: rgba(20, 240, 255, 0.38);
      box-shadow: 0 10px 24px rgba(8, 28, 52, 0.5);
      background: rgba(12, 27, 51, 0.84);
    }
    a.tool-card.tool-card-doc {
      text-decoration: none;
      color: inherit;
      cursor: pointer;
    }
    a.tool-card.tool-card-doc .doc-cta {
      font-size: 12px;
      color: #5ce0ff;
      font-weight: 600;
    }
    .tool-card-top { display: flex; align-items: center; gap: 10px; min-height: 38px; }
    .tool-card-logo {
      width: 34px;
      height: 34px;
      border-radius: 9px;
      border: 1px solid var(--line-soft);
      background: rgba(255, 255, 255, 0.06);
      object-fit: cover;
      flex: 0 0 auto;
    }
    .tool-card-logo-fallback {
      width: 34px;
      height: 34px;
      border-radius: 9px;
      border: 1px solid rgba(20, 240, 255, 0.35);
      background: linear-gradient(135deg, rgba(20, 240, 255, 0.28), rgba(136, 117, 255, 0.32));
      color: #eafaff;
      font-size: 14px;
      font-weight: 700;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      flex: 0 0 auto;
    }
    .tool-card .t {
      font-weight: 700;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      margin: 0;
    }
    .tool-card .s {
      color: #86acc4;
      font-size: 12px;
      line-height: 1.65;
      display: -webkit-box;
      line-clamp: 2;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
      margin: 0;
    }
    .tool-card .meta { color: #8ecbe8; font-size: 12px; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
    .tool-card .p { color: #e6f9ff; font-weight: 700; }
    .tool-card .c { color: #a6c7da; max-width: 55%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right; }
    .tool-card-badge {
      position: absolute;
      right: 10px;
      top: 10px;
      font-size: 12px;
      line-height: 1;
      font-weight: 700;
    }
    .tool-card-action {
      position: absolute;
      right: 10px;
      top: 10px;
      -webkit-appearance: none;
      appearance: none;
      border: 0;
      border-bottom: 0;
      border-radius: 999px;
      background: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 100%);
      background-clip: padding-box;
      color: #fff;
      padding: 6px 14px;
      font-size: 12px;
      font-weight: 700;
      line-height: 1;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      overflow: hidden;
    }
    .tool-card-action.no {
      border: 1px solid rgba(148, 163, 184, 0.35);
      border-bottom: 1px solid rgba(148, 163, 184, 0.35);
      background: linear-gradient(180deg, #fafbff 0%, #f4f6fd 100%);
      color: #9aa3c7;
    }
    .tool-card-cancel {
      position: absolute;
      right: 10px;
      bottom: 10px;
      border: 1px solid rgba(148, 163, 184, 0.28);
      border-radius: 999px;
      background: rgba(255, 255, 255, 0.06);
      color: #9fb3c8;
      padding: 5px 10px;
      font-size: 12px;
      line-height: 1;
      cursor: pointer;
    }
    .tool-card-cancel:hover {
      border-color: rgba(255, 90, 90, 0.48);
      color: #ffd0d0;
      background: rgba(255, 90, 90, 0.08);
    }
    .tool-card-cancel:disabled { opacity: 0.55; cursor: not-allowed; }
    .tools-search-row { margin-bottom: 14px; }
    .tools-search-input {
      width: min(480px, 100%);
      border: 1px solid var(--line);
      border-radius: 10px;
      background: rgba(6, 17, 34, 0.8);
      color: #dff5ff;
      padding: 10px 12px;
      outline: none;
    }
    .store-section { margin-bottom: 32px; }
    .store-head {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 10px;
      color: #dff5ff;
    }
    .store-head h3 { margin: 0; font-size: 21px; }
    .store-page-actions { display: flex; gap: 8px; }
    .store-page-actions button {
      width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line);
      background: rgba(10, 24, 46, 0.75); color: #cdeeff; cursor: pointer;
    }
    .store-page-actions button:disabled { opacity: 0.35; cursor: not-allowed; }
    .tool-modal-mask {
      position: fixed; inset: 0; display: none; z-index: 90;
      background: rgba(1, 5, 12, 0.7); backdrop-filter: blur(4px);
      align-items: center; justify-content: center; padding: 20px;
    }
    .tool-modal-mask.show { display: flex; }
    .tool-modal {
      width: min(520px, 100%);
      border: 1px solid var(--line);
      border-radius: 14px;
      background: rgba(8, 20, 41, 0.96);
      padding: 18px;
      position: relative;
      text-align: center;
    }
    .tool-modal-close {
      position: absolute; right: 12px; top: 12px; width: 30px; height: 30px;
      border: 1px solid var(--line); border-radius: 8px; background: transparent; color: #d8f0ff; cursor: pointer;
    }
    .tool-modal-logo-wrap {
      margin-top: 6px;
      margin-bottom: 10px;
      display: flex;
      align-items: center;
      justify-content: center;
      min-height: 72px;
    }
    .tool-modal-logo { width: 68px; height: 68px; object-fit: cover; border-radius: 14px; border: 1px solid var(--line-soft); background: rgba(255,255,255,0.06); }
    .tool-modal-logo-fallback {
      width: 68px;
      height: 68px;
      border-radius: 14px;
      border: 1px solid rgba(20, 240, 255, 0.35);
      background: linear-gradient(135deg, rgba(20, 240, 255, 0.28), rgba(136, 117, 255, 0.32));
      color: #eafaff;
      font-size: 24px;
      font-weight: 700;
      display: none;
      align-items: center;
      justify-content: center;
    }
    .tool-modal-name { margin: 0 0 8px; }
    .tool-modal-intro { margin: 0 0 12px; color: #9cc5dc; line-height: 1.75; white-space: pre-wrap; }
    .tool-modal-row { display: flex; justify-content: center; gap: 10px; margin-bottom: 8px; color: #b8d9ea; }
    .tool-modal-actions {
      display: flex;
      justify-content: center;
      gap: 10px;
      flex-wrap: wrap;
      margin-top: 12px;
    }
    .tool-modal-actions .btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      margin: 0;
    }
    .tool-chat-mask {
      position: static;
      z-index: auto;
      display: none;
      flex: 0 1 auto;
      flex-direction: column;
      min-height: 0;
      width: 100%;
      padding: 0;
      margin: 0;
      background: transparent;
    }
    .tool-chat-mask.show {
      display: flex;
    }
    .tool-chat-dialog {
      flex: 1 1 auto;
      min-height: 0;
      width: 100%;
      max-width: none;
      display: flex;
      flex-direction: column;
      border-radius: 12px;
      overflow: hidden;
      border: 1px solid var(--line);
      box-shadow: none;
      background:
        radial-gradient(520px 220px at 16% 12%, rgba(20, 240, 255, 0.14), transparent 62%),
        radial-gradient(460px 200px at 84% 18%, rgba(136, 117, 255, 0.14), transparent 62%),
        linear-gradient(transparent 95%, rgba(34, 88, 128, 0.08) 96%),
        linear-gradient(90deg, transparent 95%, rgba(34, 88, 128, 0.08) 96%),
        rgba(5, 15, 32, 0.98);
      background-size: auto, auto, 36px 36px, 36px 36px, auto;
      color: #f1f5f9;
    }
    .tool-chat-head {
      flex: 0 0 auto;
      height: 56px;
      border-bottom: 1px solid rgba(20, 240, 255, 0.14);
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0 16px;
      backdrop-filter: blur(4px);
      background: rgba(7, 20, 40, 0.56);
    }
    .tool-chat-title { font-size: 16px; font-weight: 700; }
    .tool-chat-close {
      width: 34px; height: 34px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.2);
      background: rgba(8, 23, 44, 0.7); color: #dff6ff; cursor: pointer; font-size: 18px;
    }
    .tool-chat-body {
      flex: 1 1 auto;
      min-height: 0;
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }
    .tool-chat-list {
      flex: 1 1 auto;
      min-height: 0;
      padding: 18px;
      overflow: auto;
      display: flex;
      flex-direction: column;
      gap: 10px;
    }
    .tool-msg {
      max-width: min(760px, 90%);
      padding: 12px 14px;
      border-radius: 12px;
      line-height: 1.65;
      white-space: pre-wrap;
      font-size: 15px;
      position: relative;
    }
    .tool-msg.user { align-self: flex-end; background: rgba(20, 240, 255, 0.15); border: 1px solid rgba(20,240,255,0.3); }
    .tool-msg.ai { align-self: flex-start; background: rgba(9, 24, 46, 0.72); border: 1px solid rgba(136,117,255,0.24); }
    .tool-msg.ai .ai-rich-heading { color: #1e293b; border-left-color: #8b5cf6; font-weight: 800; }
    .tool-msg.ai .ai-rich-subheading,
    .tool-msg.ai .ai-rich-kv strong { color: #475569; font-weight: 700; }
    .tool-msg.ai .ai-rich-p,
    .tool-msg.ai .ai-rich-text,
    .tool-msg.ai .ai-rich-kv span { color: #1a1f36; }
    .tool-msg-copy {
      position: absolute;
      right: 8px;
      top: 8px;
      border: 1px solid rgba(20, 240, 255, 0.24);
      background: rgba(7, 24, 44, 0.66);
      color: #c9f1ff;
      border-radius: 8px;
      padding: 2px 7px;
      font-size: 12px;
      cursor: pointer;
    }
    .tool-msg-text { display: block; padding-right: 52px; }
    .tool-chat-input-wrap {
      flex: 0 0 auto;
      border-top: 1px solid rgba(255, 255, 255, 0.08);
      padding: 12px 16px 16px;
    }
    .tool-chat-suggest {
      max-width: 900px;
      margin: 0 auto 10px;
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
    }
    .tool-chat-suggest button {
      border: 1px solid rgba(20, 240, 255, 0.22);
      background: rgba(10, 28, 52, 0.5);
      color: #bce6f9;
      border-radius: 999px;
      padding: 6px 10px;
      font-size: 12px;
      cursor: pointer;
    }
    .tool-chat-input-box {
      width: 100%;
      border: 1px solid rgba(255,255,255,0.15);
      border-radius: 14px;
      padding: 8px;
      display: flex;
      align-items: center;
      flex-wrap: nowrap;
      gap: 8px;
      background: rgba(255,255,255,0.04);
      box-sizing: border-box;
    }
    .tool-chat-left-actions {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      flex: 0 0 auto;
    }
    .tool-chat-attach {
      border: 1px solid rgba(20,240,255,0.28);
      border-radius: 10px;
      background: rgba(20,240,255,0.1);
      color: #d5f8ff;
      padding: 8px 10px;
      cursor: pointer;
      font-size: 13px;
      white-space: nowrap;
    }
    .tool-chat-input {
      border: 0; outline: none; background: transparent; color: #fff;
      padding: 8px; font-size: 14px;
      width: 100%;
      min-width: 0;
      flex: 1 1 auto;
    }
    .tool-chat-send {
      border: 1px solid rgba(20,240,255,0.3);
      border-radius: 10px;
      background: rgba(20,240,255,0.15);
      color: #dffcff;
      padding: 8px 12px;
      cursor: pointer;
      font-weight: 700;
      white-space: nowrap;
      flex: 0 0 auto;
    }
    .tool-chat-asset-line {
      max-width: 900px;
      margin: 0 auto 8px;
      color: #9fd2ea;
      font-size: 12px;
      display: flex;
      gap: 8px;
      align-items: center;
      min-height: 18px;
    }
    .tool-chat-asset-name { color: #d8f4ff; }

    footer {
      margin-top: auto;
      border-top: 1px solid var(--line-soft);
      color: #698ca4;
      font-size: 13px;
    }
    .foot-wrap { min-height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
    @media (max-width: 980px) {
      .tools-wrap {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
      }
      .tools-side { position: static; }
      .store-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    }
    @media (max-width: 900px) {
      .menu { display: none; }
    }
