/* ============================================================
   css/chat/chat-pins.css — 心头事（Pins）聊天界面 UI
   球状入口 + 漫画对话框风泡泡列表 + 详情弹层（快捷日期/时刻档位 + 精细时间）
   韩系法式：暖米纸 + 金色细线 + 衬线体。
   防闪烁铁律（CODE-MAP 第十五节）：
   - 入场（打开）动画一律 @keyframes；.show 里加 transition:none 断开双驱动冲突
   - 退场用 transition（合成层还在）
   - 弹层内输入不抬聊天输入栏：详情卡片 padding-bottom 用 --kbd-h 垫在键盘上方
   ============================================================ */

/* —— 球状入口（聊天界面右上角，三点下方） —— */
#pins-ball {
    position: absolute;
    top: calc(var(--safe-top, 0px) + 62px);   /* 三点下方再往下一点；+safe-top 让它在 iPhone 上随刘海下移，不再与「···」重叠（安卓 --safe-top=0 无影响） */
    right: 8px;             /* 再往右一点 */
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--surface-solid, #FFFFFF);
    border: 1px solid rgba(196, 168, 106, 0.5);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gold, #C4A86A);
    cursor: pointer;
    z-index: 40;
    opacity: 0.55;
    transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
    -webkit-tap-highlight-color: transparent;
}
#pins-ball.has-pins { opacity: 1; }
#pins-ball.open {
    box-shadow: 0 0 0 3px rgba(201, 168, 168, 0.2), 0 4px 14px rgba(0, 0, 0, 0.14);
    transform: scale(1.05);
}
#pins-ball:hover { transform: scale(1.06); box-shadow: 0 3px 12px rgba(0, 0, 0, 0.13), inset 0 1px 0 rgba(255, 255, 255, 0.5); }
#pins-ball:active { transform: scale(0.94); }
.pins-ball-icon { width: 18px; height: 18px; }

