/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    --bg: #ffffff;
    --bg-2: #f7f7f8;
    --bg-3: #efefef;
    --border: #e5e5e5;
    --text-1: #111111;
    --text-2: #6e6e80;
    --text-3: #adadbd;
    --accent: #10a37f;
    --accent-hover: #0d8f6e;
    --sidebar-w: 228px;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow-card: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-card-hover: 0 4px 16px rgba(0,0,0,.10), 0 2px 4px rgba(0,0,0,.06);
}

html { font-size: 15px; }
body { font-family: var(--font); background: var(--bg); color: var(--text-1); line-height: 1.5; -webkit-font-smoothing: antialiased; }

/* ── Layout ── */
.layout { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--bg-2);
    border-right: 1px solid var(--border);
    padding: 20px 12px 24px;
    display: flex;
    flex-direction: column;
    gap: 28px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 6px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-1);
    letter-spacing: -0.01em;
}

.sidebar-logo {
    width: 28px;
    height: 28px;
    background: var(--text-1);
    color: #fff;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 800;
    flex-shrink: 0;
    line-height: 1;
}

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

.nav-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    color: var(--text-2);
    text-decoration: none;
    transition: background 0.12s ease, color 0.12s ease;
    line-height: 1.3;
}

.nav-item:hover { background: var(--bg-3); color: var(--text-1); }
.nav-item.active { background: var(--bg-3); color: var(--text-1); font-weight: 500; }

.nav-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.6;
}
.nav-item.active .nav-icon { opacity: 1; }
.nav-spacer { flex: 1; }

/* ── Main Content ── */
.main-content {
    flex: 1;
    padding: 36px 44px 60px;
    overflow-y: auto;
    min-width: 0;
}

.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 20px; font-weight: 600; color: var(--text-1); letter-spacing: -0.02em; }

.page-body {}

/* ── Search Bar ── */
.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 28px;
    max-width: 640px;
}

.search-bar input {
    flex: 1;
    height: 38px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13.5px;
    font-family: var(--font);
    color: var(--text-1);
    background: var(--bg);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.search-bar input::placeholder { color: var(--text-3); }

.search-bar input:focus {
    border-color: #aaa;
    box-shadow: 0 0 0 3px rgba(0,0,0,.05);
}

.search-bar button {
    display: flex;
    align-items: center;
    gap: 7px;
    height: 38px;
    padding: 0 16px;
    background: var(--text-1);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13.5px;
    font-family: var(--font);
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}

.search-bar button:hover { background: #333; }
.search-bar button:active { background: #222; transform: scale(0.98); }
.search-bar button:disabled { background: #aaa; cursor: not-allowed; transform: none; }

/* ── Grid Toolbar ── */
.grid-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    min-height: 28px;
}

.posts-counter {
    font-size: 12px;
    color: var(--text-3);
    font-variant-numeric: tabular-nums;
}

.clear-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-family: var(--font);
    color: var(--text-2);
    cursor: pointer;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.clear-btn:hover {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #c0392b;
}

/* ── Toast ── */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(12px);
    background: #1a1a1a;
    color: #fff;
    font-size: 13px;
    padding: 10px 18px;
    border-radius: 8px;
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 9999;
    pointer-events: none;
    white-space: nowrap;
    max-width: 90vw;
    text-overflow: ellipsis;
    overflow: hidden;
}

.toast.toast-show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── Card Grid ── */
.card-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 18px;
}

/* ── Post Card Cover Wrapper ── */
.post-card-cover {
    position: relative;
    width: 100%;
}

/* ── Post Card ── */
.post-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg);
    box-shadow: var(--shadow-card);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    cursor: pointer;
    text-decoration: none;
    display: block;
    color: inherit;
}

.post-card:hover {
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-2px);
}

.post-card-image {
    width: 100%;
    aspect-ratio: 4 / 5;
    object-fit: cover;
    background: var(--bg-2);
    display: block;
}

.post-card-placeholder {
    width: 100%;
    aspect-ratio: 4 / 5;
    background: var(--bg-2);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--text-3);
    font-size: 11px;
}

.post-card-video-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    pointer-events: none;
}

.post-card-body { padding: 10px 12px 13px; }

.post-card-ai-title {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-1);
    line-height: 1.4;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-card-caption {
    font-size: 12.5px;
    color: var(--text-1);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 7px;
    line-height: 1.45;
}

.post-card-meta {
    font-size: 11.5px;
    color: var(--text-3);
    font-weight: 500;
}

/* ── State: loading / error / empty ── */
.loading-state,
.error-state,
.empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 80px 24px;
    color: var(--text-3);
    font-size: 13.5px;
    text-align: center;
}

