/* =========================================================================
   易学词典模块样式
   ========================================================================= */

/* ---------- 分类色 ---------- */
.is-yinyang  { --cd-c: #dc2626; }
.is-ganzhi   { --cd-c: #a16207; }
.is-bagua    { --cd-c: #7c3aed; }
.is-bazi     { --cd-c: #16a34a; }
.is-shensha  { --cd-c: #c026d3; }
.is-shushu   { --cd-c: #0891b2; }
.is-tianwen  { --cd-c: #2563eb; }

/* ---------- 顶部统计 + 搜索 ---------- */

.cd-topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    margin-bottom: 14px;
    background: var(--mn-bg-card, #fff);
    border: 1px solid var(--mn-border, #e5e7eb);
    border-radius: 10px;
    flex-wrap: wrap;
    /* 修复：防止容器溢出 */
    max-width: 100%;
    box-sizing: border-box;
}

.cd-stats {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    /* 修复：移除 flex-shrink: 0，允许收缩和换行 */
    flex: 1 1 auto;
    min-width: 0;
}
.cd-stat {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 12px;
    background: var(--mn-bg-page, #fafbfc);
    border: 1px solid var(--mn-border, #e5e7eb);
    font-size: 12px;
    color: var(--mn-text-muted, #888);
    font-weight: 600;
}
.cd-stat strong {
    font-size: 13px;
    color: var(--cd-c, #333);
    margin-left: 2px;
}

.cd-search {
    position: relative;
    /* 修复：调整 flex 策略，允许收缩并保持基础宽度 */
    flex: 1 1 200px;
    min-width: 150px;
}
.cd-search input {
    width: 100%;
    padding: 9px 36px 9px 14px;
    border-radius: 8px;
    border: 1px solid var(--mn-border, #e5e7eb);
    background: var(--mn-bg-page, #fafbfc);
    color: var(--mn-text, #333);
    font-size: 14px;
    outline: none;
    transition: border-color .2s, background-color .2s;
    box-sizing: border-box;
}
.cd-search input:focus {
    border-color: var(--mn-primary, #0066cc);
    background: var(--mn-bg-card, #fff);
}
.cd-search-clear {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: var(--mn-border-light, #f0f0f0);
    color: var(--mn-text-muted, #888);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: none;
}
.cd-search-clear.is-visible {
    display: flex;
    align-items: center;
    justify-content: center;
}
.cd-search-clear:hover {
    background: var(--mn-border, #e5e7eb);
    color: var(--mn-text, #333);
}

.cd-hint {
    margin: 0 0 14px;
    padding: 12px 16px;
    background: var(--mn-comp-alert-warning-bg, #fef3c7);
    border: 1px solid var(--mn-comp-alert-warning-border, #fde68a);
    border-radius: 8px;
    font-size: 13px;
    color: var(--mn-comp-alert-warning-text, #92400e);
    text-align: center;
}

/* ---------- 分类章节 ---------- */

.cd-group {
    margin-bottom: 28px;
    scroll-margin-top: 80px;
}

.cd-group-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--cd-c, #0066cc);
}

.cd-group-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-size: 20px;
    color: #fff;
    background: var(--cd-c, #0066cc);
}

.cd-group-titles {
    flex: 1;
    min-width: 0;
}
.cd-group-name {
    margin: 0;
    font-size: 18px;
    font-weight: 800;
    color: var(--mn-text, #333);
    letter-spacing: 1px;
}
.cd-group-desc {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--mn-text-muted, #888);
}

/* ---------- 词条卡片网格 ---------- */

.cd-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}

.cd-card {
    display: flex;
    flex-direction: column;
    padding: 14px 16px;
    background: var(--mn-bg-card, #fff);
    border: 1px solid var(--mn-border, #e5e7eb);
    border-top: 3px solid var(--cd-c, #0066cc);
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    transition: all .18s;
    position: relative;
}
.cd-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, .06);
    border-color: var(--cd-c, #0066cc);
}

.cd-card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}
.cd-card-name {
    font-size: 16px;
    font-weight: 800;
    color: var(--mn-text, #333);
    letter-spacing: 1px;
    line-height: 1.2;
}
.cd-card-cat {
    flex-shrink: 0;
    padding: 1px 8px;
    border-radius: 8px;
    background: var(--cd-c, #0066cc);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    opacity: .85;
    white-space: nowrap;
}
.cd-card-pinyin {
    font-size: 12px;
    color: var(--mn-text-muted, #888);
    font-style: italic;
    margin-bottom: 6px;
    font-family: ui-monospace, monospace;
}
.cd-card-alias {
    font-size: 11px;
    color: var(--mn-text-muted, #888);
    margin-bottom: 6px;
    padding: 2px 6px;
    background: var(--mn-bg-page, #fafbfc);
    border-radius: 4px;
    display: inline-block;
    width: fit-content;
}
.cd-card-brief {
    font-size: 13px;
    line-height: 1.7;
    color: var(--mn-text, #333);
}

/* ---------- 详情 Hero ---------- */

.cd-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 22px 24px;
    border-radius: 12px;
    background: linear-gradient(135deg,
        var(--cd-c, #0066cc) 0%,
        rgba(0, 0, 0, .3) 100%);
    color: #fff;
    margin-bottom: 16px;
    position: relative;
    overflow: hidden;
}
.cd-hero::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .08);
}
.cd-hero-left {
    flex: 1;
    min-width: 0;
    position: relative;
    z-index: 1;
}
.cd-hero-name {
    font-size: 32px;
    font-weight: 900;
    letter-spacing: 3px;
    line-height: 1.15;
    margin-bottom: 6px;
}
.cd-hero-pinyin {
    font-size: 13px;
    opacity: .85;
    font-family: ui-monospace, monospace;
    margin-bottom: 4px;
}
.cd-hero-alias {
    font-size: 12px;
    opacity: .8;
}
.cd-hero-right {
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}
.cd-hero-tag {
    padding: 4px 14px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    background: rgba(255, 255, 255, .2);
    color: #fff;
}

/* ---------- 简介 + 详细 ---------- */

.cd-brief {
    padding: 14px 18px;
    margin-bottom: 20px;
    background: var(--mn-bg-page, #fafbfc);
    border-left: 4px solid var(--cd-c, #0066cc);
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--mn-text, #333);
    line-height: 1.7;
}

.cd-detail {
    padding: 18px 20px;
    margin-bottom: 20px;
    background: var(--mn-bg-card, #fff);
    border: 1px solid var(--mn-border, #e5e7eb);
    border-radius: 10px;
    font-size: 14px;
    line-height: 2;
    color: var(--mn-text, #333);
    text-indent: 2em;
}

/* ---------- 出处 ---------- */

.cd-source {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    margin-bottom: 20px;
    background: var(--mn-bg-page, #fafbfc);
    border: 1px dashed var(--mn-border, #e5e7eb);
    border-radius: 8px;
    font-size: 13px;
}
.cd-source-icon {
    flex-shrink: 0;
    font-size: 16px;
}
.cd-source-text {
    color: var(--mn-text-secondary, #666);
    font-family: ui-monospace, "Noto Serif SC", serif;
    line-height: 1.7;
}

/* ---------- 底部说明 ---------- */

.cd-footnote {
    padding: 14px 18px;
    margin-bottom: 16px;
    background: var(--mn-bg-page, #fafbfc);
    border: 1px dashed var(--mn-border, #e5e7eb);
    border-radius: 10px;
    font-size: 12px;
    line-height: 1.85;
    color: var(--mn-text-muted, #888);
    text-align: center;
}

/* ---------- 响应式 ---------- */

@media (max-width: 640px) {
    .cd-topbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 12px;
    }
    .cd-stats { justify-content: flex-start; }
    .cd-search { min-width: 0; }

    .cd-group-head { gap: 10px; }
    .cd-group-icon { width: 34px; height: 34px; font-size: 16px; }
    .cd-group-name { font-size: 16px; }

    .cd-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .cd-card { padding: 12px 14px; }
    .cd-card-name { font-size: 15px; letter-spacing: .5px; }

    .cd-hero { padding: 18px; }
    .cd-hero-name { font-size: 24px; letter-spacing: 2px; }
    .cd-hero-right { display: none; }

    .cd-detail { font-size: 13px; line-height: 1.9; padding: 14px 16px; }
}