﻿/* ================================================================ */
/* 铅字文 · 排版工坊 — 完美兼容公众号 & 全平台手机 */
/* ================================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}
html,
body {
    height: 100%;
    overflow: hidden;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
    background: #f7f7f7;
    color: #1a1a1a;
    display: flex;
    flex-direction: column;
    padding: 0;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== 顶部固定区域 ===== */
.sticky-header {
    flex-shrink: 0;
    background: #ffffff;
    padding: 4px 8px 2px 8px;
    z-index: 100;
    border-bottom: 1px solid #e5e5e5;
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 0 4px 0;
    flex-wrap: wrap;
    gap: 2px;
}
.app-header h1 {
    font-size: 17px;
    font-weight: 500;
    color: #333;
    letter-spacing: 4px;
    font-family: "Georgia", "Times New Roman", serif;
}
.app-header h1 .subtitle {
    font-size: 10px;
    color: #999;
    letter-spacing: 2px;
    font-weight: 300;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}
.badge-pwa {
    font-size: 9px;
    color: #999;
    border: 1px solid #e5e5e5;
    padding: 1px 6px;
    border-radius: 2px;
    letter-spacing: 1px;
}
.install-banner {
    display: none;
    font-size: 10px;
    color: #666;
    border: 1px solid #e5e5e5;
    padding: 1px 6px;
    border-radius: 2px;
    align-items: center;
    gap: 4px;
}
.install-banner.show {
    display: inline-flex;
}
.install-banner button {
    background: none;
    border: none;
    color: #333;
    font-size: 10px;
    cursor: pointer;
    padding: 1px 4px;
}

/* ===== 用户信息显示 ===== */
#userBadge {
    display: none;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    background: #f0f0f0;
    color: #333;
}

#userBadge svg {
    display: block;
    flex-shrink: 0;
}

#userEmailDisplay {
    display: none;
    font-size: 11px;
    color: #333;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

#logoutBtn {
    font-size: 10px;
    padding: 2px 8px;
    color: #999;
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.15s;
}

#logoutBtn:hover {
    color: #c0392b;
    background: #fde8e8;
}

#logoutBtn:active {
    transform: scale(0.94);
}

/* ===== 分享按钮 ===== */
#shareBtn {
    font-size: 11px;
    padding: 2px 10px;
    cursor: pointer;
    color: #555;
    background: transparent;
    border: none;
    border-radius: 3px;
    transition: all 0.15s;
}

#shareBtn:hover {
    background: #f0f0f0;
}

#shareBtn:active {
    transform: scale(0.94);
    background: #e8e8e8;
}

/* ===== 主工具栏 ===== */
.toolbar-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1px 2px;
    align-items: center;
    padding: 3px 0 2px 0;
}
.toolbar-row .btn {
    background: transparent;
    border: none;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 400;
    color: #555;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    min-height: 26px;
    white-space: nowrap;
    touch-action: manipulation;
    letter-spacing: 0.2px;
    -webkit-user-select: none;
    user-select: none;
}
.toolbar-row .btn:active {
    transform: scale(0.94);
    background: #e8e8e8;
}
.toolbar-row .btn-success {
    color: #fff;
    background: #666;
    border-radius: 3px;
}
.toolbar-row .btn-success:active {
    background: #444;
}
.toolbar-row .btn-primary {
    color: #fff;
    background: #999;
    border-radius: 3px;
}
.toolbar-row .btn-primary:active {
    background: #777;
}
.toolbar-row .btn-outline {
    border: 1px solid #e5e5e5;
    border-radius: 3px;
}
.toolbar-row .btn-outline:active {
    background: #f0f0f0;
}
.toolbar-row .btn-template {
    padding: 4px 8px;
    font-size: 11px;
    color: #777;
    border: 1px solid transparent;
    border-radius: 3px;
}
.toolbar-row .btn-template:active {
    background: #e8e8e8;
}
.toolbar-row .btn-template.active {
    background: #333;
    color: #ffffff;
    border-color: #333;
}
.toolbar-row .btn-undo {
    color: #777;
    font-size: 11px;
}
.toolbar-row .btn-undo:active {
    color: #333;
    background: #f0f0f0;
}
.toolbar-row .divider {
    width: 1px;
    height: 18px;
    background: #e5e5e5;
    flex-shrink: 0;
    margin: 0 2px;
}
.template-group {
    display: flex;
    gap: 1px;
    flex-wrap: wrap;
}
.toolbar-row .btn-insert {
    font-size: 11px;
    color: #777;
    padding: 4px 8px;
    border: 1px solid transparent;
    border-radius: 3px;
}
.toolbar-row .btn-insert:active {
    background: #f0f0f0;
}

