/* ================================================================
   摘抄卡片生成器 - Styles
   ================================================================ */

/* ============ Variables ============ */
:root {
    --sidebar-w: 280px;
    --sidebar-bg: #ffffff;
    --content-bg: #f2f4f8;
    --primary: #4f6df5;
    --primary-light: #6b85f7;
    --primary-bg: rgba(79, 109, 245, 0.06);
    --text: #1a1a2e;
    --text-sec: #555;
    --text-light: #999;
    --border: #e4e7eb;
    --card-radius: 12px;
    --card-shadow:
        0 1px 2px rgba(16, 24, 40, 0.05),
        0 12px 32px rgba(16, 24, 40, 0.10);
    /* Motion tokens */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    /* WeChat Moments */
    --wm-blue: #576b95;
    --wm-bg: #ffffff;
    --wm-text: #1a1a1a;
    --wm-border: #ececec;
}

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

/* Paste-safety: strip list markers inside editable fields */
[contenteditable] ol,
[contenteditable] ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--content-bg);
    color: var(--text);
    overflow: hidden;
    height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ============ App Layout ============ */
#app {
    display: flex;
    height: 100vh;
}

#sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex-shrink: 0;
    z-index: 10;
}

#content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 0;
}

/* ============ Sidebar ============ */
.sidebar-brand {
    padding: 28px 20px 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-brand h1 {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-brand p {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 4px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.sidebar-section {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

/* Template list */
.template-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tpl-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    transition:
        border-color var(--transition-fast),
        transform var(--transition-fast),
        box-shadow var(--transition-fast);
    font-size: 14px;
    text-align: left;
    font-family: inherit;
}

.tpl-item:hover {
    border-color: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 109, 245, 0.14);
}

.tpl-item.active {
    border-color: var(--primary);
    background: var(--primary-bg);
    box-shadow: inset 3px 0 0 var(--primary);
}

.tpl-item.active .tpl-name {
    color: var(--primary);
    font-weight: 600;
}

.tpl-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tpl-icon-moments {
    background: linear-gradient(135deg, #07c160, #4cd964);
}

.tpl-icon-comment {
    background: linear-gradient(135deg, #ff5f6d, #fe2c55);
}

.tpl-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tpl-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

.tpl-desc {
    font-size: 11px;
    color: var(--text-light);
}

/* Sidebar buttons */
.sidebar-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    font-size: 14px;
    color: var(--text);
    transition:
        background var(--transition-fast),
        border-color var(--transition-fast);
    margin-bottom: 8px;
    font-family: inherit;
}

.sidebar-btn:last-child {
    margin-bottom: 0;
}

.sidebar-btn:hover {
    background: #f5f5f5;
    border-color: #d0d4da;
}

.sidebar-btn.primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.sidebar-btn.primary:hover {
    background: var(--primary-light);
    border-color: var(--primary-light);
}

/* Radius toggle */
.radius-toggle {
    display: flex;
    gap: 8px;
}

.radius-opt {
    flex: 1;
    padding: 8px 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text-sec);
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.radius-opt:hover {
    border-color: var(--primary-light);
    color: var(--primary);
}

.radius-opt.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* Square corners mode */
.square-corners .wechat-moments,
.square-corners .comment-card,
.square-corners .chat-card {
    border-radius: 0;
}

/* Tips */
.sidebar-tips {
    flex: 1;
}

.tips-list {
    list-style: none;
}

.tips-list li {
    font-size: 12px;
    color: var(--text-sec);
    line-height: 2;
    padding-left: 14px;
    position: relative;
}

.tips-list li::before {
    content: "";
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--primary);
    position: absolute;
    left: 0;
    top: 10px;
}

.tips-list li b {
    color: var(--primary);
    font-weight: 600;
}

.sidebar-footer {
    padding: 16px 20px;
    font-size: 11px;
    color: var(--text-light);
    text-align: center;
    border-top: 1px solid var(--border);
}

/* ============ Content Header ============ */
.content-header {
    padding: 24px 32px 16px;
    text-align: center;
}

.content-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.content-header p {
    font-size: 13px;
    color: var(--text-sec);
    margin-top: 4px;
}

/* ============ Canvas Area ============ */
#canvas-area {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 8px 32px 48px;
    background-image: radial-gradient(circle, #d9dee8 1px, transparent 1px);
    background-size: 24px 24px;
}

.card-wrap {
    display: none;
}

.card-wrap.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============ Editable Elements ============ */
[contenteditable] {
    outline: none;
    cursor: text;
    border-radius: 3px;
    transition: background 0.15s, box-shadow 0.15s;
    min-height: 1em;
}

[contenteditable]:hover {
    background: rgba(79, 109, 245, 0.06);
}

[contenteditable]:focus {
    background: rgba(79, 109, 245, 0.1);
    box-shadow: 0 0 0 1.5px rgba(79, 109, 245, 0.3);
}

[contenteditable]:empty::before {
    content: attr(data-placeholder);
    color: var(--text-light);
    opacity: 0.5;
}

/* Image upload */
.img-upload {
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.img-upload::after {
    content: "";
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2'><path d='M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z'/><circle cx='12' cy='13' r='4'/></svg>");
    background-size: 14px;
    background-position: center;
    background-repeat: no-repeat;
}

.img-upload:hover::after {
    opacity: 1;
}

.img-upload img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Remove button */
.remove-btn {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #ff4d4f;
    color: #fff;
    border: 2px solid #fff;
    cursor: pointer;
    font-size: 14px;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 20;
    line-height: 1;
    padding: 0;
    transition: transform 0.15s;
}

.remove-btn:hover {
    transform: scale(1.15);
    background: #ff7875;
}

.removable {
    position: relative;
}

.removable:hover > .remove-btn {
    display: flex;
}

/* Export mode */
.exporting .edit-only {
    display: none !important;
}

.exporting .remove-btn {
    display: none !important;
}

.exporting .img-upload::after {
    display: none !important;
}

.exporting .img-upload {
    cursor: default;
}

.exporting [contenteditable] {
    background: none !important;
    box-shadow: none !important;
    cursor: default;
}

.exporting [contenteditable]:hover {
    background: none !important;
}

/* ============ WeChat Moments Card ============ */
.wechat-moments {
    width: 375px;
    background: var(--wm-bg);
    border-radius: var(--card-radius);
    overflow: hidden;
    box-shadow: var(--card-shadow);
}

.wm-post {
    padding: 16px;
}

/* User */
.wm-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.wm-avatar {
    width:42px;
    height:42px;
    border-radius:6px;
    overflow:hidden;
    flex-shrink:0;
    background:#f0f0f0;
}

.wm-name {
    color: var(--wm-blue);
    font-size: 15px;
    font-weight: 500;
    line-height: 1.4;
}

/* Text */
.wm-text {
    font-size: 15px;
    line-height: 1.5;
    color: var(--wm-text);
    margin-bottom: 10px;
    word-break: break-word;
    white-space: pre-wrap;
}

/* Image grid */
.wm-images {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-bottom: 10px;
}

.wm-img-item {
    aspect-ratio: 1;
    border-radius: 4px;
    overflow: hidden;
    background: #f5f5f5;
}

.wm-img-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wm-img-add {
    aspect-ratio: 1;
    border-radius: 4px;
    border: 2px dashed #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ccc;
    cursor: pointer;
    background: #fafafa;
    transition: all 0.2s;
}

.wm-img-add:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-bg);
}

/* Meta */
.wm-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.wm-time {
    color: #b0b0b0;
    font-size: 12px;
}

/* ============ Comment Card (抖音作者评论样式) ============ */
.comment-card {
    position: relative;
    width: 480px;
    background: #ffffff;
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    padding: 24px 30px 16px;
}

/* Lock toggle */
.cm-lock {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 30;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.92);
    color: var(--text-sec);
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 20px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.cm-lock:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Header */
.cm-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.cm-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: #f0f0f0;
}

