/* styles/blocks.css v4 — 类型化块全面样式系统
 * 块外壳 (.tb-*) + 各类型渲染器 (.aiua-*)
 * 对齐主流富文本实践：干净、专业、交互反馈清晰
 */

/* ============================================================
 * 块外壳 .tb-block
 * ============================================================ */
.tb-block {
    position: relative;
    margin: 20px 0;
    padding: 0;
    border-radius: 12px;
    border: 1px solid transparent;
    transition: border-color .2s, background .2s, box-shadow .2s;
}

.tb-block:hover {
    border-color: var(--wb-border, #E5E7EB);
    background: color-mix(in srgb, var(--wb-bg-body, #F9FAFB) 50%, transparent);
}

.tb-block.is-source {
    border-color: var(--wb-accent, #3B82F6);
    background: color-mix(in srgb, var(--wb-accent, #3B82F6) 3%, var(--wb-bg-body, #F9FAFB));
}

/* 标题 */
.tb-block .tb-heading {
    margin: 14px 16px 8px;
    font-size: 1.1em;
    font-weight: 700;
    color: var(--wb-text-main, #1F2937);
    line-height: 1.4;
}

.tb-body {
    padding: 0 16px 16px;
}

/* ============================================================
 * 顶部工具条：hover 浮出
 * ============================================================ */
.tb-bar {
    position: absolute;
    top: 8px;
    right: 10px;
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-3px);
    transition: opacity .18s, transform .18s;
    z-index: 4;
}

.tb-block:hover .tb-bar,
.tb-block.is-source .tb-bar {
    opacity: 1;
    pointer-events: auto;
    transform: none;
}

.tb-spacer { width: 4px; }

.tb-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 26px;
    padding: 0 10px;
    border: 1px solid var(--wb-border, #E5E7EB);
    border-radius: 7px;
    background: var(--wb-bg-panel, #fff);
    color: var(--wb-text-muted, #6B7280);
    font-size: 11.5px;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    transition: all .15s;
}
.tb-chip:hover {
    color: var(--wb-accent, #3B82F6);
    border-color: var(--wb-accent, #3B82F6);
    background: color-mix(in srgb, var(--wb-accent, #3B82F6) 6%, var(--wb-bg-panel, #fff));
}

.tb-ibtn {
    height: 26px;
    padding: 0 9px;
    border: 1px solid var(--wb-border, #E5E7EB);
    border-radius: 7px;
    background: var(--wb-bg-panel, #fff);
    color: var(--wb-text-muted, #6B7280);
    font-size: 11.5px;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    transition: all .15s;
}
.tb-ibtn:hover {
    color: var(--wb-text-main, #1F2937);
    border-color: var(--wb-accent, #3B82F6);
}

.tb-apply {
    color: #fff;
    background: var(--wb-accent, #3B82F6);
    border-color: var(--wb-accent, #3B82F6);
}
.tb-apply:hover {
    background: #2563EB;
}

/* ============================================================
 * 类型选择菜单
 * ============================================================ */
.tb-menu {
    position: absolute;
    top: 30px;
    right: 0;
    width: 210px;
    max-height: 340px;
    overflow-y: auto;
    padding: 5px;
    background: var(--wb-bg-panel, #fff);
    border: 1px solid var(--wb-border, #E5E7EB);
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0,0,0,.14), 0 2px 8px rgba(0,0,0,.06);
    z-index: 20;
}
.tb-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 10px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--wb-text-main, #1F2937);
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    transition: background .12s;
}
.tb-menu-item small {
    margin-left: auto;
    color: var(--wb-text-light, #9CA3AF);
    font-size: 10.5px;
    font-family: "IBM Plex Mono", monospace;
}
.tb-menu-item:hover { background: var(--wb-bg-body, #F3F4F6); }
.tb-menu-item.is-cur { color: var(--wb-accent, #3B82F6); font-weight: 600; }

/* ============================================================
 * 块级右键菜单
 * ============================================================ */
.tb-ctx-menu {
    position: fixed;
    z-index: 10000;
    min-width: 168px;
    padding: 5px;
    background: var(--wb-bg-panel, #fff);
    border: 1px solid var(--wb-border, #E5E7EB);
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0,0,0,.14), 0 2px 8px rgba(0,0,0,.06);
}
.tb-ctx-item {
    display: block;
    width: 100%;
    padding: 7px 12px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--wb-text-main, #1F2937);
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    transition: background .12s;
}
.tb-ctx-item:hover {
    background: var(--wb-bg-body, #F3F4F6);
}
.tb-ctx-item.is-danger {
    color: #DC2626;
}
.tb-ctx-item.is-danger:hover {
    background: rgba(220, 38, 38, 0.06);
}
.tb-ctx-sep {
    height: 1px;
    margin: 4px 6px;
    background: var(--wb-border, #E5E7EB);
}

/* ============================================================
 * 源码编辑视图
 * ============================================================ */
.tb-source { padding: 4px 16px 12px; }

.tb-source-ta {
    width: 100%;
    min-height: 100px;
    padding: 12px;
    border: 1px solid var(--wb-border, #E5E7EB);
    border-radius: 8px;
    background: var(--wb-bg-panel, #fff);
    color: var(--wb-text-main, #1F2937);
    font-family: "JetBrains Mono", "IBM Plex Mono", ui-monospace, monospace;
    font-size: 12.5px;
    line-height: 1.65;
    resize: vertical;
    box-sizing: border-box;
    outline: none;
    transition: border-color .15s;
}
.tb-source-ta:focus {
    border-color: var(--wb-accent, #3B82F6);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--wb-accent, #3B82F6) 12%, transparent);
}

.tb-source-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}
.tb-source-hint {
    color: var(--wb-text-light, #9CA3AF);
    font-size: 11px;
}

/* 错误 / 原始 / 加载 */
.tb-err {
    color: #DC2626;
    font-size: 12.5px;
    padding: 8px 12px;
    background: rgba(220,38,38,.06);
    border-radius: 6px;
    border-left: 3px solid #DC2626;
}
.tb-raw {
    margin: 8px 0 0;
    padding: 10px 12px;
    background: var(--wb-bg-body, #F3F4F6);
    border-radius: 8px;
    font-family: "JetBrains Mono", "IBM Plex Mono", monospace;
    font-size: 12px;
    white-space: pre-wrap;
    color: var(--wb-text-muted, #6B7280);
    line-height: 1.6;
}
.tb-note {
    color: var(--wb-text-muted, #6B7280);
    font-size: 12.5px;
    margin-bottom: 6px;
}
.tb-loading {
    color: var(--wb-text-light, #9CA3AF);
    font-size: 13px;
    padding: 20px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.tb-loading::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid var(--wb-border, #E5E7EB);
    border-top-color: var(--wb-accent, #3B82F6);
    border-radius: 50%;
    animation: tbSpin .6s linear infinite;
}
@keyframes tbSpin { to { transform: rotate(360deg); } }

/* ============================================================
 * Quiz 测验
 * ============================================================ */
.aiua-quiz-q {
    margin: 8px 0;
    padding: 14px 16px;
    background: var(--wb-bg-body, #F9FAFB);
    border-radius: 10px;
    border: 1px solid var(--wb-border, #E5E7EB);
}
.aiua-quiz-title {
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--wb-text-main, #1F2937);
    line-height: 1.5;
}
.aiua-quiz-opts {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.aiua-quiz-opt {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1.5px solid var(--wb-border, #E5E7EB);
    border-radius: 8px;
    cursor: pointer;
    background: var(--wb-bg-panel, #fff);
    transition: all .15s;
    font-size: 13.5px;
    color: var(--wb-text-main, #1F2937);
}
.aiua-quiz-opt:hover {
    border-color: var(--wb-accent, #3B82F6);
    background: color-mix(in srgb, var(--wb-accent, #3B82F6) 4%, var(--wb-bg-panel, #fff));
}
.aiua-quiz-opt input { pointer-events: none; accent-color: var(--wb-accent, #3B82F6); }

/* 正确答案：绿色，优先级高于选中态 */
.aiua-quiz-opt.is-correct {
    border-color: #10B981 !important;
    background: rgba(16, 185, 129, 0.12) !important;
    color: #065F46;
}
/* 选错：红色 */
.aiua-quiz-opt.is-wrong {
    border-color: #EF4444 !important;
    background: rgba(239, 68, 68, 0.08) !important;
    color: #991B1B;
}
.aiua-quiz-opt.is-selected { font-weight: 600; }
.aiua-quiz-opt.is-locked { cursor: default; pointer-events: none; }
.aiua-quiz-opt.is-locked:hover { border-color: inherit; background: inherit; }

.aiua-quiz-fb {
    margin-top: 10px;
    font-size: 13px;
    font-weight: 500;
    min-height: 1em;
    padding: 6px 0;
}
.aiua-quiz-fb.is-correct { color: #059669; }
.aiua-quiz-fb.is-wrong { color: #DC2626; }

/* ============================================================
 * Flashcards 闪卡（网格模式）
 * ============================================================ */
.aiua-fc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}
.aiua-fc-item {
    perspective: 900px;
    min-height: 120px;
    cursor: pointer;
    outline: none;
    border-radius: 10px;
}
.aiua-fc-item:focus-visible {
    box-shadow: 0 0 0 2px var(--wb-accent, #3B82F6);
}
.aiua-fc-inner {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 120px;
    transform-style: preserve-3d;
    transition: transform .5s cubic-bezier(.4,0,.2,1);
}
.aiua-fc-item.is-flipped .aiua-fc-inner { transform: rotateY(180deg); }
.aiua-fc-front,
.aiua-fc-back {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    border-radius: 10px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.55;
    backface-visibility: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,.07);
    word-break: break-word;
}
.aiua-fc-front {
    background: linear-gradient(135deg, #DBEAFE 0%, #93C5FD 100%);
    color: #1E3A8A;
}
.aiua-fc-back {
    background: linear-gradient(135deg, #FEF3C7 0%, #FCD34D 100%);
    color: #78350F;
    transform: rotateY(180deg);
}
.aiua-fc-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.aiua-fc-meta {
    font-size: 12px;
    color: var(--wb-text-muted, #6B7280);
    display: flex;
    align-items: center;
    gap: 6px;
}
.aiua-fc-btn {
    padding: 7px 16px;
    border: 1px solid var(--wb-border, #E5E7EB);
    background: var(--wb-bg-panel, #fff);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--wb-text-main, #1F2937);
    transition: all .15s;
}
.aiua-fc-btn:hover {
    border-color: var(--wb-accent, #3B82F6);
    color: var(--wb-accent, #3B82F6);
}

/* ============================================================
 * Chart 图表
 * ============================================================ */
.aiua-chart-wrap {
    position: relative;
    height: 300px;
    padding: 8px;
}

/* ============================================================
 * Timeline 时间线
 * ============================================================ */
.aiua-tl {
    list-style: none;
    margin: 0;
    padding: 4px 0 4px 20px;
    border-left: 2.5px solid var(--wb-accent, #3B82F6);
}
.aiua-tl-item {
    position: relative;
    padding: 10px 0 10px 16px;
}
.aiua-tl-item + .aiua-tl-item {
    border-top: 1px dashed color-mix(in srgb, var(--wb-border, #E5E7EB) 60%, transparent);
}
.aiua-tl-dot {
    position: absolute;
    left: -26px;
    top: 16px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--wb-accent, #3B82F6);
    box-shadow: 0 0 0 3px var(--wb-bg-panel, #fff), 0 0 0 4px color-mix(in srgb, var(--wb-accent, #3B82F6) 30%, transparent);
}
.aiua-tl-time {
    display: inline-block;
    min-width: 80px;
    font-weight: 700;
    color: var(--wb-accent, #3B82F6);
    font-family: "IBM Plex Mono", monospace;
    font-size: 12.5px;
    letter-spacing: .02em;
}
.aiua-tl-label {
    color: var(--wb-text-main, #1F2937);
    font-size: 14px;
    margin-left: 8px;
    line-height: 1.5;
}

/* ============================================================
 * Mindmap 思维导图（垂直树形）
 * ============================================================ */
.aiua-mm { padding: 4px 0; }
.aiua-mm ul {
    list-style: none;
    margin: 0;
    padding-left: 22px;
    position: relative;
}
.aiua-mm > ul { padding-left: 0; }
.aiua-mm li {
    position: relative;
    padding: 4px 0 4px 16px;
}
.aiua-mm li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 16px;
    width: 12px;
    height: 1.5px;
    background: linear-gradient(90deg, var(--wb-accent, #3B82F6), color-mix(in srgb, var(--wb-accent, #3B82F6) 40%, transparent));
}
.aiua-mm li::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 1.5px;
    bottom: 50%;
    background: var(--wb-accent, #3B82F6);
    opacity: .4;
}
.aiua-mm li:last-child::after { bottom: calc(100% - 17px); }

.aiua-mm-node {
    display: inline-block;
    padding: 4px 12px;
    background: color-mix(in srgb, var(--wb-accent, #3B82F6) 8%, var(--wb-bg-body, #F9FAFB));
    border: 1.5px solid color-mix(in srgb, var(--wb-accent, #3B82F6) 25%, var(--wb-border, #E5E7EB));
    border-radius: 8px;
    font-size: 13px;
    color: var(--wb-text-main, #1F2937);
    transition: all .15s;
}
.aiua-mm > ul > li > .aiua-mm-node {
    background: var(--wb-accent, #3B82F6);
    color: #fff;
    border-color: var(--wb-accent, #3B82F6);
    font-weight: 600;
}

/* ============================================================
 * SWOT 分析
 * ============================================================ */
.aiua-swot {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.aiua-swot-cell {
    padding: 14px;
    border-radius: 10px;
    border-top: 3px solid var(--c, #3B82F6);
    background: color-mix(in srgb, var(--c, #3B82F6) 4%, var(--wb-bg-body, #F9FAFB));
    transition: transform .15s;
}
.aiua-swot-cell:hover { transform: translateY(-1px); }
.aiua-swot-h {
    font-weight: 700;
    color: var(--c, #3B82F6);
    margin-bottom: 8px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.aiua-swot-emoji { font-size: 20px; line-height: 1; }
.aiua-swot-h small {
    font-weight: 400;
    color: var(--wb-text-muted, #6B7280);
    font-size: 11px;
}
.aiua-swot-cell ul {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 13px;
    color: var(--wb-text-main, #1F2937);
    line-height: 1.6;
}
.aiua-swot-cell li {
    margin: 3px 0;
    padding-left: 16px;
    position: relative;
}
.aiua-swot-cell li::before {
    content: '•';
    position: absolute;
    left: 2px;
    color: var(--c, #3B82F6);
    font-weight: 700;
}

/* ============================================================
 * BMC 商业画布
 * ============================================================ */
.aiua-bmc {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: auto auto auto;
    gap: 5px;
    font-size: 12px;
}
.aiua-bmc-cell {
    padding: 10px;
    border: 1px solid var(--wb-border, #E5E7EB);
    border-radius: 8px;
    background: var(--wb-bg-body, #F9FAFB);
    min-height: 64px;
    transition: background .15s;
}
.aiua-bmc-cell:hover {
    background: color-mix(in srgb, var(--wb-accent, #3B82F6) 4%, var(--wb-bg-body, #F9FAFB));
}
.aiua-bmc-cell[data-bmc="KP"] { grid-column: 1; grid-row: 1 / span 2; }
.aiua-bmc-cell[data-bmc="KA"] { grid-column: 2; grid-row: 1; }
.aiua-bmc-cell[data-bmc="VP"] { grid-column: 3; grid-row: 1 / span 2; background: color-mix(in srgb, var(--wb-accent, #3B82F6) 6%, var(--wb-bg-body, #F9FAFB)); }
.aiua-bmc-cell[data-bmc="CR"] { grid-column: 4; grid-row: 1; }
.aiua-bmc-cell[data-bmc="CS"] { grid-column: 5; grid-row: 1 / span 2; }
.aiua-bmc-cell[data-bmc="KR"] { grid-column: 2; grid-row: 2; }
.aiua-bmc-cell[data-bmc="CH"] { grid-column: 4; grid-row: 2; }
.aiua-bmc-cell[data-bmc="CO"] { grid-column: 1 / span 2; grid-row: 3; background: rgba(239, 68, 68, 0.05); }
.aiua-bmc-cell[data-bmc="RE"] { grid-column: 3 / span 3; grid-row: 3; background: rgba(16, 185, 129, 0.05); }

.aiua-bmc-h {
    font-weight: 700;
    color: var(--wb-text-muted, #6B7280);
    margin-bottom: 6px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.aiua-bmc-b {
    color: var(--wb-text-main, #1F2937);
    line-height: 1.5;
}

/* ============================================================
 * MECE 拆解
 * ============================================================ */
.aiua-mece { padding: 4px 0; }
.aiua-mece-l {
    list-style: none;
    margin: 0;
    padding-left: 28px;
}
.aiua-mece-l > li {
    position: relative;
    padding: 5px 0;
}
.aiua-mece-l > li::before {
    content: '';
    position: absolute;
    left: -18px;
    top: 19px;
    width: 14px;
    height: 2px;
    background: var(--wb-accent, #3B82F6);
    border-radius: 1px;
}
.aiua-mece-node {
    display: inline-block;
    padding: 5px 14px;
    background: var(--wb-bg-panel, #fff);
    border: 2px solid var(--wb-accent, #3B82F6);
    border-radius: 8px;
    font-size: 13px;
    color: var(--wb-text-main, #1F2937);
    font-weight: 500;
    transition: all .15s;
}
.aiua-mece-node:hover { transform: translateX(2px); }
.aiua-mece-l-0 > li > .aiua-mece-node {
    background: var(--wb-accent, #3B82F6);
    color: #fff;
    border-color: var(--wb-accent, #3B82F6);
    font-weight: 600;
}
.aiua-mece-l-1 > li > .aiua-mece-node { border-color: #8B5CF6; }
.aiua-mece-l-2 > li > .aiua-mece-node { border-color: var(--wb-text-muted, #6B7280); border-width: 1.5px; }

/* ============================================================
 * Itinerary 行程
 * ============================================================ */
.aiua-itin-day { margin: 12px 0; }
.aiua-itin-h {
    font-weight: 700;
    color: var(--wb-accent, #3B82F6);
    padding: 8px 14px;
    background: color-mix(in srgb, var(--wb-accent, #3B82F6) 8%, var(--wb-bg-body, #F9FAFB));
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 14px;
}
.aiua-itin-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border-left: 2.5px solid var(--wb-accent, #3B82F6);
    margin-left: 16px;
}
.aiua-itin-list li {
    padding: 6px 0 6px 14px;
    display: flex;
    gap: 12px;
    align-items: baseline;
    font-size: 13.5px;
    color: var(--wb-text-main, #1F2937);
    transition: background .12s;
}
.aiua-itin-list li:hover {
    background: color-mix(in srgb, var(--wb-bg-body, #F9FAFB) 80%, transparent);
}
.aiua-itin-t {
    font-family: "JetBrains Mono", "IBM Plex Mono", monospace;
    font-size: 12px;
    color: var(--wb-accent, #3B82F6);
    min-width: 54px;
    font-weight: 700;
    flex-shrink: 0;
}

/* ============================================================
 * Tree 目录/文件树
 * ============================================================ */
.aiua-tree-pre {
    margin: 0;
    padding: 14px 16px;
    background: var(--wb-bg-body, #F9FAFB);
    border-radius: 10px;
    font-family: "JetBrains Mono", "IBM Plex Mono", ui-monospace, monospace;
    font-size: 12.5px;
    line-height: 1.7;
    color: var(--wb-text-main, #1F2937);
    overflow-x: auto;
    border: 1px solid var(--wb-border, #E5E7EB);
}
.aiua-tree ul, .aiua-tree-l {
    list-style: none;
    margin: 0;
    padding-left: 20px;
}
.aiua-tree > .aiua-tree-l { padding-left: 4px; }
.aiua-tree li {
    position: relative;
    padding: 3px 0;
}
.aiua-tree-node {
    font-size: 13.5px;
    color: var(--wb-text-main, #1F2937);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.aiua-tree-l .aiua-tree-l {
    border-left: 1px dashed color-mix(in srgb, var(--wb-border, #D1D5DB) 70%, transparent);
    margin-left: 8px;
}

/* ============================================================
 * Checklist 清单
 * ============================================================ */
.aiua-ckl-bar {
    height: 6px;
    border-radius: 4px;
    background: var(--wb-bg-body, #E5E7EB);
    overflow: hidden;
    margin-bottom: 4px;
}
.aiua-ckl-fill {
    height: 100%;
    background: linear-gradient(90deg, #10B981, #34D399);
    border-radius: 4px;
    transition: width .3s cubic-bezier(.4,0,.2,1);
}
.aiua-ckl-meta {
    font-size: 12px;
    color: var(--wb-text-muted, #6B7280);
    margin: 4px 0 10px;
}
.aiua-ckl {
    list-style: none;
    margin: 0;
    padding: 0;
}
.aiua-ckl-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background .12s;
}
.aiua-ckl-item:hover { background: var(--wb-bg-body, #F3F4F6); }
.aiua-ckl-box {
    flex: none;
    width: 20px;
    height: 20px;
    margin-top: 1px;
    border: 2px solid var(--wb-border, #D1D5DB);
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    transition: all .2s;
}
.aiua-ckl-item.is-done .aiua-ckl-box {
    background: #10B981;
    border-color: #10B981;
}
.aiua-ckl-text {
    font-size: 14px;
    color: var(--wb-text-main, #1F2937);
    line-height: 1.5;
}
.aiua-ckl-item.is-done .aiua-ckl-text {
    text-decoration: line-through;
    color: var(--wb-text-light, #9CA3AF);
}

/* ============================================================
 * Mermaid 图示
 * ============================================================ */
.aiua-mermaid {
    display: flex;
    justify-content: center;
    padding: 12px 0;
    overflow: auto;
}
.aiua-mermaid svg {
    max-width: 100%;
    height: auto;
}

/* ============================================================
 * Math 公式
 * ============================================================ */
.aiua-math { padding: 8px 0; }
.aiua-math-row {
    padding: 8px 0;
    overflow-x: auto;
    text-align: center;
}

/* ============================================================
 * Table 增强表格
 * ============================================================ */
.aiua-table { overflow-x: auto; }
.aiua-table table {
    border-collapse: collapse;
    width: 100%;
    font-size: 13.5px;
}
.aiua-table th, .aiua-table td {
    border: 1px solid var(--wb-border, #E5E7EB);
    padding: 8px 12px;
    text-align: left;
}
.aiua-table thead th {
    background: var(--wb-bg-body, #F3F4F6);
    font-weight: 600;
    color: var(--wb-text-main, #1F2937);
    font-size: 12.5px;
    text-transform: none;
}
.aiua-table tbody tr:hover { background: color-mix(in srgb, var(--wb-bg-body, #F3F4F6) 50%, transparent); }
.aiua-table tbody tr:nth-child(even) { background: color-mix(in srgb, var(--wb-bg-body, #FAFBFC) 30%, transparent); }

/* ============================================================
 * SVG 插画
 * ============================================================ */
.aiua-svg {
    display: flex;
    justify-content: center;
    padding: 12px;
    overflow: auto;
}
.aiua-svg svg {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

/* ============================================================
 * Code 可执行代码
 * ============================================================ */
.aiua-code { border-radius: 10px; overflow: hidden; }
.aiua-code-src {
    margin: 0;
    padding: 14px 16px;
    background: #1e1e2e;
    color: #cdd6f4;
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 13px;
    line-height: 1.65;
    overflow: auto;
    tab-size: 4;
}
.aiua-code-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: #181825;
}
.aiua-run-btn {
    background: #40a02b;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 5px 14px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.aiua-run-btn:hover { background: #369726; }
.aiua-run-btn:disabled { opacity: .6; cursor: wait; }
.aiua-code-lang {
    font-size: 11px;
    color: #7f849c;
}
.aiua-code-out {
    margin: 0;
    padding: 12px 16px;
    background: #11111b;
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 12.5px;
    line-height: 1.65;
    border-top: 1px solid rgba(255,255,255,.06);
}
.aiua-code-line {
    color: #cdd6f4;
    white-space: pre-wrap;
}
.aiua-code-line.is-err { color: #f38ba8; }
.aiua-code-line.is-result { color: #a6e3a1; }
.aiua-code-empty { color: #7f849c; }

/* ============================================================
 * Legacy compat (.aiua-block 旧壳 + .aiua-em)
 * ============================================================ */
.aiua-block {
    margin: 14px 0;
    padding: 12px 14px;
    border: 1px solid var(--wb-border, #E5E7EB);
    border-radius: 10px;
    background: var(--wb-bg-panel, #fff);
    font-size: 13px;
    line-height: 1.55;
    color: var(--wb-text-main, #1F2937);
}
.aiua-head {
    font-weight: 600;
    color: var(--wb-text-main, #1F2937);
    margin-bottom: 10px;
    font-size: 13px;
}
.aiua-raw {
    margin: 0;
    padding: 8px;
    background: var(--wb-bg-body, #F9FAFB);
    border-radius: 6px;
    font-family: "IBM Plex Mono", monospace;
    font-size: 11px;
    white-space: pre-wrap;
    color: var(--wb-text-muted, #6B7280);
}
.aiua-err { color: #DC2626; font-size: 12px; padding: 4px 0; }
.aiua-em { color: var(--wb-text-light, #9CA3AF); font-style: italic; }

/* ============================================================
 * Kanban 看板
 * ============================================================ */
.aiua-kb {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.aiua-kb-col {
    background: var(--wb-bg-body, #F9FAFB);
    border: 1px solid var(--wb-border, #E5E7EB);
    border-radius: 10px;
    min-height: 120px;
}
.aiua-kb-h {
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 700;
    color: var(--wb-text-main, #1F2937);
    border-bottom: 1px solid var(--wb-border, #E5E7EB);
}
.aiua-kb-list {
    padding: 8px;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: background .15s;
}
.aiua-kb-list.is-over {
    background: color-mix(in srgb, var(--wb-accent, #3B82F6) 6%, transparent);
}
.aiua-kb-card {
    padding: 8px 10px;
    background: var(--wb-bg-panel, #fff);
    border: 1px solid var(--wb-border, #E5E7EB);
    border-radius: 8px;
    font-size: 13px;
    color: var(--wb-text-main, #1F2937);
    cursor: grab;
    transition: box-shadow .15s, transform .15s;
}
.aiua-kb-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.aiua-kb-card.is-dragging { opacity: .5; cursor: grabbing; }

/* ============================================================
 * Callout 提示框
 * ============================================================ */
.aiua-callout {
    padding: 12px 14px;
    border-radius: 10px;
    border-left: 4px solid;
    font-size: 13.5px;
    line-height: 1.6;
}
.aiua-callout-h {
    font-weight: 700;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.aiua-callout-b { color: var(--wb-text-main, #1F2937); }
.aiua-callout-info { border-color: #3B82F6; background: rgba(59,130,246,.08); }
.aiua-callout-info .aiua-callout-h { color: #1D4ED8; }
.aiua-callout-warning { border-color: #F59E0B; background: rgba(245,158,11,.1); }
.aiua-callout-warning .aiua-callout-h { color: #B45309; }
.aiua-callout-success { border-color: #10B981; background: rgba(16,185,129,.08); }
.aiua-callout-success .aiua-callout-h { color: #047857; }
.aiua-callout-danger { border-color: #EF4444; background: rgba(239,68,68,.08); }
.aiua-callout-danger .aiua-callout-h { color: #B91C1C; }
.aiua-callout-tip { border-color: #8B5CF6; background: rgba(139,92,246,.08); }
.aiua-callout-tip .aiua-callout-h { color: #6D28D9; }
.aiua-callout-note { border-color: #6B7280; background: rgba(107,114,128,.08); }
.aiua-callout-note .aiua-callout-h { color: #374151; }

/* ============================================================
 * Compare 对比表
 * ============================================================ */
.aiua-compare { overflow-x: auto; }
.aiua-compare table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.aiua-compare th, .aiua-compare td {
    border: 1px solid var(--wb-border, #E5E7EB);
    padding: 8px 12px;
    text-align: left;
}
.aiua-compare thead th {
    background: var(--wb-bg-body, #F3F4F6);
    font-weight: 600;
}
.aiua-compare tbody tr:nth-child(even) { background: color-mix(in srgb, var(--wb-bg-body, #FAFBFC) 40%, transparent); }
.aiua-compare tbody tr:hover { background: color-mix(in srgb, var(--wb-accent, #3B82F6) 4%, transparent); }

/* ============================================================
 * Rating 评分
 * ============================================================ */
.aiua-rating { display: flex; flex-direction: column; gap: 10px; }
.aiua-rating-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
}
.aiua-rating-label {
    min-width: 80px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--wb-text-main, #1F2937);
}
.aiua-rating-stars {
    color: #F59E0B;
    font-size: 16px;
    letter-spacing: 2px;
}
.aiua-rating-num {
    font-size: 12px;
    color: var(--wb-text-muted, #6B7280);
    font-family: "IBM Plex Mono", monospace;
}

/* ============================================================
 * Progress 进度
 * ============================================================ */
.aiua-progress { display: flex; flex-direction: column; gap: 12px; }
.aiua-progress-row { display: flex; flex-direction: column; gap: 4px; }
.aiua-progress-meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 13px;
}
.aiua-progress-label { font-weight: 500; color: var(--wb-text-main, #1F2937); }
.aiua-progress-pct {
    font-family: "IBM Plex Mono", monospace;
    font-size: 12px;
    color: var(--wb-accent, #3B82F6);
    font-weight: 600;
}
.aiua-progress-bar {
    height: 8px;
    border-radius: 4px;
    background: var(--wb-bg-body, #E5E7EB);
    overflow: hidden;
}
.aiua-progress-fill {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--wb-accent, #3B82F6), #60A5FA);
    transition: width .4s cubic-bezier(.4,0,.2,1);
}

/* ============================================================
 * 可视化编辑：可编辑区域 / 添加 / 删除 / 排序
 * ============================================================ */
.tb-editable-target {
    cursor: text;
    border-radius: 4px;
    transition: background .15s, box-shadow .15s;
}
.tb-editable-target:hover {
    background: color-mix(in srgb, var(--wb-accent, #3B82F6) 8%, transparent);
    box-shadow: 0 1px 0 0 color-mix(in srgb, var(--wb-accent, #3B82F6) 35%, transparent);
}
.tb-editable-target[contenteditable="true"] {
    outline: none;
    background: color-mix(in srgb, var(--wb-accent, #3B82F6) 10%, var(--wb-bg-panel, #fff));
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--wb-accent, #3B82F6) 25%, transparent);
}

.tb-block-add {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 10px;
    padding: 5px 12px;
    border: 1px dashed color-mix(in srgb, var(--wb-accent, #3B82F6) 40%, var(--wb-border, #E5E7EB));
    border-radius: 7px;
    background: transparent;
    color: var(--wb-accent, #3B82F6);
    font-size: 12.5px;
    cursor: pointer;
    transition: all .15s;
}
.tb-block-add:hover {
    background: color-mix(in srgb, var(--wb-accent, #3B82F6) 8%, transparent);
    border-style: solid;
}
.tb-block-add-sm {
    margin-top: 6px;
    font-size: 11.5px;
    padding: 3px 10px;
}

.tb-block-del {
    flex: none;
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    border-radius: 5px;
    background: transparent;
    color: var(--wb-text-light, #9CA3AF);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s, background .15s, color .15s;
}
.aiua-ckl-item:hover .tb-block-del,
.aiua-tl-item:hover .tb-block-del,
.aiua-swot-cell li:hover .tb-block-del,
.aiua-kb-card:hover .tb-block-del {
    opacity: 1;
}
.tb-block-del:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #DC2626;
}

.tb-block-sort {
    display: inline-flex;
    flex-direction: column;
    gap: 1px;
    margin-right: 6px;
    vertical-align: middle;
    opacity: 0;
    transition: opacity .15s;
}
.aiua-tl-item:hover .tb-block-sort { opacity: 1; }
.tb-block-sort-btn {
    width: 18px;
    height: 14px;
    padding: 0;
    border: 1px solid var(--wb-border, #E5E7EB);
    border-radius: 3px;
    background: var(--wb-bg-panel, #fff);
    color: var(--wb-text-muted, #6B7280);
    font-size: 9px;
    line-height: 1;
    cursor: pointer;
}
.tb-block-sort-btn:hover {
    border-color: var(--wb-accent, #3B82F6);
    color: var(--wb-accent, #3B82F6);
}

/* Timeline 编辑布局 */
.aiua-tl-item {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px;
}
.aiua-tl-item .tb-block-del { margin-left: auto; align-self: center; }

/* Checklist 编辑布局 */
.aiua-ckl-item {
    position: relative;
}
.aiua-ckl-item .tb-block-del { margin-left: auto; }
.aiua-ckl-box { cursor: pointer; }

/* SWOT 条目编辑 */
.aiua-swot-cell li {
    display: flex;
    align-items: center;
    gap: 4px;
}
.aiua-swot-text { flex: 1; min-width: 0; }

/* Kanban 卡片编辑 */
.aiua-kb-card {
    display: flex;
    align-items: flex-start;
    gap: 4px;
}
.aiua-kb-card-text { flex: 1; min-width: 0; }
.aiua-kb-col .tb-block-add-sm {
    margin: 6px 8px 8px;
    display: block;
    width: calc(100% - 16px);
    text-align: center;
}

/* Rating 可点击星星 */
.aiua-rating-star {
    cursor: pointer;
    transition: transform .1s, color .15s;
}
.aiua-rating-star:hover { transform: scale(1.15); }
.aiua-rating-star.is-on { color: #F59E0B; }

/* Progress 可拖拽进度条 */
.aiua-progress-bar.is-editable {
    cursor: ew-resize;
    height: 10px;
}
.aiua-progress-bar.is-editable .aiua-progress-fill {
    transition: width .08s linear;
}
.aiua-progress-bar.is-editable:hover {
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--wb-accent, #3B82F6) 15%, transparent);
}

/* ============================================================
 * Dark mode
 * ============================================================ */
[data-mode="dark"] .tb-block:hover {
    background: rgba(255,255,255,.03);
}
[data-mode="dark"] .tb-block.is-source {
    background: rgba(59,130,246,.05);
}
[data-mode="dark"] .aiua-quiz-q,
[data-mode="dark"] .aiua-bmc-cell,
[data-mode="dark"] .aiua-swot-cell,
[data-mode="dark"] .aiua-tree-pre {
    background: rgba(255,255,255,.04);
}
[data-mode="dark"] .aiua-quiz-opt {
    background: rgba(255,255,255,.03);
    border-color: rgba(255,255,255,.08);
}
[data-mode="dark"] .aiua-quiz-opt:hover {
    border-color: var(--wb-accent, #3B82F6);
}
[data-mode="dark"] .aiua-mm-node,
[data-mode="dark"] .aiua-mece-node {
    background: rgba(255,255,255,.06);
}
[data-mode="dark"] .aiua-fc-front {
    background: linear-gradient(135deg, #1E3A8A 0%, #1E40AF 100%);
    color: #DBEAFE;
}
[data-mode="dark"] .aiua-fc-back {
    background: linear-gradient(135deg, #78350F 0%, #92400E 100%);
    color: #FEF3C7;
}
[data-mode="dark"] .aiua-kb-col,
[data-mode="dark"] .aiua-kb-card,
[data-mode="dark"] .aiua-callout {
    background: rgba(255,255,255,.04);
}
[data-mode="dark"] .aiua-kb-card {
    border-color: rgba(255,255,255,.08);
}
[data-mode="dark"] .aiua-compare th {
    background: rgba(255,255,255,.06);
}
[data-mode="dark"] .aiua-progress-bar {
    background: rgba(255,255,255,.08);
}
[data-mode="dark"] .aiua-quiz-opt.is-correct {
    color: #6EE7B7;
    background: rgba(16, 185, 129, 0.15) !important;
}
[data-mode="dark"] .aiua-quiz-opt.is-wrong {
    color: #FCA5A5;
    background: rgba(239, 68, 68, 0.12) !important;
}
[data-mode="dark"] .aiua-block {
    background: rgba(255,255,255,.03);
    border-color: rgba(255,255,255,.08);
}
[data-mode="dark"] .tb-chip,
[data-mode="dark"] .tb-ibtn {
    background: rgba(255,255,255,.06);
    border-color: rgba(255,255,255,.1);
    color: var(--wb-text-muted, #9CA3AF);
}
[data-mode="dark"] .tb-menu,
[data-mode="dark"] .tb-ctx-menu {
    background: #1e2026;
    border-color: rgba(255,255,255,.1);
}
[data-mode="dark"] .tb-ctx-item:hover {
    background: rgba(255,255,255,.06);
}
[data-mode="dark"] .tb-ctx-sep {
    background: rgba(255,255,255,.1);
}
[data-mode="dark"] .tb-source-ta {
    background: rgba(255,255,255,.04);
    border-color: rgba(255,255,255,.1);
}
[data-mode="dark"] .aiua-ckl-box {
    border-color: rgba(255,255,255,.15);
}