/* ===== 颜色选择器 ===== */
.color-picker-wrap {
    display: flex;
    align-items: center;
    gap: 2px;
    background: #ffffff;
    border: 1px solid #e5e5e5;
    border-radius: 3px;
    padding: 1px 3px 1px 4px;
}
.color-picker-wrap .color-label {
    font-size: 9px;
    color: #888;
    letter-spacing: 0.5px;
}
.color-picker-wrap input[type="color"] {
    width: 20px;
    height: 20px;
    border: 1px solid #e5e5e5;
    border-radius: 3px;
    padding: 1px;
    cursor: pointer;
    background: white;
    -webkit-appearance: none;
    appearance: none;
}
.color-picker-wrap input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}
.color-picker-wrap input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 2px;
}

/* ===== 字号选择器 ===== */
.font-size-select {
    background: transparent;
    border: 1px solid #e5e5e5;
    border-radius: 3px;
    padding: 1px 3px;
    font-size: 11px;
    height: 22px;
    color: #555;
    cursor: pointer;
    outline: none;
    font-weight: 400;
    min-width: 40px;
    -webkit-appearance: none;
    appearance: none;
}
.font-size-select:focus {
    border-color: #777;
}

/* ===== 字数统计 ===== */
.word-count {
    font-size: 11px;
    color: #999;
    white-space: nowrap;
    margin-left: auto;
    letter-spacing: 0.5px;
}

/* ===== 主卡片 & 编辑器 ===== */
.main-card {
    flex: 1;
    background: #f9f9f9;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-width: 1000px;
    width: 100%;
    margin: 0 auto;
    min-height: 0;
}
.editor-wrap {
    flex: 1;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.editor-header {
    padding: 3px 12px;
    font-size: 10px;
    font-weight: 300;
    color: #999;
    background: #fafafa;
    border-bottom: 1px solid #ececec;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    letter-spacing: 0.5px;
}
.editor-header span {
    color: #999;
}
#templateNameDisplay {
    color: #555;
    font-weight: 400;
}

#editable-content {
    flex: 1;
    padding: 16px 18px;
    overflow-y: auto;
    outline: none;
    background: #ffffff;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    line-height: 1.8;
    color: #333;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
    font-size: 16px;
    -webkit-touch-callout: none;
    touch-callout: none;
}
#editable-content:empty::before {
    content: "在这里直接输入或粘贴文章内容...";
    color: #cccccc;
    font-size: 14px;
}
#editable-content h1 {
    margin: 0.6em 0 0.3em;
}
#editable-content h2 {
    margin: 0.7em 0 0.3em;
}
#editable-content h3 {
    margin: 0.6em 0 0.2em;
}
#editable-content h4 {
    margin: 0.5em 0 0.2em;
    font-size: 1em;
}
#editable-content p {
    margin: 0.5em 0;
}
#editable-content blockquote {
    padding: 10px 14px;
    margin: 0.8em 0;
    border-radius: 0 4px 4px 0;
}
#editable-content ul,
#editable-content ol {
    padding-left: 1.6em;
    margin: 0.4em 0;
}
#editable-content li {
    margin: 0.15em 0;
}
#editable-content hr {
    border: none;
    margin: 1.2em 0;
    height: 1px;
    background: #e5e5e5;
    border-radius: 1px;
}
.highlight-box {
    padding: 12px 16px;
    border-radius: 6px;
    margin: 0.8em 0;
    border-left: 2px solid;
}
.highlight-box.info {
    background: #f3f9ff;
    border-color: #90caf9;
    color: #333;
}
.highlight-box.warn {
    background: #fff8e1;
    border-color: #ffd54f;
    color: #333;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #ffffff;
    padding: 8px 20px;
    border-radius: 8px;
    font-weight: 400;
    font-size: 13px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 99999;
    max-width: 90%;
    text-align: center;
    line-height: 1.5;
    letter-spacing: 0.3px;
}
.toast.show {
    opacity: 1;
}

