/* ================================================================
   components.css — 通用可复用 UI 组件
   ================================================================ */

/* ---- 按钮 ---- */
.btn {
  border: 1px solid var(--line);
  background: white;
  color: #4d5a52;
  border-radius: 11px !important;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 650 !important;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition:
    background-color .18s ease,
    border-color .18s ease,
    color .18s ease,
    box-shadow .18s ease,
    transform .18s ease;
}

.btn svg {
  width: 15px;
  height: 15px;
}

.btn:hover {
  background: #f6f8f5;
}

.btn:active {
  transform: scale(.98);
}

.btn-primary,
.btn.primary,
button.primary {
  background: #18181b !important;
  color: #fff !important;
  border-color: #18181b !important;
}

.btn-primary:hover,
.btn.primary:hover {
  background: #27272a !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.btn-soft,
.btn-quiet,
.copy-mini,
.fold-copy {
  background: #f4f4f5 !important;
  color: #18181b !important;
  border: 1px solid #e4e4e7 !important;
}

.btn-soft:hover,
.btn-quiet:hover {
  background: #e4e4e7 !important;
}

.btn-danger {
  background: #fef2f2 !important;
  color: #ef4444 !important;
  border: 1px solid #fee2e2 !important;
}

.btn-danger:hover {
  background: #fee2e2 !important;
}

.btn-small {
  padding: 6px 14px;
  font-size: 12px;
}

.btn.copied-sparkle {
  background: #18181b !important;
  color: #fff !important;
  border-color: #18181b !important;
  position: relative;
  overflow: hidden;
}

.btn.copied-sparkle::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.4) 10%, transparent 60%);
  animation: sparkleBurst .35s ease-out forwards;
}

.linkbtn {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  padding: 6px;
}

/* ---- 搜索框 / 输入框 ---- */
.search {
  height: 38px;
  max-width: 470px;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line) !important;
  border-radius: 11px !important;
  background: #fff !important;
  padding: 0 12px;
  color: var(--ink) !important;
}

.search svg {
  width: 16px;
  flex-shrink: 0;
}

.search input {
  border: 0;
  outline: 0;
  min-width: 0;
  flex: 1;
  color: var(--ink);
  background: transparent;
}

.search:focus,
.field input:focus,
.field textarea:focus {
  border-color: #18181b !important;
  box-shadow: 0 0 0 4px rgba(24, 24, 27, 0.08) !important;
  transition: box-shadow .2s ease, border-color .2s ease !important;
}

/* ---- 表单字段 ---- */
.field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.field label {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line) !important;
  border-radius: 11px !important;
  padding: 10px 14px;
  background: #fff !important;
  color: var(--ink) !important;
  outline: none;
}

.field textarea {
  min-height: 120px;
  resize: vertical;
}

/* ---- 图标按钮 ---- */
.iconbtn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  background: white;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #66736b;
  flex-shrink: 0;
}

.iconbtn svg {
  width: 17px;
  height: 17px;
}

.icon-btn {
  background: transparent;
  color: #71717a;
  padding: 5px;
  border-radius: 8px;
}

.icon-btn:hover {
  background: #fff;
  color: #18181b;
}

/* ---- 头像（顶栏） ---- */
.top-actions .avatar {
  width: 38px !important;
  height: 38px !important;
  min-width: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 11px !important;
  background: #f4f4f5 !important;
  border: 1px solid #e4e4e7;
  color: #18181b !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  line-height: 1;
}

/* ---- 眉标 ---- */
.eyebrow {
  font-size: 11px;
  letter-spacing: 1.6px;
  color: var(--muted) !important;
  font-weight: 750;
  text-transform: uppercase;
}

