/* ==========================================================================
   共享剪贴板 — 设计系统
   --------------------------------------------------------------------------
   1. 设计令牌（浅色 / 深色双主题）
   2. 基础 & 全局
   3. 应用布局（侧栏 + 主区域）
   4. 侧栏组件（品牌 / 搜索 / 文件夹树 / 状态）
   5. 主区域（顶栏 / Composer / 内容卡片）
   6. 通用组件（按钮 / 输入 / 开关 / 色板 / 模态框 / Toast / 骨架）
   7. 移动端适配（抽屉 + FAB）
   --------------------------------------------------------------------------
   性能约定：transition 只作用于具体属性；悬浮效果避免位移引发的布局抖动
   ========================================================================== */

/* ---------- 1. 设计令牌 ---------- */

:root {
    --bg: #edf3f9;
    --surface: #ffffff;
    --surface-2: #f5f8fb;
    --surface-3: #eaf1f7;
    --border: #dfe7ef;
    --border-strong: #cbd7e3;

    --text: #1b2733;
    --text-secondary: #52616f;
    --text-muted: #8595a5;

    --primary: #1f95ec;
    --primary-hover: #1a80cd;
    --primary-soft: rgba(31, 149, 236, 0.1);
    --primary-soft-2: rgba(31, 149, 236, 0.18);
    --on-primary: #ffffff;

    --danger: #e5484d;
    --danger-hover: #d93b40;
    --danger-soft: rgba(229, 72, 77, 0.1);
    --warning: #f0a020;
    --warning-soft: rgba(240, 160, 32, 0.12);
    --success: #2f9e6a;

    --shadow-sm: 0 1px 2px rgba(23, 43, 66, 0.06);
    --shadow-md: 0 4px 16px rgba(23, 43, 66, 0.1);
    --shadow-lg: 0 12px 40px rgba(23, 43, 66, 0.18);

    --radius-sm: 8px;
    --radius: 10px;
    --radius-lg: 14px;

    --sidebar-width: 280px;
    --content-width: 880px;
    --scrollbar-size: 10px;

    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
        'Hiragino Sans GB', 'Microsoft YaHei', Roboto, 'Helvetica Neue', Arial, sans-serif;

    color-scheme: light;
}

[data-theme="dark"] {
    --bg: #0e141b;
    --surface: #161e28;
    --surface-2: #1b2531;
    --surface-3: #212d3b;
    --border: #253141;
    --border-strong: #324153;

    --text: #e4ecf4;
    --text-secondary: #a3b2c2;
    --text-muted: #6d7f91;

    --primary: #3ba3f0;
    --primary-hover: #5cb3f3;
    --primary-soft: rgba(59, 163, 240, 0.14);
    --primary-soft-2: rgba(59, 163, 240, 0.24);
    --on-primary: #08141e;

    --danger: #f26669;
    --danger-hover: #f58486;
    --danger-soft: rgba(242, 102, 105, 0.14);
    --warning: #f5b04d;
    --warning-soft: rgba(245, 176, 77, 0.14);
    --success: #46b881;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.36);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);

    color-scheme: dark;
}

/* ---------- 2. 基础 & 全局 ---------- */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* hidden 属性优先于任何显式 display（upgradeBanner 等 flex 容器依赖此规则） */
[hidden] {
    display: none !important;
}

