:root {
    --bg: #0a0a0f;
    --bg-card: rgba(22, 22, 30, 0.85);
    --border: rgba(255, 122, 26, 0.18);
    --orange: #ff7a1a;
    --orange-light: #ffb26b;
    --orange-glow: rgba(255, 122, 26, 0.35);
    --text: #e8e6e3;
    --text-dim: #9a958e;
    --green: #34d399;
    --red: #f87171;
    --mono: 'Consolas', 'JetBrains Mono', 'Courier New', monospace;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===== 背景氛围层 ===== */
.bg-grid {
    position: fixed; inset: 0; z-index: -2;
    background-image: linear-gradient(rgba(255,122,26,0.04) 1px, transparent 1px),
                      linear-gradient(90deg, rgba(255,122,26,0.04) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, black 30%, transparent 100%);
}
.bg-orb { position: fixed; z-index: -1; border-radius: 50%; filter: blur(120px); opacity: 0.5; pointer-events: none; }
.orb1 { width: 480px; height: 480px; top: -160px; left: -120px; background: radial-gradient(circle, rgba(255,122,26,0.35), transparent 70%); animation: drift 14s ease-in-out infinite alternate; }
.orb2 { width: 420px; height: 420px; top: 30%; right: -160px; background: radial-gradient(circle, rgba(255,157,69,0.22), transparent 70%); animation: drift 18s ease-in-out infinite alternate-reverse; }
@keyframes drift { from { transform: translate(0,0) } to { transform: translate(40px, 30px) } }

/* ===== 顶栏 ===== */
.topbar {
    position: sticky; top: 0; z-index: 50;
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 32px;
    background: rgba(10, 10, 15, 0.8);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
}
.logo { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 17px; letter-spacing: 1px; color: var(--text); text-decoration: none; }
.logo .mark {
    width: 34px; height: 34px; border-radius: 10px;
    background: linear-gradient(135deg, var(--orange), #ff9d45);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; box-shadow: 0 0 18px var(--orange-glow);
}
.logo small { color: var(--text-dim); font-weight: 400; font-size: 12px; letter-spacing: 2px; display: block; }
.status-bar { display: flex; align-items: center; gap: 14px; }
.status-pill {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: 12px; color: #8ee6c0; letter-spacing: 1px;
    border: 1px dashed rgba(52, 211, 153, 0.35);
    padding: 7px 16px; border-radius: 999px; background: rgba(52, 211, 153, 0.05);
}
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; box-shadow: 0 0 0 0 rgba(52,211,153,0.5) } 50% { opacity: 0.6; box-shadow: 0 0 0 6px rgba(52,211,153,0) } }

.ghost-btn {
    background: transparent; border: 1px solid var(--border); color: var(--orange-light);
    padding: 8px 18px; border-radius: 10px; font-size: 13px; cursor: pointer; letter-spacing: 1px;
    transition: all .2s;
}
.ghost-btn:hover { border-color: var(--orange); box-shadow: 0 0 14px var(--orange-glow); }

/* ===== 页头 ===== */
.hero { text-align: center; padding: 48px 24px 10px; max-width: 860px; margin: 0 auto; }
.hero .tag {
    display: inline-block; font-size: 12px; letter-spacing: 3px; color: var(--orange-light);
    border: 1px solid var(--border); border-radius: 999px; padding: 6px 16px; margin-bottom: 16px;
    background: rgba(255, 122, 26, 0.06);
}
.hero h1 { font-size: clamp(26px, 4.5vw, 40px); font-weight: 800; }
.hero h1 .grad {
    background: linear-gradient(92deg, var(--orange) 10%, #ffcf9e 50%, var(--orange) 90%);
    -webkit-background-clip: text; background-clip: text; color: transparent;
    margin-left: 10px;
}
.hero p { color: var(--text-dim); font-size: 14px; margin-top: 12px; letter-spacing: 1px; }

/* ===== Tab ===== */
.tabs { display: flex; justify-content: center; gap: 14px; margin: 26px 0 20px; }
.tab {
    padding: 11px 30px; border-radius: 12px; cursor: pointer;
    background: rgba(22, 22, 30, 0.6); border: 1px solid rgba(255,255,255,0.08);
    color: var(--text-dim); font-size: 14px; letter-spacing: 2px; transition: all .25s;
}
.tab:hover { color: var(--text); border-color: rgba(255,255,255,0.2); }
.tab.active {
    color: #14090a; font-weight: 700;
    background: linear-gradient(92deg, #ff8c2e, var(--orange));
    border-color: transparent; box-shadow: 0 6px 24px var(--orange-glow);
}

/* ===== 面板通用 ===== */
.panel { max-width: 1280px; margin: 0 auto; padding: 0 24px 40px; animation: fadeUp .35s ease; }
.panel.hidden { display: none; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px) } to { opacity: 1; transform: none } }

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    backdrop-filter: blur(10px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    overflow: hidden;
}
.card-head {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 18px; border-bottom: 1px solid rgba(255,255,255,0.05);
    font-size: 14px; font-weight: 600;
}
.card-head .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 10px var(--orange-glow); }
.card-head .sub { margin-left: auto; font-size: 11px; color: var(--text-dim); font-weight: 400; letter-spacing: 1px; }
.empty-tip { padding: 22px; text-align: center; color: var(--text-dim); font-size: 13px; }

