* { margin:0; padding:0; box-sizing:border-box; }
  body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
    background: linear-gradient(160deg, #f5f0e8 0%, #eaf3ef 50%, #f0eaf5 100%);
    min-height: 100vh;
    color: #3D3A48;
    -webkit-font-smoothing: antialiased;
    padding-top: calc(env(safe-area-inset-top) + 64px);
  }
  .container {
    max-width: 420px;
    margin: 0 auto;
    padding: 16px 16px 40px;
  }

  /* 头部 */
  .header { text-align: center; margin-bottom: 14px; }
  .header h1 {
    font-size: 26px;
    font-weight: 800;
    background: linear-gradient(135deg, #4a9d8a, #7dc9b6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -.02em;
  }
  .header p { font-size: 12px; color: #8a8596; margin-top: 3px; }

  /* 模式切换 Tab */
  .mode-tabs {
    display: flex;
    gap: 6px;
    background: rgba(255,255,255,.6);
    padding: 5px;
    border-radius: 14px;
    margin-bottom: 16px;
    border: 1px solid rgba(255,255,255,.8);
  }
  .mode-tab {
    flex: 1;
    padding: 10px 12px;
    border-radius: 10px;
    border: none;
    background: transparent;
    font-size: 14px;
    font-weight: 600;
    color: #8a8596;
    cursor: pointer;
    transition: all .2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
  }
  .mode-tab:hover { color: #5a5668; }
  .mode-tab.active {
    background: #fff;
    color: #4a9d8a;
    box-shadow: 0 2px 8px rgba(74,157,138,.15);
  }

  .mode-panel { display: none; }
  .mode-panel.active { display: block; }

  /* 分类选择 - 主题模式（横滑） */
  .cat-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 10px;
    margin-bottom: 14px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .cat-tabs::-webkit-scrollbar { display: none; }
  .cat-tab {
    flex: 0 0 auto;
    padding: 7px 14px;
    border-radius: 18px;
    background: rgba(255,255,255,.7);
    border: 1px solid #e2dde8;
    font-size: 12px;
    font-weight: 600;
    color: #5a5668;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
  }
  .cat-tab:hover { background: #fff; }
  .cat-tab.active {
    background: linear-gradient(135deg, #4a9d8a, #7dc9b6);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 2px 10px rgba(74,157,138,.3);
  }
  .cat-tab.active::after {
    content: "✓";
    margin-left: 4px;
    font-size: 11px;
    font-weight: 700;
  }

  /* 标签折叠面板 - 图纸模式 */
  .tag-panel {
    background: rgba(255,255,255,.75);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,.9);
    border-radius: 16px;
    margin-bottom: 14px;
    overflow: hidden;
    transition: all .25s;
  }
  .tag-panel-header {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    cursor: pointer;
    gap: 10px;
  }
  .tag-panel-header:hover { background: rgba(255,255,255,.5); }
  .tag-panel-icon { font-size: 16px; }
  .tag-panel-title {
    font-size: 14px;
    font-weight: 700;
    color: #3D3A48;
    flex: 1;
  }
  .tag-panel-count {
    font-size: 12px;
    color: #8a8596;
    font-weight: 500;
  }
  .tag-panel-arrow {
    font-size: 12px;
    color: #b0acb8;
    transition: transform .25s;
  }
  .tag-panel.open .tag-panel-arrow { transform: rotate(180deg); }
  
  .tag-panel-body {
    display: none;
    padding: 0 14px 14px;
    border-top: 1px solid #f0ecec;
  }
  .tag-panel.open .tag-panel-body { display: block; }
  
  .tag-search-box {
    position: relative;
    margin: 12px 0;
  }
  .tag-search-box input {
    width: 100%;
    padding: 8px 12px 8px 32px;
    border: 1px solid #e2dde8;
    border-radius: 10px;
    background: #fff;
    font-size: 13px;
    font-family: inherit;
    color: #3D3A48;
  }
  .tag-search-box input:focus {
    outline: none;
    border-color: #7dc9b6;
  }
  .tag-search-box::before {
    content: "🔍";
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    opacity: .5;
  }
  
  .tag-group-title {
    font-size: 11px;
    font-weight: 600;
    color: #8a8596;
    margin: 10px 0 8px;
    padding-left: 2px;
  }
  .tag-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .tag-chip {
    padding: 5px 12px;
    border-radius: 14px;
    background: rgba(255,255,255,.8);
    border: 1px solid #e2dde8;
    font-size: 12px;
    font-weight: 500;
    color: #5a5668;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
  }
  .tag-chip:hover {
    background: #fff;
    border-color: #c8e5dc;
  }
  .tag-chip.active {
    background: linear-gradient(135deg, #4a9d8a, #7dc9b6);
    border-color: transparent;
    color: #fff;
  }
  .tag-chip .tag-count {
    opacity: .6;
    font-size: 11px;
    margin-left: 2px;
  }
  .tag-chip.active .tag-count { opacity: .8; }
  
  .tag-selected-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 0 4px;
  }
  .tag-selected-label {
    font-size: 11px;
    color: #8a8596;
    flex-shrink: 0;
  }
  .tag-selected-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 10px;
    background: #eaf3ef;
    color: #4a9d8a;
    font-size: 11px;
    font-weight: 600;
  }
  .tag-selected-chip .x {
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    opacity: .6;
  }
  .tag-selected-chip .x:hover { opacity: 1; }
  .tag-reset-btn {
    margin-left: auto;
    padding: 3px 10px;
    border: 1px solid #e2dde8;
    border-radius: 8px;
    background: #fff;
    color: #8a8596;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
  }
  .tag-reset-btn:hover { color: #5a5668; background: #f5f0f8; }
  .cat-hint {
    text-align: center;
    font-size: 11px;
    color: #b0acb8;
    margin: -4px 0 12px;
  }

  /* 搜索框 - 图纸模式 */
  .search-box {
    margin-bottom: 12px;
    position: relative;
  }
  .search-box input {
    width: 100%;
    padding: 10px 14px 10px 36px;
    border: 1px solid #e2dde8;
    border-radius: 12px;
    background: rgba(255,255,255,.8);
    font-size: 14px;
    font-family: inherit;
    color: #3D3A48;
  }
  .search-box input:focus {
    outline: none;
    border-color: #7dc9b6;
    background: #fff;
  }
  .search-box::before {
    content: "🔍";
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    opacity: .5;
  }

  /* 抽签卡片 */
  .draw-card {
    background: rgba(255,255,255,.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,.9);
    border-radius: 24px;
    padding: 36px 20px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(74,157,138,.12);
    margin-bottom: 16px;
    transition: all .3s;
  }
  .draw-card.result {
    border: 2px solid #7dc9b6;
    animation: popIn .45s cubic-bezier(.34,1.56,.64,1);
  }
  @keyframes popIn {
    0% { transform: scale(.85); opacity: 0; }
    60% { transform: scale(1.04); }
    100% { transform: scale(1); opacity: 1; }
  }
  .ld-cat-tag {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 10px;
    background: #eaf3ef;
    color: #4a9d8a;
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 12px;
  }
  .ld-label { font-size: 13px; color: #8a8596; margin-bottom: 6px; }
  .ld-sub { font-size: 12px; color: #b0acb8; margin-bottom: 20px; font-style: italic; }
  .ld-theme {
    font-size: 36px;
    font-weight: 800;
    color: #4a9d8a;
    margin-bottom: 24px;
    line-height: 1.2;
    letter-spacing: -.02em;
    min-height: 44px;
  }
  .ld-theme.spinning {
    animation: flash .07s infinite alternate;
  }
  @keyframes flash {
    from { opacity: .35; transform: scale(.97); }
    to { opacity: 1; transform: scale(1.02); }
  }
  .ld-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
  .btn {
    padding: 11px 24px;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all .15s;
  }
  .btn-primary {
    background: linear-gradient(135deg, #4a9d8a, #7dc9b6);
    color: #fff;
    box-shadow: 0 4px 14px rgba(74,157,138,.3);
  }
  .btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(74,157,138,.35); }
  .btn-primary:active { transform: translateY(0); }
  .btn-ghost {
    background: rgba(255,255,255,.7);
    color: #5a5668;
    border: 1px solid #e2dde8;
  }
  .btn-ghost:hover { background: #f5f0f8; }
  .btn-big {
    padding: 14px 44px;
    font-size: 18px;
    border-radius: 16px;
  }

  /* 图纸预览 - 抽签结果 */
  .note-cover {
    width: 100%;
    height: 280px;
    border-radius: 16px;
    margin-bottom: 14px;
    box-shadow: 0 4px 16px rgba(0,0,0,.1);
    background-color: #f5f0e8;
    background-image: url('./sprite.webp');
    background-size: calc(29 * 100%) calc(28 * 100%);
    background-repeat: no-repeat;
  }
  .note-cover.spinning {
    animation: imgFlash .08s infinite alternate;
  }
  @keyframes imgFlash {
    from { opacity: .5; transform: scale(.98); }
    to { opacity: 1; transform: scale(1); }
  }
  .note-title {
    font-size: 18px;
    font-weight: 700;
    color: #3D3A48;
    margin-bottom: 6px;
    line-height: 1.3;
  }
  .note-author {
    font-size: 13px;
    color: #8a8596;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
  }
  .note-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center;
    margin-bottom: 14px;
  }
  .note-tag {
    padding: 3px 10px;
    border-radius: 8px;
    background: #f0eaf5;
    color: #7c5c9e;
    font-size: 11px;
    font-weight: 500;
  }
  .note-stats {
    display: flex;
    justify-content: center;
    gap: 16px;
    font-size: 12px;
    color: #b0acb8;
    margin-bottom: 14px;
  }
  .note-stats span { display: flex; align-items: center; gap: 3px; }
  .note-link-row {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
  }
  .note-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 16px;
    border-radius: 10px;
    background: #eaf3ef;
    color: #4a9d8a;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all .15s;
  }
  .note-link-btn:hover { background: #d8ebe4; }
  .note-link-btn.copied { background: #ffeaa7; color: #b8860b; }

  /* 主题池 / 图纸池 */
  .section {
    background: rgba(255,255,255,.75);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,.9);
    border-radius: 18px;
    padding: 16px;
    margin-bottom: 14px;
    box-shadow: 0 4px 16px rgba(0,0,0,.04);
  }
  .sec-title {
    font-size: 14px;
    font-weight: 700;
    color: #3D3A48;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .sec-title .count {
    margin-left: auto;
    font-weight: 500;
    color: #8a8596;
    font-size: 12px;
  }
  .theme-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-bottom: 12px;
  }
  /* 二级标签分组 */
  .theme-group {
    width: 100%;
    margin-bottom: 6px;
  }
  .theme-group-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: #f0ede5;
    border-radius: 10px;
    font-size: 12px;
    color: #6a6576;
    cursor: pointer;
    user-select: none;
  }
  .theme-group-header:hover { background: #e8e5da; }
  .group-arrow {
    font-size: 9px;
    transition: transform .2s;
    color: #a8a3b0;
  }
  .theme-group.open .group-arrow { transform: rotate(90deg); }
  .group-name { font-weight: 600; flex: 1; }
  .group-count {
    font-size: 11px;
    color: #a8a3b0;
    margin-right: 4px;
  }
  .group-toggle-all {
    padding: 2px 8px;
    border: 1px solid #d0cbde;
    border-radius: 8px;
    background: #fff;
    color: #8a8596;
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    flex-shrink: 0;
  }
  .group-toggle-all:hover { background: #f5f0f8; }
  .group-toggle-all.all-out {
    color: #e57373;
    border-color: #f5c6c6;
  }
  .theme-group-items {
    display: none;
    padding: 8px 6px 2px;
    flex-wrap: wrap;
    gap: 6px;
  }
  .theme-group.open .theme-group-items { display: flex; }
  .theme-chip.sub {
    font-size: 11px;
    padding: 4px 10px;
    background: #f5f3ed;
    border-color: #e0dcd0;
    color: #6a6576;
  }
  .theme-chip.sub.excluded {
    background: #f0ecec;
    border-color: #e0dcdc;
    color: #b8b0b0;
  }
  .theme-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border-radius: 16px;
    background: #eaf3ef;
    border: 1px solid #c8e5dc;
    font-size: 12px;
    font-weight: 600;
    color: #4a9d8a;
  }
  .theme-chip.custom {
    background: #f5eef8;
    border-color: #e0d0eb;
    color: #7c5c9e;
  }
  .theme-chip.excluded {
    background: #f0ecec;
    border-color: #e0dcdc;
    color: #b8b0b0;
    text-decoration: line-through;
    opacity: .55;
  }
  .reset-exclude-btn {
    margin-left: 8px;
    padding: 2px 10px;
    border: 1px solid #e2dde8;
    border-radius: 10px;
    background: #fff;
    color: #8a8596;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
  }
  .reset-exclude-btn:hover { background: #f5f0f8; color: #5a5668; }
  .theme-hint {
    font-size: 11px;
    color: #b0acb8;
    margin: -2px 0 8px;
  }
  .theme-chip .chip-del {
    border: none;
    background: none;
    cursor: pointer;
    color: #a8c5bc;
    font-size: 16px;
    line-height: 1;
    padding: 0 0 0 2px;
    display: flex;
    align-items: center;
  }
  .theme-chip.custom .chip-del { color: #c4b0d5; }
  .theme-chip .chip-del:hover { color: #e74c3c; }
  .theme-empty {
    text-align: center;
    color: #b0acb8;
    font-size: 13px;
    padding: 10px 0;
  }
  .theme-add {
    display: flex;
    gap: 8px;
  }
  .theme-add input {
    flex: 1;
    padding: 9px 12px;
    border: 1px solid #e2dde8;
    border-radius: 10px;
    background: #fff;
    color: #3D3A48;
    font-size: 13px;
    font-family: inherit;
  }
  .theme-add input:focus {
    outline: none;
    border-color: #7dc9b6;
  }
  .theme-add button {
    padding: 9px 16px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #4a9d8a, #7dc9b6);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
  }
  .theme-add button:hover { opacity: .88; }

  /* 图纸池网格 */
  .note-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    max-height: 320px;
    overflow-y: auto;
    padding: 2px;
  }
  .note-grid::-webkit-scrollbar { width: 4px; }
  .note-grid::-webkit-scrollbar-thumb { background: #e2dde8; border-radius: 2px; }
  .note-grid-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: all .15s;
    border: 2px solid transparent;
  }
  .note-grid-item:hover { transform: scale(1.05); }
  .note-grid-item.excluded {
    opacity: .35;
    filter: grayscale(1);
  }
  .note-grid-item.excluded::after {
    content: "✕";
    position: absolute;
    top: 4px;
    right: 4px;
    width: 18px;
    height: 18px;
    background: rgba(0,0,0,.5);
    color: #fff;
    border-radius: 50%;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .note-grid-item .sprite-img {
    width: 100%;
    height: 100%;
    background-image: url('./sprite.webp');
    background-size: calc(29 * 100%) calc(28 * 100%);
    background-repeat: no-repeat;
  }
  .note-grid-item .grid-type {
    position: absolute;
    bottom: 2px;
    right: 2px;
    padding: 1px 5px;
    background: rgba(0,0,0,.5);
    color: #fff;
    font-size: 9px;
    border-radius: 4px;
  }

  /* 底部 */
  .footer {
    text-align: center;
    font-size: 11px;
    color: #b0acb8;
    margin-top: 20px;
    opacity: .6;
  }

  /* 复制成功提示 */
  .toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,.8);
    color: #fff;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 14px;
    z-index: 9999;
    animation: toastIn .2s ease-out;
  }
  @keyframes toastIn {
    from { opacity: 0; transform: translate(-50%, -60%); }
    to { opacity: 1; transform: translate(-50%, -50%); }
  }


/* 小工具专用样式 */
.note-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border-radius: 16px;
  background: rgba(74,157,138,.1);
  border: 1px solid rgba(74,157,138,.3);
  color: #4a9d8a;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
.note-link-btn:active {
  background: rgba(74,157,138,.2);
}

/* 雪碧图图片 */
.sprite-img {
  background-image: url('./sprite.webp');
  background-size: calc(var(--sprite-cols, 29) * 100%) calc(var(--sprite-rows, 28) * 100%);
  background-repeat: no-repeat;
  display: block;
  width: 100%;
  height: 100%;
}