.loading-state { color: var(--text-2); }
.error-state { color: #c0392b; }

.loading-dots {
    display: flex;
    gap: 6px;
}

.loading-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-3);
    animation: bounce 1.2s infinite ease-in-out;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: .4; }
    40%            { transform: translateY(-6px); opacity: 1; }
}

/* ── Source Section ── */
.source-section {
    max-width: 680px;
    margin-left: auto;
    margin-right: auto;
}

.source-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 10px;
    border-bottom: 2px solid #3b82f6;
    margin-bottom: 20px;
    width: fit-content;
    min-width: 160px;
}

.source-section-header span {
    font-size: 14px;
    font-weight: 600;
    color: #3b82f6;
}

.source-search-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0 14px;
    background: var(--bg);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.source-search-wrap:focus-within {
    border-color: #aaa;
    box-shadow: 0 0 0 3px rgba(0,0,0,.05);
}

.source-search-icon {
    color: var(--text-3);
    flex-shrink: 0;
}

.source-search-input {
    flex: 1;
    height: 42px;
    border: none;
    outline: none;
    font-size: 13.5px;
    font-family: var(--font);
    color: var(--text-1);
    background: transparent;
}

.source-search-input::placeholder { color: var(--text-3); }

/* ── Source Spinner ── */
.source-spinner {
    display: flex;
    align-items: center;
    padding-right: 4px;
}

.spinner-ring {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--text-2);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}

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

/* ── Profile Result ── */
.profile-result {
    margin-top: 14px;
    max-width: 680px;
}

.profile-error {
    font-size: 13px;
    color: #c0392b;
    padding: 12px 0;
}

.profile-card {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.15s;
}

.profile-card:hover { box-shadow: var(--shadow-card-hover); }

.profile-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-2);
    flex-shrink: 0;
    border: 1px solid var(--border);
}

.profile-avatar.avatar-error {
    background: var(--bg-3);
}

.profile-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.profile-name-row {
    display: flex;
    align-items: center;
    gap: 5px;
}

.profile-fullname {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-1);
}

.verified-badge { flex-shrink: 0; }

.profile-username {
    font-size: 13px;
    color: var(--text-2);
}

.profile-bio {
    font-size: 13px;
    color: var(--text-1);
    line-height: 1.5;
    margin-top: 4px;
    white-space: pre-line;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.profile-stats {
    display: flex;
    gap: 18px;
    margin-top: 8px;
    font-size: 12.5px;
    color: var(--text-2);
}

.profile-stats strong {
    color: var(--text-1);
    font-weight: 600;
}

/* ── Profile Card layout (search result) ── */
.profile-card {
    display: flex;
    align-items: center;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    overflow: hidden;
    transition: box-shadow 0.15s;
}

.profile-card:hover { box-shadow: var(--shadow-card-hover); }

.profile-card-link {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    padding: 18px;
    text-decoration: none;
    color: inherit;
    flex: 1;
    min-width: 0;
}

/* ── Follow Button ── */
.follow-btn {
    flex-shrink: 0;
    margin: 18px 18px 18px 0;
    padding: 6px 16px;
    border-radius: 20px;
    border: 1.5px solid var(--text-1);
    background: var(--text-1);
    color: #fff;
    font-size: 13px;
    font-family: var(--font);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.follow-btn:hover { background: #333; border-color: #333; }

.follow-btn.following {
    background: transparent;
    color: var(--text-2);
    border-color: var(--border);
}

.follow-btn.following:hover {
    background: #fef2f2;
    color: #c0392b;
    border-color: #fca5a5;
}

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

/* ── Avatar Placeholder ── */
.avatar-placeholder {
    background: var(--bg-3);
    flex-shrink: 0;
}

/* ── Following Section ── */
.following-section { max-width: 680px; margin-left: auto; margin-right: auto; }

.following-section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.following-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-1);
}

.following-counter {
    font-size: 12px;
    color: var(--text-3);
}

.following-empty {
    font-size: 13.5px;
    color: var(--text-3);
    padding: 8px 0;
}

.following-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.following-row {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    gap: 0;
    transition: box-shadow 0.15s;
}

.following-row:hover { box-shadow: var(--shadow-card); }

.following-row-link {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
    text-decoration: none;
    color: inherit;
}

.following-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-2);
    flex-shrink: 0;
    border: 1px solid var(--border);
}