/* ===== 提示词布局 ===== */
.prompt-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; }
@media (max-width: 960px) { .prompt-layout { grid-template-columns: 1fr; } }

.agent-items { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.agent-item {
    padding: 14px 16px; border-radius: 12px; cursor: pointer;
    background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.07);
    transition: all .2s;
}
.agent-item:hover { border-color: rgba(255,255,255,0.25); transform: translateX(3px); }
.agent-item.selected {
    border-color: var(--orange);
    background: rgba(255,122,26,0.08);
    box-shadow: 0 0 18px rgba(255,122,26,0.15);
}
.agent-item .a-name { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.agent-item .a-code { font-family: var(--mono); font-size: 11px; color: var(--orange-light); letter-spacing: 1px; margin-top: 4px; }
.agent-item .a-desc { font-size: 12px; color: var(--text-dim); margin-top: 6px; line-height: 1.6; }
.agent-item .a-badge {
    font-size: 10px; padding: 2px 8px; border-radius: 999px;
    background: rgba(52,211,153,0.12); color: #8ee6c0; border: 1px solid rgba(52,211,153,0.3);
}

.editor-wrap { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.editor-body { padding: 16px 18px 18px; }
#promptEditor {
    width: 100%; min-height: 320px; resize: vertical;
    background: #060609; color: var(--text);
    border: 1px solid rgba(255,255,255,0.08); border-radius: 12px;
    padding: 16px; font-family: var(--mono); font-size: 13px; line-height: 1.8;
    outline: none; transition: border-color .2s, box-shadow .2s;
}
#promptEditor:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255,122,26,0.12); }

.editor-meta { display: flex; gap: 12px; margin-top: 14px; align-items: end; flex-wrap: wrap; }
.meta-field { display: flex; flex-direction: column; gap: 6px; }
.meta-field.grow { flex: 1; min-width: 200px; }
.meta-field label { font-size: 11px; color: var(--text-dim); letter-spacing: 1px; }
.meta-field input {
    background: rgba(0,0,0,0.35); color: var(--text);
    border: 1px solid rgba(255,255,255,0.1); border-radius: 10px;
    padding: 10px 12px; font-size: 13px; outline: none; transition: all .2s;
}
.meta-field input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255,122,26,0.12); }

.cta {
    padding: 11px 26px; border: none; border-radius: 10px; cursor: pointer;
    font-size: 14px; font-weight: 700; letter-spacing: 2px; color: #14090a;
    background: linear-gradient(92deg, #ff8c2e, var(--orange));
    box-shadow: 0 6px 20px var(--orange-glow);
    transition: transform .15s, box-shadow .2s;
    white-space: nowrap;
}
.cta:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 10px 30px var(--orange-glow); }
.cta:disabled { opacity: 0.45; cursor: not-allowed; }

