:root {
    --bg: #0b1220;
    --panel: #111a2b;
    --panel-2: #0f1726;
    --text: #e8edf7;
    --muted: #9aa7bd;
    --border: rgba(255, 255, 255, 0.12);
    --primary: #4f8cff;
    --danger: #ff5c76;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    background: radial-gradient(1200px 600px at 10% 0%, rgba(79, 140, 255, 0.18), transparent 60%),
        radial-gradient(900px 500px at 90% 20%, rgba(255, 92, 118, 0.12), transparent 55%),
        var(--bg);
    color: var(--text);
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Microsoft YaHei", sans-serif;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(10px);
    background: rgba(15, 23, 38, 0.8);
    position: sticky;
    top: 0;
    z-index: 10;
}

.title h1 {
    font-size: 16px;
    margin: 0;
}

.subtitle {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 14px;
    padding: 14px;
}

/* 防止 grid 子项因为 min-width:auto 导致页面出现横向滚动条 */
.sidebar,
.maincol {
    min-width: 0;
}

.maincol {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 0;
    min-width: 0;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.panel {
    background: linear-gradient(180deg, rgba(17, 26, 43, 0.95), rgba(15, 23, 38, 0.95));
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 12px;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
}

.modal-panel {
    position: relative;
    z-index: 1;
    width: min(520px, calc(100vw - 28px));
    background: linear-gradient(180deg, rgba(17, 26, 43, 0.98), rgba(15, 23, 38, 0.98));
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 12px;
}

.modal-title {
    font-size: 12px;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 10px;
}

.panel-title {
    font-size: 12px;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 10px;
}

.subsection-title {
    margin-top: 6px;
    margin-bottom: 8px;
    font-size: 12px;
    color: rgba(232, 237, 247, 0.86);
    font-weight: 600;
}

.subsection-title.preview-panel-title {
    margin-top: 16px;
    margin-bottom: 6px;
    text-align: center;
}

.panel-actions.preview-panel-actions {
    justify-content: center;
    gap: 8px;
    margin-bottom: 8px;
}

.subsection-title.subsection-title-with-action {
    position: relative;
    text-align: center;
    padding-right: 78px;
}

.subsection-title.subsection-title-with-action .subsection-title-text {
    display: block;
}

.subsection-title.subsection-title-with-action .subsection-action {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}

.divider {
    height: 1px;
    margin: 10px 0;
    background: rgba(255, 255, 255, 0.10);
}

.category-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
}

.category-node {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.category-groups {
    margin-left: 16px;
    padding-left: 10px;
    border-left: 1px solid rgba(255, 255, 255, 0.10);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.category-groups .group-item {
    padding: 6px 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.02);
}

.category-groups .group-item .name {
    font-size: 12px;
}

.category-groups .group-item .count,
.category-groups .group-item .badge.badge-small {
    font-size: 11px;
}

.category-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.03);
    cursor: pointer;
    user-select: none;
}

.category-item:hover {
    border-color: rgba(255, 255, 255, 0.16);
}

.category-item.active {
    border-color: rgba(79, 140, 255, 0.55);
    background: rgba(79, 140, 255, 0.12);
}

/* 表格：批量勾选行的轻量高亮（不影响 row-selected 逻辑） */
tr.row-checked {
    background: rgba(79, 140, 255, 0.06);
}

.category-item .left {
    display: flex;
    flex-direction: row;
    gap: 8px;
    align-items: center;
    min-width: 0;
}

.category-item .cat-icon {
    width: 18px;
    min-width: 18px;
    text-align: center;
    font-size: 16px;
    line-height: 1;
    color: #6c757d;
}

.category-item input.category-name-input {
    height: 32px;
    padding: 6px 10px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    outline: none;
    width: 140px;
    max-width: 100px;
    min-width: 60px;
    flex: 0 0 auto;
}

.category-item input.category-name-input::placeholder {
    color: rgba(154, 167, 189, 0.65);
}

.category-item .icon-picker {
    flex: 1 1 auto;
    min-width: 80px;
    max-width: none;
}

.category-item .icon-picker input {
    height: 32px;
    width: 120px;
}

.category-item .icon-picker-open,
.category-item .icon-picker-preview {
    height: 32px;
}