.following-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.following-name-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.following-name {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.following-username {
    font-size: 12px;
    color: var(--text-3);
}

.unfollow-btn {
    flex-shrink: 0;
    padding: 5px 13px;
    border-radius: 20px;
    border: 1.5px solid var(--border);
    background: transparent;
    color: var(--text-2);
    font-size: 12.5px;
    font-family: var(--font);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
    white-space: nowrap;
}

.unfollow-btn:hover {
    background: #fef2f2;
    color: #c0392b;
    border-color: #fca5a5;
}

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

/* ── Media Type Tabs ── */
.type-tabs {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
}

.type-tab {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 14px;
    border: 1.5px solid var(--border);
    border-radius: 20px;
    background: var(--bg);
    font-size: 13px;
    font-family: var(--font);
    color: var(--text-2);
    cursor: pointer;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.type-tab:hover { background: var(--bg-2); color: var(--text-1); }

.type-tab.active {
    background: var(--text-1);
    color: #fff;
    border-color: var(--text-1);
}

.type-tab .tab-count {
    font-size: 11px;
    opacity: 0.7;
}

/* ── Category Tabs ── */
.category-tabs {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.cat-tab {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border-radius: 20px;
    border: 1.5px solid var(--border);
    background: transparent;
    color: var(--text-2);
    font-size: 12.5px;
    font-family: var(--font);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
    white-space: nowrap;
}

.cat-tab:hover {
    background: var(--bg-2);
    border-color: #ccc;
    color: var(--text-1);
}

.cat-tab.active {
    background: var(--text-1);
    border-color: var(--text-1);
    color: #fff;
}

.tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 9px;
    background: rgba(255,255,255,0.22);
    font-size: 10.5px;
    font-weight: 600;
    line-height: 1;
}

.cat-tab:not(.active) .tab-count {
    background: var(--bg-3);
    color: var(--text-2);
}

/* ── Following Row Actions ── */
.following-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* ── Category Select ── */
.cat-select {
    appearance: none;
    -webkit-appearance: none;
    padding: 4px 28px 4px 10px;
    border-radius: 6px;
    border: 1.5px solid var(--border);
    background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23adadbd' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 9px center;
    color: var(--text-2);
    font-size: 12px;
    font-family: var(--font);
    font-weight: 500;
    cursor: pointer;
    outline: none;
    transition: border-color 0.12s, color 0.12s;
    white-space: nowrap;
}

.cat-select:hover { border-color: #bbb; color: var(--text-1); }
.cat-select:focus { border-color: #aaa; box-shadow: 0 0 0 2px rgba(0,0,0,.05); }
.cat-select:disabled { opacity: 0.5; cursor: not-allowed; }

.cat-select option { color: var(--text-1); }

/* ── Coming Soon ── */
.coming-soon {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 48px 0 0;
    color: var(--text-2);
}

.coming-soon h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-1);
}

.coming-soon p {
    font-size: 13.5px;
    color: var(--text-2);
    max-width: 400px;
}

/* ── Select / Delete toolbar ── */
.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Ideas 页分类 tab 与 toolbar 之间距 */
#ideas-cat-tabs {
    margin-bottom: 12px;
}

/* ── Sync button ── */
.sync-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 13px;
    border-radius: 7px;
    border: 1.5px solid var(--border);
    background: transparent;
    color: var(--text-2);
    font-size: 12.5px;
    font-family: var(--font);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
    white-space: nowrap;
}

.sync-btn:hover { background: var(--bg-2); color: var(--text-1); border-color: #bbb; }

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

.select-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 13px;
    border-radius: 7px;
    border: 1.5px solid var(--border);
    background: transparent;
    color: var(--text-2);
    font-size: 12.5px;
    font-family: var(--font);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
    white-space: nowrap;
}

.select-btn:hover { background: var(--bg-2); color: var(--text-1); border-color: #bbb; }

.select-btn.cancel-mode {
    background: var(--bg-2);
    color: var(--text-1);
    border-color: #bbb;
}

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

.delete-selected-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 13px;
    border-radius: 7px;
    border: 1.5px solid #fca5a5;
    background: #fef2f2;
    color: #c0392b;
    font-size: 12.5px;
    font-family: var(--font);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
    white-space: nowrap;
}

.delete-selected-btn:hover { background: #fee2e2; border-color: #f87171; }
.delete-selected-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Card select mode ── */
.post-card-check {
    display: none;
    position: absolute;
    top: 8px;
    left: 8px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(255,255,255,0.92);
    border: 2px solid rgba(0,0,0,0.15);
    align-items: center;
    justify-content: center;
    color: transparent;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
    pointer-events: none;
    z-index: 2;
}

.card-grid.select-mode .post-card { cursor: pointer; }
.card-grid.select-mode .post-card:hover .post-card-check { display: flex; }
.card-grid.select-mode .post-card .post-card-check { display: flex; }

.card-grid.select-mode .post-card.selected .post-card-check {
    background: var(--text-1);
    border-color: var(--text-1);
    color: #fff;
}

.card-grid.select-mode .post-card.selected .post-card-cover::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.25);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    pointer-events: none;
}

.card-grid.select-mode .post-card:not(.selected):hover .post-card-cover::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.06);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    pointer-events: none;
}

/* ── Post Modal ── */
.post-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.post-modal.is-open { display: flex; }

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