#pins-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 16px;
    height: 16px;
    border-radius: 999px;
    /* ★ 2028-09 甲方定：**心头事这一颗**角标跟主题色走（--rose），不再用全站固定未读红。
       ★ 2026-10 甲方把这条口径推广到全站所有小红点（会话列表/底栏/公告/信箱/词书…）：现在大家都走 --rose。
       字色跟着主题色深浅走：浅色主题的 --rose（#C9A8A8）配白字只有 2.2:1 读不清，
       所以浅色用暖褐字（6.6:1）、暗色主题的 --rose（#D4B8B8）用近黑字（8.1:1）——两档都够清楚。 */
    background: var(--rose, #C9A8A8);
    color: #3A322B;
    font-size: 9.5px;
    line-height: 16px;
    text-align: center;
    padding: 0 4px;
    box-sizing: border-box;
    box-shadow: 0 0 0 2px var(--surface-solid, #FFFFFF);
}

/* —— 漫画对话框列表（长方形 + 顶部三角尖角） —— */
.pins-list {
    position: absolute;
    top: 104px;
    right: 8px;
    width: 264px;
    max-width: calc(100% - 16px);
    background: var(--surface-solid, #FFFFFF);
    border: 1px solid var(--border, rgba(180, 170, 155, 0.22));
    border-radius: 16px;
    box-shadow: var(--shadow-xs, 0 1px 2px rgba(30,28,26,0.04)), var(--shadow-sm, 0 2px 6px rgba(30,28,26,0.06));
    z-index: 45;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-6px) scale(0.97);
    transform-origin: top right;
    /* base 只留 close 方向 transition；open 方向由 .show 的 animation 独占（防闪烁） */
    transition: opacity 0.18s ease, transform 0.18s ease;
    pointer-events: none;
}
/* open 方向：keyframes 免疫合成层重建竞态 + transition:none 断开双驱动冲突（CODE-MAP 第十五节） */
.pins-list.show {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
    transition: none;
    animation: pinsListIn 0.2s cubic-bezier(0.22, 0.61, 0.36, 1);
}
@keyframes pinsListIn {
    from { opacity: 0; transform: translateY(-6px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
/* 顶部三角尖角（指向球）：border 三角，外层描边 + 内层填充 */
.pins-list-tri::before,
.pins-list-tri::after {
    content: '';
    position: absolute;
    top: 0;
    right: 10px;            /* 对准球中心：list right:8 + 三角半宽6 + right:N → N=10（实测校准） */
    width: 0;
    height: 0;
    border: 6px solid transparent;
}
.pins-list-tri::before {
    border-bottom-color: var(--border, rgba(180, 170, 155, 0.22));
    transform: translateY(-1px);
}
.pins-list-tri::after {
    border-bottom-color: var(--surface-solid, #FFFFFF);
    transform: translateY(-2px);
}

.pins-list-head {
    display: flex;
    align-items: baseline;
    gap: 7px;
    padding: 14px 16px 7px;
    border-bottom: 1px solid rgba(196, 168, 106, 0.22);
}
.pins-list-title {
    font-family: var(--font-display, 'Playfair Display'), serif;
    font-style: italic;
    font-size: 15px;
    letter-spacing: 1px;
    color: var(--gold, #C4A86A);
}
.pins-list-en {
    font-family: var(--font-script, 'Great Vibes'), cursive;
    font-size: 12px;
    color: rgba(196, 168, 106, 0.55);
    flex: 1;
}
.pins-list-count {
    font-size: 10px;
    color: var(--text-muted);
    background: rgba(201, 168, 168, 0.14);
    border-radius: 999px;
    padding: 1px 7px;
}
/* 「?」帮助按钮 */
.pins-help-btn {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px solid rgba(196, 168, 106, 0.45);
    background: transparent;
    color: var(--gold, #C4A86A);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    flex: 0 0 auto;
    margin-left: auto;
    transition: all 0.15s ease;
}
.pins-help-btn:hover { background: rgba(196, 168, 106, 0.12); transform: scale(1.08); }
.pins-help-btn:active { transform: scale(0.92); }

.pins-scroll {
    max-height: 320px;
    max-height: min(320px, 52dvh);
    overflow-y: auto;
    padding: 10px 12px 8px;
    scrollbar-width: thin;
    scrollbar-color: rgba(196, 168, 106, 0.4) transparent;
}
.pins-scroll::-webkit-scrollbar { width: 4px; }
.pins-scroll::-webkit-scrollbar-thumb { background: rgba(196, 168, 106, 0.4); border-radius: 2px; }

/* 每条心头事 = 一个小漫画气泡（带左尾） */
.pins-bubble {
    position: relative;
    border: 1px solid rgba(196, 168, 106, 0.28);
    border-radius: 10px;
    padding: 9px 11px 8px 13px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: transform 0.14s ease, box-shadow 0.14s ease;
    overflow: visible;
}
.pins-bubble::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 2px;
}
.pins-bubble.pins-from-ai { background: rgba(201, 168, 168, 0.10); }
.pins-bubble.pins-from-ai::before { background: var(--rose, #C9A8A8); }
.pins-bubble.pins-from-user { background: rgba(168, 184, 160, 0.10); }
.pins-bubble.pins-from-user::before { background: var(--sage, #A8B8A0); }
/* 左尾小三角 */
.pins-bubble-tail::before {
    content: '';
    position: absolute;
    left: -5px;
    top: 14px;
    width: 0;
    height: 0;
    border: 5px solid transparent;
    border-right-color: inherit;
}
.pins-bubble.pins-from-ai .pins-bubble-tail::before { border-right-color: rgba(201, 168, 168, 0.35); }
.pins-bubble.pins-from-user .pins-bubble-tail::before { border-right-color: rgba(168, 184, 160, 0.35); }

.pins-bubble:hover { transform: translateY(-1px); box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08); }
.pins-bubble:active { transform: scale(0.98); }
.pins-bubble-text {
    font-size: 13px;
    color: var(--text-primary, #3A322B);
    line-height: 1.5;
    word-break: break-all;
}
.pins-bubble-meta {
    margin-top: 5px;
    font-size: 10px;
    color: var(--text-muted, #9A8C7C);
    line-height: 1.5;
}
.pins-meta-who { color: var(--gold, #C4A86A); }
/* 每桩的稳定短号（1、2、3…）：他按号增改删，她也一眼分得清 */
.pins-no {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 15px;
    height: 15px;
    padding: 0 3px;
    margin-right: 5px;
    border-radius: var(--radius-full, 999px);
    background: var(--rose-light, #F6EAE8);
    color: var(--rose-hover, #A97A72);
    font-size: 10px;
    font-weight: 600;
    line-height: 1;
    vertical-align: 1px;
}
.pins-overdue {
    color: #b07a6a;
    border: 1px solid rgba(192, 144, 128, 0.45);
    border-radius: 3px;
    padding: 0 4px;
    font-size: 9px;
    margin-left: 2px;
    white-space: nowrap;
}

.pins-empty { padding: 20px 0 16px; text-align: center; }
.pins-empty-en {
    font-family: var(--font-script, 'Great Vibes'), cursive;
    font-size: 17px;
    color: rgba(196, 168, 106, 0.55);
}
.pins-empty-zh { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }

.pins-add-btn {
    width: calc(100% - 24px);
    margin: 2px 12px 12px;
    padding: 8px 0;
    border: 1px dashed rgba(196, 168, 106, 0.55);
    border-radius: 999px;
    background: transparent;
    font-family: inherit;
    font-size: 12.5px;
    color: var(--gold, #C4A86A);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
}
.pins-add-btn:hover { background: rgba(196, 168, 106, 0.08); }
.pins-add-btn:active { transform: scale(0.97); }

/* —— 帮助浮层（「?」按钮） —— */
/* ★ 防闪烁（与列表同款模式）：基类隐藏 + 仅 close 方向 transition；
   .show（下一帧由 JS 添加）open 方向 animation 独占 + transition:none ——
   杜绝「元素带着动画直接插入 → 首帧画终点再重播」的显示/消失/再显示。 */
.pins-help-overlay {
    position: absolute;
    inset: 0;
    z-index: 1560;
    background: rgba(30, 24, 18, 0.42);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}
.pins-help-overlay.show {
    opacity: 1;
    pointer-events: auto;
    transition: none;
    animation: pinsOvIn 0.18s ease;
}
.pins-help-card {
    position: relative;
    width: 300px;
    max-width: 100%;
    box-sizing: border-box;
    background: var(--surface-solid, #FFFFFF);
    border: 1px solid rgba(196, 168, 106, 0.4);
    border-radius: 16px;
    box-shadow: var(--shadow-md), var(--shadow-lg);
    padding: 20px 20px 18px;
}
/* ★ 卡片入场动画只挂 .show 后代（常驻基类会在隐形插入阶段先播、再与淡入重演出「显示→消失→再显示」一闪） */
.pins-help-overlay.show .pins-help-card {
    animation: pinsCardIn 0.24s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.pins-help-x {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: all 0.15s ease;
}
.pins-help-x:hover { background: rgba(201, 168, 168, 0.1); color: var(--text-primary); }
.pins-help-x:active { transform: scale(0.9); }
.pins-help-title {
    font-family: var(--font-display, 'Playfair Display'), serif;
    font-style: italic;
    font-size: 17px;
    letter-spacing: 1px;
    color: var(--gold, #C4A86A);
    text-align: center;
}
.pins-help-sub {
    font-family: var(--font-script, 'Great Vibes'), cursive;
    font-size: 13px;
    color: rgba(196, 168, 106, 0.55);
    text-align: center;
    margin-bottom: 12px;
}
.pins-help-lead {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.7;
    margin: 0 0 10px;
}
.pins-help-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.pins-help-list li {
    position: relative;
    font-size: 12.5px;
    color: var(--text-secondary);
    line-height: 1.7;
    padding-left: 16px;
    margin-bottom: 8px;
}
.pins-help-dot {
    position: absolute;
    left: 0;
    top: 8px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--rose, #C9A8A8);
}

/* —— 详情弹层（挂 #app） —— */
/* ★ 防闪烁同帮助浮层：基类隐藏 + close 方向 transition；.show open 方向 animation 独占 */
.pins-detail-overlay {
    position: absolute;
    inset: 0;
    z-index: 1540;
    background: rgba(30, 24, 18, 0.42);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    /* 键盘弹出时把卡片垫在键盘上方（overlay 输入模式：聊天输入栏不抬，这里自己让位） */
    padding-bottom: calc(16px + var(--kbd-h, 0px));
    box-sizing: border-box;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}
.pins-detail-overlay.show {
    opacity: 1;
    pointer-events: auto;
    transition: none;
    animation: pinsOvIn 0.18s ease;
}
@keyframes pinsOvIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.pins-detail-card {
    width: 320px;
    max-width: 100%;
    max-height: 100%;
    overflow-y: auto;
    box-sizing: border-box;
    background: var(--surface-solid, #FFFFFF);
    border: 1px solid var(--border, rgba(180, 170, 155, 0.22));
    border-radius: 16px;
    box-shadow: var(--shadow-xs, 0 1px 2px rgba(30,28,26,0.04)), var(--shadow-sm, 0 2px 6px rgba(30,28,26,0.06));
    padding: 18px 18px 14px;
    scrollbar-width: thin;
    scrollbar-color: rgba(196, 168, 106, 0.4) transparent;
}
/* ★ 卡片入场动画只挂 .show 后代（同帮助卡片，防隐形插入阶段先播重演出闪） */
.pins-detail-overlay.show .pins-detail-card {
    animation: pinsCardIn 0.24s cubic-bezier(0.22, 0.61, 0.36, 1);
}
@keyframes pinsCardIn {
    from { opacity: 0; transform: translateY(8px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.pins-detail-title {
    font-family: var(--font-display, 'Playfair Display'), serif;
    font-style: italic;
    font-size: 16px;
    letter-spacing: 1px;
    color: var(--gold, #C4A86A);
    text-align: center;
    line-height: 1.2;
}
.pins-detail-sub {
    font-family: var(--font-script, 'Great Vibes'), cursive;
    font-size: 12px;
    color: rgba(196, 168, 106, 0.55);
    text-align: center;
    margin-bottom: 6px;
}
.pins-detail-note {
    text-align: center;
    font-size: 10.5px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.pins-detail-text {
    width: 100%;
    box-sizing: border-box;
    min-height: 72px;
    border: 1px solid var(--border, rgba(180, 170, 155, 0.35));
    border-radius: 10px;
    background: var(--surface, rgba(255, 252, 249, 0.82));
    font-family: inherit;
    font-size: 13.5px;
    color: var(--text-primary);
    padding: 10px 12px;
    resize: none;
    outline: none;
    line-height: 1.6;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.pins-detail-text:focus {
    border-color: var(--rose, #C9A8A8);
    box-shadow: 0 0 0 3px rgba(201, 168, 168, 0.14);
}
.pins-detail-count {
    text-align: right;
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 3px;
    padding-right: 2px;
}

/* 档位区：网格化铺满（消除右侧空白），统一主题色 */
.pins-detail-sec {
    margin-top: 12px;
}
.pins-detail-label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary, #8A8278);
    margin-bottom: 7px;
    letter-spacing: 0.5px;
}
.pins-chip-row {
    display: grid;
    gap: 6px;
}
#pins-date-chips {
    grid-template-columns: repeat(4, 1fr);
}
#pins-time-chips {
    grid-template-columns: repeat(3, 1fr);
}
.pins-chip {
    font-family: inherit;
    font-size: 12px;
    color: var(--text-secondary, #8A8278);
    background: var(--surface, rgba(255, 252, 249, 0.82));
    border: 1px solid var(--border, rgba(180, 170, 155, 0.22));
    border-radius: 999px;
    padding: 6px 4px;
    cursor: pointer;
    min-width: 0;
    box-sizing: border-box;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
    /* iOS：禁双击放大，消点击延迟/坐标偏移（心头事点30选中16）+ 关高亮闪现 */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.pins-chip:hover { border-color: var(--rose, #C9A8A8); color: var(--text-primary, #3A322B); }
.pins-chip:active { transform: scale(0.95); }
.pins-chip.active {
    background: var(--rose, #C9A8A8);
    border-color: var(--rose, #C9A8A8);
    color: #fff;
    box-shadow: 0 2px 8px rgba(201, 168, 168, 0.28);
}
.pins-chip-cal {
    max-width: 100%;
    text-align: center;
    outline: none;
    -webkit-user-select: none;
    user-select: none;
}
.pins-chip-fine.active {
    background: var(--rose, #C9A8A8);
    border-color: var(--rose, #C9A8A8);
    color: #fff;
}

/* 精细时间选择（两列滚动 + 确定） */
.pins-fine {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.pins-fine-cols {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    min-width: 0;
    background: var(--surface, rgba(255, 252, 249, 0.82));
    border: 1px solid var(--border, rgba(180, 170, 155, 0.22));
    border-radius: 10px;
    padding: 6px 8px;
    box-sizing: border-box;
}
.pins-fine-col {
    flex: 1;
    min-width: 0;
    max-height: 128px;
    overflow-y: auto;
    text-align: center;
    scrollbar-width: thin;
    scrollbar-color: rgba(196, 168, 106, 0.4) transparent;
}
.pins-fine-col::-webkit-scrollbar { width: 3px; }
.pins-fine-col::-webkit-scrollbar-thumb { background: rgba(196, 168, 106, 0.4); border-radius: 2px; }
.pins-fine-opt {
    font-size: 13px;
    color: var(--text-secondary, #8A8278);
    padding: 4px 0;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
    font-variant-numeric: tabular-nums;
}
.pins-fine-opt:hover { background: rgba(201, 168, 168, 0.1); color: var(--text-primary, #3A322B); }
.pins-fine-opt.active {
    background: var(--rose-light, rgba(201, 168, 168, 0.12));
    color: var(--rose-dark, #A88080);
    font-weight: 600;
}
.pins-fine-div {
    color: var(--text-muted, #BFB8AE);
    font-size: 13px;
}
.pins-fine-ok {
    flex: 0 0 auto;
    padding: 7px 16px;
}

/* 摘要行（始终显示最终计划时间） */
.pins-due-summary {
    margin-top: 12px;
    text-align: center;
    font-size: 11.5px;
    color: var(--text-secondary, #8A8278);
    background: var(--gold-light, rgba(196, 168, 106, 0.10));
    border: 1px dashed rgba(196, 168, 106, 0.32);
    border-radius: 8px;
    padding: 6px 8px;
    word-break: break-all;
}
.pins-due-summary.pins-due-overdue { color: #b07a6a; }

.pins-detail-foot {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
}
.pins-btn {
    font-family: inherit;
    font-size: 12.5px;
    border-radius: 999px;
    padding: 7px 16px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, opacity 0.15s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.pins-btn:active { transform: scale(0.96); }
/* 主按钮：纯色玫瑰底（禁止渐变按钮，DESIGN-SYSTEM 第八节） */
.pins-btn-main {
    background: var(--rose, #C9A8A8);
    color: #fff;
    box-shadow: var(--shadow-xs, 0 1px 2px rgba(30,28,26,0.04)), 0 2px 8px rgba(201, 168, 168, 0.28);
}
.pins-btn-main:hover { background: var(--rose-hover, #BA9696); }
.pins-btn-ghost {
    background: transparent;
    border-color: var(--border, rgba(180, 170, 155, 0.22));
    color: var(--text-secondary, #8A8278);
}
.pins-btn-ghost:hover { border-color: var(--rose, #C9A8A8); color: var(--text-primary, #3A322B); }
.pins-btn-danger {
    background: transparent;
    border-color: rgba(192, 144, 128, 0.45);
    color: #b07a6a;
}
.pins-btn-danger:hover { background: rgba(192, 144, 128, 0.08); }

/* —— 暗色模式 —— */
[data-theme-mode="dark"] #pins-ball { background: #252120; }
[data-theme-mode="dark"] .pins-list { background: #252120; }
[data-theme-mode="dark"] .pins-list-tri::after { border-bottom-color: #252120; }
[data-theme-mode="dark"] .pins-bubble.pins-from-ai { background: rgba(201, 168, 168, 0.12); }
[data-theme-mode="dark"] .pins-bubble.pins-from-user { background: rgba(168, 184, 160, 0.12); }
[data-theme-mode="dark"] .pins-detail-card { background: #252120; }
[data-theme-mode="dark"] .pins-help-card { background: #252120; }
[data-theme-mode="dark"] .pins-help-lead { color: #EAE4DE; }
[data-theme-mode="dark"] .pins-help-list li { color: #9A928A; }
[data-theme-mode="dark"] .pins-detail-text,
[data-theme-mode="dark"] .pins-chip,
[data-theme-mode="dark"] .pins-fine-cols { background: #2B2623; }
[data-theme-mode="dark"] .pins-chip.active { background: var(--rose, #D4B8B8); border-color: var(--rose, #D4B8B8); color: #1E1A18; }
[data-theme-mode="dark"] .pins-chip-fine.active { background: var(--rose, #D4B8B8); border-color: var(--rose, #D4B8B8); color: #1E1A18; }
[data-theme-mode="dark"] .pins-btn-main { background: var(--rose, #D4B8B8); color: #1E1A18; }
[data-theme-mode="dark"] #pins-badge { background: var(--rose, #D4B8B8); color: #1E1A18; }