/* Avatar image sizing must not depend on the .img-upload class,
   otherwise it loses object-fit when the avatar is locked */
.cm-avatar img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cm-name {
    font-size: 20px;
    color: #3a3a3a;
    font-weight: 500;
    white-space: nowrap;
}

.cm-badge {
    background: #fe2c55;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    flex-shrink: 0;
}

/* Body */
.cm-body {
    position: relative;
}

.cm-lines {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.cm-line {
    position: relative;
}

.cm-line-text {
    font-size: 20px;
    line-height: 1.5;
    color: #1a1a1a;
    word-break: break-word;
    white-space: pre-wrap;
}

.cm-add-line {
    margin-top: 14px;
    border: 1px dashed #ddd;
    background: #fafafa;
    color: #999;
    border-radius: 6px;
    padding: 6px 14px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    transition: all 0.2s;
}

.cm-add-line:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-bg);
}

/* Footer */
.cm-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 22px;
}

.cm-footer-left {
    display: flex;
    align-items: center;
    gap: 18px;
    color: #9a9a9a;
    font-size: 15px;
}

.cm-publish {
    display: flex;
    align-items: center;
    gap: 4px;
}

.cm-hearts {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ============ Chat Card (微信深色聊天样式) ============ */
.chat-card {
    position: relative;
    width: 480px;
    background: #0c0c0c;
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    padding: 24px 24px 18px;
}

/* Lock toggle */
.ck-lock {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 30;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.08);
    color: #bbb;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 20px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.ck-lock:hover {
    border-color: #3eb575;
    color: #3eb575;
}

/* Time */
.ck-time {
    text-align: center;
    color: #8a8a8a;
    font-size: 15px;
    margin-bottom: 22px;
}

/* Message list */
.ck-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.ck-msg {
    display: flex;
    justify-content: flex-end;
    align-items: flex-start;
    gap: 12px;
    position: relative;
    padding-right: 28px;
}

.ck-bubble {
    position: relative;
    background: #3eb575;
    color: #1a1a1a;
    font-size: 19px;
    line-height: 1.5;
    padding: 12px 16px;
    border-radius: 8px;
    max-width: 340px;
    word-break: break-word;
    white-space: pre-wrap;
}

.ck-bubble::after {
    content: "";
    position: absolute;
    top: 16px;
    right: -7px;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 7px solid #3eb575;
}

.ck-avatar {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    background: #222;
}

.ck-avatar img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ck-add {
    margin-top: 18px;
    border: 1px dashed rgba(255, 255, 255, 0.2);
    background: transparent;
    color: #888;
    border-radius: 6px;
    padding: 6px 14px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    transition: all 0.2s;
}

.ck-add:hover {
    border-color: #3eb575;
    color: #3eb575;
}

/* ============ Toast ============ */
.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    opacity: 0;
    transition: all 0.3s;
    z-index: 9999;
    pointer-events: none;
    white-space: nowrap;
}

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

/* ============ Scrollbar ============ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

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

::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* ============ Accessibility ============ */
.tpl-item:focus-visible,
.sidebar-btn:focus-visible,
.radius-opt:focus-visible,
.remove-btn:focus-visible,
.cm-lock:focus-visible,
.ck-lock:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

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

/* ============ Responsive ============ */
@media (max-width: 768px) {
    #sidebar {
        width: 220px;
    }

    .content-header {
        padding: 16px 20px 12px;
    }

    #canvas-area {
        padding: 8px 16px 32px;
    }
}