.post-modal-box {
    position: relative;
    z-index: 1;
    display: flex;
    background: var(--bg);
    border-radius: 14px;
    overflow: hidden;
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    box-shadow: 0 24px 64px rgba(0,0,0,.22);
    animation: modalIn 0.22s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.96) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.post-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.08);
    color: var(--text-1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.12s;
}

.post-modal-close:hover { background: rgba(0,0,0,0.15); }

/* ── Media panel ── */
.post-modal-media {
    flex: 0 0 auto;
    width: 50%;
    max-width: 460px;
    background: var(--bg-2);
    /* 不限制高度，让 iframe 内容自然撑开 */
    overflow-y: auto;
    overflow-x: hidden;
}

.modal-iframe {
    width: 100%;
    /* 默认给足够高度：4:5 图 + embed 头尾 ≈ 700px */
    height: 700px;
    min-height: 500px;
    border: none;
    display: block;
}

.modal-image {
    width: 100%;
    aspect-ratio: 4 / 5;
    object-fit: cover;
    display: block;
}

/* ── Info panel ── */
.post-modal-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 28px 24px 24px;
    overflow-y: auto;
}

.modal-author {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.modal-displayname {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-1);
}

.modal-username {
    font-size: 13px;
    color: var(--text-2);
}

.modal-date {
    font-size: 12px;
    color: var(--text-3);
}

.modal-caption {
    font-size: 13.5px;
    color: var(--text-1);
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
    flex: 1;
    overflow-y: auto;
    padding-right: 4px;
}

.modal-footer-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: auto;
}

.modal-link,
.modal-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 14px;
    border-radius: 8px;
    border: 1.5px solid var(--border);
    background: transparent;
    color: var(--text-2);
    font-size: 12.5px;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
    white-space: nowrap;
}

.modal-link:hover { background: var(--bg-2); color: var(--text-1); border-color: #bbb; }

.modal-download-btn:hover {
    background: #eff6ff;
    color: #2563eb;
    border-color: #93c5fd;
}

/* ── Modal responsive ── */
@media (max-width: 640px) {
    .post-modal-box {
        flex-direction: column;
        max-height: 95vh;
    }

    .post-modal-media {
        width: 100%;
        max-width: 100%;
        max-height: 60vh;
        overflow-y: auto;
    }

    .modal-iframe {
        height: 700px;
        min-height: 400px;
    }

    .post-modal-info {
        padding: 16px;
        max-height: 45vh;
    }

    .post-modal-close {
        background: rgba(255,255,255,0.85);
    }
}

/* ── Transcribe button ── */
.transcribe-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 13px;
    border-radius: 7px;
    border: 1.5px solid #a5b4fc;
    background: #eef2ff;
    color: #4f46e5;
    font-size: 12.5px;
    font-family: var(--font);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
    white-space: nowrap;
}

.transcribe-btn:hover { background: #e0e7ff; border-color: #818cf8; }
.transcribe-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── AI title in post modal ── */
.modal-ai-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-1);
    line-height: 1.4;
    margin-bottom: 6px;
}

/* ── Shared section label (summary + transcript) ── */
.modal-section-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ── AI summary section ── */
.modal-ai-summary {
    border: 1.5px solid #d1fae5;
    border-radius: 8px;
    padding: 12px 14px;
    background: #f0fdf4;
    margin-bottom: 10px;
}
.modal-ai-summary-text {
    font-size: 13px;
    color: var(--text-1);
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ── Transcript section in post modal ── */
.modal-transcript {
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    background: var(--bg-2);
}

.modal-transcript-text {
    font-size: 13px;
    color: var(--text-1);
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 200px;
    overflow-y: auto;
}

/* ── Transcript progress modal ── */
.transcript-progress-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1200;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.transcript-progress-modal.is-open { display: flex; }

.transcript-progress-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.transcript-progress-box {
    position: relative;
    z-index: 1;
    background: var(--bg);
    border-radius: 14px;
    width: 100%;
    max-width: 560px;
    max-height: 80vh;
    box-shadow: 0 24px 64px rgba(0,0,0,.22);
    animation: modalIn 0.22s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.transcript-progress-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.transcript-progress-title {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-1);
}

.transcript-progress-counter {
    font-size: 12.5px;
    color: var(--text-3);
    font-variant-numeric: tabular-nums;
}

.transcript-item-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.transcript-item {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    background: var(--bg);
    transition: border-color 0.15s;
}

.transcript-item-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.transcript-item-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-1);
}

.transcript-item-status {
    font-size: 11.5px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 20px;
}

