/* ============================================================
   寄语卡片 · 移动端优先 H5 样式
   配色：柔和浅色系；视觉：圆角、留白、清爽
   ============================================================ */

:root {
    --bg: #fdf6f0;
    --bg-soft: #fbeee2;
    --card: #ffffff;
    --ink: #3d2f2a;
    --ink-soft: #8a7a72;
    --ink-mute: #b3a39c;
    --line: #efe2d6;
    --brand: #e98a6d;       /* 暖橘 */
    --brand-soft: #f7c9bb;
    --brand-deep: #c8603f;
    --green: #7fb98a;
    --gold: #d8a363;
    --radius-lg: 18px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --shadow: 0 6px 20px rgba(61, 47, 42, 0.08);
    --shadow-hover: 0 10px 26px rgba(61, 47, 42, 0.14);
    --maxw: 640px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: linear-gradient(180deg, #fdf6f0 0%, #fbeee2 100%);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

a { color: var(--brand-deep); text-decoration: none; }

/* ============ 头部引导 ============ */
.hero {
    position: relative;
    padding: 36px 22px 28px;
    text-align: center;
    background: linear-gradient(180deg, #fff7f0 0%, rgba(253, 246, 240, 0) 100%);
    overflow: hidden;
}

.hero-inner { position: relative; z-index: 2; }

.hero-deco {
    position: absolute;
    font-size: 28px;
    opacity: .35;
    color: var(--brand);
    user-select: none;
    z-index: 1;
}
.hero-deco-1 { top: 22px; left: 26px; transform: rotate(-12deg); }
.hero-deco-2 { top: 30px; right: 28px; transform: rotate(15deg); }

.hero-title {
    margin: 0 0 6px;
    font-size: 30px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--brand-deep);
    background: linear-gradient(90deg, #c8603f, #e98a6d);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.hero-sub {
    margin: 0 0 10px;
    font-size: 15px;
    color: var(--ink-soft);
    letter-spacing: 1px;
}
.hero-desc {
    margin: 0 auto;
    max-width: 360px;
    font-size: 13px;
    color: var(--ink-mute);
    line-height: 1.7;
}

/* ============ 主体容器 ============ */
.container {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 6px 16px 28px;
}

.section { margin-top: 26px; }

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 14px;
    font-size: 17px;
    font-weight: 600;
    color: var(--ink);
}
.section-title .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--brand);
    box-shadow: 0 0 0 4px var(--brand-soft);
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.section-head .section-title { margin: 0; }

.link-btn {
    border: none;
    background: transparent;
    color: var(--ink-mute);
    font-size: 13px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}
.link-btn:active { color: var(--brand); }

/* ============ 模板列表 ============ */
.tpl-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.tpl-item {
    position: relative;
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    padding: 6px;
    cursor: pointer;
    background: var(--card);
    box-shadow: var(--shadow);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.tpl-item:active { transform: scale(.98); }
.tpl-item.active {
    border-color: var(--brand);
    box-shadow: var(--shadow-hover);
}
.tpl-thumb {
    aspect-ratio: 4 / 3;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    text-align: center;
    padding: 12px;
}
.tpl-name {
    margin-top: 8px;
    text-align: center;
    font-size: 13px;
    color: var(--ink-soft);
}
.tpl-item.active .tpl-name { color: var(--brand-deep); font-weight: 600; }

/* 缩略图样式（与卡片样式呼应） */
.tpl-thumb--envelope { background: #fff3ea; color: #c8603f; }
.tpl-thumb--envelope::before {
    content: "✉";
    font-size: 36px;
    opacity: .35;
    position: absolute;
    top: 8px;
    right: 12px;
}
.tpl-thumb--whitespace { background: #f6f4ef; color: #5a5048; font-style: italic; }
.tpl-thumb--warm { background: linear-gradient(135deg, #ffe2cc, #f7c9bb); color: #b5502f; }
.tpl-thumb--kraft { background: #ecddc4; color: #5a4636; }

/* ============ 表单 ============ */
.form-card {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 18px 16px;
}

.form-label {
    display: block;
    font-size: 13px;
    color: var(--ink-soft);
    margin-bottom: 8px;
}
.form-label:not(:first-child) { margin-top: 18px; }

.form-textarea, .form-input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    font-size: 15px;
    color: var(--ink);
    background: #fffdfb;
    font-family: inherit;
    resize: none;
    transition: border-color .2s, box-shadow .2s;
}
.form-textarea { min-height: 96px; line-height: 1.6; }
.form-textarea:focus, .form-input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(233, 138, 109, .18);
}

.form-counter {
    text-align: right;
    font-size: 12px;
    color: var(--ink-mute);
    margin-top: 6px;
}
.form-tip {
    margin: 14px 0 0;
    font-size: 12px;
    color: var(--ink-mute);
    background: var(--bg-soft);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
}

/* ============ 实时预览 ============ */
.preview-wrap {
    background: var(--bg-soft);
    border-radius: var(--radius-lg);
    padding: 22px 18px;
    text-align: center;
}

.card-preview {
    margin: 0 auto;
    width: 100%;
    max-width: 360px;
    min-height: 220px;
    border-radius: var(--radius-md);
    position: relative;
    overflow: hidden;
    transition: background .25s, color .25s;
}

.preview-hint {
    margin: 14px 0 0;
    font-size: 12px;
    color: var(--ink-mute);
}

/* ===== 卡片内部排版（动态根据模板类名变化） ===== */
.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 220px;
    padding: 28px 22px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    box-sizing: border-box;
}

.card-msg {
    font-size: 16px;
    line-height: 1.8;
    color: inherit;
    word-break: break-word;
    margin: 0 0 14px;
    max-height: 200px;
    overflow: hidden;
}
.card-msg:empty::before {
    content: "在这里写下你的寄语…";
    color: rgba(0,0,0,.3);
}
.card-nick {
    font-size: 13px;
    color: inherit;
    opacity: .85;
    margin-top: 4px;
}
.card-nick::before { content: "— "; }
.card-nick:empty::before { content: ""; }

/* 模板 1：简约信封款 */
.tpl--envelope {
    background: #fff3ea;
    color: #c8603f;
    border: 1px solid #f5d8c4;
}
.tpl--envelope .card-inner::before {
    content: "✉";
    position: absolute;
    top: 14px;
    right: 18px;
    font-size: 26px;
    opacity: .35;
}
.tpl--envelope .card-msg { font-style: normal; }

/* 模板 2：文艺留白款 */
.tpl--whitespace {
    background: #f6f4ef;
    color: #5a5048;
    padding: 8px;
}
.tpl--whitespace .card-inner {
    border: 1px dashed #cdbfa8;
    background: #fdfcf8;
    border-radius: 10px;
}
.tpl--whitespace .card-msg { font-style: italic; }

/* 模板 3：温馨渐变款 */
.tpl--warm {
    background: linear-gradient(135deg, #ffe2cc 0%, #f7c9bb 100%);
    color: #b5502f;
}
.tpl--warm .card-inner::before {
    content: "✿";
    position: absolute;
    bottom: 12px;
    left: 16px;
    font-size: 22px;
    opacity: .35;
}
.tpl--warm .card-inner::after {
    content: "✿";
    position: absolute;
    top: 12px;
    right: 16px;
    font-size: 22px;
    opacity: .35;
    transform: rotate(45deg);
}

/* 模板 4：复古牛皮纸款 */
.tpl--kraft {
    background:
        radial-gradient(circle at 20% 20%, rgba(0,0,0,.04) 0 1px, transparent 1px) 0 0 / 14px 14px,
        #ecddc4;
    color: #5a4636;
    border: 1px solid #d6c4a3;
}
.tpl--kraft .card-inner::before {
    content: "❀";
    position: absolute;
    top: 12px;
    left: 16px;
    font-size: 18px;
    opacity: .4;
}

/* ============ 功能按钮 ============ */
.actions { text-align: center; }
.btn {
    appearance: none;
    border: none;
    border-radius: 999px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    padding: 14px 22px;
    cursor: pointer;
    transition: transform .15s, box-shadow .2s, background .2s;
    -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.97); }

.btn-primary {
    width: 100%;
    background: linear-gradient(90deg, #e98a6d, #c8603f);
    color: #fff;
    box-shadow: 0 8px 18px rgba(200, 96, 63, .28);
    margin-bottom: 12px;
}
.btn-primary:active { box-shadow: 0 4px 12px rgba(200, 96, 63, .24); }

.btn-row {
    display: flex;
    gap: 8px;
}
.btn-row .btn {
    flex: 1;
    min-width: 0;
    padding: 14px 12px;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.btn-ghost {
    background: #fff;
    color: var(--brand-deep);
    border: 1px solid var(--brand-soft);
    box-shadow: var(--shadow);
}

/* 微信分享按钮：与保存/复制同排，区分配色，默认 hidden 不占位 */
.btn-wxshare {
    background: #07c160;
    color: #fff;
    border: 1px solid #07c160;
    box-shadow: 0 6px 14px rgba(7, 193, 96, .25);
}
.btn-wxshare:active { box-shadow: 0 3px 8px rgba(7, 193, 96, .2); }

.actions-tip {
    margin: 12px 0 0;
    font-size: 12px;
    color: var(--ink-mute);
}

/* ============ 我的记录 ============ */
.history-list {
    display: grid;
    gap: 12px;
}
.history-empty {
    text-align: center;
    color: var(--ink-mute);
    background: #fff;
    border: 1px dashed var(--line);
    border-radius: var(--radius-md);
    padding: 26px 12px;
    font-size: 13px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fff;
    border-radius: var(--radius-md);
    padding: 10px 12px;
    box-shadow: var(--shadow);
}
.history-thumb {
    width: 64px;
    height: 48px;
    border-radius: 8px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: rgba(0,0,0,.5);
    overflow: hidden;
    text-align: center;
    padding: 4px;
}
.history-meta { flex: 1; min-width: 0; }
.history-msg {
    font-size: 13px;
    color: var(--ink);
    margin: 0 0 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.history-time {
    font-size: 11px;
    color: var(--ink-mute);
}
.history-del {
    border: none;
    background: transparent;
    color: var(--ink-mute);
    font-size: 18px;
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 6px;
}
.history-del:active { color: var(--brand); }

/* ============ 底部 ============ */
.footer {
    margin-top: 36px;
    padding: 24px 18px 36px;
    background: #fff7f0;
    border-top: 1px solid var(--line);
}
.footer-inner {
    max-width: var(--maxw);
    margin: 0 auto;
    text-align: center;
    font-size: 12px;
    color: var(--ink-mute);
    line-height: 1.8;
}
.footer-disclaimer {
    margin: 0 0 8px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}
.footer-contact { margin: 6px 0; }
.footer-copy { margin: 6px 0 0; }

/* ============ 导出舞台（屏幕外） ============ */
.export-stage {
    position: fixed;
    left: -9999px;
    top: 0;
    width: 360px;
    pointer-events: none;
}

/* ============ Toast ============ */
.toast {
    position: fixed;
    left: 50%;
    bottom: 28%;
    transform: translate(-50%, 20px);
    background: rgba(61, 47, 42, .92);
    color: #fff;
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s, transform .25s;
    z-index: 9999;
    max-width: 80%;
    text-align: center;
}
.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ============ 平板/桌面适配 ============ */
@media (min-width: 768px) {
    body { font-size: 16px; }
    .hero { padding: 56px 22px 36px; }
    .hero-title { font-size: 36px; }
    .hero-sub { font-size: 16px; }
    .container { padding: 12px 24px 36px; }
    .tpl-list { grid-template-columns: repeat(4, 1fr); }
    .card-preview { max-width: 420px; min-height: 260px; }
    .card-inner { min-height: 260px; }
}

/* ============ 安全区域 ============ */
@supports (padding: env(safe-area-inset-bottom)) {
    .footer { padding-bottom: calc(36px + env(safe-area-inset-bottom)); }
}

/* ============ 微信分享引导层 ============ */
.wx-share-guide {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, .72);
    z-index: 10000;
    display: none;
    overflow: hidden;
}
.wx-share-guide.show { display: block; }

.wx-share-arrow {
    position: fixed;
    top: 10px;
    right: 12px;
    font-size: 64px;
    line-height: 1;
    color: #fff;
    text-shadow: 0 0 12px rgba(7, 193, 96, .9);
    animation: wxArrowBounce 1.2s ease-in-out infinite;
    pointer-events: none;
}
@keyframes wxArrowBounce {
    0%, 100% { transform: translate(0, 0); }
    50%      { transform: translate(6px, -6px); }
}

.wx-share-guide-text {
    position: fixed;
    top: 80px;
    right: 14px;
    max-width: 55%;
    margin: 0;
    color: #fff;
    font-size: 15px;
    line-height: 1.8;
    text-align: right;
    pointer-events: none;
}
.wx-share-guide-text strong {
    font-size: 22px;
    letter-spacing: 2px;
    color: #07c160;
}

.wx-share-guide-close {
    position: fixed;
    bottom: 18%;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    border: none;
    border-radius: 999px;
    padding: 10px 26px;
    font-size: 15px;
    font-weight: 500;
    color: var(--ink);
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .2);
}
.wx-share-guide-close:active { opacity: .85; }