.category-item .name {
    font-size: 13px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-item .right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.category-item .count {
    color: var(--muted);
    font-size: 12px;
}

.category-meta-line {
    display: grid;
    grid-template-columns: auto minmax(140px, 1fr) minmax(160px, 240px);
    align-items: center;
    gap: 10px;
    margin-top: 6px;
    margin-bottom: 2px;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
}

.category-meta-line .field-inline {
    min-width: 0;
}

.group-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.group-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.03);
    cursor: pointer;
    user-select: none;
}

.group-item .left {
    display: flex;
    flex-direction: row;
    gap: 8px;
    align-items: center;
    min-width: 0;
}

.group-item .group-icon {
    width: 18px;
    min-width: 18px;
    text-align: center;
    font-size: 16px;
    line-height: 1;
    color: #6c757d;
}

.group-item .name {
    font-size: 13px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.group-item .right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.group-item .cat {
    color: var(--muted);
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.03);
    max-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.badge.badge-small {
    padding: 1px 6px;
    font-size: 11px;
}

.group-item:hover {
    border-color: rgba(255, 255, 255, 0.16);
}

.group-item.active {
    border-color: rgba(79, 140, 255, 0.55);
    background: rgba(79, 140, 255, 0.12);
}

/* Duplicate-card indicator (green ring) */
.group-item.dup-ring {
    border-color: rgba(46, 229, 157, 0.55);
    box-shadow: 0 0 0 2px rgba(46, 229, 157, 0.45), 0 0 18px rgba(46, 229, 157, 0.22);
}

.group-item.active .group-icon {
    color: #0d6efd;
}

.group-item .count {
    color: var(--muted);
    font-size: 12px;
}

/* URL Test columns */
thead th.col-test,
thead th.col-togoTest {
    cursor: pointer;
    user-select: none;
}

thead th.col-test:hover,
thead th.col-togoTest:hover {
    background: rgba(255, 255, 255, 0.04);
}

thead th.col-test.is-testing,
thead th.col-togoTest.is-testing {
    color: #ffd166;
}

td.col-test,
td.col-togoTest,
th.col-test,
th.col-togoTest {
    text-align: center;
}

.link-test-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 74px;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    line-height: 1.4;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--muted);
    white-space: nowrap;
}

.link-test-badge.status-none {
    color: var(--muted);
}

.link-test-badge.status-running {
    color: #ffd166;
    border-color: rgba(255, 209, 102, 0.35);
    background: rgba(255, 209, 102, 0.10);
}

.link-test-badge.status-valid {
    color: #2ee59d;
    border-color: rgba(46, 229, 157, 0.35);
    background: rgba(46, 229, 157, 0.10);
}

.link-test-badge.status-invalid {
    color: var(--danger);
    border-color: rgba(255, 92, 118, 0.35);
    background: rgba(255, 92, 118, 0.10);
}

.link-test-badge.status-timeout {
    color: var(--primary);
    border-color: rgba(79, 140, 255, 0.35);
    background: rgba(79, 140, 255, 0.10);
}

/* 右侧编辑区：group 元信息单行布局 */
.group-meta-line {
    display: grid;
    grid-template-columns: auto minmax(130px, 155px) minmax(110px, 160px) minmax(160px, 240px) auto;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
}

/* 覆盖 field-inline 的固定宽度：在 grid 中自适应列宽 */
.group-meta-line .field-inline {
    min-width: 0;
}

.group-meta-line .field-inline>input[type="text"],
.group-meta-line .field-inline>select {
    width: 100%;
}

.group-meta-line .field-expanded {
    justify-self: end;
}

.group-meta-left {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-wrap: wrap;
    min-width: 0;
}

