/* 原稿工作台 */
.ms-workbench { position: fixed; inset: 0; z-index: 2000; display: none; flex-direction: column; background: var(--bg-main); color: var(--text-primary); }
.ms-workbench.show { display: flex; }
.ms-topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 16px; background: var(--bg-card); border-bottom: 1px solid var(--border); }
.ms-top-left, .ms-top-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ms-title { font-size: 16px; white-space: nowrap; }
.ms-select { width: auto; min-width: 160px; max-width: 280px; padding: 6px 8px; }
.ms-info, .ms-muted { color: var(--text-secondary); font-size: 12px; }
.ms-btn { background: var(--bg-hover); color: var(--text-primary); border: 1px solid var(--border-light); border-radius: var(--radius-sm); padding: 6px 12px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.ms-btn:hover { background: var(--bg-active); }
.ms-btn.primary { background: var(--primary-light); border-color: var(--primary-light); color: #fff; }
.ms-btn.primary:hover { background: var(--primary); }
.ms-btn.danger { color: var(--danger); }
.ms-open { width: auto !important; padding: 0 12px !important; font-size: 14px; }
.ms-jobbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 16px; background: var(--primary-dark); color: #fff; font-size: 13px; }

.ms-viewport { position: relative; flex: 1; overflow: hidden; cursor: grab; touch-action: none;
  background-color: var(--bg-main);
  background-image: radial-gradient(circle, var(--border-light) 1px, transparent 1.2px); }
.ms-viewport.panning { cursor: grabbing; }
.ms-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.ms-links { position: absolute; overflow: visible; pointer-events: none; }
.ms-links path { fill: none; stroke: var(--primary-light); stroke-width: 2; stroke-dasharray: 6 6; opacity: .6; }

.ms-card { position: absolute; width: 300px; height: 210px; display: flex; flex-direction: column; background: var(--bg-card); border: 1px solid var(--border-light); border-radius: var(--radius); box-shadow: var(--shadow-sm); cursor: default; user-select: none; }
.ms-card:hover { border-color: var(--primary-light); }
.ms-card.active { border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(124, 58, 237, .35); }
.ms-card-head { display: flex; gap: 8px; align-items: baseline; padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: move; }
.ms-card-num { color: var(--primary-light); font-weight: 700; font-size: 13px; white-space: nowrap; }
.ms-card-title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-card-body { flex: 1; padding: 8px 12px; font-size: 12.5px; line-height: 1.6; color: var(--text-secondary); overflow: hidden; }
.ms-card-foot { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--border); }
.ms-card-meta { font-size: 11px; color: var(--text-muted); display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.ms-mini { background: var(--bg-hover); color: var(--text-primary); border: 1px solid var(--border-light); border-radius: 6px; padding: 3px 7px; font-size: 11.5px; cursor: pointer; }
.ms-mini.primary { background: var(--primary-light); border-color: var(--primary-light); color: #fff; }
.ms-badge { font-size: 10.5px; padding: 1px 6px; border-radius: 10px; white-space: nowrap; }
.ms-badge.stale { background: rgba(245, 158, 11, .18); color: var(--warning); }
.ms-badge.edit { background: rgba(59, 130, 246, .18); color: var(--info); }
.ms-badge.ai { background: rgba(16, 185, 129, .18); color: var(--success); }
.ms-badge.run { background: var(--primary-light); color: #fff; }
.ms-badge.wait { background: var(--bg-active); color: var(--text-secondary); }

.ms-empty { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; text-align: center; padding: 16px; pointer-events: none; }
.ms-empty p { margin: 6px 0; }
.ms-controls { position: absolute; left: 16px; bottom: 16px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px; }
.ms-zoom { font-size: 12px; min-width: 42px; text-align: center; }
.ms-hint { position: absolute; right: 16px; bottom: 16px; }

.ms-editor { position: absolute; top: 0; right: 0; bottom: 0; width: min(720px, 100%); display: flex; flex-direction: column; background: var(--bg-card); border-left: 1px solid var(--border); box-shadow: var(--shadow); transform: translateX(105%); transition: transform .25s ease; z-index: 5; }
.ms-editor.show { transform: none; }
.ms-ed-head { display: flex; gap: 8px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.ms-ed-head strong { white-space: nowrap; }
.ms-ed-head input { flex: 1; }
.ms-ed-text { flex: 1; resize: none; border: 0; outline: 0; padding: 16px 20px; background: var(--bg-main); color: var(--text-primary); font-size: 15px; line-height: 1.9; font-family: inherit; }
.ms-ed-foot { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 16px; border-top: 1px solid var(--border); }
.ms-spacer { flex: 1; }

.ms-dialog { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(0, 0, 0, .55); z-index: 10; padding: 16px; }
.ms-dialog.show { display: flex; }
.ms-dialog-box { width: min(560px, 100%); max-height: 100%; overflow: auto; background: var(--bg-card); border: 1px solid var(--border-light); border-radius: var(--radius); padding: 20px; }
.ms-dialog-box h3 { margin: 0 0 14px; }
.ms-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 10px 0; font-size: 14px; }
.ms-indent { margin-left: 24px; color: var(--text-secondary); font-size: 13px; }
.ms-num { width: 80px !important; padding: 4px 6px !important; }
.ms-note { width: 100%; min-height: 70px; margin-top: 6px; resize: vertical; }
.ms-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

.ms-toast { position: absolute; left: 50%; top: 70px; transform: translate(-50%, -20px); opacity: 0; pointer-events: none; background: var(--bg-active); color: var(--text-primary); border: 1px solid var(--border-light); border-radius: var(--radius-sm); padding: 10px 16px; font-size: 13px; transition: all .2s; z-index: 20; max-width: calc(100% - 32px); }
.ms-toast.show { opacity: 1; transform: translate(-50%, 0); }
.ms-toast.err { border-color: var(--danger); color: var(--danger); }

@media (max-width: 640px) {
  .ms-hint { display: none; }
  .ms-editor { width: 100%; }
}

/* 书架 */
.shelf-body { flex: 1; overflow: auto; padding: 20px 16px 40px; }
.shelf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; max-width: 1400px; margin: 0 auto; }
.shelf-card { display: flex; flex-direction: column; gap: 10px; background: var(--bg-card); border: 1px solid var(--border-light); border-radius: var(--radius); padding: 16px; cursor: pointer; position: relative; }
.shelf-card:hover { border-color: var(--primary-light); }
.shelf-card.current { border-color: var(--primary-light); box-shadow: 0 0 0 2px rgba(124, 58, 237, .3); }
.shelf-card .shelf-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.shelf-cover { position: absolute; top: 16px; right: 16px; width: 44px; height: 58px; border-radius: 4px 8px 8px 4px; background: linear-gradient(135deg, var(--primary-light), var(--primary-dark)); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; }
.shelf-title { font-size: 17px; font-weight: 700; padding-right: 56px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shelf-bar { height: 6px; background: var(--bg-active); border-radius: 3px; overflow: hidden; margin: 4px 56px 4px 0; }
.shelf-bar div { height: 100%; background: var(--primary-light); }
.shelf-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.shelf-new { align-items: center; justify-content: center; min-height: 190px; border-style: dashed; color: var(--text-secondary); font-size: 15px; }
.shelf-plus { font-size: 40px; line-height: 1; color: var(--primary-light); }
@media (max-width: 640px) { .shelf-grid { grid-template-columns: 1fr; } }