/* ===== 弹窗通用样式 ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.modal-content {
    background: #ffffff;
    border-radius: 12px;
    max-width: 400px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px 12px 20px;
    border-bottom: 1px solid #e5e5e5;
    font-size: 18px;
    font-weight: 600;
    color: #2d3436;
}
.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    padding: 0 4px;
}
.modal-close:hover {
    color: #333;
}
.modal-body {
    padding: 20px;
}

/* ===== 登录/注册表单 ===== */
.form-group {
    margin-bottom: 14px;
}
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #555;
    margin-bottom: 4px;
}
.form-group input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
.form-group input:focus {
    outline: none;
    border-color: #666;
}
.btn-block {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 14px;
}
.modal-footer-text {
    text-align: center;
    margin-top: 16px;
    font-size: 13px;
    color: #888;
}
.link-btn {
    background: none;
    border: none;
    color: #c0392b;
    font-weight: 600;
    cursor: pointer;
    font-size: 13px;
}
.link-btn:hover {
    text-decoration: underline;
}
.auth-error {
    background: #fde8e8;
    color: #c0392b;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 12px;
}

/* ===== 激活弹窗 ===== */
.activate-message p,
.activate-blocked p {
    font-size: 14px;
    line-height: 1.7;
    color: #2d3436;
    margin-bottom: 8px;
}
.contact-info {
    background: #f5f5f5;
    padding: 12px 16px;
    border-radius: 6px;
    margin: 12px 0;
}
.contact-info p {
    font-size: 13px;
    margin: 4px 0;
}
.activate-blocked {
    text-align: center;
}

/* ================================================================ */
/* 手机端适配 */
/* ================================================================ */
@media (max-width: 820px) {
    .sticky-header {
        padding: 2px 4px 1px 4px;
    }
    .app-header h1 {
        font-size: 15px;
        letter-spacing: 3px;
    }
    .app-header h1 .subtitle {
        font-size: 9px;
    }
    .toolbar-row {
        gap: 1px 2px;
        padding: 2px 0;
    }
    .toolbar-row .btn {
        font-size: 11px;
        padding: 3px 7px;
        min-height: 22px;
        border-radius: 3px;
    }
    .toolbar-row .btn-template {
        font-size: 10px;
        padding: 3px 6px;
    }
    .toolbar-row .btn-insert {
        font-size: 10px;
        padding: 3px 6px;
    }
    .toolbar-row .btn-undo {
        font-size: 10px;
    }
    .toolbar-row .divider {
        height: 16px;
        margin: 0 1px;
    }
    .color-picker-wrap {
        padding: 1px 2px 1px 3px;
    }
    .color-picker-wrap input[type="color"] {
        width: 18px;
        height: 18px;
    }
    .color-picker-wrap .color-label {
        font-size: 8px;
    }
    .font-size-select {
        font-size: 10px;
        height: 20px;
        min-width: 36px;
        padding: 1px 2px;
    }
    .word-count {
        font-size: 10px;
    }
    #editable-content {
        padding: 14px 12px;
        font-size: 15px;
    }
    .toast {
        font-size: 12px;
        padding: 6px 16px;
        bottom: 12px;
        max-width: 92%;
    }
    .editor-header {
        font-size: 9px;
        padding: 2px 10px;
    }
    .modal-content {
        max-width: 95%;
    }
    #userEmailDisplay {
        max-width: 80px;
        font-size: 10px;
    }
    #userBadge {
        font-size: 12px;
        padding: 1px 6px;
    }
    #userBadge svg {
        width: 14px;
        height: 14px;
    }
    #shareBtn {
        font-size: 10px;
        padding: 1px 8px;
    }
}