.transcript-item-status.pending { background: var(--bg-2); color: var(--text-3); }
.transcript-item-status.running { background: #eef2ff; color: #4f46e5; }
.transcript-item-status.done    { background: #f0fdf4; color: #16a34a; }
.transcript-item-status.error   { background: #fef2f2; color: #c0392b; }

.transcript-item-caption {
    font-size: 12px;
    color: var(--text-2);
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.transcript-item-result {
    margin-top: 10px;
    font-size: 12.5px;
    color: var(--text-1);
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.transcript-progress-footer {
    padding: 14px 24px 20px;
    display: flex;
    justify-content: flex-end;
    flex-shrink: 0;
    border-top: 1px solid var(--border);
}

/* ── Bookmark button on Ideas cards ── */
.post-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.post-card-bookmark {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
    color: var(--text-3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s;
    margin-right: -2px;
    border-radius: 4px;
}

.post-card-bookmark:hover { color: var(--text-1); }
.post-card-bookmark.is-saved { color: var(--text-1); }

/* ── Idea card (text creation) ── */
.idea-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    background: var(--bg);
    box-shadow: var(--shadow-card);
    cursor: pointer;
    transition: box-shadow 0.2s, transform 0.2s;
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-height: 140px;
}

.idea-card:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-2px); }

.idea-card-icon {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: var(--bg-2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-2);
    flex-shrink: 0;
    margin-bottom: 2px;
}

.idea-card-title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-1);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.idea-card-content {
    font-size: 12.5px;
    color: var(--text-2);
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
}

.idea-card-empty { color: var(--text-3); }

.idea-card-date {
    font-size: 11px;
    color: var(--text-3);
    margin-top: auto;
    padding-top: 4px;
}

/* ── Note badge on saved post cards (Creation page) ── */
.post-note-badge {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(255,255,255,0.92);
    border-radius: 6px;
    padding: 3px 7px;
    font-size: 11px;
    color: var(--text-2);
    display: flex;
    align-items: center;
    gap: 4px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    pointer-events: none;
}

/* ── Note / Idea Modal ── */
.note-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1100;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.note-modal.is-open { display: flex; }

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

.note-modal-box {
    position: relative;
    z-index: 1;
    background: var(--bg);
    border-radius: 14px;
    overflow: hidden;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    box-shadow: 0 24px 64px rgba(0,0,0,.22);
    animation: modalIn 0.22s ease;
    display: flex;
    flex-direction: column;
}

.note-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.07);
    color: var(--text-1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.12s;
}

.note-modal-close:hover { background: rgba(0,0,0,0.13); }

.note-modal-post-preview {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px 24px 18px;
    border-bottom: 1px solid var(--border);
}

.note-preview-img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    background: var(--bg-2);
    flex-shrink: 0;
    border: 1px solid var(--border);
}

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

.note-preview-username {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-1);
}

.note-preview-caption {
    font-size: 12px;
    color: var(--text-2);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: 3px;
    line-height: 1.4;
}

.note-modal-form {
    padding: 20px 24px 12px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}
.note-modal-form textarea {
    max-height: 160px;
    resize: vertical;
}

.note-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.note-field label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-2);
    letter-spacing: 0.01em;
}

.note-field input,
.note-field textarea {
    width: 100%;
    padding: 10px 13px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 13.5px;
    font-family: var(--font);
    color: var(--text-1);
    background: var(--bg);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    resize: vertical;
    line-height: 1.55;
}

.note-field input:focus,
.note-field textarea:focus {
    border-color: #aaa;
    box-shadow: 0 0 0 3px rgba(0,0,0,.05);
}

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

