/* ============================================================
   法律文书生成器 — yicool.com.cn /tools/ldg
   视觉语言：正式 / 可靠，主蓝 #1d4f9c · 白纸预览 · 三端适配
   断点：>=1100px 桌面双栏 / 768-1099 平板 / <768px 手机单栏
   ============================================================ */

/* 占满整个电脑端屏幕：覆盖全站 .app / .main-content 的宽度限制 */
body.page-ldg-full .app { max-width: 100%; }
body.page-ldg-full .main-content { max-width: 100%; border-right: 0; }
.ldg-page {
    max-width: 100%;
    margin: 0 auto;
    padding: 24px 16px 48px;
}

/* ---------- 标题区 ---------- */
.ldg-hero { margin-bottom: 20px; }
.ldg-hero-title {
    font-size: 26px; font-weight: 700; color: #1b1f24;
    display: flex; align-items: center; gap: 10px; margin: 0 0 6px;
}
.ldg-hero-title::before {
    content: ''; width: 8px; height: 22px; border-radius: 4px;
    background: linear-gradient(180deg, #1d4f9c, #5b8de6); flex: none;
}
.ldg-hero-sub { font-size: 14px; color: #8a93a2; margin: 0; line-height: 1.7; max-width: 760px; }

/* ---------- 主布局 ---------- */
.ldg-main {
    display: grid;
    grid-template-columns: 1fr 480px;
    gap: 20px;
    align-items: start;
}
.ldg-panel {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .06);
    overflow: hidden;
}
.ldg-panel-head {
    padding: 14px 18px;
    border-bottom: 1px solid #eef0f3;
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.ldg-panel-title { font-size: 15px; font-weight: 700; color: #1b1f24; margin: 0; }
.ldg-panel-sub { font-size: 12px; color: #8a93a2; margin: 2px 0 0; }
.ldg-panel-body { padding: 16px 18px 20px; }

/* ---------- 文书类型选择（桌面：网格卡片） ---------- */
.ldg-cats { margin-bottom: 14px; }
.ldg-cat-label {
    font-size: 12px; font-weight: 700; color: #8a93a2;
    margin: 14px 0 8px; letter-spacing: .5px;
}
.ldg-cat-label:first-child { margin-top: 0; }
.ldg-type-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}
.ldg-type-card {
    border: 1.5px solid #e6e9ef;
    border-radius: 10px;
    padding: 10px 12px;
    cursor: pointer;
    display: flex; gap: 10px; align-items: flex-start;
    transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
    background: #fff;
    text-align: left;
    font: inherit;
}
.ldg-type-card:hover { border-color: #b9cdf0; }
.ldg-type-card.active {
    border-color: #1d4f9c;
    background: #f0f5fd;
    box-shadow: 0 0 0 2px rgba(29, 79, 156, .12);
}
.ldg-type-icon {
    width: 34px; height: 34px; flex: none;
    border-radius: 8px;
    background: #eef3fb; color: #1d4f9c;
    display: flex; align-items: center; justify-content: center;
    font-size: 17px;
}
.ldg-type-card.active .ldg-type-icon { background: #1d4f9c; color: #fff; }
.ldg-type-name { font-size: 13px; font-weight: 600; color: #1b1f24; line-height: 1.3; }
.ldg-type-desc { font-size: 11px; color: #8a93a2; margin-top: 2px; line-height: 1.5; }

/* ---------- 表单 ---------- */
.ldg-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.ldg-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.ldg-field-full { grid-column: 1 / -1; }
.ldg-field label { font-size: 12px; color: #53606e; font-weight: 600; }
.ldg-field label .ldg-opt { color: #a5adb8; font-weight: 400; }
.ldg-field input,
.ldg-field select,
.ldg-field textarea {
    width: 100%;
    border: 1px solid #dde1e8;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 14px;
    color: #1b1f24;
    background: #fff;
    transition: border-color .15s ease, box-shadow .15s ease;
    box-sizing: border-box;
    font-family: inherit;
}
.ldg-field input:focus,
.ldg-field select:focus,
.ldg-field textarea:focus {
    outline: none;
    border-color: #1d4f9c;
    box-shadow: 0 0 0 3px rgba(29, 79, 156, .12);
}
.ldg-field textarea { resize: vertical; min-height: 64px; line-height: 1.6; }
.ldg-field .ldg-hint { font-size: 11px; color: #a5adb8; line-height: 1.5; }

/* ---------- 预览（白纸） ---------- */
.ldg-preview-sticky { position: sticky; top: 84px; }
.ldg-paper {
    background: #fff;
    padding: 34px 40px 40px;
    font-family: "SimSun", "Songti SC", "NSimSun", serif;
    color: #111;
    font-size: 14px;
    line-height: 1.9;
    min-height: 420px;
    word-break: break-word;
}
.ldg-paper-empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: #b6bdc7; font-size: 13px; gap: 10px;
    min-height: 300px;
}
.ldg-paper-empty svg { width: 44px; height: 44px; color: #cfd6e0; }
.ldg-paper .pb-title { text-align: center; font-weight: 700; font-size: 18px; margin-bottom: 8px; }
.ldg-paper .pb-para { text-indent: 2em; margin: 0 0 4px; }
.ldg-paper .pb-center { text-align: center; margin: 0 0 4px; }
.ldg-paper .pb-right { text-align: right; margin: 0 0 4px; }
.ldg-paper .pb-bold { font-weight: 700; text-indent: 2em; margin: 0 0 4px; }
.ldg-paper .pb-space { height: 12px; }
.ldg-paper hr { border: none; border-top: 1px dashed #cfd6e0; margin: 12px 0; }
.ldg-paper-note {
    font-size: 11px; color: #a5adb8; text-align: center;
    padding: 8px; border-top: 1px dashed #e6e9ef; line-height: 1.6;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---------- 操作区 ---------- */
.ldg-actions {
    display: flex; gap: 10px; padding: 14px 18px;
    border-top: 1px solid #eef0f3; flex-wrap: wrap;
}
.ldg-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border: none; cursor: pointer; font-size: 14px; font-weight: 600;
    border-radius: 8px; padding: 10px 18px; line-height: 1.4;
    transition: all .15s ease; white-space: nowrap; font-family: inherit;
}
.ldg-btn:disabled { opacity: .55; cursor: not-allowed; }
.ldg-btn-primary {
    background: #1d4f9c; color: #fff;
}
.ldg-btn-primary:hover:not(:disabled) { background: #17437f; }
.ldg-btn-ghost {
    background: #f1f3f7; color: #2c3542;
}
.ldg-btn-ghost:hover:not(:disabled) { background: #e4e9f2; }
.ldg-btn-email {
    background: #eef3fb; color: #1d4f9c; border: 1px solid #c9d8f2;
}
.ldg-btn-email:hover:not(:disabled) { background: #e0eafa; }
.ldg-btn svg { width: 16px; height: 16px; flex: none; }

/* ---------- 邮件面板 ---------- */
.ldg-mask {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(15, 20, 25, .5);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.ldg-mask[hidden] { display: none; }
.ldg-mailbox {
    width: 100%; max-width: 420px;
    background: #fff; border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .2);
    overflow: hidden;
}
.ldg-mailbox-head {
    padding: 16px 18px 12px;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid #eef0f3;
}
.ldg-mailbox-head h3 { margin: 0; font-size: 16px; color: #1b1f24; }
.ldg-mailbox-close {
    border: none; background: none; cursor: pointer; font-size: 20px; color: #8a93a2; line-height: 1;
    padding: 4px;
}
.ldg-mailbox-body { padding: 16px 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.ldg-mailbox-body .ldg-field { grid-column: auto; }
.ldg-mailbox-body .ldg-mail-info {
    font-size: 12px; color: #8a93a2; background: #f6f8fb;
    border-radius: 8px; padding: 8px 10px; line-height: 1.6;
}
.ldg-mailbox-actions { display: flex; gap: 10px; justify-content: flex-end; }
.ldg-mail-error { font-size: 12px; color: #c0392b; display: none; }
.ldg-mail-error.show { display: block; }

/* ---------- Toast ---------- */
.ldg-toast {
    position: fixed; top: 18px; left: 50%; transform: translateX(-50%) translateY(-120%);
    z-index: 200; background: #1b1f24; color: #fff;
    font-size: 13px; padding: 10px 18px; border-radius: 999px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
    transition: transform .25s ease; max-width: 90vw; text-align: center;
    pointer-events: none;
}
.ldg-toast.show { transform: translateX(-50%) translateY(0); }
.ldg-toast.err { background: #b3372e; }

/* ---------- 移动端底部操作栏 ---------- */
.ldg-action-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid #eef0f3;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    display: none;
    gap: 10px;
}
.ldg-action-bar .ldg-btn { flex: 1; }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 1120px) {
    .ldg-main { grid-template-columns: 1fr 400px; }
}

@media (max-width: 860px) {
    .ldg-main { grid-template-columns: 1fr; }
    .ldg-preview-sticky { position: static; }
    /* 类型选择改为横向滚动 chips */
    .ldg-cats { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin: 0 -4px 14px; scroll-snap-type: x mandatory; }
    .ldg-cat-group { min-width: 100%; scroll-snap-align: start; padding: 0 4px; }
    .ldg-cat-label { margin-top: 0; }
    .ldg-type-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
    .ldg-page { padding: 18px 12px 96px; }
    .ldg-hero-title { font-size: 22px; }
    .ldg-form { grid-template-columns: 1fr; }
    .ldg-type-grid { grid-template-columns: 1fr 1fr; }
    .ldg-paper { padding: 24px 20px 28px; }
    .ldg-actions { display: none; }        /* 桌面按钮隐藏 */
    .ldg-action-bar { display: flex; }     /* 底部悬浮栏出现 */
    .ldg-mailbox { max-width: 100%; }
}