.group-meta-extra {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 2px;
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.group-preview {
    max-width: 380px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 新增 group 表单：每项各占一行（label 左对齐，控件占剩余宽度） */
.add-group-form .form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    align-items: center;
}

.add-group-form .field {
    display: grid;
    grid-template-columns: 140px 1fr;
    align-items: center;
    gap: 10px;
    margin: 0;
    min-width: 0;
}

.add-group-form .field .label {
    margin-bottom: 0;
    white-space: nowrap;
}

.add-group-form .field input[type="text"],
.add-group-form .field input[type="number"],
.add-group-form .field textarea {
    width: 100%;
}

/* Add Group: Category 输入框 + Select 按钮同行 */
.add-group-form .field .field-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.add-group-form .field .field-row>input[type="text"] {
    flex: 1 1 auto;
    min-width: 0;
}

.add-group-form .field .field-row>.btn {
    flex: 0 0 auto;
    white-space: nowrap;
}

/* Expanded：label 靠左，复选框在右侧区域水平居中 */
.add-group-form .field.field-expanded-inline {
    grid-template-columns: 140px 1fr;
}

.add-group-form .field.field-expanded-inline input[type="checkbox"] {
    width: auto;
    justify-self: center;
}

.group-count {
    color: var(--muted);
}

.group-id-badge {
    flex-shrink: 0;
}

.field-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.field-inline .label {
    font-size: 12px;
    color: var(--muted);
    margin: 0;
    white-space: nowrap;
}

.field-inline input,
.field-inline select {
    height: 34px;
    padding: 6px 10px;
    border-radius: 10px;
}

.field-inline input[type="checkbox"] {
    width: auto;
    height: auto;
    padding: 0;
    border-radius: 4px;
    transform: translateY(1px);
}

.field-inline input {
    width: 170px;
}

.field-inline select {
    width: 120px;
}

.field-inline.field-category input {
    width: 150px;
}

.field-inline.field-title input {
    width: 180px;
}

/* ----------------------------
   Icon Picker (group icon UI)
----------------------------- */

.icon-picker {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    max-width: 100%;
    flex: 1 1 auto;
}

.icon-picker input {
    min-width: 80px;
    width: auto;
    flex: 1 1 auto;
    min-width: 0;
}

.field-inline .icon-picker {
    width: 100%;
}

.field-inline.field-caticon .icon-picker {
    flex: 1 1 auto;
    min-width: 0;
}

.add-group-form .icon-picker {
    width: 100%;
}

.icon-picker-preview,
.icon-picker-open {
    height: 34px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    cursor: pointer;
    transition: transform 0.06s ease, border-color 0.15s ease, background 0.15s ease;
}

.icon-picker-preview {
    width: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.icon-picker-preview i {
    font-size: 18px;
    line-height: 1;
}

.icon-picker-open {
    padding: 0 10px;
    font-size: 12px;
    white-space: nowrap;
}

/* 当不含 preview/clear 时，选择按钮保持不被挤压 */
.icon-picker .icon-picker-open {
    flex: 0 0 auto;
}

.icon-picker-preview:hover,
.icon-picker-open:hover {
    border-color: rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.10);
}

.icon-picker-preview:active,
.icon-picker-open:active {
    transform: translateY(1px);
}

.icon-picker.is-disabled {
    opacity: 0.55;
}

.icon-picker.is-disabled .icon-picker-preview,
.icon-picker.is-disabled .icon-picker-open {
    cursor: not-allowed;
}

.icon-picker-popover {
    position: absolute;
    z-index: 9999;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(17, 26, 43, 0.98), rgba(15, 23, 38, 0.98));
    box-shadow: var(--shadow);
    padding: 10px;
}

.icon-picker-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.icon-picker-search {
    height: 34px;
    border-radius: 10px;
    padding: 8px 10px;
    flex: 1 1 auto;
    min-width: 140px;
    width: 1px;
}

.icon-picker-lib {
    height: 34px;
    border-radius: 10px;
    padding: 0 10px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(17, 26, 43, 0.85);
    color: var(--text);
    color-scheme: dark;
}

/* 说明：Windows/Chrome 的原生下拉选项样式可定制程度有限；这里尽量把 option 也调成暗色 */
.icon-picker-lib option {
    background: rgba(17, 26, 43, 0.98);
    color: var(--text);
}

.icon-picker-lib:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.22);
    border-color: rgba(79, 140, 255, 0.35);
}

/* 让左侧 Groups 的 emoji 图标对齐一致 */
.group-item .group-icon.group-icon-emoji {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
}

.icon-picker-clear {
    height: 34px;
    border-radius: 10px;
    padding: 0 10px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    cursor: pointer;
}

.icon-picker-clear:hover {
    border-color: rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.10);
}

.icon-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
    gap: 8px;
    max-height: 320px;
    overflow: auto;
    padding-right: 2px;
}

.icon-picker-item .icon-emoji {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 18px;
    line-height: 1;
}

.icon-picker-item {
    height: 36px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-picker-item i {
    font-size: 18px;
    line-height: 1;
}

.icon-picker-item:hover {
    border-color: rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.08);
}

.icon-picker-item.is-selected {
    border-color: rgba(79, 140, 255, 0.7);
    background: rgba(79, 140, 255, 0.14);
}