.muted { color: var(--muted) !important; }
.small { font-size: 12px; color: var(--muted) !important; }
.author { font-size: 12px; color: #68776f; }

/* ---- Hero 横幅 ---- */
.hero {
  background: linear-gradient(120deg, #fff 0%, #fbfcfb 65%, #f4f4f5 100%) !important;
  border: 1px solid var(--line) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow) !important;
  padding: 28px 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  position: relative;
  overflow: hidden;
  margin-bottom: 22px;
}

.hero::after {
  content: "";
  position: absolute;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  border: 1px solid #b8c9bd66;
  right: 8%;
  top: -115px;
  box-shadow: 0 0 0 22px #b8c9bd18, 0 0 0 46px #b8c9bd12;
  pointer-events: none;
}

.hero h1 {
  font-size: 27px;
  letter-spacing: -.8px;
  line-height: 1.25;
  margin: 8px 0;
}

.hero p {
  color: #6e7c73;
  margin: 8px 0 0;
  max-width: 490px;
}

.hero-quote {
  position: relative;
  z-index: 1;
  color: #526b5e;
  font: italic 15px Georgia, serif;
  text-align: right;
  max-width: 180px;
}

.hero-info {
  flex: 1;
  min-width: 0;
  position: relative;
  z-index: 1;
}

.hero-top-row {
  display: flex;
  gap: 14px;
  align-items: center;
}

.hero-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

/* ---- 面板 ---- */
.panel {
  background: var(--card) !important;
  border: 1px solid var(--line) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow) !important;
  padding: 18px;
  margin-bottom: 14px;
}

.panel h3 {
  margin: 0 0 14px;
  font-size: 14px;
}

.panel-title {
  color: var(--ink) !important;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.content-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: text;
  font-size: 14px;
  color: var(--ink) !important;
  line-height: 1.8;
  max-height: none;
}

/* ---- 标签 ---- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px !important;
  background: var(--soft) !important;
  color: var(--ink) !important;
  border: 1px solid #e4e4e7 !important;
  border-radius: 999px !important;
  font-size: 10px;
}

.tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ---- 选项卡 ---- */
.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line) !important;
  margin-bottom: 14px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  border: 0;
  background: transparent;
  padding: 9px 11px;
  border-radius: 10px !important;
  color: var(--muted) !important;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  border-bottom: 2px solid transparent;
}

.tab.active {
  background: var(--soft) !important;
  color: var(--accent-dark) !important;
  box-shadow: none !important;
  font-weight: 650;
}

.tab-panel {
  display: grid;
  gap: 14px;
}

/* ---- 快速入口卡片（默认桌面 4 列） ---- */
.quickgrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 13px;
}

.quickcard {
  border: 1px solid var(--line) !important;
  border-radius: 14px;
  background: #fff !important;
  padding: 17px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: left;
  min-height: 133px;
  min-width: 0;
  color: var(--ink);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease !important;
}

.quickcard:hover {
  transform: translateY(-2px);
  border-color: #b9cbbf !important;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.06) !important;
}

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

.icowash {
  width: 35px;
  height: 35px;
  border-radius: 11px;
  background: var(--soft) !important;
  color: var(--accent-dark) !important;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.icowash.lav {
  background: var(--lav);
  color: #7968b3;
}

.icowash svg {
  width: 18px;
  height: 18px;
}

.quickcard strong {
  display: block;
  font-size: 14px;
  color: var(--accent-dark);
}

.quickcard small {
  color: var(--muted);
  display: block;
  margin-top: 3px;
  font-size: 11px;
}

/* ---- 资源卡 ---- */
.resourcegrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 13px;
}

.resource {
  border: 1px solid var(--line) !important;
  background: #fff;
  border-radius: 13px;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 11px;
  text-align: left;
  min-width: 0;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease !important;
}

.resource:hover {
  border-color: #b9c9bf !important;
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.resource strong {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
}

.resource small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 4px;
}