/* ===== 版本时间线 ===== */
.version-timeline { padding: 18px 18px 18px 26px; max-height: 300px; overflow-y: auto; position: relative; }
.version-timeline::before {
    content: ''; position: absolute; left: 32px; top: 20px; bottom: 20px; width: 1px;
    background: linear-gradient(180deg, var(--orange-glow), rgba(255,255,255,0.05));
}
.v-item {
    position: relative; padding: 10px 14px 10px 26px; margin-bottom: 8px;
    border-radius: 10px; cursor: pointer; transition: all .2s;
    border: 1px solid transparent;
}
.v-item::before {
    content: ''; position: absolute; left: -1px; top: 16px;
    width: 9px; height: 9px; border-radius: 50%;
    background: #3a3a45; border: 2px solid var(--bg);
}
.v-item:hover { background: rgba(255,122,26,0.06); border-color: var(--border); }
.v-item.current::before { background: var(--orange); box-shadow: 0 0 10px var(--orange-glow); }
.v-item .v-head { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.v-item .v-ver { font-weight: 700; font-family: var(--mono); color: var(--orange-light); }
.v-item .v-cur-badge {
    font-size: 10px; padding: 2px 8px; border-radius: 999px;
    background: rgba(52,211,153,0.12); color: #8ee6c0; border: 1px solid rgba(52,211,153,0.3);
}
.v-item .v-time { margin-left: auto; font-size: 11px; color: var(--text-dim); font-family: var(--mono); }
.v-item .v-log { font-size: 12px; color: var(--text-dim); margin-top: 4px; line-height: 1.6; }
.v-item .v-by { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

/* ===== 工具表格 ===== */
.mini-btn {
    margin-left: 14px; padding: 6px 16px; border-radius: 8px; cursor: pointer;
    border: 1px solid var(--border); background: rgba(255,122,26,0.08);
    color: var(--orange-light); font-size: 12px; letter-spacing: 1px; transition: all .2s;
}
.mini-btn:hover { border-color: var(--orange); box-shadow: 0 0 12px var(--orange-glow); }
.tool-table-wrap { overflow-x: auto; overflow-y: auto; max-height: 268px; }
.tool-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tool-table th {
    text-align: left; padding: 12px 16px; color: var(--text-dim);
    font-size: 11px; letter-spacing: 2px; font-weight: 600;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    background: rgba(10,10,15,0.95);
    position: sticky; top: 0; z-index: 2;
}
.tool-table td { padding: 14px 16px; border-bottom: 1px solid rgba(255,255,255,0.04); vertical-align: middle; }
.tool-table tbody tr { transition: background .2s; }
.tool-table tbody tr:hover { background: rgba(255,122,26,0.04); }
.tool-table .code { font-family: var(--mono); color: var(--orange-light); font-size: 12px; letter-spacing: 0.5px; }
.tool-table .desc { color: var(--text-dim); font-size: 12px; line-height: 1.7; max-width: 460px; }
.tool-table tr.disabled td { opacity: 0.45; }

/* ===== 开关 ===== */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
    position: absolute; inset: 0; cursor: pointer; border-radius: 999px;
    background: rgba(255,255,255,0.12); transition: all .25s;
}
.switch .slider::before {
    content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%;
    left: 3px; top: 3px; background: #cfcfcf; transition: all .25s;
}
.switch input:checked + .slider { background: rgba(255,122,26,0.35); box-shadow: inset 0 0 8px rgba(255,122,26,0.3); }
.switch input:checked + .slider::before { transform: translateX(20px); background: var(--orange); box-shadow: 0 0 8px var(--orange-glow); }

.link-btn {
    background: none; border: none; color: var(--orange-light); cursor: pointer;
    font-size: 12px; letter-spacing: 1px; padding: 4px 8px; border-radius: 6px; transition: all .2s;
}
.link-btn:hover { background: rgba(255,122,26,0.1); }

/* ===== 弹窗 ===== */
.modal-mask {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(5, 5, 8, 0.7); backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center; padding: 20px;
    animation: fadeIn .2s ease;
}
.modal-mask.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
.modal {
    width: 560px; max-width: 94vw; max-height: 88vh; overflow-y: auto;
    background: #14141c; border: 1px solid var(--border); border-radius: 18px;
    padding: 26px 28px; box-shadow: 0 24px 80px rgba(0,0,0,0.7);
    animation: slideUp .25s ease;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(24px) } to { opacity: 1; transform: none } }
.modal-title {
    font-size: 17px; font-weight: 700; margin-bottom: 20px;
    background: linear-gradient(92deg, var(--orange), #ffcf9e);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.modal-field { margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.modal-field.row { flex-direction: row; align-items: center; gap: 14px; }
.modal-field label { font-size: 12px; color: var(--text-dim); letter-spacing: 1px; }
.modal-field input, .modal-field textarea {
    background: rgba(0,0,0,0.35); color: var(--text);
    border: 1px solid rgba(255,255,255,0.1); border-radius: 10px;
    padding: 10px 12px; font-size: 13px; outline: none; font-family: inherit;
    transition: all .2s; resize: vertical;
}
.modal-field input:focus, .modal-field textarea:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255,122,26,0.12); }
.modal-field input:read-only { opacity: 0.55; cursor: not-allowed; }
.field-hint { font-size: 11px; color: var(--text-dim); }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 22px; }