.icon-picker-empty {
    grid-column: 1 / -1;
    color: var(--muted);
    font-size: 12px;
    padding: 8px 2px;
}

/* 悬浮图标放大预览（延迟 0.1s 显示） */
.icon-hover-preview {
    position: fixed;
    z-index: 10000;
    pointer-events: none;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(10, 16, 28, 0.92);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
    padding: 10px 12px;
    min-width: 120px;
    max-width: 260px;
    backdrop-filter: blur(10px);
}

.icon-hover-preview-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 85px;
    width: 100%;
}

.icon-hover-preview-icon i {
    font-size: 76px;
    line-height: 1;
}

.icon-hover-preview-emoji {
    font-size: 76px;
    line-height: 1;
}

.icon-hover-preview-name {
    margin-top: 6px;
    font-size: 12px;
    color: var(--muted);
    text-align: center;
    word-break: break-word;
}

.form {
    display: grid;
    gap: 10px;
}

.field .label {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
}

input,
textarea {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(0, 0, 0, 0.18);
    color: var(--text);
    border-radius: 10px;
    padding: 8px 10px;
    outline: none;
}

input:focus,
textarea:focus {
    border-color: rgba(79, 140, 255, 0.7);
    box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.15);
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 12px;
}

.hint {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
}

.panel-actions,
.topbar-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
}

/* 仅用于 Categories & Groups 顶部两行按钮：居中对齐 */
.panel-actions.panel-actions-right {
    justify-content: center;
    /* flex-end 靠右对齐 */
}

/* 拖拽排序：左侧 group 行 */
.group-drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    min-width: 18px;
    height: 18px;
    border-radius: 6px;
    color: rgba(232, 237, 247, 0.65);
    background: rgba(255, 255, 255, 0.04);
    cursor: grab;
    user-select: none;
}

.group-item.dragging,
.category-item.dragging {
    opacity: 0.6;
}

.group-item.drop-target,
.category-item.drop-target,
.category-groups.drop-target {
    outline: 2px dashed rgba(79, 140, 255, 0.65);
    outline-offset: 2px;
}

/* 拖拽排序：表格行 */
.row-drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    min-width: 18px;
    height: 18px;
    margin-right: 6px;
    border-radius: 6px;
    color: rgba(232, 237, 247, 0.65);
    background: rgba(255, 255, 255, 0.04);
    cursor: grab;
    user-select: none;
}

tr.row-drop-target {
    outline: 2px dashed rgba(79, 140, 255, 0.65);
    outline-offset: -3px;
}

.add-group-form {
    border: 1px solid rgba(255, 255, 255, 0.10);
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 10px;
}

.btn {
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    border-radius: 10px;
    padding: 8px 10px;
    cursor: pointer;
    transition: transform 0.06s ease, border-color 0.15s ease, background 0.15s ease;
}

.btn:hover {
    border-color: rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.10);
}

.btn:active {
    transform: translateY(1px);
}

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

.btn-primary {
    border-color: rgba(79, 140, 255, 0.6);
    background: rgba(79, 140, 255, 0.16);
}

.btn-danger {
    border-color: rgba(255, 92, 118, 0.55);
    background: rgba(255, 92, 118, 0.14);
}

.content {
    background: linear-gradient(180deg, rgba(17, 26, 43, 0.70), rgba(15, 23, 38, 0.75));
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.group-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 10px;
    margin-bottom: 6px;
    align-items: end;
}


.category-icon-list {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.category-icon-row {
    display: grid;
    grid-template-columns: 90px 1fr auto;
    gap: 8px;
    align-items: center;
}

.category-icon-name {
    color: var(--text);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-icon-input {
    width: 100%;
    height: 34px;
    padding: 6px 10px;
    border-radius: 10px;
}

.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px;
    border-bottom: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.08);
}

.content-title {
    font-size: 14px;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.06);
    font-size: 12px;
}