html,
body {
    height: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

body.modal-open {
    overflow: hidden;
}

.icon {
    width: 1.15em;
    height: 1.15em;
    flex: none;
    vertical-align: -0.2em;
}

/* .spin 可作用于 svg 自身，或包裹图标的占位 span（行内元素动画无效，转其内部 svg） */
svg.spin,
.spin .icon,
.spinning .icon {
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

::-webkit-scrollbar {
    width: var(--scrollbar-size);
    height: var(--scrollbar-size);
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 6px;
    border: 2px solid transparent;
    background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-muted);
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ---------- 3. 应用布局 ---------- */

.app {
    display: flex;
    height: 100dvh;
    max-width: 1680px;
    margin: 0 auto;
    background: var(--surface);
    border-inline: 1px solid var(--border);
}

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

/* ---------- 4. 侧栏 ---------- */

.sidebar {
    width: var(--sidebar-width);
    flex: none;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--border);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 16px 16px 12px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.brand .icon {
    width: 22px;
    height: 22px;
    color: var(--primary);
}

.search-box {
    position: relative;
    padding: 0 16px 12px;
}

.search-box .icon {
    position: absolute;
    left: 28px;
    top: 50%;
    transform: translateY(calc(-50% - 6px));
    width: 15px;
    height: 15px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    padding: 9px 12px 9px 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.search-box input:focus {
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.folder-tree {
    flex: 1;
    overflow-y: auto;
    /* gutter 占据右侧滚动条宽度，抵消后让文件夹行与搜索框同为 16px 边距。 */
    padding: 4px calc(16px - var(--scrollbar-size)) 4px 16px;
    scrollbar-gutter: stable;
}

.folder-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
    margin: 2px 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    user-select: none;
    position: relative;
    transition: background-color 0.12s ease, color 0.12s ease;
}

/* 桌面端编辑按钮为绝对定位，需要为它保留独立的尾部空间。 */
.folder-item[draggable="true"] {
    padding-right: 44px;
}

.folder-item:hover {
    background: var(--surface-2);
    color: var(--text);
}

.folder-item.active {
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 600;
}

.folder-home-icon {
    display: inline-flex;
    width: 16px;
    margin-left: 2px;
    justify-content: center;
}

.folder-color {
    width: 10px;
    height: 10px;
    margin-left: 8px;
    flex: none;
    border-radius: 3px;
}

.folder-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13.5px;
}

.folder-badge {
    display: inline-flex;
    color: var(--text-muted);
}

.folder-badge .icon {
    width: 13px;
    height: 13px;
}

.folder-badge.pinned {
    color: var(--warning);
}

.folder-count {
    flex: none;
    font-size: 11.5px;
    color: var(--text-muted);
    background: var(--surface-3);
    border-radius: 99px;
    padding: 1px 7px;
    line-height: 1.5;
    white-space: nowrap;
}

.folder-item.active .folder-count {
    background: var(--primary-soft-2);
    color: var(--primary);
}

.folder-edit-btn {
    display: none;
    position: absolute;
    right: 6px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.folder-item:hover .folder-edit-btn {
    display: inline-flex;
}

.folder-item:hover .folder-count {
    visibility: hidden; /* 给编辑按钮让位，避免重叠 */
}

.folder-drag-handle {
    display: inline-flex;
    position: absolute;
    left: 2px;
    width: 14px;
    color: var(--text-muted);
    opacity: 0;
    cursor: grab;
    transition: opacity 0.12s ease;
}

.folder-item:hover .folder-drag-handle {
    opacity: 0.7;
}

.folder-item.dragging {
    opacity: 0.55;
    background: var(--primary-soft);
}

.folder-item.drop-above::before,
.folder-item.drop-below::after {
    content: "";
    position: absolute;
    left: 6px;
    right: 6px;
    height: 2px;
    border-radius: 2px;
    background: var(--primary);
}

.folder-item.drop-above::before {
    top: -2px;
}

.folder-item.drop-below::after {
    bottom: -2px;
}

.sidebar-actions {
    padding: 10px 16px;
}

.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    flex: none;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-dot.connected {
    background: var(--success);
}

.status-dot.connecting {
    background: var(--warning);
    animation: pulse 1.6s ease-in-out infinite;
}

.status-dot.error {
    background: var(--danger);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

.status-text {
    flex: 1;
}

.sidebar-backdrop {
    display: none;
}

/* ---------- 5. 主区域 ---------- */

.main-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex: none;
}

.main-title {
    display: flex;
    align-items: baseline;
    gap: 14px;
    flex: 1;
    min-width: 0;
}

.main-title h1 {
    font-size: 18px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.main-meta {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.upgrade-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 24px 0;
    padding: 10px 14px;
    border: 1px solid var(--warning);
    background: var(--warning-soft);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--text);
    flex: none;
}

.upgrade-banner .icon {
    color: var(--warning);
}

.upgrade-banner a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}

.upgrade-banner a:hover {
    text-decoration: underline;
}

/* --- Composer（输入区）--- */

.composer {
    flex: none;
    /* 与 items-scroll 的稳定滚动条 gutter 使用相同的内容宽度基准。 */
    padding: 14px calc(24px + var(--scrollbar-size)) 0 24px;
    max-width: calc(var(--content-width) + 48px + var(--scrollbar-size));
    width: 100%;
    margin: 0 auto;
}

.composer-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    background: var(--surface);
    color: var(--text-muted);
    font-size: 13.5px;
    font-family: inherit;
    cursor: text;
    text-align: left;
    transition: border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.composer-trigger:hover {
    border-color: var(--primary);
    color: var(--text-secondary);
    box-shadow: var(--shadow-sm);
}

.composer-trigger .icon {
    color: var(--primary);
}

.composer-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px;
    box-shadow: var(--shadow-sm);
}

.composer-form input[type="text"] {
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 14.5px;
    font-weight: 600;
    font-family: inherit;
    outline: none;
    padding: 2px 2px 8px;
}

.composer-form input[type="text"]::placeholder,
.composer-form textarea::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.composer-form textarea {
    width: 100%;
    min-height: 88px;
    max-height: 40vh;
    resize: vertical;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    line-height: 1.6;
    padding: 10px 12px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.composer-form textarea:focus {
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

textarea.drag-over {
    border-color: var(--primary) !important;
    background: var(--primary-soft) !important;
}

.composer-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.spacer {
    flex: 1;
}

/* --- 内容列表 --- */

.items-scroll {
    flex: 1;
    overflow-y: auto;
    scrollbar-gutter: stable;
}

.items {
    max-width: calc(var(--content-width) + 48px);
    margin: 0 auto;
    padding: 14px 24px 8px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    margin-bottom: 12px;
    cursor: pointer;
    position: relative;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}

.card.copied {
    animation: copy-flash 0.5s ease;
}

@keyframes copy-flash {
    0% { background: var(--surface); }
    45% { background: var(--primary-soft-2); }
    100% { background: var(--surface); }
}

.card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.card-heading {
    min-width: 0;
}

.card-title {
    font-size: 15px;
    font-weight: 650;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.card-folder {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 1px 8px;
    border-radius: 99px;
    background: var(--surface-3);
    color: var(--text-secondary);
    font-size: 11.5px;
}

.card-folder::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 2px;
    background: var(--folder-color, var(--primary));
}

.card-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.12s ease;
}

.card:hover .card-actions,
.card:focus-within .card-actions {
    opacity: 1;
}

.card-content {
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 260px;
    overflow: hidden;
}

.card-truncated {
    color: var(--text-muted);
}

.card-more {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

/* --- 卡片附件 --- */

.card-attachment {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.attachment-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--text-secondary);
    text-decoration: none;
    transition: background-color 0.12s ease;
}

.attachment-row:hover {
    background: var(--surface-3);
}

.attachment-file-icon {
    display: inline-flex;
    color: var(--primary);
}

.attachment-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    color: var(--text);
}

.attachment-size {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.attachment-download {
    display: inline-flex;
    color: var(--text-muted);
}

.attachment-thumb-wrap {
    position: relative;
    display: inline-block;
    max-width: 100%;
    border-radius: var(--radius);
    overflow: hidden;
    line-height: 0;
}

.attachment-thumb {
    max-width: 100%;
    max-height: 220px;
    display: block;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.attachment-zoom {
    position: absolute;
    right: 8px;
    top: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    opacity: 0;
    transition: opacity 0.12s ease;
}

.attachment-thumb-wrap:hover .attachment-zoom {
    opacity: 1;
}

.attachment-caption {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 12.5px;
    color: var(--text-muted);
}

.attachment-caption .attachment-name {
    flex: none;
    max-width: 60%;
}

/* --- 附件预览（composer / 编辑框内）--- */

.attachment-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.attachment-preview[hidden] {
    display: none;
}

.attachment-preview-thumb {
    width: 52px;
    height: 52px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    flex: none;
}

.attachment-preview-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    background: var(--primary-soft);
    color: var(--primary);
    flex: none;
}

.attachment-preview-icon .icon {
    width: 22px;
    height: 22px;
}

.attachment-preview-info {
    flex: 1;
    min-width: 0;
}

.attachment-preview-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-preview-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.attachment-preview-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    padding: 6px;
}

/* --- 空状态 / 加载更多 --- */

.empty-state {
    text-align: center;
    padding: 72px 20px;
    color: var(--text-muted);
}

.empty-state .icon {
    width: 44px;
    height: 44px;
    opacity: 0.45;
    margin-bottom: 14px;
}

.empty-state p {
    font-size: 14px;
}

.empty-hint {
    font-size: 12.5px;
    margin-top: 6px;
    opacity: 0.8;
}

.load-more {
    display: flex;
    justify-content: center;
    padding: 4px 24px 24px;
}

.load-more[hidden] {
    display: none;
}

/* ---------- 6. 通用组件 ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 15px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: 13.5px;
    font-weight: 550;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    outline: none;
    transition: background-color 0.13s ease, border-color 0.13s ease, color 0.13s ease, box-shadow 0.13s ease;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn:focus-visible {
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.btn-primary {
    background: var(--primary);
    color: var(--on-primary);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border-strong);
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
    background: var(--danger-soft);
    color: var(--danger-hover);
}

.btn-block {
    width: 100%;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex: none;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    outline: none;
    transition: background-color 0.12s ease, color 0.12s ease;
}

.icon-btn:hover {
    background: var(--surface-3);
    color: var(--text);
}

.icon-btn:focus-visible {
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.icon-btn .icon {
    width: 16px;
    height: 16px;
}

.select {
    padding: 8px 32px 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background-color: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    cursor: pointer;
    max-width: 200px;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='m6 9 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 14px;
    transition: border-color 0.13s ease, box-shadow 0.13s ease;
}

.select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.hidden-file-input {
    display: none;
}

/* --- 模态框 --- */

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(9, 16, 24, 0.5);
    backdrop-filter: blur(3px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.open {
    display: flex;
    animation: fade-in 0.16s ease;
}

.modal-dialog {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 520px;
    max-height: 86vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: slide-up 0.18s ease;
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slide-up {
    from { transform: translateY(14px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex: none;
}

.modal-header h3 {
    font-size: 15.5px;
    font-weight: 700;
}

.modal-body {
    padding: 18px 20px;
    overflow-y: auto;
}

.modal-body input[type="text"],
.modal-body textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    margin-bottom: 14px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.modal-body input[type="text"]:focus,
.modal-body textarea:focus {
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.modal-body textarea {
    min-height: 150px;
    max-height: 46vh;
    resize: vertical;
    line-height: 1.6;
}

.modal-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    flex: none;
}

.field-label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 7px;
}

.edit-extra-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
    flex-wrap: wrap;
}

/* --- 色板 --- */

.color-options {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.color-option {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    outline: 2px solid transparent;
    outline-offset: 2px;
    cursor: pointer;
    transition: outline-color 0.12s ease, transform 0.12s ease;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.selected {
    outline-color: var(--text);
}

/* --- 开关 --- */

.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 0;
    font-size: 13.5px;
    color: var(--text);
    cursor: pointer;
}

.switch {
    appearance: none;
    width: 40px;
    height: 22px;
    flex: none;
    border-radius: 99px;
    background: var(--border-strong);
    position: relative;
    cursor: pointer;
    outline: none;
    transition: background-color 0.16s ease;
}

.switch::before {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: var(--shadow-sm);
    transition: transform 0.16s ease;
}

.switch:checked {
    background: var(--primary);
}

.switch:checked::before {
    transform: translateX(18px);
}

.switch:focus-visible {
    box-shadow: 0 0 0 3px var(--primary-soft);
}

/* --- 图片预览 --- */

.image-preview {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(5, 10, 16, 0.88);
    z-index: 1100;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 24px;
}

.image-preview.open {
    display: flex;
    animation: fade-in 0.16s ease;
}

.image-preview img {
    max-width: min(92vw, 1200px);
    max-height: 78vh;
    object-fit: contain;
    border-radius: var(--radius);
}

.image-preview-close {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.image-preview-close:hover {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
}

.image-preview-download {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    border: none;
    text-decoration: none;
}

.image-preview-download:hover {
    background: rgba(255, 255, 255, 0.26);
    color: #fff;
}

/* --- Toast --- */

.toast {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 1200;
    padding: 11px 18px;
    border-radius: var(--radius);
    background: var(--success);
    color: #fff;
    font-size: 13.5px;
    font-weight: 550;
    box-shadow: var(--shadow-md);
    transform: translateX(calc(100% + 24px));
    transition: transform 0.22s ease;
    max-width: min(86vw, 420px);
    word-break: break-word;
}

.toast.show {
    transform: translateX(0);
}

.toast.error {
    background: var(--danger);
}

.toast.warning {
    background: var(--warning);
    color: #3d2c00;
}

/* --- 骨架屏 --- */

.skeleton-card {
    pointer-events: none;
}

.skeleton {
    background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.3s ease-in-out infinite;
    border-radius: 6px;
}

@keyframes shimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

.skeleton-title {
    width: 38%;
    height: 15px;
    margin-bottom: 12px;
}

.skeleton-line {
    width: 92%;
    height: 12px;
    margin-bottom: 8px;
}

.skeleton-line.short {
    width: 61%;
}

/* --- FAB --- */

.fab {
    display: none;
    position: fixed;
    right: 18px;
    bottom: 22px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: var(--on-primary);
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    z-index: 900;
    align-items: center;
    justify-content: center;
    transition: background-color 0.13s ease, transform 0.13s ease;
}

.fab:hover {
    background: var(--primary-hover);
}

.fab:active {
    transform: scale(0.94);
}

.fab .icon {
    width: 22px;
    height: 22px;
}

.mobile-only {
    display: none !important;
}

/* ---------- 7. 移动端 ---------- */

@media (max-width: 768px) {
    .mobile-only {
        display: inline-flex !important;
    }

    .app {
        border-inline: none;
    }

    /* 侧栏 → 抽屉 */
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 1050;
        width: min(84vw, 320px);
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1040;
        background: rgba(9, 16, 24, 0.45);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
    }

    .sidebar-backdrop.show {
        opacity: 1;
        pointer-events: auto;
    }

    /* 触屏没有 hover，操作按钮常显 */
    .card-actions {
        opacity: 1;
    }

    .folder-edit-btn {
        display: inline-flex;
        position: static;
        box-shadow: none;
        background: transparent;
    }

    /* 移动端按钮参与 flex 布局，不再需要桌面端的预留空间。 */
    .folder-item[draggable="true"] {
        padding-right: 10px;
    }

    .folder-item .folder-count {
        visibility: visible;
    }

    .folder-drag-handle {
        opacity: 0.45;
    }

    .main-header {
        padding: 10px 14px;
    }

    .main-title {
        flex-direction: column;
        gap: 1px;
    }

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

    .main-meta {
        gap: 8px;
        font-size: 11px;
    }

    .composer {
        padding: 10px calc(14px + var(--scrollbar-size)) 0 14px;
    }

    .items {
        padding: 12px 14px 8px;
    }

    .card {
        padding: 13px 14px;
    }

    .fab {
        display: flex;
    }

    .composer-actions .select {
        max-width: none;
        flex: 1;
    }

    .upgrade-banner {
        margin: 10px 14px 0;
    }

    .modal {
        padding: 12px;
        align-items: flex-end;
    }

    .modal-dialog {
        max-height: 92vh;
        animation: slide-up-mobile 0.2s ease;
    }

    @keyframes slide-up-mobile {
        from { transform: translateY(40px); opacity: 0; }
        to { transform: translateY(0); opacity: 1; }
    }

    .toast {
        left: 14px;
        right: 14px;
        top: 12px;
        max-width: none;
        transform: translateY(calc(-100% - 20px));
    }

    .toast.show {
        transform: translateY(0);
    }
}

/* 平板：收窄侧栏 */
@media (min-width: 769px) and (max-width: 1024px) {
    :root {
        --sidebar-width: 240px;
    }
}