.note-modal-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px 16px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.note-footer-right {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.note-save-btn {
    padding: 7px 20px;
    background: var(--text-1);
    color: #fff;
    border: none;
    border-radius: 7px;
    font-size: 13.5px;
    font-family: var(--font);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s;
}

.note-save-btn:hover   { background: #333; }
.note-save-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.note-cancel-btn {
    padding: 7px 14px;
    background: transparent;
    color: var(--text-2);
    border: 1.5px solid var(--border);
    border-radius: 7px;
    font-size: 13.5px;
    font-family: var(--font);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}

.note-cancel-btn:hover { background: var(--bg-2); color: var(--text-1); }

.note-delete-btn {
    padding: 7px 14px;
    background: transparent;
    color: #c0392b;
    border: 1.5px solid #fca5a5;
    border-radius: 7px;
    font-size: 13.5px;
    font-family: var(--font);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s;
}

.note-delete-btn:hover { background: #fef2f2; }

/* ── Responsive ── */
@media (max-width: 1280px) {
    .card-grid { grid-template-columns: repeat(4, 1fr); }
    .main-content { padding: 28px 32px 48px; }
}

@media (max-width: 900px) {
    .card-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
    .layout { flex-direction: column; }

    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        flex-direction: row;
        align-items: center;
        padding: 12px 16px;
        gap: 20px;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .sidebar-nav { flex-direction: row; gap: 4px; }
    .main-content { padding: 20px 16px 40px; }
    .card-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .search-bar { max-width: 100%; }
}

@media (max-width: 480px) {
    .card-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .main-content { padding: 16px 12px 32px; }
}

/* ── AI Polish Button ── */
.note-polish-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    height: 28px;
    padding: 0 11px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-family: var(--font);
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.15s;
}
.note-polish-btn:hover    { opacity: 0.88; }
.note-polish-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── AI Polish Result Panel ── */
.note-polish-result {
    margin: 10px 0 4px;
    border: 1px solid #ddd6fe;
    border-radius: var(--radius-sm);
    background: #faf5ff;
}
.note-polish-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: #ede9fe;
    font-size: 12px;
    font-weight: 600;
    color: #5b21b6;
}
.note-polish-section {
    padding: 8px 12px;
    border-top: 1px solid #ede9fe;
}
.note-polish-label {
    font-size: 10.5px;
    font-weight: 600;
    color: #7c3aed;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}
.note-polish-value {
    font-size: 12.5px;
    color: var(--text-1);
    line-height: 1.6;
    white-space: pre-wrap;
}
.polish-direction-item {
    padding: 4px 0;
    font-size: 12.5px;
    color: var(--text-1);
    line-height: 1.5;
    border-bottom: 1px dashed #e9d5ff;
}
.polish-direction-item:last-child { border-bottom: none; }
.polish-apply-btn {
    display: block;
    width: calc(100% - 24px);
    margin: 8px 12px;
    padding: 7px 0;
    background: #7c3aed;
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    font-family: var(--font);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}
.polish-apply-btn:hover { background: #6d28d9; }

/* ── AI Generate Button ── */
.ai-generate-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 13px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    font-family: var(--font);
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.1s;
}
.ai-generate-btn:hover  { opacity: 0.9; }
.ai-generate-btn:active { transform: scale(0.97); }
.ai-generate-btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

/* ── Settings Page ── */
.settings-wrap { max-width: 560px; }

.settings-toast {
    background: #f0fdf4;
    border: 1px solid #86efac;
    color: #166534;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 24px;
}

.settings-form { display: flex; flex-direction: column; gap: 20px; }

.settings-section {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    background: var(--bg);
}

.settings-section-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 18px;
}

.settings-section-icon {
    width: 32px;
    height: 32px;
    background: var(--bg-2);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--text-2);
}

.settings-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-1);
    margin-bottom: 2px;
}

.settings-section-desc {
    font-size: 12px;
    color: var(--text-3);
}

.settings-field { margin-bottom: 14px; }
.settings-field:last-child { margin-bottom: 0; }

.settings-label {
    display: block;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-2);
    margin-bottom: 6px;
}

.settings-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.settings-input {
    width: 100%;
    height: 36px;
    padding: 0 36px 0 12px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 13px;
    font-family: var(--font);
    color: var(--text-1);
    background: var(--bg);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.settings-input:focus {
    border-color: #aaa;
    box-shadow: 0 0 0 3px rgba(0,0,0,.05);
}

.settings-input-wrap .settings-input { padding-right: 36px; }

.settings-eye-btn {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-3);
    padding: 0;
}
.settings-eye-btn:hover { color: var(--text-2); }

/* standalone input (no eye button) */
.settings-field > .settings-input { padding-right: 12px; }

.settings-hint {
    font-size: 11.5px;
    color: var(--text-3);
    margin-top: 5px;
}

.settings-link { color: var(--accent); text-decoration: none; }
.settings-link:hover { text-decoration: underline; }

.settings-footer { display: flex; justify-content: flex-end; }

.settings-save-btn {
    height: 36px;
    padding: 0 20px;
    background: var(--text-1);
    color: #fff;
    border: none;
    border-radius: 7px;
    font-size: 13.5px;
    font-family: var(--font);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}
.settings-save-btn:hover { background: #333; }

/* ══════════════════════════════════════════════
   Posts Design
══════════════════════════════════════════════ */

/* Posts Design needs the page body to fill remaining height */
.pd-layout {
    display: flex;
    gap: 20px;
    height: calc(100vh - 100px);
    min-height: 0;
}

/* ── Tabs ── */
.pd-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin: 0 0 4px;
    flex-shrink: 0;
}
.pd-tab {
    flex: 1;
    padding: 10px 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-3);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color .15s, border-color .15s;
}
.pd-tab:hover { color: var(--text-1); }
.pd-tab.active {
    color: var(--text-1);
    border-bottom-color: var(--accent);
}

/* ── Left control panel ── */
.pd-panel {
    width: 280px;
    flex-shrink: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0;
    padding-bottom: 16px;
}

.pd-section {
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.pd-section:first-child { padding-top: 0; }

.pd-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-3);
    display: flex;
    align-items: center;
    gap: 6px;
}

.pd-val {
    font-weight: 500;
    color: var(--text-2);
    margin-left: auto;
}

