/* HK100 备赛页 · 右侧训练日志抽屉（沿用 base.html :root 设计 token） */

/* ---------------------------------------------------------- 悬浮按钮 */
.coach-fab {
    position: fixed; right: 20px; bottom: 20px; z-index: 40;
    display: inline-flex; align-items: center; gap: 8px;
    height: 44px; padding: 0 18px 0 14px;
    border: 1px solid var(--accent); border-radius: 22px;
    background: var(--accent); color: #fff;
    font: 600 14px/1 var(--font); letter-spacing: .02em; cursor: pointer; text-decoration: none;
    box-shadow: 0 6px 18px rgba(36, 40, 36, .16);
    transition: transform 160ms ease, background-color 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}
.coach-fab:hover { background: var(--accent-soft); transform: translateY(-1px); box-shadow: 0 8px 22px rgba(36, 40, 36, .2); color: #fff; text-decoration: none; }
.coach-fab:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.coach-fab svg { width: 18px; height: 18px; flex: 0 0 auto; }
.coach-fab .dot { width: 7px; height: 7px; border-radius: 50%; background: #9fd3b6; margin-left: 2px; animation: coach-pulse 2.4s ease-in-out infinite; }
.coach-fab.locked { background: var(--surface); color: var(--accent); box-shadow: 0 4px 14px rgba(36, 40, 36, .08); }
.coach-fab.locked:hover { background: #eef3f0; color: var(--accent); }
.coach-fab.locked .dot { display: none; }
.coach-fab[hidden] { display: none; }
body.coach-open .coach-fab { opacity: 0; pointer-events: none; }
@keyframes coach-pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }

/* ---------------------------------------------------------- 遮罩与抽屉 */
.coach-mask {
    position: fixed; inset: 0; z-index: 60; background: rgba(36, 40, 36, .28);
    opacity: 0; pointer-events: none; transition: opacity 150ms ease;
}
body.coach-open .coach-mask { opacity: 1; pointer-events: auto; }
body.coach-open { overflow: hidden; }
.coach-drawer {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 61;
    width: var(--cd-width, min(560px, calc(100vw - 80px))); max-width: 100vw; display: flex; flex-direction: column;
    background: var(--bg); border-left: 1px solid var(--line); font-family: var(--font);
    transform: translateX(100%); visibility: hidden;
    transition: transform 220ms cubic-bezier(.2, .7, .2, 1), visibility 0s linear 220ms;
}
body.coach-open .coach-drawer { transform: none; visibility: visible; transition: transform 220ms cubic-bezier(.2, .7, .2, 1); }

/* ---------------------------------------------------------- 头部 */
.cd-head { flex: 0 0 auto; padding: 14px 14px 10px 18px; border-bottom: 1px solid var(--line); background: var(--surface); }
.cd-title-row { display: flex; align-items: center; gap: 10px; }
.cd-mark { width: 26px; height: 26px; flex: 0 0 auto; display: grid; place-items: center; border-radius: var(--radius); background: var(--accent); color: #fff; font-size: 11px; font-weight: 600; letter-spacing: .03em; }
.cd-title { font-size: 16px; font-weight: 600; color: var(--ink); margin: 0; line-height: 1.3; }
.cd-sub { font-size: 12px; color: var(--ink-muted); margin: 0; line-height: 1.45; }
.cd-close {
    margin-left: auto; flex: 0 0 auto; width: 32px; height: 32px; display: grid; place-items: center;
    border: 1px solid transparent; border-radius: var(--radius); background: transparent; color: var(--ink-muted); cursor: pointer;
    transition: border-color 150ms ease, color 150ms ease;
}
.cd-close:hover { border-color: var(--line); color: var(--ink); }
.cd-date { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.cd-date button {
    width: 30px; height: 30px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
    color: var(--ink-muted); cursor: pointer; font-size: 15px; line-height: 1; transition: border-color 150ms ease, color 150ms ease;
}
.cd-date button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.cd-date button:disabled { opacity: .35; cursor: default; }
.cd-date input {
    flex: 1 1 auto; min-width: 0; height: 30px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
    padding: 0 10px; font: 500 13px var(--font); color: var(--ink); font-variant-numeric: tabular-nums;
}
.cd-date input:focus { outline: none; border-color: var(--accent); }
.cd-plan { margin-top: 8px; font-size: 12px; color: var(--ink-muted); line-height: 1.55; }
.cd-plan b { color: var(--ink); font-weight: 600; }
.cd-today { font-size: 11px; color: var(--accent); border: 1px solid var(--accent); border-radius: 2px; padding: 0 5px; white-space: nowrap; }

/* ---------------------------------------------------------- 消息流 */
.cd-body { flex: 1 1 auto; overflow-y: auto; padding: 16px 16px 8px; overscroll-behavior: contain; }
.cd-empty { color: var(--ink-muted); font-size: 13px; line-height: 1.7; padding: 6px 2px; }
.cd-empty h4 { font-size: 14px; font-weight: 600; color: var(--ink); margin: 0 0 .4rem; }
.cd-chips { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.cd-chip {
    text-align: left; font: 13px/1.5 var(--font); color: var(--ink); background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; cursor: pointer;
    transition: border-color 150ms ease, background-color 150ms ease, transform 120ms ease;
}
.cd-chip:hover { border-color: var(--accent); background: #f7faf8; transform: translateX(2px); }
.cd-chip span { color: var(--ink-muted); }
.cd-msg { display: flex; flex-direction: column; margin-bottom: 14px; animation: coach-in 220ms ease both; }
.cd-msg.user { align-items: flex-end; }
.cd-bubble { max-width: 92%; font-size: 14px; line-height: 1.7; color: var(--ink); word-break: break-word; }
.cd-msg.user .cd-bubble { background: #eef3f0; border: 1px solid #d7e3dc; border-radius: 10px 10px 2px 10px; padding: 9px 12px; white-space: pre-wrap; }
.cd-msg.assistant .cd-bubble { background: var(--surface); border: 1px solid var(--line); border-radius: 2px 10px 10px 10px; padding: 10px 14px; max-width: 100%; }
.cd-msg.error .cd-bubble { border-color: var(--danger); color: var(--danger); background: #fdf7f6; }
.cd-meta { font-size: 11px; color: var(--ink-muted); margin-top: 4px; font-variant-numeric: tabular-nums; display: flex; gap: 8px; align-items: center; }
.cd-retry { font: 12px var(--font); color: var(--danger); background: none; border: 1px solid var(--danger); border-radius: 2px; padding: 0 6px; cursor: pointer; }
.cd-retry:hover { background: var(--danger); color: #fff; }
@keyframes coach-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* 反馈正文的 Markdown 排版 */
.cd-md h3 { font-size: 13px; font-weight: 600; color: var(--accent); margin: .9rem 0 .25rem; letter-spacing: .04em; }
.cd-md h3:first-child { margin-top: 0; }
.cd-md p { margin: 0 0 .5rem; }
.cd-md p:last-child { margin-bottom: 0; }
.cd-md ul, .cd-md ol { margin: 0 0 .5rem; padding-left: 1.15rem; }
.cd-md li { margin: .15rem 0; }
.cd-md li::marker { color: var(--accent); }
.cd-md strong { color: var(--ink); font-weight: 600; }
.cd-md code { font-size: 12.5px; background: #f4f2ec; border-radius: 2px; padding: 0 4px; }
.cd-md .cd-table-wrap { overflow-x: auto; margin: .35rem 0 .7rem; }
.cd-md table { width: 100%; border-collapse: collapse; font-size: 13px; line-height: 1.45; font-variant-numeric: tabular-nums; word-break: normal; }
.cd-md th, .cd-md td { border: 1px solid var(--line); padding: .28rem .55rem; text-align: left; vertical-align: top; white-space: nowrap; }
.cd-md th { font-weight: 600; background: #f4f2ec; color: var(--ink); }
.cd-md td { background: #fff; }
.cd-md .cd-table-wrap:last-child { margin-bottom: 0; }

/* 正在分析 */
.cd-thinking { display: inline-flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-muted); background: var(--surface); border: 1px solid var(--line); border-radius: 2px 10px 10px 10px; padding: 10px 14px; }
.cd-dots { display: inline-flex; gap: 4px; }
.cd-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: coach-bounce 1.2s infinite ease-in-out; }
.cd-dots i:nth-child(2) { animation-delay: .15s; }
.cd-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes coach-bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .35; } 40% { transform: translateY(-4px); opacity: 1; } }

/* ---------------------------------------------------------- 输入区 */
.cd-foot { flex: 0 0 auto; padding: 10px 14px 14px; border-top: 1px solid var(--line); background: var(--surface); }
.cd-input-wrap { display: flex; align-items: flex-end; gap: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); padding: 6px 6px 6px 12px; transition: border-color 150ms ease; }
.cd-input-wrap:focus-within { border-color: var(--accent); }
.cd-add { flex: 0 0 32px; height: 36px; padding: 0; background: transparent; color: var(--accent); border: 1px solid var(--line); border-radius: var(--radius); font: 24px/1 var(--font); cursor: pointer; }
.cd-add:hover:not(:disabled), .cd-add:focus-visible { background: #eef3f0; border-color: var(--accent); }
.cd-add:disabled { opacity: .4; cursor: default; }
.cd-images-preview { display: flex; gap: 10px; padding: 4px 0 10px; overflow-x: auto; }
.cd-images-preview[hidden] { display: none; }
.cd-image-draft { position: relative; flex: 0 0 72px; height: 72px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.cd-image-draft img { width: 100%; height: 100%; object-fit: cover; }
.cd-image-draft > span { font-size: 11px; color: var(--ink-muted); padding: 8px; display: block; }
.cd-image-draft button { position: absolute; right: 0; top: 0; background: var(--surface); border: 1px solid var(--line); width: 24px; height: 24px; line-height: 1; padding: 0; color: var(--ink); border-radius: 3px; }
.cd-message-images { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; white-space: normal; }
.cd-message-images a { display: block; max-width: 100%; }
.cd-message-images img { display: block; width: 140px; max-width: 100%; height: 110px; object-fit: contain; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.cd-image-hint { font-size: 11px; color: var(--ink-muted); margin-top: 5px; }
#coachInput { min-width: 0; }
.cd-input {
    flex: 1 1 auto; border: 0; outline: none; resize: none; background: transparent;
    font: 14px/1.6 var(--font); color: var(--ink); max-height: 9.6em; min-height: 1.6em; padding: 4px 0;
}
.cd-input::placeholder { color: #9a9f99; }
.cd-input:disabled { opacity: .6; }
.cd-send {
    flex: 0 0 auto; width: 36px; height: 36px; border-radius: 7px; border: 0; background: var(--accent); color: #fff;
    display: grid; place-items: center; cursor: pointer; transition: background-color 150ms ease, opacity 150ms ease, transform 120ms ease;
}
.cd-send:hover:not(:disabled) { background: var(--accent-soft); }
.cd-send:active:not(:disabled) { transform: scale(.95); }
.cd-send:disabled { opacity: .35; cursor: default; }
.cd-hint { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-muted); margin-top: 6px; }
.cd-notice { font-size: 12px; color: var(--warn); background: #fbf8f1; border-left: 3px solid var(--warn); padding: 6px 10px; margin-bottom: 8px; border-radius: 0 var(--radius) var(--radius) 0; }

@media (max-width: 768px) {
    .coach-fab { right: 14px; bottom: 14px; height: 42px; padding: 0 15px 0 12px; font-size: 13px; }
    .coach-drawer { width: 100vw !important; border-left: 0; }
    .cd-resizer { display: none; }
    .cd-bubble { max-width: 96%; }
    .cd-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
    .cd-hint span:first-child { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    .coach-drawer, .coach-mask, .cd-msg, .coach-fab .dot, .cd-dots i { transition: none; animation: none; }
}

/* ---------------------------------------------------------- 过程展示：思考 / 工具 / 流式（类 Claude Code） */
.cd-turn { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; animation: coach-in 220ms ease both; }
.cd-status { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-muted); }
.cd-status .cd-dots i { width: 5px; height: 5px; }

.cd-step { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; }
.cd-step > summary {
    list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px;
    padding: 7px 10px; font-size: 12.5px; color: var(--ink-muted); user-select: none;
    transition: background-color 150ms ease;
}
.cd-step > summary::-webkit-details-marker { display: none; }
.cd-step > summary:hover { background: #f7f6f2; }
.cd-step .ic { width: 16px; height: 16px; flex: 0 0 auto; display: grid; place-items: center; color: var(--ink-muted); }
.cd-step .nm { color: var(--ink); font-weight: 500; }
.cd-step .arg { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; color: var(--ink-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1 1 auto; }
.cd-step .chev { margin-left: auto; flex: 0 0 auto; transition: transform 150ms ease; color: #a3a7a2; }
.cd-step[open] > summary .chev { transform: rotate(90deg); }
.cd-step .bd { border-top: 1px solid var(--line); padding: 8px 10px; max-height: 260px; overflow: auto; background: #fcfbf8; }
.cd-step pre { margin: 0; font: 11.5px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; color: #4a4f4a; white-space: pre-wrap; word-break: break-word; }

.cd-step.think .ic { color: var(--info); }
.cd-step.think .bd { font-size: 12.5px; line-height: 1.7; color: var(--ink-muted); white-space: pre-wrap; font-style: normal; }
.cd-step.think.live > summary .nm::after { content: "…"; animation: coach-pulse 1.2s ease-in-out infinite; }

.cd-step.tool .ic { color: var(--accent); }
.cd-step.tool.running { border-color: #cfe0d6; }
.cd-step.tool.running .ic { animation: coach-spin 1s linear infinite; }
.cd-step.tool.error { border-color: var(--danger); }
.cd-step.tool.error .ic { color: var(--danger); }
.cd-step .st { font-size: 11px; padding: 0 6px; border-radius: 2px; flex: 0 0 auto; }
.cd-step.tool.running .st { color: var(--accent); background: #eef3f0; }
.cd-step.tool.done .st { color: var(--ink-muted); background: #f4f2ec; }
.cd-step.tool.error .st { color: var(--danger); background: #fdf1ef; }
@keyframes coach-spin { to { transform: rotate(360deg); } }

.cd-msg.assistant .cd-bubble.streaming::after {
    content: ""; display: inline-block; width: 7px; height: 14px; margin-left: 2px; vertical-align: -2px;
    background: var(--accent); animation: coach-caret 1s steps(2) infinite;
}
@keyframes coach-caret { 50% { opacity: 0; } }
.cd-trace-toggle { font: 11.5px var(--font); color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; }
.cd-trace-toggle:hover { text-decoration: underline; text-underline-offset: 3px; }
.cd-trace { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.cd-trace[hidden] { display: none; }

/* ---------------------------------------------------------- 拖动左边缘调整宽度 */
.cd-resizer {
    position: absolute; top: 0; bottom: 0; left: -5px; width: 10px; z-index: 2;
    cursor: ew-resize; touch-action: none; background: transparent; border: 0; padding: 0;
}
.cd-resizer::before {
    content: ""; position: absolute; top: 0; bottom: 0; left: 4px; width: 2px;
    background: var(--accent); opacity: 0; transition: opacity 150ms ease;
}
.cd-resizer::after {
    content: ""; position: absolute; top: 50%; left: 2px; width: 6px; height: 36px; margin-top: -18px;
    border-radius: 3px; background: #c9cdc8; transition: background-color 150ms ease, height 150ms ease;
}
.cd-resizer:hover::before, .cd-resizer:focus-visible::before, body.coach-resizing .cd-resizer::before { opacity: .55; }
.cd-resizer:hover::after, .cd-resizer:focus-visible::after, body.coach-resizing .cd-resizer::after { background: var(--accent); height: 48px; margin-top: -24px; }
.cd-resizer:focus-visible { outline: none; }
body.coach-resizing, body.coach-resizing * { cursor: ew-resize !important; user-select: none !important; }
body.coach-resizing .coach-drawer { transition: none !important; }
body.coach-resizing .coach-drawer iframe { pointer-events: none; }
.cd-width-tip {
    position: absolute; top: 50%; left: 14px; transform: translateY(-50%); z-index: 3;
    font: 600 11px/1 var(--font); color: #fff; background: rgba(36, 40, 36, .86);
    padding: 5px 7px; border-radius: 3px; pointer-events: none; opacity: 0; transition: opacity 120ms ease;
    font-variant-numeric: tabular-nums;
}
body.coach-resizing .cd-width-tip { opacity: 1; }

/* 宽抽屉下正文别拉得太长，保持可读行宽 */
.cd-body > * { max-width: 860px; margin-left: auto; margin-right: auto; }
.cd-msg.user .cd-bubble { max-width: min(92%, 640px); }

/* 回复里的链接 */
.cd-md a { color: var(--accent); text-decoration: underline; text-decoration-color: rgba(54, 91, 75, .35); text-underline-offset: 3px; word-break: break-all; }
.cd-md a:hover { text-decoration-color: var(--accent); }
