/* ================= 名片舞台（横版经典名片 · 基础层） ================= */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body.card-stage {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
                 "Segoe UI", Roboto, sans-serif;
    background:
        radial-gradient(60% 50% at 50% 0%, rgba(37,99,235,.05), transparent),
        linear-gradient(180deg, #eef1f6, #e3e7ee);
    color: #333;
}
body.card-stage.is-owner { background: linear-gradient(180deg,#f2f5fa,#e6eaf1); }

/* ---------- 卡片基底：90×54mm 标准名片比例 ---------- */
#card {
    width: min(620px, 94vw);
    aspect-ratio: 5 / 3;              /* 经典横版比例 */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 8px;
    padding: 26px 32px 18px;
    transition: box-shadow .25s ease, transform .25s ease;
}
@media (hover:hover) {
    #card:hover { transform: translateY(-2px); }
}

/* 眉头：公司 + 头像 */
.card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}
.card-company {
    font-size: 13.5px;
    font-weight: 600;
    letter-spacing: .08em;
    line-height: 1.4;
    padding-top: 4px;
}
.avatar-wrap { flex: none; }
.avatar-img {
    width: 46px; height: 46px; border-radius: 50%;
    object-fit: cover; border: 2px solid rgba(0,0,0,.06);
    display: block;
}
.avatar-fallback {
    width: 46px; height: 46px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; font-weight: 700;
}

/* 主体：左身份，右联系方式 */
.card-body {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 24px;
}
.identity { min-width: 0; }
.card-name { margin: 0; font-size: 30px; line-height: 1.15; letter-spacing: .02em; }
.card-title { margin: 5px 0 0; font-size: 12.5px; letter-spacing: .12em; }
.card-tagline {
    margin: 9px 0 0;
    font-size: 11.5px;
    line-height: 1.55;
    max-width: 300px;
}

.contact-list {
    list-style: none;
    margin: 0; padding: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: none;
    max-width: 55%;
}
.contact-list li {
    display: flex; align-items: center; gap: 7px;
    border-radius: 6px; padding: 1px 4px; margin: 0 -4px;
    font-size: 11.5px;
}
.c-ico {
    width: 19px; height: 19px; flex: none; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
}
.contact-list span[data-field], .contact-list a {
    text-decoration: none; word-break: break-all; color: inherit; line-height: 1.45;
}
.contact-list a:hover { text-decoration: underline; }

.mini-copy {
    border: none; background: none; cursor: pointer;
    font-size: 10px; color: inherit; opacity: .45; padding: 1px 5px; border-radius: 5px;
}
.mini-copy:hover { opacity: 1; background: rgba(0,0,0,.06); }

/* 底部操作 */
.card-actions {
    display: flex; align-items: center; gap: 8px;
    padding-top: 10px;
}
.act-gap { flex: 1; }
.act-btn {
    appearance: none; border: none; cursor: pointer; text-decoration: none;
    font-size: 12px; padding: 6px 14px; border-radius: 999px;
    display: inline-flex; align-items: center; gap: 5px;
    transition: filter .15s ease, background .15s ease, opacity .15s ease;
}
.act-btn.primary { color: #fff; }
.act-btn.primary:hover { filter: brightness(1.08); }
.act-btn.ghost { background: transparent; border: 1px solid rgba(120,130,150,.3); color: inherit; opacity: .85; }
.act-btn.ghost:hover { opacity: 1; background: rgba(127,140,160,.08); }

/* ---------- 空字段：访客隐藏，主人可编辑 ---------- */
#card .empty { display: none; }
body.is-owner #card .empty { display: flex; opacity: .5; }

/* ---------- 所见即所得编辑态 ---------- */
body.is-owner [data-field][data-ph]:empty::before {
    content: attr(data-ph);
    color: #b3bac6;
    font-weight: 400;
}
body.is-owner [data-field] {
    cursor: text;
    border-bottom: 1px dashed transparent;
    border-radius: 2px;
    min-width: 20px;
    min-height: 1em;
    display: inline-block;
    outline: none;
}
body.is-owner #card .empty span[data-field] { flex: none; }
body.is-owner .identity [data-field] { display: block; }
body.is-owner [data-field]:hover { border-bottom-color: rgba(37,99,235,.45); }
body.is-owner [data-field]:focus {
    background: rgba(37,99,235,.07);
    border-bottom-color: #2563eb;
    box-shadow: 0 1px 0 #2563eb;
}

/* ---------- 主人管理入口：右上角低调圆钮 + 下拉面板 ---------- */
.owner-menu { position: fixed; top: 14px; right: 16px; z-index: 60; }
.om-trigger {
    width: 34px; height: 34px; border-radius: 50%;
    border: 1px solid rgba(120,132,155,.28);
    background: rgba(255,255,255,.55);
    backdrop-filter: blur(4px);
    color: #66738c; font-size: 15px; line-height: 1;
    cursor: pointer; opacity: .35;
    transition: opacity .2s ease, transform .2s ease;
}
.om-trigger:hover, .owner-menu.open .om-trigger { opacity: 1; }
.owner-menu.open .om-trigger { transform: rotate(-12deg); }

.om-panel {
    position: absolute; top: 42px; right: 0;
    width: 272px;
    background: #fff;
    border: 1px solid #e3e8f0;
    border-radius: 14px;
    box-shadow: 0 22px 60px -18px rgba(20,30,60,.35);
    padding: 16px;
    display: none;
    font-size: 13px;
    color: #333f52;
}
.owner-menu.open .om-panel { display: block; animation: omIn .16s ease; }
@keyframes omIn { from { opacity: 0; transform: translateY(-4px); } }

.omp-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.omp-head { justify-content: space-between; }
.ob-badge {
    background: linear-gradient(135deg,#2563eb,#7c3aed);
    color: #fff; padding: 3px 10px; border-radius: 999px;
    font-weight: 600; font-size: 11.5px;
}
.save-state { font-size: 11.5px; color: #16a34a; min-width: 56px; text-align: right; }
.save-state.err { color: #dc2626; }

.omp-btn {
    display: inline-flex; align-items: center; gap: 6px;
    background: #f4f6fa; border: 1px solid #e2e7f0; color: #40506a;
    border-radius: 9px; padding: 7px 12px;
    font-size: 12.5px; cursor: pointer; text-decoration: none;
    transition: background .15s ease;
}
.omp-btn:hover { background: #ecf0f7; }
.omp-block { display: flex !important; width: 100%; justify-content: flex-start; margin-bottom: 8px; }
.omp-chip.unread { background:#fee2e2; border-color:#fecaca; color:#b91c1c; font-weight:600; }

.omp-label {
    font-size: 11px; color: #98a2b8; letter-spacing: .08em;
    margin: 12px 0 8px; border-top: 1px dashed #e6eaf2; padding-top: 12px;
}

/* 面板内模板缩略图 */
.tp-thumbs {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
    max-height: 208px; overflow-y: auto; padding-right: 2px;
}
.tp-thumb {
    border: 2px solid transparent; background: none; padding: 0; cursor: pointer;
    border-radius: 8px; position: relative;
}
.tp-thumb img { display: block; width: 100%; height: 44px; border-radius: 6px; object-fit: cover; }
.tp-thumb i {
    display: block; font-style: normal; font-size: 10.5px; color: #66708a;
    text-align: center; padding-top: 2px; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
}
.tp-thumb.active { border-color: #2563eb; }
.tp-thumb.active i { color: #2563eb; font-weight: 600; }

/* ---------- 弹窗 ---------- */
dialog {
    border: none; border-radius: 16px; padding: 24px 24px 18px;
    width: min(400px, 92vw);
    box-shadow: 0 30px 80px -20px rgba(0,0,0,.45);
}
dialog::backdrop { background: rgba(10,14,22,.45); backdrop-filter: blur(3px); }
dialog h3 { margin: 0 0 4px; font-size: 18px; }
dialog .muted { color: #8a93a6; font-size: 12.5px; margin: 0 0 14px; }
dialog label { display: block; font-size: 13px; color: #4b5568; margin-bottom: 10px; }
dialog input, dialog textarea {
    width: 100%; margin-top: 4px; padding: 9px 12px;
    border: 1px solid #d7dde8; border-radius: 9px; font-size: 14px; font-family: inherit;
}
dialog input:focus, dialog textarea:focus { outline: 2px solid rgba(37,99,235,.35); border-color: #2563eb; }
.dlg-close { position: absolute; top: 8px; right: 10px; margin: 0; }
.dlg-close button {
    border: none; background: none; font-size: 22px; color: #9aa3b5; cursor: pointer; line-height: 1;
}
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
#qrImg { display: block; margin: 6px auto 10px; image-rendering: pixelated; border-radius: 8px; }
.qr-url { text-align: center; word-break: break-all; }

/* ---------- Toast ---------- */
.toast {
    position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%);
    background: #111827; color: #fff; font-size: 13px;
    padding: 10px 18px; border-radius: 999px; z-index: 99;
    box-shadow: 0 10px 30px rgba(0,0,0,.3);
    animation: rise .2s ease;
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }

.form-error { color: #dc2626; font-size: 13px; margin: 6px 0; }

@media (max-width: 560px) {
    body.card-stage { padding: 18px 10px; }
    #card { aspect-ratio: auto; width: 100%; padding: 22px 22px 16px; }
    .card-body { flex-direction: column; align-items: stretch; gap: 14px; }
    .contact-list { max-width: none; }
    .om-panel { width: min(272px, calc(100vw - 32px)); }
}