/* Format buttons */
.pd-format-group {
    display: flex;
    gap: 6px;
}
.pd-format-btn {
    flex: 1;
    padding: 6px 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    font-size: 11px;
    font-family: var(--font);
    color: var(--text-2);
    cursor: pointer;
    text-align: center;
    line-height: 1.4;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.pd-format-btn span { font-size: 9.5px; color: var(--text-3); display: block; }
.pd-format-btn.active,
.pd-format-btn:hover { border-color: var(--text-1); background: var(--text-1); color: #fff; }
.pd-format-btn.active span,
.pd-format-btn:hover span { color: rgba(255,255,255,0.65); }

/* Template buttons */
.pd-tpl-group { display: flex; gap: 6px; }
.pd-tpl-btn {
    flex: 1;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    font-size: 12px;
    font-family: var(--font);
    font-weight: 600;
    color: var(--text-2);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.pd-tpl-btn.active,
.pd-tpl-btn:hover { border-color: var(--text-1); background: var(--text-1); color: #fff; }

/* Upload label */
.pd-upload-label {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 12px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-2);
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}
.pd-upload-label:hover { border-color: var(--text-1); color: var(--text-1); }

/* Inputs */
.pd-input {
    width: 100%;
    height: 30px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    font-size: 12.5px;
    font-family: var(--font);
    color: var(--text-1);
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.15s;
}
.pd-input:focus { border-color: #aaa; }
.pd-input-highlight { border-color: #fbbf24; }
.pd-input-highlight:focus { border-color: #f59e0b; }

.pd-hint { font-size: 11px; color: var(--text-3); margin: 0; line-height: 1.5; }

.pd-slider {
    width: 100%;
    accent-color: var(--text-1);
    cursor: pointer;
}

.pd-color {
    width: 28px;
    height: 24px;
    padding: 1px;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    background: none;
}

.pd-select {
    flex: 1;
    height: 26px;
    padding: 0 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    font-size: 12px;
    font-family: var(--font);
    color: var(--text-1);
    outline: none;
    cursor: pointer;
}

.pd-row {
    display: flex;
    align-items: center;
    gap: 6px;
}
.pd-row-label {
    font-size: 11.5px;
    color: var(--text-2);
    white-space: nowrap;
    flex-shrink: 0;
}

.pd-topic-input {
    resize: vertical;
    min-height: 64px;
}
.pd-gen-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    width: 100%;
    height: 36px;
    margin-top: 8px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: var(--font);
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}
.pd-gen-btn:hover   { opacity: 0.88; }
.pd-gen-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.pd-gen-status {
    margin-top: 7px;
    font-size: 12px;
    color: var(--text-3);
    line-height: 1.5;
}
.pd-gen-status.error { color: #e53e3e; }

/* ── Reference images picker ── */
.pd-ref-section {
    margin: 10px 0 10px;
}
.pd-ref-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 7px;
}
.pd-ref-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.pd-ref-count {
    font-size: 11px;
    color: var(--text-3);
    flex: 1;
}
.pd-ref-upload-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 24px;
    padding: 0 9px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-2);
    cursor: pointer;
    user-select: none;
    transition: background 0.12s;
}
.pd-ref-upload-btn:hover { background: var(--bg-3); }
.pd-ref-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}
.pd-ref-empty {
    font-size: 11px;
    color: var(--text-3);
    padding: 4px 0;
}
.pd-ref-thumb {
    position: relative;
    width: 52px;
    height: 65px;
    border-radius: 5px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    opacity: 0.5;
    transition: opacity 0.15s, border-color 0.15s;
    flex-shrink: 0;
}
.pd-ref-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}
.pd-ref-thumb.selected {
    border-color: var(--accent);
    opacity: 1;
}
.pd-ref-thumb:hover { opacity: 0.85; }
.pd-ref-thumb.selected:hover { opacity: 1; }
.pd-ref-check {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    font-size: 9px;
    line-height: 16px;
    text-align: center;
    display: none;
    pointer-events: none;
}
.pd-ref-thumb.selected .pd-ref-check { display: block; }

/* ── Progress bar ── */
.pd-progress-wrap {
    margin-top: 10px;
}
.pd-progress-track {
    height: 5px;
    background: var(--bg-3);
    border-radius: 3px;
    overflow: hidden;
}
.pd-progress-bar {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.25s ease-out;
}
.pd-progress-label {
    margin-top: 5px;
    font-size: 11px;
    color: var(--text-3);
}

/* ── Template list ── */
.pd-tpl-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.pd-tpl-new-btn {
    height: 22px;
    padding: 0 9px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-2);
    cursor: pointer;
    transition: background 0.12s;
}
.pd-tpl-new-btn:hover { background: var(--bg-3); }
.pd-tpl-empty {
    font-size: 11px;
    color: var(--text-3);
    padding: 2px 0;
}
.pd-tpl-list {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}
.pd-tpl-card {
    width: 58px;
    cursor: pointer;
    border-radius: 6px;
    border: 2px solid transparent;
    transition: border-color 0.15s;
    flex-shrink: 0;
}
.pd-tpl-card:hover  { border-color: var(--border); }
.pd-tpl-card.active { border-color: var(--accent); }
.pd-tpl-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 4/5;
    background: var(--bg-2);
    border-radius: 4px;
    overflow: hidden;
}
.pd-tpl-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.pd-tpl-no-img {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    color: var(--text-3);
}
.pd-tpl-card-actions {
    position: absolute;
    top: 2px;
    right: 2px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s;
}
.pd-tpl-thumb:hover .pd-tpl-card-actions { opacity: 1; }
.pd-tpl-edit-btn,
.pd-tpl-del-btn {
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 3px;
    font-size: 10px;
    line-height: 18px;
    text-align: center;
    cursor: pointer;
    padding: 0;
    display: block;
}
.pd-tpl-edit-btn { background: rgba(255,255,255,0.90); color: #333; }
.pd-tpl-del-btn  { background: rgba(220,38,38,0.85);   color: #fff; }
.pd-tpl-card-name {
    font-size: 10px;
    color: var(--text-2);
    text-align: center;
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 2px;
}

/* ── Template modal ── */
.pd-tpl-modal-wrap {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pd-tpl-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.40);
}
.pd-tpl-modal-box {
    position: relative;
    z-index: 1;
    width: 440px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 60px);
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: 0 8px 32px rgba(0,0,0,0.14);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.pd-tpl-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}
.pd-tpl-modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-2);
    padding: 2px;
    display: flex;
    align-items: center;
    border-radius: 4px;
}
.pd-tpl-modal-close:hover { color: var(--text-1); background: var(--bg-2); }
.pd-tpl-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.pd-tpl-field-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    display: flex;
    align-items: center;
    gap: 6px;
}
.pd-tpl-hint {
    font-size: 10px;
    font-weight: 400;
    color: var(--text-3);
    text-transform: none;
    letter-spacing: 0;
}
.pd-tpl-pos-group {
    display: flex;
    gap: 6px;
}
.pd-tpl-pos-btn {
    flex: 1;
    height: 30px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-2);
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.pd-tpl-pos-btn:hover  { background: var(--bg-3); }
.pd-tpl-pos-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.pd-tpl-logo-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.pd-tpl-modal-footer {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.pd-action-row {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}
.pd-action-row .pd-save-btn,
.pd-action-row .pd-export-btn {
    flex: 1;
    margin-top: 0;
}

.pd-save-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 36px;
    background: var(--bg-2);
    color: var(--text-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: var(--font);
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}
.pd-save-btn:hover   { background: var(--bg-3); }
.pd-save-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.pd-export-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 36px;
    background: var(--text-1);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: var(--font);
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}
.pd-export-btn:hover { opacity: 0.85; }