@media (max-width: 480px) {
    .app-header h1 {
        font-size: 14px;
        letter-spacing: 2px;
    }
    .app-header h1 .subtitle {
        font-size: 8px;
    }
    .toolbar-row {
        gap: 1px 1px;
    }
    .toolbar-row .btn {
        font-size: 10px;
        padding: 2px 5px;
        min-height: 18px;
    }
    .toolbar-row .btn-template {
        font-size: 9px;
        padding: 2px 4px;
    }
    .toolbar-row .btn-insert {
        font-size: 9px;
        padding: 2px 4px;
    }
    .toolbar-row .btn-undo {
        font-size: 9px;
    }
    .toolbar-row .divider {
        height: 14px;
        margin: 0 1px;
    }
    .color-picker-wrap input[type="color"] {
        width: 16px;
        height: 16px;
    }
    .color-picker-wrap .color-label {
        font-size: 7px;
    }
    .font-size-select {
        font-size: 9px;
        height: 18px;
        min-width: 32px;
        padding: 0 2px;
    }
    .word-count {
        font-size: 9px;
    }
    #editable-content {
        padding: 10px 8px;
        font-size: 14px;
    }
    .editor-header {
        font-size: 8px;
        padding: 2px 8px;
    }
    .badge-pwa {
        font-size: 7px;
        padding: 0 4px;
    }
    .install-banner {
        font-size: 8px;
        padding: 0 4px;
    }
    .install-banner button {
        font-size: 8px;
    }
    .toast {
        font-size: 11px;
        padding: 5px 12px;
        bottom: 10px;
        max-width: 94%;
    }
    #userEmailDisplay {
        max-width: 60px;
        font-size: 9px;
    }
    #userBadge {
        font-size: 10px;
        padding: 1px 4px;
        gap: 2px;
    }
    #userBadge svg {
        width: 12px;
        height: 12px;
    }
    #logoutBtn {
        font-size: 8px;
        padding: 1px 4px;
    }
    #shareBtn {
        font-size: 9px;
        padding: 1px 6px;
    }
}

/* ================================================================ */
/* 模板样式 */
/* ================================================================ */

/* 简约 Minimal */
.template-minimal #editable-content {
    background: #ffffff;
}
.template-minimal h1 {
    font-size: 24px;
    font-weight: 700;
    color: #333;
    text-align: center;
    letter-spacing: 4px;
    border-bottom: 1px solid #e5e5e5;
    padding-bottom: 10px;
}
.template-minimal hr {
    background: #e5e5e5;
    height: 1px;
}

/* 文艺 Literary */
.template-literary #editable-content {
    background: #fcf8f3;
}
.template-literary h1 {
    font-size: 28px;
    font-weight: 700;
    color: #c0392b;
    text-align: center;
    letter-spacing: 6px;
    padding: 10px 0 14px 0;
}
.template-literary h2 {
    font-size: 20px;
    font-weight: 700;
    color: #2d3436;
    padding: 10px 0;
    margin: 0 0 14px 0;
    letter-spacing: 1px;
    display: inline-block;
    border-top: 2px solid #8e44ad;
    border-bottom: 2px solid #8e44ad;
}
.template-literary h3 {
    font-size: 17px;
    font-weight: 600;
    color: #2d3436;
    padding: 0 0 8px 0;
    margin: 0 0 12px 0;
    border-bottom: 2px dashed #e67e22;
    display: inline-block;
}
.template-literary h4 {
    font-size: 15px;
    font-weight: 700;
    color: #2d3436;
    padding: 0 6px 0 0;
    margin: 0 0 10px 0;
    display: block;
    border-right: 3px solid #6d4c41;
}
.template-literary p {
    font-size: 17px;
    line-height: 1.9;
    color: #2d3436;
    margin: 0.5em 0;
}
.template-literary blockquote {
    border-left: 4px solid #8e44ad;
    background: #f0edf5;
    color: #2d3436;
    padding: 12px 16px;
    margin: 0.8em 0;
    border-radius: 0 6px 6px 0;
}
.template-literary hr {
    background: #dfe6e9;
    height: 1px;
}

/* 商业 Business */
.template-business #editable-content {
    background: #ffffff;
}
.template-business h1 {
    font-size: 26px;
    font-weight: 700;
    color: #1a73e8;
    text-align: center;
    letter-spacing: 2px;
    padding-bottom: 10px;
    border-bottom: 1px solid #bbdefb;
}
.template-business hr {
    background: #e5e5e5;
    height: 1px;
}

/* 科技 Tech */
.template-tech #editable-content {
    background: #ffffff;
}
.template-tech h1 {
    font-size: 26px;
    font-weight: 700;
    color: #00838f;
    text-align: center;
    letter-spacing: 8px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e0f7fa;
}
.template-tech h3 {
    font-size: 16px;
    font-weight: 600;
    color: #006064;
    background: rgba(0,151,167,0.06);
    padding: 6px 16px;
    border-radius: 4px;
    display: inline-block;
    margin: 0 0 10px 0;
}
.template-tech h4 {
    font-size: 15px;
    font-weight: 600;
    color: #00838f;
    padding: 2px 0 2px 10px;
    border-left: 2px solid #b2ebf2;
    display: block;
    margin: 0 0 8px 0;
}
.template-tech hr {
    background: #e5e5e5;
    height: 1px;
}