.content-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* 竖屏优化：顶部栏/按钮尺寸 + group 顶部两行布局 + 右侧按钮单行 */
@media (max-width: 767.98px) {
    .topbar {
        padding: 10px 12px;
        gap: 10px;
        align-items: flex-start;
    }

    .title h1 {
        font-size: 14px;
        line-height: 1.25;
    }

    .subtitle {
        font-size: 11px;
        line-height: 1.25;
    }

    .topbar-actions {
        margin-top: 0;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }

    .topbar-actions .btn {
        padding: 6px 8px;
        font-size: 12px;
        white-space: nowrap;
    }

    .layout {
        grid-template-columns: 1fr;
    }

    .content-header {
        flex-direction: column;
        align-items: stretch;
    }

    /* Edit Advanced Columns：小屏也独占一行 */
    .toggle {
        width: 100%;
    }

    /* group 编辑框顶部：左侧设置项限制两行（网格区域布局） */
    .group-meta-line {
        grid-template-columns: minmax(72px, auto) minmax(0, 1fr) minmax(0, 1fr) auto;
        grid-template-areas:
            "id category title title"
            "id icon icon expanded";
        gap: 8px;
        overflow-x: hidden;
    }

    .group-id-badge {
        grid-area: id;
        align-self: start;
        max-width: 92px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .group-meta-line .field-category {
        grid-area: category;
    }

    .group-meta-line .field-title {
        grid-area: title;
    }

    .group-meta-line .field-caticon {
        grid-area: icon;
    }

    .group-meta-line .field-expanded {
        grid-area: expanded;
        justify-self: end;
    }

    .group-meta-line .field-inline input[type="text"],
    .group-meta-line .field-inline select {
        width: 100%;
        min-width: 0;
    }

    /* 竖屏：顶部 meta 行更紧凑，给输入框更多空间 */
    .group-meta-line .field-inline {
        gap: 4px;
        min-width: 0;
    }

    .group-meta-line .field-inline .label {
        font-size: 11px;
    }

    .group-meta-line .field-inline>input[type="text"],
    .group-meta-line .field-inline>select {
        height: 30px;
        padding: 4px 8px;
        border-radius: 9px;
    }

    /* icon-picker 在竖屏下跟随输入框高度 */
    .group-meta-line .icon-picker-preview,
    .group-meta-line .icon-picker-open {
        height: 30px;
        border-radius: 9px;
    }

    .group-meta-line .field-inline input[type="checkbox"] {
        transform: translateY(0);
    }

    /* 右侧编辑功能按钮：竖屏强制一行，必要时横向滚动 */
    .content-actions {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        justify-content: flex-end;
        gap: 6px;
        padding-top: 2px;
    }

    .content-actions .btn {
        padding: 4px 6px;
        font-size: 11px;
        border-radius: 8px;
        white-space: nowrap;
    }

    /* 竖屏：条目编辑区固定视窗（高度由 editor.js 动态计算），其余通过右侧滚动条查看 */
    #itemsTableWrap {
        border: 1px solid rgba(255, 255, 255, 0.10);
        border-radius: 12px;
    }
}

.table-wrap {
    /* 横向滚动只作用于表格本身，不让页面底部出现滚动条 */
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    max-height: none;
}

.table {
    /* 表格可以超宽，但由 table-wrap 托管横向滚动 */
    width: max-content;
    border-collapse: collapse;
    min-width: 0;
    table-layout: fixed;
}

.table thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: rgba(15, 23, 38, 0.95);
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    color: var(--muted);
    text-align: left;
    padding: 10px;
    white-space: nowrap;
    user-select: none;
}

.table thead th,
.table tbody td {
    position: relative;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 已放弃冻结列：不再使用 sticky-col / sticky-1 / sticky-2 */

.col-resizer {
    position: absolute;
    top: 0;
    right: -3px;
    width: 7px;
    height: 100%;
    cursor: col-resize;
}

.col-resizer:hover {
    background: rgba(79, 140, 255, 0.15);
}

.table tbody td {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding: 8px;
    vertical-align: top;
}

/* 选中列：更紧凑并居中 */
.table th.col-select,
.table td.col-select {
    text-align: center;
    padding: 0 6px;
    min-width: 68px;
}

/* hide 列：更紧凑并居中 */
.table th.col-hide,
.table td.col-hide {
    text-align: center;
    padding: 0 6px;
}

.table td.col-select {
    vertical-align: middle;
}

/* box 列：行勾选（批量操作） */
.table .col-select input[type="checkbox"][name="checkedRow"],
#chkAllRows {
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: rgba(0, 0, 0, 0.18);
    display: inline-block;
    margin: 0;
    vertical-align: middle;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.table .col-select input[type="checkbox"][name="checkedRow"]:hover,
#chkAllRows:hover {
    border-color: rgba(255, 255, 255, 0.45);
}