/* ── Saved projects gallery ── */
.pd-saved-section {
    margin-top: 32px;
    padding: 0 0 40px;
}
.pd-saved-header {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}
.pd-saved-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-1);
}
.pd-saved-meta {
    font-size: 12px;
    color: var(--text-3);
}
.pd-saved-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
}
.pd-saved-empty {
    font-size: 13px;
    color: var(--text-3);
    padding: 20px 0;
}
.pd-saved-card {
    cursor: pointer;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    transition: box-shadow 0.15s, border-color 0.15s;
}
.pd-saved-card:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(0,0,0,0.10);
}
.pd-saved-thumb-wrap {
    position: relative;
    aspect-ratio: 4/5;
    overflow: hidden;
    background: #111;
}
.pd-saved-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.pd-saved-type-tag {
    position: absolute;
    top: 6px;
    left: 6px;
    background: rgba(0,0,0,0.55);
    color: #fff;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    pointer-events: none;
}
.pd-saved-actions {
    position: absolute;
    bottom: 6px;
    right: 6px;
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.15s;
}
.pd-saved-thumb-wrap:hover .pd-saved-actions { opacity: 1; }
.pd-saved-dl,
.pd-saved-del {
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.pd-saved-dl  { background: rgba(255,255,255,0.85); color: #222; }
.pd-saved-del { background: rgba(220,38,38,0.85);   color: #fff; }
.pd-saved-label {
    font-size: 11px;
    color: var(--text-3);
    padding: 5px 8px 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Right canvas area ── */
.pd-canvas-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    position: relative;
    overflow: hidden;
}

#pd-canvas {
    display: block;
    border-radius: 4px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    user-select: none;
    -webkit-user-select: none;
}

.pd-canvas-info {
    position: absolute;
    bottom: 10px;
    right: 12px;
    font-size: 10.5px;
    color: var(--text-3);
    font-weight: 500;
    letter-spacing: 0.04em;
}