/* ===== Toast ===== */
.toast-wrap { position: fixed; top: 76px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
    min-width: 240px; max-width: 360px; padding: 13px 18px;
    border-radius: 12px; font-size: 13px; letter-spacing: 0.5px;
    background: rgba(20, 20, 28, 0.95); border: 1px solid var(--border);
    box-shadow: 0 12px 40px rgba(0,0,0,0.6);
    animation: toastIn .3s ease;
}
.toast.ok { border-color: rgba(52,211,153,0.4); color: #8ee6c0; }
.toast.err { border-color: rgba(248,113,113,0.45); color: #fca5a5; }
.toast.out { animation: toastOut .3s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(30px) } to { opacity: 1; transform: none } }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px) } }

footer {
    text-align: center; padding: 26px 16px 34px;
    color: var(--text-dim); font-size: 12px; letter-spacing: 1px;
}

/* ===== 只读模式（未设置 ADMIN_MODIFY=true） ===== */
body.readonly-mode .write-only { display: none !important; }
body.readonly-mode .switch input { pointer-events: none; }
body.readonly-mode .switch { opacity: 0.45; }
body.readonly-mode .tool-table .link-btn { visibility: hidden; }
body.readonly-mode #promptEditor { opacity: 0.75; }
.readonly-banner {
    display: inline-block; margin-top: 14px;
    font-size: 12px; letter-spacing: 1px; color: #fca5a5;
    border: 1px dashed rgba(248, 113, 113, 0.45);
    background: rgba(248, 113, 113, 0.06);
    border-radius: 10px; padding: 8px 18px;
}
.readonly-banner.hidden { display: none; }

/* ===== 契约治理理念注脚（工具契约库旁展示） ===== */
.contract-note {
    margin: 14px 18px 0; padding: 10px 14px; border-radius: 10px;
    border-left: 2px solid var(--orange);
    background: rgba(255,122,26,0.05);
    font-size: 12px; color: var(--text-dim); line-height: 1.8; letter-spacing: 0.5px;
}
.contract-note b { color: var(--orange-light); font-weight: 600; }

/* ===== 工具契约库表格列宽（收拢原页面 th 上的内联宽度） ===== */
.tool-table .col-id { width: 70px; }
.tool-table .col-code { width: 220px; }
.tool-table .col-name { width: 160px; }
.tool-table .col-status { width: 90px; }
.tool-table .col-action { width: 90px; }

/* ghost 按钮作链接使用时去掉下划线，视觉保持一致 */
a.ghost-btn { text-decoration: none; }

/* ===== 调试台 · 话术沙箱覆盖（区明 / 彩彻共用） ===== */
.prompt-lab {
    margin-top: 18px;
    border: 1px solid rgba(255,122,26,0.28);
    box-shadow: 0 0 0 1px rgba(255,122,26,0.06), 0 12px 40px rgba(0,0,0,0.45);
}
.prompt-lab .prompt-lab-body {
    padding: 16px 18px 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.prompt-lab .pl-lead {
    font-size: 12px;
    color: var(--text-dim);
    line-height: 1.6;
}
.prompt-lab .pl-lead code {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--orange-light);
}
.prompt-lab .pl-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}
.prompt-lab .pl-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(0,0,0,0.28);
    font-size: 13px;
    color: var(--text-dim);
    cursor: pointer;
    user-select: none;
}
.prompt-lab .pl-toggle input {
    width: 16px;
    height: 16px;
    accent-color: var(--orange);
}
.prompt-lab.is-on .pl-toggle {
    color: var(--orange-light);
    border-color: rgba(255,122,26,0.45);
    background: rgba(255,122,26,0.1);
}
.prompt-lab .pl-badge {
    font-size: 11px;
    letter-spacing: 1px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px dashed rgba(255,255,255,0.12);
    color: var(--text-dim);
}
.prompt-lab.is-on .pl-badge {
    color: #8ee6c0;
    border-color: rgba(52,211,153,0.4);
    background: rgba(52,211,153,0.08);
}
.prompt-lab .pl-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
@media (max-width: 860px) {
    .prompt-lab .pl-grid { grid-template-columns: 1fr; }
}
.prompt-lab .pl-pane {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}
.prompt-lab .pl-pane label {
    font-size: 12px;
    color: var(--text-dim);
    letter-spacing: 1px;
}
.prompt-lab .pl-pane .pl-meta {
    font-size: 11px;
    color: #6a6560;
    font-family: var(--mono);
}
.prompt-lab .pl-pane textarea {
    width: 100%;
    min-height: 220px;
    resize: vertical;
    background: #060609;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    color: var(--text);
    padding: 12px 14px;
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.55;
}
.prompt-lab .pl-pane textarea:focus {
    outline: none;
    border-color: var(--orange);
    box-shadow: 0 0 0 2px rgba(255,122,26,0.15);
}
.prompt-lab .pl-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