.table .col-select input[type="checkbox"][name="checkedRow"]:focus-visible,
#chkAllRows:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.22);
}

.table .col-select input[type="checkbox"][name="checkedRow"]:checked,
#chkAllRows:checked {
    border-color: rgba(79, 140, 255, 0.22);
    background: rgba(9, 48, 120, 0.82);
    box-shadow: inset 0 0 0 3px rgb(17, 26, 43);
}

/* box 列：表头全选/反选控件 */
.th-select-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    height: 100%;
}

/* 右侧 group 编辑区：Category 选择框主题色 */
#currentGroupCategory {
    background: #121925;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.16);
    color-scheme: dark;
}

#currentGroupCategory:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.22);
}

/* Move To 弹窗：Target Group 选择框主题色 */
#moveToTargetGroup {
    background: #121925;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.16);
    color-scheme: dark;
}

#moveToTargetGroup:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.22);
}

/* Add Group：Category 输入框主题色（不使用 datalist 下拉） */
#addGroupCategory {
    background: #121925;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.16);
}

#addGroupCategory:focus {
    border-color: rgba(79, 140, 255, 0.7);
    box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.15);
}

/* Add Group：Category 的 Select 按钮样式参考 icon-picker-open */
#btnPickGroupCategory {
    height: 34px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    cursor: pointer;
    transition: transform 0.06s ease, border-color 0.15s ease, background 0.15s ease;
    padding: 0 10px;
    font-size: 12px;
    white-space: nowrap;
}

#btnPickGroupCategory:hover {
    border-color: rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.10);
}

#btnPickGroupCategory:active {
    transform: translateY(1px);
}

/* Add Group：Category 标签选择悬浮框 */
.category-pick-popover {
    position: fixed;
    z-index: 10000;
    width: min(520px, calc(100vw - 28px));
    background: linear-gradient(180deg, rgba(17, 26, 43, 0.98), rgba(15, 23, 38, 0.98));
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 10px;
}

.category-pick-title {
    font-size: 12px;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 10px;
}

.category-pick-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 320px;
    overflow: auto;
    padding-right: 2px;
}

.category-chip {
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
    user-select: none;
}

.category-chip:hover {
    border-color: rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.08);
}

.category-chip.is-selected {
    border-color: rgba(79, 140, 255, 0.7);
    background: rgba(79, 140, 255, 0.14);
}

.category-pick-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 10px;
}

.th-select-btn {
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.04);
    color: rgba(232, 237, 247, 0.82);
    border-radius: 8px;
    padding: 2px 6px;
    font-size: 11px;
    line-height: 1.2;
    cursor: pointer;
    user-select: none;
}

.th-select-btn:hover {
    border-color: rgba(255, 255, 255, 0.30);
    background: rgba(255, 255, 255, 0.06);
}

.table .col-hide input[type="checkbox"] {
    width: 14px;
    height: 14px;
    margin: 0;
    cursor: pointer;
    accent-color: rgba(79, 140, 255, 0.22);
}

.table tbody tr:hover {
    background: rgba(255, 255, 255, 0.04);
}

/* 默认隐藏高级列：dataId / cardColClass / fallbackIcon / alt */
.table th.col-advanced,
.table td.col-advanced {
    display: none;
}

.table.show-advanced th.col-advanced,
.table.show-advanced td.col-advanced {
    display: table-cell;
}

.toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    color: var(--muted);
    font-size: 12px;
}

.toggle input {
    width: auto;
}

.export-panel {
    background: linear-gradient(180deg, rgba(17, 26, 43, 0.70), rgba(15, 23, 38, 0.75));
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 12px;
    overflow: hidden;
}

