/* ============================================================
 *  Mermaid 菱形修复渲染器 - 样式表
 *  简洁 / 无 Tailwind / 手写 CSS
 * ============================================================ */

:root {
    --bg: #f6f8fa;
    --bg-deep: #ffffff;
    --fg: #24292f;
    --fg-muted: #57606a;
    --border: #d0d7de;
    --border-light: #e1e4e8;
    --accent: #0969da;
    --accent-hover: #0550ae;
    --accent-dim: rgba(9,105,218,0.1);
    --success: #1a7f37;
    --success-bg: #dafbe1;
    --danger: #cf222e;
    --danger-bg: #ffebe9;
    --card: #ffffff;
    --shadow: 0 1px 2px rgba(31,35,40,0.04), 0 1px 3px rgba(31,35,40,0.08);
    --radius: 6px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--fg);
    min-height: 100vh;
    line-height: 1.5;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 16px;
}

/* ==================== 工具栏 ==================== */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar-label {
    font-size: 13px;
    color: var(--fg-muted);
    font-weight: 500;
}

.toolbar-select {
    font-size: 13px;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-deep);
    color: var(--fg);
    cursor: pointer;
    outline: none;
    font-family: inherit;
}
.toolbar-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

/* ==================== 按钮 ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    background: var(--bg-deep);
    color: var(--fg);
}
.btn:hover { background: var(--bg); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-secondary {
    background: var(--success-bg);
    color: var(--success);
    border-color: rgba(26,127,55,0.2);
}
.btn-secondary:hover { background: #c6f6d5; }

/* ==================== 编辑器 ==================== */
.editor-wrap {
    display: flex;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-deep);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}
.editor-wrap:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.line-nums {
    padding: 12px 0;
    min-width: 40px;
    text-align: right;
    font-family: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Courier New", monospace;
    font-size: 12px;
    line-height: 1.6;
    color: var(--fg-muted);
    background: #f6f8fa;
    user-select: none;
    overflow: hidden;
    border-right: 1px solid var(--border-light);
}
.line-nums span {
    display: block;
    padding: 0 10px 0 6px;
}

.editor-textarea {
    flex: 1;
    padding: 12px;
    font-family: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Courier New", monospace;
    font-size: 13px;
    line-height: 1.6;
    color: var(--fg);
    background: transparent;
    border: none;
    outline: none;
    resize: vertical;
    min-height: 200px;
    tab-size: 4;
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: auto;
}
.editor-textarea::placeholder { color: var(--fg-muted); opacity: 0.6; }

/* ==================== 渲染区域 ==================== */
.render-box {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-height: 160px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow);
}
.render-box svg {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 160px;
    gap: 10px;
    color: var(--fg-muted);
}
.empty-state svg { opacity: 0.4; }
.empty-state span { font-size: 13px; }

/* ==================== Toast ==================== */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    padding: 10px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    transform: translateX(120%);
    transition: transform 0.25s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 320px;
    box-shadow: var(--shadow);
}
.toast.show { transform: translateX(0); }
.toast.success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(26,127,55,0.2); }
.toast.error { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(207,34,46,0.2); }
.toast.info { background: #ddf4ff; color: var(--accent); border: 1px solid rgba(9,105,218,0.2); }

/* ==================== 响应式 ==================== */
@media (max-width: 600px) {
    .container { padding: 12px; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .toolbar-right { justify-content: flex-end; }
    .editor-textarea { min-height: 160px; font-size: 12px; }
}

/* ==================== Mermaid 原生风格覆盖 ==================== */
/* 不覆盖 Mermaid 的配色，只确保字体正确 */
.render-box .nodeLabel {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif !important;
}

/* ==================== 引导区 ==================== */
.usage-guide {
    background: #ddf4ff;
    border: 1px solid rgba(9,105,218,0.2);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 20px;
    color: #0550ae;
}
.guide-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.guide-header h3 { font-size: 16px; font-weight: 600; }
.usage-guide p { font-size: 14px; margin-bottom: 8px; }
.usage-guide ol { font-size: 13px; padding-left: 20px; line-height: 1.8; }

/* ==================== 提示词卡片 ==================== */
.prompt-card {
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 24px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}
.prompt-header {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fcfcfc;
}
.prompt-title { font-size: 14px; font-weight: 600; color: var(--fg); }
.btn-copy {
    background: var(--bg-deep);
    color: var(--accent);
    border-color: var(--accent);
}
.btn-copy:hover { background: var(--accent-dim); }

.prompt-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.prompt-item { display: flex; flex-direction: column; gap: 6px; }
.prompt-item label { font-size: 12px; color: var(--fg-muted); font-weight: 500; }

.prompt-input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 8px 10px;
    font-size: 13px;
    font-family: inherit;
    resize: none;
    line-height: 1.5;
    outline: none;
    transition: border-color 0.2s;
}
.prompt-input:focus { border-color: var(--accent); }
.prompt-input.readonly {
    background: #f9f9f9;
    color: #666;
    height: 100px;
}
#userProcessInput { height: 80px; }

/* 响应式适配 */
@media (max-width: 600px) {
    .prompt-header { flex-direction: row; }
    .prompt-input.readonly { height: 120px; }
}