.thumb {
  width: 54px;
  height: 58px;
  border-radius: 9px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  color: #f9fbf8;
  font-size: 17px;
  font-weight: 600;
  overflow: hidden;
  background: linear-gradient(145deg, #b9c9bd, #657c70);
}

/* ---- 工具栏 ---- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 17px;
}

.toolbar-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted) !important;
}

/* ---- 空态 ---- */
.empty {
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #71717a;
  padding: 30px;
}

.empty-icon {
  width: 68px;
  height: 68px;
  background: #f4f4f5;
  border-radius: 20px;
  display: grid;
  place-items: center;
  font-size: 28px;
  color: #18181b;
  margin-bottom: 16px;
}

.empty-state {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  text-align: center;
}

/* ---- 弹窗 ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 26, 22, .5) !important;
  backdrop-filter: blur(5px) !important;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 10;
}

.modal-backdrop.show { display: flex; }

.modal {
  background: #fff !important;
  color: var(--ink) !important;
  width: min(480px, 100%);
  border-radius: 20px !important;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.2);
  padding: 22px;
  overscroll-behavior: contain;
}

.modal h2 { margin: 0; font-size: 17px; letter-spacing: -.025em; }
.modalhead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modalfoot, .modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.close { border: 0; background: #f2f4f1; border-radius: 8px; width: 30px; height: 30px; font-size: 19px; color: #67736b; }

/* ---- Toast ---- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(12px);
  z-index: 999999;
  background: #202b24 !important;
  color: #fff !important;
  padding: 10px 18px;
  border-radius: 9999px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.18) !important;
  border: 1px solid #3d5144 !important;
  max-width: 90vw;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: all .22s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  animation: toast-in .22s ease-out;
}

/* ---- 提示框 ---- */
.notice {
  padding: 11px 13px;
  border-radius: 12px !important;
  background: #f4f4f5 !important;
  border: 1px solid #e4e4e7 !important;
  color: #71717a !important;
  font-size: 12px;
  margin: 12px 0;
}

.token-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.token-badge.safe  { color: #2e7d32; background: #edf7ed; }
.token-badge.warn  { color: #ed6c02; background: #fff4e5; }
.token-badge.danger{ color: #d32f2f; background: #fdeeed; }

.detail-count { font-size: 11px; color: #71717a; }

.klv-switch {
  position: relative;
  width: 50px;
  height: 28px;
  appearance: none;
  -webkit-appearance: none;
  background: #e3e5e9;
  outline: none;
  border-radius: 99px;
  cursor: pointer;
  transition: background-color .28s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.klv-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  transition: transform .32s cubic-bezier(0.34, 1.56, 0.64, 1), width .2s ease !important;
}

.klv-switch:active::after { width: 28px !important; }
.klv-switch:checked { background: #18181b; }
.klv-switch:checked::after { transform: translateX(22px); }

.settingsrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid #e4e4e7 !important;
}

.settingsrow:last-child { border: 0; }
.settingsrow strong { font-size: 13px; }
.settingsrow p { font-size: 11px; color: var(--muted); margin: 3px 0 0; }

.settingsrow .btn {
  width: 70px !important;
  min-width: 70px !important;
  max-width: 70px !important;
  height: 32px !important;
  min-height: 32px !important;
  padding: 0 !important;
  border-radius: 10px !important;
  font-size: 12px !important;
  background: #f4f4f5 !important;
  color: #18181b !important;
  border: 1px solid #e4e4e7 !important;
  flex-shrink: 0 !important;
}

.development-panel {
  background: var(--card) !important;
  border: 1px solid var(--line) !important;
  border-radius: 18px !important;
  box-shadow: var(--shadow) !important;
  margin-top: 24px;
  padding: clamp(20px, 4vw, 36px);
  min-height: 280px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 10px;
}

.dropdown-capsule-wrap { position: relative; display: inline-block; }
.dropdown-capsule-btn {
  background: #fff;
  border: 1px solid var(--line);
  padding: 6px 14px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.dropdown-capsule-btn:active { transform: scale(0.97); }
.dropdown-capsule-arrow { font-size: 10px; color: var(--muted); transition: transform .24s ease; }
.dropdown-capsule-wrap.open .dropdown-capsule-arrow { transform: rotate(180deg); }

.dropdown-capsule-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 4px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
  min-width: 145px;
  z-index: 100;
  opacity: 0;
  transform: scale(0.92) translateY(-6px);
  pointer-events: none;
  transform-origin: top left;
  transition: all .2s cubic-bezier(0.16, 1, 0.3, 1);
}
.dropdown-capsule-menu.show { opacity: 1; transform: scale(1) translateY(0); pointer-events: auto; }
.dropdown-capsule-item { padding: 8px 12px; border-radius: 8px; font-size: 12px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: space-between; color: var(--ink); }
.dropdown-capsule-item:active { background: var(--soft); }

.peek-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 10000; opacity: 0; pointer-events: none;
  transition: opacity .25s ease;
}
.peek-backdrop.show { opacity: 1; pointer-events: auto; }
.context-active-peek {
  position: relative !important; z-index: 10001 !important;
  transform: scale(1.03) !important;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18) !important;
  border-color: #18181b !important;
}
.menu-popover {
  position: fixed; z-index: 10002; background: #fff;
  border: 1px solid #e4e4e7; border-radius: 16px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.15);
  display: none; flex-direction: column; min-width: 180px; overflow: hidden;
}
.menu-item { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; font-size: 13px; font-weight: 600; border-bottom: 1px solid #f4f4f5; cursor: pointer; color: #18181b; }
.menu-item:last-child { border-bottom: 0; }
.menu-item:active { background: #f4f4f5; }
.menu-item.danger { color: #ef4444; }

/* ================================================================
   移动端响应式 (≤760px)
   关键修复：强制 .quickgrid 永远为 2 列（2x2 网格），绝不退化为单列！
   ================================================================ */
@media (max-width: 760px) {
  .hero {
    padding: 18px 16px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 14px !important;
    align-items: stretch !important;
    margin-bottom: 17px;
    border-radius: 17px;
  }

  .hero::after {
    width: 130px;
    height: 130px;
    right: -52px;
    top: -75px;
    box-shadow: 0 0 0 12px rgba(184, 201, 189, 0.07);
    opacity: .25;
  }

  .hero-quote { display: none; }

  .hero h1 {
    font-size: 20px !important;
    line-height: 1.3;
  }

  .hero p {
    font-size: 13px;
    line-height: 1.7;
    max-width: 100%;
  }

  /* 核心：手机端永远保持 2 列，紧凑 2x2 排布 */
  .quickgrid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  .quickcard {
    min-height: 120px !important;
    padding: 13px !important;
    gap: 10px !important;
  }

  .quickcard strong {
    font-size: 13px;
  }

  .quickcard small {
    font-size: 10px;
  }

  .resourcegrid {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .panel {
    padding: 14px !important;
  }

  .tabs {
    padding: 10px 0 8px;
    max-width: 100%;
  }

  .tab {
    padding: 9px 11px;
  }

  button, .btn {
    min-height: 40px;
    max-width: 100%;
  }

  .modal-backdrop {
    padding: 10px !important;
    align-items: end !important;
  }

  .modal {
    max-height: 88dvh !important;
    border-radius: 20px 20px 14px 14px !important;
    padding: 17px !important;
  }

  .modal-actions {
    position: sticky;
    bottom: -17px;
    background: #fff;
    padding: 12px 0 2px;
    margin-top: 8px;
  }
}

/* ---- 折叠面板与复制按钮样式修复 ---- */
.fold-summary {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 12px;
  cursor: pointer;
  list-style: none !important;
  padding: 15px 18px !important;
}

/* 隐藏浏览器原生黑三角 ▸ */
.fold-summary::-webkit-details-marker,
.fold-summary::marker {
  display: none !important;
}

.fold-title {
  font-size: 11px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink) !important;
  font-weight: 700;
}

.fold-summary-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* 圆角胶囊复制按钮 */
.copy-mini {
  border: 1px solid #e4e4e7 !important;
  background: #f4f4f5 !important;
  color: #18181b !important;
  border-radius: 999px !important;
  padding: 5px 12px !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  white-space: nowrap !important;
  cursor: pointer;
}

.copy-mini:active {
  transform: scale(0.96);
  background: #e4e4e7 !important;
}

.panel-body {
  border-top: 1px solid var(--line);
}