/* 预览区作为右下角独立面板：有多余高度时贴底 */
.preview-panel {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.export-title {
    font-size: 12px;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 8px;
}

.table input,
.table textarea {
    width: 100%;
    min-width: 0;
    padding: 6px 8px;
    border-radius: 10px;
}

/* 条目编辑区：强制单行，避免出现纵向滚动条 */
.table input {
    height: 30px;
    line-height: 30px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 表格内的图标选择按钮跟随行高（避免 34px 撑高行） */
.table .icon-picker-preview,
.table .icon-picker-open {
    height: 30px;
    border-radius: 10px;
}

.table .icon-picker-preview {
    width: 34px;
}

.table tbody td {
    vertical-align: middle;
}

.col-select {
    width: 110px;
}

/* 默认列宽（可拖拽调整） */
.table col.col-select {
    width: 110px;
}

.table col.col-hide {
    width: 56px;
}

.table col.col-name {
    width: 180px;
}

.table col.col-desc {
    width: 220px;
}

.table col.col-url {
    width: 220px;
}

.table col.col-icon {
    width: 160px;
}

.table col.col-title {
    width: 280px;
}

.table col.col-togoUrl {
    width: 220px;
}

.table col.col-togoTitle {
    width: 110px;
}

.table col.col-dataId {
    width: 70px;
}

.table col.col-fallbackIcon {
    width: 160px;
}

.table col.col-alt {
    width: 180px;
}

.table col.col-cardColClass {
    width: 120px;
}

/* 生成内容预览：增高并保持稳定布局 */
#exportText {
    flex: 1 1 auto;
    min-height: 0;
    resize: none;
}

.table tbody tr.row-selected {
    background: rgba(79, 140, 255, 0.08);
}

.table tbody tr.row-hidden {
    opacity: 0.62;
}

.footer {
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.06);
}

@media (max-width: 980px) {
    .layout {
        grid-template-columns: 1fr;
    }
}

/* 竖屏/手机：顶部栏与 group 元信息行优化 */
@media (max-width: 720px) {
    .topbar {
        flex-wrap: wrap;
        align-items: flex-start;
        gap: 10px;
        padding: 10px 12px;
    }

    .title {
        min-width: 0;
        flex: 1 1 100%;
    }

    .title h1 {
        font-size: 14px;
        line-height: 1.2;
    }

    .subtitle {
        font-size: 11px;
        line-height: 1.25;
    }

    /* 右侧按钮保持单行（横向滚动），避免竖屏换行挤压 */
    .topbar-actions {
        width: 100%;
        margin-top: 0;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        gap: 6px;
    }

    .topbar-actions .btn {
        padding: 6px 8px;
        font-size: 12px;
        white-space: nowrap;
        flex: 0 0 auto;
    }

    .content-header {
        flex-direction: column;
        align-items: stretch;
    }

    .content-actions {
        justify-content: flex-start;
    }

    /* 竖屏下 group 顶部一行：改为自动换行布局，避免 grid 横向滚动导致显示异常 */
    .group-meta-line {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
        overflow: visible;
    }

    .group-meta-line .group-id-badge {
        flex: 0 0 auto;
    }

    .group-meta-line .field-inline {
        flex: 1 1 calc(50% - 8px);
        min-width: 140px;
    }

    .group-meta-line .field-inline>input[type="text"] {
        width: 100%;
    }

    .group-meta-line .field-expanded {
        flex: 0 0 auto;
        margin-left: auto;
    }
}

@media (max-width: 420px) {
    .group-meta-line .field-inline {
        flex-basis: 100%;
        min-width: 0;
    }

    .group-meta-line .field-expanded {
        width: 100%;
        margin-left: 0;
        justify-content: flex-start;
    }
}

/* 竖屏模式：不依赖屏幕宽度，保证顶部布局符合移动端交互习惯 */
@media (orientation: portrait) and (min-width: 768px) {
    .content-header {
        flex-direction: column;
        align-items: stretch;
    }

    /* group 编辑框顶部：两行布局（第一行到 Title，第二行 Icon+Expanded） */
    .group-meta-line {
        grid-template-columns: minmax(72px, auto) minmax(0, 1fr) minmax(0, 1fr) auto;
        grid-template-areas:
            "id category title title"
            "id icon icon expanded";
        overflow-x: hidden;
        gap: 8px;
    }

    .group-id-badge {
        grid-area: id;
        align-self: start;
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .group-meta-line .field-category {
        grid-area: category;
    }

    .group-meta-line .field-title {
        grid-area: title;
    }

    .group-meta-line .field-caticon {
        grid-area: icon;
    }

    .group-meta-line .field-expanded {
        grid-area: expanded;
        justify-self: end;
    }

    /* Edit Advanced Columns：单独一行 */
    .toggle {
        width: 100%;
    }

    /* 右侧编辑功能按钮：单独一行，必要时横向滚动 */
    .content-actions {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        justify-content: flex-end;
        white-space: nowrap;
    }
}

/* Add Group: 自动生成的只读 groupId 更像“系统值” */
#addGroupId[readonly] {
    opacity: 0.9;
    background: rgba(255, 255, 255, 0.06);
}