docs/.vitepress/theme/components/HomeFeatures.vue

9c6588973e856dbc27ebb283f0d963c792faa8df
wotaku/docs/.vitepress/theme/components/HomeFeatures.vue history · blame · raw

1262 lines · 32161 bytes

   1<script setup lang="ts">
   2import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
   3import type { HomeCard } from '../../configs/constants'
   4
   5const props = defineProps<{ cards: HomeCard[] }>()
   6
   7const STORAGE_KEY = 'wotaku-home-cards-v2'
   8const PREFS_KEY = 'wotaku-home-prefs-v1'
   9
  10interface CardState {
  11  homepage: string[]
  12}
  13
  14function defaultState(): CardState {
  15  return {
  16    homepage: props.cards.filter((c) => c.featured).map((c) => c.id)
  17  }
  18}
  19
  20function loadState(): CardState {
  21  if (typeof window === 'undefined') return defaultState()
  22  try {
  23    const raw = localStorage.getItem(STORAGE_KEY)
  24    if (!raw) return defaultState()
  25    const parsed: CardState = JSON.parse(raw)
  26    const allIds = new Set(props.cards.map((c) => c.id))
  27    return { homepage: (parsed.homepage ?? []).filter((id) => allIds.has(id)) }
  28  } catch { return defaultState() }
  29}
  30
  31const mounted = ref(false)
  32const state = ref<CardState>(defaultState())
  33
  34onMounted(() => {
  35  state.value = loadState()
  36  const prefs = loadPrefs()
  37  columnMode.value = prefs.columnMode
  38  viewMode.value = prefs.viewMode
  39  mounted.value = true
  40})
  41
  42function save() {
  43  localStorage.setItem(STORAGE_KEY, JSON.stringify(state.value))
  44}
  45
  46const cardMap = computed(() => new Map(props.cards.map((c) => [c.id, c])))
  47
  48const homepageSet = computed(() => new Set(state.value.homepage))
  49
  50const visibleCards = computed(() =>
  51  state.value.homepage.map((id) => cardMap.value.get(id)!).filter(Boolean)
  52)
  53
  54const grid = computed(() => {
  55  const n = visibleCards.value.length
  56  if (n === 0) return undefined
  57  if (columnMode.value === 'max') return 'grid-max'
  58  if (n === 2) return 'grid-2'
  59  if (n === 3) return 'grid-3'
  60  if (n % 3 === 0) return 'grid-6'
  61  if (n > 3) return 'grid-4'
  62  return undefined
  63})
  64
  65const panelGrid = computed(() => {
  66  if (columnMode.value === 'max') return 'grid-max'
  67  const n = props.cards.length
  68  if (n === 2) return 'grid-2'
  69  if (n === 3) return 'grid-3'
  70  if (n % 3 === 0) return 'grid-6'
  71  if (n > 3) return 'grid-4'
  72  return undefined
  73})
  74
  75const KNOWN_PREFIXES = /^(lucide|mdi|ic|mingcute|material-symbols|simple-icons|uil|octicon|logos|akar-icons|map|bi|streamline-logos|streamline-ultimate|streamline-sharp|iconoir)-/
  76
  77function cardIcon(card: HomeCard) {
  78  return card.icon.replace(/:([A-Za-z0-9_+-]+):/g, (_, markup) => {
  79    const cls = KNOWN_PREFIXES.test(markup) ? markup : `twemoji-${markup}`
  80    return `<span class="i-${cls}"></span>`
  81  })
  82}
  83
  84/* ── Manager panel ── */
  85const panelOpen = ref(false)
  86const dropdownOpen = ref(false)
  87
  88type HelpSection = 'view' | 'columns'
  89const activeHelpSection = ref<HelpSection | null>(null)
  90const helpPopupEl = ref<HTMLDivElement | null>(null)
  91const helpPopupPos = ref({ top: -9999, left: -9999 })
  92
  93watch(dropdownOpen, (val) => {
  94  if (!val) {
  95    activeHelpSection.value = null
  96    helpPopupPos.value = { top: -9999, left: -9999 }
  97  }
  98})
  99
 100function toggleHelpSection(section: HelpSection, e: MouseEvent) {
 101  if (activeHelpSection.value === section) {
 102    activeHelpSection.value = null
 103    helpPopupPos.value = { top: -9999, left: -9999 }
 104    return
 105  }
 106  activeHelpSection.value = section
 107  helpPopupPos.value = { top: -9999, left: -9999 }
 108  const btn = e.currentTarget as HTMLElement
 109  const rect = btn.getBoundingClientRect()
 110  nextTick(() => {
 111    const popupW = helpPopupEl.value?.offsetWidth || 220
 112    const popupH = helpPopupEl.value?.offsetHeight || 160
 113    const margin = 8
 114    helpPopupPos.value = {
 115      left: Math.max(margin, rect.left - popupW - 8),
 116      top: Math.max(margin, Math.min(rect.top, window.innerHeight - popupH - margin)),
 117    }
 118  })
 119}
 120
 121watch(panelOpen, (open) => {
 122  if (typeof document !== 'undefined')
 123    document.body.style.overflow = open ? 'hidden' : ''
 124})
 125
 126function onKeydown(e: KeyboardEvent) {
 127  if (e.key === 'Escape') {
 128    panelOpen.value = false
 129    cardTooltip.value = null
 130  }
 131}
 132
 133onMounted(() => document.addEventListener('keydown', onKeydown))
 134onUnmounted(() => document.removeEventListener('keydown', onKeydown))
 135
 136function loadPrefs() {
 137  if (typeof window === 'undefined') return { columnMode: 'default' as const, viewMode: 'default' as const }
 138  try {
 139    const p = JSON.parse(localStorage.getItem(PREFS_KEY) ?? '{}')
 140    return {
 141      columnMode: p.columnMode === 'max' ? 'max' as const : 'default' as const,
 142      viewMode: p.viewMode === 'mini' ? 'mini' as const : 'default' as const
 143    }
 144  } catch { return { columnMode: 'default' as const, viewMode: 'default' as const } }
 145}
 146
 147const columnMode = ref<'default' | 'max'>('default')
 148const viewMode = ref<'default' | 'mini'>('default')
 149
 150watch([columnMode, viewMode], () => {
 151  localStorage.setItem(PREFS_KEY, JSON.stringify({
 152    columnMode: columnMode.value,
 153    viewMode: viewMode.value
 154  }))
 155})
 156
 157const homepageSectionCards = computed(() =>
 158  state.value.homepage.map((id) => cardMap.value.get(id)!).filter(Boolean)
 159)
 160
 161const otherSections = computed(() => {
 162  const sectionMap = new Map<string, HomeCard[]>()
 163  for (const card of props.cards) {
 164    const s = card.section ?? 'Pages'
 165    if (!sectionMap.has(s)) sectionMap.set(s, [])
 166    if (!homepageSet.value.has(card.id)) sectionMap.get(s)!.push(card)
 167  }
 168  return Array.from(sectionMap.entries()).map(([label, cards]) => ({ label, cards }))
 169})
 170
 171function toggleCard(id: string) {
 172  if (homepageSet.value.has(id)) {
 173    state.value.homepage = state.value.homepage.filter((hid) => hid !== id)
 174  } else {
 175    state.value.homepage.push(id)
 176  }
 177  save()
 178}
 179
 180function showAll() {
 181  const current = new Set(state.value.homepage)
 182  const toAdd = props.cards.filter((c) => !current.has(c.id)).map((c) => c.id)
 183  state.value.homepage = [...state.value.homepage, ...toAdd]
 184  save()
 185}
 186
 187function hideAll() {
 188  state.value.homepage = []
 189  save()
 190}
 191
 192function resetDefaults() {
 193  state.value = defaultState()
 194  columnMode.value = 'default'
 195  viewMode.value = 'default'
 196  save()
 197}
 198
 199const cardTooltip = ref<{ text: string; x: number; y: number } | null>(null)
 200
 201function showCardTooltip(e: MouseEvent, title: string) {
 202  if (!window.matchMedia('(hover: hover)').matches) return
 203  const rect = (e.currentTarget as HTMLElement).getBoundingClientRect()
 204  cardTooltip.value = { text: title, x: rect.left + rect.width / 2, y: rect.top }
 205}
 206
 207function hideCardTooltip() {
 208  cardTooltip.value = null
 209}
 210
 211/* ── Drag-to-reorder (homepage only, pointer events) ── */
 212const dragging = ref<string | null>(null)
 213const dragTarget = ref<string | null>(null)
 214const cardListEl = ref<HTMLElement | null>(null)
 215const ghostPos = ref<{ x: number; y: number } | null>(null)
 216
 217function onHandlePointerDown(e: PointerEvent, id: string) {
 218  e.preventDefault()
 219  dragging.value = id
 220  dragTarget.value = null
 221  ghostPos.value = { x: e.clientX, y: e.clientY }
 222  ;(e.currentTarget as HTMLElement).setPointerCapture(e.pointerId)
 223}
 224
 225function onHandlePointerMove(e: PointerEvent) {
 226  if (!dragging.value) return
 227  ghostPos.value = { x: e.clientX, y: e.clientY }
 228  const items = cardListEl.value?.querySelectorAll<HTMLElement>('[data-card-id]')
 229  if (!items) return
 230  for (const item of items) {
 231    const rect = item.getBoundingClientRect()
 232    if (
 233      e.clientX >= rect.left && e.clientX <= rect.right &&
 234      e.clientY >= rect.top && e.clientY <= rect.bottom
 235    ) {
 236      const id = item.dataset.cardId!
 237      if (id !== dragging.value) dragTarget.value = id
 238      break
 239    }
 240  }
 241}
 242
 243function onHandlePointerUp() {
 244  if (dragging.value && dragTarget.value) {
 245    const order = [...state.value.homepage]
 246    const from = order.indexOf(dragging.value)
 247    const to = order.indexOf(dragTarget.value)
 248    if (from !== -1 && to !== -1) {
 249      order.splice(from, 1)
 250      order.splice(to, 0, dragging.value)
 251      state.value.homepage = order
 252      save()
 253    }
 254  }
 255  dragging.value = null
 256  dragTarget.value = null
 257  ghostPos.value = null
 258}
 259</script>
 260
 261<template>
 262  <!-- ── Feature Grid ── -->
 263  <div class="home-features" :class="{ 'is-mounted': mounted }">
 264    <div class="container">
 265      <div class="card-toolbar">
 266        <button class="gear-btn" aria-label="Customize cards" @click="panelOpen = true">
 267          <span class="i-lucide-ellipsis" />
 268        </button>
 269      </div>
 270      <div class="items" :class="{ 'view-mini': viewMode === 'mini' }">
 271        <div
 272          v-for="card in visibleCards"
 273          :key="card.id"
 274          class="item"
 275          :class="grid"
 276        >
 277          <a class="card" :href="card.link">
 278            <article class="box">
 279              <div class="icon" v-html="cardIcon(card)" />
 280              <h2 class="title">{{ card.title }}</h2>
 281              <p class="details">{{ card.details }}</p>
 282            </article>
 283          </a>
 284        </div>
 285      </div>
 286    </div>
 287  </div>
 288
 289  <!-- ── Manager Panel ── -->
 290  <Teleport to="body">
 291    <Transition name="fade">
 292      <div v-if="panelOpen" class="backdrop" @click.self="panelOpen = false">
 293        <Transition name="slide-up" appear>
 294          <div v-if="panelOpen" class="panel" role="dialog" aria-modal="true" aria-label="Customize cards">
 295            <div class="panel-head">
 296              <span class="panel-title">Customize Cards</span>
 297              <button class="close-btn" aria-label="Close" @click="panelOpen = false">
 298                <span class="i-lucide-x" />
 299              </button>
 300            </div>
 301
 302            <div class="card-sections">
 303              <!-- Homepage section (draggable) -->
 304              <div class="section-label">Homepage</div>
 305              <ul ref="cardListEl" class="card-list" :class="panelGrid">
 306                <li v-if="homepageSectionCards.length === 0" class="empty-box">
 307                  <span class="empty-hint">No cards have been selected</span>
 308                </li>
 309                <li
 310                  v-for="card in homepageSectionCards"
 311                  :key="card.id"
 312                  :data-card-id="card.id"
 313                  class="card-row"
 314                  @mouseenter="showCardTooltip($event, card.title)"
 315                  @mouseleave="hideCardTooltip"
 316                  :class="{
 317                    'is-dragging': dragging === card.id,
 318                    'is-over': dragTarget === card.id && dragging !== card.id
 319                  }"
 320                >
 321                  <span
 322                    class="row-handle"
 323                    aria-hidden="true"
 324                    @pointerdown="onHandlePointerDown($event, card.id)"
 325                    @pointermove="onHandlePointerMove"
 326                    @pointerup="onHandlePointerUp"
 327                  >
 328                    <span class="i-lucide-grip-vertical" />
 329                  </span>
 330                  <span class="row-icon" v-html="cardIcon(card)" />
 331                  <span class="row-name">{{ card.title }}</span>
 332                  <button
 333                    class="row-toggle active"
 334                    aria-label="Remove from homepage"
 335                    @click="toggleCard(card.id)"
 336                  >
 337                    <span class="i-lucide-eye" />
 338                  </button>
 339                </li>
 340              </ul>
 341
 342              <!-- Other sections (Pages, Extensions, Other…) -->
 343              <template v-for="section in otherSections" :key="section.label">
 344                <div class="section-label">{{ section.label }}</div>
 345                <ul class="card-list" :class="panelGrid">
 346                  <li v-if="section.cards.length === 0" class="empty-box">
 347                    <span class="empty-hint">All cards from this section have been selected</span>
 348                  </li>
 349                  <li
 350                    v-for="card in section.cards"
 351                    :key="card.id"
 352                    class="card-row card-row-unselected"
 353                    @mouseenter="showCardTooltip($event, card.title)"
 354                    @mouseleave="hideCardTooltip"
 355                  >
 356                    <span class="row-handle-spacer" aria-hidden="true" />
 357                    <span class="row-icon" v-html="cardIcon(card)" />
 358                    <span class="row-name">{{ card.title }}</span>
 359                    <button
 360                      class="row-toggle"
 361                      aria-label="Add to homepage"
 362                      @click="toggleCard(card.id)"
 363                    >
 364                      <span class="i-lucide-eye-off" />
 365                    </button>
 366                  </li>
 367                </ul>
 368              </template>
 369            </div>
 370
 371            <div class="panel-foot">
 372              <div class="foot-group">
 373                <button class="tool-btn" aria-label="Show all" @click="showAll">
 374                  <span class="i-lucide-eye" />
 375                </button>
 376                <button class="tool-btn" aria-label="Hide all" @click="hideAll">
 377                  <span class="i-lucide-eye-off" />
 378                </button>
 379                <button class="tool-btn" aria-label="Reset to default" @click="resetDefaults">
 380                  <span class="i-lucide-refresh-ccw" />
 381                </button>
 382              </div>
 383              <div class="foot-group">
 384                <div class="settings-wrap">
 385                  <div v-if="dropdownOpen" class="dropdown-overlay" @click="dropdownOpen = false" />
 386                  <div v-if="dropdownOpen" class="settings-dropdown">
 387                    <div class="dropdown-section">
 388                      <div class="dropdown-section-header">
 389                        <span class="dropdown-label">
 390                          <span class="i-lucide-layout-list dropdown-label-icon" />
 391                          View
 392                        </span>
 393                        <button type="button" class="settings-help-btn" :class="{ active: activeHelpSection === 'view' }" aria-label="View help" @click.stop="toggleHelpSection('view', $event)">
 394                          <span class="i-carbon:help-filled settings-help-icon" />
 395                        </button>
 396                      </div>
 397                      <div class="dropdown-group">
 398                        <button class="tool-btn" :class="{ 'is-active': viewMode === 'default' }" @click="viewMode = 'default'">Default</button>
 399                        <button class="tool-btn" :class="{ 'is-active': viewMode === 'mini' }" @click="viewMode = 'mini'">Mini</button>
 400                      </div>
 401                    </div>
 402                    <div class="dropdown-section">
 403                      <div class="dropdown-section-header">
 404                        <span class="dropdown-label">
 405                          <span class="i-lucide-columns-3-cog dropdown-label-icon" />
 406                          Columns
 407                        </span>
 408                        <button type="button" class="settings-help-btn" :class="{ active: activeHelpSection === 'columns' }" aria-label="Columns help" @click.stop="toggleHelpSection('columns', $event)">
 409                          <span class="i-carbon:help-filled settings-help-icon" />
 410                        </button>
 411                      </div>
 412                      <div class="dropdown-group">
 413                        <button class="tool-btn" :class="{ 'is-active': columnMode === 'default' }" @click="columnMode = 'default'">Default</button>
 414                        <button class="tool-btn" :class="{ 'is-active': columnMode === 'max' }" @click="columnMode = 'max'">Max</button>
 415                      </div>
 416                    </div>
 417                  </div>
 418                  <button
 419                    class="tool-btn"
 420                    :class="{ 'is-active': dropdownOpen }"
 421                    aria-label="Display settings"
 422                    @click.stop="dropdownOpen = !dropdownOpen"
 423                  >
 424                    <span class="i-lucide-settings-2" />
 425                  </button>
 426                </div>
 427              </div>
 428            </div>
 429          </div>
 430        </Transition>
 431      </div>
 432    </Transition>
 433
 434    <div
 435      v-if="cardTooltip"
 436      class="card-tooltip"
 437      :style="{ left: cardTooltip.x + 'px', top: cardTooltip.y + 'px' }"
 438    >{{ cardTooltip.text }}</div>
 439
 440    <Transition name="help-popup-fade">
 441      <div
 442        v-if="activeHelpSection && dropdownOpen"
 443        ref="helpPopupEl"
 444        class="home-help-popup"
 445        :style="{ top: helpPopupPos.top + 'px', left: helpPopupPos.left + 'px' }"
 446      >
 447        <template v-if="activeHelpSection === 'view'">
 448          <h4 class="sh-title">
 449            <span class="i-lucide-layout-list sh-title-icon" />
 450            View
 451          </h4>
 452          <p class="sh-desc">Controls how cards are displayed on the homepage.</p>
 453          <div class="sh-options">
 454            <div class="sh-option">
 455              <strong>
 456                <span class="i-lucide-layout-grid sh-option-icon" />
 457                Default
 458              </strong>
 459              <span>Full card with icon, title, and description.</span>
 460            </div>
 461            <div class="sh-option">
 462              <strong>
 463                <span class="i-lucide-rows-3 sh-option-icon" />
 464                Mini
 465              </strong>
 466              <span>Compact row with icon and title only.</span>
 467            </div>
 468          </div>
 469        </template>
 470        <template v-else-if="activeHelpSection === 'columns'">
 471          <h4 class="sh-title">
 472            <span class="i-lucide-columns-3-cog sh-title-icon" />
 473            Columns
 474          </h4>
 475          <p class="sh-desc">Controls how many columns the card grid uses.</p>
 476          <div class="sh-options">
 477            <div class="sh-option">
 478              <strong>
 479                <span class="i-lucide-columns-2 sh-option-icon" />
 480                Default
 481              </strong>
 482              <span>Adapts automatically based on the number of cards.</span>
 483            </div>
 484            <div class="sh-option">
 485              <strong>
 486                <span class="i-lucide-columns-3 sh-option-icon" />
 487                Max
 488              </strong>
 489              <span>Always uses the maximum number of columns based on screen resolution.</span>
 490            </div>
 491          </div>
 492        </template>
 493      </div>
 494    </Transition>
 495
 496    <Transition name="ghost-fade">
 497      <div
 498        v-if="dragging && ghostPos"
 499        class="drag-ghost"
 500        :style="{ left: ghostPos.x + 'px', top: ghostPos.y + 'px' }"
 501      >
 502        <span class="row-icon" v-html="cardIcon(cardMap.get(dragging)!)" />
 503        <span class="drag-ghost-name">{{ cardMap.get(dragging)?.title }}</span>
 504      </div>
 505    </Transition>
 506  </Teleport>
 507</template>
 508
 509<style scoped>
 510/* ── Grid ── */
 511.home-features {
 512  position: relative;
 513  padding: 0 24px;
 514}
 515
 516.home-features .container {
 517  opacity: 0;
 518  transition: opacity 0.15s ease;
 519}
 520
 521.home-features.is-mounted .container {
 522  opacity: 1;
 523}
 524
 525@media (min-width: 640px) {
 526  .home-features { padding: 0 48px; }
 527}
 528
 529@media (min-width: 960px) {
 530  .home-features { padding: 0 64px; }
 531}
 532
 533.container {
 534  position: relative;
 535  margin: 0 auto;
 536  max-width: 1152px;
 537}
 538
 539.items {
 540  display: flex;
 541  flex-wrap: wrap;
 542  margin: -8px;
 543}
 544
 545.item {
 546  padding: 8px;
 547  width: 100%;
 548}
 549
 550@media (min-width: 640px) {
 551  .item.grid-2,
 552  .item.grid-4,
 553  .item.grid-6 { width: calc(100% / 2); }
 554}
 555
 556@media (min-width: 768px) {
 557  .item.grid-2,
 558  .item.grid-4 { width: calc(100% / 2); }
 559  .item.grid-3,
 560  .item.grid-6 { width: calc(100% / 3); }
 561}
 562
 563@media (min-width: 960px) {
 564  .item.grid-4 { width: calc(100% / 4); }
 565}
 566
 567@media (min-width: 640px) {
 568  .item.grid-max { width: calc(100% / 2); }
 569}
 570
 571@media (min-width: 768px) {
 572  .item.grid-max { width: calc(100% / 3); }
 573}
 574
 575@media (min-width: 960px) {
 576  .item.grid-max { width: calc(100% / 4); }
 577}
 578
 579/* ── Card ── */
 580.card {
 581  display: block;
 582  border: 2px solid #3d3d3d;
 583  border-radius: 12px;
 584  height: 100%;
 585  background-color: var(--vp-c-bg-soft);
 586  transition: border-color 0.25s, background-color 0.25s;
 587  text-decoration: none;
 588  color: inherit;
 589}
 590
 591.card:hover {
 592  border-color: var(--vp-c-brand-1);
 593}
 594
 595.card:active {
 596  transform: none;
 597}
 598
 599.box {
 600  display: flex;
 601  flex-direction: column;
 602  padding: 24px;
 603  height: 100%;
 604}
 605
 606.icon {
 607  display: flex;
 608  justify-content: center;
 609  align-items: center;
 610  margin-bottom: 20px;
 611  border-radius: 6px;
 612  background-color: var(--vp-c-default-soft);
 613  width: 48px;
 614  height: 48px;
 615  font-size: 27px;
 616  transition: background-color 0.25s;
 617}
 618
 619.title {
 620  line-height: 24px;
 621  font-size: 16px;
 622  font-weight: 600;
 623}
 624
 625.details {
 626  flex-grow: 1;
 627  padding-top: 8px;
 628  line-height: 24px;
 629  font-size: 14px;
 630  font-weight: 500;
 631  color: var(--vp-c-text-2);
 632}
 633
 634/* ── Mini View ── */
 635.view-mini .box {
 636  flex-direction: row;
 637  align-items: center;
 638  padding: 12px 16px;
 639  gap: 12px;
 640}
 641
 642.view-mini .icon {
 643  width: 32px;
 644  height: 32px;
 645  font-size: 18px;
 646  margin-bottom: 0;
 647  flex-shrink: 0;
 648}
 649
 650.view-mini .title {
 651  font-size: 14px;
 652  line-height: 1.3;
 653}
 654
 655.view-mini .details {
 656  display: none;
 657}
 658
 659/* ── Gear Button ── */
 660.card-toolbar {
 661  display: flex;
 662  justify-content: flex-end;
 663  margin-bottom: 4px;
 664}
 665
 666.gear-btn {
 667  background: none;
 668  border: none;
 669  padding: 4px;
 670  color: var(--vp-c-text-3, var(--vp-c-text-2));
 671  font-size: 18px;
 672  cursor: pointer;
 673  transition: color 0.2s;
 674  display: flex;
 675  align-items: center;
 676}
 677
 678.gear-btn:hover {
 679  color: var(--vp-c-brand-1);
 680}
 681
 682/* ── Backdrop ── */
 683.backdrop {
 684  position: fixed;
 685  inset: 0;
 686  z-index: 100;
 687  display: flex;
 688  align-items: center;
 689  justify-content: center;
 690  background: rgba(0, 0, 0, 0.5);
 691  backdrop-filter: blur(4px);
 692  overscroll-behavior: none;
 693  touch-action: none;
 694}
 695
 696@media (max-width: 767px) {
 697  .backdrop {
 698    align-items: stretch;
 699  }
 700}
 701
 702/* ── Panel ── */
 703.panel {
 704  width: min(520px, calc(100vw - 32px));
 705  max-height: 85vh;
 706  display: flex;
 707  flex-direction: column;
 708  border-radius: 16px;
 709  border: 2px solid #3d3d3d;
 710  background: var(--vp-c-bg);
 711}
 712
 713@media (max-width: 767px) {
 714  .panel {
 715    width: 100vw;
 716    height: 100vh;
 717    height: 100dvh;
 718    max-height: none;
 719    border-radius: 0;
 720    border: none;
 721  }
 722}
 723
 724@media (min-width: 768px) {
 725  .panel { width: min(720px, calc(100vw - 32px)); }
 726}
 727
 728@media (min-width: 960px) {
 729  .panel { width: min(940px, calc(100vw - 32px)); }
 730}
 731
 732.panel-head {
 733  display: flex;
 734  align-items: center;
 735  justify-content: space-between;
 736  padding: 10px 16px;
 737  border-bottom: 1px solid var(--vp-c-divider);
 738  flex-shrink: 0;
 739}
 740
 741.panel-title {
 742  font-size: 15px;
 743  font-weight: 600;
 744  color: var(--vp-c-text-1);
 745}
 746
 747.close-btn {
 748  position: relative;
 749  display: flex;
 750  align-items: center;
 751  justify-content: center;
 752  width: 28px;
 753  height: 28px;
 754  border-radius: 6px;
 755  border: none;
 756  background: transparent;
 757  color: var(--vp-c-text-2);
 758  font-size: 16px;
 759  cursor: pointer;
 760  transition: background 0.15s, color 0.15s;
 761}
 762
 763.close-btn:hover {
 764  background: var(--vp-c-bg-soft);
 765  color: var(--vp-c-text-1);
 766}
 767
 768.close-btn::after {
 769  content: attr(aria-label);
 770  position: absolute;
 771  top: calc(100% + 6px);
 772  right: 0;
 773  background: var(--vp-c-bg-soft);
 774  color: var(--vp-c-text-1);
 775  border: 1px solid var(--vp-c-divider);
 776  border-radius: 5px;
 777  padding: 3px 8px;
 778  font-size: 11px;
 779  white-space: nowrap;
 780  pointer-events: none;
 781  opacity: 0;
 782  transition: opacity 0.15s;
 783  z-index: 10;
 784}
 785
 786@media (hover: hover) {
 787  .close-btn:hover::after {
 788    opacity: 1;
 789  }
 790}
 791
 792/* ── Card List ── */
 793.card-sections {
 794  overflow-y: auto;
 795  min-height: 0;
 796  padding: 8px;
 797  display: flex;
 798  flex-direction: column;
 799  gap: 2px;
 800  touch-action: pan-y;
 801  overscroll-behavior: contain;
 802}
 803
 804.section-label {
 805  font-size: 11px;
 806  font-weight: 600;
 807  text-transform: uppercase;
 808  letter-spacing: 0.06em;
 809  color: var(--vp-c-text-3, var(--vp-c-text-2));
 810  padding: 8px 10px 2px;
 811}
 812
 813.section-label:first-child {
 814  padding-top: 2px;
 815}
 816
 817.card-list {
 818  list-style: none;
 819  margin: 0;
 820  padding: 0;
 821  display: grid;
 822  grid-template-columns: 1fr;
 823  gap: 2px;
 824}
 825
 826@media (min-width: 640px) {
 827  .card-list.grid-2,
 828  .card-list.grid-4,
 829  .card-list.grid-6,
 830  .card-list.grid-max { grid-template-columns: 1fr 1fr; }
 831}
 832
 833@media (min-width: 768px) {
 834  .card-list.grid-3,
 835  .card-list.grid-6,
 836  .card-list.grid-max { grid-template-columns: 1fr 1fr 1fr; }
 837}
 838
 839@media (min-width: 960px) {
 840  .card-list.grid-4,
 841  .card-list.grid-max { grid-template-columns: 1fr 1fr 1fr 1fr; }
 842}
 843
 844.card-row {
 845  display: flex;
 846  align-items: center;
 847  gap: 8px;
 848  padding: 7px 10px;
 849  border-radius: 8px;
 850  transition: background 0.15s, opacity 0.15s;
 851  user-select: none;
 852  min-width: 0;
 853}
 854
 855.card-row:hover {
 856  background: var(--vp-c-bg-soft);
 857}
 858
 859.card-row-unselected {
 860  opacity: 0.45;
 861}
 862
 863.card-row-unselected:hover {
 864  opacity: 1;
 865}
 866
 867.empty-box {
 868  grid-column: 1 / -1;
 869  list-style: none;
 870  border-radius: 8px;
 871  padding: 14px 16px;
 872  display: flex;
 873  align-items: center;
 874  justify-content: center;
 875  background-image:
 876    linear-gradient(90deg, var(--vp-c-divider) 6px, transparent 6px),
 877    linear-gradient(90deg, var(--vp-c-divider) 6px, transparent 6px),
 878    linear-gradient(0deg,  var(--vp-c-divider) 6px, transparent 6px),
 879    linear-gradient(0deg,  var(--vp-c-divider) 6px, transparent 6px);
 880  background-size: 10px 1px, 10px 1px, 1px 10px, 1px 10px;
 881  background-position: top left, bottom left, top left, top right;
 882  background-repeat: repeat-x, repeat-x, repeat-y, repeat-y;
 883}
 884
 885.empty-hint {
 886  font-size: 13px;
 887  color: var(--vp-c-text-3, var(--vp-c-text-2));
 888  font-style: italic;
 889}
 890
 891.card-tooltip {
 892  position: fixed;
 893  z-index: 9999;
 894  transform: translate(-50%, calc(-100% - 6px));
 895  background: var(--vp-c-bg-soft);
 896  color: var(--vp-c-text-1);
 897  border: 1px solid var(--vp-c-divider);
 898  border-radius: 5px;
 899  padding: 3px 8px;
 900  font-size: 11px;
 901  white-space: nowrap;
 902  pointer-events: none;
 903}
 904
 905.card-row.is-dragging {
 906  opacity: 0.25;
 907  cursor: grabbing;
 908}
 909
 910.card-row.is-over {
 911  background: var(--vp-c-brand-soft);
 912  outline: 2px solid var(--vp-c-brand-1);
 913  outline-offset: -2px;
 914}
 915
 916.row-handle {
 917  color: var(--vp-c-text-3, var(--vp-c-text-2));
 918  font-size: 16px;
 919  flex-shrink: 0;
 920  display: flex;
 921  align-items: center;
 922  cursor: grab;
 923  touch-action: none;
 924}
 925
 926.row-handle:active {
 927  cursor: grabbing;
 928}
 929
 930.row-handle-spacer {
 931  width: 16px;
 932  flex-shrink: 0;
 933}
 934
 935.row-icon {
 936  font-size: 18px;
 937  flex-shrink: 0;
 938  display: flex;
 939  align-items: center;
 940  width: 20px;
 941}
 942
 943.row-name {
 944  flex: 1;
 945  font-size: 14px;
 946  font-weight: 500;
 947  color: var(--vp-c-text-1);
 948  overflow: hidden;
 949  white-space: nowrap;
 950  text-overflow: ellipsis;
 951  min-width: 0;
 952}
 953
 954.row-toggle {
 955  display: flex;
 956  align-items: center;
 957  justify-content: center;
 958  width: 30px;
 959  height: 30px;
 960  border-radius: 6px;
 961  border: none;
 962  background: transparent;
 963  color: var(--vp-c-text-2);
 964  font-size: 16px;
 965  cursor: pointer;
 966  flex-shrink: 0;
 967  transition: background 0.15s, color 0.15s;
 968}
 969
 970.row-toggle:hover {
 971  background: var(--vp-c-bg-alt);
 972  color: var(--vp-c-text-1);
 973}
 974
 975.row-toggle.active {
 976  color: var(--vp-c-brand-1);
 977}
 978
 979/* ── Panel Footer ── */
 980.panel-foot {
 981  display: flex;
 982  align-items: center;
 983  justify-content: space-between;
 984  padding: 5px 8px;
 985  border-top: 1px solid var(--vp-c-divider);
 986  flex-shrink: 0;
 987  gap: 8px;
 988}
 989
 990.foot-group {
 991  display: flex;
 992  align-items: center;
 993  gap: 4px;
 994}
 995
 996.tool-btn {
 997  position: relative;
 998  display: flex;
 999  align-items: center;
1000  gap: 5px;
1001  font-size: 14px;
1002  font-weight: 500;
1003  color: var(--vp-c-text-2);
1004  background: transparent;
1005  border: none;
1006  border-radius: 5px;
1007  padding: 5px 6px;
1008  cursor: pointer;
1009  transition: color 0.15s, background 0.15s;
1010}
1011
1012.tool-btn[aria-label]::after {
1013  content: attr(aria-label);
1014  position: absolute;
1015  bottom: calc(100% + 6px);
1016  left: 50%;
1017  transform: translateX(-50%);
1018  background: var(--vp-c-bg-soft);
1019  color: var(--vp-c-text-1);
1020  border: 1px solid var(--vp-c-divider);
1021  border-radius: 5px;
1022  padding: 3px 8px;
1023  font-size: 11px;
1024  white-space: nowrap;
1025  pointer-events: none;
1026  opacity: 0;
1027  transition: opacity 0.15s;
1028  z-index: 10;
1029}
1030
1031@media (hover: hover) {
1032  .tool-btn[aria-label]:hover::after {
1033    opacity: 1;
1034  }
1035}
1036
1037.tool-btn:hover {
1038  color: var(--vp-c-text-1);
1039  background: var(--vp-c-bg-soft);
1040}
1041
1042.tool-btn.is-active {
1043  color: var(--vp-c-brand-1);
1044  background: var(--vp-c-brand-soft);
1045}
1046
1047/* ── Settings Help ── */
1048.dropdown-section-header {
1049  display: flex;
1050  align-items: center;
1051  justify-content: space-between;
1052  margin-bottom: 6px;
1053}
1054
1055.dropdown-section-header .dropdown-label {
1056  margin-bottom: 0;
1057}
1058
1059.settings-help-btn {
1060  display: flex;
1061  align-items: center;
1062  justify-content: center;
1063  padding: 3px;
1064  background: transparent;
1065  border: none;
1066  cursor: pointer;
1067  color: var(--vp-c-text-3);
1068  opacity: 0.5;
1069  transition: opacity 0.15s, color 0.15s;
1070  border-radius: 3px;
1071  line-height: 1;
1072}
1073
1074.settings-help-btn:hover,
1075.settings-help-btn.active {
1076  opacity: 1;
1077  color: var(--vp-c-text-1);
1078}
1079
1080.settings-help-icon {
1081  display: block;
1082  width: 14px;
1083  height: 14px;
1084}
1085
1086.home-help-popup {
1087  position: fixed;
1088  z-index: 9999;
1089  width: 280px;
1090  background: var(--vp-c-bg-elv);
1091  border: 1px solid var(--vp-c-divider);
1092  border-radius: 12px;
1093  padding: 16px;
1094  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
1095  pointer-events: none;
1096}
1097
1098.help-popup-fade-enter-active,
1099.help-popup-fade-leave-active {
1100  transition: opacity 0.15s ease;
1101}
1102
1103.help-popup-fade-enter-from,
1104.help-popup-fade-leave-to {
1105  opacity: 0;
1106}
1107
1108.sh-title {
1109  display: flex;
1110  align-items: center;
1111  gap: 6px;
1112  font-size: 1rem;
1113  font-weight: 600;
1114  color: var(--vp-c-text-1);
1115  margin: 0 0 4px;
1116}
1117
1118.sh-title-icon {
1119  flex-shrink: 0;
1120  width: 16px;
1121  height: 16px;
1122  display: block;
1123}
1124
1125.sh-desc {
1126  font-size: 0.875rem;
1127  color: var(--vp-c-text-2);
1128  margin: 0 0 6px;
1129  line-height: 1.5;
1130}
1131
1132.sh-options {
1133  display: flex;
1134  flex-direction: column;
1135  gap: 5px;
1136}
1137
1138.sh-option {
1139  display: flex;
1140  flex-direction: column;
1141  gap: 4px;
1142  background: var(--vp-c-bg-soft);
1143  border-radius: 12px;
1144  padding: 10px 12px;
1145}
1146
1147.sh-option strong {
1148  display: flex;
1149  align-items: center;
1150  gap: 4px;
1151  font-size: 0.875rem;
1152  font-weight: 600;
1153  color: var(--vp-c-text-1);
1154}
1155
1156.sh-option-icon {
1157  width: 14px;
1158  height: 14px;
1159  flex-shrink: 0;
1160}
1161
1162.sh-option span {
1163  font-size: 0.875rem;
1164  color: var(--vp-c-text-2);
1165  line-height: 1.4;
1166}
1167
1168/* ── Settings Dropdown ── */
1169.settings-wrap {
1170  position: relative;
1171}
1172
1173.dropdown-overlay {
1174  position: fixed;
1175  inset: 0;
1176  z-index: 1;
1177}
1178
1179.settings-dropdown {
1180  position: absolute;
1181  bottom: calc(100% + 8px);
1182  right: 0;
1183  z-index: 2;
1184  min-width: 196px;
1185  background: var(--vp-c-bg);
1186  border: 1px solid var(--vp-c-divider);
1187  border-radius: 10px;
1188  padding: 10px;
1189  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
1190}
1191
1192.dropdown-section + .dropdown-section {
1193  border-top: 1px solid var(--vp-c-divider);
1194  margin-top: 8px;
1195  padding-top: 8px;
1196}
1197
1198.dropdown-label {
1199  display: flex;
1200  align-items: center;
1201  gap: 6px;
1202  font-size: 14px;
1203  font-weight: 500;
1204  color: var(--vp-c-text-1);
1205  margin-bottom: 0;
1206}
1207
1208.dropdown-label-icon {
1209  width: 14px;
1210  height: 14px;
1211  flex-shrink: 0;
1212}
1213
1214.dropdown-group {
1215  display: flex;
1216  gap: 4px;
1217}
1218
1219/* ── Drag Ghost ── */
1220.drag-ghost {
1221  position: fixed;
1222  pointer-events: none;
1223  z-index: 9999;
1224  display: flex;
1225  align-items: center;
1226  gap: 8px;
1227  padding: 6px 12px 6px 10px;
1228  background: var(--vp-c-bg);
1229  border: 1px solid var(--vp-c-brand-1);
1230  border-radius: 8px;
1231  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
1232  opacity: 0.88;
1233  font-size: 14px;
1234  font-weight: 500;
1235  color: var(--vp-c-text-1);
1236  white-space: nowrap;
1237  user-select: none;
1238  transform: translate(12px, -50%);
1239}
1240
1241.drag-ghost-name {
1242  font-size: 14px;
1243  font-weight: 500;
1244  color: var(--vp-c-text-1);
1245}
1246
1247.ghost-fade-enter-active,
1248.ghost-fade-leave-active { transition: opacity 0.1s ease; }
1249.ghost-fade-enter-from,
1250.ghost-fade-leave-to { opacity: 0; }
1251
1252/* ── Transitions ── */
1253.fade-enter-active,
1254.fade-leave-active { transition: opacity 0.2s ease; }
1255.fade-enter-from,
1256.fade-leave-to { opacity: 0; }
1257
1258.slide-up-enter-active { transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease; }
1259.slide-up-leave-active { transition: transform 0.2s ease, opacity 0.15s ease; }
1260.slide-up-enter-from { transform: translateY(20px); opacity: 0; }
1261.slide-up-leave-to { transform: translateY(10px); opacity: 0; }
1262</style>